Chia-Network / chia-blockchain-gui

Chia blockchain GUI in electron/react
https://chia.net
Apache License 2.0
332 stars 246 forks source link

Clawback autoclaim fails with 0 XCH in wallet [Bug] #1863

Closed danieljperry closed 1 year ago

danieljperry commented 1 year ago

What happened?

This is related to issue 1835 but it involves auto-claim. The wallet allows the user to enable auto-claim for clawback transactions, even when the wallet has 0 XCH. The result is that the auto-claim fails, but doesn't show a reason why in the GUI. The following video demonstrates this:

https://github.com/Chia-Network/chia-blockchain-gui/assets/69756004/f3f309a9-d2ca-4879-8b0d-bb31888dc49a

Version

1.8.2rc4 + PR 15496

What platform are you using?

Windows

What ui mode are you using?

GUI

Relevant log output or stacktrace

2023-06-21T13:47:15.978 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction 542d61deadb2252eb88bb3ccc088a6488b58705daae34145593ce630d266004a: Cannot find coin record for clawback transaction 0x542d61deadb2252eb88bb3ccc088a6488b58705daae34145593ce630d266004a
2023-06-21T13:47:15.981 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction e3db05afb0a67eb1dcc5206ec71fb95214f052f255aca45f039ee6ebd71cbd6c: Cannot find coin record for clawback transaction 0xe3db05afb0a67eb1dcc5206ec71fb95214f052f255aca45f039ee6ebd71cbd6c
2023-06-21T13:47:17.204 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction 542d61deadb2252eb88bb3ccc088a6488b58705daae34145593ce630d266004a: Cannot find coin record for clawback transaction 0x542d61deadb2252eb88bb3ccc088a6488b58705daae34145593ce630d266004a
2023-06-21T13:47:17.207 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction e3db05afb0a67eb1dcc5206ec71fb95214f052f255aca45f039ee6ebd71cbd6c: Cannot find coin record for clawback transaction 0xe3db05afb0a67eb1dcc5206ec71fb95214f052f255aca45f039ee6ebd71cbd6c
2023-06-21T13:47:17.226 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction 542d61deadb2252eb88bb3ccc088a6488b58705daae34145593ce630d266004a: Cannot find coin record for clawback transaction 0x542d61deadb2252eb88bb3ccc088a6488b58705daae34145593ce630d266004a
2023-06-21T13:47:17.228 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction e3db05afb0a67eb1dcc5206ec71fb95214f052f255aca45f039ee6ebd71cbd6c: Cannot find coin record for clawback transaction 0xe3db05afb0a67eb1dcc5206ec71fb95214f052f255aca45f039ee6ebd71cbd6c
2023-06-21T13:47:18.056 wallet chia.wallet.wallet_node    : WARNING  SpendBundle has been rejected by the FullNode. {'error': 'DOUBLE_SPEND', 'status': 3, 'txid': '0x6cff59548285d0130d7738496c2e512ea2096596e8090fc3db6ef71d36b579bc'}
2023-06-21T13:47:18.065 wallet chia.wallet.wallet_node    : WARNING  SpendBundle has been rejected by the FullNode. {'error': 'DOUBLE_SPEND', 'status': 3, 'txid': '0x131a3b4ff6ee54882bc75eb6b77a2410f0288136aff1aeb7cd02132cf5f2574c'}
2023-06-21T13:47:18.074 wallet chia.wallet.wallet_node    : WARNING  SpendBundle has been rejected by the FullNode. {'error': 'DOUBLE_SPEND', 'status': 3, 'txid': '0x2fd26a150cc306ba4cb0c2faf7b17892da71389f729b238c32af2c1e44115963'}
2023-06-21T13:47:18.081 wallet chia.wallet.wallet_node    : WARNING  SpendBundle has been rejected by the FullNode. {'error': 'DOUBLE_SPEND', 'status': 3, 'txid': '0x876963e7238720ae91e3f8ce3e66ee48547e5e01c1fc697a690c4392318244bb'}
2023-06-21T13:47:18.120 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction 542d61deadb2252eb88bb3ccc088a6488b58705daae34145593ce630d266004a: Cannot find coin record for clawback transaction 0x542d61deadb2252eb88bb3ccc088a6488b58705daae34145593ce630d266004a
2023-06-21T13:47:18.123 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction e3db05afb0a67eb1dcc5206ec71fb95214f052f255aca45f039ee6ebd71cbd6c: Cannot find coin record for clawback transaction 0xe3db05afb0a67eb1dcc5206ec71fb95214f052f255aca45f039ee6ebd71cbd6c
2023-06-21T13:47:20.636 wallet wallet_server              : WARNING  Peer 54.191.117.215 is still banned, not connecting to it
2023-06-21T13:47:25.441 wallet wallet_server              : WARNING  Peer 52.12.3.173 is still banned, not connecting to it
2023-06-21T13:47:26.195 wallet wallet_server              : WARNING  Peer 64.95.53.234 is still banned, not connecting to it
2023-06-21T13:47:27.478 full_node full_node_server        : WARNING  Banning 90.211.57.59 for 10 seconds
2023-06-21T13:47:27.478 full_node full_node_server        : WARNING  Invalid handshake with peer PeerInfo(_ip=IPv4Address('90.211.57.59'), _port=8444). Maybe the peer is running old software.
2023-06-21T13:47:29.070 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction d16da4ec4f37b53984b4479d7bb45c79457e6e4d621968efad8db934e907c9bf: Cannot find coin record for clawback transaction 0xd16da4ec4f37b53984b4479d7bb45c79457e6e4d621968efad8db934e907c9bf
2023-06-21T13:47:29.071 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction 542d61deadb2252eb88bb3ccc088a6488b58705daae34145593ce630d266004a: Cannot find coin record for clawback transaction 0x542d61deadb2252eb88bb3ccc088a6488b58705daae34145593ce630d266004a
2023-06-21T13:47:29.072 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction e3db05afb0a67eb1dcc5206ec71fb95214f052f255aca45f039ee6ebd71cbd6c: Cannot find coin record for clawback transaction 0xe3db05afb0a67eb1dcc5206ec71fb95214f052f255aca45f039ee6ebd71cbd6c
2023-06-21T13:47:29.089 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction d16da4ec4f37b53984b4479d7bb45c79457e6e4d621968efad8db934e907c9bf: Cannot find coin record for clawback transaction 0xd16da4ec4f37b53984b4479d7bb45c79457e6e4d621968efad8db934e907c9bf
2023-06-21T13:47:29.090 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction 542d61deadb2252eb88bb3ccc088a6488b58705daae34145593ce630d266004a: Cannot find coin record for clawback transaction 0x542d61deadb2252eb88bb3ccc088a6488b58705daae34145593ce630d266004a
2023-06-21T13:47:29.091 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction e3db05afb0a67eb1dcc5206ec71fb95214f052f255aca45f039ee6ebd71cbd6c: Cannot find coin record for clawback transaction 0xe3db05afb0a67eb1dcc5206ec71fb95214f052f255aca45f039ee6ebd71cbd6c
2023-06-21T13:47:29.688 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction d16da4ec4f37b53984b4479d7bb45c79457e6e4d621968efad8db934e907c9bf: Cannot find coin record for clawback transaction 0xd16da4ec4f37b53984b4479d7bb45c79457e6e4d621968efad8db934e907c9bf
2023-06-21T13:47:29.689 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction 542d61deadb2252eb88bb3ccc088a6488b58705daae34145593ce630d266004a: Cannot find coin record for clawback transaction 0x542d61deadb2252eb88bb3ccc088a6488b58705daae34145593ce630d266004a
2023-06-21T13:47:29.691 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction e3db05afb0a67eb1dcc5206ec71fb95214f052f255aca45f039ee6ebd71cbd6c: Cannot find coin record for clawback transaction 0xe3db05afb0a67eb1dcc5206ec71fb95214f052f255aca45f039ee6ebd71cbd6c
2023-06-21T13:47:29.727 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction d16da4ec4f37b53984b4479d7bb45c79457e6e4d621968efad8db934e907c9bf: Cannot find coin record for clawback transaction 0xd16da4ec4f37b53984b4479d7bb45c79457e6e4d621968efad8db934e907c9bf
2023-06-21T13:47:29.728 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction 542d61deadb2252eb88bb3ccc088a6488b58705daae34145593ce630d266004a: Cannot find coin record for clawback transaction 0x542d61deadb2252eb88bb3ccc088a6488b58705daae34145593ce630d266004a
2023-06-21T13:47:29.729 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction e3db05afb0a67eb1dcc5206ec71fb95214f052f255aca45f039ee6ebd71cbd6c: Cannot find coin record for clawback transaction 0xe3db05afb0a67eb1dcc5206ec71fb95214f052f255aca45f039ee6ebd71cbd6c
2023-06-21T13:47:30.042 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction d16da4ec4f37b53984b4479d7bb45c79457e6e4d621968efad8db934e907c9bf: Cannot find coin record for clawback transaction 0xd16da4ec4f37b53984b4479d7bb45c79457e6e4d621968efad8db934e907c9bf
2023-06-21T13:47:30.044 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction 542d61deadb2252eb88bb3ccc088a6488b58705daae34145593ce630d266004a: Cannot find coin record for clawback transaction 0x542d61deadb2252eb88bb3ccc088a6488b58705daae34145593ce630d266004a
2023-06-21T13:47:30.045 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction e3db05afb0a67eb1dcc5206ec71fb95214f052f255aca45f039ee6ebd71cbd6c: Cannot find coin record for clawback transaction 0xe3db05afb0a67eb1dcc5206ec71fb95214f052f255aca45f039ee6ebd71cbd6c
2023-06-21T13:47:30.084 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction d16da4ec4f37b53984b4479d7bb45c79457e6e4d621968efad8db934e907c9bf: Cannot find coin record for clawback transaction 0xd16da4ec4f37b53984b4479d7bb45c79457e6e4d621968efad8db934e907c9bf
2023-06-21T13:47:30.085 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction 542d61deadb2252eb88bb3ccc088a6488b58705daae34145593ce630d266004a: Cannot find coin record for clawback transaction 0x542d61deadb2252eb88bb3ccc088a6488b58705daae34145593ce630d266004a
2023-06-21T13:47:30.093 wallet chia.rpc.wallet_rpc_api    : ERROR    Failed to get transaction e3db05afb0a67eb1dcc5206ec71fb95214f052f255aca45f039ee6ebd71cbd6c: Cannot find coin record for clawback transaction 0xe3db05afb0a67eb1dcc5206ec71fb95214f052f255aca45f039ee6ebd71cbd6c
2023-06-21T13:47:34.456 wallet wallet_server              : WARNING  Peer 82.65.108.81 is still banned, not connecting to it
2023-06-21T13:47:36.751 wallet wallet_server              : WARNING  Peer 64.95.53.234 is still banned, not connecting to it
2023-06-21T13:47:40.306 wallet wallet_server              : WARNING  Peer 35.92.249.42 is still banned, not connecting to it
2023-06-21T13:47:48.810 wallet wallet_server              : WARNING  Peer 116.203.117.15 is still banned, not connecting to it
2023-06-21T13:47:51.833 wallet wallet_server              : WARNING  Peer 34.213.193.211 is still banned, not connecting to it
2023-06-21T13:47:58.942 full_node full_node_server        : WARNING  Banning 87.197.155.88 for 10 seconds
2023-06-21T13:47:58.944 full_node full_node_server        : WARNING  Invalid handshake with peer PeerInfo(_ip=IPv4Address('87.197.155.88'), _port=8444). Maybe the peer is running old software.
2023-06-21T13:48:00.261 wallet wallet_server              : WARNING  Peer 34.221.111.178 is still banned, not connecting to it
2023-06-21T13:48:03.375 wallet wallet_server              : WARNING  Peer 44.234.48.74 is still banned, not connecting to it
2023-06-21T13:48:06.506 full_node full_node_server        : WARNING  Banning 92.220.10.100 for 10 seconds
2023-06-21T13:48:06.507 full_node full_node_server        : WARNING  Invalid handshake with peer PeerInfo(_ip=IPv4Address('92.220.10.100'), _port=8444). Maybe the peer is running old software.
2023-06-21T13:48:08.113 wallet chia.wallet.wallet         : WARNING  Can't select amount higher than our spendable balance.  Amount: 10000, spendable: 0
2023-06-21T13:48:08.117 wallet chia.rpc.rpc_server        : WARNING  Error while handling message: Traceback (most recent call last):
  File "C:\Users\User\Chia\1.8.2\chia-blockchain\chia\rpc\rpc_server.py", line 340, in safe_handle
    response = await self.ws_api(message)
  File "C:\Users\User\Chia\1.8.2\chia-blockchain\chia\rpc\rpc_server.py", line 331, in ws_api
    return await f_rpc_api(data)
  File "C:\Users\User\Chia\1.8.2\chia-blockchain\chia\rpc\wallet_rpc_api.py", line 1080, in spend_clawback_coins
    tx_id_list.extend((await self.service.wallet_state_manager.spend_clawback_coins(coins, tx_fee)))
  File "C:\Users\User\Chia\1.8.2\chia-blockchain\chia\wallet\wallet_state_manager.py", line 778, in spend_clawback_coins
    chia_tx = await self.main_wallet.create_tandem_xch_tx(
  File "C:\Users\User\Chia\1.8.2\chia-blockchain\chia\wallet\wallet.py", line 586, in create_tandem_xch_tx
    chia_coins = await self.select_coins(fee)
  File "C:\Users\User\Chia\1.8.2\chia-blockchain\chia\wallet\wallet.py", line 292, in select_coins
    coins = await select_coins(
  File "C:\Users\User\Chia\1.8.2\chia-blockchain\chia\wallet\coin_selection.py", line 39, in select_coins
    raise ValueError(error_msg)
ValueError: Can't select amount higher than our spendable balance.  Amount: 10000, spendable: 0

2023-06-21T13:48:14.191 wallet wallet_server              : WARNING  Peer 54.202.31.131 is still banned, not connecting to it
2023-06-21T13:48:18.004 wallet wallet_server              : WARNING  Peer 82.218.159.114 is still banned, not connecting to it
2023-06-21T13:48:40.779 wallet wallet_server              : WARNING  Peer 54.191.117.215 is still banned, not connecting to it
2023-06-21T13:48:41.540 wallet wallet_server              : WARNING  Peer 52.12.3.173 is still banned, not connecting to it
2023-06-21T13:48:45.307 wallet chia.wallet.wallet         : WARNING  Can't select amount higher than our spendable balance.  Amount: 100000000, spendable: 0
2023-06-21T13:48:45.308 wallet chia.wallet.wallet_node    : ERROR    Exception handling NewPeakItem(item_type=<NewPeakQueueTypes.NEW_PEAK_WALLET: 4>, data=(NewPeakWallet(header_hash=<bytes32: 47a062fac87e7e3401447c0a98366e7c9954c5a9e5736e9527ce6591d28ca81a>, height=2804967, weight=170743781070, fork_point_with_previous_peak=2804966), WSChiaConnection(local_type=<NodeType.WALLET: 6>, local_port=8449, local_capabilities=[<Capability.BASE: 1>, <Capability.BLOCK_HEADERS: 2>, <Capability.RATE_LIMITS_V2: 3>], peer_info=PeerInfo(_ip=IPv4Address('127.0.0.1'), _port=58444), peer_node_id=<bytes32: b3d9de85d29931c10050b56c7afb91c99141943fc81ff2d1a8425e52be0d08ab>, outbound_rate_limiter=<chia.server.rate_limits.RateLimiter object at 0x000001D37A454AC0>, inbound_rate_limiter=<chia.server.rate_limits.RateLimiter object at 0x000001D379D95E20>, is_outbound=True, creation_time=1687373248.924692, bytes_read=160512, bytes_written=56211, last_message_time=1687373325.2767327, peer_server_port=58444, active=False, closed=False, connection_type=<NodeType.FULL_NODE: 1>, request_nonce=52, peer_capabilities=[<Capability.BASE: 1>, <Capability.BLOCK_HEADERS: 2>, <Capability.RATE_LIMITS_V2: 3>], version=<Version('1.8.2rc4')>, protocol_version=<Version('0.0.34')>))), Can't select amount higher than our spendable balance.  Amount: 100000000, spendable: 0 Traceback (most recent call last):
  File "C:\Users\User\Chia\1.8.2\chia-blockchain\chia\wallet\wallet_node.py", line 593, in _process_new_subscriptions
    await self.wallet_state_manager.auto_claim_coins()
  File "C:\Users\User\Chia\1.8.2\chia-blockchain\chia\wallet\wallet_state_manager.py", line 725, in auto_claim_coins
    await self.spend_clawback_coins(clawback_coins, tx_fee)
  File "C:\Users\User\Chia\1.8.2\chia-blockchain\chia\wallet\wallet_state_manager.py", line 778, in spend_clawback_coins
    chia_tx = await self.main_wallet.create_tandem_xch_tx(
  File "C:\Users\User\Chia\1.8.2\chia-blockchain\chia\wallet\wallet.py", line 586, in create_tandem_xch_tx
    chia_coins = await self.select_coins(fee)
  File "C:\Users\User\Chia\1.8.2\chia-blockchain\chia\wallet\wallet.py", line 292, in select_coins
    coins = await select_coins(
  File "C:\Users\User\Chia\1.8.2\chia-blockchain\chia\wallet\coin_selection.py", line 39, in select_coins
    raise ValueError(error_msg)
ValueError: Can't select amount higher than our spendable balance.  Amount: 100000000, spendable: 0
paninaro commented 1 year ago

@zsolt-dev I think you addressed this mostly, right?

zsolt-dev commented 1 year ago

To recap, you cannot set autoclaim to zero, but when you set it to lets say 0.001 and your wallet has zero balance, then the autoclaim is still tried.

So I believe this is not a GUI issue, since even if I add a check to check for the current wallet balance, the balance might be zero at later time when the receiver get the clawback transaction.

I propose the solution that would involve backend - it should not try to run the autoclaim when not enough balance.

@paninaro Let me pls know if you agree.

@ytx1991 Pls let us know the feasibility of this change on the backend and some time frame.

danieljperry commented 1 year ago

If this is going to be fixed in the backend, then I can close this issue and open a new one in the chia-blockchain repo if needed. Just let me know. I'll keep this issue open in the meantime for tracking.

zsolt-dev commented 1 year ago

Yes, please close this since as I explained there is good way to fix in the GUI. Thank you