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

Function wallet_htlc_save_in

wallet/wallet.c:3382–3442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3380}
3381
3382void wallet_htlc_save_in(struct wallet *wallet,
3383 const struct channel *chan, struct htlc_in *in)
3384{
3385 struct db_stmt *stmt;
3386
3387 stmt = db_prepare_v2(wallet->db,
3388 SQL("INSERT INTO channel_htlcs ("
3389 " id,"
3390 " channel_id,"
3391 " channel_htlc_id, "
3392 " direction,"
3393 " msatoshi,"
3394 " cltv_expiry,"
3395 " payment_hash, "
3396 " payment_key,"
3397 " hstate,"
3398 " shared_secret,"
3399 " routing_onion,"
3400 " received_time,"
3401 " min_commit_num, "
3402 " fail_immediate) VALUES "
3403 "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);"));
3404
3405 in->dbid = htlcs_index_created(wallet->ld,
3406 in->key.id,
3407 chan,
3408 &in->payment_hash,
3409 REMOTE,
3410 in->cltv_expiry,
3411 in->msat,
3412 in->hstate);
3413 db_bind_u64(stmt, in->dbid);
3414 db_bind_u64(stmt, chan->dbid);
3415 db_bind_u64(stmt, in->key.id);
3416 db_bind_int(stmt, DIRECTION_INCOMING);
3417 db_bind_amount_msat(stmt, in->msat);
3418 db_bind_int(stmt, in->cltv_expiry);
3419 db_bind_sha256(stmt, &in->payment_hash);
3420
3421 if (in->preimage)
3422 db_bind_preimage(stmt, in->preimage);
3423 else
3424 db_bind_null(stmt);
3425 db_bind_int(stmt, in->hstate);
3426
3427 if (!in->shared_secret)
3428 db_bind_null(stmt);
3429 else
3430 db_bind_secret(stmt, in->shared_secret);
3431
3432 db_bind_blob(stmt, in->onion_routing_packet,
3433 sizeof(in->onion_routing_packet));
3434
3435 db_bind_timeabs(stmt, in->received_time);
3436 db_bind_u64(stmt, min_unsigned(chan->next_index[LOCAL]-1,
3437 chan->next_index[REMOTE]-1));
3438
3439 db_bind_int(stmt, in->fail_immediate);

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
htlcs_index_createdFunction · 0.50

Tested by 1

test_htlc_crudFunction · 0.68