wallet: Store payment description in the database

This commit is contained in:
Christian Decker 2018-07-20 15:57:00 +02:00 committed by Rusty Russell
parent ff5ca37f3c
commit 60e0eec967
2 changed files with 18 additions and 3 deletions

View File

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

View File

@ -1593,8 +1593,9 @@ void wallet_payment_store(struct wallet *wallet,
" path_secrets,"
" route_nodes,"
" route_channels,"
" msatoshi_sent"
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);");
" msatoshi_sent,"
" description"
") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);");
sqlite3_bind_int(stmt, 1, payment->status);
sqlite3_bind_sha256(stmt, 2, &payment->payment_hash);
@ -1609,6 +1610,13 @@ void wallet_payment_store(struct wallet *wallet,
payment->route_channels);
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);
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);
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;
}
@ -1681,7 +1695,7 @@ wallet_payment_by_hash(const tal_t *ctx, struct wallet *wallet,
"SELECT id, status, destination,"
"msatoshi, payment_hash, timestamp, payment_preimage, "
"path_secrets, route_nodes, route_channels, "
"msatoshi_sent "
"msatoshi_sent, description "
"FROM payments "
"WHERE payment_hash = ?");