ExchangeUnion / xud

Exchange Union Daemon 🔁 ⚡️
https://exchangeunion.com
GNU Affero General Public License v3.0
115 stars 44 forks source link

Show funds in pending htlcs as `pending` in `getbalance` #1684

Open kilrau opened 4 years ago

kilrau commented 4 years ago

Follow-up of https://github.com/ExchangeUnion/xud/pull/1680, needed for https://github.com/ExchangeUnion/xud/issues/1673: since we now treat a swap as atomically completed upon reaching PreimageResolved from maker's perspective, we should show balance that is currently in swap recovery with xud trying to claim the htlc but still didn't manage to do so (and might go on-chain at some point) as pending in getbalance.

In other words: in addition to new pending channels, any balance in pending htlc should show as pending under getbalance.

Currently this balance isn't shown anywhere and the user would see a successfully completed swap, deducted outgoing asset balance, but nothing added for the incoming asset's balance (where is my money?).

kilrau commented 4 years ago

For example funds from this failed swap don't show anywhere in xud:

lndbtc:

            "pending_htlcs": [
                {
                    "incoming": true,
                    "amount": "10000",
                    "hash_lock": "928a7b6caf95b590b78db560db427dd6731a2f208c11b394ede420599ba3e927",
                    "expiration_height": 640526
                }
            ],

connext:

bash-5.0# curl -H 'Content-Type: application/json' http://0.0.0.0:5040/hashlock-status/0x928a7b6caf95b590b78db560db427dd6731a2f208c11b394ede420599ba3e927/0x0000000000000000000000000000000000000000 | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   438  100   438    0     0    863      0 --:--:-- --:--:-- --:--:--   863
{
  "senderIdentifier": "indraABC",
  "receiverIdentifier": "indraABC",
  "assetId": "0x0000000000000000000000000000000000000000",
  "amount": "100000000000000",
  "lockHash": "0x928a7b6caf95b590b78db560db427dd6731a2f208c11b394ede420599ba3e927",
  "status": "PENDING",
  "preImage": "0x0000000000000000000000000000000000000000000000000000000000000000",
  "expiry": "10517875"
}
ghost commented 4 years ago

Getting the amount of funds locked up via /hashlock-status endpoint might not be the best solution because of the complexity it adds on xud level to track the payments. Perhaps connext client can consider displaying this information in the response of /balance endpoint? Or a more general /getinfo endpoint?

kilrau commented 4 years ago

Agree. Wdyt? @ArjunBhuptani

kilrau commented 4 years ago

Also, currently the connext client doesn't seem to account for funds locked in an htlc. The balance reported is still the same. We propose to add 4 different balances to the connext client (either in one /balance endpoint or 4 different endpoints ):

  1. off-chain
  2. off-chain pending
  3. on-chain
  4. on-chain pending
kilrau commented 4 years ago

Moved this to P2 since we are depending on changes from connext side: https://github.com/connext/rest-api-client/issues/66