Browse Source

wallet: Store payment description in the database

ppa-0.6.1
Christian Decker 7 years ago
committed by Rusty Russell
parent
commit
60e0eec967
  1. 1
      lightningd/pay.c
  2. 20
      wallet/wallet.c

1
lightningd/pay.c

@ -792,6 +792,7 @@ send_payment(const tal_t *ctx,
payment->path_secrets = tal_steal(payment, path_secrets); payment->path_secrets = tal_steal(payment, path_secrets);
payment->route_nodes = tal_steal(payment, ids); payment->route_nodes = tal_steal(payment, ids);
payment->route_channels = tal_steal(payment, channels); payment->route_channels = tal_steal(payment, channels);
payment->description = NULL;
/* We write this into db when HTLC is actually sent. */ /* We write this into db when HTLC is actually sent. */
wallet_payment_setup(ld->wallet, payment); wallet_payment_setup(ld->wallet, payment);

20
wallet/wallet.c

@ -1593,8 +1593,9 @@ void wallet_payment_store(struct wallet *wallet,
" path_secrets," " path_secrets,"
" route_nodes," " route_nodes,"
" route_channels," " route_channels,"
" msatoshi_sent" " msatoshi_sent,"
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);"); " description"
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
sqlite3_bind_int(stmt, 1, payment->status); sqlite3_bind_int(stmt, 1, payment->status);
sqlite3_bind_sha256(stmt, 2, &payment->payment_hash); sqlite3_bind_sha256(stmt, 2, &payment->payment_hash);
@ -1609,6 +1610,13 @@ void wallet_payment_store(struct wallet *wallet,
payment->route_channels); payment->route_channels);
sqlite3_bind_int64(stmt, 9, payment->msatoshi_sent); sqlite3_bind_int64(stmt, 9, payment->msatoshi_sent);
if (payment->description != NULL)
sqlite3_bind_text(stmt, 10, payment->description,
strlen(payment->description),
SQLITE_TRANSIENT);
else
sqlite3_bind_null(stmt, 10);
db_exec_prepared(wallet->db, stmt); db_exec_prepared(wallet->db, stmt);
tal_free(payment); tal_free(payment);
@ -1662,6 +1670,12 @@ static struct wallet_payment *wallet_stmt2payment(const tal_t *ctx,
payment->msatoshi_sent = sqlite3_column_int64(stmt, 10); payment->msatoshi_sent = sqlite3_column_int64(stmt, 10);
if (sqlite3_column_type(stmt, 11) != SQLITE_NULL)
payment->description = tal_strdup(
payment, (const char *)sqlite3_column_text(stmt, 11));
else
payment->description = NULL;
return payment; return payment;
} }
@ -1681,7 +1695,7 @@ wallet_payment_by_hash(const tal_t *ctx, struct wallet *wallet,
"SELECT id, status, destination," "SELECT id, status, destination,"
"msatoshi, payment_hash, timestamp, payment_preimage, " "msatoshi, payment_hash, timestamp, payment_preimage, "
"path_secrets, route_nodes, route_channels, " "path_secrets, route_nodes, route_channels, "
"msatoshi_sent " "msatoshi_sent, description "
"FROM payments " "FROM payments "
"WHERE payment_hash = ?"); "WHERE payment_hash = ?");

Loading…
Cancel
Save