mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2024-12-23 14:39:37 -05:00
Workaround to avoid overflow in check_tx_key
`check_tx_key` can run into an overflow error when handling `-1` values for confirmations. This most likely happens when a transaction is not in mempool yet. In order to avoid unwanted side effects in the tests (i.e. failure because the transfer is seemingly confirmed, when it is not yet), we add a guard that checks for values close to u64::MAX. Note that we cannot check for the exact value of u64::MAX, because it seems that there is an addition somewhere in monerod/wallet-rpc, that results in `-1` (first), `-2` (second) (...) until the transaction is in mempool.
This commit is contained in:
parent
6c4d72704a
commit
99268c2715
@ -281,8 +281,17 @@ impl Client {
|
||||
|
||||
debug!("check_tx_key RPC response: {}", response);
|
||||
|
||||
let r = serde_json::from_str::<Response<CheckTxKey>>(&response)?;
|
||||
Ok(r.result)
|
||||
let check_tx_key = serde_json::from_str::<Response<CheckTxKey>>(&response)?;
|
||||
let mut check_tx_key = check_tx_key.result;
|
||||
|
||||
// Due to a bug in monerod that causes check_tx_key confirmations
|
||||
// to overflow we safeguard the confirmations to avoid unwanted
|
||||
// side effects.
|
||||
if check_tx_key.confirmations > u64::MAX - 1000 {
|
||||
check_tx_key.confirmations = 0u64;
|
||||
}
|
||||
|
||||
Ok(check_tx_key)
|
||||
}
|
||||
|
||||
pub async fn generate_from_keys(
|
||||
|
Loading…
Reference in New Issue
Block a user