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

Function wallet_htlc_save_in

wallet/wallet.c:2389–2440  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2387}
2388
2389void wallet_htlc_save_in(struct wallet *wallet,
2390 const struct channel *chan, struct htlc_in *in)
2391{
2392 struct db_stmt *stmt;
2393
2394 stmt = db_prepare_v2(wallet->db,
2395 SQL("INSERT INTO channel_htlcs ("
2396 " channel_id,"
2397 " channel_htlc_id, "
2398 " direction,"
2399 " msatoshi,"
2400 " cltv_expiry,"
2401 " payment_hash, "
2402 " payment_key,"
2403 " hstate,"
2404 " shared_secret,"
2405 " routing_onion,"
2406 " received_time,"
2407 " min_commit_num, "
2408 " fail_immediate) VALUES "
2409 "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"));
2410
2411 db_bind_u64(stmt, 0, chan->dbid);
2412 db_bind_u64(stmt, 1, in->key.id);
2413 db_bind_int(stmt, 2, DIRECTION_INCOMING);
2414 db_bind_amount_msat(stmt, 3, &in->msat);
2415 db_bind_int(stmt, 4, in->cltv_expiry);
2416 db_bind_sha256(stmt, 5, &in->payment_hash);
2417
2418 if (in->preimage)
2419 db_bind_preimage(stmt, 6, in->preimage);
2420 else
2421 db_bind_null(stmt, 6);
2422 db_bind_int(stmt, 7, in->hstate);
2423
2424 if (!in->shared_secret)
2425 db_bind_null(stmt, 8);
2426 else
2427 db_bind_secret(stmt, 8, in->shared_secret);
2428
2429 db_bind_blob(stmt, 9, in->onion_routing_packet,
2430 sizeof(in->onion_routing_packet));
2431
2432 db_bind_timeabs(stmt, 10, in->received_time);
2433 db_bind_u64(stmt, 11, min_unsigned(chan->next_index[LOCAL]-1,
2434 chan->next_index[REMOTE]-1));
2435
2436 db_bind_int(stmt, 12, in->fail_immediate);
2437
2438 db_exec_prepared_v2(stmt);
2439 in->dbid = db_last_insert_id_v2(take(stmt));
2440}
2441
2442void wallet_htlc_save_out(struct wallet *wallet,
2443 const struct channel *chan,

Callers 2

test_htlc_crudFunction · 0.85
channel_added_their_htlcFunction · 0.85

Calls 11

db_bind_u64Function · 0.85
db_bind_intFunction · 0.85
db_bind_amount_msatFunction · 0.85
db_bind_sha256Function · 0.85
db_bind_preimageFunction · 0.85
db_bind_nullFunction · 0.85
db_bind_secretFunction · 0.85
db_bind_blobFunction · 0.85
db_bind_timeabsFunction · 0.85
db_exec_prepared_v2Function · 0.85
db_last_insert_id_v2Function · 0.85

Tested by 1

test_htlc_crudFunction · 0.68