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

Function wallet_payments_by_offer

wallet/wallet.c:3612–3664  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3610}
3611
3612const struct wallet_payment **
3613wallet_payments_by_offer(const tal_t *ctx,
3614 struct wallet *wallet,
3615 const struct sha256 *local_offer_id)
3616{
3617 const struct wallet_payment **payments;
3618 struct db_stmt *stmt;
3619 struct wallet_payment *p;
3620 size_t i;
3621
3622 payments = tal_arr(ctx, const struct wallet_payment *, 0);
3623 stmt = db_prepare_v2(wallet->db, SQL("SELECT"
3624 " id"
3625 ", status"
3626 ", destination"
3627 ", msatoshi"
3628 ", payment_hash"
3629 ", timestamp"
3630 ", payment_preimage"
3631 ", path_secrets"
3632 ", route_nodes"
3633 ", route_channels"
3634 ", msatoshi_sent"
3635 ", description"
3636 ", bolt11"
3637 ", paydescription"
3638 ", failonionreply"
3639 ", total_msat"
3640 ", partid"
3641 ", local_offer_id"
3642 ", groupid"
3643 ", completed_at"
3644 " FROM payments"
3645 " WHERE local_offer_id = ?;"));
3646 db_bind_sha256(stmt, 0, local_offer_id);
3647 db_query_prepared(stmt);
3648
3649 for (i = 0; db_step(stmt); i++) {
3650 tal_resize(&payments, i+1);
3651 payments[i] = wallet_stmt2payment(payments, stmt);
3652 }
3653 tal_free(stmt);
3654
3655 /* Now attach payments not yet in db. */
3656 list_for_each(&wallet->unstored_payments, p, list) {
3657 if (!p->local_offer_id || !sha256_eq(p->local_offer_id, local_offer_id))
3658 continue;
3659 tal_resize(&payments, i+1);
3660 payments[i++] = p;
3661 }
3662
3663 return payments;
3664}
3665
3666void wallet_htlc_sigs_save(struct wallet *w, u64 channel_id,
3667 const struct bitcoin_signature *htlc_sigs)

Callers 1

check_offer_usageFunction · 0.85

Calls 5

db_bind_sha256Function · 0.85
db_query_preparedFunction · 0.85
db_stepFunction · 0.85
wallet_stmt2paymentFunction · 0.85
tal_freeFunction · 0.85

Tested by

no test coverage detected