Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: getrawtransaction Command Not Found in florestad #301

Open
lucasbalieiro opened this issue Dec 6, 2024 · 4 comments
Open

Bug: getrawtransaction Command Not Found in florestad #301

lucasbalieiro opened this issue Dec 6, 2024 · 4 comments

Comments

@lucasbalieiro
Copy link
Contributor

When running the getrawtransaction command, floresta_cli returns an error indicating that the method is not found in florestad.

$ ./floresta_cli getrawtransaction 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
Error: JsonRpc returned an error RPC error response: RpcError { 
    code: -32601, 
    message: "Method not found", 
    data: None 
}

Steps to Reproduce

  1. Checkout the master branch at commit Current HEAD: 6615959
  2. Run the getrawtransaction command with a valid transaction hash:
    $ ./floresta_cli getrawtransaction 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
  3. Observe the response:
    Error: JsonRpc returned an error RPC error response: RpcError { 
        code: -32601, 
        message: "Method not found", 
        data: None 
    }
    

Investigation

Upon reviewing the source code, I found a potential mismatch in the RPC method's name declaration.
In server.rs, the RPC method is defined as gettransaction instead of getrawtransaction:

#[rpc(name = "gettransaction")]
fn get_transaction(&self, tx_id: Txid, verbosity: Option<bool>) -> Result<Value>;

To test, I modified the annotation:

#[rpc(name = "getrawtransaction")]

After rebuilding the project, the command returned:

$ ./floresta_cli getrawtransaction 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
Error: JsonRpc returned an error RPC error response: RpcError { 
    code: 3, 
    message: "Transaction not found", 
    data: None 
}

This error (Transaction not found) seems expected because, if I understand the code correctly, the getrawtransaction RPC method only works with watch-only wallets.

Clarification Needed

Since I’m not a Rust developer, I’m unsure if:

  • This is the intended behavior (e.g., I am using the command incorrectly), or

  • This is a bug that requires fixing.

Expected Behavior

  • The getrawtransaction command should work as documented or provide a clear explanation of its usage restrictions.

Environment Details

System Information

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.5 LTS
Release:	22.04
Codename:	jammy
commit 6615959aa31c3e4d80879be0f2762b048b99e3d1 (HEAD -> master, tag: 0.7.0, origin/master, origin/HEAD, origin/0.7.x)
Author: Davidson Souza <[email protected]>
Date:   Wed Dec 4 10:27:23 2024 -0300

    bump version (#293)


Let me know if further clarification is needed.

@luisschwab
Copy link
Contributor

luisschwab commented Dec 6, 2024

AFAIK Floresta doesn't index transactions, so getrawtransaction will only work on transactions currently on the mempool. In Bitcoin Core, you would need to set txindex=1 to be able to query any transaction not in the mempool.

@jaoleal
Copy link
Contributor

jaoleal commented Dec 6, 2024

You can open a PR to change 'gettransaction' to 'getrawtransaction', seems a good change for me.

Its good to follow strictly the naming conventions from bips.

In other way, its exactly what @luisschwab said in the comment above. we arent indexating yet. that means we discart the blocks after validating it.

@Davidson-Souza
Copy link
Collaborator

AFAIK Floresta doesn't index transactions, so getrawtransaction will only work on transactions currently on the mempool. In Bitcoin Core, you would need to set txindex=1 to be able to query any transaction not in the mempool.

In core, if you pass the block hash, then no need for txindex.

@lucasbalieiro usually, gettransaction is used for wallet transactions, while getrawtransaction for arbitrary transactions. I think the gettransaction you mentioned returns wallet transactions. So we may just rename it in the CLI.

@luisschwab
Copy link
Contributor

In core, if you pass the block hash, then no need for txindex

TIL

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

No branches or pull requests

4 participants