mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 21:35:11 +01:00
wallet_payment: Make msatoshi field nullable.
This commit is contained in:
parent
50471bf4fe
commit
caab95b922
@ -259,7 +259,10 @@ static void json_invoice(struct command *cmd,
|
||||
payment.payment_hash = invoice->rhash;
|
||||
payment.destination = NULL;
|
||||
payment.status = PAYMENT_PENDING;
|
||||
payment.msatoshi = *invoice->msatoshi;
|
||||
if (invoice->msatoshi)
|
||||
payment.msatoshi = tal_dup(cmd, u64, invoice->msatoshi);
|
||||
else
|
||||
payment.msatoshi = NULL;
|
||||
payment.timestamp = b11->timestamp;
|
||||
|
||||
if (!wallet_payment_add(cmd->ld->wallet, &payment)) {
|
||||
|
@ -247,7 +247,8 @@ static bool send_payment(struct command *cmd,
|
||||
payment->payment_hash = *rhash;
|
||||
payment->destination = &ids[n_hops - 1];
|
||||
payment->status = PAYMENT_PENDING;
|
||||
payment->msatoshi = route[n_hops-1].amount;
|
||||
payment->msatoshi = tal(payment, u64);
|
||||
*payment->msatoshi = route[n_hops-1].amount;
|
||||
payment->timestamp = time_now().ts.tv_sec;
|
||||
}
|
||||
pc->cmd = cmd;
|
||||
@ -503,7 +504,8 @@ static void json_listpayments(struct command *cmd, const char *buffer,
|
||||
json_add_hex(response, "payment_hash", &t->payment_hash, sizeof(t->payment_hash));
|
||||
if (!t->incoming)
|
||||
json_add_pubkey(response, "destination", t->destination);
|
||||
json_add_u64(response, "msatoshi", t->msatoshi);
|
||||
if (t->msatoshi)
|
||||
json_add_u64(response, "msatoshi", *t->msatoshi);
|
||||
json_add_u64(response, "timestamp", t->timestamp);
|
||||
|
||||
switch (t->status) {
|
||||
|
@ -557,6 +557,7 @@ static bool test_payment_crud(const tal_t *ctx)
|
||||
|
||||
t.id = 0;
|
||||
t.destination = NULL;
|
||||
t.msatoshi = NULL;
|
||||
|
||||
db_begin_transaction(w->db);
|
||||
CHECK(wallet_payment_add(w, &t));
|
||||
|
@ -1403,7 +1403,10 @@ bool wallet_payment_add(struct wallet *wallet,
|
||||
else
|
||||
sqlite3_bind_null(stmt, 4);
|
||||
|
||||
sqlite3_bind_int64(stmt, 5, payment->msatoshi);
|
||||
if (payment->msatoshi)
|
||||
sqlite3_bind_int64(stmt, 5, *payment->msatoshi);
|
||||
else
|
||||
sqlite3_bind_null(stmt, 5);
|
||||
|
||||
sqlite3_bind_int(stmt, 6, payment->timestamp);
|
||||
|
||||
@ -1427,7 +1430,12 @@ static struct wallet_payment *wallet_stmt2payment(const tal_t *ctx,
|
||||
payment->destination = NULL;
|
||||
}
|
||||
|
||||
payment->msatoshi = sqlite3_column_int64(stmt, 4);
|
||||
if (sqlite3_column_type(stmt, 4) != SQLITE_NULL) {
|
||||
payment->msatoshi = tal(payment, u64);
|
||||
*payment->msatoshi = sqlite3_column_int64(stmt, 4);
|
||||
} else {
|
||||
payment->msatoshi = NULL;
|
||||
}
|
||||
sqlite3_column_sha256(stmt, 5, &payment->payment_hash);
|
||||
|
||||
payment->timestamp = sqlite3_column_int(stmt, 6);
|
||||
|
@ -89,7 +89,7 @@ struct wallet_payment {
|
||||
struct sha256 payment_hash;
|
||||
enum wallet_payment_status status;
|
||||
struct pubkey *destination;
|
||||
u64 msatoshi;
|
||||
u64 *msatoshi;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user