lightninglabs / lightninglabs/taproot-assets

[bug]: direct payments of an asset invoice uses remote peer's quote

Open
#1,392 15 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug payments
Dominant language
Go
Stars
525
Forks
150
Avg merge
2d 15h
Merged PRs (30d)
31

Description

I have the following network configuration:

         TA
edward <----> frank

Frank creates an invoice for 36000 asset and gives it to Edward. Edward pays the invoice through a direct channel. Frank gets 37088 assets.

=======================================================================================
edward sending Asset1 via frank and frank receiving 36000 Asset1_base (360.0 Asset1_friendly) via edward
MaxAllowableFee: 11
accepted_buy_quote {
  peer: "027c9b0b306d37e2df89f460460a4df1073af94d088f023053f0106d0d95f3c21c"
  id: "\177\316\304\215\204b\340p \r\332\300\350\350\336\3260f\336.\010\344w7\364\337U\027\212\260l\276"
  scid: 17644915424660319422
  asset_max_amount: 36000
  ask_asset_rate {
    coefficient: "98522167480000000000"
    scale: 10
  }
  expiry: 1739790752
  min_transportable_units: 34876
}
invoice_result {
  r_hash: "\020 \253\033\232\004\355\3019]\270\322\rG\307\277]\253b\304\030\2643\222\037\274\202h\2073\262s"
  payment_request: "lnbcrt3654n1pnmxxtapp5zqs2kxu6qnkuzw2ahrfq6378haw6kckyrz6r8yslhjpx3penkfesdqqcqzzsxqyz5vqrzjqf7fkzesd5m79huf73syvzjd7yrn472dpz8syvzn7qgx6rv470ppeaxl25tc4vrvhcqqqqlgqqqqqqgq2qsp5h3whq8pr32p0uckcw770fg3uvnr5rg76xpq3mpmdu9akmjscj88q9qxpqysgq7r2rxcq2amu5kpj5k5ercwp5qz844mngwm3f9sx569qc3dge4q3rt5t4wwz0429uy77xlhulewv274hfgmvs77wut8z7hptd2h2ydeqq0wfmmm"
  add_index: 1
  payment_addr: "\274]p\034#\212\202\376b\330w\274\364\242<d\307A\243\3320A\035\207m\341{m\312\030\221\316"
}

r_hash: 1020ab1b9a04edc1395db8d20d47c7bf5dab62c418b433921fbc82688733b273

invoice asset_amount: 35960
invoice num_satoshis: 365

invoice route_hints: [hop_hints {
  node_id: "027c9b0b306d37e2df89f460460a4df1073af94d088f023053f0106d0d95f3c21c"
  chan_id: 17644915424660319422
  fee_base_msat: 1000
  fee_proportional_millionths: 1
  cltv_expiry_delta: 80
}
]

expected route: ['edward', 'frank']
actual channel capacities:
active: true
remote_pubkey: "03d6ae1074144880117932cd354d12412930f64e55e62c1fe305b6ec1c578abf38"
channel_point: "174015ce901962a9317e48335857a21c714dcabbb0382b58c89274a253a6a4ca:0"
chan_id: 485984139542528
capacity: 100000
local_balance: 46920
remote_balance: 50000
commit_fee: 2420
commit_weight: 958
fee_per_kw: 2500
csv_delay: 144
private: true
initiator: true
chan_status_flags: "ChanStatusDefault"
local_chan_reserve_sat: 1000
remote_chan_reserve_sat: 1062
lifetime: 9
uptime: 9
commitment_type: SIMPLE_TAPROOT_OVERLAY
push_amount_sat: 50000
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: 83
}
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: 83
}
alias_scids: 17592186044416000001
alias_scids: 17644915424660319422
peer_scid_alias: 17592186044416000000
custom_channel_data: "{\"assets\":[{\"asset_utxo\":{\"version\":1,\"asset_genesis\":{\"genesis_point\":\"2587f694b70a20066162b751bfc341584af591e6ff6f2bd443db410666291b7c:1\",\"name\":\"Asset1\",\"meta_hash\":\"009dc0aa29bd1c320fa9b33e15227169f23b77ab6ca845fabcdab2249b95568c\",\"asset_id\":\"af87bf249a7e5ee330c1210e51ac101224034b2e2716177d210b60a06f714ae7\"},\"amount\":200000000,\"script_key\":\"0250aaeb166f4234650d84a2d8a130987aeaf6950206e0905401ee74ff3f8d18e6\",\"decimal_display\":2},\"capacity\":200000000,\"local_balance\":200000000,\"remote_balance\":0}]}"

custom_channel_data:
{'assets': [{'asset_utxo': {'amount': 200000000,
                            'asset_genesis': {'asset_id': 'af87bf249a7e5ee330c1210e51ac101224034b2e2716177d210b60a06f714ae7',
                                              'genesis_point': '2587f694b70a20066162b751bfc341584af591e6ff6f2bd443db410666291b7c:1',
                                              'meta_hash': '009dc0aa29bd1c320fa9b33e15227169f23b77ab6ca845fabcdab2249b95568c',
                                              'name': 'Asset1'},
                            'decimal_display': 2,
                            'script_key': '0250aaeb166f4234650d84a2d8a130987aeaf6950206e0905401ee74ff3f8d18e6',
                            'version': 1},
             'capacity': 200000000,
             'local_balance': 200000000,
             'remote_balance': 0}]}
(✔) (A) cap: 100000 sat, edward->[bal: 46920 sat|res: 1000 sat|spend: 41390 sat], frank->[bal: 50000 sat|res: 1062 sat|spend: 44408 sat], commit_fee: 2420
(✔) (A) cap: 200000000 Asset1, edward->[bal: 200000000 Asset1], frank->[bal: 0 Asset1]

accepted_sell_order {
  peer: "03d6ae1074144880117932cd354d12412930f64e55e62c1fe305b6ec1c578abf38"
  id: "S\255\364\001a\222\263\005\325\333\245\277{\010\035\001M\277\337n0\373\n_\366\022\371\301l\212yt"
  scid: 17731509292056082804
  asset_amount: 38204
  bid_asset_rate {
    coefficient: "101499999990000000000"
    scale: 10
  }
  expiry: 1739790752
  min_transportable_msat: 354009
}

payment_result {
  payment_hash: "1020ab1b9a04edc1395db8d20d47c7bf5dab62c418b433921fbc82688733b273"
  value: 365
  creation_date: 1739790717
  payment_preimage: "0000000000000000000000000000000000000000000000000000000000000000"
  value_sat: 365
  value_msat: 365400
  payment_request: "lnbcrt3654n1pnmxxtapp5zqs2kxu6qnkuzw2ahrfq6378haw6kckyrz6r8yslhjpx3penkfesdqqcqzzsxqyz5vqrzjqf7fkzesd5m79huf73syvzjd7yrn472dpz8syvzn7qgx6rv470ppeaxl25tc4vrvhcqqqqlgqqqqqqgq2qsp5h3whq8pr32p0uckcw770fg3uvnr5rg76xpq3mpmdu9akmjscj88q9qxpqysgq7r2rxcq2amu5kpj5k5ercwp5qz844mngwm3f9sx569qc3dge4q3rt5t4wwz0429uy77xlhulewv274hfgmvs77wut8z7hptd2h2ydeqq0wfmmm"
  status: IN_FLIGHT
  creation_time_ns: 1739790717487880562
  payment_index: 1
  first_hop_custom_records {
    key: 65538
    value: "S\255\364\001a\222\263\005\325\333\245\277{\010\035\001M\277\337n0\373\n_\366\022\371\301l\212yt"
  }
}

payment_result {
  payment_hash: "1020ab1b9a04edc1395db8d20d47c7bf5dab62c418b433921fbc82688733b273"
  value: 365
  creation_date: 1739790717
  payment_preimage: "0000000000000000000000000000000000000000000000000000000000000000"
  value_sat: 365
  value_msat: 365400
  payment_request: "lnbcrt3654n1pnmxxtapp5zqs2kxu6qnkuzw2ahrfq6378haw6kckyrz6r8yslhjpx3penkfesdqqcqzzsxqyz5vqrzjqf7fkzesd5m79huf73syvzjd7yrn472dpz8syvzn7qgx6rv470ppeaxl25tc4vrvhcqqqqlgqqqqqqgq2qsp5h3whq8pr32p0uckcw770fg3uvnr5rg76xpq3mpmdu9akmjscj88q9qxpqysgq7r2rxcq2amu5kpj5k5ercwp5qz844mngwm3f9sx569qc3dge4q3rt5t4wwz0429uy77xlhulewv274hfgmvs77wut8z7hptd2h2ydeqq0wfmmm"
  status: IN_FLIGHT
  creation_time_ns: 1739790717487880562
  htlcs {
    route {
      total_time_lock: 734
      total_amt: 365
      hops {
        chan_id: 485984139542528
        chan_capacity: 100000
        amt_to_forward: 365
        expiry: 734
        amt_to_forward_msat: 365400
        pub_key: "03d6ae1074144880117932cd354d12412930f64e55e62c1fe305b6ec1c578abf38"
        tlv_payload: true
        mpp_record {
          total_amt_msat: 365400
          payment_addr: "\274]p\034#\212\202\376b\330w\274\364\242<d\307A\243\3320A\035\207m\341{m\312\030\221\316"
        }
      }
      total_amt_msat: 365400
      first_hop_amount_msat: 354000
      custom_channel_data: "{\"balances\":[{\"asset_id\":\"af87bf249a7e5ee330c1210e51ac101224034b2e2716177d210b60a06f714ae7\",\"amount\":37088}],\"rfq_id\":\"53adf4016192b305d5dba5bf7b081d014dbfdf6e30fb0a5ff612f9c16c8a7974\"}"
    }
    attempt_time_ns: 1739790717502996180
    attempt_id: 1
  }
  payment_index: 1
  first_hop_custom_records {
    key: 65538
    value: "S\255\364\001a\222\263\005\325\333\245\277{\010\035\001M\277\337n0\373\n_\366\022\371\301l\212yt"
  }
}

payment_result {
  payment_hash: "1020ab1b9a04edc1395db8d20d47c7bf5dab62c418b433921fbc82688733b273"
  value: 365
  creation_date: 1739790717
  payment_preimage: "ac829941a25edfda67b517b4f41da14183225cbac80e5c2eaec2b3c74de2c29a"
  value_sat: 365
  value_msat: 365400
  payment_request: "lnbcrt3654n1pnmxxtapp5zqs2kxu6qnkuzw2ahrfq6378haw6kckyrz6r8yslhjpx3penkfesdqqcqzzsxqyz5vqrzjqf7fkzesd5m79huf73syvzjd7yrn472dpz8syvzn7qgx6rv470ppeaxl25tc4vrvhcqqqqlgqqqqqqgq2qsp5h3whq8pr32p0uckcw770fg3uvnr5rg76xpq3mpmdu9akmjscj88q9qxpqysgq7r2rxcq2amu5kpj5k5ercwp5qz844mngwm3f9sx569qc3dge4q3rt5t4wwz0429uy77xlhulewv274hfgmvs77wut8z7hptd2h2ydeqq0wfmmm"
  status: SUCCEEDED
  creation_time_ns: 1739790717487880562
  htlcs {
    status: SUCCEEDED
    route {
      total_time_lock: 734
      total_amt: 365
      hops {
        chan_id: 485984139542528
        chan_capacity: 100000
        amt_to_forward: 365
        expiry: 734
        amt_to_forward_msat: 365400
        pub_key: "03d6ae1074144880117932cd354d12412930f64e55e62c1fe305b6ec1c578abf38"
        tlv_payload: true
        mpp_record {
          total_amt_msat: 365400
          payment_addr: "\274]p\034#\212\202\376b\330w\274\364\242<d\307A\243\3320A\035\207m\341{m\312\030\221\316"
        }
      }
      total_amt_msat: 365400
      first_hop_amount_msat: 354000
      custom_channel_data: "{\"balances\":[{\"asset_id\":\"af87bf249a7e5ee330c1210e51ac101224034b2e2716177d210b60a06f714ae7\",\"amount\":37088}],\"rfq_id\":\"53adf4016192b305d5dba5bf7b081d014dbfdf6e30fb0a5ff612f9c16c8a7974\"}"
    }
    attempt_time_ns: 1739790717502996180
    resolve_time_ns: 1739790717656241145
    preimage: "\254\202\231A\242^\337\332g\265\027\264\364\035\241A\203\"\\\272\310\016\\.\256\302\263\307M\342\302\232"
    attempt_id: 1
  }
  payment_index: 1
  first_hop_custom_records {
    key: 65538
    value: "S\255\364\001a\222\263\005\325\333\245\277{\010\035\001M\277\337n0\373\n_\366\022\371\301l\212yt"
  }
}

status: SUCCEEDED
expected route: ['edward', 'frank']
actual channel capacities:
active: true
remote_pubkey: "03d6ae1074144880117932cd354d12412930f64e55e62c1fe305b6ec1c578abf38"
channel_point: "174015ce901962a9317e48335857a21c714dcabbb0382b58c89274a253a6a4ca:0"
chan_id: 485984139542528
capacity: 100000
local_balance: 46566
remote_balance: 50354
commit_fee: 2420
commit_weight: 958
fee_per_kw: 2500
total_satoshis_sent: 354
num_updates: 2
csv_delay: 144
private: true
initiator: true
chan_status_flags: "ChanStatusDefault"
local_chan_reserve_sat: 1000
remote_chan_reserve_sat: 1062
lifetime: 11
uptime: 11
commitment_type: SIMPLE_TAPROOT_OVERLAY
push_amount_sat: 50000
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: 83
}
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: 83
}
alias_scids: 17592186044416000001
alias_scids: 17644915424660319422
peer_scid_alias: 17592186044416000000
custom_channel_data: "{\"assets\":[{\"asset_utxo\":{\"version\":1,\"asset_genesis\":{\"genesis_point\":\"2587f694b70a20066162b751bfc341584af591e6ff6f2bd443db410666291b7c:1\",\"name\":\"Asset1\",\"meta_hash\":\"009dc0aa29bd1c320fa9b33e15227169f23b77ab6ca845fabcdab2249b95568c\",\"asset_id\":\"af87bf249a7e5ee330c1210e51ac101224034b2e2716177d210b60a06f714ae7\"},\"amount\":200000000,\"script_key\":\"0250aaeb166f4234650d84a2d8a130987aeaf6950206e0905401ee74ff3f8d18e6\",\"decimal_display\":2},\"capacity\":200000000,\"local_balance\":199962912,\"remote_balance\":37088}]}"

custom_channel_data:
{'assets': [{'asset_utxo': {'amount': 200000000,
                            'asset_genesis': {'asset_id': 'af87bf249a7e5ee330c1210e51ac101224034b2e2716177d210b60a06f714ae7',
                                              'genesis_point': '2587f694b70a20066162b751bfc341584af591e6ff6f2bd443db410666291b7c:1',
                                              'meta_hash': '009dc0aa29bd1c320fa9b33e15227169f23b77ab6ca845fabcdab2249b95568c',
                                              'name': 'Asset1'},
                            'decimal_display': 2,
                            'script_key': '0250aaeb166f4234650d84a2d8a130987aeaf6950206e0905401ee74ff3f8d18e6',
                            'version': 1},
             'capacity': 200000000,
             'local_balance': 199962912,
             'remote_balance': 37088}]}
(A) cap: 100000 sat, edward->[bal: 46566 sat|res: 1000 sat|spend: 41036 sat], frank->[bal: 50354 sat|res: 1062 sat|spend: 44762 sat], commit_fee: 2420
(A) cap: 200000000 Asset1, edward->[bal: 199962912 Asset1], frank->[bal: 37088 Asset1]

=======================================================================================

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Edward/Frank direct-channel reproduction and compare the 36,000-asset invoice with the 37,088 assets received. Trace the accepted buy and sell quotes shown in the logs, then verify that direct invoice payment uses the invoice creator's quote; done means the recipient receives the invoiced amount without applying the remote peer's quote.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
payments
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.