From f2c2fc60711f2fde1362522d99b77b89a10eb198 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 11 Mar 2021 10:33:51 +0200 Subject: [PATCH] fix exception on debug logging when sending from two or more utxos on the same derivation --- .../sparrowwallet/sparrow/wallet/SendController.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java index 778e6152..5d9cec4f 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/SendController.java @@ -838,12 +838,16 @@ public class SendController extends WalletFormController implements Initializabl public void createTransaction(ActionEvent event) { if(log.isDebugEnabled()) { - Map nodeHashes = walletTransactionProperty.get().getSelectedUtxos().values().stream().collect(Collectors.toMap(Function.identity(), node -> ElectrumServer.getScriptHash(walletForm.getWallet(), node))); - Map changeHash = Collections.emptyMap(); + Map> inputHashes = new LinkedHashMap<>(); + for(WalletNode node : walletTransactionProperty.get().getSelectedUtxos().values()) { + List nodeHashes = inputHashes.computeIfAbsent(node, k -> new ArrayList<>()); + nodeHashes.add(ElectrumServer.getScriptHash(walletForm.getWallet(), node)); + } + Map> changeHash = Collections.emptyMap(); if(walletTransactionProperty.get().getChangeNode() != null) { - changeHash = Map.of(walletTransactionProperty.get().getChangeNode(), ElectrumServer.getScriptHash(walletForm.getWallet(), walletTransactionProperty.get().getChangeNode())); + changeHash = Map.of(walletTransactionProperty.get().getChangeNode(), List.of(ElectrumServer.getScriptHash(walletForm.getWallet(), walletTransactionProperty.get().getChangeNode()))); } - log.debug("Creating tx " + walletTransactionProperty.get().getTransaction().getTxId() + ", expecting notifications for \ninputs \n" + nodeHashes + " and \nchange \n" + changeHash); + log.debug("Creating tx " + walletTransactionProperty.get().getTransaction().getTxId() + ", expecting notifications for \ninputs \n" + inputHashes + " and \nchange \n" + changeHash); } addWalletTransactionNodes();