diff --git a/lightningd/pay.c b/lightningd/pay.c index 4caccfaff..c1f5ccaaf 100644 --- a/lightningd/pay.c +++ b/lightningd/pay.c @@ -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); diff --git a/wallet/wallet.c b/wallet/wallet.c index fab2868f9..bec2d41b7 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -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 = ?");