[RPC][Bitcoin-TX] Add support for sequence number #7957
pull jonasschnelli wants to merge 3 commits into bitcoin:master from jonasschnelli:2016/04/rbf_base changing 6 files +41 −8-
jonasschnelli commented at 1:42 pm on April 27, 2016: contributor
-
[RPC] createrawtransaction: add option to set the sequence number per input a946bb6b18
-
[bitcoin-tx] allow to set nSequence number over the in= command e59336fbf9
-
jonasschnelli added the label RPC/REST/ZMQ on Apr 27, 2016
-
jonasschnelli added the label Utils and libraries on Apr 27, 2016
-
jonasschnelli force-pushed on Apr 27, 2016
-
jonasschnelli commented at 1:43 pm on April 27, 2016: contributorSubset PR as requested in #7865.
-
in src/rpc/rawtransaction.cpp: in e59336fbf9 outdated
384@@ -384,6 +385,12 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp) 385 throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, vout must be positive"); 386 387 uint32_t nSequence = (rawTx.nLockTime ? std::numeric_limits<uint32_t>::max() - 1 : std::numeric_limits<uint32_t>::max()); 388+ 389+ // set the sequence number if passed in the parameters object 390+ const UniValue& sequenceObj = find_value(o, "sequence"); 391+ if (sequenceObj.isNum()) 392+ nSequence = sequenceObj.get_int(); 393+
mruddy commented at 1:03 am on April 28, 2016:Neat, this is useful. I was trying it out and think that being able to use hex is a little easier. Maybe something like this:
0if (sequenceObj.isNum()) 1{ 2 nSequence = sequenceObj.get_int(); 3} else if (sequenceObj.isStr() /*&& IsHex(sequenceObj.get_str())*/) 4{ 5 nSequence = strtoul(sequenceObj.get_str().c_str(), NULL, 16); 6}
I commented out the IsHex check because I think it might be too restrictive (but left it there to see what you thought). With this little patch, these work too:
0createrawtransaction '[{"txid":"d5eb7e43a7cf85c5bee47a7a33c8351b8dcc013616a7c6bdc3af49538d986221","vout":0,"sequence":"0xfffffffe"}]' '{"mifzFw94bSGApmx2eWw1nzLCfEeq4cTwey":49.99}' 0 1createrawtransaction '[{"txid":"d5eb7e43a7cf85c5bee47a7a33c8351b8dcc013616a7c6bdc3af49538d986221","vout":0,"sequence":"fffffffd"}]' '{"mifzFw94bSGApmx2eWw1nzLCfEeq4cTwey":49.99}' 0 2createrawtransaction '[{"txid":"d5eb7e43a7cf85c5bee47a7a33c8351b8dcc013616a7c6bdc3af49538d986221","vout":0,"sequence":"f"}]' '{"mifzFw94bSGApmx2eWw1nzLCfEeq4cTwey":49.99}' 0
jonasschnelli commented at 7:46 am on April 28, 2016:Thanks for the review! Hmm… I’m not sure if we want utility function (hex->int) on machine-to-machine communication (RPC). But no strong opinion.
mruddy commented at 11:40 am on April 28, 2016:Good point, I was thinking of only the GUI RPC console use (that’s where the hex conversion is useful to me). If your threat model includes hostile input on this interface, then the IsHex check could be used and the length of the string could be validated to be <= 8. That would likely be sufficient input validation. Adding back IsHex makes my first and third examples invalid. The sequence value of the third would need to change to “0f” instead of just “f”.sipa commented at 3:00 pm on June 2, 2016: memberutACK e59336fbf9b906bf05d50a732036613216898bd1paveljanik commented at 3:23 pm on June 6, 2016: contributor[Bitcoin-Tx] Add tests for sequence number support ae357d5ab9jonasschnelli commented at 3:39 pm on June 7, 2016: contributorAdded a commit with twobitcoin-tx
tests to cover the sequence number feature.laanwj merged this on Jun 7, 2016laanwj closed this on Jun 7, 2016
laanwj referenced this in commit 79004d4ae6 on Jun 7, 2016laanwj commented at 4:28 pm on June 7, 2016: memberutACK ae357d5codablock referenced this in commit b1ad52ad4a on Sep 16, 2017codablock referenced this in commit 8d2df32ba6 on Sep 19, 2017codablock referenced this in commit 9af87c8269 on Dec 22, 2017zkbot referenced this in commit 3b0a5bcd24 on Apr 13, 2018zkbot referenced this in commit 65a8f9f201 on Apr 13, 2018sickpig referenced this in commit 6c5d05a107 on May 4, 2018sickpig referenced this in commit 638b66ecdb on May 9, 2018andvgal referenced this in commit 72bf4f61eb on Jan 6, 2019MarcoFalke locked this on Sep 8, 2021
github-metadata-mirror
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-18 18:12 UTC
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-18 18:12 UTC
This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me
More mirrored repositories can be found on mirror.b10c.me