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

Add bolt11 test vector with amount in p units #699

Merged
merged 2 commits into from
Mar 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .aspell.en.pws
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ FIPS
responder
UTF
blockchain
Blockstream
nSequence
decrypt
flen
Expand Down Expand Up @@ -320,6 +321,7 @@ incentivize
redemptions
vbytes
BTC
USD
XSS
SQL
DOM
Expand Down
32 changes: 32 additions & 0 deletions 11-payment-encoding.md
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,38 @@ Breakdown:
* `40wa3khl49yue3zsgm26jrepqr2eghqlx86rttutve3ugd05em86nsefzh4pfurpd9ek9w2vp95zxqnfe2u7ckudyahsa52q66tgzcp`: signature
* `6t2dyk`: Bech32 checksum

> ### Please send 0.00967878534 BTC for a list of items within one week, amount in pico-BTC
> lnbc9678785340p1pwmna7lpp5gc3xfm08u9qy06djf8dfflhugl6p7lgza6dsjxq454gxhj9t7a0sd8dgfkx7cmtwd68yetpd5s9xar0wfjn5gpc8qhrsdfq24f5ggrxdaezqsnvda3kkum5wfjkzmfqf3jkgem9wgsyuctwdus9xgrcyqcjcgpzgfskx6eqf9hzqnteypzxz7fzypfhg6trddjhygrcyqezcgpzfysywmm5ypxxjemgw3hxjmn8yptk7untd9hxwg3q2d6xjcmtv4ezq7pqxgsxzmnyyqcjqmt0wfjjq6t5v4khxxqyjw5qcqp2rzjq0gxwkzc8w6323m55m4jyxcjwmy7stt9hwkwe2qxmy8zpsgg7jcuwz87fcqqeuqqqyqqqqlgqqqqn3qq9qn07ytgrxxzad9hc4xt3mawjjt8znfv8xzscs7007v9gh9j569lencxa8xeujzkxs0uamak9aln6ez02uunw6rd2ht2sqe4hz8thcdagpleym0j

Breakdown:

* `lnbc`: prefix, Lightning on bitcoin mainnet
* `9678785340p`: amount (9678785340 pico-bitcoin = 967878534 milli satoshi)
* `1`: Bech32 separator
* `pwmna7l`: timestamp (1572468703)
* `p`: payment hash.
* `p5`: `data_length` (`p` = 1, `5` = 20; 1 * 32 + 20 == 52)
* `gc3xfm08u9qy06djf8dfflhugl6p7lgza6dsjxq454gxhj9t7a0s`: payment hash 462264ede7e14047e9b249da94fefc47f41f7d02ee9b091815a5506bc8abf75f
* `d`: short description
Copy link
Collaborator

Choose a reason for hiding this comment

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

might be too late at this point, just some thoughts:

the rest of these fields seem tangential to testing pico amount? imo more minimal, targeted test cases are preferable. i see also that it was updated to test route hints as well, perhaps that should have been its own test case?

there are also a lot of constants that are defined and only used for this test, e.g. payment hash, expiry, description, etc. that could be shared with other tests since they don't seem to be exercising explicit edge cases.

Copy link
Collaborator

Choose a reason for hiding this comment

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

True, this test case may be covering too much. But that doesn't mean an implementation has to do all the checks if they're redundant with other tests, right? I don't mind updating this PR, but I'd rather not spend too much time on in since it's quite a trivial addition.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it depends on your testing framework, lnd asserts encoding/decoding and the in-memory representation. I wouldn't explain what I just went through as trivial, but it is done now :P

Copy link
Collaborator

Choose a reason for hiding this comment

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

Allright then now that the painful code is written, let's merge this PR and let this test case live a long and happy life :D

* `8d`: `data_length` (`8` = 7, `d` = 13; 7 * 32 + 13 == 237)
* `gfkx7cmtwd68yetpd5s9xar0wfjn5gpc8qhrsdfq24f5ggrxdaezqsnvda3kkum5wfjkzmfqf3jkgem9wgsyuctwdus9xgrcyqcjcgpzgfskx6eqf9hzqnteypzxz7fzypfhg6trddjhygrcyqezcgpzfysywmm5ypxxjemgw3hxjmn8yptk7untd9hxwg3q2d6xjcmtv4ezq7pqxgsxzmnyyqcjqmt0wfjjq6t5v4khx`: 'Blockstream Store: 88.85 USD for Blockstream Ledger Nano S x 1, \"Back In My Day\" Sticker x 2, \"I Got Lightning Working\" Sticker x 2 and 1 more items'
* `x`: expiry time
* `qy`: `data_length` (`q` = 0, `y` = 2; 0 * 32 + 4 == 4)
* `jw5q`: 604800 seconds (`j` = 18, `w` = 14, `5` = 20, `q` = 0; 18 * 32^3 + 14 * 32^2 + 20 * 32 + 0 == 604800)
* `c`: `min_final_cltv_expiry`
* `qp`: `data_length` (`q` = 0, `p` = 1; 0 * 32 + 1 == 1)
* `2`: min_final_cltv_expiry = 10
* `r`: tagged field: route information
* `zj`: `data_length` (`z` = 2, `j` = 18; 2 * 32 + 18 == 82)
* `q0gxwkzc8w6323m55m4jyxcjwmy7stt9hwkwe2qxmy8zpsgg7jcuwz87fcqqeuqqqyqqqqlgqqqqn3qq9q`:
* pubkey: 03d06758583bb5154774a6eb221b1276c9e82d65bbaceca806d90e20c108f4b1c7
* short_channel_id: 589390x3312x1
* fee_base_msat = 1000
* fee_proportional_millionths = 2500
* cltv_expiry_delta = 40
* `n07ytgrxxzad9hc4xt3mawjjt8znfv8xzscs7007v9gh9j569lencxa8xeujzkxs0uamak9aln6ez02uunw6rd2ht2sqe4hz8thcdagp`: signature
* `leym0j`: Bech32 checksum

# Authors

[ FIXME: ]
Expand Down