File tree Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,18 @@ class Psbt {
97
97
get inputCount ( ) {
98
98
return this . data . inputs . length ;
99
99
}
100
+ get txVersion ( ) {
101
+ return this . __CACHE . __TX . version ;
102
+ }
103
+ get txLocktime ( ) {
104
+ return this . __CACHE . __TX . locktime ;
105
+ }
106
+ get txInputs ( ) {
107
+ return deepClone ( this . __CACHE . __TX . ins ) ;
108
+ }
109
+ get txOutputs ( ) {
110
+ return deepClone ( this . __CACHE . __TX . outs ) ;
111
+ }
100
112
combine ( ...those ) {
101
113
this . data . combine ( ...those . map ( o => o . data ) ) ;
102
114
return this ;
@@ -579,6 +591,11 @@ class PsbtTransaction {
579
591
return this . tx . toBuffer ( ) ;
580
592
}
581
593
}
594
+ function deepClone ( obj ) {
595
+ return JSON . parse ( JSON . stringify ( obj ) , ( _ , value ) =>
596
+ value . type === 'Buffer' ? Buffer . from ( value . data ) : value ,
597
+ ) ;
598
+ }
582
599
function canFinalize ( input , script , scriptType ) {
583
600
switch ( scriptType ) {
584
601
case 'pubkey' :
Original file line number Diff line number Diff line change @@ -129,6 +129,22 @@ export class Psbt {
129
129
return this . data . inputs . length ;
130
130
}
131
131
132
+ get txVersion ( ) : number {
133
+ return this . __CACHE . __TX . version ;
134
+ }
135
+
136
+ get txLocktime ( ) : number {
137
+ return this . __CACHE . __TX . locktime ;
138
+ }
139
+
140
+ get txInputs ( ) : TransactionInput [ ] {
141
+ return deepClone ( this . __CACHE . __TX . ins ) ;
142
+ }
143
+
144
+ get txOutputs ( ) : TransactionInput [ ] {
145
+ return deepClone ( this . __CACHE . __TX . outs ) ;
146
+ }
147
+
132
148
combine ( ...those : Psbt [ ] ) : this {
133
149
this . data . combine ( ...those . map ( o => o . data ) ) ;
134
150
return this ;
@@ -757,6 +773,12 @@ class PsbtTransaction implements ITransaction {
757
773
}
758
774
}
759
775
776
+ function deepClone ( obj : any ) : any {
777
+ return JSON . parse ( JSON . stringify ( obj ) , ( _ , value ) =>
778
+ value . type === 'Buffer' ? Buffer . from ( value . data ) : value ,
779
+ ) ;
780
+ }
781
+
760
782
function canFinalize (
761
783
input : PsbtInput ,
762
784
script : Buffer ,
Original file line number Diff line number Diff line change @@ -44,6 +44,10 @@ export declare class Psbt {
44
44
private opts ;
45
45
constructor ( opts ?: PsbtOptsOptional , data ?: PsbtBase ) ;
46
46
readonly inputCount : number ;
47
+ readonly txVersion : number ;
48
+ readonly txLocktime : number ;
49
+ readonly txInputs : TransactionInput [ ] ;
50
+ readonly txOutputs : TransactionInput [ ] ;
47
51
combine ( ...those : Psbt [ ] ) : this;
48
52
clone ( ) : Psbt ;
49
53
setMaximumFeeRate ( satoshiPerByte : number ) : void ;
You can’t perform that action at this time.
0 commit comments