@@ -60,23 +60,6 @@ const DEFAULT_OPTS = {
6060 * Transaction object. Such as fee rate not being larger than maximumFeeRate etc.
6161 */
6262class Psbt {
63- data ;
64- static fromBase64 ( data , opts = { } ) {
65- const buffer = Buffer . from ( data , 'base64' ) ;
66- return this . fromBuffer ( buffer , opts ) ;
67- }
68- static fromHex ( data , opts = { } ) {
69- const buffer = Buffer . from ( data , 'hex' ) ;
70- return this . fromBuffer ( buffer , opts ) ;
71- }
72- static fromBuffer ( buffer , opts = { } ) {
73- const psbtBase = bip174_1 . Psbt . fromBuffer ( buffer , transactionFromBuffer ) ;
74- const psbt = new Psbt ( opts , psbtBase ) ;
75- checkTxForDupeIns ( psbt . __CACHE . __TX , psbt . __CACHE ) ;
76- return psbt ;
77- }
78- __CACHE ;
79- opts ;
8063 constructor ( opts = { } , data = new bip174_1 . Psbt ( new PsbtTransaction ( ) ) ) {
8164 this . data = data ;
8265 // set defaults
@@ -106,6 +89,20 @@ class Psbt {
10689 dpew ( this , '__CACHE' , false , true ) ;
10790 dpew ( this , 'opts' , false , true ) ;
10891 }
92+ static fromBase64 ( data , opts = { } ) {
93+ const buffer = Buffer . from ( data , 'base64' ) ;
94+ return this . fromBuffer ( buffer , opts ) ;
95+ }
96+ static fromHex ( data , opts = { } ) {
97+ const buffer = Buffer . from ( data , 'hex' ) ;
98+ return this . fromBuffer ( buffer , opts ) ;
99+ }
100+ static fromBuffer ( buffer , opts = { } ) {
101+ const psbtBase = bip174_1 . Psbt . fromBuffer ( buffer , transactionFromBuffer ) ;
102+ const psbt = new Psbt ( opts , psbtBase ) ;
103+ checkTxForDupeIns ( psbt . __CACHE . __TX , psbt . __CACHE ) ;
104+ return psbt ;
105+ }
109106 get inputCount ( ) {
110107 return this . data . inputs . length ;
111108 }
@@ -625,7 +622,6 @@ const transactionFromBuffer = buffer => new PsbtTransaction(buffer);
625622 * It contains a bitcoinjs-lib Transaction object.
626623 */
627624class PsbtTransaction {
628- tx ;
629625 constructor ( buffer = Buffer . from ( [ 2 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ] ) ) {
630626 this . tx = transaction_1 . Transaction . fromBuffer ( buffer ) ;
631627 checkTxEmpty ( this . tx ) ;
0 commit comments