@@ -36,27 +36,20 @@ const ONE: Buffer = Buffer.from(
3636 'hex' ,
3737) ;
3838const VALUE_UINT64_MAX : Buffer = Buffer . from ( 'ffffffffffffffff' , 'hex' ) ;
39- const BLANK_OUTPUT : BlankOutput = {
39+ const BLANK_OUTPUT = {
4040 script : EMPTY_SCRIPT ,
4141 valueBuffer : VALUE_UINT64_MAX ,
4242} ;
4343
44- function isOutput ( out : Output | BlankOutput ) : out is Output {
45- return ( out as Output ) . value !== undefined ;
46- }
47-
48- export interface BlankOutput {
49- script : Buffer ;
50- valueBuffer : Buffer ;
44+ function isOutput ( out : Output ) : boolean {
45+ return out . value !== undefined ;
5146}
5247
5348export interface Output {
5449 script : Buffer ;
5550 value : number ;
5651}
5752
58- type OpenOutput = Output | BlankOutput ;
59-
6053export interface Input {
6154 hash : Buffer ;
6255 index : number ;
@@ -185,7 +178,7 @@ export class Transaction {
185178 version : number = 1 ;
186179 locktime : number = 0 ;
187180 ins : Input [ ] = [ ] ;
188- outs : OpenOutput [ ] = [ ] ;
181+ outs : Output [ ] = [ ] ;
189182
190183 isCoinbase ( ) : boolean {
191184 return (
@@ -275,7 +268,7 @@ export class Transaction {
275268 newTx . outs = this . outs . map ( txOut => {
276269 return {
277270 script : txOut . script ,
278- value : ( txOut as Output ) . value ,
271+ value : txOut . value ,
279272 } ;
280273 } ) ;
281274
@@ -333,7 +326,7 @@ export class Transaction {
333326
334327 // "blank" outputs before
335328 for ( let i = 0 ; i < inIndex ; i ++ ) {
336- txTmp . outs [ i ] = BLANK_OUTPUT ;
329+ ( txTmp . outs as any ) [ i ] = BLANK_OUTPUT ;
337330 }
338331
339332 // ignore sequence numbers (except at inIndex)
@@ -445,7 +438,7 @@ export class Transaction {
445438 toffset = 0 ;
446439
447440 this . outs . forEach ( out => {
448- writeUInt64 ( ( out as Output ) . value ) ;
441+ writeUInt64 ( out . value ) ;
449442 writeVarSlice ( out . script ) ;
450443 } ) ;
451444
@@ -458,7 +451,7 @@ export class Transaction {
458451
459452 tbuffer = Buffer . allocUnsafe ( 8 + varSliceSize ( output . script ) ) ;
460453 toffset = 0 ;
461- writeUInt64 ( ( output as Output ) . value ) ;
454+ writeUInt64 ( output . value ) ;
462455 writeVarSlice ( output . script ) ;
463456
464457 hashOutputs = bcrypto . hash256 ( tbuffer ) ;
@@ -602,7 +595,7 @@ export class Transaction {
602595 if ( isOutput ( txOut ) ) {
603596 writeUInt64 ( txOut . value ) ;
604597 } else {
605- writeSlice ( txOut . valueBuffer ) ;
598+ writeSlice ( ( txOut as any ) . valueBuffer ) ;
606599 }
607600
608601 writeVarSlice ( txOut . script ) ;
0 commit comments