From 40b95273010f9cb57e078b9bcd3330e5829499bc Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Thu, 13 Sep 2018 16:55:18 -0600 Subject: [PATCH] Incorporate APPROX_RELEASE_HEIGHT when determining what consensus branch to sign with --- qa/rpc-tests/signrawtransaction_offline.py | 10 ---------- src/rpc/rawtransaction.cpp | 8 ++++++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/qa/rpc-tests/signrawtransaction_offline.py b/qa/rpc-tests/signrawtransaction_offline.py index 5eadf2cb3..55acf7b4a 100755 --- a/qa/rpc-tests/signrawtransaction_offline.py +++ b/qa/rpc-tests/signrawtransaction_offline.py @@ -36,22 +36,12 @@ class SignOfflineTest (BitcoinTestFramework): sign_inputs = [{'txid': txid, 'vout': 0, 'scriptPubKey': scriptpubkey, 'amount': 10}] create_hex = self.nodes[0].createrawtransaction(create_inputs, {taddr: 9.9999}) - print "create:" - print create_hex signed_tx = offline_node.signrawtransaction(create_hex, sign_inputs, privkeys) - print "sign:" - print signed_tx # If we return the transaction hash, then we have have not thrown an error (success) online_tx_hash = self.nodes[0].sendrawtransaction(signed_tx['hex']) assert_true(len(online_tx_hash) > 0) - #signed_hex = signed_tx['hex'] - #print "decoded:" - #print self.nodes[0].decoderawtransaction(signed_hex) - print "sent:" - print online_tx_hash - if __name__ == '__main__': SignOfflineTest().main() \ No newline at end of file diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 912cbe3ba..4a3c83610 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -7,6 +7,7 @@ #include "consensus/validation.h" #include "core_io.h" #include "init.h" +#include "deprecation.h" #include "key_io.h" #include "keystore.h" #include "main.h" @@ -872,9 +873,12 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp) } bool fHashSingle = ((nHashType & ~SIGHASH_ANYONECANPAY) == SIGHASH_SINGLE); - + // Use the approximate release height if it is greater so offline nodes + // have a better estimation of the current height and will be more likely to + // determine the correct consensus branch ID. + int chainHeight = std::max(chainActive.Height() + 1, APPROX_RELEASE_HEIGHT); // Grab the current consensus branch ID - auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); + auto consensusBranchId = CurrentEpochBranchId(chainHeight, Params().GetConsensus()); // Script verification errors UniValue vErrors(UniValue::VARR);