Use improved getCoinbaseTx() if available#59
Conversation
b31cc6c to
a0d4a73
Compare
|
Rebased after #57 and bumped |
a0d4a73 to
e1f0117
Compare
|
Updated against the latest changes in bitcoin/bitcoin#33819 (e.g. renaming |
e1f0117 to
ece49d3
Compare
|
Empty push after #58 was merged so Github sees it's only one commit now. |
| for (const auto& output : coinbase.required_outputs) { | ||
| m_coinbase_tx_outputs.push_back(output); |
There was a problem hiding this comment.
In the new constructor the loop just pushes all required_outputs:
This trusts that getCoinbase() already filtered to OP_RETURN outputs. The fallback path does
the filtering in ExtractCoinbaseTemplate(). This is correct assuming Bitcoin Core's
getCoinbase() returns pre-filtered outputs - just worth double-checking in Bitcoin Core.
There was a problem hiding this comment.
This trusts that getCoinbase() already filtered to OP_RETURN outputs.
Indeed. I think it's better that Bitcoin Core handles this filtering. This means we no longer have to assume only OP_RETURN outputs are possible.
There was a problem hiding this comment.
I think we can say the PR is ready for merging.
There was a problem hiding this comment.
Thanks, I plan to do that after bitcoin/bitcoin#33819 lands.
ece49d3 to
3f68384
Compare
|
Updated to match the latest Bitcoin Core PR version. The interface changes in that latest update only rename methods and variables, which doesn't impact IPC, so you can still use ece49d3. |
48f57bb mining: add new getCoinbaseTx() returning a struct (Sjors Provoost) d59b4cd mining: rename getCoinbaseTx() to ..RawTx() (Sjors Provoost) Pull request description: The first commit renames `getCoinbaseTx()` to `getCoinbaseRawTx()` to reflect that it returns a serialised transaction. This does not impact IPC clients, because they do not use the function name. The second commit then introduces a replacement `getCoinbase()` that provides a struct with everything clients need to construct a coinbase. This avoids clients having to parse and manipulate our dummy transaction. Deprecate but don't remove `getCoinbaseRawTx()`, `getCoinbaseCommitment()` and `getWitnessCommitmentIndex()`. After this change we can drop these deprecated methods, which in turn would allow us to clear the dummy transaction from the `getBlock()` result. But that is left for a followup to keep this PR focussed. See Sjors#106 for an approach. Expand the `interface_ipc.py` functional test to document its usage. Can be tested using: - stratum-mining/sv2-tp#59 ACKs for top commit: ryanofsky: Code review ACK 48f57bb. Just rebased and addressed comments and dropped coinbase tx "template" suffix, which is a nice change ismaelsadeeq: code review ACK 48f57bb vasild: ACK 48f57bb Tree-SHA512: c4f1d752777fb3086a1a0b7b8b06e4205dbe2f3adb41f218855ad1dee952adccc263cf82acd3bf9300cc83c2c64cebd2b27f66a69beee32d325b9a85e3643b0d
This frees up the name getCoinbaseTx() for the next commit. Changing a function name does not impact IPC clients, as they only consider the function signature and sequence number.
Avoid the brittle process of constructing the template coinbase fields from Bitcoin Core's dummy coinbase transaction. This uses the new getCoinbaseTx() interface method. Fall back to the old approach if that method is not available.
3f68384 to
ee016be
Compare
|
Rebased. Renamed bitcoin/bitcoin#33819 was merged so this is ready. For testing: use the master branch from Bitcoin Core |
xyephy
left a comment
There was a problem hiding this comment.
tACK.
The CoinbaseTx struct, ExtractCoinbaseTx fallback, and the try/catch backward compatibility mechanism all work correctly. Ready to merge.
Take advantage of the improved
getCoinbaseTx()introduced in bitcoin/bitcoin#33819 which provides aCoinbaseTemplatestruct.This lets us avoid parsing Bitcoin Core's dummy transaction. For backwards compatibility when using the deprecated
getCoinbaseRawTx()theExtractCoinbaseTxTemplatestill does that. This can be dropped after a Bitcoin Core release ships with the new method.Builds on: