Repository navigation
Conversation
l0rinc
force-pushed
the
l0rinc/encapsulate-ctransaction-fields
branch
7 times, most recently
from
July 7, 2026 20:20
719dcf1 to
a3bfcf3
Compare
Route generic transaction code through `tx_detail` overload helpers before changing any `CTransaction` fields. The helpers delegate to the public field on `CMutableTransaction` and to the matching field or observer on `CTransaction`. This removes the incidental dependency on both transaction types sharing public member names, so later commits can leave `CMutableTransaction` unchanged while migrating only the immutable transaction side. At this point the `CTransaction` overload bodies still contain direct field access, which lets the later field-observer scripted diffs update those overloads mechanically. Co-authored-by: Daniel Pfeifer <[email protected]>
Spell policy and RPC transaction-version constants as `uint32_t` before `CTransaction::version` stops being public. These values are protocol version numbers, so the field migration commits do not need to carry this cleanup. Co-authored-by: Daniel Pfeifer <[email protected]>
Add a parameterized `bitcoin-tidy` check that rewrites reads of a configured qualified field to the observer call derived from a configured observer declaration, renames the configured storage field with the `m_` prefix, and inserts the observer declaration after the renamed field declaration. The helper is option-driven rather than tied to `CTransaction` because the following scripted diffs run it once per `CTransaction` field. When no field-observer options are provided, the check registers no matchers so regular `clang-tidy` runs can load it through `bitcoin-*` without requiring scripted-diff configuration. Partial or malformed check options produce `clang-tidy` configuration diagnostics instead of silently registering no matchers. Keep the bitcoin-tidy self-test scoped to `bitcoin-nontrivial-threadlocal`, because this check is option-driven and only runs when a scripted diff provides its field and observer options. Install the lint-environment build, ccache, and clang-tidy packages needed by scripted diffs that run this helper, and raise the lint timeout so CI can host those verifier runs. The verify scripts still perform their own configure/build steps, so the lint checker does not need custom setup logic. Co-authored-by: Daniel Pfeifer <[email protected]>
l0rinc
force-pushed
the
l0rinc/encapsulate-ctransaction-fields
branch
from
July 8, 2026 20:47
a3bfcf3 to
632286a
Compare
Run `bitcoin-field-observers` for `::CTransaction::nLockTime` so external reads use the observer, the storage field is renamed with the `m_` prefix, and the observer is added.
`CMutableTransaction::nLockTime` stays public.
-BEGIN VERIFY SCRIPT-
export CC=clang
export CXX=clang++
rm -rf /tmp/bitcoin-field-observers-build /tmp/bitcoin-field-observers-tidy
cmake -B /tmp/bitcoin-field-observers-build -S . -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DBUILD_GUI=ON -DBUILD_KERNEL_LIB=ON -DBUILD_UTIL_CHAINSTATE=ON -DENABLE_IPC=OFF -DWITH_QRENCODE=OFF
cmake --build /tmp/bitcoin-field-observers-build --parallel "$(nproc)" && cmake -B /tmp/bitcoin-field-observers-tidy -S contrib/devtools/bitcoin-tidy && cmake --build /tmp/bitcoin-field-observers-tidy --parallel "$(nproc)"
run-clang-tidy -j "$(nproc)" -p=/tmp/bitcoin-field-observers-build -load=/tmp/bitcoin-field-observers-tidy/libbitcoin-tidy.so -checks='-*,bitcoin-field-observers' \
-config='{
CheckOptions: {
bitcoin-field-observers.ReplacementMainFile: "src/primitives/transaction.cpp",
bitcoin-field-observers.QualifiedFieldName: "::CTransaction::nLockTime",
bitcoin-field-observers.AccessorDeclaration: "uint32_t nLockTime() const { return m_nLockTime; }"
}
}' -header-filter='.*' -fix
-END VERIFY SCRIPT-
Co-authored-by: Daniel Pfeifer <[email protected]>
Run `bitcoin-field-observers` for `::CTransaction::version` so external reads use the observer, the storage field is renamed with the `m_` prefix, and the observer is added.
`CMutableTransaction::version` stays public.
-BEGIN VERIFY SCRIPT-
export CC=clang
export CXX=clang++
rm -rf /tmp/bitcoin-field-observers-build /tmp/bitcoin-field-observers-tidy
cmake -B /tmp/bitcoin-field-observers-build -S . -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DBUILD_GUI=ON -DBUILD_KERNEL_LIB=ON -DBUILD_UTIL_CHAINSTATE=ON -DENABLE_IPC=OFF -DWITH_QRENCODE=OFF
cmake --build /tmp/bitcoin-field-observers-build --parallel "$(nproc)" && cmake -B /tmp/bitcoin-field-observers-tidy -S contrib/devtools/bitcoin-tidy && cmake --build /tmp/bitcoin-field-observers-tidy --parallel "$(nproc)"
run-clang-tidy -j "$(nproc)" -p=/tmp/bitcoin-field-observers-build -load=/tmp/bitcoin-field-observers-tidy/libbitcoin-tidy.so -checks='-*,bitcoin-field-observers' \
-config='{
CheckOptions: {
bitcoin-field-observers.ReplacementMainFile: "src/primitives/transaction.cpp",
bitcoin-field-observers.QualifiedFieldName: "::CTransaction::version",
bitcoin-field-observers.AccessorDeclaration: "uint32_t version() const { return m_version; }"
}
}' -header-filter='.*' -fix
-END VERIFY SCRIPT-
Co-authored-by: Daniel Pfeifer <[email protected]>
Run `bitcoin-field-observers` for `::CTransaction::vout` so external reads use the observer, the storage field is renamed with the `m_` prefix, and the observer is added.
`CMutableTransaction::vout` stays public.
-BEGIN VERIFY SCRIPT-
export CC=clang
export CXX=clang++
rm -rf /tmp/bitcoin-field-observers-build /tmp/bitcoin-field-observers-tidy
cmake -B /tmp/bitcoin-field-observers-build -S . -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DBUILD_GUI=ON -DBUILD_KERNEL_LIB=ON -DBUILD_UTIL_CHAINSTATE=ON -DENABLE_IPC=OFF -DWITH_QRENCODE=OFF
cmake --build /tmp/bitcoin-field-observers-build --parallel "$(nproc)" && cmake -B /tmp/bitcoin-field-observers-tidy -S contrib/devtools/bitcoin-tidy && cmake --build /tmp/bitcoin-field-observers-tidy --parallel "$(nproc)"
run-clang-tidy -j "$(nproc)" -p=/tmp/bitcoin-field-observers-build -load=/tmp/bitcoin-field-observers-tidy/libbitcoin-tidy.so -checks='-*,bitcoin-field-observers' \
-config='{
CheckOptions: {
bitcoin-field-observers.ReplacementMainFile: "src/primitives/transaction.cpp",
bitcoin-field-observers.QualifiedFieldName: "::CTransaction::vout",
bitcoin-field-observers.AccessorDeclaration: "const std::vector<CTxOut>& vout() const LIFETIMEBOUND { return m_vout; }"
}
}' -header-filter='.*' -fix
-END VERIFY SCRIPT-
Co-authored-by: Daniel Pfeifer <[email protected]>
Run `bitcoin-field-observers` for `::CTransaction::vin` so external reads use the observer, the storage field is renamed with the `m_` prefix, and the observer is added.
`CMutableTransaction::vin` stays public.
-BEGIN VERIFY SCRIPT-
export CC=clang
export CXX=clang++
rm -rf /tmp/bitcoin-field-observers-build /tmp/bitcoin-field-observers-tidy
cmake -B /tmp/bitcoin-field-observers-build -S . -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON -DBUILD_GUI=ON -DBUILD_KERNEL_LIB=ON -DBUILD_UTIL_CHAINSTATE=ON -DENABLE_IPC=OFF -DWITH_QRENCODE=OFF
cmake --build /tmp/bitcoin-field-observers-build --parallel "$(nproc)" && cmake -B /tmp/bitcoin-field-observers-tidy -S contrib/devtools/bitcoin-tidy && cmake --build /tmp/bitcoin-field-observers-tidy --parallel "$(nproc)"
run-clang-tidy -j "$(nproc)" -p=/tmp/bitcoin-field-observers-build -load=/tmp/bitcoin-field-observers-tidy/libbitcoin-tidy.so -checks='-*,bitcoin-field-observers' \
-config='{
CheckOptions: {
bitcoin-field-observers.ReplacementMainFile: "src/primitives/transaction.cpp",
bitcoin-field-observers.QualifiedFieldName: "::CTransaction::vin",
bitcoin-field-observers.AccessorDeclaration: "const std::vector<CTxIn>& vin() const LIFETIMEBOUND { return m_vin; }"
}
}' -header-filter='.*' -fix
-END VERIFY SCRIPT-
Co-authored-by: Daniel Pfeifer <[email protected]>
Move the renamed `CTransaction` storage members behind the class boundary once all external reads have been migrated. The previous commits keep the transaction data `const` and add only read-only observers. This commit preserves that shape: it changes visibility and declaration placement, declares copy construction explicitly, deletes copy assignment, and leaves `CMutableTransaction` as the mutable construction type. The declared copy constructor keeps `CTransaction` without an implicit move constructor while still allowing containers to copy from rvalues when required. It also updates comments that still referenced the old public member spelling. Co-authored-by: Daniel Pfeifer <[email protected]>
l0rinc
force-pushed
the
l0rinc/encapsulate-ctransaction-fields
branch
from
July 8, 2026 21:05
632286a to
f926510
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem:
CTransactionexposesvin,vout,version, andnLockTimeas public fields, so callers depend on the layout of the immutable transaction object.bitcoin#35569 solves this with
GetInputs()/GetOutputs()style (non-reusable) observers that migrate everything (includingCMutableTransaction) all at once.Fix: This stack first routes generic transaction reads through small
tx_detailoverloads, soCTransactionandCMutableTransactionno longer need matching public member names.It then adds a parameterized
bitcoin-field-observerstidy helper and uses four one-fieldscripted-diffcommits to renameCTransactionstorage tom_..., add protocol-name observers (vin(),vout(),version(), andnLockTime()), and rewrite external reads mechanically.The final commit moves the renamed
conststorage private and updates comments.CMutableTransactionremains the mutable construction type with public mutable fields.