@@ -29,6 +29,10 @@ function toUtxoPsbt(psbt: Psbt | Buffer | Uint8Array) {
29
29
throw new Error ( "Invalid input" ) ;
30
30
}
31
31
32
+ function assertEqualBuffer ( a : Buffer | Uint8Array , b : Buffer | Uint8Array , message ?: string ) {
33
+ assert . strictEqual ( Buffer . from ( a ) . toString ( "hex" ) , Buffer . from ( b ) . toString ( "hex" ) , message ) ;
34
+ }
35
+
32
36
const fixtures = getPsbtFixtures ( rootWalletKeys ) ;
33
37
34
38
function describeUpdateInputWithDescriptor (
@@ -47,20 +51,20 @@ function describeUpdateInputWithDescriptor(
47
51
const descriptorStr = getDescriptorForScriptType ( rootWalletKeys , scriptType , "internal" ) ;
48
52
const index = 0 ;
49
53
const descriptor = Descriptor . fromString ( descriptorStr , "derivable" ) ;
50
- const wrappedPsbt = toWrappedPsbt ( toPsbtWithPrevOutOnly ( psbt ) ) ;
54
+ const wrappedPsbt = toWrappedPsbt ( psbt ) ;
51
55
wrappedPsbt . updateInputWithDescriptor ( 0 , descriptor . atDerivationIndex ( index ) ) ;
52
56
const updatedPsbt = toUtxoPsbt ( wrappedPsbt ) ;
53
57
updatedPsbt . signAllInputsHD ( rootWalletKeys . triple [ 0 ] ) ;
54
58
updatedPsbt . signAllInputsHD ( rootWalletKeys . triple [ 2 ] ) ;
59
+ const wrappedSignedPsbt = toWrappedPsbt ( updatedPsbt ) ;
55
60
updatedPsbt . finalizeAllInputs ( ) ;
56
- assert . deepStrictEqual (
57
- fullSignedFixture . psbt
58
- . clone ( )
59
- . finalizeAllInputs ( )
60
- . extractTransaction ( )
61
- . toBuffer ( )
62
- . toString ( "hex" ) ,
63
- updatedPsbt . extractTransaction ( ) . toBuffer ( ) . toString ( "hex" ) ,
61
+ wrappedSignedPsbt . finalize ( ) ;
62
+
63
+ assertEqualBuffer ( updatedPsbt . toBuffer ( ) , wrappedSignedPsbt . serialize ( ) ) ;
64
+
65
+ assertEqualBuffer (
66
+ fullSignedFixture . psbt . clone ( ) . finalizeAllInputs ( ) . extractTransaction ( ) . toBuffer ( ) ,
67
+ updatedPsbt . extractTransaction ( ) . toBuffer ( ) ,
64
68
) ;
65
69
} ) ;
66
70
} ) ;
@@ -77,11 +81,11 @@ fixtures.forEach(({ psbt, scriptType, stage }) => {
77
81
} ) ;
78
82
79
83
it ( "should map to same hex" , function ( ) {
80
- assert . strictEqual ( buf . toString ( "hex" ) , Buffer . from ( wrappedPsbt . serialize ( ) ) . toString ( "hex" ) ) ;
84
+ assertEqualBuffer ( buf , wrappedPsbt . serialize ( ) ) ;
81
85
} ) ;
82
86
83
87
it ( "should round-trip utxolib -> ms -> utxolib" , function ( ) {
84
- assert . strictEqual ( buf . toString ( "hex" ) , toUtxoPsbt ( wrappedPsbt ) . toBuffer ( ) . toString ( "hex" ) ) ;
88
+ assertEqualBuffer ( buf , toUtxoPsbt ( wrappedPsbt ) . toBuffer ( ) ) ;
85
89
} ) ;
86
90
87
91
if ( stage === "bare" ) {
0 commit comments