diff --git a/src/app.rs b/src/app.rs index 001a74bf..719420ab 100644 --- a/src/app.rs +++ b/src/app.rs @@ -305,12 +305,11 @@ impl InnerApp { ) -> Result<()> { #[cfg(feature = "ethereum")] { - crate::bitcoin::exempt_from_fee()?; - - // TODO: fee - let signer = self.signer()?; - let coins = self.bitcoin.accounts.withdraw(signer, amount)?; + let mut coins = self.bitcoin.accounts.withdraw(signer, amount)?; + + let fee = coins.take(20_000_000)?; + self.bitcoin.give_rewards(fee)?; let dest = Dest::EthAccount { network, @@ -511,6 +510,7 @@ impl InnerApp { match sender { Identity::NativeAccount { address } => { + log::debug!("Returning funds to NativeAccount sender"); self.bitcoin.accounts.deposit(address, coins)?; } #[cfg(feature = "ethereum")] @@ -519,10 +519,17 @@ impl InnerApp { connection, address, } => { - self.ethereum + let res = self + .ethereum .network_mut(network)? .connection_mut(connection.into())? - .transfer(address.into(), coins)?; + .transfer(address.into(), coins); + if let Err(e) = res { + log::debug!("Error returning funds to EthAccount sender: {:?}", e); + // TODO: place funds in rewards pool? + } else { + log::debug!("Returning funds to EthAccount sender"); + } } _ => {} } diff --git a/src/ethereum/mod.rs b/src/ethereum/mod.rs index a6a9ec8b..aca269b3 100644 --- a/src/ethereum/mod.rs +++ b/src/ethereum/mod.rs @@ -734,6 +734,12 @@ impl Connection { /// Processes an adjustment to the emergency disbursal balances received /// from the remote bridge contract deployment. + /// + /// NOTE: as of this version, the emergency disbursal balances are not yet + /// being used by the Bitcoin state machine. When it is integrated, the + /// total balances will be checked against the actual amount of funds + /// bridged to the contract and all emergency disbursal balances will be + /// ignored if the total exceeds the actual balance. pub fn adjust_emergency_disbursal_balance( &mut self, script: Adapter