Skip to content
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

Fixes stuff inside bolt12 decode #324

Merged
merged 3 commits into from
Feb 10, 2025

Conversation

Harshit933
Copy link
Collaborator

@Harshit933 Harshit933 commented Dec 14, 2024

Decoding bolt12 now:

[harshit:~] lampo-cli --network regtest decode --invoice_str lno1qgsyxjtl6luzd9t3pr62xr7eemp6awnejusgf6gw45q75vcfqqqqqqqsespexwyy4tcadvgg89l9aljus6709kx235hhqrk6n8dey98uyuftzdqzrtkahuum7m56dxlnx8r6tffy54004l7kvs7pylmxx7xs4n54986qyqeeuhhunayntt50snmdkq4t7fzsgghpl69v9csgparek8kv7dlp5uqr8ymp5s4z9upmwr2s8xu020d45t5phqc8nljrq8gzsjmurzevawjz6j6rc95xwfvnhgfx6v4c3jha7jwynecrz3y092nn25ek4yl7xp9yu9ry9zqagt0ktn4wwvqg52v9ss9ls22sqyqqestzp2l6decpn87pq96udsvx
{
  "issuer": "No issuer id provided",
  "offer_id": "[52, 70, 8, 105, 84, 158, 55, 116, 140, 234, 171, 220, 255, 98, 132, 169, 130, 102, 193, 128, 82, 171, 42, 126, 158, 181, 161, 175, 10, 94, 91, 125]",
  "offer_chains": [
    "43497fd7f826957108f4a30fd9cec3aeba79972084e90ead01ea330900000000"
  ],
  "description": "Description not provided",
  "offer_paths": [
    {
      "blinded_hops": [
        "0339e5efc9f4935ae8f84f6db02abf2450422e1fe8ac2e2080f479b1eccf37e1a7",
        "031448f2aa7355336a93fe304a4e14642881d42df65ceae73008a2985840bf8295"
      ],
      "blinding_points": "021aeddbf39bf6e9a69bf331c7a5a524a55efaffd6643c127f66378d0ace9529f4"
    }
  ],
  "network": "testnet"
}

If the bolt11/bolt12 is invalid:

[harshit:~] lampo-cli --network regtest decode --invoice_str lno1qgsyxjtl6luzd9t3pr62xr7eemp6awnejusgf6gw45q75vcfqqqqqqqsespexwyy4tcadvgg89l9aljus6709kx235hhqrk6n8dey98uyuftzdqzrtkahuum7m56dxlnx8r6tffy54004l7kvs7pylmxx7xs4n54986qyqeeuhhunayntt50snmdkq4t7fzsgghpl69v9csgparek8kv7dlp5uqr8ymp5s4z9upmwr2s8xu020d45t5phqc8nljrq8gzsjmurzevawjz6j6rc95xwfvnhgfx6v4c3jha7jwynecrz3y092nn25ek4yl7xp9yu9ry9zqagt0ktn4wwvqg52v9ss9ls22sqyqqestzp2l6decpn87pq96uds
{
  "code": -1,
  "message": "Not able to decode invoice",
  "data": null
}

UPDATE:

Running lampo-cli --network regtest decode --invoice_str lno1qgsyxjtl6luzd9t3pr62xr7eemp6awnejusgf6gw45q75vcfqqqqqqqsespexwyy4tcadvgg89l9aljus6709kx235hhqrk6n8dey98uyuftzdqzrtkahuum7m56dxlnx8r6tffy54004l7kvs7pylmxx7xs4n54986qyqeeuhhunayntt50snmdkq4t7fzsgghpl69v9csgparek8kv7dlp5uqr8ymp5s4z9upmwr2s8xu020d45t5phqc8nljrq8gzsjmurzevawjz6j6rc95xwfvnhgfx6v4c3jha7jwynecrz3y092nn25ek4yl7xp9yu9ry9zqagt0ktn4wwvqg52v9ss9ls22sqyqqestzp2l6decpn87pq96udsvx

Gives the following output:

{
  "issuer_id": null,
  "offer_id": "34460869549e37748ceaabdcff6284a98266c18052ab2a7e9eb5a1af0a5e5b7d",
  "offer_chains": [
    "43497fd7f826957108f4a30fd9cec3aeba79972084e90ead01ea330900000000"
  ],
  "description": null,
  "offer_paths": [
    {
      "blinded_hops": [
        "0339e5efc9f4935ae8f84f6db02abf2450422e1fe8ac2e2080f479b1eccf37e1a7",
        "031448f2aa7355336a93fe304a4e14642881d42df65ceae73008a2985840bf8295"
      ],
      "blinding_points": "021aeddbf39bf6e9a69bf331c7a5a524a55efaffd6643c127f66378d0ace9529f4"
    }
  ],
  "network": "testnet"
}

See commits for more info.
Fixes #270 #318

@vincenzopalazzo
Copy link
Owner

Plus offer_id is a vector of bytes, please convert it to hex::(offer_id) there is no need to print a vector of byte to the user

@vincenzopalazzo
Copy link
Owner

@Harshit933 can you post another time the lampo-cli --network regtest decode --invoice_str lno1qgsyxjtl6luzd9t3pr62xr7eemp6awnejusgf6gw45q75vcfqqqqqqqsespexwyy4tcadvgg89l9aljus6709kx235hhqrk6n8dey98uyuftzdqzrtkahuum7m56dxlnx8r6tffy54004l7kvs7pylmxx7xs4n54986qyqeeuhhunayntt50snmdkq4t7fzsgghpl69v9csgparek8kv7dlp5uqr8ymp5s4z9upmwr2s8xu020d45t5phqc8nljrq8gzsjmurzevawjz6j6rc95xwfvnhgfx6v4c3jha7jwynecrz3y092nn25ek4yl7xp9yu9ry9zqagt0ktn4wwvqg52v9ss9ls22sqyqqestzp2l6decpn87pq96udsvx

And/or probably write a test to make sure that what we should have as a hex string it is not a vector of bytes?

otherwise LGMT Thanks :)

@vincenzopalazzo vincenzopalazzo added this to the v24.12 milestone Jan 16, 2025
@vincenzopalazzo vincenzopalazzo added the P-hight Hiight Priotity issue label Jan 16, 2025
@Harshit933
Copy link
Collaborator Author

@Harshit933 can you post another time the lampo-cli --network regtest decode --invoice_str lno1qgsyxjtl6luzd9t3pr62xr7eemp6awnejusgf6gw45q75vcfqqqqqqqsespexwyy4tcadvgg89l9aljus6709kx235hhqrk6n8dey98uyuftzdqzrtkahuum7m56dxlnx8r6tffy54004l7kvs7pylmxx7xs4n54986qyqeeuhhunayntt50snmdkq4t7fzsgghpl69v9csgparek8kv7dlp5uqr8ymp5s4z9upmwr2s8xu020d45t5phqc8nljrq8gzsjmurzevawjz6j6rc95xwfvnhgfx6v4c3jha7jwynecrz3y092nn25ek4yl7xp9yu9ry9zqagt0ktn4wwvqg52v9ss9ls22sqyqqestzp2l6decpn87pq96udsvx

Updated the description also added a test in 593fe3e

Copy link
Owner

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

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

Ok I did another review, thanks for doing it.

I think the git history need some kind of rework (squash the commit with the one that are no longer true) and then we are ready to go :)

Thanks for doing it

@Harshit933 Harshit933 force-pushed the feature/fix-bolt12 branch 2 times, most recently from d25a806 to 5e19836 Compare January 27, 2025 02:02
This commit adds another struct namely `Bolt12Invoice` to structure
all the information regarding it. Also renames the `InvoiceInfo` to
`Bolt11InvoiceInfo`, mainly for holding bolt11 info.
This commits renames the previous testing server command for
decoding offers ("decode_invoice") to `decode` and also changes
all its occurings in the testing code.
@Harshit933 Harshit933 force-pushed the feature/fix-bolt12 branch 2 times, most recently from 6a3a72c to 6a02c69 Compare January 27, 2025 02:14
Copy link
Owner

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

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

Concept ACK 6a02c69

Small comments on the code still, but we are good to go! thanks for working on it

This commit adds an integration test to check if the `offer_id`
is a hex string or not.
Copy link
Owner

@vincenzopalazzo vincenzopalazzo left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines 97 to 101
let network = offer
.chains()
.first()
.map(|hash| Network::from_chain_hash(*hash))
.unwrap_or(Some(Network::Bitcoin));
.and_then(|hash| Network::from_chain_hash(*hash))
.or(Some(Network::Bitcoin));
Copy link
Owner

Choose a reason for hiding this comment

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

Good also for a folloup PR, but I would like to leave this Optional and not try to force the type here!

If there is any chain, will remain None

Comment on lines +532 to +534
// Checks if all the character inside the offer_id is hex.
let res = decode.offer_id.chars().all(|c| c.is_ascii_hexdigit());
assert!(res);
Copy link
Owner

Choose a reason for hiding this comment

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

we can remove this code, I do not understand it, so better remove it (also in a follup PR)

@vincenzopalazzo vincenzopalazzo merged commit 74010e7 into vincenzopalazzo:main Feb 10, 2025
3 of 5 checks passed
khadar1020 pushed a commit to khadar1020/lampo.rs that referenced this pull request Feb 11, 2025
This removes the validation check in hex as discussed in issues vincenzopalazzo#351 and vincenzopalazzo#324.
@Psycho-Pirate Psycho-Pirate mentioned this pull request Feb 17, 2025
vincenzopalazzo pushed a commit that referenced this pull request Feb 17, 2025
This removes the validation check in hex as discussed in issues #351 and #324.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P-hight Hiight Priotity issue
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[BUG] bolt12 decode does not include the blinded path inside the offer if specified
2 participants