Skip to content

Commit 458c6e7

Browse files
Merge pull request #50 from BitGo/psbt-clone
chore(psbt): psbt clone uses correct fromBuffer
2 parents 1562deb + e70bdea commit 458c6e7

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

package-lock.json

Lines changed: 3 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
"bs58check": "^2.1.2",
5555
"create-hash": "^1.1.0",
5656
"fastpriorityqueue": "^0.7.1",
57+
"json5": "^2.2.3",
5758
"ripemd160": "^2.0.2",
5859
"typeforce": "^1.11.3",
5960
"varuint-bitcoin": "^1.1.2",

src/psbt.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class Psbt {
152152
}
153153
clone() {
154154
// TODO: more efficient cloning
155-
const res = Psbt.fromBuffer(this.data.toBuffer());
155+
const res = this.constructor.fromBuffer(this.data.toBuffer(), this.opts);
156156
res.opts = JSON.parse(JSON.stringify(this.opts));
157157
return res;
158158
}

ts_src/psbt.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,10 @@ export class Psbt {
216216

217217
clone(): Psbt {
218218
// TODO: more efficient cloning
219-
const res = Psbt.fromBuffer(this.data.toBuffer());
219+
const res = (this.constructor as typeof Psbt).fromBuffer(
220+
this.data.toBuffer(),
221+
this.opts,
222+
);
220223
res.opts = JSON.parse(JSON.stringify(this.opts));
221224
return res;
222225
}

0 commit comments

Comments
 (0)