Browse Source

Incorporate APPROX_RELEASE_HEIGHT when determining what consensus branch to sign with

pull/4/head
Eirik Ogilvie-Wigley 6 years ago
parent
commit
40b9527301
  1. 10
      qa/rpc-tests/signrawtransaction_offline.py
  2. 8
      src/rpc/rawtransaction.cpp

10
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()

8
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);

Loading…
Cancel
Save