monero icon indicating copy to clipboard operation
monero copied to clipboard

Address doesn't belong to the wallet while I created the address with wallet RPC "create_address"

Open devilrayzl opened this issue 2 years ago • 8 comments

  1. curl http://127.0.0.1:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"create_address","params":{"account_index":0,"label":"new-sub"}}' -H 'Content-Type: application/json' With this RPC interface I created an sub address. 2.curl http://127.0.0.1:18082/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_address_index","params":{"address":"7BnERTpvL5MbCLtj5n9No7J5oE5hHiB3tVCK5cjSvCsYWD2WRJLFuWeKTLiXo5QJqt2ZwUaLy2Vh1Ad51K7FNgqcHgjW85o"}}' -H 'Content-Type: application/json' However, while I check this address with RPC get_address_index, it returns Address doesn't belong to the wallet.

How is that happen?And is there any way to get this address back? Since I send some XMR coin to the address. May get some help?

devilrayzl avatar Sep 14 '22 14:09 devilrayzl

Subaddresses are deterministic, there is no way to "lose" a subaddress. Are you sure you opened the same wallet in both cases?

selsta avatar Sep 14 '22 18:09 selsta

sanity check:

create_address

curl http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"create_address","params":{"account_index":0,"label":"new-sub"}}' -H 'Content-Type: application/json''
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "address": "84dFGjDZXYCUHTP3fTPces7QjP2MxK8hw8yCcy3vcB93X5Rzrv7BAjB6JKxVi1C4RBY437CX4ycuv8oz8fVk5CLh1tXPRwk",
    "address_index": 5,
    "address_indices": [5],
    "addresses": ["84dFGjDZXYCUHTP3fTPces7QjP2MxK8hw8yCcy3vcB93X5Rzrv7BAjB6JKxVi1C4RBY437CX4ycuv8oz8fVk5CLh1tXPRwk"]
  }
}

get_address_index:

curl http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_address_index","params":{"address":"84dFGjDZXYCUHTP3fTPces7QjP2MxK8hw8yCcy3vcB93X5Rzrv7BAjB6JKxVi1C4RBY437CX4ycuv8oz8fVk5CLh1tXPRwk"}}' -H 'Content-Type: application/json''
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "index": {
      "major": 0,
      "minor": 5
    }
  }
}

please close

plowsof avatar Sep 14 '22 20:09 plowsof

Subaddresses are deterministic, there is no way to "lose" a subaddress. Are you sure you opened the same wallet in both cases?

Yes,I'm sure. I had create about 500 hundred subaddresses, some of them could list by wallet some not. Really weird.

devilrayzl avatar Sep 15 '22 08:09 devilrayzl

sanity check:

create_address

curl http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"create_address","params":{"account_index":0,"label":"new-sub"}}' -H 'Content-Type: application/json''
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "address": "84dFGjDZXYCUHTP3fTPces7QjP2MxK8hw8yCcy3vcB93X5Rzrv7BAjB6JKxVi1C4RBY437CX4ycuv8oz8fVk5CLh1tXPRwk",
    "address_index": 5,
    "address_indices": [5],
    "addresses": ["84dFGjDZXYCUHTP3fTPces7QjP2MxK8hw8yCcy3vcB93X5Rzrv7BAjB6JKxVi1C4RBY437CX4ycuv8oz8fVk5CLh1tXPRwk"]
  }
}

get_address_index:

curl http://127.0.0.1:18081/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_address_index","params":{"address":"84dFGjDZXYCUHTP3fTPces7QjP2MxK8hw8yCcy3vcB93X5Rzrv7BAjB6JKxVi1C4RBY437CX4ycuv8oz8fVk5CLh1tXPRwk"}}' -H 'Content-Type: application/json''
{
  "id": "0",
  "jsonrpc": "2.0",
  "result": {
    "index": {
      "major": 0,
      "minor": 5
    }
  }
}

please close

Yes, I'm going to run this way now. But I think there is a bug maybe for creating subaddress.

devilrayzl avatar Sep 15 '22 08:09 devilrayzl

Did you make sure to save the wallet after creating them? Otherwise you have to recreate them.

selsta avatar Sep 15 '22 08:09 selsta

I'm sure about saving the wallet. As you know, I could actually get the index of most addresses. Not all of the addresses are not belong.

devilrayzl avatar Sep 15 '22 08:09 devilrayzl

apologies for the dumb sanity check @devilrayzl - i was unaware that 'the wallet file must be saved after creating the subaddress' else they will not "belong to the wallet" -> if this is true , and the get_address_index is simply searching the file for an address - and is not a deterministic process - there is a possibility - if the address was not written to file, it 'could happen'.

  • to confirm the address actually belongs to the wallet i would suggest you use something like monero-python , to create addresses offline , and then see if it exists (enter them into a database or just a list in memory)

plowsof avatar Sep 15 '22 10:09 plowsof

Try to open that wallet with monero-wallet-cli, enter address all and show what is says under the address with the index it should be.

selsta avatar Sep 15 '22 17:09 selsta

I also encountered this problem. Why are some addresses in my wallet address list missing, and the balance has not increased after being transferred to this address

leolily7 avatar Sep 22 '22 03:09 leolily7