lightninglabs / taproot-assets

A layer 1 daemon, for the Taproot Assets Protocol specification, written in Go (golang)
MIT License
439 stars 106 forks source link

Asset change from channel open not accessible #964

Closed ffranr closed 6 days ago

ffranr commented 1 week ago

This bug issue follows from a report made here: https://github.com/lightninglabs/taproot-assets/issues/942

Jamal report (see https://github.com/lightninglabs/taproot-assets/issues/942#issuecomment-2176663481):

There's an issue which I previously reported in chat that I forgot to mention here.

After opening a channel with a capacity that's lower than the node's total asset balance, the remaining balance becomes inaccessible. tapcli assets list returns no assets and tapcli assets balance shows the asset with the pre-channel balance.

Expand for reproduction of the issue via CLI ```sh litd@alice:/$ litcli --version litcli version 0.13.0-alpha commit=v0.13.0-alpha-9-g980ee938aa1e7a45633216aff8775ca8d05c12aa litd@alice:/$ tapcli --version tapcli version 0.3.2-alpha commit=v0.3.3-0.20240609154533-2b3c60ae77a9 litd@alice:/$ tapcli assets mint --name PBUX --type normal --supply 1000 { "pending_batch": { "batch_key": "03f44cb28755bb1069a3b44d4af3cc49bbe9e433d56bd1aa05d49efbc997e91aa3", "batch_txid": "", "state": "BATCH_STATE_PENDING", "assets": [ { "asset_version": "ASSET_VERSION_V0", "asset_type": "NORMAL", "name": "PBUX", "asset_meta": null, "amount": "1000", "new_grouped_asset": false, "group_key": "", "group_anchor": "", "group_internal_key": null, "group_tapscript_root": "", "script_key": { "pub_key": "3573758b2c7f60b6c6be2cf7f99d886c1d0d56a53da11e30a96eb926a63a3886", "key_desc": { "raw_key_bytes": "031a620843e9a4a8fdfa76bd27de4d118db6e2d45b23d408802d39057109e783e4", "key_loc": { "key_family": 212, "key_index": 0 } }, "tap_tweak": "" } } ], "created_at": "1718732824", "height_hint": 107, "batch_psbt": "" } } litd@alice:/$ tapcli assets mint finalize { "batch": { "batch_key": "03f44cb28755bb1069a3b44d4af3cc49bbe9e433d56bd1aa05d49efbc997e91aa3", "batch_txid": "19af46087e3c014a0435dc66218563231bdb4c73da9423ea681d15f51c261fda", "state": "BATCH_STATE_BROADCAST", "assets": [ { "asset_version": "ASSET_VERSION_V0", "asset_type": "NORMAL", "name": "PBUX", "asset_meta": null, "amount": "1000", "new_grouped_asset": false, "group_key": "", "group_anchor": "", "group_internal_key": null, "group_tapscript_root": "", "script_key": { "pub_key": "3573758b2c7f60b6c6be2cf7f99d886c1d0d56a53da11e30a96eb926a63a3886", "key_desc": { "raw_key_bytes": "031a620843e9a4a8fdfa76bd27de4d118db6e2d45b23d408802d39057109e783e4", "key_loc": { "key_family": 212, "key_index": 0 } }, "tap_tweak": "" } } ], "created_at": "1718732824", "height_hint": 107, "batch_psbt": "70736274ff0100890200000001cee728c17955bddb96fb686abb2dea74b50dba9690aac4cc5ed149cf6370ce0d00000000000000000002e803000000000000225120bf607a5ae2ecf3e0885fd80d0bb8d3c55c81726b9816ef14a90de3e48fee92f52b1e0f00000000002251202f3851fdcc740d758a5fd17fe3c24b0a636113966d5a3cc7792a8c06c0a965bf00000000000100de02000000000101465ab280735889735105a511dc31eaacfd60b49ca6346cb80c2b97c691a5509f0000000000fdffffff0240420f0000000000160014b71899fb99beb61413d8a1833916464b2160762fbca4f629010000001600141fad0c5c9b6959723abdc3e1d4d6c0560ce1fa0402473044022062d430d4fdfca0f3716e1b47f96d18ca38c19e17692f4ae96e4ac787c1f5a088022076c7c356ef4ea7c426db509b50e1172e80fb58c74f8e41dd6c27db202c165edd012102858ae48c2698bc5c3435e11e799637031d690e82b50c8e29176dc65374d520b36500000001011f40420f0000000000160014b71899fb99beb61413d8a1833916464b2160762f01086c0248304502210097f4e4726a42581f0c05185688eb331b10c530e6be10965f7771a5a2dd26e85e022072eb72eca3dbfe28da288575d127094d240342159ccc31c2e083010cce9feaf40121038f99fbf00e2169d3c29304b0157bf5aa0426a865ec4f2f4ece4320667fba8cb2000022020265d51e54cd1c1aefcf4eaddf74c06d58d5cdb2bfc21b534f6a153319cdf350911800000000560000800000008000000080010000000000000001052065d51e54cd1c1aefcf4eaddf74c06d58d5cdb2bfc21b534f6a153319cdf35091210765d51e54cd1c1aefcf4eaddf74c06d58d5cdb2bfc21b534f6a153319cdf35091190000000000560000800000008000000080010000000000000000" } } # 6 blocks mined here litd@alice:/$ tapcli assets list { "assets": [ { "version": "ASSET_VERSION_V0", "asset_genesis": { "genesis_point": "0dce7063cf49d15eccc4aa9096ba0db574ea2dbb6a68fb96dbbd5579c128e7ce:0", "name": "PBUX", "meta_hash": "0000000000000000000000000000000000000000000000000000000000000000", "asset_id": "4c220f9f2db413a3134dbc98ca0ffb6fa596e6a50a5fa86051625044ed00a899", "asset_type": "NORMAL", "output_index": 0 }, "amount": "1000", "lock_time": 0, "relative_lock_time": 0, "script_version": 0, "script_key": "023573758b2c7f60b6c6be2cf7f99d886c1d0d56a53da11e30a96eb926a63a3886", "script_key_is_local": true, "asset_group": null, "chain_anchor": { "anchor_tx": "02000000000101cee728c17955bddb96fb686abb2dea74b50dba9690aac4cc5ed149cf6370ce0d00000000000000000002e803000000000000225120bf607a5ae2ecf3e0885fd80d0bb8d3c55c81726b9816ef14a90de3e48fee92f52b1e0f00000000002251202f3851fdcc740d758a5fd17fe3c24b0a636113966d5a3cc7792a8c06c0a965bf0248304502210097f4e4726a42581f0c05185688eb331b10c530e6be10965f7771a5a2dd26e85e022072eb72eca3dbfe28da288575d127094d240342159ccc31c2e083010cce9feaf40121038f99fbf00e2169d3c29304b0157bf5aa0426a865ec4f2f4ece4320667fba8cb200000000", "anchor_block_hash": "22eb84a9ef36d099dfe4de67fbf2f73bd2fc91e408105c6f2c4c130b43a44d7f", "anchor_outpoint": "19af46087e3c014a0435dc66218563231bdb4c73da9423ea681d15f51c261fda:0", "internal_key": "03f44cb28755bb1069a3b44d4af3cc49bbe9e433d56bd1aa05d49efbc997e91aa3", "merkle_root": "c65a298b0ec5e8a182370b2641572055c6fccede2732cb36d3ecf2c22ca0b394", "tapscript_sibling": "", "block_height": 0 }, "prev_witnesses": [], "is_spent": false, "lease_owner": "", "lease_expiry": "0", "is_burn": false, "script_key_declared_known": false, "script_key_has_script_path": false } ] } litd@alice:/$ tapcli assets balance { "asset_balances": { "4c220f9f2db413a3134dbc98ca0ffb6fa596e6a50a5fa86051625044ed00a899": { "asset_genesis": { "genesis_point": "0dce7063cf49d15eccc4aa9096ba0db574ea2dbb6a68fb96dbbd5579c128e7ce:0", "name": "PBUX", "meta_hash": "0000000000000000000000000000000000000000000000000000000000000000", "asset_id": "4c220f9f2db413a3134dbc98ca0ffb6fa596e6a50a5fa86051625044ed00a899", "asset_type": "NORMAL", "output_index": 0 }, "balance": "1000" } }, "asset_group_balances": {} } litd@alice:/$ litcli --macaroonpath ~/.lnd/data/chain/bitcoin/regtest/admin.macaroon ln fundchannel --asset_id 4c220f9f2db413a3134dbc98ca0ffb6fa596e6a50a5fa86051625044ed00a899 --node_key 02e61ab7bd13a3df8c8bb5aca2fa976b5bbcdc88afb1c6a8c02184cd86f0fd9615 --sat_per_vbyte 10 --asset_amount 400 { "txid": "ac9ec6252d772dfab1fd9969113702257561b4ab4fddf5f47df3488c2854b032" } # 6 blocks mined here litd@alice:/$ tapcli assets list { "assets": [] } litd@alice:/$ tapcli assets balance { "asset_balances": { "4c220f9f2db413a3134dbc98ca0ffb6fa596e6a50a5fa86051625044ed00a899": { "asset_genesis": { "genesis_point": "0dce7063cf49d15eccc4aa9096ba0db574ea2dbb6a68fb96dbbd5579c128e7ce:0", "name": "PBUX", "meta_hash": "0000000000000000000000000000000000000000000000000000000000000000", "asset_id": "4c220f9f2db413a3134dbc98ca0ffb6fa596e6a50a5fa86051625044ed00a899", "asset_type": "NORMAL", "output_index": 0 }, "balance": "1000" } }, "asset_group_balances": {} } litd@alice:/$ lncli listchannels { "channels": [ { "active": true, "remote_pubkey": "02e61ab7bd13a3df8c8bb5aca2fa976b5bbcdc88afb1c6a8c02184cd86f0fd9615", "channel_point": "ac9ec6252d772dfab1fd9969113702257561b4ab4fddf5f47df3488c2854b032:0", "chan_id": "125344325632000", "capacity": "100000", "local_balance": "96920", "remote_balance": "0", "commit_fee": "2750", "commit_weight": "614", "fee_per_kw": "2500", "unsettled_balance": "0", "total_satoshis_sent": "0", "total_satoshis_received": "0", "num_updates": "0", "pending_htlcs": [], "csv_delay": 144, "private": true, "initiator": true, "chan_status_flags": "ChanStatusDefault", "local_chan_reserve_sat": "1000", "remote_chan_reserve_sat": "1062", "static_remote_key": false, "commitment_type": "SIMPLE_TAPROOT", "lifetime": "106", "uptime": "106", "close_address": "", "push_amount_sat": "0", "thaw_height": 0, "local_constraints": { "csv_delay": 144, "chan_reserve_sat": "1000", "dust_limit_sat": "354", "max_pending_amt_msat": "99000000", "min_htlc_msat": "1", "max_accepted_htlcs": 483 }, "remote_constraints": { "csv_delay": 144, "chan_reserve_sat": "1062", "dust_limit_sat": "354", "max_pending_amt_msat": "99000000", "min_htlc_msat": "1", "max_accepted_htlcs": 483 }, "alias_scids": [ "17592186044416000000" ], "zero_conf": false, "zero_conf_confirmed_scid": "0", "peer_alias": "bob", "peer_scid_alias": "17592186044416000000", "memo": "", "custom_channel_data": { "assets": [ { "asset_utxo": { "version": 1, "asset_genesis": { "genesis_point": "0dce7063cf49d15eccc4aa9096ba0db574ea2dbb6a68fb96dbbd5579c128e7ce:0", "name": "PBUX", "meta_hash": "0000000000000000000000000000000000000000000000000000000000000000", "asset_id": "4c220f9f2db413a3134dbc98ca0ffb6fa596e6a50a5fa86051625044ed00a899" }, "amount": 400, "script_key": "0250aaeb166f4234650d84a2d8a130987aeaf6950206e0905401ee74ff3f8d18e6" }, "capacity": 400, "local_balance": 400, "remote_balance": 0 } ] } } ] } litd@alice:/$ ```
ffranr commented 6 days ago

The force close changes seems to have solved this issue. Care should be taken when running tapcli assets list because unconfirmed assets are not listed. This change will hopefully add clarity there: https://github.com/lightninglabs/taproot-assets/pull/969

dstadulis commented 6 days ago

The force close changes seems to have solved this issue. Care should be taken when running tapcli assets list because unconfirmed assets are not listed. This change will hopefully add clarity there: #969

https://github.com/lightninglabs/taproot-assets/issues/645 would help also clarify in scenarios when an asset could confirm