diff --git a/lightningd/pay.c b/lightningd/pay.c index 7c4659896c..37768853da 100644 --- a/lightningd/pay.c +++ b/lightningd/pay.c @@ -844,9 +844,7 @@ found: return channel; } -/* Check if payment already in progress. Returns NULL if all good; - * sets old_payment to a previous attempt if there is one (otherwise - * NULL). */ +/* Check if payment already in progress. Returns NULL if all good */ static struct command_result *check_progress(struct lightningd *ld, struct command *cmd, const struct sha256 *rhash, @@ -854,14 +852,11 @@ static struct command_result *check_progress(struct lightningd *ld, struct amount_msat total_msat, u64 partid, u64 group, - const struct node_id *destination, - const struct wallet_payment **old_payment) + const struct node_id *destination) { bool have_complete = false; struct amount_msat msat_already_pending = AMOUNT_MSAT(0); - *old_payment = NULL; - /* Now, do we already have one or more payments? */ for (struct db_stmt *stmt = payments_by_hash(cmd->ld->wallet, rhash); stmt; @@ -974,8 +969,7 @@ static struct command_result *check_progress(struct lightningd *ld, break; case PAYMENT_FAILED: - if (payment->partid == partid) - *old_payment = payment; + break; } /* There is no way for us to add a payment with the * same (payment_hash, partid, groupid) tuple since @@ -1040,7 +1034,6 @@ send_payment_core(struct lightningd *ld, struct secret *path_secrets, const struct sha256 *local_invreq_id) { - const struct wallet_payment *old_payment; struct channel *channel; const u8 *failmsg; struct htlc_out *hout; @@ -1049,8 +1042,8 @@ send_payment_core(struct lightningd *ld, struct wallet_payment *payment; /* Reconcile this with previous attempts */ - ret = check_progress(ld, cmd, rhash, msat, total_msat, partid, group, destination, - &old_payment); + ret = check_progress(ld, cmd, rhash, msat, total_msat, partid, group, + destination); if (ret) return ret; @@ -1096,21 +1089,11 @@ send_payment_core(struct lightningd *ld, &channel->peer->id); return sendpay_fail( - cmd, old_payment, PAY_TRY_OTHER_ROUTE, NULL, fail, + cmd, NULL, PAY_TRY_OTHER_ROUTE, NULL, fail, sendpay_errmsg_fmt(tmpctx, PAY_TRY_OTHER_ROUTE, fail, "First peer not ready")); } - /* If we're retrying we delete outgoing HTLC otherwise it gets - * reported to onchaind as a possibility, and we end up in - * handle_missing_htlc_output -> onchain_failed_our_htlc -> - * payment_failed with no payment. - */ - if (old_payment) { - wallet_local_htlc_out_delete(ld->wallet, channel, rhash, - partid); - } - payment = wallet_add_payment(cmd, ld->wallet, time_now().ts.tv_sec, diff --git a/wallet/wallet.c b/wallet/wallet.c index 082b99c84a..d0677b2c49 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -3332,25 +3332,6 @@ struct htlc_stub *wallet_htlc_stubs(const tal_t *ctx, struct wallet *wallet, return stubs; } -void wallet_local_htlc_out_delete(struct wallet *wallet, - struct channel *chan, - const struct sha256 *payment_hash, - u64 partid) -{ - struct db_stmt *stmt; - - stmt = db_prepare_v2(wallet->db, SQL("DELETE FROM channel_htlcs" - " WHERE direction = ?" - " AND origin_htlc = ?" - " AND payment_hash = ?" - " AND partid = ?;")); - db_bind_int(stmt, DIRECTION_OUTGOING); - db_bind_int(stmt, 0); - db_bind_sha256(stmt, payment_hash); - db_bind_u64(stmt, partid); - db_exec_prepared_v2(take(stmt)); -} - /* FIXME: reorder! */ static struct wallet_payment *wallet_payment_new(const tal_t *ctx, diff --git a/wallet/wallet.h b/wallet/wallet.h index f404222cd8..b26de521bc 100644 --- a/wallet/wallet.h +++ b/wallet/wallet.h @@ -923,18 +923,6 @@ void wallet_payment_delete(struct wallet *wallet, const u64 *groupid, const u64 *partid, const enum payment_status *status); -/** - * wallet_local_htlc_out_delete - Remove a local outgoing failed HTLC - * - * This is not a generic HTLC cleanup! This is specifically for the - * narrow (and simple!) case of removing the HTLC associated with a - * local outgoing payment. - */ -void wallet_local_htlc_out_delete(struct wallet *wallet, - struct channel *chan, - const struct sha256 *payment_hash, - u64 partid); - /** * wallet_payment_by_hash - Retrieve a specific payment *