Skip to content

Conversation

@jonasschnelli
Copy link
Contributor

No description provided.

@jonasschnelli
Copy link
Contributor Author

Subset PR as requested in #7865.

const UniValue& sequenceObj = find_value(o, "sequence");
if (sequenceObj.isNum())
nSequence = sequenceObj.get_int();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

if (sequenceObj.isNum())
{
    nSequence = sequenceObj.get_int();
} else if (sequenceObj.isStr() /*&& IsHex(sequenceObj.get_str())*/)
{
    nSequence = strtoul(sequenceObj.get_str().c_str(), NULL, 16);
}

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:

createrawtransaction '[{"txid":"d5eb7e43a7cf85c5bee47a7a33c8351b8dcc013616a7c6bdc3af49538d986221","vout":0,"sequence":"0xfffffffe"}]' '{"mifzFw94bSGApmx2eWw1nzLCfEeq4cTwey":49.99}' 0
createrawtransaction '[{"txid":"d5eb7e43a7cf85c5bee47a7a33c8351b8dcc013616a7c6bdc3af49538d986221","vout":0,"sequence":"fffffffd"}]' '{"mifzFw94bSGApmx2eWw1nzLCfEeq4cTwey":49.99}' 0
createrawtransaction '[{"txid":"d5eb7e43a7cf85c5bee47a7a33c8351b8dcc013616a7c6bdc3af49538d986221","vout":0,"sequence":"f"}]' '{"mifzFw94bSGApmx2eWw1nzLCfEeq4cTwey":49.99}' 0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

sipa commented Jun 2, 2016

utACK e59336f

@paveljanik
Copy link
Contributor

utACK e59336f

@jonasschnelli
Copy link
Contributor Author

Added a commit with two bitcoin-tx tests to cover the sequence number feature.

@laanwj laanwj merged commit ae357d5 into bitcoin:master Jun 7, 2016
laanwj added a commit that referenced this pull request Jun 7, 2016
ae357d5 [Bitcoin-Tx] Add tests for sequence number support (Jonas Schnelli)
e59336f [bitcoin-tx] allow to set nSequence number over the in= command (Jonas Schnelli)
a946bb6 [RPC] createrawtransaction: add option to set the sequence number per input (Jonas Schnelli)
@laanwj
Copy link
Member

laanwj commented Jun 7, 2016

utACK ae357d5

codablock pushed a commit to codablock/dash that referenced this pull request Dec 22, 2017
ae357d5 [Bitcoin-Tx] Add tests for sequence number support (Jonas Schnelli)
e59336f [bitcoin-tx] allow to set nSequence number over the in= command (Jonas Schnelli)
a946bb6 [RPC] createrawtransaction: add option to set the sequence number per input (Jonas Schnelli)
zkbot added a commit to zcash/zcash that referenced this pull request Apr 13, 2018
CLI binary improvements

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#5936
- bitcoin/bitcoin#7550
- bitcoin/bitcoin#7989
- bitcoin/bitcoin#7957
- bitcoin/bitcoin#9067
- bitcoin/bitcoin#9220

Excludes any changes that affected the QT code.
sickpig pushed a commit to sickpig/BitcoinUnlimited that referenced this pull request May 4, 2018
…quence number

bitcoin/bitcoin#7957 - [RPC][Bitcoin-TX] Add support for sequence number
bitcoin/bitcoin#8164 - [Bitcoin-Tx] fix missing test fixtures, fix 32bit atoi issue
bitcoin/bitcoin#8171 - [RPC] Fix createrawtx sequence number unsigned int parsing

[RPC][Bitcoin-TX] Add support for sequence number
sickpig pushed a commit to sickpig/BitcoinUnlimited that referenced this pull request May 9, 2018
…quence number

bitcoin/bitcoin#7957 - [RPC][Bitcoin-TX] Add support for sequence number
bitcoin/bitcoin#8164 - [Bitcoin-Tx] fix missing test fixtures, fix 32bit atoi issue
bitcoin/bitcoin#8171 - [RPC] Fix createrawtx sequence number unsigned int parsing

[RPC][Bitcoin-TX] Add support for sequence number
andvgal pushed a commit to energicryptocurrency/gen2-energi that referenced this pull request Jan 6, 2019
ae357d5 [Bitcoin-Tx] Add tests for sequence number support (Jonas Schnelli)
e59336f [bitcoin-tx] allow to set nSequence number over the in= command (Jonas Schnelli)
a946bb6 [RPC] createrawtransaction: add option to set the sequence number per input (Jonas Schnelli)
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants