@@ -4,7 +4,7 @@ const convert = require('../converter');
44const tools_1 = require ( '../converter/tools' ) ;
55const varuint = require ( '../converter/varint' ) ;
66const typeFields_1 = require ( '../typeFields' ) ;
7- function psbtFromBuffer ( buffer , txGetter ) {
7+ function psbtFromBuffer ( buffer , txGetter , { bip32PathsAbsolute = true } = { } ) {
88 let offset = 0 ;
99 function varSlice ( ) {
1010 const keyLen = varuint . decode ( buffer , offset ) ;
@@ -114,11 +114,15 @@ function psbtFromBuffer(buffer, txGetter) {
114114 }
115115 outputKeyVals . push ( output ) ;
116116 }
117- return psbtFromKeyVals ( unsignedTx , {
118- globalMapKeyVals,
119- inputKeyVals,
120- outputKeyVals,
121- } ) ;
117+ return psbtFromKeyVals (
118+ unsignedTx ,
119+ {
120+ globalMapKeyVals,
121+ inputKeyVals,
122+ outputKeyVals,
123+ } ,
124+ { bip32PathsAbsolute } ,
125+ ) ;
122126}
123127exports . psbtFromBuffer = psbtFromBuffer ;
124128function checkKeyBuffer ( type , keyBuf , keyNum ) {
@@ -132,6 +136,7 @@ exports.checkKeyBuffer = checkKeyBuffer;
132136function psbtFromKeyVals (
133137 unsignedTx ,
134138 { globalMapKeyVals, inputKeyVals, outputKeyVals } ,
139+ { bip32PathsAbsolute = true } = { } ,
135140) {
136141 // That was easy :-)
137142 const globalMap = {
@@ -244,7 +249,7 @@ function psbtFromKeyVals(
244249 input . bip32Derivation = [ ] ;
245250 }
246251 input . bip32Derivation . push (
247- convert . inputs . bip32Derivation . decode ( keyVal ) ,
252+ convert . inputs . bip32Derivation . decode ( keyVal , bip32PathsAbsolute ) ,
248253 ) ;
249254 break ;
250255 case typeFields_1 . InputTypes . FINAL_SCRIPTSIG :
@@ -298,7 +303,10 @@ function psbtFromKeyVals(
298303 input . tapBip32Derivation = [ ] ;
299304 }
300305 input . tapBip32Derivation . push (
301- convert . inputs . tapBip32Derivation . decode ( keyVal ) ,
306+ convert . inputs . tapBip32Derivation . decode (
307+ keyVal ,
308+ bip32PathsAbsolute ,
309+ ) ,
302310 ) ;
303311 break ;
304312 case typeFields_1 . InputTypes . TAP_INTERNAL_KEY :
@@ -357,7 +365,7 @@ function psbtFromKeyVals(
357365 output . bip32Derivation = [ ] ;
358366 }
359367 output . bip32Derivation . push (
360- convert . outputs . bip32Derivation . decode ( keyVal ) ,
368+ convert . outputs . bip32Derivation . decode ( keyVal , bip32PathsAbsolute ) ,
361369 ) ;
362370 break ;
363371 case typeFields_1 . OutputTypes . TAP_INTERNAL_KEY :
@@ -381,7 +389,10 @@ function psbtFromKeyVals(
381389 output . tapBip32Derivation = [ ] ;
382390 }
383391 output . tapBip32Derivation . push (
384- convert . outputs . tapBip32Derivation . decode ( keyVal ) ,
392+ convert . outputs . tapBip32Derivation . decode (
393+ keyVal ,
394+ bip32PathsAbsolute ,
395+ ) ,
385396 ) ;
386397 break ;
387398 default :
0 commit comments