Skip to content

[custom channels]: in itest assert payment and invoice HTLCs show custom data #879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 30, 2024

Conversation

guggero
Copy link
Member

@guggero guggero commented Oct 22, 2024

Depends on #848.

With this commit we sporadically assert in our itests that the outgoing HTLCs for a payment and the incoming HTLCs of an invoice show the custom channel data JSON with the actual asset amounts.

Fixes #860.

Example invoice
assets_test.go:862: Asset invoice: {
            "memo":  "this is an asset invoice over 100000 units",
            "r_preimage":  "0b47e516136f867eb8f578ec44e240d4935643050ad47583b14a6c26ffbb20e2",
            "r_hash":  "cb502385800559c07812597ee863556fca2c981451668c57a582ad998ebd034d",
            "value":  "1718035",
            "value_msat":  "1718035941",
            "settled":  true,
            "creation_date":  "1729615613",
            "settle_date":  "1729615613",
            "payment_request":  "lnbcrt17180359410p1pn304happ5edgz8pvqq4vuq7qjt9lwsc64dl9zexq529ngc4a9s2kenr4aqdxsdzyw35xjueqd9ejqctwypshxum9wssxjmnkda5kxefqdamx2u3qxycrqvpsxqs82mnfw3escqzzsxqzfvrzjq0qpeu7ra3xl2pxgrfkdlj0s0yvp99xvmltzw0xsezz6srunx6esdazhpj8h8twt3sqqqqlgqqqqqqgq2qsp5dpm8vjvzn3uyw6xsdc4swc6s74zll7ucpakdwldcjg2jd7rtt8aq9qxpqysgq8jualj4mpv9x0wd906hpe2a93mq40klfznrs0rfqrn0qdc5s3a6sekl6l8uvvjayes36a6s7fck8k7853ykg5yklnj9hn6sfjqrgslsqmyczep",
            "description_hash":  "",
            "expiry":  "300",
            "fallback_addr":  "",
            "cltv_expiry":  "80",
            "route_hints":  [
                {
                    "hop_hints":  [
                        {
                            "node_id":  "03c01cf3c3ec4df504c81a6cdfc9f079181294ccdfd6273cd0c885a80f9336b306",
                            "chan_id":  "17606555078488869772",
                            "fee_base_msat":  1000,
                            "fee_proportional_millionths":  1,
                            "cltv_expiry_delta":  80
                        }
                    ]
                }
            ],
            "private":  true,
            "add_index":  "5",
            "settle_index":  "5",
            "amt_paid":  "1718035941",
            "amt_paid_sat":  "1718035",
            "amt_paid_msat":  "1718035941",
            "state":  "SETTLED",
            "htlcs":  [
                {
                    "chan_id":  "537661186179072",
                    "htlc_index":  "18",
                    "amt_msat":  "1718035941",
                    "accept_height":  494,
                    "accept_time":  "1729615613",
                    "resolve_time":  "1729615613",
                    "expiry_height":  577,
                    "state":  "SETTLED",
                    "custom_records":  {
                        "65536":  "012c0020bb9eedadf7e7985639fbd60b1c6ea97b5eb9b4ae55f4f63685ba480a42e5db070108000000000001869f",
                        "65538":  "a812a383f14908081a3b289c55b9e77aac5caab6cbf00345f68fa397327597ac",
                        "65543":  "006c016a0020bb9eedadf7e7985639fbd60b1c6ea97b5eb9b4ae55f4f63685ba480a42e5db0701407386a43b1722319acd6b32e42a83e0bf1835f7a45992a6a7aaa52d141c553877731d2748c06f68fb5c468c3e40fac62909d4859ee690cc95bd5983f56926a77e020400000083"
                    },
                    "mpp_total_amt_msat":  "1718035941",
                    "amp":  null,
                    "custom_channel_data":  "7b2262616c616e636573223a5b7b2261737365745f6964223a2262623965656461646637653739383536333966626436306231633665613937623565623962346165353566346636333638356261343830613432653564623037222c22616d6f756e74223a39393939397d5d2c227266715f6964223a2261383132613338336631343930383038316133623238396335356239653737616163356361616236636266303033343566363866613339373332373539376163227d"
                }
            ],
            "features":  {
                "8":  {
                    "name":  "tlv-onion",
                    "is_required":  true,
                    "is_known":  true
                },
                "14":  {
                    "name":  "payment-addr",
                    "is_required":  true,
                    "is_known":  true
                },
                "17":  {
                    "name":  "multi-path-payments",
                    "is_required":  false,
                    "is_known":  true
                },
                "25":  {
                    "name":  "route-blinding",
                    "is_required":  false,
                    "is_known":  true
                }
            },
            "is_keysend":  false,
            "payment_addr":  "68767649829c784768d06e2b076350f545fffb980f6cd77db8921526f86b59fa",
            "is_amp":  false,
            "amp_invoice_state":  {},
            "is_blinded":  false,
            "blinded_path_config":  null
        }

Where the custom channel data evaluate to (would be decoded automatically in lncli, the above is directly from the itests):

{
  "balances": [
    {
      "asset_id": "bb9eedadf7e7985639fbd60b1c6ea97b5eb9b4ae55f4f63685ba480a42e5db07",
      "amount": 99999
    }
  ],
  "rfq_id": "a812a383f14908081a3b289c55b9e77aac5caab6cbf00345f68fa397327597ac"
}
Example payment
assets_test.go:904: Asset payment: {
            "payment_hash":  "cb502385800559c07812597ee863556fca2c981451668c57a582ad998ebd034d",
            "value":  "1718035",
            "creation_date":  "1729615613",
            "fee":  "0",
            "payment_preimage":  "0b47e516136f867eb8f578ec44e240d4935643050ad47583b14a6c26ffbb20e2",
            "value_sat":  "1718035",
            "value_msat":  "1718035941",
            "payment_request":  "lnbcrt17180359410p1pn304happ5edgz8pvqq4vuq7qjt9lwsc64dl9zexq529ngc4a9s2kenr4aqdxsdzyw35xjueqd9ejqctwypshxum9wssxjmnkda5kxefqdamx2u3qxycrqvpsxqs82mnfw3escqzzsxqzfvrzjq0qpeu7ra3xl2pxgrfkdlj0s0yvp99xvmltzw0xsezz6srunx6esdazhpj8h8twt3sqqqqlgqqqqqqgq2qsp5dpm8vjvzn3uyw6xsdc4swc6s74zll7ucpakdwldcjg2jd7rtt8aq9qxpqysgq8jualj4mpv9x0wd906hpe2a93mq40klfznrs0rfqrn0qdc5s3a6sekl6l8uvvjayes36a6s7fck8k7853ykg5yklnj9hn6sfjqrgslsqmyczep",
            "status":  "SUCCEEDED",
            "fee_sat":  "0",
            "fee_msat":  "0",
            "creation_time_ns":  "1729615613604251687",
            "htlcs":  [
                {
                    "attempt_id":  "19",
                    "status":  "SUCCEEDED",
                    "route":  {
                        "total_time_lock":  577,
                        "total_fees":  "0",
                        "total_amt":  "1718035",
                        "hops":  [
                            {
                                "chan_id":  "537661186179072",
                                "chan_capacity":  "100000",
                                "amt_to_forward":  "1718035",
                                "fee":  "0",
                                "expiry":  577,
                                "amt_to_forward_msat":  "1718035941",
                                "fee_msat":  "0",
                                "pub_key":  "031bb2310f97d81b3219bc3c72a96400beb95a3287e43c1f7ed762e9bf4bce24e1",
                                "tlv_payload":  true,
                                "mpp_record":  {
                                    "payment_addr":  "68767649829c784768d06e2b076350f545fffb980f6cd77db8921526f86b59fa",
                                    "total_amt_msat":  "1718035941"
                                },
                                "amp_record":  null,
                                "custom_records":  {},
                                "metadata":  "",
                                "blinding_point":  "",
                                "encrypted_data":  "",
                                "total_amt_msat":  "0"
                            }
                        ],
                        "total_fees_msat":  "0",
                        "total_amt_msat":  "1718035941",
                        "first_hop_amount_msat":  "354000",
                        "custom_channel_data":  "7b2262616c616e636573223a5b7b2261737365745f6964223a2262623965656461646637653739383536333966626436306231633665613937623565623962346165353566346636333638356261343830613432653564623037222c22616d6f756e74223a39393939397d5d2c227266715f6964223a2261383132613338336631343930383038316133623238396335356239653737616163356361616236636266303033343566363866613339373332373539376163227d"
                    },
                    "attempt_time_ns":  "1729615613623285861",
                    "resolve_time_ns":  "1729615613844891774",
                    "failure":  null,
                    "preimage":  "0b47e516136f867eb8f578ec44e240d4935643050ad47583b14a6c26ffbb20e2"
                }
            ],
            "payment_index":  "7",
            "failure_reason":  "FAILURE_REASON_NONE",
            "first_hop_custom_records":  {
                "65536":  "00",
                "65538":  "a812a383f14908081a3b289c55b9e77aac5caab6cbf00345f68fa397327597ac"
            }
        }

Decoded:

{
  "balances": [
    {
      "asset_id": "bb9eedadf7e7985639fbd60b1c6ea97b5eb9b4ae55f4f63685ba480a42e5db07",
      "amount": 99999
    }
  ],
  "rfq_id": "a812a383f14908081a3b289c55b9e77aac5caab6cbf00345f68fa397327597ac"
}

@guggero guggero requested review from ffranr and GeorgeTsagk October 22, 2024 16:56
@guggero guggero self-assigned this Oct 22, 2024
@guggero guggero linked an issue Oct 22, 2024 that may be closed by this pull request
5 tasks
@dstadulis dstadulis added this to the tapd v0.4.2 milestone Oct 23, 2024
@guggero guggero force-pushed the update-to-lnd-18-4 branch from eb2784e to af9c9bd Compare October 28, 2024 10:22
@guggero guggero requested review from gijswijs and removed request for GeorgeTsagk October 28, 2024 10:26
@guggero guggero force-pushed the assert-payment-invoice-htlcs branch from 3041f1e to 27d4e91 Compare October 28, 2024 10:36
@guggero guggero requested a review from ffranr October 28, 2024 10:36
Copy link
Contributor

@gijswijs gijswijs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't even find a nit, and I tried, so LGTM! 🎉

@guggero guggero force-pushed the update-to-lnd-18-4 branch from a533a9f to 25d64a1 Compare October 30, 2024 08:37
With this commit we sporadically assert in our itests that the outgoing
HTLCs for a payment and the incoming HTLCs of an invoice show the custom
channel data JSON with the actual asset amounts.
@guggero guggero force-pushed the assert-payment-invoice-htlcs branch from 27d4e91 to 2e30a6d Compare October 30, 2024 08:39
@guggero guggero merged commit 9d2c79d into update-to-lnd-18-4 Oct 30, 2024
11 of 13 checks passed
@guggero guggero deleted the assert-payment-invoice-htlcs branch October 30, 2024 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

itests: Assert payment+invoice HTLC custom wire records are persisted, returned
4 participants