MCPcopy Create free account
hub / github.com/ElementsProject/lightning / wallet_peer_load

Function wallet_peer_load

wallet/wallet.c:815–855  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

813}
814
815static struct peer *wallet_peer_load(struct wallet *w, const u64 dbid)
816{
817 const char *addrstr;
818 struct peer *peer = NULL;
819 struct node_id id;
820 struct wireaddr_internal addr;
821 struct db_stmt *stmt;
822
823 stmt = db_prepare_v2(
824 w->db, SQL("SELECT id, node_id, address FROM peers WHERE id=?;"));
825 db_bind_u64(stmt, 0, dbid);
826 db_query_prepared(stmt);
827
828 if (!db_step(stmt))
829 goto done;
830
831 if (db_col_is_null(stmt, "node_id")) {
832 db_col_ignore(stmt, "address");
833 db_col_ignore(stmt, "id");
834 goto done;
835 }
836
837 db_col_node_id(stmt, "node_id", &id);
838
839 /* This can happen for peers last seen on Torv2! */
840 addrstr = db_col_strdup(tmpctx, stmt, "address");
841 if (!parse_wireaddr_internal(addrstr, &addr, chainparams_get_ln_port(chainparams),
842 false, false, true, NULL)) {
843 log_unusual(w->log, "Unparsable peer address %s: replacing",
844 addrstr);
845 parse_wireaddr_internal("127.0.0.1:1", &addr, chainparams_get_ln_port(chainparams),
846 false, false, true, NULL);
847 }
848
849 /* FIXME: save incoming in db! */
850 peer = new_peer(w->ld, db_col_u64(stmt, "id"), &id, &addr, false);
851
852done:
853 tal_free(stmt);
854 return peer;
855}
856
857static struct bitcoin_signature *
858wallet_htlc_sigs_load(const tal_t *ctx, struct wallet *w, u64 channelid,

Callers 1

wallet_stmt2channelFunction · 0.85

Calls 12

db_bind_u64Function · 0.85
db_query_preparedFunction · 0.85
db_stepFunction · 0.85
db_col_is_nullFunction · 0.85
db_col_ignoreFunction · 0.85
db_col_node_idFunction · 0.85
db_col_strdupFunction · 0.85
parse_wireaddr_internalFunction · 0.85
db_col_u64Function · 0.85
tal_freeFunction · 0.85
chainparams_get_ln_portFunction · 0.50
new_peerFunction · 0.50

Tested by

no test coverage detected