mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-15 11:59:16 +01:00
paycore: Default groupid
to increment from last one
This re-establishes the prior behavior where a `sendpay` or `sendonion` that'd match a prior payment would cause the prior payment to be deleted. While we no longer delete prior attempts we now avoid a primary key collision by incrementing once. This helps us not having to touch all existing tests, and likely avoids breaking other users too.
This commit is contained in:
parent
ec9040577e
commit
818a4d14cb
1 changed files with 16 additions and 2 deletions
|
@ -1284,10 +1284,18 @@ static struct command_result *json_sendonion(struct command *cmd,
|
|||
p_opt_def("msatoshi", param_msat, &msat, AMOUNT_MSAT(0)),
|
||||
p_opt("destination", param_node_id, &destination),
|
||||
p_opt("localofferid", param_sha256, &local_offer_id),
|
||||
p_opt_def("groupid", param_u64, &group, 0),
|
||||
p_opt("groupid", param_u64, &group),
|
||||
NULL))
|
||||
return command_param_failed();
|
||||
|
||||
/* If groupid was not provided default to incrementing from the previous one. */
|
||||
if (group == NULL) {
|
||||
group = tal(tmpctx, u64);
|
||||
*group =
|
||||
wallet_payment_get_groupid(cmd->ld->wallet, payment_hash) +
|
||||
1;
|
||||
}
|
||||
|
||||
packet = parse_onionpacket(cmd, onion, tal_bytelen(onion), &failcode);
|
||||
|
||||
if (!packet)
|
||||
|
@ -1437,7 +1445,7 @@ static struct command_result *json_sendpay(struct command *cmd,
|
|||
p_opt("payment_secret", param_secret, &payment_secret),
|
||||
p_opt_def("partid", param_u64, &partid, 0),
|
||||
p_opt("localofferid", param_sha256, &local_offer_id),
|
||||
p_opt_def("groupid", param_u64, &group, 0),
|
||||
p_opt("groupid", param_u64, &group),
|
||||
NULL))
|
||||
return command_param_failed();
|
||||
|
||||
|
@ -1447,6 +1455,12 @@ static struct command_result *json_sendpay(struct command *cmd,
|
|||
|
||||
const struct amount_msat final_amount = route[tal_count(route)-1].amount;
|
||||
|
||||
/* If groupid was not provided default to incrementing from the previous one. */
|
||||
if (group == NULL) {
|
||||
group = tal(tmpctx, u64);
|
||||
*group = wallet_payment_get_groupid(cmd->ld->wallet, rhash) + 1;
|
||||
}
|
||||
|
||||
if (msat && !*partid && !amount_msat_eq(*msat, final_amount))
|
||||
return command_fail(cmd, JSONRPC2_INVALID_PARAMS,
|
||||
"Do not specify msatoshi (%s) without"
|
||||
|
|
Loading…
Add table
Reference in a new issue