Skip to content

Commit

Permalink
add overwinter param for support overwinter
Browse files Browse the repository at this point in the history
  • Loading branch information
wangjiling committed Nov 14, 2018
1 parent ea496de commit b5eb2dd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/transaction_builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,13 +509,15 @@ TransactionBuilder.prototype.setLockTime = function (locktime) {
this.tx.locktime = locktime
}

TransactionBuilder.prototype.setVersion = function (version) {
TransactionBuilder.prototype.setVersion = function (version, overwinter = true) {
typeforce(types.UInt32, version)

if (!this.network.consensusBranchId.hasOwnProperty(this.tx.version)) {
throw new Error('Unsupported Zcash transaction')
}

this.tx.overwintered = (overwinter ? 1 : 0)

// XXX: this might eventually become more complex depending on what the versions represent
this.tx.version = version
}
Expand Down Expand Up @@ -725,7 +727,7 @@ TransactionBuilder.prototype.sign = function (vin, keyPair, redeemScript, hashTy
var signatureHash
if (input.witness) {
signatureHash = this.tx.hashForWitnessV0(vin, input.signScript, input.value, hashType)
} else if (overwintered) {
} else if (overwintered || this.tx.overwintered) {
signatureHash = this.tx.hashForZIP143(vin, input.signScript, witnessValue, hashType)
} else {
signatureHash = this.tx.hashForSignature(vin, input.signScript, hashType)
Expand Down

0 comments on commit b5eb2dd

Please sign in to comment.