@@ -349,6 +349,7 @@ const Psbt = function (config) {
349
349
350
350
const spendableUtxos = ownedUtxos . filter ( utxo => ! selectedUtxos . some ( ownedUtxo => ownedUtxo . txid === utxo . txid ) )
351
351
. filter ( ( x ) => x . status . confirmed )
352
+ . filter ( ( x ) => x . value > 10000 )
352
353
. filter ( utxo => ! utxo . inscriptionId )
353
354
. sort ( ( a , b ) => b . value - a . value ) ;
354
355
@@ -391,6 +392,13 @@ const Psbt = function (config) {
391
392
const nonOrdinals = inputs . filter ( utxo => ! utxo . inscriptionId ) ;
392
393
const spendableAmount = nonOrdinals . reduce ( ( acc , utxo ) => acc + utxo . value , 0 ) ;
393
394
395
+ const metadata = {
396
+ inputs : inputs . map ( ( utxo , index ) => ( {
397
+ index,
398
+ type : utxo . inscriptionId ? 'ordinal' : 'cardinal' ,
399
+ } ) ) ,
400
+ } ;
401
+
394
402
for ( const utxo of ordinals ) {
395
403
psbt . addOutput ( {
396
404
address : destinationBtcAddress ,
@@ -444,7 +452,6 @@ const Psbt = function (config) {
444
452
}
445
453
} ) ;
446
454
447
- debugger ;
448
455
const psbtOutputs = psbt . data . inputs . map ( ( _ , index ) => {
449
456
// @ts -ignore
450
457
const sigHash = psbt . __CACHE . __TX . hashForWitnessV1 (
@@ -472,18 +479,16 @@ const Psbt = function (config) {
472
479
const final_fee = final_signed_psbt . getFee ( ) ;
473
480
const final_tx = final_signed_psbt . extractTransaction ( ) ;
474
481
const final_vbytes = final_tx . virtualSize ( ) ;
475
- const final_hex = final_tx . toHex ( ) ;
476
482
const final_fee_rate = ( final_fee / final_vbytes ) . toFixed ( 1 ) ;
477
- console . log ( `Final fee rate of signed psbt is ~${ final_fee_rate } sat/vbyte` ) ;
478
- console . log ( 'final_signed_psbt' , final_signed_psbt . toHex ( ) ) ;
479
-
480
- debugger ;
483
+ const final_signed_hex_psbt = final_signed_psbt . toHex ( ) ;
484
+ console . log ( 'final_signed_hex_psbt' , final_signed_hex_psbt ) ;
481
485
482
486
return {
483
- final_hex,
484
487
final_fee_rate,
485
488
final_fee,
489
+ final_signed_hex_psbt,
486
490
final_signed_psbt,
491
+ metadata
487
492
} ;
488
493
} ,
489
494
0 commit comments