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

Function wallet_stmt2htlc_in

wallet/wallet.c:3603–3678  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3601}
3602
3603static bool wallet_stmt2htlc_in(struct channel *channel,
3604 struct db_stmt *stmt, struct htlc_in *in)
3605{
3606 bool ok = true;
3607 in->dbid = db_col_u64(stmt, "id");
3608 in->key.id = db_col_u64(stmt, "channel_htlc_id");
3609 in->key.channel = channel;
3610 in->msat = db_col_amount_msat(stmt, "msatoshi");
3611 in->cltv_expiry = db_col_int(stmt, "cltv_expiry");
3612 in->hstate = db_col_int(stmt, "hstate");
3613 in->status = NULL;
3614 /* FIXME: save path_key in db !*/
3615 in->path_key = NULL;
3616 in->payload = NULL;
3617 /* FIXME: save extra_tlvs in db! But: check the implications that a
3618 * spammy peer - giving us big extra tlvs - would have on our database.
3619 * Right now, not saving the extra tlvs in the db seems OK as it is
3620 * only relevant in the case that I forward but restart in the middle
3621 * of a payment.
3622 */
3623 in->extra_tlvs = NULL;
3624
3625 db_col_sha256(stmt, "payment_hash", &in->payment_hash);
3626
3627 in->preimage = db_col_optional(in, stmt, "payment_key", preimage);
3628
3629 assert(db_col_bytes(stmt, "routing_onion")
3630 == sizeof(in->onion_routing_packet));
3631 memcpy(&in->onion_routing_packet, db_col_blob(stmt, "routing_onion"),
3632 sizeof(in->onion_routing_packet));
3633
3634 if (db_col_is_null(stmt, "failuremsg"))
3635 in->failonion = NULL;
3636 else
3637 in->failonion = db_col_onionreply(in, stmt, "failuremsg");
3638 in->badonion = db_col_int(stmt, "malformed_onion");
3639 in->shared_secret = db_col_optional(in, stmt, "shared_secret", secret);
3640#ifdef COMPAT_V062
3641 if (in->shared_secret
3642 && memeqzero(in->shared_secret, sizeof(*in->shared_secret)))
3643 in->shared_secret = tal_free(in->shared_secret);
3644#endif
3645
3646#ifdef COMPAT_V072
3647 if (db_col_is_null(stmt, "received_time")) {
3648 in->received_time.ts.tv_sec = 0;
3649 in->received_time.ts.tv_nsec = 0;
3650 } else
3651#endif /* COMPAT_V072 */
3652 in->received_time = db_col_timeabs(stmt, "received_time");
3653
3654#ifdef COMPAT_V080
3655 /* This field is now reserved for badonion codes: the rest should
3656 * use the failonion field. */
3657 if (in->badonion && !(in->badonion & BADONION)) {
3658 log_broken(channel->log,
3659 "Replacing incoming HTLC %"PRIu64" error "
3660 "%s with WIRE_TEMPORARY_NODE_FAILURE",

Callers 1

Calls 12

db_col_u64Function · 0.85
db_col_amount_msatFunction · 0.85
db_col_intFunction · 0.85
db_col_sha256Function · 0.85
db_col_bytesFunction · 0.85
db_col_blobFunction · 0.85
db_col_is_nullFunction · 0.85
db_col_onionreplyFunction · 0.85
memeqzeroFunction · 0.85
tal_freeFunction · 0.85
db_col_timeabsFunction · 0.85
create_onionreplyFunction · 0.85

Tested by

no test coverage detected