commands: add a new 'delspendtx' command
This commit is contained in:
8 files changed
+82
No files matched your search
@@ -79,6 +79,9 @@ pub trait DatabaseConnection {
|
||||
|
||||
/// List all existing Spend transactions.
|
||||
fn list_spend(&mut self) -> Vec<Psbt>;
|
||||
|
||||
/// Delete a Spend transaction from database.
|
||||
fn delete_spend(&mut self, txid: &bitcoin::Txid);
|
||||
}
|
||||
|
||||
// FIXME: if possible, avoid reallocating.
|
||||
@@ -181,6 +184,10 @@ impl DatabaseConnection for SqliteConn {
|
||||
.map(|db_spend| db_spend.psbt)
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn delete_spend(&mut self, txid: &bitcoin::Txid) {
|
||||
self.delete_spend(txid)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
|
||||
@@ -392,6 +392,17 @@ impl SqliteConn {
|
||||
)
|
||||
.expect("Db must not fail")
|
||||
}
|
||||
|
||||
pub fn delete_spend(&mut self, txid: &bitcoin::Txid) {
|
||||
db_exec(&mut self.conn, |db_tx| {
|
||||
db_tx.execute(
|
||||
"DELETE FROM spend_transactions WHERE txid = ?1",
|
||||
rusqlite::params![txid.to_vec()],
|
||||
)?;
|
||||
Ok(())
|
||||
})
|
||||
.expect("Db must not fail");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in new issue
Block a user