]> Untitled Git - bdk/commitdiff
fix(esplora): use saturating_add in update_tx_graph()
authorSteve Myers <steve@notmandatory.org>
Mon, 4 Sep 2023 05:25:38 +0000 (00:25 -0500)
committerSteve Myers <steve@notmandatory.org>
Tue, 26 Sep 2023 02:09:42 +0000 (21:09 -0500)
This fixes overflow error when calling update_tx_graph() from update_tx_graph_without_keychain().

crates/esplora/src/async_ext.rs
crates/esplora/src/blocking_ext.rs

index 98c47253fafc72f896091be1a283c4d4afccdd09..279c8e962ccc09ffc0a64ebcfa66e723c897a057 100644 (file)
@@ -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;
                 }
             }
index 5220cf07fbe16a0e6eb3c4ff040cb9d60e15fecc..17c364ca9cb62e0e240803e19d95717daa44bd94 100644 (file)
@@ -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;
                 }
             }