funding_spent: fix leaks.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
8c4eecc089
commit
ed8baf5f88
|
@ -1374,6 +1374,7 @@ static enum watch_result funding_spent(struct peer *peer,
|
||||||
s64 keyindex;
|
s64 keyindex;
|
||||||
struct pubkey ourkey;
|
struct pubkey ourkey;
|
||||||
struct htlc_stub *stubs;
|
struct htlc_stub *stubs;
|
||||||
|
const tal_t *tmpctx = tal_tmpctx(peer);
|
||||||
|
|
||||||
peer_fail_permanent_str(peer, "Funding transaction spent");
|
peer_fail_permanent_str(peer, "Funding transaction spent");
|
||||||
|
|
||||||
|
@ -1389,12 +1390,14 @@ static enum watch_result funding_spent(struct peer *peer,
|
||||||
if (!peer->owner) {
|
if (!peer->owner) {
|
||||||
log_broken(peer->log, "Could not subdaemon onchain: %s",
|
log_broken(peer->log, "Could not subdaemon onchain: %s",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
|
tal_free(tmpctx);
|
||||||
return KEEP_WATCHING;
|
return KEEP_WATCHING;
|
||||||
}
|
}
|
||||||
|
|
||||||
stubs = wallet_htlc_stubs(peer, peer->ld->wallet, peer->channel);
|
stubs = wallet_htlc_stubs(tmpctx, peer->ld->wallet, peer->channel);
|
||||||
if (!stubs) {
|
if (!stubs) {
|
||||||
log_broken(peer->log, "Could not load htlc_stubs");
|
log_broken(peer->log, "Could not load htlc_stubs");
|
||||||
|
tal_free(tmpctx);
|
||||||
return KEEP_WATCHING;
|
return KEEP_WATCHING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1406,14 +1409,16 @@ static enum watch_result funding_spent(struct peer *peer,
|
||||||
keyindex = wallet_get_newindex(peer->ld);
|
keyindex = wallet_get_newindex(peer->ld);
|
||||||
if (keyindex < 0) {
|
if (keyindex < 0) {
|
||||||
log_broken(peer->log, "Could not get keyindex");
|
log_broken(peer->log, "Could not get keyindex");
|
||||||
|
tal_free(tmpctx);
|
||||||
return KEEP_WATCHING;
|
return KEEP_WATCHING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scriptpubkey = p2wpkh_for_keyidx(peer, peer->ld, keyindex);
|
scriptpubkey = p2wpkh_for_keyidx(tmpctx, peer->ld, keyindex);
|
||||||
if (!scriptpubkey) {
|
if (!scriptpubkey) {
|
||||||
peer_internal_error(peer,
|
peer_internal_error(peer,
|
||||||
"Can't get shutdown script %"PRIu64,
|
"Can't get shutdown script %"PRIu64,
|
||||||
keyindex);
|
keyindex);
|
||||||
|
tal_free(tmpctx);
|
||||||
return DELETE_WATCH;
|
return DELETE_WATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1421,6 +1426,7 @@ static enum watch_result funding_spent(struct peer *peer,
|
||||||
peer_internal_error(peer,
|
peer_internal_error(peer,
|
||||||
"Can't get shutdown key %"PRIu64,
|
"Can't get shutdown key %"PRIu64,
|
||||||
keyindex);
|
keyindex);
|
||||||
|
tal_free(tmpctx);
|
||||||
return DELETE_WATCH;
|
return DELETE_WATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1470,6 +1476,7 @@ static enum watch_result funding_spent(struct peer *peer,
|
||||||
|
|
||||||
watch_tx_and_outputs(peer, tx);
|
watch_tx_and_outputs(peer, tx);
|
||||||
|
|
||||||
|
tal_free(tmpctx);
|
||||||
/* We keep watching until peer finally deleted, for reorgs. */
|
/* We keep watching until peer finally deleted, for reorgs. */
|
||||||
return KEEP_WATCHING;
|
return KEEP_WATCHING;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1160,7 +1160,7 @@ bool wallet_invoice_remove(struct wallet *wallet, struct invoice *inv)
|
||||||
return sqlite3_changes(wallet->db->sql) == 1;
|
return sqlite3_changes(wallet->db->sql) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct htlc_stub *wallet_htlc_stubs(tal_t *ctx, struct wallet *wallet,
|
struct htlc_stub *wallet_htlc_stubs(const tal_t *ctx, struct wallet *wallet,
|
||||||
struct wallet_channel *chan)
|
struct wallet_channel *chan)
|
||||||
{
|
{
|
||||||
struct htlc_stub *stubs;
|
struct htlc_stub *stubs;
|
||||||
|
|
|
@ -374,7 +374,7 @@ bool wallet_invoice_remove(struct wallet *wallet, struct invoice *inv);
|
||||||
* @wallet: Wallet to load from
|
* @wallet: Wallet to load from
|
||||||
* @chan: Channel to fetch stubs for
|
* @chan: Channel to fetch stubs for
|
||||||
*/
|
*/
|
||||||
struct htlc_stub *wallet_htlc_stubs(tal_t *ctx, struct wallet *wallet,
|
struct htlc_stub *wallet_htlc_stubs(const tal_t *ctx, struct wallet *wallet,
|
||||||
struct wallet_channel *chan);
|
struct wallet_channel *chan);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue