diff --git a/monero-rpc/src/wallet.rs b/monero-rpc/src/wallet.rs index 3e21ad1b..177d5f24 100644 --- a/monero-rpc/src/wallet.rs +++ b/monero-rpc/src/wallet.rs @@ -36,6 +36,7 @@ pub trait MoneroWalletRpc { async fn refresh(&self) -> Refreshed; async fn sweep_all(&self, address: String) -> SweepAll; async fn get_version(&self) -> Version; + async fn store(&self); } #[jsonrpc_client::implement(MoneroWalletRpc)] diff --git a/swap/src/bin/asb.rs b/swap/src/bin/asb.rs index 3a0d2dd4..5f436c6c 100644 --- a/swap/src/bin/asb.rs +++ b/swap/src/bin/asb.rs @@ -466,7 +466,8 @@ async fn init_monero_wallet( env_config, ) .await?; - + let _ = wallet.refresh().await?; + wallet.store().await?; Ok(wallet) } diff --git a/swap/src/monero/wallet.rs b/swap/src/monero/wallet.rs index e3db3416..8f59ba1f 100644 --- a/swap/src/monero/wallet.rs +++ b/swap/src/monero/wallet.rs @@ -71,6 +71,11 @@ impl Wallet { Ok(()) } + pub async fn store(&self) -> Result<()> { + self.inner.lock().await.store().await?; + Ok(()) + } + /// Close the wallet and open (load) another wallet by generating it from /// keys. The generated wallet will remain loaded. pub async fn create_from_and_load( diff --git a/swap/src/protocol/alice/swap.rs b/swap/src/protocol/alice/swap.rs index 14f718d3..a1a1e860 100644 --- a/swap/src/protocol/alice/swap.rs +++ b/swap/src/protocol/alice/swap.rs @@ -189,6 +189,8 @@ where ) })?; + monero_wallet.store().await?; + AliceState::XmrLocked { monero_wallet_restore_blockheight, transfer_proof, @@ -395,6 +397,8 @@ where ) .await?; + monero_wallet.store().await?; + AliceState::XmrRefunded } AliceState::BtcPunishable {