use of com.sparrowwallet.drongo.bip47.InvalidPaymentCodeException in project sparrow by sparrowwallet.
the class PaymentController method getRecipientAddress.
private Address getRecipientAddress() throws InvalidAddressException {
if (payNymProperty.get() == null) {
return Address.fromString(address.getText());
}
try {
Wallet recipientBip47Wallet = getWalletForPayNym(payNymProperty.get());
if (recipientBip47Wallet != null) {
WalletNode sendNode = recipientBip47Wallet.getFreshNode(KeyPurpose.SEND);
ECKey pubKey = sendNode.getPubKey();
Address address = recipientBip47Wallet.getScriptType().getAddress(pubKey);
if (sendController.getPaymentTabs().getTabs().size() > 1 || (getRecipientValueSats() != null && getRecipientValueSats() > getRecipientDustThreshold(address)) || maxButton.isSelected()) {
return address;
}
}
} catch (InvalidPaymentCodeException e) {
log.error("Error creating payment code from PayNym", e);
}
return new PayNymAddress(payNymProperty.get());
}
use of com.sparrowwallet.drongo.bip47.InvalidPaymentCodeException in project sparrow by sparrowwallet.
the class PayNymService method addPaymentCode.
public Observable<Map<String, Object>> addPaymentCode(PaymentCode paymentCode, String authToken, String signature, boolean segwit) {
String strPaymentCode;
try {
strPaymentCode = segwit ? paymentCode.makeSamouraiPaymentCode() : paymentCode.toString();
} catch (InvalidPaymentCodeException e) {
log.warn("Error creating segwit enabled payment code", e);
strPaymentCode = paymentCode.toString();
}
Map<String, String> headers = new HashMap<>();
headers.put("content-type", "application/json");
headers.put("auth-token", authToken);
HashMap<String, Object> body = new HashMap<>();
body.put("nym", paymentCode.toString());
body.put("code", strPaymentCode);
body.put("signature", signature);
IHttpClient httpClient = httpClientService.getHttpClient(HttpUsage.COORDINATOR_REST);
return httpClient.postJson("https://paynym.is/api/v1/nym/add", Map.class, headers, body).subscribeOn(Schedulers.io()).observeOn(JavaFxScheduler.platform()).map(Optional::get);
}
Aggregations