Add registername RPC with shared name_new commitment helper#2
Open
mstrofnone wants to merge 1 commit intomasterfrom
Open
Add registername RPC with shared name_new commitment helper#2mstrofnone wants to merge 1 commit intomasterfrom
mstrofnone wants to merge 1 commit intomasterfrom
Conversation
Add a new 'registername' RPC method that provides a simple single-call
interface for name registration: registername "myname" "my-value"
Unlike name_firstupdate (which requires a prior name_new and takes
rand/tx/value as separate positional args), registername takes just
a name and value, handling the commitment automatically:
1. Scan the wallet for a matching name_new commitment.
2. If none is found, create one automatically via name_new.
3. Build the name_firstupdate transaction.
4. If mempool-eligible, broadcast; otherwise commit to wallet for
automatic rebroadcast after the name_new matures.
Refactors the wallet scanning logic from name_firstupdate into a
shared findNameNewCommitment() helper that is reused by both
name_firstupdate and registername. This eliminates the duplicated
wallet scan code and makes the commitment-finding logic testable
independently.
name_firstupdate is completely unchanged in behavior -- power users
can still do the two-step manual procedure.
Returns {txid, rand} as a JSON object.
Includes functional tests covering:
- Basic registration with auto name_new
- Reuse of existing name_new commitment
- Duplicate name rejection
- Default (empty) value
- Parameter validation (name too long, value too long)
- Return format verification
Ref: namecoin#576, namecoin#579, namecoin#581
mstrofnone
pushed a commit
that referenced
this pull request
May 1, 2026
…lazy-init of decodepsbt_inputs d517fa0 rpc: fix initialization-order-fiasco by lazy-init of decodepsbt_inputs (Eugene Siegel) Pull request description: Prior to this commit, `decodepsbt_inputs` would call `TxDoc` during initialization which lives in another TLU. `TxDoc` relies on `CURRENCY_UNIT` to be initialized when it may not have been (note this is different from the TLU containing `decodepsbt_inputs` which also has a `CURRENCY_UNIT`). Fix this by lazy initializing `decodepsbt_inputs`. Also prevent the issue in the future by doing the same for `decodepsbt_outputs` and `getblock_vin`. Curious why the CI missed this, it broke fuzzamoto. It was introduced in fadf901. I was able to trigger this with clang-21 and `ASAN_OPTIONS="detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1"`: ``` ================================================================= ==926804==ERROR: AddressSanitizer: initialization-order-fiasco on address 0x5631e5784288 at pc 0x5631e3309f9c bp 0x7ffdb6abc7b0 sp 0x7ffdb6abc7a8 READ of size 8 at 0x5631e5784288 thread T0 #0 0x5631e3309f9b in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>::size() const /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/basic_string.h:1064:16 #1 0x5631e3309f9b in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> std::operator+<char, std::char_traits<char>, std::allocator<char>>(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/basic_string.tcc:618:35 #2 0x5631e4238948 in TxDoc(TxDocOptions const&) /root/bitcoin/src/rpc/rawtransaction_util.cpp:382:76 namecoin#3 0x5631e316945e in __cxx_global_var_init.9 /root/bitcoin/src/rpc/rawtransaction.cpp:784:17 namecoin#4 0x5631e3186355 in _GLOBAL__sub_I_rawtransaction.cpp /root/bitcoin/src/rpc/rawtransaction.cpp namecoin#5 0x7fa6ca046375 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x27375) (BuildId: 79005c16293efa45b441fed45f4f29b138557e9e) namecoin#6 0x5631e31cf160 in _start (/root/bitcoin/build/bin/bitcoind+0x25b160) 0x5631e5784288 is located 56 bytes before global variable 'CURRENCY_ATOM[abi:cxx11]' defined in '/root/bitcoin/src/policy/feerate.h:20' (0x5631e57842c0) of size 32 registered at: #0 0x5631e31e5738 in __asan_register_globals /root/llvm-project/compiler-rt/lib/asan/asan_globals.cpp:431:3 #1 0x5631e31e68a9 in __asan_register_elf_globals /root/llvm-project/compiler-rt/lib/asan/asan_globals.cpp:414:3 0x5631e5784288 is located 8 bytes inside of global variable 'CURRENCY_UNIT[abi:cxx11]' defined in '/root/bitcoin/src/policy/feerate.h:19' (0x5631e5784280) of size 32 registered at: #0 0x5631e31e5738 in __asan_register_globals /root/llvm-project/compiler-rt/lib/asan/asan_globals.cpp:431:3 #1 0x5631e31e68a9 in __asan_register_elf_globals /root/llvm-project/compiler-rt/lib/asan/asan_globals.cpp:414:3 SUMMARY: AddressSanitizer: initialization-order-fiasco /root/bitcoin/src/rpc/rawtransaction_util.cpp:382:76 in TxDoc(TxDocOptions const&) Shadow bytes around the buggy address: 0x5631e5784000: f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 0x5631e5784080: f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 0x5631e5784100: f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 0x5631e5784180: f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 0x5631e5784200: f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 =>0x5631e5784280: f6[f6]f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 0x5631e5784300: f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 0x5631e5784380: f6 f6 f6 f6 01 f9 f9 f9 f6 f6 f6 f6 f6 f6 f6 f6 0x5631e5784400: f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 0x5631e5784480: f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 0x5631e5784500: f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 f6 00 00 00 00 Shadow byte legend (one shadow byte represents 8 application bytes): Addressable: 00 Partially addressable: 01 02 03 04 05 06 07 Heap left redzone: fa Freed heap region: fd Stack left redzone: f1 Stack mid redzone: f2 Stack right redzone: f3 Stack after return: f5 Stack use after scope: f8 Global redzone: f9 Global init order: f6 Poisoned by user: f7 Container overflow: fc Array cookie: ac Intra object redzone: bb ASan internal: fe Left alloca redzone: ca Right alloca redzone: cb ==926804==ABORTING ``` Can be reviewed with `git diff HEAD~1 -w` since it's mostly indentation. ACKs for top commit: davidgumberg: crACK bitcoin/bitcoin@d517fa0 nervana21: tACK d517fa0 dergoegge: tACK d517fa0 Tree-SHA512: cfcaf4baccbb5748ab10ba5537cfacf38d7137b7ff051ccb9aba0f673718be1532487586b4f4e6d2f4526ca1786733009bd73a870d79a966b9c1fb38f7aaf5cc
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.
Add a new
registernameRPC method that provides a simple single-call interface for name registration:Unlike
name_firstupdate(which requires a priorname_newand takes rand/tx/value as separate positional args),registernametakes just a name and value, handling the commitment automatically:name_newcommitment.name_new.name_firstupdatetransaction.name_newmatures.Refactoring
Factors out the wallet scanning logic from
name_firstupdateinto a sharedfindNameNewCommitment()helper that is reused by bothname_firstupdateandregistername. This eliminates duplicated wallet scan code and makes the commitment-finding logic testable independently.The core logic for creating a name_new and building a name_firstupdate is not called via the RPC method
name_new()with all the RPC boilerplate around it, but instead uses the factored-out helper functions directly.name_firstupdateis completely unchanged in behavior — power users can still do the two-step manual procedure.Returns
{txid, rand}as a JSON object.Tests
Includes functional tests (
name_registername.py) covering:name_newname_newcommitmentRef: namecoin#576, namecoin#579, namecoin#581