Skip to content

Conversation

levonpetrosyan93
Copy link
Contributor

No description provided.

Copy link

coderabbitai bot commented Apr 17, 2025

Walkthrough

This update modifies Spark name-related RPC commands and consensus parameters. The ZC_SIGMA_END_BLOCK constant is updated and its usage is standardized in the chain parameters. In the RPC layer, the getsparknamedata method is changed to return a JSON object and require exactly one parameter, and a new getsparknametxdetails RPC method is introduced to retrieve Spark name and address from a transaction hash. In the wallet RPC, the Spark name detail commands getsparknamedata and getsparknametxdetails are removed, and only getsparknames remains with a minor help text update.

Changes

Files/Paths Change Summary
src/firo_params.h, src/chainparams.cpp Updated ZC_SIGMA_END_BLOCK constant value and replaced hardcoded integer with the symbolic constant.
src/rpc/blockchain.cpp Renamed getsparknames to getsparknamedata with new parameter and output format; added getsparknametxdetails; updated RPC registration.
src/wallet/rpcwallet.cpp Removed getsparknamedata and getsparknametxdetails RPC commands and registration; updated help text for getsparknames.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant RPC_Server
    participant Chain
    participant SparkNameManager

    User->>RPC_Server: getsparknamedata(sparkname)
    RPC_Server->>Chain: Lock chain state
    RPC_Server->>SparkNameManager: Query sparkname
    SparkNameManager-->>RPC_Server: Return address, validUntil, additionalInfo
    RPC_Server-->>User: Return JSON object {address, validUntil, additionalInfo}

    User->>RPC_Server: getsparknametxdetails(txhash)
    RPC_Server->>Chain: Lock chain state
    RPC_Server->>Chain: Retrieve transaction by txhash
    alt Valid Spark Name TX
        RPC_Server->>SparkNameManager: Extract name and address
        RPC_Server-->>User: Return JSON object {sparkname, sparkaddress}
    else Error
        RPC_Server-->>User: Error (unknown/invalid tx)
    end

    User->>RPC_Server: getsparknames(fOnlyOwn)
    RPC_Server->>Chain: Lock chain state
    RPC_Server->>SparkNameManager: Get all spark names
    alt fOnlyOwn == true
        RPC_Server->>SparkNameManager: Filter to wallet-owned names
    end
    SparkNameManager-->>RPC_Server: List of names and addresses
    RPC_Server-->>User: Return array of {sparkname, sparkaddress}
Loading

Possibly related PRs

  • firoorg/firo#1529: Refactors and extends Spark name RPC commands, directly modifying the same RPC functions as this PR.
  • firoorg/firo#1477: Updates the ZC_SIGMA_END_BLOCK constant and its usage, which is further modified in this PR.

Poem

In the warren of code, a Spark name shines bright,
With constants aligned and RPCs set right.
Old commands are gone, new helpers appear,
Spark names and addresses are now crystal clear.
The blockchain hops forward, the wallet keeps pace—
A bunny’s delight in this Spark-named race!
🐇✨

Tip

⚡💬 Agentic Chat (Pro Plan, General Availability)
  • We're introducing multi-step agentic chat in review comments and issue comments, within and outside of PR's. This feature enhances review and issue discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments and add commits to existing pull requests.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 130a909 and b5fc891.

📒 Files selected for processing (4)
  • src/chainparams.cpp (1 hunks)
  • src/firo_params.h (1 hunks)
  • src/rpc/blockchain.cpp (3 hunks)
  • src/wallet/rpcwallet.cpp (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/wallet/rpcwallet.cpp (2)
src/rpc/server.h (2)
  • HelpExampleCli (201-201)
  • HelpExampleRpc (202-202)
src/rpc/server.cpp (4)
  • HelpExampleCli (591-594)
  • HelpExampleCli (591-591)
  • HelpExampleRpc (596-600)
  • HelpExampleRpc (596-596)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Create Source Distribution
  • GitHub Check: Create Source Distribution
🔇 Additional comments (6)
src/chainparams.cpp (1)

419-419: Fix the usage of ZC_SIGMA_END_BLOCK constant

The assignment uses the ZC_SIGMA_END_BLOCK constant, which was defined with a trailing semicolon in firo_params.h. This will result in a double semicolon in this line, which is syntactically valid but not good practice.

Make sure to remove the trailing semicolon from the ZC_SIGMA_END_BLOCK definition in firo_params.h to ensure proper behavior.

src/rpc/blockchain.cpp (4)

220-231: Improved RPC documentation and interface for getsparknamedata

The function signature has been updated to require exactly one parameter and the documentation now clearly indicates the function returns a JSON object with named fields instead of an array.


250-261: Enhanced return format for getsparknamedata

The return format has been improved to use a proper JSON object with named fields instead of a positional array, making the API more robust and self-documenting.


264-312: New RPC method getsparknametxdetails

Added a new RPC method to retrieve spark name and address from a transaction hash. The implementation properly:

  1. Checks if Spark is activated
  2. Retrieves the transaction by hash
  3. Validates the transaction as a spark name transaction
  4. Returns the appropriate data or error messages

1797-1798: Updated RPC command registration

The command registration has been properly updated to include the parameter name for getsparknamedata and to register the new getsparknametxdetails method.

src/wallet/rpcwallet.cpp (1)

3952-3999: LGTM! Well-implemented RPC rename with clear documentation.

The renaming of getsparknames to getownsparknames is well implemented with clear documentation and proper error handling. The function maintains its core functionality while adding a useful parameter to filter results by ownership.

Copy link
Contributor

@psolstice psolstice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why getownsparknames is needed? There is already an argument for getsparknames doing that (a single argument set to true retrieves only own spark names)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5090e85 and 460173f.

📒 Files selected for processing (2)
  • src/rpc/blockchain.cpp (3 hunks)
  • src/wallet/rpcwallet.cpp (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/wallet/rpcwallet.cpp
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Create Source Distribution
  • GitHub Check: Create Source Distribution
🔇 Additional comments (2)
src/rpc/blockchain.cpp (2)

180-223: New getsparknamedata implementation looks good

The function has been properly implemented to take a spark name as a required parameter and return structured data about the spark name. It correctly checks for Spark activation before proceeding, ensuring backward compatibility with nodes that haven't activated this feature yet.


1758-1759: RPC commands registration updated correctly

The RPC command registration table now includes the renamed getsparknamedata method and the new getsparknametxdetails method, both with proper parameter specifications.

Comment on lines +226 to 274
UniValue getsparknametxdetails(const JSONRPCRequest &request)
{
if (request.fHelp || request.params.size() > 1) {
if (request.fHelp || request.params.size() != 1) {
throw std::runtime_error(
"getsparknamedata ( sparkname )\n"
"\nReturns info about spark name.\n"
"getsparknametxdetails (txhash)\n"
"\nReturns spark address and spark name associated with tx hash.\n"
"\nArguments:\n"
"Spark name (string)\n"
"1. txhash\n"
"\nResult:\n"
"[\n"
"1. Address (string)\n"
"2. Block height until this spark name is valid (int)\n"
"3. Additional info (string)\n"
" \"Name (string)\n"
" \"Address (string)\"\n"
" ...\n"
"]\n"
"\nExamples:\n"
+ HelpExampleCli("getsparknamedata", "sparkname")
+ HelpExampleRpc("getsparknamedata", "sparkname")
+ HelpExampleCli("getsparknametxdetails", "txhash")
+ HelpExampleRpc("getsparknametxdetails", "txhash")
);
}

LOCK(cs_main);

if (!spark::IsSparkAllowed()) {
throw JSONRPCError(RPC_WALLET_ERROR, "Spark is not activated yet");
}

std::string sparkName = request.params[0].get_str();
CSparkNameManager *sparkNameManager = CSparkNameManager::GetInstance();
std::string strTxId = request.params[0].get_str();
uint256 txid = uint256S(strTxId);

std::string SparkAddr;
sparkNameManager->GetSparkAddress(sparkName, SparkAddr);

UniValue result(UniValue::VARR);
unsigned char network = spark::GetNetworkType();
CTransactionRef txRef;
uint256 hashBlock;
if(!GetTransaction(txid, txRef, Params().GetConsensus(), hashBlock, true))
throw JSONRPCError(RPC_TRANSACTION_ERROR, "Unknown transaction.");

result.push_back(SparkAddr);
CSparkNameTxData sparkNameData;
CValidationState state;
CSparkNameManager *sparkNameManager = CSparkNameManager::GetInstance();

uint64_t nameBlockHeight = sparkNameManager->GetSparkNameBlockHeight(sparkName);
result.push_back(nameBlockHeight);
const CTransaction& tx = *txRef;
if (!sparkNameManager->CheckSparkNameTx(tx, chainActive.Height(), state, &sparkNameData))
throw JSONRPCError(RPC_TRANSACTION_ERROR, "Invalid spark tx hash");

std::string sparkNameData = sparkNameManager->GetSparkNameAdditionalData(sparkName);
result.push_back(sparkNameData);
if (sparkNameData.name.empty() && sparkNameData.sparkAddress.empty())
throw JSONRPCError(RPC_TRANSACTION_ERROR, "Invalid spark name tx hash");

UniValue result(UniValue::VOBJ);
result.push_back(Pair("name", sparkNameData.name));
result.push_back(Pair("address", sparkNameData.sparkAddress));
return result;
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Inconsistency between documentation and implementation in getsparknametxdetails

The implementation properly retrieves and validates a spark name transaction, but there's a discrepancy between the help text and the actual return value:

  • The help text in lines 235-239 describes the result as a JSON array [ "Name (string)", "Address (string)", ... ]
  • The actual implementation in lines 270-273 returns a JSON object { "name": "...", "address": "..." }

Update the help text to match the actual implementation:

    "\nResult:\n"
-    "[\n"
-    "  \"Name (string)\n"
-    "  \"Address (string)\"\n"
-    "  ...\n"
-    "]\n"
+    "{\n"
+    "  \"name\": \"...\",       (string) The spark name\n"
+    "  \"address\": \"...\"     (string) The spark address\n"
+    "}\n"

@reubenyap reubenyap merged commit c24d9d3 into master Apr 18, 2025
11 checks passed
@reubenyap reubenyap deleted the build_fix branch April 18, 2025 09:08
aleflm added a commit that referenced this pull request Apr 23, 2025
Rebase includes:

* UI improvements (#1475)

* Lelantus UI stripped

* More improvements

* Fixed UI hang issue during batch verification

* QT hanging improvements

* QT hanging fix

* Review commits applied

* coderabbit comments applied

* more coderabbitai comments resolved

---------

Co-authored-by: firstcryptoman <firstcryptoman@gmail.com>

* Spark names (#1532)

* Initial spark name architecture

* Spark address ownership proofs implemented.

* Missing files added

* Check the ownership proof for spark names: initial implementation

* Fixes to the core part of spark names

* Added additional field (core)

* Consensus parameters for spark names

* Fixed mempool bug

* Fixes in spark name conflict resolution

* RPCs for spark names

* Additional API for spark names tx creation

* Changed way of checking spark name tx

* Wallet API for spark name transaction creation

* API changes for spark name tx creation

* Added registersparkname RPC call

* Spark activation check for RPC

* Make spark names case-insensitive

* Spark name RPC fixes

* Faster lookup for spark name by spark address

* Fixes for spark name/address lookup

* Improvements for duplicated address detection

* Fixes for spark name state

* Block index entries for spark names

* Make dot (.) a legit symbol in spark name

* Spark name block number for testnet

* Fixed restoration of old spark name data if block is disconnected

* API for quick check of spark name transaction validity before the creation

* added isAddressMine function

* Check if the address belongs to the wallet before creating spark name transaction

* Fixed fee calculation for spark name

* Fix for spark names RPC

* Added ability to spend to spark names in "sparkspend" RPC

* UI fixes

* Additional validations

* Fix for crash with spend to unregistered name

* Fixed fee value when registering spark name for more than one year

* Spark name UI improvements

* UI modifications for sending to spark name

* Address book fixes related to spark names

* Fixed period of validity when creating spark name through GUI

* Extended spark name error info for RPC

* Fixed crash on non-HD wallet

* Request wallet password for spark name creation

* Fixed fee calculation for the spark name tx

* Fixed detection of previously used spark address for a spark name

* Unit test for spark names

* Additional unit tests

* Fixes #1533

* getsparknamedata RPC now returns JSON object

* Added "My own spark names" to the dropdown list in address book

* Added an option of displaying only own spark names for RPC. Closes #1535

* Set HF block for spark names

* Fixed a check for spark name block start

* Added tests for correctly respecting HF block number

* Check if we're over HF before spark name transaction creation

* new rpc for spark name (#1552)

* Fixed spark name tests

* Changed HF date

* Change of HF block number

---------

Co-authored-by: levonpetrosyan93 <petrosyan.levon93@gmail.com>
Co-authored-by: levoncrypto <levoncrypto1994@gmail.com>
Co-authored-by: levoncrypto <95240473+levoncrypto@users.noreply.github.com>
Co-authored-by: levonpetrosyan93 <45027856+levonpetrosyan93@users.noreply.github.com>

* Export View Keys (#1543)

* Add an RPC command to export the Spark view key.

* Show Spark View Key in Qt.

* Sigma pool closed, Extra payload extended (#1477)

* Change of emission rules

* Fixes for testnet

* Cleaning up code and tests

* Workaround for current devnet bugs

* Workaround for testnet

* Devnet parameter tweak

* Sigma pool closed

* Extra payload size limit increased

* Changed HF block for testnet

* Initial spark name architecture

* Spark address ownership proofs implemented.

* Missing files added

* Check the ownership proof for spark names: initial implementation

* Fixes to the core part of spark names

* Added additional field (core)

* Consensus parameters for spark names

* Fixed mempool bug

* Fixes in spark name conflict resolution

* RPCs for spark names

* Additional API for spark names tx creation

* Changed way of checking spark name tx

* Wallet API for spark name transaction creation

* API changes for spark name tx creation

* Added registersparkname RPC call

* Spark activation check for RPC

* Make spark names case-insensitive

* Spark name RPC fixes

* Faster lookup for spark name by spark address

* Fixes for spark name/address lookup

* Improvements for duplicated address detection

* Fixes for spark name state

* Block index entries for spark names

* Make dot (.) a legit symbol in spark name

* Spark name block number for testnet

* Fixed restoration of old spark name data if block is disconnected

* API for quick check of spark name transaction validity before the creation

* added isAddressMine function

* Check if the address belongs to the wallet before creating spark name transaction

* Fixed fee calculation for spark name

* Fix for spark names RPC

* Added ability to spend to spark names in "sparkspend" RPC

* UI fixes

* Additional validations

* Fix for crash with spend to unregistered name

* Fixed fee value when registering spark name for more than one year

* Spark name UI improvements

* UI modifications for sending to spark name

* Address book fixes related to spark names

* Fixed period of validity when creating spark name through GUI

* Extended spark name error info for RPC

* Fixed crash on non-HD wallet

* Request wallet password for spark name creation

* Fixed fee calculation for the spark name tx

* Fixed detection of previously used spark address for a spark name

* Unit test for spark names

* Additional unit tests

* Fixes #1533

* Testnet HF block set

* Mainnet HF block set

---------

Co-authored-by: Peter Shugalev <peter@shugalev.com>
Co-authored-by: levoncrypto <levoncrypto1994@gmail.com>

* Build fix (#1553)

* Build fix

* coderabbitai comment resolved

* Duplicated rpc removed

* Bump version to v0.14.14.1 Spark Names (#1550)

* secp256k1: CMake build system added

* cmake: add cmake folder

* bench: Add initial cmake support

* Add initial main CMakeLists.txt

* doc: add initial cmake support

* univalue: add initial cmake support

* zmq: add initial cmake support

* crypto: add initial cmake support

* wallet: add initial cmake support

* src: initial add of src/CMakeLists.txt

* toolchain.cmake.in: Adding toolchain.cmake.in support

* crypto: add support for CMake function check.

* bitcoin-cli: add CMake compilation.

* firo-tx: add CMake compilation.
Improve miscellaneous CMake files.

* firod: add CMake compilation support.
    * Improved misc CMake compilation support.
    * Add bitcoin-config.h generation support.

* gmp: fix gmp link on OS X

* build: generate Linux installable package.

* CMake: add tests (test_bitcoin) compilation support.

* Qt: CMake GUI compilation support (Ubuntu)

* src/qt: Add macOS support for GUI with CMake compilation.

* depends: fix gmp compilation issue with mingw

* build: Add MingW support for CMake build system

* src: add backtrace compilation support macOS

* src: add backtrace compilation support Linux and MinGW-w64

* CMake: apply CodeRabbitAI suggestions.

* CMake: Add CI tasks for CMake build.

* Remove static from functions to fix debug linking

In release builds, these functions are inlined, avoiding linkage issues.
Debug builds (without inlining) caused undefined references in dependent
libraries due to static visibility. Removing static resolves this while
maintaining intended behavior in optimized builds.

* Add removed testcases and make BUILD_GUI=ON default option

* Added documentation to readme.md and fixed a lelantus test issue

* Fixed documentation, set ENABLE_WALLET=ON by default
Remove outdated old sigma testcase

* Rebase to Wed Apr 23 11:39:34 AM BST 2025

---------

Co-authored-by: levonpetrosyan93 <45027856+levonpetrosyan93@users.noreply.github.com>
Co-authored-by: firstcryptoman <firstcryptoman@gmail.com>
Co-authored-by: psolstice <peter@shugalev.com>
Co-authored-by: levonpetrosyan93 <petrosyan.levon93@gmail.com>
Co-authored-by: levoncrypto <levoncrypto1994@gmail.com>
Co-authored-by: levoncrypto <95240473+levoncrypto@users.noreply.github.com>
Co-authored-by: cassandras-lies <203535133+cassandras-lies@users.noreply.github.com>
Co-authored-by: justanwar <42809091+justanwar@users.noreply.github.com>
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.

4 participants