@@ -125,21 +125,21 @@ export interface VerifyAddressOptions<TCoinSpecific extends UtxoCoinSpecific> ex
125125 coinSpecific ?: TCoinSpecific ;
126126}
127127
128- export interface BaseOutput {
128+ export interface BaseOutput < TAmount = string | number > {
129129 address : string ;
130- amount : string | number ;
130+ amount : TAmount ;
131131 // Even though this external flag is redundant with the chain property, it is necessary for backwards compatibility
132132 // with legacy transaction format.
133133 external ?: boolean ;
134134}
135135
136- export interface FixedScriptWalletOutput extends BaseOutput {
136+ export interface FixedScriptWalletOutput < TAmount = string | number > extends BaseOutput < TAmount > {
137137 needsCustomChangeKeySignatureVerification ?: boolean ;
138138 chain : number ;
139139 index : number ;
140140}
141141
142- export type Output = BaseOutput | FixedScriptWalletOutput ;
142+ export type Output < TAmount = string | number > = BaseOutput < TAmount > | FixedScriptWalletOutput < TAmount > ;
143143
144144export function isWalletOutput ( output : Output ) : output is FixedScriptWalletOutput {
145145 return (
@@ -206,23 +206,42 @@ export interface ParseTransactionOptions<TNumber extends number | bigint = numbe
206206 reqId ?: IRequestTracer ;
207207}
208208
209- export type ParsedTransaction < TNumber extends number | bigint = number > = {
209+ export type BaseParsedTransactionOutputs < TNumber extends number | bigint , TOutput > = {
210+ /** all transaction outputs */
211+ outputs : TOutput [ ] ;
212+ /** transaction outputs that were specified as recipients but are missing from the transaction */
213+ missingOutputs : TOutput [ ] ;
214+ /** transaction outputs that were specified as recipients and are present in the transaction */
215+ explicitExternalOutputs : TOutput [ ] ;
216+ /** transaction outputs that were not specified as recipients but are present in the transaction */
217+ implicitExternalOutputs : TOutput [ ] ;
218+ /** transaction outputs that are change outputs */
219+ changeOutputs : TOutput [ ] ;
220+ /** sum of all explicit external outputs */
221+ explicitExternalSpendAmount : TNumber ;
222+ /** sum of all implicit external outputs */
223+ implicitExternalSpendAmount : TNumber ;
224+ } ;
225+
226+ export type BaseParsedTransaction < TNumber extends number | bigint , TOutput > = BaseParsedTransactionOutputs <
227+ TNumber ,
228+ TOutput
229+ > /** Some extra properties that have nothing to do with an individual transaction */ & {
210230 keychains : UtxoNamedKeychains ;
211231 keySignatures : {
212232 backupPub ?: string ;
213233 bitgoPub ?: string ;
214234 } ;
215- outputs : Output [ ] ;
216- missingOutputs : Output [ ] ;
217- explicitExternalOutputs : Output [ ] ;
218- implicitExternalOutputs : Output [ ] ;
219- changeOutputs : Output [ ] ;
220- explicitExternalSpendAmount : TNumber ;
221- implicitExternalSpendAmount : TNumber ;
222235 needsCustomChangeKeySignatureVerification : boolean ;
223236 customChange ?: CustomChangeOptions ;
224237} ;
225238
239+ /**
240+ * This type is a bit silly because it allows the type for the aggregate amounts to be different from the type of
241+ * individual amounts.
242+ */
243+ export type ParsedTransaction < TNumber extends number | bigint = number > = BaseParsedTransaction < TNumber , Output > ;
244+
226245export interface GenerateAddressOptions {
227246 addressType ?: ScriptType2Of3 ;
228247 threshold ?: number ;
0 commit comments