Skip to content

Conversation

@Sjors
Copy link
Collaborator

@Sjors Sjors commented Nov 7, 2025

Take advantage of the improved getCoinbaseTx() introduced in bitcoin/bitcoin#33819 which provides a CoinbaseTemplate struct.

This lets us avoid parsing Bitcoin Core's dummy transaction. For backwards compatibility when using the deprecated getCoinbaseRawTx() the ExtractCoinbaseTxTemplate still does that. This can be dropped after a Bitcoin Core release ships with the new method.

Builds on:

@Sjors
Copy link
Collaborator Author

Sjors commented Nov 11, 2025

Rebased after #57 and bumped getCoinbase to @12.

Copy link
Contributor

@xyephy xyephy left a comment

Choose a reason for hiding this comment

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

Concept ACK, this is a much cleaner way to handle coinbase templates. I've highlighted the Assert fix in the comments below , then this is ready to merge (after #58 is fixed).

@Sjors
Copy link
Collaborator Author

Sjors commented Nov 17, 2025

Updated against the latest changes in bitcoin/bitcoin#33819 (e.g. renaming inputSequence to sequence).

@Sjors
Copy link
Collaborator Author

Sjors commented Nov 18, 2025

Empty push after #58 was merged so Github sees it's only one commit now.

Comment on lines +25 to +26
for (const auto& output : coinbase.required_outputs) {
m_coinbase_tx_outputs.push_back(output);
Copy link
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can say the PR is ready for merging.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks, I plan to do that after bitcoin/bitcoin#33819 lands.

@Sjors Sjors changed the title Use getCoinbase() if available Use improved getCoinbase() if available Dec 3, 2025
@Sjors Sjors changed the title Use improved getCoinbase() if available Use improved getCoinbaseTx() if available Dec 3, 2025
Sjors added 2 commits December 3, 2025 15:24
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.
@Sjors
Copy link
Collaborator Author

Sjors commented Dec 3, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants