diff --git a/wallet/wallet.c b/wallet/wallet.c index 89e3346b6..8e35ee4ee 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -1689,3 +1689,11 @@ void wallet_block_remove(struct wallet *w, struct block *b) assert(sqlite3_step(stmt) == SQLITE_DONE); sqlite3_finalize(stmt); } + +void wallet_blocks_rollback(struct wallet *w, u32 height) +{ + sqlite3_stmt *stmt = db_prepare(w->db, "DELETE FROM blocks " + "WHERE height >= ?"); + sqlite3_bind_int(stmt, 1, height); + db_exec_prepared(w->db, stmt); +} diff --git a/wallet/wallet.h b/wallet/wallet.h index a3f66fd7a..3ce1fcb4d 100644 --- a/wallet/wallet.h +++ b/wallet/wallet.h @@ -695,5 +695,9 @@ void wallet_block_add(struct wallet *w, struct block *b); */ void wallet_block_remove(struct wallet *w, struct block *b); +/** + * wallet_blocks_rollback - Roll the blockchain back to the given height + */ +void wallet_blocks_rollback(struct wallet *w, u32 height); #endif /* WALLET_WALLET_H */