invoice: print duplicate r value even if we choose it.

This shouldn't happen, but if our RNG is busted and get a duplicate,
r would be NULL.

(scan-build found this)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2016-11-01 21:34:58 +10:30
parent 642a2f2d4e
commit 1d57fa60b8

View File

@ -2,6 +2,7 @@
#include "invoice.h"
#include "jsonrpc.h"
#include "lightningd.h"
#include "utils.h"
#include <ccan/str/hex/hex.h>
#include <ccan/structeq/structeq.h>
#include <ccan/tal/str/str.h>
@ -130,8 +131,9 @@ static void json_invoice(struct command *cmd,
sha256(&invoice->rhash, invoice->r.r, sizeof(invoice->r.r));
if (find_unpaid(cmd->dstate, &invoice->rhash)
|| find_paid(cmd->dstate, &invoice->rhash)) {
command_fail(cmd, "Duplicate r value '%.*s'",
r->end - r->start, buffer + r->start);
command_fail(cmd, "Duplicate r value '%s'",
tal_hexstr(cmd, &invoice->rhash,
sizeof(invoice->rhash)));
return;
}