lightningnetwork / lnd

Lightning Network Daemon ⚡️
MIT License
7.67k stars 2.07k forks source link

invoice not working: failure resolution result outcome: expiry too soon #6316

Closed philipp1992 closed 2 years ago

philipp1992 commented 2 years ago

Background

Payee LND --- LND Payer

Sending an invoice like the following: image

When trying to pay for that invoice, the payer gets an "incorrect payment details" error. On the payee lnd side, i get the following log:

2022-03-08 09:34:29.788 [TRC] IRPC: [addinvoice] adding new invoice (*channeldb.Invoice)(0xc0008c4540)({
 Memo: ([]uint8) (len=21 cap=32) {
  00000000  46 65 65 20 66 6f 72 20  70 6c 61 63 69 6e 67 20  |Fee for placing |
  00000010  6f 72 64 65 72                                    |order|
 },
 PaymentRequest: ([]uint8) (len=290 cap=320) {
  00000000  6c 6e 74 62 31 30 6e 31  70 33 7a 77 67 65 39 70  |lntb10n1p3zwge9p|
  00000010  70 35 70 6d 6e 6d 78 68  33 32 77 37 70 66 79 35  |p5pmnmxh32w7pfy5|
  00000020  75 6d 38 72 76 66 6d 6a  79 67 6b 73 39 30 38 73  |um8rvfmjygks908s|
......
 CreationDate: (time.Time) 2022-03-08 09:34:29.782577084 +0000 UTC m=+5887.631966287,
 SettleDate: (time.Time) 0001-01-01 00:00:00 +0000 UTC,
 Terms: (channeldb.ContractTerm) amt=1000 mSAT, expiry=2h0m0s, final_cltv_delta=160,
 AddIndex: (uint64) 0,
 SettleIndex: (uint64) 0,
 State: (channeldb.ContractState) Open,
 AmtPaid: (lnwire.MilliSatoshi) 0 mSAT,
 Htlcs: (map[channeldb.CircuitKey]*channeldb.InvoiceHTLC) <nil>,
 HodlInvoice: (bool) false
})

2022-03-08 09:34:30.115 [TRC] LNWL: ChannelPoint(a9935e6c1d7561e9fefbecc3bfa3a777d3d07cfe900204f6924c29a9782663d7:0): remote party accepted state transition, revoked height 151, now at 152
2022-03-08 09:34:30.119 [TRC] HSWC: ChannelLink(2169552:2:0): processing 1 remote adds for height 152
2022-03-08 09:34:30.120 [TRC] CNCT: ChannelArbitrator(a9935e6c1d7561e9fefbecc3bfa3a777d3d07cfe900204f6924c29a9782663d7:0): fresh set of htlcs=(*contractcourt.ContractUpdate)(0xc002dfaa20)({
 HtlcKey: (contractcourt.HtlcSetKey) RemoteHtlcSet,

2022-03-08 09:34:30.142 [DBG] INVC: Invoice0xb03ae0: failure resolution result outcome: expiry too soon, at accept height: 2183957, amt=1000 mSAT, expiry=2184113, circuit=(Chan ID=2169552:2:0, HTLC ID=71), mpp=total=1000 mSAT, addr=cd0e9b422c0b0984e9ffecf2a11fe6a54cd2e87bc26202637e920bf0602b62c4

2022-03-08 09:34:30.143 [DBG] HSWC: ChannelLink(2169552:2:0): received cancel resolution for (Chan ID=2169552:2:0, HTLC ID=71) with outcome: expiry too soon
2022-03-08 09:34:30.144 [TRC] HSWC: Notifying link failure event: receive over (Chan ID=2169552:2:0, HTLC ID=71), incoming amount: 1000 mSAT, incoming timelock: 2184113
2022-03-08 09:34:30.144 [DBG] PEER: Sending UpdateFailHTLC(chan_id=d7632678a9294c92f6040290fe7cd0d377a7a3bfc3ecfbfee961751d6c5e93a9, id=71, reason=bc7d10036478224a86e4ba15a2bd10bdc7a7b9afd2d59927b98b0f26840afd488da1f06242ae66a2b39c6295b59467bb3895eff690fe7ff57a41b90b938840d11a95e9d4073102b7c1680e87dc0a1befd6707b6788804ffa7d224b681d0949e9511e037c5a63d80e7ae2ff9b4e3aa227a097c08db24213fae051315da9a583bc14cefc0ce0a4d4f2647c4a1c5107569c47112e9c0b1e17001eeb6a7d715f6d07313622df03ebcd5229445f42e4a0912d96d8fbef81c99dc12ffcc5395393cbfe65c361b161e60466bad67f14f07a3509eed780c5ba0e31d7661f33caae58b266acdf609012dae0c4f212d14defd07c103b7eb02491dda0419c381e326621b0ed0c8057d1dd57b4bfa8b73ca814659e642ec230f583ebd32727fa31928c6dfeb49be44355) to 02ad34cf2a15f89666d31e0cc159640e7747e7a1d4e167f0239863b9694d169d3e@10.42.0.1:23940
2022-03-08 09:34:30.145 [TRC] PEER: writeMessage to 02ad34cf2a15f89666d31e0cc159640e7747e7a1d4e167f0239863b9694d169d3e@10.42.0.1:23940: (*lnwire.UpdateFailHTLC)(0xc003cf6200)({
 ChanID: (lnwire.ChannelID) (len=32 cap=32) d7632678a9294c92f6040290fe7cd0d377a7a3bfc3ecfbfee961751d6c5e93a9,

LND parameters:


--tlscertpath=/data/tls.cert --tlskeypath=/data/tls.key  --tlsextradomain=lnd-btc  --rpclisten=0.0.0.0:10000 --listen=0.0.0.0:11000 --restlisten=12000 --datadir=/data --logdir=/data --nobootstrap --bitcoin.active --bitcoin.testnet \
    --bitcoin.defaultchanconfs=1 --bitcoin.node=bitcoind --bitcoind.rpchost=bitcoind:18332 --bitcoind.rpcuser=xxx--bitcoind.rpcpass=xxx--bitcoind.zmqpubrawblock=tcp://bitcoind:18444 \
    --bitcoind.zmqpubrawtx=tcp://bitcoind:18446 --debuglevel=debug --autopilot.conftarget=1 --externalip=${EXTERNAL_IP}:xxx--maxpendingchannels=50 --chan-enable-timeout=1m \
    --maxlogfiles=100 --backupfilepath=/data/channel.backup --bitcoin.timelockdelta=18 --bitcoin.defaultremotedelay=3 --historicalsyncinterval=30m --numgraphsyncpeers=30000   \
    --alias=${EXTERNAL_IP} --color=#227223 --watchtower.active --watchtower.towerdir=/data/tower_data --watchtower.externalip=${EXTERNAL_IP}:19000 --watchtower.listen=0.0.0.0:9900 
Roasbeef commented 2 years ago

Are all the nodes synced to the main chain? This happens if one node is behind and doesn't know what the proper block height is.

I see you're on testnet, where there was a block storm (several blocks a minute) over the past few days. This is likely the culprit, if both nodes are fully synced, you won't encounter that issue.

Will re-open if we have evidence otherwise.

Roasbeef commented 2 years ago

Terms: (channeldb.ContractTerm) amt=1000 mSAT, expiry=2h0m0s, final_cltv_delta=160,

How are you paying the invoice? I see you have a custom final CLTV delta set, higher than the actual amount.

philipp1992 commented 2 years ago

these two commands were executed back to back within 5 seconds with the same pay_request and the first one failed with the "expiry too soon" error from above, while the second succeeded.

payment request was created with lncli addinvoice --amt 100000

philipp@ubuntu:~/.local/share/Stakenet/stakenet-wallet-testnet/lnd/ltc$ lncli --network=testnet  --rpcserver=localhost:20001  --macaroonpath=./admin.macaroon --tlscertpath=./tls.cert payinvoice $INVOICE -f --json
{
    "payment_hash": "f7b465ffce94bfd9fa6a60710f71984bfba2c048df9f226ac0decfef5196445e",
    "value": "100000",
    "creation_date": "1647643915",
    "fee": "0",
    "payment_preimage": "0000000000000000000000000000000000000000000000000000000000000000",
    "value_sat": "100000",
    "value_msat": "100000000",
    "payment_request": "lntltc1m1p3r2r86pp5776xtl7wjjlan7n2vpcs7uvcf0a69szgm70jy6kqmm8775vkg30qdqqcqzjqxqrrsssp5af6kyj79xn7rgaktnxygewp2jw6mu58qxc82f5rwysfff3n9875s9qyyssqru6cw2xrruusvuyv33fedw75lx02vjwdlfp7rnmnux2c5w3pnx43chj7lepzd3w0u6tymp46y0snhv89hz3a7my5cnckvzvcd8t2tyspftnyzz",
    "status": "FAILED",
    "fee_sat": "0",
    "fee_msat": "0",
    "creation_time_ns": "1647643915632593076",
    "htlcs": [
        {
            "attempt_id": "20025",
            "status": "FAILED",
            "route": {
                "total_time_lock": 2253507,
                "total_fees": "0",
                "total_amt": "100000",
                "hops": [
                    {
                        "chan_id": "2464825793524531200",
                        "chan_capacity": "42888721",
                        "amt_to_forward": "100000",
                        "fee": "0",
                        "expiry": 2253507,
                        "amt_to_forward_msat": "100000000",
                        "fee_msat": "0",
                        "pub_key": "037b321ba397e96f2733c9bb49cfe447c8054306194f510a156630d45a598c1f67",
                        "tlv_payload": true,
                        "mpp_record": {
                            "payment_addr": "ea75624bc534fc3476cb99888cb82a93b5be50e0360ea4d06e241294c6653fa9",
                            "total_amt_msat": "100000000"
                        },
                        "amp_record": null,
                        "custom_records": {
                        }
                    }
                ],
                "total_fees_msat": "0",
                "total_amt_msat": "100000000"
            },
            "attempt_time_ns": "1647643915645426918",
            "resolve_time_ns": "1647643916021317300",
            "failure": {
                "code": "INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS",
                "channel_update": null,
                "htlc_msat": "0",
                "onion_sha_256": null,
                "cltv_expiry": 0,
                "flags": 0,
                "failure_source_index": 1,
                "height": 2252938
            },
            "preimage": null
        }
    ],
    "payment_index": "123",
    "failure_reason": "FAILURE_REASON_INCORRECT_PAYMENT_DETAILS"
}
[lncli] FAILED
philipp@ubuntu:~/.local/share/Stakenet/stakenet-wallet-testnet/lnd/ltc$ lncli --network=testnet  --rpcserver=localhost:20001  --macaroonpath=./admin.macaroon --tlscertpath=./tls.cert payinvoice $INVOICE -f --json
{
    "payment_hash": "f7b465ffce94bfd9fa6a60710f71984bfba2c048df9f226ac0decfef5196445e",
    "value": "100000",
    "creation_date": "1647643929",
    "fee": "0",
    "payment_preimage": "34f2011215829800ee0cb9be4599f316fd19dae4b9b42bfeafacfa6dde0ba629",
    "value_sat": "100000",
    "value_msat": "100000000",
    "payment_request": "lntltc1m1p3r2r86pp5776xtl7wjjlan7n2vpcs7uvcf0a69szgm70jy6kqmm8775vkg30qdqqcqzjqxqrrsssp5af6kyj79xn7rgaktnxygewp2jw6mu58qxc82f5rwysfff3n9875s9qyyssqru6cw2xrruusvuyv33fedw75lx02vjwdlfp7rnmnux2c5w3pnx43chj7lepzd3w0u6tymp46y0snhv89hz3a7my5cnckvzvcd8t2tyspftnyzz",
    "status": "SUCCEEDED",
    "fee_sat": "0",
    "fee_msat": "0",
    "creation_time_ns": "1647643929609239014",
    "htlcs": [
        {
            "attempt_id": "20026",
            "status": "SUCCEEDED",
            "route": {
                "total_time_lock": 2253515,
                "total_fees": "0",
                "total_amt": "100000",
                "hops": [
                    {
                        "chan_id": "2464825793524531200",
                        "chan_capacity": "42888721",
                        "amt_to_forward": "100000",
                        "fee": "0",
                        "expiry": 2253515,
                        "amt_to_forward_msat": "100000000",
                        "fee_msat": "0",
                        "pub_key": "037b321ba397e96f2733c9bb49cfe447c8054306194f510a156630d45a598c1f67",
                        "tlv_payload": true,
                        "mpp_record": {
                            "payment_addr": "ea75624bc534fc3476cb99888cb82a93b5be50e0360ea4d06e241294c6653fa9",
                            "total_amt_msat": "100000000"
                        },
                        "amp_record": null,
                        "custom_records": {
                        }
                    }
                ],
                "total_fees_msat": "0",
                "total_amt_msat": "100000000"
            },
            "attempt_time_ns": "1647643929622230564",
            "resolve_time_ns": "1647643929889771889",
            "failure": null,
            "preimage": "34f2011215829800ee0cb9be4599f316fd19dae4b9b42bfeafacfa6dde0ba629"
        }
    ],
    "payment_index": "124",
    "failure_reason": "FAILURE_REASON_NONE"
}