mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-08-03 12:16:27 -04:00
Add deposit funds screen
This commit is contained in:
parent
605cf27eaf
commit
fa11cb4a6b
23 changed files with 675 additions and 37 deletions
|
@ -499,7 +499,7 @@ public class DisputeManager {
|
|||
contract.getBuyerPayoutAddressString(),
|
||||
contract.getSellerPayoutAddressString(),
|
||||
disputeResult.getArbitratorAddressAsString(),
|
||||
walletService.getAddressEntryByOfferId(dispute.getTradeId()),
|
||||
walletService.getTradeAddressEntry(dispute.getTradeId()),
|
||||
contract.getBuyerBtcPubKey(),
|
||||
contract.getSellerBtcPubKey(),
|
||||
disputeResult.getArbitratorPubKey()
|
||||
|
|
|
@ -44,8 +44,10 @@ public final class AddressEntry implements Persistable {
|
|||
private static final Logger log = LoggerFactory.getLogger(AddressEntry.class);
|
||||
|
||||
public enum Context {
|
||||
SAVINGS,
|
||||
TRADE,
|
||||
ARBITRATOR
|
||||
ARBITRATOR,
|
||||
DAO
|
||||
}
|
||||
|
||||
// keyPair can be null in case the object is created from deserialization as it is transient.
|
||||
|
|
|
@ -66,9 +66,16 @@ public final class AddressEntryList extends ArrayList<AddressEntry> implements P
|
|||
}
|
||||
}
|
||||
|
||||
public AddressEntry getNewAddressEntry(AddressEntry.Context context, String offerId) {
|
||||
public AddressEntry getNewTradeAddressEntry(String offerId) {
|
||||
log.trace("getNewAddressEntry called with offerId " + offerId);
|
||||
AddressEntry addressEntry = new AddressEntry(wallet.freshReceiveKey(), wallet.getParams(), context, offerId);
|
||||
AddressEntry addressEntry = new AddressEntry(wallet.freshReceiveKey(), wallet.getParams(), AddressEntry.Context.TRADE, offerId);
|
||||
add(addressEntry);
|
||||
storage.queueUpForSave();
|
||||
return addressEntry;
|
||||
}
|
||||
|
||||
public AddressEntry getNewSavingsAddressEntry() {
|
||||
AddressEntry addressEntry = new AddressEntry(wallet.freshReceiveKey(), wallet.getParams(), AddressEntry.Context.SAVINGS);
|
||||
add(addressEntry);
|
||||
storage.queueUpForSave();
|
||||
return addressEntry;
|
||||
|
|
|
@ -312,18 +312,28 @@ public class WalletService {
|
|||
return ImmutableList.copyOf(addressEntryList);
|
||||
}
|
||||
|
||||
public List<AddressEntry> getSavingsAddressEntryList() {
|
||||
return getAddressEntryList().stream()
|
||||
.filter(e -> e.getContext().equals(AddressEntry.Context.SAVINGS))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public AddressEntry getArbitratorAddressEntry() {
|
||||
return arbitratorAddressEntry;
|
||||
}
|
||||
|
||||
public AddressEntry getAddressEntryByOfferId(String offerId) {
|
||||
public AddressEntry getTradeAddressEntry(String offerId) {
|
||||
Optional<AddressEntry> addressEntry = getAddressEntryList().stream()
|
||||
.filter(e -> offerId.equals(e.getOfferId()))
|
||||
.findAny();
|
||||
if (addressEntry.isPresent())
|
||||
return addressEntry.get();
|
||||
else
|
||||
return addressEntryList.getNewAddressEntry(AddressEntry.Context.TRADE, offerId);
|
||||
return addressEntryList.getNewTradeAddressEntry(offerId);
|
||||
}
|
||||
|
||||
public AddressEntry getNewSavingsAddressEntry() {
|
||||
return addressEntryList.getNewSavingsAddressEntry();
|
||||
}
|
||||
|
||||
private Optional<AddressEntry> getAddressEntryByAddress(String address) {
|
||||
|
|
|
@ -302,7 +302,7 @@ public class TradeManager {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void onWithdrawRequest(String toAddress, KeyParameter aesKey, Trade trade, ResultHandler resultHandler, FaultHandler faultHandler) {
|
||||
AddressEntry addressEntry = walletService.getAddressEntryByOfferId(trade.getId());
|
||||
AddressEntry addressEntry = walletService.getTradeAddressEntry(trade.getId());
|
||||
String fromAddress = addressEntry.getAddressString();
|
||||
|
||||
FutureCallback<Transaction> callback = new FutureCallback<Transaction>() {
|
||||
|
|
|
@ -45,7 +45,7 @@ public class BroadcastCreateOfferFeeTx extends Task<PlaceOfferModel> {
|
|||
try {
|
||||
runInterceptHook();
|
||||
Coin totalsNeeded = FeePolicy.getSecurityDeposit().add(FeePolicy.getCreateOfferFee()).add(FeePolicy.getFixedTxFeeForTrades());
|
||||
AddressEntry addressEntry = model.walletService.getAddressEntryByOfferId(model.offer.getId());
|
||||
AddressEntry addressEntry = model.walletService.getTradeAddressEntry(model.offer.getId());
|
||||
Coin balance = model.walletService.getBalanceForAddress(addressEntry.getAddress());
|
||||
if (balance.compareTo(totalsNeeded) >= 0) {
|
||||
model.tradeWalletService.broadcastTx(model.getTransaction(), new FutureCallback<Transaction>() {
|
||||
|
|
|
@ -44,7 +44,7 @@ public class CreateOfferFeeTx extends Task<PlaceOfferModel> {
|
|||
log.debug("selectedArbitratorAddress " + selectedArbitratorNodeAddress);
|
||||
Arbitrator selectedArbitrator = model.user.getAcceptedArbitratorByAddress(selectedArbitratorNodeAddress);
|
||||
Transaction transaction = model.tradeWalletService.createTradingFeeTx(
|
||||
model.walletService.getAddressEntryByOfferId(model.offer.getId()),
|
||||
model.walletService.getTradeAddressEntry(model.offer.getId()),
|
||||
FeePolicy.getCreateOfferFee(),
|
||||
selectedArbitrator.getBtcAddress());
|
||||
|
||||
|
|
|
@ -180,7 +180,7 @@ public class ProcessModel implements Model, Serializable {
|
|||
}
|
||||
|
||||
public AddressEntry getAddressEntry() {
|
||||
return walletService.getAddressEntryByOfferId(offer.getId());
|
||||
return walletService.getTradeAddressEntry(offer.getId());
|
||||
}
|
||||
|
||||
public byte[] getTradeWalletPubKey() {
|
||||
|
|
|
@ -51,7 +51,7 @@ public class SetupDepositBalanceListener extends TradeTask {
|
|||
runInterceptHook();
|
||||
|
||||
WalletService walletService = processModel.getWalletService();
|
||||
Address address = walletService.getAddressEntryByOfferId(trade.getId()).getAddress();
|
||||
Address address = walletService.getTradeAddressEntry(trade.getId()).getAddress();
|
||||
balanceListener = new BalanceListener(address) {
|
||||
@Override
|
||||
public void onBalanceChanged(Coin balance, Transaction tx) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue