diff --git a/13_4_Paying_a_Invoice.md b/13_4_Paying_a_Invoice.md index 8dc6890..4809119 100644 --- a/13_4_Paying_a_Invoice.md +++ b/13_4_Paying_a_Invoice.md @@ -4,7 +4,16 @@ > :book: ***What is an invoice +Almost all payments made on the Lightning Network require an invoice, which is nothing more than a request for payment made by the recipient of the money and sent by different means to the user who will pay. The format for a Lightning invoice uses bech32 encoding, which is already used for Bitcoin Segregated Witness and all payment requests are single use. +Invoices have two parts: + +- Human readable part: `ln` + (`lnbc` for Bitcoin mainnet, `lntb` for Bitcoin testnet, and `lnbcrt` for Bitcoin regtest) + data amount + +- Data part : UNIX Timestamp + tagged parts include a payment hash, the pubkey of the payee node, an optional description of the payment, an expiration time, and some extra routing information. + +Conside this ln invoice `lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39vhgcnv6gfa2g2ktqy9lf0aph60d0388xmqdqqcqzpgsp545a9fphd8m5ayplcu8m5845cr4m0zcnyxddwv4g3zm32yprkfd4q9qy9qsq3s4y6cmyvh0qw9qm0sf80llxyyjy9xwrjds7lpkqhzv247jsm6q5me8t9e6ftquma664gz5u4a2rvs0yf4f0mlwtwfs6as5uj5djzhcqpnqlcj +` Starts with Prefix ln+tb+1m that indicates milli, so you should multi by 0.001. ### Understanding your invoice @@ -25,6 +34,41 @@ c$lightning-cli --network=testnet decodepay lntb1m1p03ft7lpp5zve4dsgwgdxekqqq39v "signature": "30450221008c2a4d636465de07141b7c1277ffe621244299c39361ef86c0b898aafa50de8102204de4eb2e7495839beeb5540a9caf543641e44d52fdfdcb7261aec29c951b215f" } ``` +### Check your balance + +``` +c$ lightning-cli --network=testnet listfunds +{ + "outputs": [ + { + "txid": "9843c037f54a4660b297a9f2454e11d26d8659f084a284a5740bb15cb1d97aa6", + "output": 0, + "value": 19238, + "amount_msat": "19238000msat", + "scriptpubkey": "0014aa572371f29310cd677d039cdcd054156c1a9545", + "address": "tb1q4ftjxu0jjvgv6emaqwwde5z5z4kp49299gmdpd", + "status": "confirmed", + "blockheight": 1780768, + "reserved": false + } + ], + "channels": [ + { + "peer_id": "0302d48972ba7eef8b40696102ad114090fd4c146e381f18c7932a2a1d73566f84", + "connected": true, + "state": "CHANNELD_AWAITING_LOCKIN", + "channel_sat": 280000, + "our_amount_msat": "280000000msat", + "channel_total_sat": 280000, + "amount_msat": "280000000msat", + "funding_txid": "9843c037f54a4660b297a9f2454e11d26d8659f084a284a5740bb15cb1d97aa6", + "funding_output": 1 + } + ] +} +``` + + ### Paying your invoice ```