Fix addInput and addOuput for Psbt

This commit is contained in:
junderw 2019-08-07 17:37:52 +09:00
commit 139567d6c5
No known key found for this signature in database
GPG key ID: B256185D3A971908
2 changed files with 18 additions and 9 deletions
ts_src

View file

@ -6,6 +6,7 @@ import {
PsbtGlobalUpdate,
PsbtInput,
PsbtInputUpdate,
PsbtOutput,
PsbtOutputUpdate,
Transaction as ITransaction,
TransactionFromBuffer,
@ -176,12 +177,12 @@ export class Psbt {
return this;
}
addInputs(inputDatas: TransactionInput[]): this {
addInputs(inputDatas: PsbtInputExtended[]): this {
inputDatas.forEach(inputData => this.addInput(inputData));
return this;
}
addInput(inputData: TransactionInput): this {
addInput(inputData: PsbtInputExtended): this {
checkInputsForPartialSig(this.data.inputs, 'addInput');
const c = this.__CACHE;
this.data.addInput(inputData);
@ -198,12 +199,12 @@ export class Psbt {
return this;
}
addOutputs(outputDatas: TransactionOutput[]): this {
addOutputs(outputDatas: PsbtOutputExtended[]): this {
outputDatas.forEach(outputData => this.addOutput(outputData));
return this;
}
addOutput(outputData: TransactionOutput): this {
addOutput(outputData: PsbtOutputExtended): this {
checkInputsForPartialSig(this.data.inputs, 'addOutput');
const { address } = outputData as any;
if (typeof address === 'string') {
@ -622,6 +623,10 @@ interface PsbtOpts {
maximumFeeRate: number;
}
interface PsbtInputExtended extends PsbtInput, TransactionInput {}
interface PsbtOutputExtended extends PsbtOutput, TransactionOutput {}
interface HDSignerBase {
/**
* DER format compressed publicKey buffer