mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
delinvoice: fixes.
Error code is inverted (which makes sense: who returns 'true' on error?), and anyway there's a leak if we do error. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -279,7 +279,6 @@ static void json_delinvoice(struct command *cmd,
|
|||||||
struct json_result *response = new_json_result(cmd);
|
struct json_result *response = new_json_result(cmd);
|
||||||
const char *label;
|
const char *label;
|
||||||
struct wallet *wallet = cmd->ld->wallet;
|
struct wallet *wallet = cmd->ld->wallet;
|
||||||
bool error;
|
|
||||||
|
|
||||||
if (!json_get_params(buffer, params,
|
if (!json_get_params(buffer, params,
|
||||||
"label", &labeltok,
|
"label", &labeltok,
|
||||||
@@ -300,10 +299,9 @@ static void json_delinvoice(struct command *cmd,
|
|||||||
* otherwise the invoice will be freed. */
|
* otherwise the invoice will be freed. */
|
||||||
json_add_invoice(response, i, true);
|
json_add_invoice(response, i, true);
|
||||||
|
|
||||||
error = wallet_invoice_delete(wallet, i);
|
if (!wallet_invoice_delete(wallet, i)) {
|
||||||
|
log_broken(cmd->ld->log,
|
||||||
if (error) {
|
"Error attempting to remove invoice %"PRIu64,
|
||||||
log_broken(cmd->ld->log, "Error attempting to remove invoice %"PRIu64,
|
|
||||||
i->id);
|
i->id);
|
||||||
command_fail(cmd, "Database error");
|
command_fail(cmd, "Database error");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -230,8 +230,10 @@ bool invoices_delete(struct invoices *invoices,
|
|||||||
sqlite3_bind_int64(stmt, 1, invoice->id);
|
sqlite3_bind_int64(stmt, 1, invoice->id);
|
||||||
db_exec_prepared(invoices->db, stmt);
|
db_exec_prepared(invoices->db, stmt);
|
||||||
|
|
||||||
if (sqlite3_changes(invoices->db->sql) != 1)
|
if (sqlite3_changes(invoices->db->sql) != 1) {
|
||||||
|
tal_free(tmpctx);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* Delete from invoices object. */
|
/* Delete from invoices object. */
|
||||||
list_del_from(&invoices->invlist, &invoice->list);
|
list_del_from(&invoices->invlist, &invoice->list);
|
||||||
|
|||||||
Reference in New Issue
Block a user