mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
accept bip21 uri in pay to field
This commit is contained in:
parent
a7a3ad012c
commit
389ce2180d
1 changed files with 24 additions and 11 deletions
|
@ -7,6 +7,7 @@ import com.sparrowwallet.drongo.address.InvalidAddressException;
|
||||||
import com.sparrowwallet.drongo.address.P2PKHAddress;
|
import com.sparrowwallet.drongo.address.P2PKHAddress;
|
||||||
import com.sparrowwallet.drongo.protocol.Transaction;
|
import com.sparrowwallet.drongo.protocol.Transaction;
|
||||||
import com.sparrowwallet.drongo.protocol.TransactionOutput;
|
import com.sparrowwallet.drongo.protocol.TransactionOutput;
|
||||||
|
import com.sparrowwallet.drongo.uri.BitcoinURI;
|
||||||
import com.sparrowwallet.drongo.wallet.MaxUtxoSelector;
|
import com.sparrowwallet.drongo.wallet.MaxUtxoSelector;
|
||||||
import com.sparrowwallet.drongo.wallet.Payment;
|
import com.sparrowwallet.drongo.wallet.Payment;
|
||||||
import com.sparrowwallet.drongo.wallet.UtxoSelector;
|
import com.sparrowwallet.drongo.wallet.UtxoSelector;
|
||||||
|
@ -22,9 +23,9 @@ import com.sparrowwallet.sparrow.event.ExchangeRatesUpdatedEvent;
|
||||||
import com.sparrowwallet.sparrow.event.FiatCurrencySelectedEvent;
|
import com.sparrowwallet.sparrow.event.FiatCurrencySelectedEvent;
|
||||||
import com.sparrowwallet.sparrow.io.Config;
|
import com.sparrowwallet.sparrow.io.Config;
|
||||||
import com.sparrowwallet.sparrow.io.ExchangeSource;
|
import com.sparrowwallet.sparrow.io.ExchangeSource;
|
||||||
|
import javafx.application.Platform;
|
||||||
import javafx.beans.value.ChangeListener;
|
import javafx.beans.value.ChangeListener;
|
||||||
import javafx.beans.value.ObservableValue;
|
import javafx.beans.value.ObservableValue;
|
||||||
import javafx.collections.ListChangeListener;
|
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.Initializable;
|
import javafx.fxml.Initializable;
|
||||||
|
@ -95,6 +96,14 @@ public class PaymentController extends WalletFormController implements Initializ
|
||||||
@Override
|
@Override
|
||||||
public void initializeView() {
|
public void initializeView() {
|
||||||
address.textProperty().addListener((observable, oldValue, newValue) -> {
|
address.textProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
|
try {
|
||||||
|
BitcoinURI bitcoinURI = new BitcoinURI(newValue);
|
||||||
|
Platform.runLater(() -> updateFromURI(bitcoinURI));
|
||||||
|
return;
|
||||||
|
} catch(Exception e) {
|
||||||
|
//ignore, not a URI
|
||||||
|
}
|
||||||
|
|
||||||
revalidate(amount, amountListener);
|
revalidate(amount, amountListener);
|
||||||
maxButton.setDisable(!isValidRecipientAddress());
|
maxButton.setDisable(!isValidRecipientAddress());
|
||||||
sendController.updateTransaction();
|
sendController.updateTransaction();
|
||||||
|
@ -291,19 +300,23 @@ public class PaymentController extends WalletFormController implements Initializ
|
||||||
if(optionalResult.isPresent()) {
|
if(optionalResult.isPresent()) {
|
||||||
QRScanDialog.Result result = optionalResult.get();
|
QRScanDialog.Result result = optionalResult.get();
|
||||||
if(result.uri != null) {
|
if(result.uri != null) {
|
||||||
if(result.uri.getAddress() != null) {
|
updateFromURI(result.uri);
|
||||||
address.setText(result.uri.getAddress().toString());
|
|
||||||
}
|
}
|
||||||
if(result.uri.getLabel() != null) {
|
|
||||||
label.setText(result.uri.getLabel());
|
|
||||||
}
|
}
|
||||||
if(result.uri.getAmount() != null) {
|
}
|
||||||
setRecipientValueSats(result.uri.getAmount());
|
|
||||||
|
private void updateFromURI(BitcoinURI bitcoinURI) {
|
||||||
|
if(bitcoinURI.getAddress() != null) {
|
||||||
|
address.setText(bitcoinURI.getAddress().toString());
|
||||||
|
}
|
||||||
|
if(bitcoinURI.getLabel() != null) {
|
||||||
|
label.setText(bitcoinURI.getLabel());
|
||||||
|
}
|
||||||
|
if(bitcoinURI.getAmount() != null) {
|
||||||
|
setRecipientValueSats(bitcoinURI.getAmount());
|
||||||
}
|
}
|
||||||
sendController.updateTransaction();
|
sendController.updateTransaction();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addPayment(ActionEvent event) {
|
public void addPayment(ActionEvent event) {
|
||||||
sendController.addPaymentTab();
|
sendController.addPaymentTab();
|
||||||
|
|
Loading…
Reference in a new issue