Export PSBT getter types
This commit is contained in:
parent
361ea7c098
commit
de0bbf51e5
4 changed files with 22 additions and 9 deletions
|
@ -9,7 +9,7 @@ import * as script from './script';
|
|||
export { ECPair, address, bip32, crypto, networks, payments, script };
|
||||
|
||||
export { Block } from './block';
|
||||
export { Psbt } from './psbt';
|
||||
export { Psbt, PsbtTxInput, PsbtTxOutput } from './psbt';
|
||||
export { OPS as opcodes } from './script';
|
||||
export { Transaction } from './transaction';
|
||||
export { TransactionBuilder } from './transaction_builder';
|
||||
|
|
|
@ -11,7 +11,6 @@ import {
|
|||
Transaction as ITransaction,
|
||||
TransactionFromBuffer,
|
||||
TransactionInput,
|
||||
TransactionOutput,
|
||||
} from 'bip174/src/lib/interfaces';
|
||||
import { checkForInput, checkForOutput } from 'bip174/src/lib/utils';
|
||||
import { fromOutputScript, toOutputScript } from './address';
|
||||
|
@ -27,6 +26,14 @@ import * as payments from './payments';
|
|||
import * as bscript from './script';
|
||||
import { Output, Transaction } from './transaction';
|
||||
|
||||
export interface PsbtTxInput extends TransactionInput {
|
||||
hash: Buffer;
|
||||
}
|
||||
|
||||
export interface PsbtTxOutput extends Output {
|
||||
address: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* These are the default arguments for a Psbt instance.
|
||||
*/
|
||||
|
@ -146,7 +153,7 @@ export class Psbt {
|
|||
this.setLocktime(locktime);
|
||||
}
|
||||
|
||||
get txInputs(): TransactionInput[] {
|
||||
get txInputs(): PsbtTxInput[] {
|
||||
return this.__CACHE.__TX.ins.map(input => ({
|
||||
hash: cloneBuffer(input.hash),
|
||||
index: input.index,
|
||||
|
@ -154,7 +161,7 @@ export class Psbt {
|
|||
}));
|
||||
}
|
||||
|
||||
get txOutputs(): TransactionOutput[] {
|
||||
get txOutputs(): PsbtTxOutput[] {
|
||||
return this.__CACHE.__TX.outs.map(output => ({
|
||||
script: cloneBuffer(output.script),
|
||||
value: output.value,
|
||||
|
|
2
types/index.d.ts
vendored
2
types/index.d.ts
vendored
|
@ -7,7 +7,7 @@ import * as payments from './payments';
|
|||
import * as script from './script';
|
||||
export { ECPair, address, bip32, crypto, networks, payments, script };
|
||||
export { Block } from './block';
|
||||
export { Psbt } from './psbt';
|
||||
export { Psbt, PsbtTxInput, PsbtTxOutput } from './psbt';
|
||||
export { OPS as opcodes } from './script';
|
||||
export { Transaction } from './transaction';
|
||||
export { TransactionBuilder } from './transaction_builder';
|
||||
|
|
14
types/psbt.d.ts
vendored
14
types/psbt.d.ts
vendored
|
@ -1,8 +1,14 @@
|
|||
import { Psbt as PsbtBase } from 'bip174';
|
||||
import { KeyValue, PsbtGlobalUpdate, PsbtInput, PsbtInputUpdate, PsbtOutput, PsbtOutputUpdate, TransactionInput, TransactionOutput } from 'bip174/src/lib/interfaces';
|
||||
import { KeyValue, PsbtGlobalUpdate, PsbtInput, PsbtInputUpdate, PsbtOutput, PsbtOutputUpdate, TransactionInput } from 'bip174/src/lib/interfaces';
|
||||
import { Signer, SignerAsync } from './ecpair';
|
||||
import { Network } from './networks';
|
||||
import { Transaction } from './transaction';
|
||||
import { Output, Transaction } from './transaction';
|
||||
export interface PsbtTxInput extends TransactionInput {
|
||||
hash: Buffer;
|
||||
}
|
||||
export interface PsbtTxOutput extends Output {
|
||||
address: string;
|
||||
}
|
||||
/**
|
||||
* Psbt class can parse and generate a PSBT binary based off of the BIP174.
|
||||
* There are 6 roles that this class fulfills. (Explained in BIP174)
|
||||
|
@ -46,8 +52,8 @@ export declare class Psbt {
|
|||
readonly inputCount: number;
|
||||
version: number;
|
||||
locktime: number;
|
||||
readonly txInputs: TransactionInput[];
|
||||
readonly txOutputs: TransactionOutput[];
|
||||
readonly txInputs: PsbtTxInput[];
|
||||
readonly txOutputs: PsbtTxOutput[];
|
||||
combine(...those: Psbt[]): this;
|
||||
clone(): Psbt;
|
||||
setMaximumFeeRate(satoshiPerByte: number): void;
|
||||
|
|
Loading…
Reference in a new issue