RGB-Tools / rgb-lightning-node

MIT License
17 stars 19 forks source link

RGB amounts in the intermediate node's channels weren't updated after a payment forwarded #24

Closed whfuyn closed 5 months ago

whfuyn commented 5 months ago

I noticed a problem while testing the rgb lightning channel.

Suppose there were three nodes, A, B, and C, and two channels, A->B, B->C.

Initially, A->B had 4500->500 rgb assets, and B->C had 20->0.

After sending 6 rgb assets from A to C through A->B->C, I expected the A->B to have 4494->506, and B->C to have 14->6.

However, when I checked in the response of listchannel from node B, it showed that the rgb amounts in both channels weren't updated as node A and C did.

Node A

{
  "channels": [
    {
      "channel_id": "bbda30a0d7a0d63bc9d7e230250c482fbce25d2951991d39e840c38c12d985f6",
      "funding_txid": "f685d9128cc340e8391d9951295de2bc2f480c2530e2d7c93bd6a0d7a030dabb",
      "peer_pubkey": "031ae15fbc060b935d6be7dbe60ff4e045f21230c29d47bca09498ad2f91a71dff",
      "peer_alias": "",
      "short_channel_id": 219902325620736,
      "ready": true,
      "capacity_sat": 100000,
      "local_balance_msat": 92604999,
      "outbound_balance_msat": 91604999,
      "inbound_balance_msat": 6395001,
      "is_usable": true,
      "public": true,
      "asset_id": "rgb:24i4tVt-DJn39YHZc-uExrSrv5K-Z11utSgd3-d6NL4c3Gr-deFPMUq",
      "asset_local_amount": 4494,
      "asset_remote_amount": 506
    }
  ]
}

Node B

{
  "channels": [
    {
      "channel_id": "ab5ec3ea5b648ab20244dd4df4ece2eb02b4b9fd9c8153c87e8819aba117eb66",
      "funding_txid": "66eb17a1ab19887ec853819cfdb9b402ebe2ecf44ddd4402b28a645beac35eab",
      "peer_pubkey": "027b4535c2bb0761b8591cc16ff585d1b73998b4f12c286e9fd6946a2dfd74ece8",
      "peer_alias": null,
      "short_channel_id": 325455441887232,
      "ready": true,
      "capacity_sat": 100000,
      "local_balance_msat": 95605999,
      "outbound_balance_msat": 94605999,
      "inbound_balance_msat": 3394001,
      "is_usable": true,
      "public": true,
      "asset_id": "rgb:24i4tVt-DJn39YHZc-uExrSrv5K-Z11utSgd3-d6NL4c3Gr-deFPMUq",
      "asset_local_amount": 20,
      "asset_remote_amount": 0
    },
    {
      "channel_id": "bbda30a0d7a0d63bc9d7e230250c482fbce25d2951991d39e840c38c12d985f6",
      "funding_txid": "f685d9128cc340e8391d9951295de2bc2f480c2530e2d7c93bd6a0d7a030dabb",
      "peer_pubkey": "02159535fe9ed0715d82d78d35d9380c4909be423ad9829bc9738c862ec775a79d",
      "peer_alias": null,
      "short_channel_id": 219902325620736,
      "ready": true,
      "capacity_sat": 100000,
      "local_balance_msat": 7395001,
      "outbound_balance_msat": 6395001,
      "inbound_balance_msat": 91604999,
      "is_usable": true,
      "public": true,
      "asset_id": "rgb:24i4tVt-DJn39YHZc-uExrSrv5K-Z11utSgd3-d6NL4c3Gr-deFPMUq",
      "asset_local_amount": 500,
      "asset_remote_amount": 4500
    }
  ]
}

Node C

{
  "channels": [
    {
      "channel_id": "ab5ec3ea5b648ab20244dd4df4ece2eb02b4b9fd9c8153c87e8819aba117eb66",
      "funding_txid": "66eb17a1ab19887ec853819cfdb9b402ebe2ecf44ddd4402b28a645beac35eab",
      "peer_pubkey": "031ae15fbc060b935d6be7dbe60ff4e045f21230c29d47bca09498ad2f91a71dff",
      "peer_alias": "",
      "short_channel_id": 325455441887232,
      "ready": true,
      "capacity_sat": 100000,
      "local_balance_msat": 4394001,
      "outbound_balance_msat": 3394001,
      "inbound_balance_msat": 94605999,
      "is_usable": true,
      "public": true,
      "asset_id": "rgb:24i4tVt-DJn39YHZc-uExrSrv5K-Z11utSgd3-d6NL4c3Gr-deFPMUq",
      "asset_local_amount": 6,
      "asset_remote_amount": 14
    }
  ]
}
whfuyn commented 5 months ago

I've made an attempt to fix this problem. The channel's rgb amounts are correct after applying this fix, but I'm not sure if I've missed anything.

nicbus commented 5 months ago

Thanks for reporting, I have been able to confirm the issue and will improve tests once both PRs will have been merged.