Skip to content

Commit

Permalink
wallet: Store the description in the database for invoices
Browse files Browse the repository at this point in the history
  • Loading branch information
cdecker authored and rustyrussell committed Jul 30, 2018
1 parent 687f171 commit 7f45947
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions lightningd/invoice.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ static void json_invoice(struct command *cmd,
take(label_val),
expiry,
b11enc,
b11->description,
&r,
&rhash);

Expand Down
6 changes: 4 additions & 2 deletions wallet/invoices.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ bool invoices_create(struct invoices *invoices,
const struct json_escaped *label TAKES,
u64 expiry,
const char *b11enc,
const char *description,
const struct preimage *r,
const struct sha256 *rhash)
{
Expand Down Expand Up @@ -288,11 +289,11 @@ bool invoices_create(struct invoices *invoices,
" ( payment_hash, payment_key, state"
" , msatoshi, label, expiry_time"
" , pay_index, msatoshi_received"
" , paid_timestamp, bolt11)"
" , paid_timestamp, bolt11, description)"
" VALUES ( ?, ?, ?"
" , ?, ?, ?"
" , NULL, NULL"
" , NULL, ?);");
" , NULL, ?, ?);");

sqlite3_bind_blob(stmt, 1, rhash, sizeof(struct sha256), SQLITE_TRANSIENT);
sqlite3_bind_blob(stmt, 2, r, sizeof(struct preimage), SQLITE_TRANSIENT);
Expand All @@ -304,6 +305,7 @@ bool invoices_create(struct invoices *invoices,
sqlite3_bind_json_escaped(stmt, 5, label);
sqlite3_bind_int64(stmt, 6, expiry_time);
sqlite3_bind_text(stmt, 7, b11enc, strlen(b11enc), SQLITE_TRANSIENT);
sqlite3_bind_text(stmt, 8, description, strlen(description), SQLITE_TRANSIENT);

db_exec_prepared(invoices->db, stmt);

Expand Down
1 change: 1 addition & 0 deletions wallet/invoices.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ bool invoices_create(struct invoices *invoices,
const struct json_escaped *label TAKES,
u64 expiry,
const char *b11enc,
const char *description,
const struct preimage *r,
const struct sha256 *rhash);

Expand Down
1 change: 1 addition & 0 deletions wallet/test/run-wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ bool invoices_create(struct invoices *invoices UNNEEDED,
const struct json_escaped *label TAKES UNNEEDED,
u64 expiry UNNEEDED,
const char *b11enc UNNEEDED,
const char *description UNNEEDED,
const struct preimage *r UNNEEDED,
const struct sha256 *rhash UNNEEDED)
{ fprintf(stderr, "invoices_create called!\n"); abort(); }
Expand Down
3 changes: 2 additions & 1 deletion wallet/wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1402,10 +1402,11 @@ bool wallet_invoice_create(struct wallet *wallet,
const struct json_escaped *label TAKES,
u64 expiry,
const char *b11enc,
const char *description,
const struct preimage *r,
const struct sha256 *rhash)
{
return invoices_create(wallet->invoices, pinvoice, msatoshi, label, expiry, b11enc, r, rhash);
return invoices_create(wallet->invoices, pinvoice, msatoshi, label, expiry, b11enc, description, r, rhash);
}
bool wallet_invoice_find_by_label(struct wallet *wallet,
struct invoice *pinvoice,
Expand Down
1 change: 1 addition & 0 deletions wallet/wallet.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ bool wallet_invoice_create(struct wallet *wallet,
const struct json_escaped *label TAKES,
u64 expiry,
const char *b11enc,
const char *description,
const struct preimage *r,
const struct sha256 *rhash);

Expand Down

0 comments on commit 7f45947

Please sign in to comment.