-
Notifications
You must be signed in to change notification settings - Fork 12
Use improved getCoinbaseTx() if available #59
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
Draft
Sjors
wants to merge
2
commits into
stratum-mining:master
Choose a base branch
from
Sjors:2025/11/coinbase
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| // Copyright (c) 2025 The Bitcoin Core developers | ||
| // Distributed under the MIT software license, see the accompanying | ||
| // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
|
||
| #ifndef BITCOIN_SV2_COINBASE_TEMPLATE_H | ||
| #define BITCOIN_SV2_COINBASE_TEMPLATE_H | ||
|
|
||
| #include <consensus/amount.h> | ||
| #include <cstddef> | ||
| #include <cstdint> | ||
| #include <optional> | ||
| #include <script/script.h> | ||
| #include <primitives/transaction.h> | ||
| #include <util/time.h> | ||
| #include <vector> | ||
|
|
||
| namespace node { | ||
|
|
||
| struct CoinbaseTxTemplate { | ||
| /* nVersion */ | ||
| uint32_t version; | ||
| /* nSequence for the only coinbase transaction input */ | ||
| uint32_t sequence; | ||
| /** | ||
| * Prefix which needs to be placed at the beginning of the scriptSig. | ||
| * Clients may append extra data to this as long as the overall scriptSig | ||
| * size is 100 bytes or less, to avoid the block being rejected with | ||
| * "bad-cb-length" error. | ||
| * | ||
| * Currently with BIP 34, the prefix is guaranteed to be less than 8 bytes, | ||
| * but future soft forks could require longer prefixes. | ||
| */ | ||
| CScript script_sig_prefix; | ||
| /** | ||
| * The first (and only) witness stack element of the coinbase input. | ||
| * | ||
| * Omitted for block templates without witness data. | ||
| * | ||
| * This is currently the BIP 141 witness reserved value, and can be chosen | ||
| * arbitrarily by the node, but future soft forks may constrain it. | ||
| */ | ||
| std::optional<uint256> witness; | ||
| /** | ||
| * Block subsidy plus fees, minus any non-zero required_outputs. | ||
| * | ||
| * Currently there are no non-zero required_outputs, so block_reward_remaining | ||
| * is the entire block reward. See also required_outputs. | ||
| */ | ||
| CAmount block_reward_remaining; | ||
| /* | ||
| * To be included as the last outputs in the coinbase transaction. | ||
| * Currently this is only the witness commitment OP_RETURN, but future | ||
| * softforks or a custom mining patch could add more. | ||
| * | ||
| * The dummy output that spends the full reward is excluded. | ||
| */ | ||
| std::vector<CTxOut> required_outputs; | ||
| uint32_t lock_time; | ||
| }; | ||
|
|
||
| } // namespace node | ||
|
|
||
| #endif // BITCOIN_SV2_COINBASE_TEMPLATE_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
In the new constructor the loop just pushes all required_outputs:
This trusts that
getCoinbase()already filtered to OP_RETURN outputs. The fallback path doesthe filtering in
ExtractCoinbaseTemplate(). This is correct assuming Bitcoin Core'sgetCoinbase()returns pre-filtered outputs - just worth double-checking in Bitcoin Core.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.
Indeed. I think it's better that Bitcoin Core handles this filtering. This means we no longer have to assume only
OP_RETURNoutputs are possible.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.
I think we can say the PR is ready for merging.
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.
Thanks, I plan to do that after bitcoin/bitcoin#33819 lands.