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

relay a confirmed tx to wallet produced dirty data #8793

Closed
wangsai-silence opened this issue Mar 21, 2023 · 3 comments
Closed

relay a confirmed tx to wallet produced dirty data #8793

wangsai-silence opened this issue Mar 21, 2023 · 3 comments

Comments

@wangsai-silence
Copy link

  • First, I create a tx with wallet transfer RPC
curl http://localhost:18082/json_rpc \
-u admin:123 --digest \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":"0","method":"transfer","params":{"destinations":[{"amount":60,"address":"7BWQGPqwy3TAbykGqDoD9fXq6GS84121XRRKJvcb2y6Md2Bed42mvSwF5LqeVAqtrQVo1T9D3WsqP3THyLW4cZWTFjY8p2g"}],"account_index":0,"get_tx_key":false,"get_tx_hex":false, "do_not_relay": true, "get_tx_metadata":true}}' 
  • Then, I relay it to chain
curl http://localhost:18082/json_rpc  \
-u admin:123 --digest \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":"0","method":"relay_tx","params":{"hex":"metadata..."}}'  \

{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "tx_hash": "3850e52507f5a9b7038417d758bb1c12e93bb57187d562c614be81844735024e"
  }
}

  • After tx is confirmed. I check the wallet balance
curl http://127.0.0.1:18082/json_rpc \
-u admin:123 --digest \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":"0","method":"get_balance","params":{"account_index":0,"address_indices":[]}}' \

{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "balance": 61085212629330,
    "blocks_to_unlock": 5,
    "multisig_import_needed": false,
    "per_subaddress": [...],
    "time_to_unlock": 0,
    "unlocked_balance": 60906659842570
  }
}
  • It seems all good, until I relay it again. The wallet accepts it and returns a tx_id as step 2
curl http://localhost:18082/json_rpc  \
-u admin:123 --digest \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":"0","method":"relay_tx","params":{"hex":"metadata..."}}'  \

{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "tx_hash": "3850e52507f5a9b7038417d758bb1c12e93bb57187d562c614be81844735024e"
  }
}

  • Obviously, this tx won't on chain again. So after 500s, it was marked as failed. But when I checked balance again, balance increased.
curl http://127.0.0.1:18082/json_rpc \
-u admin:123 --digest \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":"0","method":"get_balance","params":{"account_index":0,"address_indices":[]}}' \

{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "balance": 61085364099330,
    "blocks_to_unlock": 0,
    "multisig_import_needed": false,
    "per_subaddress": [...],
    "time_to_unlock": 0,
    "unlocked_balance": 61085364099330
  }
}

I'd have to run rescan_spent to fix balance and unspent info. Relay tx should be a idempotent function.

@wangsai-silence wangsai-silence changed the title relay a tx alreay onchain to wallet makes dirty data in wallet relay a confirmed tx to wallet produced dirty data Mar 21, 2023
@moneromooo-monero
Copy link
Collaborator

What makes you think the balance change is due to this transaction ?

@moneromooo-monero
Copy link
Collaborator

Nevermind, I can repro.

@moneromooo-monero
Copy link
Collaborator

#8796

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

2 participants