From 6faeae397ffcca0a6d163003cc871fb75222b143 Mon Sep 17 00:00:00 2001 From: Daniel Cousens Date: Wed, 22 Jun 2016 14:57:11 +1000 Subject: [PATCH] TxBuilder: add setVersion --- src/transaction_builder.js | 7 +++++++ test/transaction_builder.js | 10 ++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/transaction_builder.js b/src/transaction_builder.js index 0ec0718..5384745 100644 --- a/src/transaction_builder.js +++ b/src/transaction_builder.js @@ -163,6 +163,13 @@ TransactionBuilder.prototype.setLockTime = function (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) { var txb = new TransactionBuilder(network) diff --git a/test/transaction_builder.js b/test/transaction_builder.js index afbb6d9..51cde35 100644 --- a/test/transaction_builder.js +++ b/test/transaction_builder.js @@ -17,14 +17,8 @@ function construct (f, sign) { var network = NETWORKS[f.network] var txb = new TransactionBuilder(network) - // FIXME: add support for version in TransactionBuilder API - if (f.version !== undefined) { - txb.tx.version = f.version - } - - if (f.locktime !== undefined) { - txb.setLockTime(f.locktime) - } + if (f.version !== undefined) txb.setVersion(f.version) + if (f.locktime !== undefined) txb.setLockTime(f.locktime) f.inputs.forEach(function (input) { var prevTxScript