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

Function wallet_remote_ann_sigs_load

wallet/wallet.c:892–936  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

890}
891
892bool wallet_remote_ann_sigs_load(const tal_t *ctx, struct wallet *w, u64 id,
893 secp256k1_ecdsa_signature **remote_ann_node_sig,
894 secp256k1_ecdsa_signature **remote_ann_bitcoin_sig)
895{
896 struct db_stmt *stmt;
897 bool res;
898 stmt = db_prepare_v2(
899 w->db, SQL("SELECT remote_ann_node_sig, remote_ann_bitcoin_sig"
900 " FROM channels WHERE id = ?"));
901 db_bind_u64(stmt, 0, id);
902 db_query_prepared(stmt);
903
904 res = db_step(stmt);
905
906 /* This must succeed, since we know the channel exists */
907 assert(res);
908
909 /* if only one sig exists, forget the sig and hope peer send new ones*/
910 if (db_col_is_null(stmt, "remote_ann_node_sig")
911 || db_col_is_null(stmt, "remote_ann_bitcoin_sig")) {
912 db_col_ignore(stmt, "remote_ann_bitcoin_sig");
913 *remote_ann_node_sig = *remote_ann_bitcoin_sig = NULL;
914 tal_free(stmt);
915 return true;
916 }
917
918 /* the case left over is both sigs exist */
919 *remote_ann_node_sig = tal(ctx, secp256k1_ecdsa_signature);
920 *remote_ann_bitcoin_sig = tal(ctx, secp256k1_ecdsa_signature);
921
922 if (!db_col_signature(stmt, "remote_ann_node_sig", *remote_ann_node_sig))
923 goto fail;
924
925 if (!db_col_signature(stmt, "remote_ann_bitcoin_sig", *remote_ann_bitcoin_sig))
926 goto fail;
927
928 tal_free(stmt);
929 return true;
930
931fail:
932 *remote_ann_node_sig = tal_free(*remote_ann_node_sig);
933 *remote_ann_bitcoin_sig = tal_free(*remote_ann_bitcoin_sig);
934 tal_free(stmt);
935 return false;
936}
937
938static struct fee_states *wallet_channel_fee_states_load(struct wallet *w,
939 const u64 id,

Callers 2

test_channel_crudFunction · 0.85
peer_start_channeldFunction · 0.85

Calls 7

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
tal_freeFunction · 0.85
db_col_signatureFunction · 0.85

Tested by 1

test_channel_crudFunction · 0.68