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

Function wallet_payment_by_hash

wallet/wallet.c:3287–3334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3285}
3286
3287struct wallet_payment *
3288wallet_payment_by_hash(const tal_t *ctx, struct wallet *wallet,
3289 const struct sha256 *payment_hash,
3290 u64 partid, u64 groupid)
3291{
3292 struct db_stmt *stmt;
3293 struct wallet_payment *payment;
3294
3295 /* Present the illusion that it's in the db... */
3296 payment = find_unstored_payment(wallet, payment_hash, partid);
3297 if (payment)
3298 return payment;
3299
3300 stmt = db_prepare_v2(wallet->db, SQL("SELECT"
3301 " id"
3302 ", status"
3303 ", destination"
3304 ", msatoshi"
3305 ", payment_hash"
3306 ", timestamp"
3307 ", payment_preimage"
3308 ", path_secrets"
3309 ", route_nodes"
3310 ", route_channels"
3311 ", msatoshi_sent"
3312 ", description"
3313 ", bolt11"
3314 ", paydescription"
3315 ", failonionreply"
3316 ", total_msat"
3317 ", partid"
3318 ", local_offer_id"
3319 ", groupid"
3320 ", completed_at"
3321 " FROM payments"
3322 " WHERE payment_hash = ?"
3323 " AND partid = ? AND groupid=?"));
3324
3325 db_bind_sha256(stmt, 0, payment_hash);
3326 db_bind_u64(stmt, 1, partid);
3327 db_bind_u64(stmt, 2, groupid);
3328 db_query_prepared(stmt);
3329 if (db_step(stmt)) {
3330 payment = wallet_stmt2payment(ctx, stmt);
3331 }
3332 tal_free(stmt);
3333 return payment;
3334}
3335
3336void wallet_payment_set_status(struct wallet *wallet,
3337 const struct sha256 *payment_hash,

Callers 5

test_payment_crudFunction · 0.85
payment_succeededFunction · 0.85
payment_failedFunction · 0.85
wait_paymentFunction · 0.85
update_out_htlcFunction · 0.85

Calls 7

find_unstored_paymentFunction · 0.85
db_bind_sha256Function · 0.85
db_bind_u64Function · 0.85
db_query_preparedFunction · 0.85
db_stepFunction · 0.85
wallet_stmt2paymentFunction · 0.85
tal_freeFunction · 0.85

Tested by 1

test_payment_crudFunction · 0.68