@@ -11,10 +11,11 @@ import {
1111 Transaction as ITransaction ,
1212 TransactionFromBuffer ,
1313 TransactionInput ,
14+ TransactionOutput ,
1415} from 'bip174/src/lib/interfaces' ;
1516import { checkForInput } from 'bip174/src/lib/utils' ;
16- import { toOutputScript } from './address' ;
17- import { reverseBuffer } from './bufferutils' ;
17+ import { fromOutputScript , toOutputScript } from './address' ;
18+ import { cloneBuffer , reverseBuffer } from './bufferutils' ;
1819import { hash160 } from './crypto' ;
1920import {
2021 fromPublicKey as ecPairFromPublicKey ,
@@ -129,6 +130,38 @@ export class Psbt {
129130 return this . data . inputs . length ;
130131 }
131132
133+ get version ( ) : number {
134+ return this . __CACHE . __TX . version ;
135+ }
136+
137+ set version ( version : number ) {
138+ this . setVersion ( version ) ;
139+ }
140+
141+ get locktime ( ) : number {
142+ return this . __CACHE . __TX . locktime ;
143+ }
144+
145+ set locktime ( locktime : number ) {
146+ this . setLocktime ( locktime ) ;
147+ }
148+
149+ get txInputs ( ) : TransactionInput [ ] {
150+ return this . __CACHE . __TX . ins . map ( input => ( {
151+ hash : cloneBuffer ( input . hash ) ,
152+ index : input . index ,
153+ sequence : input . sequence ,
154+ } ) ) ;
155+ }
156+
157+ get txOutputs ( ) : TransactionOutput [ ] {
158+ return this . __CACHE . __TX . outs . map ( output => ( {
159+ script : cloneBuffer ( output . script ) ,
160+ value : output . value ,
161+ address : fromOutputScript ( output . script , this . opts . network ) ,
162+ } ) ) ;
163+ }
164+
132165 combine ( ...those : Psbt [ ] ) : this {
133166 this . data . combine ( ...those . map ( o => o . data ) ) ;
134167 return this ;
0 commit comments