Skip to content

Commit

Permalink
fixup! invoice: Parse amounts without a multiplier as BTC not msats
Browse files Browse the repository at this point in the history
  • Loading branch information
cdecker committed Apr 9, 2020
1 parent ce70919 commit bb1032f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion common/bolt11.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ struct bolt11 *bolt11_decode(const tal_t *ctx, const char *str,
* 'social' convention of a payment unit -- in the case of
* Bitcoin the unit is 'bitcoin' NOT satoshis.
*/
u64 m10 = 10E12; /* Pico satoshis in a Bitcoin */
u64 m10 = 10 * MSAT_PER_BTC; /* Pico satoshis in a Bitcoin */
u64 amount;
char *end;

Expand Down
3 changes: 2 additions & 1 deletion tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,8 @@ def test_decodepay(node_factory):
# satoshis.
b11 = "lnbcrt71p0g4u8upp5xn4k45tsp05akmn65s5k2063d5fyadhjse9770xz5sk7u4x6vcmqdqqcqzynxqrrssx94cf4p727jamncsvcd8m99n88k423ruzq4dxwevfatpp5gx2mksj2swshjlx4pe3j5w9yed5xjktrktzd3nc2a04kq8yu84l7twhwgpxjn3pw"
b11 = l1.rpc.decodepay(b11)
assert(b11['msatoshi'] == 7*10**11)
sat_per_btc = 10**8
assert(b11['msatoshi'] == 7 * sat_per_btc * 1000)

with pytest.raises(RpcError):
l1.rpc.decodepay('1111111')
Expand Down

0 comments on commit bb1032f

Please sign in to comment.