Skip to content

Add registername RPC with shared name_new commitment helper#2

Open
mstrofnone wants to merge 1 commit intomasterfrom
feature/registername
Open

Add registername RPC with shared name_new commitment helper#2
mstrofnone wants to merge 1 commit intomasterfrom
feature/registername

Conversation

@mstrofnone
Copy link
Copy Markdown
Owner

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.

Refactoring

Factors out the wallet scanning logic from name_firstupdate into a shared findNameNewCommitment() helper that is reused by both name_firstupdate and registername. 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_firstupdate is 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:

  • 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

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
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.

1 participant