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

Function wallet_stmt2payment

wallet/wallet.c:3191–3285  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3189}
3190
3191static struct wallet_payment *wallet_stmt2payment(const tal_t *ctx,
3192 struct db_stmt *stmt)
3193{
3194 struct wallet_payment *payment = tal(ctx, struct wallet_payment);
3195 payment->id = db_col_u64(stmt, "id");
3196 payment->status = db_col_int(stmt, "status");
3197
3198 if (!db_col_is_null(stmt, "destination")) {
3199 payment->destination = tal(payment, struct node_id);
3200 db_col_node_id(stmt, "destination", payment->destination);
3201 } else {
3202 payment->destination = NULL;
3203 }
3204
3205 db_col_amount_msat(stmt, "msatoshi", &payment->msatoshi);
3206 db_col_sha256(stmt, "payment_hash", &payment->payment_hash);
3207
3208 payment->timestamp = db_col_int(stmt, "timestamp");
3209 if (!db_col_is_null(stmt, "payment_preimage")) {
3210 payment->payment_preimage = tal(payment, struct preimage);
3211 db_col_preimage(stmt, "payment_preimage",
3212 payment->payment_preimage);
3213 } else
3214 payment->payment_preimage = NULL;
3215
3216 /* We either used `sendpay` or `sendonion` with the `shared_secrets`
3217 * argument. */
3218 if (!db_col_is_null(stmt, "path_secrets"))
3219 payment->path_secrets
3220 = db_col_secret_arr(payment, stmt, "path_secrets");
3221 else
3222 payment->path_secrets = NULL;
3223
3224 /* Either none, or both are set */
3225 assert(db_col_is_null(stmt, "route_nodes")
3226 == db_col_is_null(stmt, "route_channels"));
3227 if (!db_col_is_null(stmt, "route_nodes")) {
3228 payment->route_nodes
3229 = db_col_node_id_arr(payment, stmt, "route_nodes");
3230 payment->route_channels =
3231 db_col_short_channel_id_arr(payment, stmt, "route_channels");
3232 } else {
3233 payment->route_nodes = NULL;
3234 payment->route_channels = NULL;
3235 }
3236
3237 db_col_amount_msat(stmt, "msatoshi_sent", &payment->msatoshi_sent);
3238
3239 if (!db_col_is_null(stmt, "description"))
3240 payment->label = db_col_strdup(payment, stmt, "description");
3241 else
3242 payment->label = NULL;
3243
3244 if (!db_col_is_null(stmt, "paydescription"))
3245 payment->description = db_col_strdup(payment, stmt, "paydescription");
3246 else
3247 payment->description = NULL;
3248

Callers 3

wallet_payment_by_hashFunction · 0.85
wallet_payment_listFunction · 0.85
wallet_payments_by_offerFunction · 0.85

Calls 11

db_col_u64Function · 0.85
db_col_intFunction · 0.85
db_col_is_nullFunction · 0.85
db_col_node_idFunction · 0.85
db_col_amount_msatFunction · 0.85
db_col_sha256Function · 0.85
db_col_preimageFunction · 0.85
db_col_secret_arrFunction · 0.85
db_col_node_id_arrFunction · 0.85
db_col_strdupFunction · 0.85

Tested by

no test coverage detected