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

Function wallet_htlc_save_out

wallet/wallet.c:3462–3536  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3460}
3461
3462void wallet_htlc_save_out(struct wallet *wallet,
3463 const struct channel *chan,
3464 struct htlc_out *out)
3465{
3466 struct db_stmt *stmt;
3467
3468 /* We absolutely need the incoming HTLC to be persisted before
3469 * we can persist it's dependent */
3470 assert(out->in == NULL || out->in->dbid != 0);
3471
3472 stmt = db_prepare_v2(
3473 wallet->db,
3474 SQL("INSERT INTO channel_htlcs ("
3475 " id,"
3476 " channel_id,"
3477 " channel_htlc_id,"
3478 " direction,"
3479 " origin_htlc,"
3480 " msatoshi,"
3481 " cltv_expiry,"
3482 " payment_hash,"
3483 " payment_key,"
3484 " hstate,"
3485 " routing_onion,"
3486 " malformed_onion,"
3487 " partid,"
3488 " groupid,"
3489 " fees_msat,"
3490 " min_commit_num"
3491 ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?, ?, ?, ?);"));
3492
3493 out->dbid = htlcs_index_created(wallet->ld,
3494 out->key.id,
3495 chan,
3496 &out->payment_hash,
3497 LOCAL,
3498 out->cltv_expiry,
3499 out->msat,
3500 out->hstate);
3501 db_bind_u64(stmt, out->dbid);
3502 db_bind_u64(stmt, chan->dbid);
3503 db_bind_u64(stmt, out->key.id);
3504 db_bind_int(stmt, DIRECTION_OUTGOING);
3505 if (out->in)
3506 db_bind_u64(stmt, out->in->dbid);
3507 else
3508 db_bind_null(stmt);
3509 db_bind_amount_msat(stmt, out->msat);
3510 db_bind_int(stmt, out->cltv_expiry);
3511 db_bind_sha256(stmt, &out->payment_hash);
3512
3513 if (out->preimage)
3514 db_bind_preimage(stmt, out->preimage);
3515 else
3516 db_bind_null(stmt);
3517 db_bind_int(stmt, out->hstate);
3518
3519 db_bind_blob(stmt, out->onion_routing_packet,

Callers 2

test_htlc_crudFunction · 0.85
update_out_htlcFunction · 0.85

Calls 10

db_bind_u64Function · 0.85
db_bind_intFunction · 0.85
db_bind_nullFunction · 0.85
db_bind_amount_msatFunction · 0.85
db_bind_sha256Function · 0.85
db_bind_preimageFunction · 0.85
db_bind_blobFunction · 0.85
min_u64Function · 0.85
db_exec_prepared_v2Function · 0.85
htlcs_index_createdFunction · 0.50

Tested by 1

test_htlc_crudFunction · 0.68