Add clone, addInputs, addOutputs
This commit is contained in:
parent
b8c341dea0
commit
01c7ac39b6
4 changed files with 221 additions and 152 deletions
ts_src
|
@ -130,6 +130,13 @@ export class Psbt extends PsbtBase {
|
|||
return this.inputs.length;
|
||||
}
|
||||
|
||||
clone(): Psbt {
|
||||
// TODO: more efficient cloning
|
||||
const res = Psbt.fromBuffer(this.toBuffer());
|
||||
res.opts = JSON.parse(JSON.stringify(this.opts));
|
||||
return res;
|
||||
}
|
||||
|
||||
setMaximumFeeRate(satoshiPerByte: number): void {
|
||||
check32Bit(satoshiPerByte); // 42.9 BTC per byte IS excessive... so throw
|
||||
this.opts.maximumFeeRate = satoshiPerByte;
|
||||
|
@ -168,6 +175,11 @@ export class Psbt extends PsbtBase {
|
|||
return this;
|
||||
}
|
||||
|
||||
addInputs(inputDatas: TransactionInput[]): this {
|
||||
inputDatas.forEach(inputData => this.addInput(inputData));
|
||||
return this;
|
||||
}
|
||||
|
||||
addInput(inputData: TransactionInput): this {
|
||||
checkInputsForPartialSig(this.inputs, 'addInput');
|
||||
const c = this.__CACHE;
|
||||
|
@ -178,6 +190,11 @@ export class Psbt extends PsbtBase {
|
|||
return this;
|
||||
}
|
||||
|
||||
addOutputs(outputDatas: TransactionOutput[]): this {
|
||||
outputDatas.forEach(outputData => this.addOutput(outputData));
|
||||
return this;
|
||||
}
|
||||
|
||||
addOutput(outputData: TransactionOutput): this {
|
||||
checkInputsForPartialSig(this.inputs, 'addOutput');
|
||||
const { address } = outputData as any;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue