Browse Source

wallet: Add primitives to add forwarded payments to the DB

Signed-off-by: Christian Decker <@cdecker>
ppa-0.6.2rc1
Christian Decker 6 years ago
committed by Rusty Russell
parent
commit
5b924a7eb7
  1. 25
      wallet/wallet.c
  2. 4
      wallet/wallet.h

25
wallet/wallet.c

@ -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);
}

4
wallet/wallet.h

@ -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 */

Loading…
Cancel
Save