Skip to content

Commit de0bbf5

Browse files
committed
Export PSBT getter types
1 parent 361ea7c commit de0bbf5

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

ts_src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import * as script from './script';
99
export { ECPair, address, bip32, crypto, networks, payments, script };
1010

1111
export { Block } from './block';
12-
export { Psbt } from './psbt';
12+
export { Psbt, PsbtTxInput, PsbtTxOutput } from './psbt';
1313
export { OPS as opcodes } from './script';
1414
export { Transaction } from './transaction';
1515
export { TransactionBuilder } from './transaction_builder';

ts_src/psbt.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
Transaction as ITransaction,
1212
TransactionFromBuffer,
1313
TransactionInput,
14-
TransactionOutput,
1514
} from 'bip174/src/lib/interfaces';
1615
import { checkForInput, checkForOutput } from 'bip174/src/lib/utils';
1716
import { fromOutputScript, toOutputScript } from './address';
@@ -27,6 +26,14 @@ import * as payments from './payments';
2726
import * as bscript from './script';
2827
import { Output, Transaction } from './transaction';
2928

29+
export interface PsbtTxInput extends TransactionInput {
30+
hash: Buffer;
31+
}
32+
33+
export interface PsbtTxOutput extends Output {
34+
address: string;
35+
}
36+
3037
/**
3138
* These are the default arguments for a Psbt instance.
3239
*/
@@ -146,15 +153,15 @@ export class Psbt {
146153
this.setLocktime(locktime);
147154
}
148155

149-
get txInputs(): TransactionInput[] {
156+
get txInputs(): PsbtTxInput[] {
150157
return this.__CACHE.__TX.ins.map(input => ({
151158
hash: cloneBuffer(input.hash),
152159
index: input.index,
153160
sequence: input.sequence,
154161
}));
155162
}
156163

157-
get txOutputs(): TransactionOutput[] {
164+
get txOutputs(): PsbtTxOutput[] {
158165
return this.__CACHE.__TX.outs.map(output => ({
159166
script: cloneBuffer(output.script),
160167
value: output.value,

types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as payments from './payments';
77
import * as script from './script';
88
export { ECPair, address, bip32, crypto, networks, payments, script };
99
export { Block } from './block';
10-
export { Psbt } from './psbt';
10+
export { Psbt, PsbtTxInput, PsbtTxOutput } from './psbt';
1111
export { OPS as opcodes } from './script';
1212
export { Transaction } from './transaction';
1313
export { TransactionBuilder } from './transaction_builder';

types/psbt.d.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import { Psbt as PsbtBase } from 'bip174';
2-
import { KeyValue, PsbtGlobalUpdate, PsbtInput, PsbtInputUpdate, PsbtOutput, PsbtOutputUpdate, TransactionInput, TransactionOutput } from 'bip174/src/lib/interfaces';
2+
import { KeyValue, PsbtGlobalUpdate, PsbtInput, PsbtInputUpdate, PsbtOutput, PsbtOutputUpdate, TransactionInput } from 'bip174/src/lib/interfaces';
33
import { Signer, SignerAsync } from './ecpair';
44
import { Network } from './networks';
5-
import { Transaction } from './transaction';
5+
import { Output, Transaction } from './transaction';
6+
export interface PsbtTxInput extends TransactionInput {
7+
hash: Buffer;
8+
}
9+
export interface PsbtTxOutput extends Output {
10+
address: string;
11+
}
612
/**
713
* Psbt class can parse and generate a PSBT binary based off of the BIP174.
814
* There are 6 roles that this class fulfills. (Explained in BIP174)
@@ -46,8 +52,8 @@ export declare class Psbt {
4652
readonly inputCount: number;
4753
version: number;
4854
locktime: number;
49-
readonly txInputs: TransactionInput[];
50-
readonly txOutputs: TransactionOutput[];
55+
readonly txInputs: PsbtTxInput[];
56+
readonly txOutputs: PsbtTxOutput[];
5157
combine(...those: Psbt[]): this;
5258
clone(): Psbt;
5359
setMaximumFeeRate(satoshiPerByte: number): void;

0 commit comments

Comments
 (0)