rpc: add registername with auto-commitment support#1
Open
mstrofnone wants to merge 1 commit intomasterfrom
Open
rpc: add registername with auto-commitment support#1mstrofnone wants to merge 1 commit intomasterfrom
mstrofnone wants to merge 1 commit intomasterfrom
Conversation
cf841f4 to
ab6995f
Compare
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
ab6995f to
907636a
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.
Add a new
registernameRPC method that wrapsname_firstupdatewith improved UX: if no matchingname_newcommitment is found in the wallet, one is created automatically before proceeding.Motivation
As discussed in namecoin#576 and namecoin#579, the separate
name_autoregisterRPC creates UX friction by being its own method. This PR rolls that functionality intoregistername(the Bitcoin Core convention alias forname_firstupdate), giving average users a single-call registration flow while preserving the two-step manual procedure for power users.Behaviour
When called as
registername:name_newcommitment input.name_newautomatically to create one.name_firstupdatetransaction.name_newmatures (via the wallet'sblockConnectedrebroadcast logic).When called as
name_firstupdate(the original method), the old behaviour is preserved — it simply fails if no commitment is found.Implementation
name_firstupdate_impl()is a shared static helper parameterised by method name.name_firstupdate()andregistername()both delegate to it.JSONRPCRequestforname_newreusing the caller's context.getNamePrevoutfor when the just-createdname_newoutput is not yet inCoinsTip(unconfirmed).registernameis registered as a separate RPC command (not an alias sharingunique_id) so it gets its own help text describing the auto-commitment behaviour.Usage
Ref: namecoin#576, namecoin#579