Browse Source

pay: Move setting failed status on payment to after we get payment details.

ppa-0.6.1
ZmnSCPxj 7 years ago
committed by Rusty Russell
parent
commit
b2d8efcf25
  1. 11
      lightningd/pay.c

11
lightningd/pay.c

@ -65,11 +65,10 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout,
struct secret *path_secrets; struct secret *path_secrets;
const tal_t *tmpctx = tal_tmpctx(ld); const tal_t *tmpctx = tal_tmpctx(ld);
wallet_payment_set_status(ld->wallet, &hout->payment_hash,
PAYMENT_FAILED, NULL);
/* This gives more details than a generic failure message */ /* This gives more details than a generic failure message */
if (localfail) { if (localfail) {
wallet_payment_set_status(ld->wallet, &hout->payment_hash,
PAYMENT_FAILED, NULL);
json_pay_failed(hout->cmd, NULL, hout->failcode, localfail); json_pay_failed(hout->cmd, NULL, hout->failcode, localfail);
tal_free(tmpctx); tal_free(tmpctx);
return; return;
@ -96,6 +95,12 @@ void payment_failed(struct lightningd *ld, const struct htlc_out *hout,
failcode, onion_type_name(failcode)); failcode, onion_type_name(failcode));
} }
/* This may invalidated the payment structure returned, so
* access to payment object should not be done after the
* below call. */
wallet_payment_set_status(ld->wallet, &hout->payment_hash,
PAYMENT_FAILED, NULL);
/* FIXME: save ids we can turn reply->origin_index into sender. */ /* FIXME: save ids we can turn reply->origin_index into sender. */
/* FIXME: check for routing failure / perm fail. */ /* FIXME: check for routing failure / perm fail. */

Loading…
Cancel
Save