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 {
152152 }
153153 clone ( ) {
154154 // 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 ) ;
156156 res . opts = JSON . parse ( JSON . stringify ( this . opts ) ) ;
157157 return res ;
158158 }
Original file line number Diff line number Diff line change @@ -896,6 +896,20 @@ describe(`Psbt`, () => {
896896 assert . notStrictEqual ( clone . toBase64 ( ) , notAClone . toBase64 ( ) ) ;
897897 assert . strictEqual ( psbt . toBase64 ( ) , notAClone . toBase64 ( ) ) ;
898898 } ) ;
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+ } ) ;
899913 } ) ;
900914
901915 describe ( 'setMaximumFeeRate' , ( ) => {
Original file line number Diff line number Diff line change @@ -217,7 +217,7 @@ export class Psbt {
217217 clone ( ) : Psbt {
218218 // TODO: more efficient cloning
219219 const res = ( this . constructor as typeof Psbt ) . fromBuffer (
220- this . data . toBuffer ( ) ,
220+ this . toBuffer ( ) ,
221221 this . opts ,
222222 ) ;
223223 res . opts = JSON . parse ( JSON . stringify ( this . opts ) ) ;
You can’t perform that action at this time.
0 commit comments