TxBuilder: add setVersion

This commit is contained in:
Daniel Cousens 2016-06-22 14:57:11 +10:00
parent 0d0f7c9f00
commit 6faeae397f
2 changed files with 9 additions and 8 deletions

View file

@ -163,6 +163,13 @@ TransactionBuilder.prototype.setLockTime = function (locktime) {
this.tx.locktime = locktime this.tx.locktime = locktime
} }
TransactionBuilder.prototype.setVersion = function (version) {
typeforce(types.UInt32, version)
// XXX: this might eventually become more complex depending on what the versions represent
this.tx.version = version
}
TransactionBuilder.fromTransaction = function (transaction, network) { TransactionBuilder.fromTransaction = function (transaction, network) {
var txb = new TransactionBuilder(network) var txb = new TransactionBuilder(network)

View file

@ -17,14 +17,8 @@ function construct (f, sign) {
var network = NETWORKS[f.network] var network = NETWORKS[f.network]
var txb = new TransactionBuilder(network) var txb = new TransactionBuilder(network)
// FIXME: add support for version in TransactionBuilder API if (f.version !== undefined) txb.setVersion(f.version)
if (f.version !== undefined) { if (f.locktime !== undefined) txb.setLockTime(f.locktime)
txb.tx.version = f.version
}
if (f.locktime !== undefined) {
txb.setLockTime(f.locktime)
}
f.inputs.forEach(function (input) { f.inputs.forEach(function (input) {
var prevTxScript var prevTxScript