mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
remove aopp
This commit is contained in:
parent
526de33bdd
commit
c81f3d9f5d
9 changed files with 2 additions and 262 deletions
|
@ -210,7 +210,7 @@ jlink {
|
||||||
appVersion = "${sparrowVersion}"
|
appVersion = "${sparrowVersion}"
|
||||||
skipInstaller = os.macOsX || properties.skipInstallers
|
skipInstaller = os.macOsX || properties.skipInstallers
|
||||||
imageOptions = []
|
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) {
|
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/']
|
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']
|
imageOptions += ['--icon', 'src/main/deploy/package/windows/sparrow.ico']
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
mime-type=x-scheme-handler/aopp
|
|
||||||
description=Verify Address Ownership URI
|
|
|
@ -6,4 +6,4 @@ Icon=/opt/sparrow/lib/Sparrow.png
|
||||||
Terminal=false
|
Terminal=false
|
||||||
Type=Application
|
Type=Application
|
||||||
Categories=Unknown
|
Categories=Unknown
|
||||||
MimeType=application/psbt;application/bitcoin-transaction;x-scheme-handler/bitcoin;x-scheme-handler/aopp
|
MimeType=application/psbt;application/bitcoin-transaction;x-scheme-handler/bitcoin
|
|
@ -45,14 +45,6 @@
|
||||||
<string>bitcoin</string>
|
<string>bitcoin</string>
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
<dict>
|
|
||||||
<key>CFBundleURLName</key>
|
|
||||||
<string>com.sparrowwallet.sparrow.aopp</string>
|
|
||||||
<key>CFBundleURLSchemes</key>
|
|
||||||
<array>
|
|
||||||
<string>aopp</string>
|
|
||||||
</array>
|
|
||||||
</dict>
|
|
||||||
</array>
|
</array>
|
||||||
<key>UTImportedTypeDeclarations</key>
|
<key>UTImportedTypeDeclarations</key>
|
||||||
<array>
|
<array>
|
||||||
|
|
|
@ -77,16 +77,6 @@
|
||||||
|
|
||||||
<DirectoryRef Id="TARGETDIR">
|
<DirectoryRef Id="TARGETDIR">
|
||||||
<Component Id="RegistryEntries" Guid="{206C911C-56EF-44B8-9257-5FD214427965}">
|
<Component Id="RegistryEntries" Guid="{206C911C-56EF-44B8-9257-5FD214427965}">
|
||||||
<RegistryKey Root="HKCR" Key="aopp" Action="createAndRemoveOnUninstall">
|
|
||||||
<RegistryValue Type="string" Name="URL Protocol" Value=""/>
|
|
||||||
<RegistryValue Type="string" Value="URL:Address Ownership Proof Protocol"/>
|
|
||||||
<RegistryKey Key="DefaultIcon">
|
|
||||||
<RegistryValue Type="string" Value="$(var.JpAppName).exe" />
|
|
||||||
</RegistryKey>
|
|
||||||
<RegistryKey Key="shell\open\command">
|
|
||||||
<RegistryValue Type="string" Value=""[INSTALLDIR]$(var.JpAppName).exe" "%1"" />
|
|
||||||
</RegistryKey>
|
|
||||||
</RegistryKey>
|
|
||||||
<RegistryKey Root="HKCR" Key="bitcoin" Action="createAndRemoveOnUninstall">
|
<RegistryKey Root="HKCR" Key="bitcoin" Action="createAndRemoveOnUninstall">
|
||||||
<RegistryValue Type="string" Name="URL Protocol" Value=""/>
|
<RegistryValue Type="string" Name="URL Protocol" Value=""/>
|
||||||
<RegistryValue Type="string" Value="URL:Bitcoin Payment URL"/>
|
<RegistryValue Type="string" Value="URL:Bitcoin Payment URL"/>
|
||||||
|
|
|
@ -794,8 +794,6 @@ public class AppServices {
|
||||||
Platform.runLater(() -> {
|
Platform.runLater(() -> {
|
||||||
if("bitcoin".equals(uri.getScheme())) {
|
if("bitcoin".equals(uri.getScheme())) {
|
||||||
openBitcoinUri(uri);
|
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) {
|
private static Wallet selectWallet(ScriptType scriptType, String actionDescription) {
|
||||||
Wallet wallet = null;
|
Wallet wallet = null;
|
||||||
List<Wallet> wallets = get().getOpenWallets().keySet().stream().filter(w -> scriptType == null || w.getScriptType() == scriptType).collect(Collectors.toList());
|
List<Wallet> wallets = get().getOpenWallets().keySet().stream().filter(w -> scriptType == null || w.getScriptType() == scriptType).collect(Collectors.toList());
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -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<String, String> 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -20,7 +20,6 @@ import com.sparrowwallet.sparrow.event.*;
|
||||||
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5;
|
import com.sparrowwallet.sparrow.glyphfont.FontAwesome5;
|
||||||
import com.sparrowwallet.sparrow.io.Device;
|
import com.sparrowwallet.sparrow.io.Device;
|
||||||
import com.sparrowwallet.sparrow.io.Hwi;
|
import com.sparrowwallet.sparrow.io.Hwi;
|
||||||
import com.sparrowwallet.sparrow.net.Aopp;
|
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
@ -244,33 +243,6 @@ public class ReceiveController extends WalletFormController implements Initializ
|
||||||
this.currentEntry = null;
|
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<ButtonBar.ButtonData> 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() {
|
public static Glyph getUnusedGlyph() {
|
||||||
Glyph checkGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.CHECK_CIRCLE);
|
Glyph checkGlyph = new Glyph(FontAwesome5.FONT_NAME, FontAwesome5.Glyph.CHECK_CIRCLE);
|
||||||
checkGlyph.getStyleClass().add("unused-check");
|
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
|
@Subscribe
|
||||||
public void walletNodesChanged(WalletNodesChangedEvent event) {
|
public void walletNodesChanged(WalletNodesChangedEvent event) {
|
||||||
if(event.getWallet().equals(walletForm.getWallet())) {
|
if(event.getWallet().equals(walletForm.getWallet())) {
|
||||||
|
|
Loading…
Reference in a new issue