mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-05-15 21:12:14 -04:00
use default country in bank account
This commit is contained in:
parent
fc85a8ee17
commit
ac2b8e3f41
8 changed files with 35 additions and 33 deletions
|
@ -61,7 +61,7 @@ public class WalletFacade
|
||||||
private Wallet wallet;
|
private Wallet wallet;
|
||||||
private WalletEventListener walletEventListener;
|
private WalletEventListener walletEventListener;
|
||||||
private AddressEntry registrationAddressEntry;
|
private AddressEntry registrationAddressEntry;
|
||||||
private AddressEntry arbitratorDepositAddressInfo;
|
private AddressEntry arbitratorDepositAddressEntry;
|
||||||
|
|
||||||
@GuardedBy("lock")
|
@GuardedBy("lock")
|
||||||
private List<AddressEntry> addressEntryList = new ArrayList<>();
|
private List<AddressEntry> addressEntryList = new ArrayList<>();
|
||||||
|
@ -201,6 +201,7 @@ public class WalletFacade
|
||||||
persistedAddressEntry.setDeterministicKey((DeterministicKey) wallet.findKeyFromPubHash(persistedAddressEntry.getPubKeyHash()));
|
persistedAddressEntry.setDeterministicKey((DeterministicKey) wallet.findKeyFromPubHash(persistedAddressEntry.getPubKeyHash()));
|
||||||
}
|
}
|
||||||
addressEntryList = persistedAddressEntryList;
|
addressEntryList = persistedAddressEntryList;
|
||||||
|
registrationAddressEntry = addressEntryList.get(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -273,22 +274,22 @@ public class WalletFacade
|
||||||
return ImmutableList.copyOf(addressEntryList);
|
return ImmutableList.copyOf(addressEntryList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AddressEntry getRegistrationAddressInfo()
|
public AddressEntry getRegistrationAddressEntry()
|
||||||
{
|
{
|
||||||
return registrationAddressEntry;
|
return registrationAddressEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AddressEntry getArbitratorDepositAddressInfo()
|
public AddressEntry getArbitratorDepositAddressEntry()
|
||||||
{
|
{
|
||||||
if (arbitratorDepositAddressInfo == null)
|
if (arbitratorDepositAddressEntry == null)
|
||||||
arbitratorDepositAddressInfo = getNewAddressEntry(AddressEntry.AddressContext.ARBITRATOR_DEPOSIT, null);
|
arbitratorDepositAddressEntry = getNewAddressEntry(AddressEntry.AddressContext.ARBITRATOR_DEPOSIT, null);
|
||||||
|
|
||||||
return arbitratorDepositAddressInfo;
|
return arbitratorDepositAddressEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AddressEntry getAddressInfoByTradeID(String offerId)
|
public AddressEntry getAddressInfoByTradeID(String offerId)
|
||||||
{
|
{
|
||||||
Optional<AddressEntry> addressEntry = getAddressEntryList().stream().filter(e -> e.getOfferId().equals(offerId)).findFirst();
|
Optional<AddressEntry> addressEntry = getAddressEntryList().stream().filter(e -> offerId.equals(e.getOfferId())).findFirst();
|
||||||
|
|
||||||
if (addressEntry.isPresent())
|
if (addressEntry.isPresent())
|
||||||
return addressEntry.get();
|
return addressEntry.get();
|
||||||
|
@ -316,7 +317,7 @@ public class WalletFacade
|
||||||
|
|
||||||
private Optional<AddressEntry> getAddressEntryByAddressString(String address)
|
private Optional<AddressEntry> getAddressEntryByAddressString(String address)
|
||||||
{
|
{
|
||||||
return getAddressEntryList().stream().filter(e -> e.getAddressString().equals(address)).findFirst();
|
return getAddressEntryList().stream().filter(e -> address.equals(e.getAddressString())).findFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -359,7 +360,7 @@ public class WalletFacade
|
||||||
List<TransactionOutput> mergedOutputs = getOutputsWithConnectedOutputs(tx);
|
List<TransactionOutput> mergedOutputs = getOutputsWithConnectedOutputs(tx);
|
||||||
List<TransactionConfidence> transactionConfidenceList = new ArrayList<>();
|
List<TransactionConfidence> transactionConfidenceList = new ArrayList<>();
|
||||||
|
|
||||||
mergedOutputs.stream().filter(transactionOutput -> transactionOutput.getScriptPubKey().isSentToAddress() || transactionOutput.getScriptPubKey().isSentToP2SH()).forEach(transactionOutput -> {
|
mergedOutputs.stream().filter(e -> e.getScriptPubKey().isSentToAddress() || e.getScriptPubKey().isSentToP2SH()).forEach(transactionOutput -> {
|
||||||
Address outputAddress = transactionOutput.getScriptPubKey().getToAddress(params);
|
Address outputAddress = transactionOutput.getScriptPubKey().getToAddress(params);
|
||||||
if (address.equals(outputAddress))
|
if (address.equals(outputAddress))
|
||||||
{
|
{
|
||||||
|
@ -432,9 +433,9 @@ public class WalletFacade
|
||||||
public boolean isRegistrationFeeConfirmed()
|
public boolean isRegistrationFeeConfirmed()
|
||||||
{
|
{
|
||||||
TransactionConfidence transactionConfidence = null;
|
TransactionConfidence transactionConfidence = null;
|
||||||
if (getRegistrationAddressInfo() != null)
|
if (getRegistrationAddressEntry() != null)
|
||||||
{
|
{
|
||||||
transactionConfidence = getConfidenceForAddress(getRegistrationAddressInfo().getAddress());
|
transactionConfidence = getConfidenceForAddress(getRegistrationAddressEntry().getAddress());
|
||||||
}
|
}
|
||||||
return transactionConfidence != null && transactionConfidence.getConfidenceType().equals(TransactionConfidence.ConfidenceType.BUILDING);
|
return transactionConfidence != null && transactionConfidence.getConfidenceType().equals(TransactionConfidence.ConfidenceType.BUILDING);
|
||||||
}
|
}
|
||||||
|
@ -491,12 +492,12 @@ public class WalletFacade
|
||||||
|
|
||||||
Coin getRegistrationBalance()
|
Coin getRegistrationBalance()
|
||||||
{
|
{
|
||||||
return getBalanceForAddress(getRegistrationAddressInfo().getAddress());
|
return getBalanceForAddress(getRegistrationAddressEntry().getAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Coin getArbitratorDepositBalance()
|
public Coin getArbitratorDepositBalance()
|
||||||
{
|
{
|
||||||
return getBalanceForAddress(getArbitratorDepositAddressInfo().getAddress());
|
return getBalanceForAddress(getArbitratorDepositAddressEntry().getAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRegistrationFeeBalanceNonZero()
|
public boolean isRegistrationFeeBalanceNonZero()
|
||||||
|
@ -543,7 +544,7 @@ public class WalletFacade
|
||||||
|
|
||||||
Transaction tx = new Transaction(params);
|
Transaction tx = new Transaction(params);
|
||||||
|
|
||||||
byte[] data = cryptoFacade.getEmbeddedAccountRegistrationData(getRegistrationAddressInfo().getKey(), stringifiedBankAccounts);
|
byte[] data = cryptoFacade.getEmbeddedAccountRegistrationData(getRegistrationAddressEntry().getKey(), stringifiedBankAccounts);
|
||||||
tx.addOutput(Transaction.MIN_NONDUST_OUTPUT, new ScriptBuilder().op(OP_RETURN).data(data).build());
|
tx.addOutput(Transaction.MIN_NONDUST_OUTPUT, new ScriptBuilder().op(OP_RETURN).data(data).build());
|
||||||
|
|
||||||
Coin fee = FeePolicy.ACCOUNT_REGISTRATION_FEE.subtract(Transaction.MIN_NONDUST_OUTPUT).subtract(FeePolicy.TX_FEE);
|
Coin fee = FeePolicy.ACCOUNT_REGISTRATION_FEE.subtract(Transaction.MIN_NONDUST_OUTPUT).subtract(FeePolicy.TX_FEE);
|
||||||
|
@ -554,8 +555,8 @@ public class WalletFacade
|
||||||
sendRequest.shuffleOutputs = false;
|
sendRequest.shuffleOutputs = false;
|
||||||
// we don't allow spending of unconfirmed tx as with fake registrations we would open up doors for spam and market manipulation with fake offers
|
// we don't allow spending of unconfirmed tx as with fake registrations we would open up doors for spam and market manipulation with fake offers
|
||||||
// so set includePending to false
|
// so set includePending to false
|
||||||
sendRequest.coinSelector = new AddressBasedCoinSelector(params, getRegistrationAddressInfo(), false);
|
sendRequest.coinSelector = new AddressBasedCoinSelector(params, getRegistrationAddressEntry(), false);
|
||||||
sendRequest.changeAddress = getRegistrationAddressInfo().getAddress();
|
sendRequest.changeAddress = getRegistrationAddressEntry().getAddress();
|
||||||
Wallet.SendResult sendResult = wallet.sendCoins(sendRequest);
|
Wallet.SendResult sendResult = wallet.sendCoins(sendRequest);
|
||||||
//Object k = getRegistrationAddressInfo().getKey();
|
//Object k = getRegistrationAddressInfo().getKey();
|
||||||
Futures.addCallback(sendResult.broadcastComplete, callback);
|
Futures.addCallback(sendResult.broadcastComplete, callback);
|
||||||
|
|
|
@ -367,7 +367,7 @@ public class ArbitratorRegistrationController extends CachedViewController
|
||||||
"Please pay in " + arbitrator.getMaxTradeVolume() * 10 + " BTC");
|
"Please pay in " + arbitrator.getMaxTradeVolume() * 10 + " BTC");
|
||||||
|
|
||||||
|
|
||||||
String collateralAddress = walletFacade.getRegistrationAddressInfo() != null ? walletFacade.getRegistrationAddressInfo().toString() : "";
|
String collateralAddress = walletFacade.getRegistrationAddressEntry() != null ? walletFacade.getRegistrationAddressEntry().toString() : "";
|
||||||
collateralAddressTextField.setText(collateralAddress);
|
collateralAddressTextField.setText(collateralAddress);
|
||||||
|
|
||||||
AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY);
|
AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY);
|
||||||
|
@ -478,7 +478,7 @@ public class ArbitratorRegistrationController extends CachedViewController
|
||||||
arbitrationFeeTextField,
|
arbitrationFeeTextField,
|
||||||
minArbitrationFeeTextField);
|
minArbitrationFeeTextField);
|
||||||
|
|
||||||
String pubKeyAsHex = walletFacade.getArbitratorDepositAddressInfo().getPubKeyAsHexString();
|
String pubKeyAsHex = walletFacade.getArbitratorDepositAddressEntry().getPubKeyAsHexString();
|
||||||
String messagePubKeyAsHex = DSAKeyUtil.getHexStringFromPublicKey(user.getMessagePublicKey());
|
String messagePubKeyAsHex = DSAKeyUtil.getHexStringFromPublicKey(user.getMessagePublicKey());
|
||||||
String name = nameTextField.getText();
|
String name = nameTextField.getText();
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,8 @@ import javafx.beans.property.StringProperty;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.Tooltip;
|
import javafx.scene.control.Tooltip;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
public class WithdrawalListItem
|
public class WithdrawalListItem
|
||||||
{
|
{
|
||||||
private final StringProperty addressString = new SimpleStringProperty();
|
private final StringProperty addressString = new SimpleStringProperty();
|
||||||
|
@ -122,14 +124,8 @@ public class WithdrawalListItem
|
||||||
case REGISTRATION_FEE:
|
case REGISTRATION_FEE:
|
||||||
return "Registration fee";
|
return "Registration fee";
|
||||||
case TRADE:
|
case TRADE:
|
||||||
if (addressEntry.getOfferId() != null)
|
checkNotNull(addressEntry.getOfferId());
|
||||||
{
|
return "Offer ID: " + addressEntry.getOfferId();
|
||||||
return "Trade ID: " + addressEntry.getOfferId();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return "Trade (not used yet)";
|
|
||||||
}
|
|
||||||
case ARBITRATOR_DEPOSIT:
|
case ARBITRATOR_DEPOSIT:
|
||||||
return "Arbitration deposit";
|
return "Arbitration deposit";
|
||||||
}
|
}
|
||||||
|
|
|
@ -567,7 +567,11 @@ public class SettingsController extends CachedViewController
|
||||||
bankAccountTypesComboBox.getSelectionModel().selectFirst();
|
bankAccountTypesComboBox.getSelectionModel().selectFirst();
|
||||||
bankAccountCurrencyComboBox.getSelectionModel().selectFirst();
|
bankAccountCurrencyComboBox.getSelectionModel().selectFirst();
|
||||||
bankAccountRegionComboBox.getSelectionModel().select(3);
|
bankAccountRegionComboBox.getSelectionModel().select(3);
|
||||||
bankAccountCountryComboBox.getSelectionModel().select(5);
|
|
||||||
|
Optional<Country> country = bankAccountCountryComboBox.getItems().stream().filter(e -> e.getCode().equals(CountryUtil.getDefaultCountry().getCode())).findFirst();
|
||||||
|
if (country.isPresent())
|
||||||
|
bankAccountCountryComboBox.getSelectionModel().select(country.get());
|
||||||
|
|
||||||
bankAccountTitleTextField.setText("dummy title");
|
bankAccountTitleTextField.setText("dummy title");
|
||||||
bankAccountHolderNameTextField.setText("dummy name");
|
bankAccountHolderNameTextField.setText("dummy name");
|
||||||
bankAccountPrimaryIDTextField.setText("dummy primary ID");
|
bankAccountPrimaryIDTextField.setText("dummy primary ID");
|
||||||
|
|
|
@ -103,6 +103,9 @@ public class CreateOfferController extends CachedViewController
|
||||||
{
|
{
|
||||||
super.initialize(url, rb);
|
super.initialize(url, rb);
|
||||||
|
|
||||||
|
setupBindings();
|
||||||
|
setupValidation();
|
||||||
|
|
||||||
//TODO just for dev testing
|
//TODO just for dev testing
|
||||||
if (BitSquare.fillFormsWithDummyData)
|
if (BitSquare.fillFormsWithDummyData)
|
||||||
{
|
{
|
||||||
|
@ -111,8 +114,6 @@ public class CreateOfferController extends CachedViewController
|
||||||
priceTextField.setText("" + (int) (499 - new Random().nextDouble() * 1000 / 100));
|
priceTextField.setText("" + (int) (499 - new Random().nextDouble() * 1000 / 100));
|
||||||
}
|
}
|
||||||
|
|
||||||
setupBindings();
|
|
||||||
setupValidation();
|
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
if (walletFacade.getWallet() != null)
|
if (walletFacade.getWallet() != null)
|
||||||
|
|
|
@ -344,9 +344,9 @@ public class OrderBookController extends CachedViewController
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
walletFacade.payRegistrationFee(user.getStringifiedBankAccounts(), callback);
|
walletFacade.payRegistrationFee(user.getStringifiedBankAccounts(), callback);
|
||||||
if (walletFacade.getRegistrationAddressInfo() != null)
|
if (walletFacade.getRegistrationAddressEntry() != null)
|
||||||
{
|
{
|
||||||
user.setAccountID(walletFacade.getRegistrationAddressInfo().toString());
|
user.setAccountID(walletFacade.getRegistrationAddressEntry().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
persistence.write(user.getClass().getName(), user);
|
persistence.write(user.getClass().getName(), user);
|
||||||
|
|
|
@ -132,7 +132,7 @@ public class ProtocolForOffererAsBuyer
|
||||||
accountId = user.getAccountId();
|
accountId = user.getAccountId();
|
||||||
messagePublicKey = user.getMessagePublicKey();
|
messagePublicKey = user.getMessagePublicKey();
|
||||||
|
|
||||||
accountKey = walletFacade.getRegistrationAddressInfo().getKey();
|
accountKey = walletFacade.getRegistrationAddressEntry().getKey();
|
||||||
payoutAddress = walletFacade.getAddressInfoByTradeID(tradeId).getAddressString();
|
payoutAddress = walletFacade.getAddressInfoByTradeID(tradeId).getAddressString();
|
||||||
|
|
||||||
state = State.Init;
|
state = State.Init;
|
||||||
|
|
|
@ -130,7 +130,7 @@ public class ProtocolForTakerAsSeller
|
||||||
messagePublicKey = user.getMessagePublicKey();
|
messagePublicKey = user.getMessagePublicKey();
|
||||||
|
|
||||||
pubKeyForThatTrade = walletFacade.getAddressInfoByTradeID(tradeId).getPubKeyAsHexString();
|
pubKeyForThatTrade = walletFacade.getAddressInfoByTradeID(tradeId).getPubKeyAsHexString();
|
||||||
accountKey = walletFacade.getRegistrationAddressInfo().getKey();
|
accountKey = walletFacade.getRegistrationAddressEntry().getKey();
|
||||||
|
|
||||||
state = State.Init;
|
state = State.Init;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue