mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
wallet: properly handle case where peer has no address when saving channel.
In practice, it currently always does, so we've never hit an error. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
81ca1db347
commit
65c09c895d
@ -737,9 +737,12 @@ void wallet_channel_save(struct wallet *w, struct wallet_channel *chan)
|
||||
/* Need to store the peer first */
|
||||
stmt = db_prepare(w->db, "INSERT INTO peers (node_id, address) VALUES (?, ?);");
|
||||
sqlite3_bind_pubkey(stmt, 1, &chan->peer->id);
|
||||
sqlite3_bind_text(stmt, 2,
|
||||
type_to_string(tmpctx, struct wireaddr, &chan->peer->addr),
|
||||
-1, SQLITE_TRANSIENT);
|
||||
if (chan->peer->addr.type == ADDR_TYPE_PADDING)
|
||||
sqlite3_bind_null(stmt, 2);
|
||||
else
|
||||
sqlite3_bind_text(stmt, 2,
|
||||
type_to_string(tmpctx, struct wireaddr, &chan->peer->addr),
|
||||
-1, SQLITE_TRANSIENT);
|
||||
db_exec_prepared(w->db, stmt);
|
||||
p->dbid = sqlite3_last_insert_rowid(w->db->sql);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user