wallet: Add primitives to add forwarded payments to the DB

Signed-off-by: Christian Decker <@cdecker>
This commit is contained in:
Christian Decker 2018-10-16 21:28:35 +02:00 committed by Rusty Russell
parent 07ebc525e9
commit 5b924a7eb7
2 changed files with 29 additions and 0 deletions

View File

@ -2405,3 +2405,28 @@ struct channeltx *wallet_channeltxs_get(struct wallet *w, const tal_t *ctx,
db_stmt_done(stmt);
return res;
}
void wallet_forwarded_payment_add(struct wallet *w, const struct htlc_in *in,
const struct htlc_out *out,
enum forward_status state)
{
sqlite3_stmt *stmt;
stmt = db_prepare(
w->db,
"INSERT OR REPLACE INTO forwarded_payments ("
" in_htlc_id"
", out_htlc_id"
", in_channel_scid"
", out_channel_scid"
", in_msatoshi"
", out_msatoshi"
", state) VALUES (?, ?, ?, ?, ?, ?, ?);");
sqlite3_bind_int64(stmt, 1, in->dbid);
sqlite3_bind_int64(stmt, 2, out->dbid);
sqlite3_bind_int64(stmt, 3, in->key.channel->scid->u64);
sqlite3_bind_int64(stmt, 4, out->key.channel->scid->u64);
sqlite3_bind_int64(stmt, 5, in->msatoshi);
sqlite3_bind_int64(stmt, 6, out->msatoshi);
sqlite3_bind_int(stmt, 7, state);
db_exec_prepared(w->db, stmt);
}

View File

@ -995,4 +995,8 @@ u32 *wallet_onchaind_channels(struct wallet *w,
struct channeltx *wallet_channeltxs_get(struct wallet *w, const tal_t *ctx,
u32 channel_id);
void wallet_forwarded_payment_add(struct wallet *w, const struct htlc_in *in,
const struct htlc_out *out,
enum forward_status state);
#endif /* LIGHTNING_WALLET_WALLET_H */