diff --git a/build.gradle b/build.gradle index 03fcf1ee..231d335b 100644 --- a/build.gradle +++ b/build.gradle @@ -210,7 +210,7 @@ jlink { appVersion = "${sparrowVersion}" skipInstaller = os.macOsX || properties.skipInstallers imageOptions = [] - installerOptions = ['--file-associations', 'src/main/deploy/psbt.properties', '--file-associations', 'src/main/deploy/txn.properties', '--file-associations', 'src/main/deploy/bitcoin.properties', '--file-associations', 'src/main/deploy/aopp.properties', '--license-file', 'LICENSE'] + installerOptions = ['--file-associations', 'src/main/deploy/psbt.properties', '--file-associations', 'src/main/deploy/txn.properties', '--file-associations', 'src/main/deploy/bitcoin.properties', '--license-file', 'LICENSE'] if(os.windows) { installerOptions += ['--win-per-user-install', '--win-dir-chooser', '--win-menu', '--win-menu-group', 'Sparrow', '--win-shortcut', '--resource-dir', 'src/main/deploy/package/windows/'] imageOptions += ['--icon', 'src/main/deploy/package/windows/sparrow.ico'] diff --git a/src/main/deploy/aopp.properties b/src/main/deploy/aopp.properties deleted file mode 100644 index 0f7aefb1..00000000 --- a/src/main/deploy/aopp.properties +++ /dev/null @@ -1,2 +0,0 @@ -mime-type=x-scheme-handler/aopp -description=Verify Address Ownership URI \ No newline at end of file diff --git a/src/main/deploy/package/linux/Sparrow.desktop b/src/main/deploy/package/linux/Sparrow.desktop index 594e5171..07af3c3f 100644 --- a/src/main/deploy/package/linux/Sparrow.desktop +++ b/src/main/deploy/package/linux/Sparrow.desktop @@ -6,4 +6,4 @@ Icon=/opt/sparrow/lib/Sparrow.png Terminal=false Type=Application Categories=Unknown -MimeType=application/psbt;application/bitcoin-transaction;x-scheme-handler/bitcoin;x-scheme-handler/aopp \ No newline at end of file +MimeType=application/psbt;application/bitcoin-transaction;x-scheme-handler/bitcoin \ No newline at end of file diff --git a/src/main/deploy/package/osx/Info.plist b/src/main/deploy/package/osx/Info.plist index fdefec4f..895d7a77 100644 --- a/src/main/deploy/package/osx/Info.plist +++ b/src/main/deploy/package/osx/Info.plist @@ -45,14 +45,6 @@ bitcoin - - CFBundleURLName - com.sparrowwallet.sparrow.aopp - CFBundleURLSchemes - - aopp - - UTImportedTypeDeclarations diff --git a/src/main/deploy/package/windows/main.wxs b/src/main/deploy/package/windows/main.wxs index 0703949d..5933cc6b 100644 --- a/src/main/deploy/package/windows/main.wxs +++ b/src/main/deploy/package/windows/main.wxs @@ -77,16 +77,6 @@ - - - - - - - - - - diff --git a/src/main/java/com/sparrowwallet/sparrow/AppServices.java b/src/main/java/com/sparrowwallet/sparrow/AppServices.java index 9c5af9fd..d33415b0 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppServices.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppServices.java @@ -794,8 +794,6 @@ public class AppServices { Platform.runLater(() -> { if("bitcoin".equals(uri.getScheme())) { openBitcoinUri(uri); - } else if("aopp".equals(uri.getScheme())) { - openAddressOwnershipProof(uri); } }); } @@ -830,20 +828,6 @@ public class AppServices { } } - public static void openAddressOwnershipProof(URI uri) { - try { - Aopp aopp = new Aopp(uri); - Wallet wallet = selectWallet(aopp.getScriptType(), "send proof of address"); - - if(wallet != null) { - EventManager.get().post(new ReceiveActionEvent(wallet)); - Platform.runLater(() -> EventManager.get().post(new ReceiveProofEvent(wallet, aopp))); - } - } catch(Exception e) { - showErrorDialog("Not a valid AOPP URI", e.getMessage()); - } - } - private static Wallet selectWallet(ScriptType scriptType, String actionDescription) { Wallet wallet = null; List wallets = get().getOpenWallets().keySet().stream().filter(w -> scriptType == null || w.getScriptType() == scriptType).collect(Collectors.toList()); diff --git a/src/main/java/com/sparrowwallet/sparrow/event/ReceiveProofEvent.java b/src/main/java/com/sparrowwallet/sparrow/event/ReceiveProofEvent.java deleted file mode 100644 index 2f1abf19..00000000 --- a/src/main/java/com/sparrowwallet/sparrow/event/ReceiveProofEvent.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.sparrowwallet.sparrow.event; - -import com.sparrowwallet.drongo.wallet.Wallet; -import com.sparrowwallet.sparrow.net.Aopp; - -public class ReceiveProofEvent { - private final Wallet wallet; - private final Aopp aopp; - - public ReceiveProofEvent(Wallet wallet, Aopp aopp) { - this.wallet = wallet; - this.aopp = aopp; - } - - public Wallet getWallet() { - return wallet; - } - - public Aopp getAopp() { - return aopp; - } -} diff --git a/src/main/java/com/sparrowwallet/sparrow/net/Aopp.java b/src/main/java/com/sparrowwallet/sparrow/net/Aopp.java deleted file mode 100644 index 6ff82b10..00000000 --- a/src/main/java/com/sparrowwallet/sparrow/net/Aopp.java +++ /dev/null @@ -1,167 +0,0 @@ -package com.sparrowwallet.sparrow.net; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.sparrowwallet.drongo.address.Address; -import com.sparrowwallet.drongo.protocol.ScriptType; -import com.sparrowwallet.sparrow.AppServices; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.*; -import java.net.*; -import java.nio.charset.StandardCharsets; -import java.util.LinkedHashMap; -import java.util.Map; - -public class Aopp { - private static final Logger log = LoggerFactory.getLogger(Aopp.class); - - public static final String SCHEME = "aopp"; - - private final int version; - private final String message; - private final ScriptType scriptType; - private final URL callback; - - public Aopp(URI uri) throws MalformedURLException { - if(!uri.getScheme().equals(SCHEME)) { - throw new IllegalArgumentException("Uri " + uri + " does not have the correct scheme"); - } - - Map parameterMap = new LinkedHashMap<>(); - String query = uri.getSchemeSpecificPart(); - if(query.startsWith("?")) { - query = query.substring(1); - } - - String[] pairs = query.split("&"); - for(String pair : pairs) { - int idx = pair.indexOf("="); - parameterMap.put(pair.substring(0, idx), pair.substring(idx + 1)); - } - - String strVersion = parameterMap.get("v"); - if(strVersion == null) { - throw new IllegalArgumentException("No version parameter provided"); - } - - version = Integer.parseInt(strVersion); - if(version != 0) { - throw new IllegalArgumentException("Unsupported version number " + version); - } - - String strMessage = parameterMap.get("msg"); - if(strMessage == null) { - throw new IllegalArgumentException("No msg parameter provided"); - } - message = strMessage.replace('+', ' '); - - String asset = parameterMap.get("asset"); - if(asset == null || !asset.equals("btc")) { - throw new IllegalArgumentException("Unsupported asset type " + asset); - } - - String format = parameterMap.get("format"); - if(format == null) { - throw new IllegalArgumentException("No format parameter provided"); - } - if(format.equals("p2sh")) { - format = "p2sh_p2wpkh"; - } - - if(format.equals("any")) { - scriptType = null; - } else { - scriptType = ScriptType.valueOf(format.toUpperCase()); - } - - String callbackUrl = parameterMap.get("callback"); - if(callbackUrl == null) { - throw new IllegalArgumentException("No callback parameter provided"); - } - - callback = new URL(callbackUrl); - } - - public void sendProofOfAddress(Address address, String signature) throws URISyntaxException, IOException, InterruptedException, AoppException { - Proxy proxy = AppServices.getProxy(); - - CallbackRequest callbackRequest = new CallbackRequest(version, address.toString(), signature); - Gson gson = new GsonBuilder().disableHtmlEscaping().create(); - String json = gson.toJson(callbackRequest); - - if(log.isDebugEnabled()) { - log.debug("Sending " + json + " to " + callback); - } - - HttpURLConnection connection = proxy == null ? (HttpURLConnection)callback.openConnection() : (HttpURLConnection)callback.openConnection(proxy); - connection.setRequestMethod("POST"); - connection.setRequestProperty("Content-Type", "application/json"); - connection.setDoOutput(true); - - try(OutputStream os = connection.getOutputStream()) { - byte[] jsonBytes = json.getBytes(StandardCharsets.UTF_8); - os.write(jsonBytes); - } - - StringBuilder response = new StringBuilder(); - try(BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) { - String responseLine; - while((responseLine = br.readLine()) != null) { - response.append(responseLine.trim()); - } - } - int statusCode = connection.getResponseCode(); - - if(log.isDebugEnabled()) { - log.debug("Received " + statusCode + " " + response); - } - - if(statusCode < 200 || statusCode >= 300) { - throw new AoppException("Could not send proof of ownership. Server returned " + response); - } - } - - public ScriptType getScriptType() { - return scriptType; - } - - public String getMessage() { - return message; - } - - public URL getCallback() { - return callback; - } - - private static class CallbackRequest { - public CallbackRequest(int version, String address, String signature) { - this.version = version; - this.address = address; - this.signature = signature; - } - - public int version; - public String address; - public String signature; - } - - public static final class AoppException extends Exception { - public AoppException(String message) { - super(message); - } - - public AoppException(String message, Throwable cause) { - super(message, cause); - } - - public AoppException(Throwable cause) { - super(cause); - } - - public AoppException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } - } -} diff --git a/src/main/java/com/sparrowwallet/sparrow/wallet/ReceiveController.java b/src/main/java/com/sparrowwallet/sparrow/wallet/ReceiveController.java index 827ee8e2..67a8e147 100644 --- a/src/main/java/com/sparrowwallet/sparrow/wallet/ReceiveController.java +++ b/src/main/java/com/sparrowwallet/sparrow/wallet/ReceiveController.java @@ -20,7 +20,6 @@ import com.sparrowwallet.sparrow.event.*; import com.sparrowwallet.sparrow.glyphfont.FontAwesome5; import com.sparrowwallet.sparrow.io.Device; import com.sparrowwallet.sparrow.io.Hwi; -import com.sparrowwallet.sparrow.net.Aopp; import javafx.application.Platform; import javafx.event.ActionEvent; import javafx.fxml.FXML; @@ -244,33 +243,6 @@ public class ReceiveController extends WalletFormController implements Initializ this.currentEntry = null; } - private void signAndSendProofOfAddress(Aopp aopp) { - if(currentEntry == null) { - Platform.runLater(() -> signAndSendProofOfAddress(aopp)); - } else { - try { - ButtonType signSendButtonType = new ButtonType("Sign & Send", ButtonBar.ButtonData.APPLY); - ButtonType cancelButtonType = new ButtonType("Cancel", ButtonBar.ButtonData.CANCEL_CLOSE); - MessageSignDialog messageSignDialog = new MessageSignDialog(getWalletForm().getWallet(), currentEntry.getNode(), "Send Proof of Address", aopp.getMessage(), signSendButtonType, cancelButtonType); - messageSignDialog.setElectrumSignatureFormat(true); - Stage stage = (Stage)messageSignDialog.getDialogPane().getScene().getWindow(); - stage.setAlwaysOnTop(true); - messageSignDialog.setOnShown(event -> { - stage.setAlwaysOnTop(false); - }); - Optional buttonData = messageSignDialog.showAndWait(); - if(buttonData.isPresent() && buttonData.get() == ButtonBar.ButtonData.OK_DONE) { - Address address = getWalletForm().getWallet().getAddress(currentEntry.getNode()); - String signature = messageSignDialog.getSignature(); - aopp.sendProofOfAddress(address, signature); - AppServices.showAlertDialog("Proof of Address Sent", "Proof of ownership of address\n" + address + "\nhas been successfully sent to\n" + aopp.getCallback().getHost() + ".", Alert.AlertType.INFORMATION); - } - } catch(Exception e) { - AppServices.showErrorDialog("Cannot send proof of ownership", e.getMessage()); - } - } - } - public static Glyph getUnusedGlyph() { Glyph checkGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.CHECK_CIRCLE); checkGlyph.getStyleClass().add("unused-check"); @@ -303,13 +275,6 @@ public class ReceiveController extends WalletFormController implements Initializ } } - @Subscribe - public void receiveProof(ReceiveProofEvent event) { - if(event.getWallet().equals(getWalletForm().getWallet())) { - Platform.runLater(() -> signAndSendProofOfAddress(event.getAopp())); - } - } - @Subscribe public void walletNodesChanged(WalletNodesChangedEvent event) { if(event.getWallet().equals(walletForm.getWallet())) {