-
Notifications
You must be signed in to change notification settings - Fork 37.5k
[RPC] Add optional locktime to createrawtransaction #5936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
So... an extra parameter is kind of a pain because if we add any additional ones after it it becomes a pain to have to dummy out this one; so we should take care to make sure that this is really the order that we want the arguments in, and that maybe we don't want something else first. One way around this would be to take an array for additional named arguments. Is there a reason that the locktime=N parameter of bitcoin-tx doesn't already accommodate this functionality? You can createrawtransaction then use bitcointx to set the locktime. Though right now it doesn't set the sequence numbers but perhaps it should. |
Locktime is the only thing left at the same level as vin and vout, so it seems logical that it should be adjacent to them. Wouldn't more complex scripts, for example, be accommodated by adding flexibility in params[1]? I would like to use this in a python test, where adding in bitcoin-tx would be kind of messy. |
Transaction version is as well (and consider, upcoming anti-malleability BIP that makes the choice of transaction version an important decision). There may be other-meta-parameters like controls over ordering (e.g. the output address array is unordered.). I'm not sure how much this matters. |
Perhaps we should have support in the python test framework to use bitcoin-tx instead of createrawtransaction. |
"weak NAK" (that is, NAK, unless somebody can talk me out of it)
|
@jgarzik I just needed this, and thought it was harmless. No problem if I was mistaken. |
@sipa Or just depend on a more featureful Bitcoin library - would be pretty trivial to do in python-bitcoinlib... |
I'm with @jgarzik on this. We shouldn't extend "pure function" calls. Bitcoin-tx can handle locktime modification already. @dgenr8: For RPC tests i would recommend to fiddle with the hex-/byte-stream to change the lock_time's uint32_t. Isn't it always at the end of the serialized data? @petertodd: Adding a bitcoin library for tests would be possible however i think it would be a overkill and tests-environments should be lightweight to avoid test result displacement IMO. so I tend to NACK |
This PR is a bugfix imho since the rawtx API is now incapable of producing a tx that mimics the locked txes that the wallet generates. If this is closed, I'll get the job done one of those other ways in #5881. bitcoin-tx requires changes to be able to set nSequence compatibly with the wallet and nSequence also needs fiddling-with in the manual route. |
I agree with regard to no longer extending pure-utility functions. On the other hand this is trivial. So weak NACK only.
Yes, I'd prefer to do it in the test code itself too. It's quite easy to manipulate a transaction from Python. |
Hmm, it is unfortunate that createrawtransaction is unable to have
identically to sendtransaction now. I would consider that a bug, but I'm
not sure how to fix it.
An extra field is an option, but has the problems already discussed.
We could make it behave identical to sendtransaction wrt locktime by
default, but that is 1) not really in the spirit of createrawtransaction 2)
not replicatable in bitcoin-tx due to it not knowing the current height.
|
throw runtime_error( | ||
"createrawtransaction [{\"txid\":\"id\",\"vout\":n},...] {\"address\":amount,...}\n" | ||
"createrawtransaction [{\"txid\":\"id\",\"vout\":n},...] {\"address\":amount,...} locktime\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fails to express that locktime is optional.
ut implementation OK (although I agree it is better not to extend utility RPC in principle) |
690366f
to
053526e
Compare
Updated 1-line help to indicate locktime is optional. Thanks Luke. |
A non-zero locktime also causes input sequences to be set to non-max, activating the locktime.
053526e
to
212bcca
Compare
Closing this. "The wind is blowing negative" based on comments, and the long term direction is to remove pure function RPC calls; you don't need to call a server to achieve what is better left to a lib or bitcoin-tx. Just as easy to use bitcoin-tx as it is to use bitcoin-cli from the command line. And if it's custom code, just use a lib. |
Recap:
Conclusion: [ERROR] internal consistency failure |
Happy to re-open this if people think it will get merged in the short term. "easy to close, easy to reopen" is the more general goal. |
IMO it makes more sense to merge this than #6346 did |
Reopnening this. Even though I'd like to move away from internal utility functions as well, it has only very local code impact but there are a lot of people asking for it, so may as well merge it in the "doesn't hurt" category. |
212bcca Add optional locktime to createrawtransaction (Tom Harding)
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.
A non-zero locktime also causes input sequences to be set to non-max, activating the locktime.