@@ -91,6 +91,7 @@ const handleSignUtxo = function(recoveryRequest, key, skipConfirm) {
91
91
}
92
92
93
93
const isBCH = recoveryRequest . coin === 'bch' || recoveryRequest . coin === 'tbch' ;
94
+ const isZEC = recoveryRequest . coin === 'zec' || recoveryRequest . coin === 'tzec' ;
94
95
const transaction = utxoLib . Transaction . fromHex ( recoveryRequest . transactionHex , network ) ;
95
96
96
97
const outputs = transaction . outs . map ( out => ( {
@@ -110,15 +111,21 @@ const handleSignUtxo = function(recoveryRequest, key, skipConfirm) {
110
111
// force override network as we use btc mainnet xpubs for all utxo coins
111
112
backupKeyNode . keyPair . network = network ;
112
113
113
- // For BCH we need to add the input values to each input, because input values must be signed
114
- if ( isBCH ) {
114
+
115
+ // For BCH and ZEC we need to add the input values to each input, because input values must be signed
116
+ if ( isBCH || isZEC ) {
115
117
transaction . ins . forEach ( function ( input , i ) {
116
118
transaction . ins [ i ] . value = recoveryRequest . inputs [ i ] . amount ;
117
119
} )
118
120
}
119
121
120
122
const txBuilder = utxoLib . TransactionBuilder . fromTransaction ( transaction , network ) ;
121
123
124
+ if ( isZEC ) {
125
+ txBuilder . setVersion ( utxoLib . Transaction . ZCASH_SAPLING_VERSION ) ;
126
+ txBuilder . setVersionGroupId ( 0x892f2085 ) ;
127
+ }
128
+
122
129
_ . forEach ( recoveryRequest . inputs , function ( input , i ) {
123
130
const isBech32 = ! input . redeemScript ;
124
131
const isSegwit = ! ! input . witnessScript ;
@@ -147,7 +154,7 @@ const handleSignUtxo = function(recoveryRequest, key, skipConfirm) {
147
154
const witnessScript = new Buffer ( input . witnessScript , 'hex' ) ;
148
155
txBuilder . sign ( i , derivedHDNode . keyPair , redeemScript , utxoLib . Transaction . SIGHASH_ALL , input . amount , witnessScript )
149
156
} else {
150
- txBuilder . sign ( i , derivedHDNode . keyPair , redeemScript , utxoLib . Transaction . SIGHASH_ALL ) ;
157
+ txBuilder . sign ( i , derivedHDNode . keyPair , redeemScript , utxoLib . Transaction . SIGHASH_ALL , input . amount ) ;
151
158
}
152
159
}
153
160
}
0 commit comments