diff --git a/drongo b/drongo index 567294a4..42ffeb95 160000 --- a/drongo +++ b/drongo @@ -1 +1 @@ -Subproject commit 567294a4b055cc062650de45fccbbc89db714f39 +Subproject commit 42ffeb95650c56bffbd5ec8f8e8f38d91faaab3f diff --git a/src/main/java/com/sparrowwallet/sparrow/AppController.java b/src/main/java/com/sparrowwallet/sparrow/AppController.java index 10bf5293..513943ad 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppController.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppController.java @@ -18,6 +18,7 @@ import com.sparrowwallet.drongo.protocol.Transaction; import com.sparrowwallet.drongo.psbt.PSBT; import com.sparrowwallet.drongo.psbt.PSBTInput; import com.sparrowwallet.drongo.psbt.PSBTParseException; +import com.sparrowwallet.drongo.psbt.PSBTSignatureException; import com.sparrowwallet.drongo.wallet.*; import com.sparrowwallet.sparrow.control.*; import com.sparrowwallet.sparrow.event.*; @@ -1176,7 +1177,8 @@ public class AppController implements Initializable { private void addTransactionTab(String name, File file, byte[] bytes) throws PSBTParseException, ParseException, TransactionParseException { if(PSBT.isPSBT(bytes)) { - PSBT psbt = new PSBT(bytes); + //Don't verify signatures here - provided PSBT may omit UTXO data that can be found when combining with an existing PSBT + PSBT psbt = new PSBT(bytes, false); addTransactionTab(name, file, psbt); } else if(Transaction.isTransaction(bytes)) { try { @@ -1252,6 +1254,16 @@ public class AppController implements Initializable { } } + if(psbt != null) { + try { + //Any PSBTs that have reached this point could not be combined with an existing PSBT. Verify signatures before continuing + psbt.verifySignatures(); + } catch(PSBTSignatureException e) { + AppServices.showErrorDialog("Invalid PSBT", e.getMessage()); + return; + } + } + try { String tabName = name; diff --git a/src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java b/src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java index 8bd1b1c9..27d81dd2 100644 --- a/src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java +++ b/src/main/java/com/sparrowwallet/sparrow/control/QRScanDialog.java @@ -209,7 +209,7 @@ public class QRScanDialog extends Dialog { if(parts.stream().filter(Objects::nonNull).count() == n) { String complete = String.join("", parts); try { - PSBT psbt = PSBT.fromString(complete); + PSBT psbt = PSBT.fromString(complete, false); result = new Result(psbt); return; } catch(PSBTParseException e) { @@ -261,7 +261,7 @@ public class QRScanDialog extends Dialog { } try { - psbt = PSBT.fromString(qrtext); + psbt = PSBT.fromString(qrtext, false); result = new Result(psbt); return; } catch(PSBTParseException e) { @@ -273,7 +273,7 @@ public class QRScanDialog extends Dialog { } try { - psbt = new PSBT(qrResult.getRawBytes()); + psbt = new PSBT(qrResult.getRawBytes(), false); result = new Result(psbt); return; } catch(Exception e) { @@ -298,7 +298,7 @@ public class QRScanDialog extends Dialog { //Try Base43 used by Electrum try { - psbt = new PSBT(Base43.decode(qrtext)); + psbt = new PSBT(Base43.decode(qrtext), false); result = new Result(psbt); return; } catch(Exception e) { @@ -324,7 +324,7 @@ public class QRScanDialog extends Dialog { if(urRegistryType.equals(RegistryType.BYTES)) { byte[] urBytes = (byte[])ur.decodeFromRegistry(); try { - PSBT psbt = new PSBT(urBytes); + PSBT psbt = new PSBT(urBytes, false); return new Result(psbt); } catch(PSBTParseException e) { if(PSBT.isPSBT(urBytes)) { @@ -354,7 +354,7 @@ public class QRScanDialog extends Dialog { } else if(urRegistryType.equals(RegistryType.CRYPTO_PSBT)) { CryptoPSBT cryptoPSBT = (CryptoPSBT)ur.decodeFromRegistry(); try { - PSBT psbt = new PSBT(cryptoPSBT.getPsbt()); + PSBT psbt = new PSBT(cryptoPSBT.getPsbt(), false); return new Result(psbt); } catch(Exception e) { log.error("Error parsing PSBT from UR type " + urRegistryType, e);