Browse Source

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>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
2443d45b47
  1. 8
      lightningd/invoice.c
  2. 4
      wallet/invoices.c

8
lightningd/invoice.c

@ -279,7 +279,6 @@ static void json_delinvoice(struct command *cmd,
struct json_result *response = new_json_result(cmd);
const char *label;
struct wallet *wallet = cmd->ld->wallet;
bool error;
if (!json_get_params(buffer, params,
"label", &labeltok,
@ -300,10 +299,9 @@ static void json_delinvoice(struct command *cmd,
* otherwise the invoice will be freed. */
json_add_invoice(response, i, true);
error = wallet_invoice_delete(wallet, i);
if (error) {
log_broken(cmd->ld->log, "Error attempting to remove invoice %"PRIu64,
if (!wallet_invoice_delete(wallet, i)) {
log_broken(cmd->ld->log,
"Error attempting to remove invoice %"PRIu64,
i->id);
command_fail(cmd, "Database error");
return;

4
wallet/invoices.c

@ -230,8 +230,10 @@ bool invoices_delete(struct invoices *invoices,
sqlite3_bind_int64(stmt, 1, invoice->id);
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;
}
/* Delete from invoices object. */
list_del_from(&invoices->invlist, &invoice->list);

Loading…
Cancel
Save