Record btc utxo in cashierdb

This commit is contained in:
Janus
2021-09-14 08:28:47 -04:00
parent 1aed118a8f
commit e1df3eead7
3 changed files with 36 additions and 1 deletions

View File

@@ -135,6 +135,7 @@ impl BitcoinKeys {
pub fn get_script(&self) -> &Script {
&self.script
}
}
@@ -166,7 +167,7 @@ impl CoinClient for BtcClient {
let btc_priv = btc_keys.clone();
let btc_priv = btc_priv.get_privkey();
// let _ = btc_keys.start_subscribe().await?;
let _ = btc_keys.start_subscribe().await?;
// start scheduler for checking balance
debug!(target: "BRIDGE BITCOIN", "Subscribing for deposit");

View File

@@ -105,7 +105,32 @@ impl CashierDb {
)?;
Ok(())
}
pub fn put_btc_utxo(
&self,
tx_id: &Vec<u8>,
btc_key_public: &Vec<u8>,
balance: i64,
) -> Result<()> {
debug!(target: "CASHIERDB", "Put BTC Utxo");
let tx_id = self.get_value_serialized(tx_id)?;
// open connection
let conn = Connection::open(&self.path)?;
// unlock database
conn.pragma_update(None, "key", &self.password)?;
conn.execute(
"INSERT INTO btc_utxo(tx_id, btc_key_public, balance)
VALUES (:tx_id, :btc_key_public, :balance)",
named_params! {
":tx_id": tx_id,
":btc_key_public": btc_key_public,
":balance": balance,
},
)?;
Ok(())
}
pub fn get_withdraw_private_keys(&self) -> Result<Vec<jubjub::Fr>> {
debug!(target: "CASHIERDB", "Get withdraw private keys");
// open connection