From f4ac18c3e153ce006f8e6b7e7b41a7edc41d9cad Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 2 Nov 2023 12:38:51 +0100 Subject: [PATCH] increase gap limit where necessary to sign a psbt where global xpubs match --- drongo | 2 +- .../sparrow/transaction/HeadersController.java | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drongo b/drongo index 12db57c8..75730f00 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit 12db57c8d75c6f9eb96a8da89e80139850cc450b +Subproject commit 75730f00ac9930c5800bd0868133903c90ce7930 diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java index 6cc094f6..a484281d 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/HeadersController.java @@ -1364,6 +1364,20 @@ public class HeadersController extends TransactionFormController implements Init public void openWallets(OpenWalletsEvent event) { if(id.getScene().getWindow().equals(event.getWindow()) && headersForm.getPsbt() != null && headersForm.getBlockTransaction() == null) { List availableWallets = event.getWallets().stream().filter(wallet -> wallet.canSign(headersForm.getPsbt())).sorted(new WalletSignComparator()).collect(Collectors.toList()); + if(availableWallets.isEmpty()) { + for(Wallet wallet : event.getWalletsMap().keySet()) { + if(wallet.isValid() && !wallet.getSigningKeystores(headersForm.getPsbt()).isEmpty()) { + int currentGapLimit = wallet.getGapLimit(); + Integer requiredGapLimit = wallet.getRequiredGapLimit(headersForm.getPsbt()); + if(requiredGapLimit != null && requiredGapLimit > currentGapLimit) { + wallet.setGapLimit(requiredGapLimit); + EventManager.get().post(new WalletGapLimitChangedEvent(event.getStorage(wallet).getWalletId(wallet), wallet, currentGapLimit)); + Platform.runLater(() -> EventManager.get().post(new RequestOpenWalletsEvent())); + } + } + } + } + Map availableWalletsMap = new LinkedHashMap<>(event.getWalletsMap()); availableWalletsMap.keySet().retainAll(availableWallets); headersForm.getAvailableWallets().keySet().retainAll(availableWallets);