From 33d6da8a991c00286f2ac2c3656a1550d17c32d7 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Thu, 23 Jul 2020 13:39:35 +0200 Subject: [PATCH] cleanup psbt utxo fetching --- drongo | 2 +- .../sparrow/transaction/InputController.java | 10 ++-------- .../sparrow/transaction/InputsController.java | 14 +++++--------- 3 files changed, 8 insertions(+), 18 deletions(-) diff --git a/drongo b/drongo index af562dad..8bc4e3b3 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit af562dad1022c24d5ff851100cc3958a852fbec8 +Subproject commit 8bc4e3b3dcf4c826d148aeafd556ecdbe8673939 diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/InputController.java b/src/main/java/com/sparrowwallet/sparrow/transaction/InputController.java index 0920efb7..63a6ba78 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/InputController.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/InputController.java @@ -156,13 +156,7 @@ public class InputController extends TransactionFormController implements Initia from.setVisible(false); if(psbtInput != null) { - TransactionOutput output = null; - if(psbtInput.getNonWitnessUtxo() != null) { - output = psbtInput.getNonWitnessUtxo().getOutputs().get(txInput.getIndex()); - } else if(psbtInput.getWitnessUtxo() != null) { - output = psbtInput.getWitnessUtxo(); - } - + TransactionOutput output = psbtInput.getUtxo(); updateSpends(output); } else if(inputForm.getInputTransactions() != null) { updateSpends(inputForm.getInputTransactions()); @@ -299,7 +293,7 @@ public class InputController extends TransactionFormController implements Initia PSBTInput psbtInput = inputForm.getPsbtInput(); int reqSigs = -1; - if((psbtInput.getNonWitnessUtxo() != null || psbtInput.getWitnessUtxo() != null) && psbtInput.getSigningScript() != null) { + if(psbtInput.getUtxo() != null && psbtInput.getSigningScript() != null) { try { reqSigs = psbtInput.getSigningScript().getNumRequiredSignatures(); } catch (NonStandardScriptException e) { diff --git a/src/main/java/com/sparrowwallet/sparrow/transaction/InputsController.java b/src/main/java/com/sparrowwallet/sparrow/transaction/InputsController.java index 61d803ab..0cfc08cc 100644 --- a/src/main/java/com/sparrowwallet/sparrow/transaction/InputsController.java +++ b/src/main/java/com/sparrowwallet/sparrow/transaction/InputsController.java @@ -56,17 +56,13 @@ public class InputsController extends TransactionFormController implements Initi boolean showDenominator = true; List outputs = new ArrayList<>(); - for(int i = 0; i < tx.getInputs().size(); i++) { - TransactionInput input = tx.getInputs().get(i); - PSBTInput psbtInput = inputsForm.getPsbt().getPsbtInputs().get(i); - - if(psbtInput.getNonWitnessUtxo() != null) { - outputs.add(psbtInput.getNonWitnessUtxo().getOutputs().get((int)input.getOutpoint().getIndex())); - } else if(psbtInput.getWitnessUtxo() != null) { - outputs.add(psbtInput.getWitnessUtxo()); + for(PSBTInput psbtInput : inputsForm.getPsbt().getPsbtInputs()) { + TransactionOutput output = psbtInput.getUtxo(); + if(output != null) { + outputs.add(output); } - if((psbtInput.getNonWitnessUtxo() != null || psbtInput.getWitnessUtxo() != null) && psbtInput.getSigningScript() != null) { + if(psbtInput.getUtxo() != null && psbtInput.getSigningScript() != null) { try { reqSigs += psbtInput.getSigningScript().getNumRequiredSignatures(); } catch (NonStandardScriptException e) {