File tree Expand file tree Collapse file tree 3 files changed +16
-2
lines changed Expand file tree Collapse file tree 3 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ class Psbt {
152
152
}
153
153
clone ( ) {
154
154
// TODO: more efficient cloning
155
- const res = this . constructor . fromBuffer ( this . data . toBuffer ( ) , this . opts ) ;
155
+ const res = this . constructor . fromBuffer ( this . toBuffer ( ) , this . opts ) ;
156
156
res . opts = JSON . parse ( JSON . stringify ( this . opts ) ) ;
157
157
return res ;
158
158
}
Original file line number Diff line number Diff line change @@ -896,6 +896,20 @@ describe(`Psbt`, () => {
896
896
assert . notStrictEqual ( clone . toBase64 ( ) , notAClone . toBase64 ( ) ) ;
897
897
assert . strictEqual ( psbt . toBase64 ( ) , notAClone . toBase64 ( ) ) ;
898
898
} ) ;
899
+
900
+ it ( 'Should use the proper toBuffer method when cloning' , ( ) => {
901
+ class PsbtSubclass extends Psbt {
902
+ toBuffer ( ) : Buffer {
903
+ super . setLocktime ( 1000 ) ;
904
+ return super . toBuffer ( ) ;
905
+ }
906
+ }
907
+ const psbt = new PsbtSubclass ( ) ;
908
+ assert . strictEqual ( psbt . extractTransaction ( ) . locktime , 0 ) ;
909
+
910
+ const clone = psbt . clone ( ) ;
911
+ assert . strictEqual ( clone . extractTransaction ( ) . locktime , 1000 ) ;
912
+ } ) ;
899
913
} ) ;
900
914
901
915
describe ( 'setMaximumFeeRate' , ( ) => {
Original file line number Diff line number Diff line change @@ -217,7 +217,7 @@ export class Psbt {
217
217
clone ( ) : Psbt {
218
218
// TODO: more efficient cloning
219
219
const res = ( this . constructor as typeof Psbt ) . fromBuffer (
220
- this . data . toBuffer ( ) ,
220
+ this . toBuffer ( ) ,
221
221
this . opts ,
222
222
) ;
223
223
res . opts = JSON . parse ( JSON . stringify ( this . opts ) ) ;
You can’t perform that action at this time.
0 commit comments