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

Function wallet_htlc_sigs_load

wallet/wallet.c:1332–1366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1330}
1331
1332static struct bitcoin_signature *
1333wallet_htlc_sigs_load(const tal_t *ctx, struct wallet *w, u64 channelid,
1334 bool option_anchors)
1335{
1336 struct db_stmt *stmt;
1337 struct bitcoin_signature *htlc_sigs = tal_arr(ctx, struct bitcoin_signature, 0);
1338
1339 stmt = db_prepare_v2(
1340 w->db, SQL("SELECT signature FROM htlc_sigs WHERE channelid = ?"
1341 " AND inflight_tx_id is NULL"));
1342 db_bind_u64(stmt, channelid);
1343 db_query_prepared(stmt);
1344
1345 while (db_step(stmt)) {
1346 struct bitcoin_signature sig;
1347 db_col_signature(stmt, "signature", &sig.s);
1348 /* BOLT #3:
1349 * ## HTLC-Timeout and HTLC-Success Transactions
1350 *...
1351 * * if `option_anchors` applies to this commitment
1352 * transaction, `SIGHASH_SINGLE|SIGHASH_ANYONECANPAY` is
1353 * used as described in [BOLT #5]
1354 */
1355 if (option_anchors)
1356 sig.sighash_type = SIGHASH_SINGLE|SIGHASH_ANYONECANPAY;
1357 else
1358 sig.sighash_type = SIGHASH_ALL;
1359 tal_arr_expand(&htlc_sigs, sig);
1360 }
1361 tal_free(stmt);
1362
1363 log_debug(w->log, "Loaded %zu HTLC signatures from DB",
1364 tal_count(htlc_sigs));
1365 return htlc_sigs;
1366}
1367
1368bool wallet_remote_ann_sigs_load(struct wallet *w,
1369 const struct channel *chan,

Callers 1

wallet_stmt2channelFunction · 0.85

Calls 5

db_bind_u64Function · 0.85
db_query_preparedFunction · 0.85
db_stepFunction · 0.85
db_col_signatureFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected