mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
wallet: Add last_was_revoke to channels
Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
@@ -156,6 +156,7 @@ char *dbmigrations[] = {
|
|||||||
"ALTER TABLE invoices ADD COLUMN msatoshi_received INTEGER;",
|
"ALTER TABLE invoices ADD COLUMN msatoshi_received INTEGER;",
|
||||||
/* Normally impossible, so at least we'll know if databases are ancient. */
|
/* Normally impossible, so at least we'll know if databases are ancient. */
|
||||||
"UPDATE invoices SET msatoshi_received=0 WHERE state=1;",
|
"UPDATE invoices SET msatoshi_received=0 WHERE state=1;",
|
||||||
|
"ALTER TABLE channels ADD COLUMN last_was_revoke INTEGER;",
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -281,6 +281,8 @@ static bool channelseq(struct wallet_channel *c1, struct wallet_channel *c2)
|
|||||||
CHECK(p1->local_shutdown_idx == p2->local_shutdown_idx);
|
CHECK(p1->local_shutdown_idx == p2->local_shutdown_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CHECK(p1->last_was_revoke == p2->last_was_revoke);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,6 +375,7 @@ static bool test_channel_crud(const tal_t *ctx)
|
|||||||
|
|
||||||
/* Variant 3: update with our_satoshi set */
|
/* Variant 3: update with our_satoshi set */
|
||||||
c1.peer->our_msatoshi = &msat;
|
c1.peer->our_msatoshi = &msat;
|
||||||
|
c1.peer->last_was_revoke = !c1.peer->last_was_revoke;
|
||||||
|
|
||||||
wallet_channel_save(w, &c1, 0);
|
wallet_channel_save(w, &c1, 0);
|
||||||
CHECK_MSG(!wallet_err, tal_fmt(w, "Insert into DB: %s", wallet_err));
|
CHECK_MSG(!wallet_err, tal_fmt(w, "Insert into DB: %s", wallet_err));
|
||||||
|
|||||||
@@ -571,6 +571,8 @@ static bool wallet_stmt2channel(const tal_t *ctx, struct wallet *w, sqlite3_stmt
|
|||||||
chan->peer->last_sig = tal_free(chan->peer->last_sig);
|
chan->peer->last_sig = tal_free(chan->peer->last_sig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chan->peer->last_was_revoke = sqlite3_column_int(stmt, 34) != 0;
|
||||||
|
|
||||||
chan->peer->channel = chan;
|
chan->peer->channel = chan;
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
@@ -591,7 +593,7 @@ static const char *channel_fields =
|
|||||||
"old_per_commit_remote, local_feerate_per_kw, remote_feerate_per_kw, shachain_remote_id, "
|
"old_per_commit_remote, local_feerate_per_kw, remote_feerate_per_kw, shachain_remote_id, "
|
||||||
"shutdown_scriptpubkey_remote, shutdown_keyidx_local, "
|
"shutdown_scriptpubkey_remote, shutdown_keyidx_local, "
|
||||||
"last_sent_commit_state, last_sent_commit_id, "
|
"last_sent_commit_state, last_sent_commit_id, "
|
||||||
"last_tx, last_sig";
|
"last_tx, last_sig, last_was_revoke";
|
||||||
|
|
||||||
bool wallet_channels_load_active(const tal_t *ctx, struct wallet *w, struct list_head *peers)
|
bool wallet_channels_load_active(const tal_t *ctx, struct wallet *w, struct list_head *peers)
|
||||||
{
|
{
|
||||||
@@ -745,7 +747,8 @@ void wallet_channel_save(struct wallet *w, struct wallet_channel *chan,
|
|||||||
" shutdown_scriptpubkey_remote=?,"
|
" shutdown_scriptpubkey_remote=?,"
|
||||||
" shutdown_keyidx_local=?,"
|
" shutdown_keyidx_local=?,"
|
||||||
" channel_config_local=?,"
|
" channel_config_local=?,"
|
||||||
" last_tx=?, last_sig=?"
|
" last_tx=?, last_sig=?,"
|
||||||
|
" last_was_revoke=?"
|
||||||
" WHERE id=?");
|
" WHERE id=?");
|
||||||
sqlite3_bind_int64(stmt, 1, p->their_shachain.id);
|
sqlite3_bind_int64(stmt, 1, p->their_shachain.id);
|
||||||
if (p->scid)
|
if (p->scid)
|
||||||
@@ -781,7 +784,8 @@ void wallet_channel_save(struct wallet *w, struct wallet_channel *chan,
|
|||||||
sqlite3_bind_tx(stmt, 19, p->last_tx);
|
sqlite3_bind_tx(stmt, 19, p->last_tx);
|
||||||
if (p->last_sig)
|
if (p->last_sig)
|
||||||
sqlite3_bind_signature(stmt, 20, p->last_sig);
|
sqlite3_bind_signature(stmt, 20, p->last_sig);
|
||||||
sqlite3_bind_int64(stmt, 21, chan->id);
|
sqlite3_bind_int(stmt, 21, p->last_was_revoke);
|
||||||
|
sqlite3_bind_int64(stmt, 22, chan->id);
|
||||||
db_exec_prepared(w->db, stmt);
|
db_exec_prepared(w->db, stmt);
|
||||||
|
|
||||||
if (chan->peer->channel_info) {
|
if (chan->peer->channel_info) {
|
||||||
|
|||||||
Reference in New Issue
Block a user