From 6a5c9d7a00bfddbdf6bd279d003fefe3958dccc1 Mon Sep 17 00:00:00 2001 From: Steve Myers Date: Mon, 4 Sep 2023 00:25:38 -0500 Subject: [PATCH] fix(esplora): use saturating_add in update_tx_graph() This fixes overflow error when calling update_tx_graph() from update_tx_graph_without_keychain(). --- crates/esplora/src/async_ext.rs | 2 +- crates/esplora/src/blocking_ext.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/esplora/src/async_ext.rs b/crates/esplora/src/async_ext.rs index 98c47253..279c8e96 100644 --- a/crates/esplora/src/async_ext.rs +++ b/crates/esplora/src/async_ext.rs @@ -261,7 +261,7 @@ impl EsploraAsyncExt for esplora_client::AsyncClient { } } - if last_index > last_active_index.map(|i| i + stop_gap as u32) { + if last_index > last_active_index.map(|i| i.saturating_add(stop_gap as u32)) { break; } } diff --git a/crates/esplora/src/blocking_ext.rs b/crates/esplora/src/blocking_ext.rs index 5220cf07..17c364ca 100644 --- a/crates/esplora/src/blocking_ext.rs +++ b/crates/esplora/src/blocking_ext.rs @@ -252,7 +252,7 @@ impl EsploraExt for esplora_client::BlockingClient { } } - if last_index > last_active_index.map(|i| i + stop_gap as u32) { + if last_index > last_active_index.map(|i| i.saturating_add(stop_gap as u32)) { break; } }