[RPC] Fix createrawtx sequence number unsigned int parsing
This commit is contained in:
parent
6a034ed898
commit
6fa950a573
2 changed files with 21 additions and 2 deletions
|
@ -143,6 +143,20 @@ class RawTransactionsTest(BitcoinTestFramework):
|
||||||
rawtx = self.nodes[0].createrawtransaction(inputs, outputs)
|
rawtx = self.nodes[0].createrawtransaction(inputs, outputs)
|
||||||
decrawtx= self.nodes[0].decoderawtransaction(rawtx)
|
decrawtx= self.nodes[0].decoderawtransaction(rawtx)
|
||||||
assert_equal(decrawtx['vin'][0]['sequence'], 1000)
|
assert_equal(decrawtx['vin'][0]['sequence'], 1000)
|
||||||
|
|
||||||
|
inputs = [ {'txid' : "1d1d4e24ed99057e84c3f80fd8fbec79ed9e1acee37da269356ecea000000000", 'vout' : 1, 'sequence' : -1}]
|
||||||
|
outputs = { self.nodes[0].getnewaddress() : 1 }
|
||||||
|
assert_raises(JSONRPCException, self.nodes[0].createrawtransaction, inputs, outputs)
|
||||||
|
|
||||||
|
inputs = [ {'txid' : "1d1d4e24ed99057e84c3f80fd8fbec79ed9e1acee37da269356ecea000000000", 'vout' : 1, 'sequence' : 4294967296}]
|
||||||
|
outputs = { self.nodes[0].getnewaddress() : 1 }
|
||||||
|
assert_raises(JSONRPCException, self.nodes[0].createrawtransaction, inputs, outputs)
|
||||||
|
|
||||||
|
inputs = [ {'txid' : "1d1d4e24ed99057e84c3f80fd8fbec79ed9e1acee37da269356ecea000000000", 'vout' : 1, 'sequence' : 4294967294}]
|
||||||
|
outputs = { self.nodes[0].getnewaddress() : 1 }
|
||||||
|
rawtx = self.nodes[0].createrawtransaction(inputs, outputs)
|
||||||
|
decrawtx= self.nodes[0].decoderawtransaction(rawtx)
|
||||||
|
assert_equal(decrawtx['vin'][0]['sequence'], 4294967294)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
RawTransactionsTest().main()
|
RawTransactionsTest().main()
|
||||||
|
|
|
@ -388,8 +388,13 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp)
|
||||||
|
|
||||||
// set the sequence number if passed in the parameters object
|
// set the sequence number if passed in the parameters object
|
||||||
const UniValue& sequenceObj = find_value(o, "sequence");
|
const UniValue& sequenceObj = find_value(o, "sequence");
|
||||||
if (sequenceObj.isNum())
|
if (sequenceObj.isNum()) {
|
||||||
nSequence = sequenceObj.get_int();
|
int64_t seqNr64 = sequenceObj.get_int64();
|
||||||
|
if (seqNr64 < 0 || seqNr64 > std::numeric_limits<uint32_t>::max())
|
||||||
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, sequence number is out of range");
|
||||||
|
else
|
||||||
|
nSequence = (uint32_t)seqNr64;
|
||||||
|
}
|
||||||
|
|
||||||
CTxIn in(COutPoint(txid, nOutput), CScript(), nSequence);
|
CTxIn in(COutPoint(txid, nOutput), CScript(), nSequence);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue