invoice: remove strange code.

This is called when we load from database: clearly our tests aren't thorough
enough because we were allocating and initializing `r` in an unused structure.

invs is also the owner already; functions which steal are a bit surprising
to callers, so we either document them, or just don't do it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2017-12-15 20:59:18 +10:30 committed by Christian Decker
parent adf8740b96
commit 1356913143

View File

@ -60,9 +60,7 @@ static struct invoice *find_invoice_by_label(const struct invoices *invs,
void invoice_add(struct invoices *invs,
struct invoice *inv)
{
tal_steal(invs, inv);
struct invoice *invoice = tal(invs, struct invoice);
sha256(&invoice->rhash, invoice->r.r, sizeof(invoice->r.r));
sha256(&inv->rhash, inv->r.r, sizeof(inv->r.r));
list_add(&invs->invlist, &inv->list);
}