Reconstruct the parts of a Lightning payment attempt
A single invoice can produce several failed and successful outgoing part records. Counting each record as a complete order inflates a payment report.
Group low-level records by attempt
Set HASH to the invoice payment hash. Query named parameters with -k so the hash is not mistaken for a positional invoice string. Keep the part number within its group.
lightning-cli -k listsendpays payment_hash="$HASH" | jq '.payments | group_by(.groupid) | map(map({groupid, partid, status, amount_sent_msat}))'
Compare group outcome with the payment
Different groupid values distinguish attempts sharing the hash. A failed part can coexist with later successful parts. Reconcile the order from listpays, then use listsendpays to explain how it completed. Do not sum failed and successful attempts together as customer spend.
docs.corelightning.org listsendpays · docs.corelightning.org listpays