mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
only allow sending to paynyms where a notification transaction has previously been sent
This commit is contained in:
parent
60aa20ac55
commit
22303a2efc
2 changed files with 26 additions and 3 deletions
|
@ -321,7 +321,9 @@ public class PayNymController {
|
||||||
|
|
||||||
public boolean isLinked(PayNym payNym) {
|
public boolean isLinked(PayNym payNym) {
|
||||||
PaymentCode externalPaymentCode = payNym.paymentCode();
|
PaymentCode externalPaymentCode = payNym.paymentCode();
|
||||||
return getMasterWallet().getChildWallet(externalPaymentCode, payNym.segwit() ? ScriptType.P2WPKH : ScriptType.P2PKH) != null;
|
//As per BIP47 a notification transaction must have been sent from this wallet to enable the recipient to restore funds from seed
|
||||||
|
return getMasterWallet().getChildWallet(externalPaymentCode, payNym.segwit() ? ScriptType.P2WPKH : ScriptType.P2PKH) != null
|
||||||
|
&& !getNotificationTransaction(externalPaymentCode).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateFollowing() {
|
public void updateFollowing() {
|
||||||
|
@ -356,7 +358,7 @@ public class PayNymController {
|
||||||
for(PayNym payNym : following) {
|
for(PayNym payNym : following) {
|
||||||
if(!isLinked(payNym)) {
|
if(!isLinked(payNym)) {
|
||||||
PaymentCode externalPaymentCode = payNym.paymentCode();
|
PaymentCode externalPaymentCode = payNym.paymentCode();
|
||||||
Map<BlockTransaction, WalletNode> unlinkedNotification = getMasterWallet().getNotificationTransaction(externalPaymentCode);
|
Map<BlockTransaction, WalletNode> unlinkedNotification = getNotificationTransaction(externalPaymentCode);
|
||||||
if(!unlinkedNotification.isEmpty() && !INVALID_PAYMENT_CODE_LABEL.equals(unlinkedNotification.keySet().iterator().next().getLabel())) {
|
if(!unlinkedNotification.isEmpty() && !INVALID_PAYMENT_CODE_LABEL.equals(unlinkedNotification.keySet().iterator().next().getLabel())) {
|
||||||
unlinkedNotifications.putAll(unlinkedNotification);
|
unlinkedNotifications.putAll(unlinkedNotification);
|
||||||
unlinkedPayNyms.put(unlinkedNotification.keySet().iterator().next(), payNym);
|
unlinkedPayNyms.put(unlinkedNotification.keySet().iterator().next(), payNym);
|
||||||
|
@ -607,6 +609,22 @@ public class PayNymController {
|
||||||
return wallet.createWalletTransaction(utxoSelectors, utxoFilters, payments, opReturns, Collections.emptySet(), feeRate, minimumFeeRate, null, AppServices.getCurrentBlockHeight(), groupByAddress, includeMempoolOutputs, false);
|
return wallet.createWalletTransaction(utxoSelectors, utxoFilters, payments, opReturns, Collections.emptySet(), feeRate, minimumFeeRate, null, AppServices.getCurrentBlockHeight(), groupByAddress, includeMempoolOutputs, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<BlockTransaction, WalletNode> getNotificationTransaction(PaymentCode externalPaymentCode) {
|
||||||
|
Map<BlockTransaction, WalletNode> notificationTransaction = getMasterWallet().getNotificationTransaction(externalPaymentCode);
|
||||||
|
if(notificationTransaction.isEmpty()) {
|
||||||
|
for(Wallet childWallet : getMasterWallet().getChildWallets()) {
|
||||||
|
if(!childWallet.isNested()) {
|
||||||
|
notificationTransaction = childWallet.getNotificationTransaction(externalPaymentCode);
|
||||||
|
if(!notificationTransaction.isEmpty()) {
|
||||||
|
return notificationTransaction;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return notificationTransaction;
|
||||||
|
}
|
||||||
|
|
||||||
public Wallet getMasterWallet() {
|
public Wallet getMasterWallet() {
|
||||||
Wallet wallet = AppServices.get().getWallet(walletId);
|
Wallet wallet = AppServices.get().getWallet(walletId);
|
||||||
return wallet.isMasterWallet() ? wallet : wallet.getMasterWallet();
|
return wallet.isMasterWallet() ? wallet : wallet.getMasterWallet();
|
||||||
|
|
|
@ -90,7 +90,12 @@ public class WalletController extends WalletFormController implements Initializa
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(!existing) {
|
if(!existing) {
|
||||||
FXMLLoader functionLoader = new FXMLLoader(AppServices.class.getResource("wallet/" + function.toString().toLowerCase() + ".fxml"));
|
URL url = AppServices.class.getResource("wallet/" + function.toString().toLowerCase() + ".fxml");
|
||||||
|
if(url == null) {
|
||||||
|
throw new IllegalStateException("Cannot find wallet/" + function.toString().toLowerCase() + ".fxml");
|
||||||
|
}
|
||||||
|
|
||||||
|
FXMLLoader functionLoader = new FXMLLoader(url);
|
||||||
Node walletFunction = functionLoader.load();
|
Node walletFunction = functionLoader.load();
|
||||||
walletFunction.setUserData(function);
|
walletFunction.setUserData(function);
|
||||||
WalletFormController controller = functionLoader.getController();
|
WalletFormController controller = functionLoader.getController();
|
||||||
|
|
Loading…
Reference in a new issue