Add getters for Psbt.{txVersion,txLocktime,txInputs,txOutputs}
This commit is contained in:
parent
c95e15de01
commit
854c601342
3 changed files with 43 additions and 0 deletions
src
17
src/psbt.js
17
src/psbt.js
|
@ -97,6 +97,18 @@ class Psbt {
|
|||
get inputCount() {
|
||||
return this.data.inputs.length;
|
||||
}
|
||||
get txVersion() {
|
||||
return this.__CACHE.__TX.version;
|
||||
}
|
||||
get txLocktime() {
|
||||
return this.__CACHE.__TX.locktime;
|
||||
}
|
||||
get txInputs() {
|
||||
return deepClone(this.__CACHE.__TX.ins);
|
||||
}
|
||||
get txOutputs() {
|
||||
return deepClone(this.__CACHE.__TX.outs);
|
||||
}
|
||||
combine(...those) {
|
||||
this.data.combine(...those.map(o => o.data));
|
||||
return this;
|
||||
|
@ -579,6 +591,11 @@ class PsbtTransaction {
|
|||
return this.tx.toBuffer();
|
||||
}
|
||||
}
|
||||
function deepClone(obj) {
|
||||
return JSON.parse(JSON.stringify(obj), (_, value) =>
|
||||
value.type === 'Buffer' ? Buffer.from(value.data) : value,
|
||||
);
|
||||
}
|
||||
function canFinalize(input, script, scriptType) {
|
||||
switch (scriptType) {
|
||||
case 'pubkey':
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue