mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-01-27 07:47:08 -05:00
Merge #213
213: Properly calculate the confirmations for Bitcoin tx r=da-kami a=da-kami Once the transaction was included into a block it has one confirmation - before inclusion it has zero. current-block-height - transaction-block-height = zero; but that means one confirmation. Hence, the confirmation calculation was adapted to: Current-block-height - (transaction-block-height - 1). I could not think of a more elegant solution - if you have one please comment :) Co-authored-by: Daniel Karzel <daniel@comit.network>
This commit is contained in:
commit
c4df3fdcbc
@ -273,7 +273,11 @@ impl WaitForTransactionFinality for Wallet {
|
|||||||
tracing::debug!("tx_block_height: {:?}", tx_block_height);
|
tracing::debug!("tx_block_height: {:?}", tx_block_height);
|
||||||
let block_height = self.get_block_height().await?;
|
let block_height = self.get_block_height().await?;
|
||||||
tracing::debug!("latest_block_height: {:?}", block_height);
|
tracing::debug!("latest_block_height: {:?}", block_height);
|
||||||
if let Some(confirmations) = block_height.checked_sub(tx_block_height) {
|
if let Some(confirmations) = block_height.checked_sub(
|
||||||
|
tx_block_height
|
||||||
|
.checked_sub(BlockHeight::new(1))
|
||||||
|
.expect("transaction must be included in block with height >= 1"),
|
||||||
|
) {
|
||||||
tracing::debug!("confirmations: {:?}", confirmations);
|
tracing::debug!("confirmations: {:?}", confirmations);
|
||||||
if u32::from(confirmations) >= execution_params.bitcoin_finality_confirmations {
|
if u32::from(confirmations) >= execution_params.bitcoin_finality_confirmations {
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user