Skip to content

Commit d2d368b

Browse files
committed
Fix PsbtOutputExtended address support
1 parent 07a2769 commit d2d368b

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

ts_src/psbt.ts

Lines changed: 11 additions & 2 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 } from 'bip174/src/lib/utils';
1716
import { toOutputScript } from './address';
@@ -624,7 +623,17 @@ interface PsbtOpts {
624623

625624
interface PsbtInputExtended extends PsbtInput, TransactionInput {}
626625

627-
interface PsbtOutputExtended extends PsbtOutput, TransactionOutput {}
626+
type PsbtOutputExtended = PsbtOutputExtendedAddress | PsbtOutputExtendedScript;
627+
628+
interface PsbtOutputExtendedAddress extends PsbtOutput {
629+
address: string;
630+
value: number;
631+
}
632+
633+
interface PsbtOutputExtendedScript extends PsbtOutput {
634+
script: Buffer;
635+
value: number;
636+
}
628637

629638
interface HDSignerBase {
630639
/**

types/psbt.d.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types="node" />
22
import { Psbt as PsbtBase } from 'bip174';
3-
import { KeyValue, PsbtGlobalUpdate, PsbtInput, PsbtInputUpdate, PsbtOutput, PsbtOutputUpdate, TransactionInput, TransactionOutput } from 'bip174/src/lib/interfaces';
3+
import { KeyValue, PsbtGlobalUpdate, PsbtInput, PsbtInputUpdate, PsbtOutput, PsbtOutputUpdate, TransactionInput } from 'bip174/src/lib/interfaces';
44
import { Signer, SignerAsync } from './ecpair';
55
import { Network } from './networks';
66
import { Transaction } from './transaction';
@@ -87,7 +87,14 @@ interface PsbtOptsOptional {
8787
}
8888
interface PsbtInputExtended extends PsbtInput, TransactionInput {
8989
}
90-
interface PsbtOutputExtended extends PsbtOutput, TransactionOutput {
90+
declare type PsbtOutputExtended = PsbtOutputExtendedAddress | PsbtOutputExtendedScript;
91+
interface PsbtOutputExtendedAddress extends PsbtOutput {
92+
address: string;
93+
value: number;
94+
}
95+
interface PsbtOutputExtendedScript extends PsbtOutput {
96+
script: Buffer;
97+
value: number;
9198
}
9299
interface HDSignerBase {
93100
/**

0 commit comments

Comments
 (0)