diff --git a/package.json b/package.json index d8071a5..30d916a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nosft-core", - "version": "2.5.2", + "version": "2.5.1", "private": false, "main": "./dist/index.js", "module": "./dist/index.mjs", diff --git a/src/app/psbt.ts b/src/app/psbt.ts index 752f1ec..c39b172 100644 --- a/src/app/psbt.ts +++ b/src/app/psbt.ts @@ -349,6 +349,7 @@ const Psbt = function (config) { const spendableUtxos = ownedUtxos.filter(utxo => !selectedUtxos.some(ownedUtxo => ownedUtxo.txid === utxo.txid)) .filter((x) => x.status.confirmed) + .filter((x) => x.value > 10000) .filter(utxo => !utxo.inscriptionId) .sort((a, b) => b.value - a.value); @@ -391,6 +392,13 @@ const Psbt = function (config) { const nonOrdinals = inputs.filter(utxo => !utxo.inscriptionId); const spendableAmount = nonOrdinals.reduce((acc, utxo) => acc + utxo.value, 0); + const metadata = { + inputs: inputs.map((utxo, index) => ({ + index, + type: utxo.inscriptionId ? 'ordinal' : 'cardinal', + })), + }; + for (const utxo of ordinals) { psbt.addOutput({ address: destinationBtcAddress, @@ -444,7 +452,6 @@ const Psbt = function (config) { } }); - debugger; const psbtOutputs = psbt.data.inputs.map((_, index) => { // @ts-ignore const sigHash = psbt.__CACHE.__TX.hashForWitnessV1( @@ -472,18 +479,16 @@ const Psbt = function (config) { const final_fee = final_signed_psbt.getFee(); const final_tx = final_signed_psbt.extractTransaction(); const final_vbytes = final_tx.virtualSize(); - const final_hex = final_tx.toHex(); const final_fee_rate = (final_fee / final_vbytes).toFixed(1); - console.log(`Final fee rate of signed psbt is ~${final_fee_rate} sat/vbyte`); - console.log('final_signed_psbt', final_signed_psbt.toHex()); - - debugger; + const final_signed_hex_psbt = final_signed_psbt.toHex(); + console.log('final_signed_hex_psbt', final_signed_hex_psbt); return { - final_hex, final_fee_rate, final_fee, + final_signed_hex_psbt, final_signed_psbt, + metadata }; },