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:
Rusty Russell
2018-01-18 14:25:43 +10:30
parent c8c68cfb7c
commit 2443d45b47
2 changed files with 6 additions and 6 deletions

View File

@@ -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;