Replace 'Facade' naming with 'Service' naming

This commit is contained in:
Chris Beams 2014-11-12 10:49:50 +01:00
parent 526727134f
commit 80758a0a47
No known key found for this signature in database
GPG key ID: 3D214F8F5BC5ED73
61 changed files with 372 additions and 372 deletions

View file

@ -19,7 +19,7 @@ package io.bitsquare.app;
import io.bitsquare.BitsquareException; import io.bitsquare.BitsquareException;
import io.bitsquare.btc.UserAgent; import io.bitsquare.btc.UserAgent;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.gui.ViewCB; import io.bitsquare.gui.ViewCB;
import io.bitsquare.persistence.Persistence; import io.bitsquare.persistence.Persistence;
@ -115,8 +115,8 @@ public class BitsquareEnvironment extends StandardEnvironment {
setProperty(UserAgent.NAME_KEY, appName); setProperty(UserAgent.NAME_KEY, appName);
setProperty(UserAgent.VERSION_KEY, BitsquareEnvironment.this.getRequiredProperty(APP_VERSION_KEY)); setProperty(UserAgent.VERSION_KEY, BitsquareEnvironment.this.getRequiredProperty(APP_VERSION_KEY));
setProperty(WalletFacade.DIR_KEY, appDataDir); setProperty(WalletService.DIR_KEY, appDataDir);
setProperty(WalletFacade.PREFIX_KEY, appName); setProperty(WalletService.PREFIX_KEY, appName);
setProperty(Persistence.DIR_KEY, appDataDir); setProperty(Persistence.DIR_KEY, appDataDir);
setProperty(Persistence.PREFIX_KEY, appName + "_pref"); setProperty(Persistence.PREFIX_KEY, appName + "_pref");

View file

@ -50,17 +50,17 @@ public class BitcoinModule extends BitsquareModule {
bindConstant().annotatedWith(named(UserAgent.VERSION_KEY)).to(env.getRequiredProperty(UserAgent.VERSION_KEY)); bindConstant().annotatedWith(named(UserAgent.VERSION_KEY)).to(env.getRequiredProperty(UserAgent.VERSION_KEY));
bind(UserAgent.class).asEagerSingleton(); bind(UserAgent.class).asEagerSingleton();
File walletDir = new File(env.getRequiredProperty(WalletFacade.DIR_KEY)); File walletDir = new File(env.getRequiredProperty(WalletService.DIR_KEY));
bind(File.class).annotatedWith(named(WalletFacade.DIR_KEY)).toInstance(walletDir); bind(File.class).annotatedWith(named(WalletService.DIR_KEY)).toInstance(walletDir);
bindConstant().annotatedWith(named(WalletFacade.PREFIX_KEY)).to(env.getRequiredProperty(WalletFacade.PREFIX_KEY)); bindConstant().annotatedWith(named(WalletService.PREFIX_KEY)).to(env.getRequiredProperty(WalletService.PREFIX_KEY));
bind(WalletFacade.class).asEagerSingleton(); bind(WalletService.class).asEagerSingleton();
bind(BlockChainFacade.class).asEagerSingleton(); bind(BlockChainService.class).asEagerSingleton();
} }
@Override @Override
protected void doClose(Injector injector) { protected void doClose(Injector injector) {
injector.getInstance(WalletFacade.class).shutDown(); injector.getInstance(WalletService.class).shutDown();
} }
private NetworkParameters network() { private NetworkParameters network() {

View file

@ -22,11 +22,11 @@ import io.bitsquare.bank.BankAccount;
import javax.inject.Inject; import javax.inject.Inject;
/** /**
* A facade delivers blockchain functionality from the BitcoinJ library. * A service delivers blockchain functionality from the BitcoinJ library.
*/ */
public class BlockChainFacade { public class BlockChainService {
@Inject @Inject
public BlockChainFacade() { public BlockChainService() {
} }

View file

@ -20,7 +20,7 @@ package io.bitsquare.btc;
import io.bitsquare.btc.listeners.AddressConfidenceListener; import io.bitsquare.btc.listeners.AddressConfidenceListener;
import io.bitsquare.btc.listeners.BalanceListener; import io.bitsquare.btc.listeners.BalanceListener;
import io.bitsquare.btc.listeners.TxConfidenceListener; import io.bitsquare.btc.listeners.TxConfidenceListener;
import io.bitsquare.crypto.CryptoFacade; import io.bitsquare.crypto.CryptoService;
import io.bitsquare.persistence.Persistence; import io.bitsquare.persistence.Persistence;
import org.bitcoinj.core.Address; import org.bitcoinj.core.Address;
@ -91,8 +91,8 @@ import static org.bitcoinj.script.ScriptOpCodes.OP_RETURN;
* TODO: use walletextension (with protobuffer) instead of saving addressEntryList via storage * TODO: use walletextension (with protobuffer) instead of saving addressEntryList via storage
* TODO: break that class up. maybe a bitsquarewallet * TODO: break that class up. maybe a bitsquarewallet
*/ */
public class WalletFacade { public class WalletService {
private static final Logger log = LoggerFactory.getLogger(WalletFacade.class); private static final Logger log = LoggerFactory.getLogger(WalletService.class);
private static final String LOCK_NAME = "lock"; private static final String LOCK_NAME = "lock";
public static final String DIR_KEY = "wallet.dir"; public static final String DIR_KEY = "wallet.dir";
@ -105,7 +105,7 @@ public class WalletFacade {
private final NetworkParameters params; private final NetworkParameters params;
private final FeePolicy feePolicy; private final FeePolicy feePolicy;
private final CryptoFacade cryptoFacade; private final CryptoService cryptoService;
private final Persistence persistence; private final Persistence persistence;
private final File walletDir; private final File walletDir;
private final String walletPrefix; private final String walletPrefix;
@ -123,12 +123,12 @@ public class WalletFacade {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Inject @Inject
public WalletFacade(NetworkParameters params, FeePolicy feePolicy, CryptoFacade cryptoFacade, public WalletService(NetworkParameters params, FeePolicy feePolicy, CryptoService cryptoService,
Persistence persistence, UserAgent userAgent, Persistence persistence, UserAgent userAgent,
@Named(DIR_KEY) File walletDir, @Named(PREFIX_KEY) String walletPrefix) { @Named(DIR_KEY) File walletDir, @Named(PREFIX_KEY) String walletPrefix) {
this.params = params; this.params = params;
this.feePolicy = feePolicy; this.feePolicy = feePolicy;
this.cryptoFacade = cryptoFacade; this.cryptoService = cryptoService;
this.persistence = persistence; this.persistence = persistence;
this.walletDir = walletDir; this.walletDir = walletDir;
this.walletPrefix = walletPrefix; this.walletPrefix = walletPrefix;
@ -555,7 +555,7 @@ public class WalletFacade {
Transaction tx = new Transaction(params); Transaction tx = new Transaction(params);
byte[] data = cryptoFacade.getEmbeddedAccountRegistrationData( byte[] data = cryptoService.getEmbeddedAccountRegistrationData(
getRegistrationAddressEntry().getKey(), stringifiedBankAccounts); 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());

View file

@ -29,6 +29,6 @@ public class CryptoModule extends BitsquareModule {
@Override @Override
protected void configure() { protected void configure() {
bind(CryptoFacade.class).asEagerSingleton(); bind(CryptoService.class).asEagerSingleton();
} }
} }

View file

@ -39,15 +39,15 @@ import org.spongycastle.crypto.params.KeyParameter;
import org.spongycastle.util.encoders.Base64; import org.spongycastle.util.encoders.Base64;
/** /**
* That facade delivers crypto functionality from the bitcoinJ library * That service delivers crypto functionality from the bitcoinJ library
* //TODO still very basic as not much used yet, missing implementations * //TODO still very basic as not much used yet, missing implementations
*/ */
public class CryptoFacade { public class CryptoService {
private static final Logger log = LoggerFactory.getLogger(CryptoFacade.class); private static final Logger log = LoggerFactory.getLogger(CryptoService.class);
@Inject @Inject
public CryptoFacade() { public CryptoService() {
} }
// DeterministicKey does not support signMessage yet. // DeterministicKey does not support signMessage yet.

View file

@ -17,7 +17,7 @@
package io.bitsquare.gui.components; package io.bitsquare.gui.components;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.btc.listeners.AddressConfidenceListener; import io.bitsquare.btc.listeners.AddressConfidenceListener;
import io.bitsquare.btc.listeners.BalanceListener; import io.bitsquare.btc.listeners.BalanceListener;
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator; import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
@ -74,23 +74,23 @@ public class BalanceTextField extends AnchorPane {
getChildren().addAll(textField, progressIndicator); getChildren().addAll(textField, progressIndicator);
} }
public void setup(WalletFacade walletFacade, Address address, BSFormatter formatter) { public void setup(WalletService walletService, Address address, BSFormatter formatter) {
this.formatter = formatter; this.formatter = formatter;
walletFacade.addAddressConfidenceListener(new AddressConfidenceListener(address) { walletService.addAddressConfidenceListener(new AddressConfidenceListener(address) {
@Override @Override
public void onTransactionConfidenceChanged(TransactionConfidence confidence) { public void onTransactionConfidenceChanged(TransactionConfidence confidence) {
updateConfidence(confidence); updateConfidence(confidence);
} }
}); });
updateConfidence(walletFacade.getConfidenceForAddress(address)); updateConfidence(walletService.getConfidenceForAddress(address));
walletFacade.addBalanceListener(new BalanceListener(address) { walletService.addBalanceListener(new BalanceListener(address) {
@Override @Override
public void onBalanceChanged(Coin balance) { public void onBalanceChanged(Coin balance) {
updateBalance(balance); updateBalance(balance);
} }
}); });
updateBalance(walletFacade.getBalanceForAddress(address)); updateBalance(walletService.getBalanceForAddress(address));
} }

View file

@ -25,7 +25,7 @@ import eu.hansolo.enzo.notification.NotificationBuilder;
import eu.hansolo.enzo.notification.NotifierBuilder; import eu.hansolo.enzo.notification.NotifierBuilder;
/** /**
* Not sure if we stick with the eu.hansolo.enzo.notification.Notification implementation, so keep it behind a facade * Not sure if we stick with the eu.hansolo.enzo.notification.Notification implementation, so keep it behind a service
*/ */
public class SystemNotification { public class SystemNotification {
private static final Logger log = LoggerFactory.getLogger(SystemNotification.class); private static final Logger log = LoggerFactory.getLogger(SystemNotification.class);

View file

@ -17,7 +17,7 @@
package io.bitsquare.gui.components; package io.bitsquare.gui.components;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.btc.listeners.TxConfidenceListener; import io.bitsquare.btc.listeners.TxConfidenceListener;
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator; import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
@ -85,7 +85,7 @@ public class TxIdTextField extends AnchorPane {
getChildren().addAll(textField, copyIcon, progressIndicator); getChildren().addAll(textField, copyIcon, progressIndicator);
} }
public void setup(WalletFacade walletFacade, String txID) { public void setup(WalletService walletService, String txID) {
textField.setText(txID); textField.setText(txID);
textField.setOnMouseClicked(mouseEvent -> { textField.setOnMouseClicked(mouseEvent -> {
try { try {
@ -107,13 +107,13 @@ public class TxIdTextField extends AnchorPane {
} }
}); });
walletFacade.addTxConfidenceListener(new TxConfidenceListener(txID) { walletService.addTxConfidenceListener(new TxConfidenceListener(txID) {
@Override @Override
public void onTransactionConfidenceChanged(TransactionConfidence confidence) { public void onTransactionConfidenceChanged(TransactionConfidence confidence) {
updateConfidence(confidence); updateConfidence(confidence);
} }
}); });
updateConfidence(walletFacade.getConfidenceForTxId(txID)); updateConfidence(walletService.getConfidenceForTxId(txID));
} }
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////

View file

@ -18,10 +18,10 @@
package io.bitsquare.gui.main; package io.bitsquare.gui.main;
import io.bitsquare.bank.BankAccount; import io.bitsquare.bank.BankAccount;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.gui.UIModel; import io.bitsquare.gui.UIModel;
import io.bitsquare.gui.util.Profiler; import io.bitsquare.gui.util.Profiler;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageService;
import io.bitsquare.msg.listeners.BootstrapListener; import io.bitsquare.msg.listeners.BootstrapListener;
import io.bitsquare.network.BootstrapState; import io.bitsquare.network.BootstrapState;
import io.bitsquare.persistence.Persistence; import io.bitsquare.persistence.Persistence;
@ -50,20 +50,20 @@ class MainModel extends UIModel {
private static final Logger log = LoggerFactory.getLogger(MainModel.class); private static final Logger log = LoggerFactory.getLogger(MainModel.class);
private final User user; private final User user;
private final WalletFacade walletFacade; private final WalletService walletService;
private final MessageFacade messageFacade; private final MessageService messageService;
private final TradeManager tradeManager; private final TradeManager tradeManager;
private final Persistence persistence; private final Persistence persistence;
private boolean messageFacadeInited; private boolean messageServiceInited;
private boolean walletFacadeInited; private boolean walletServiceInited;
private boolean facadesInitialised; private boolean servicesInitialised;
final BooleanProperty backendReady = new SimpleBooleanProperty(); final BooleanProperty backendReady = new SimpleBooleanProperty();
final DoubleProperty networkSyncProgress = new SimpleDoubleProperty(-1); final DoubleProperty networkSyncProgress = new SimpleDoubleProperty(-1);
final IntegerProperty numPendingTrades = new SimpleIntegerProperty(0); final IntegerProperty numPendingTrades = new SimpleIntegerProperty(0);
final ObjectProperty<BootstrapState> bootstrapState = new SimpleObjectProperty<>(); final ObjectProperty<BootstrapState> bootstrapState = new SimpleObjectProperty<>();
final ObjectProperty walletFacadeException = new SimpleObjectProperty<Throwable>(); final ObjectProperty walletServiceException = new SimpleObjectProperty<Throwable>();
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@ -71,11 +71,11 @@ class MainModel extends UIModel {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Inject @Inject
private MainModel(User user, WalletFacade walletFacade, MessageFacade messageFacade, private MainModel(User user, WalletService walletService, MessageService messageService,
TradeManager tradeManager, Persistence persistence) { TradeManager tradeManager, Persistence persistence) {
this.user = user; this.user = user;
this.walletFacade = walletFacade; this.walletService = walletService;
this.messageFacade = messageFacade; this.messageService = messageService;
this.tradeManager = tradeManager; this.tradeManager = tradeManager;
this.persistence = persistence; this.persistence = persistence;
} }
@ -105,13 +105,13 @@ class MainModel extends UIModel {
void initBackend() { void initBackend() {
// For testing with the bootstrap node we need the BootstrappedPeerFactory which gets started from // For testing with the bootstrap node we need the BootstrappedPeerFactory which gets started from
// messageFacade.init // messageService.init
messageFacade.init(new BootstrapListener() { messageService.init(new BootstrapListener() {
@Override @Override
public void onCompleted() { public void onCompleted() {
messageFacadeInited = true; messageServiceInited = true;
if (walletFacadeInited) onFacadesInitialised(); if (walletServiceInited) onServicesInitialised();
} }
@Override @Override
@ -125,15 +125,15 @@ class MainModel extends UIModel {
} }
}); });
Profiler.printMsgWithTime("MainModel.initFacades"); Profiler.printMsgWithTime("MainModel.initServices");
WalletFacade.BlockchainDownloadListener blockchainDownloadListener = new WalletFacade WalletService.BlockchainDownloadListener blockchainDownloadListener = new WalletService
.BlockchainDownloadListener() { .BlockchainDownloadListener() {
@Override @Override
public void progress(double percentage) { public void progress(double percentage) {
networkSyncProgress.set(percentage / 100.0); networkSyncProgress.set(percentage / 100.0);
if (facadesInitialised && percentage >= 100.0) if (servicesInitialised && percentage >= 100.0)
backendReady.set(true); backendReady.set(true);
} }
@ -141,26 +141,26 @@ class MainModel extends UIModel {
public void doneDownload() { public void doneDownload() {
networkSyncProgress.set(1.0); networkSyncProgress.set(1.0);
if (facadesInitialised) if (servicesInitialised)
backendReady.set(true); backendReady.set(true);
} }
}; };
WalletFacade.StartupListener startupListener = new WalletFacade.StartupListener() { WalletService.StartupListener startupListener = new WalletService.StartupListener() {
@Override @Override
public void completed() { public void completed() {
walletFacadeInited = true; walletServiceInited = true;
if (messageFacadeInited) if (messageServiceInited)
onFacadesInitialised(); onServicesInitialised();
} }
@Override @Override
public void failed(final Throwable failure) { public void failed(final Throwable failure) {
walletFacadeException.set(failure); walletServiceException.set(failure);
} }
}; };
walletFacade.initialize(Platform::runLater, blockchainDownloadListener, startupListener); walletService.initialize(Platform::runLater, blockchainDownloadListener, startupListener);
} }
@ -191,12 +191,12 @@ class MainModel extends UIModel {
// Private // Private
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
private void onFacadesInitialised() { private void onServicesInitialised() {
tradeManager.getPendingTrades().addListener((MapChangeListener<String, tradeManager.getPendingTrades().addListener((MapChangeListener<String,
Trade>) change -> updateNumPendingTrades()); Trade>) change -> updateNumPendingTrades());
updateNumPendingTrades(); updateNumPendingTrades();
facadesInitialised = true; servicesInitialised = true;
if (networkSyncProgress.get() >= 1.0) if (networkSyncProgress.get() >= 1.0)
backendReady.set(true); backendReady.set(true);

View file

@ -54,7 +54,7 @@ class MainPM extends PresentationModel<MainModel> {
final DoubleProperty blockchainSyncProgress = new SimpleDoubleProperty(); final DoubleProperty blockchainSyncProgress = new SimpleDoubleProperty();
final BooleanProperty blockchainSyncIndicatorVisible = new SimpleBooleanProperty(true); final BooleanProperty blockchainSyncIndicatorVisible = new SimpleBooleanProperty(true);
final StringProperty blockchainSyncIconId = new SimpleStringProperty(); final StringProperty blockchainSyncIconId = new SimpleStringProperty();
final StringProperty walletFacadeErrorMsg = new SimpleStringProperty(); final StringProperty walletServiceErrorMsg = new SimpleStringProperty();
final DoubleProperty bootstrapProgress = new SimpleDoubleProperty(-1); final DoubleProperty bootstrapProgress = new SimpleDoubleProperty(-1);
final BooleanProperty bootstrapFailed = new SimpleBooleanProperty(); final BooleanProperty bootstrapFailed = new SimpleBooleanProperty();
@ -116,11 +116,11 @@ class MainPM extends PresentationModel<MainModel> {
} }
); );
model.walletFacadeException.addListener((ov, oldValue, newValue) -> { model.walletServiceException.addListener((ov, oldValue, newValue) -> {
blockchainSyncProgress.set(0); blockchainSyncProgress.set(0);
blockchainSyncIndicatorVisible.set(false); blockchainSyncIndicatorVisible.set(false);
blockchainSyncState.set("Startup failed."); blockchainSyncState.set("Startup failed.");
walletFacadeErrorMsg.set(((Throwable) newValue).getMessage()); walletServiceErrorMsg.set(((Throwable) newValue).getMessage());
}); });
model.networkSyncProgress.addListener((ov, oldValue, newValue) -> { model.networkSyncProgress.addListener((ov, oldValue, newValue) -> {

View file

@ -284,7 +284,7 @@ public class MainViewCB extends ViewCB<MainPM> {
Label blockchainSyncLabel = new Label(); Label blockchainSyncLabel = new Label();
blockchainSyncLabel.textProperty().bind(presentationModel.blockchainSyncState); blockchainSyncLabel.textProperty().bind(presentationModel.blockchainSyncState);
presentationModel.walletFacadeErrorMsg.addListener((ov, oldValue, newValue) -> { presentationModel.walletServiceErrorMsg.addListener((ov, oldValue, newValue) -> {
blockchainSyncLabel.setId("splash-error-state-msg"); blockchainSyncLabel.setId("splash-error-state-msg");
Popups.openErrorPopup("Error", "An error occurred at startup. \n\nError message:\n" + Popups.openErrorPopup("Error", "An error occurred at startup. \n\nError message:\n" +
newValue); newValue);

View file

@ -25,7 +25,7 @@ import io.bitsquare.gui.ViewCB;
import io.bitsquare.gui.ViewLoader; import io.bitsquare.gui.ViewLoader;
import io.bitsquare.gui.main.account.arbitrator.profile.ArbitratorProfileViewCB; import io.bitsquare.gui.main.account.arbitrator.profile.ArbitratorProfileViewCB;
import io.bitsquare.locale.LanguageUtil; import io.bitsquare.locale.LanguageUtil;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageService;
import io.bitsquare.msg.listeners.ArbitratorListener; import io.bitsquare.msg.listeners.ArbitratorListener;
import io.bitsquare.persistence.Persistence; import io.bitsquare.persistence.Persistence;
@ -53,7 +53,7 @@ public class ArbitratorBrowserViewCB extends CachedViewCB implements ArbitratorL
private final AccountSettings accountSettings; private final AccountSettings accountSettings;
private final Persistence persistence; private final Persistence persistence;
private final MessageFacade messageFacade; private final MessageService messageService;
private final List<Arbitrator> allArbitrators = new ArrayList<>(); private final List<Arbitrator> allArbitrators = new ArrayList<>();
private Arbitrator currentArbitrator; private Arbitrator currentArbitrator;
@ -69,10 +69,10 @@ public class ArbitratorBrowserViewCB extends CachedViewCB implements ArbitratorL
@Inject @Inject
public ArbitratorBrowserViewCB(AccountSettings accountSettings, Persistence persistence, public ArbitratorBrowserViewCB(AccountSettings accountSettings, Persistence persistence,
MessageFacade messageFacade) { MessageService messageService) {
this.accountSettings = accountSettings; this.accountSettings = accountSettings;
this.persistence = persistence; this.persistence = persistence;
this.messageFacade = messageFacade; this.messageService = messageService;
} }
@ -82,8 +82,8 @@ public class ArbitratorBrowserViewCB extends CachedViewCB implements ArbitratorL
@Override @Override
public void initialize(URL url, ResourceBundle rb) { public void initialize(URL url, ResourceBundle rb) {
messageFacade.addArbitratorListener(this); messageService.addArbitratorListener(this);
messageFacade.getArbitrators(LanguageUtil.getDefaultLanguageLocale()); messageService.getArbitrators(LanguageUtil.getDefaultLanguageLocale());
loadView(Navigation.Item.ARBITRATOR_PROFILE); loadView(Navigation.Item.ARBITRATOR_PROFILE);
checkButtonState(); checkButtonState();

View file

@ -19,13 +19,13 @@ package io.bitsquare.gui.main.account.arbitrator.registration;
import io.bitsquare.arbitrator.Arbitrator; import io.bitsquare.arbitrator.Arbitrator;
import io.bitsquare.arbitrator.Reputation; import io.bitsquare.arbitrator.Reputation;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.gui.CachedViewCB; import io.bitsquare.gui.CachedViewCB;
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator; import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.locale.BSResources; import io.bitsquare.locale.BSResources;
import io.bitsquare.locale.LanguageUtil; import io.bitsquare.locale.LanguageUtil;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageService;
import io.bitsquare.persistence.Persistence; import io.bitsquare.persistence.Persistence;
import io.bitsquare.user.User; import io.bitsquare.user.User;
import io.bitsquare.util.DSAKeyUtil; import io.bitsquare.util.DSAKeyUtil;
@ -65,8 +65,8 @@ public class ArbitratorRegistrationViewCB extends CachedViewCB {
private static final Logger log = LoggerFactory.getLogger(ArbitratorRegistrationViewCB.class); private static final Logger log = LoggerFactory.getLogger(ArbitratorRegistrationViewCB.class);
private final Persistence persistence; private final Persistence persistence;
private final WalletFacade walletFacade; private final WalletService walletService;
private final MessageFacade messageFacade; private final MessageService messageService;
private final User user; private final User user;
private final BSFormatter formatter; private final BSFormatter formatter;
private Arbitrator arbitrator = new Arbitrator(); private Arbitrator arbitrator = new Arbitrator();
@ -100,11 +100,11 @@ public class ArbitratorRegistrationViewCB extends CachedViewCB {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Inject @Inject
private ArbitratorRegistrationViewCB(Persistence persistence, WalletFacade walletFacade, private ArbitratorRegistrationViewCB(Persistence persistence, WalletService walletService,
MessageFacade messageFacade, User user, BSFormatter formatter) { MessageService messageService, User user, BSFormatter formatter) {
this.persistence = persistence; this.persistence = persistence;
this.walletFacade = walletFacade; this.walletService = walletService;
this.messageFacade = messageFacade; this.messageService = messageService;
this.user = user; this.user = user;
this.formatter = formatter; this.formatter = formatter;
} }
@ -322,7 +322,7 @@ public class ArbitratorRegistrationViewCB extends CachedViewCB {
} }
} }
messageFacade.addArbitrator(arbitrator); messageService.addArbitrator(arbitrator);
} }
@FXML @FXML
@ -344,8 +344,8 @@ public class ArbitratorRegistrationViewCB extends CachedViewCB {
"resolution.\n\nPlease pay in 2 BTC"); "resolution.\n\nPlease pay in 2 BTC");
String securityDepositAddress = walletFacade.getRegistrationAddressEntry() != null ? String securityDepositAddress = walletService.getRegistrationAddressEntry() != null ?
walletFacade.getRegistrationAddressEntry().toString() : ""; walletService.getRegistrationAddressEntry().toString() : "";
securityDepositAddressTextField.setText(securityDepositAddress); securityDepositAddressTextField.setText(securityDepositAddress);
AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY); AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY);
@ -356,9 +356,9 @@ public class ArbitratorRegistrationViewCB extends CachedViewCB {
clipboard.setContent(content); clipboard.setContent(content);
}); });
paymentDoneButton.setDisable(walletFacade.getArbitratorDepositBalance().isZero()); paymentDoneButton.setDisable(walletService.getArbitratorDepositBalance().isZero());
log.debug("getArbitratorDepositBalance " + walletFacade.getArbitratorDepositBalance()); log.debug("getArbitratorDepositBalance " + walletService.getArbitratorDepositBalance());
walletFacade.getWallet().addEventListener(new WalletEventListener() { walletService.getWallet().addEventListener(new WalletEventListener() {
@Override @Override
public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) { public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
paymentDoneButton.setDisable(newBalance.isZero()); paymentDoneButton.setDisable(newBalance.isZero());
@ -431,7 +431,7 @@ public class ArbitratorRegistrationViewCB extends CachedViewCB {
private Arbitrator getEditedArbitrator() { private Arbitrator getEditedArbitrator() {
String pubKeyAsHex = walletFacade.getArbitratorDepositAddressEntry().getPubKeyAsHexString(); String pubKeyAsHex = walletService.getArbitratorDepositAddressEntry().getPubKeyAsHexString();
String messagePubKeyAsHex = DSAKeyUtil.getHexStringFromPublicKey(user.getMessagePublicKey()); String messagePubKeyAsHex = DSAKeyUtil.getHexStringFromPublicKey(user.getMessagePublicKey());
String name = nameTextField.getText(); String name = nameTextField.getText();
Coin fee = formatter.parseToCoin(arbitrationFeeTextField.getText()); Coin fee = formatter.parseToCoin(arbitrationFeeTextField.getText());

View file

@ -28,7 +28,7 @@ import io.bitsquare.locale.CountryUtil;
import io.bitsquare.locale.CurrencyUtil; import io.bitsquare.locale.CurrencyUtil;
import io.bitsquare.locale.LanguageUtil; import io.bitsquare.locale.LanguageUtil;
import io.bitsquare.locale.Region; import io.bitsquare.locale.Region;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageService;
import io.bitsquare.persistence.Persistence; import io.bitsquare.persistence.Persistence;
import io.bitsquare.user.User; import io.bitsquare.user.User;
import io.bitsquare.util.DSAKeyUtil; import io.bitsquare.util.DSAKeyUtil;
@ -59,7 +59,7 @@ class IrcAccountModel extends UIModel {
private final User user; private final User user;
private final AccountSettings accountSettings; private final AccountSettings accountSettings;
private final MessageFacade messageFacade; private final MessageService messageService;
private final Persistence persistence; private final Persistence persistence;
final StringProperty nickName = new SimpleStringProperty(); final StringProperty nickName = new SimpleStringProperty();
@ -78,11 +78,11 @@ class IrcAccountModel extends UIModel {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Inject @Inject
IrcAccountModel(User user, Persistence persistence, AccountSettings accountSettings, MessageFacade messageFacade) { IrcAccountModel(User user, Persistence persistence, AccountSettings accountSettings, MessageService messageService) {
this.persistence = persistence; this.persistence = persistence;
this.user = user; this.user = user;
this.accountSettings = accountSettings; this.accountSettings = accountSettings;
this.messageFacade = messageFacade; this.messageService = messageService;
} }
@ -205,7 +205,7 @@ class IrcAccountModel extends UIModel {
accountSettings.addAcceptedArbitrator(arbitrator); accountSettings.addAcceptedArbitrator(arbitrator);
persistence.write(accountSettings); persistence.write(accountSettings);
messageFacade.addArbitrator(arbitrator); messageService.addArbitrator(arbitrator);
} }
} }
} }

View file

@ -19,7 +19,7 @@ package io.bitsquare.gui.main.account.content.registration;
import io.bitsquare.btc.AddressEntry; import io.bitsquare.btc.AddressEntry;
import io.bitsquare.btc.FeePolicy; import io.bitsquare.btc.FeePolicy;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.btc.listeners.BalanceListener; import io.bitsquare.btc.listeners.BalanceListener;
import io.bitsquare.gui.UIModel; import io.bitsquare.gui.UIModel;
import io.bitsquare.persistence.Persistence; import io.bitsquare.persistence.Persistence;
@ -48,7 +48,7 @@ import org.slf4j.LoggerFactory;
class RegistrationModel extends UIModel { class RegistrationModel extends UIModel {
private static final Logger log = LoggerFactory.getLogger(RegistrationModel.class); private static final Logger log = LoggerFactory.getLogger(RegistrationModel.class);
private final WalletFacade walletFacade; private final WalletService walletService;
private final User user; private final User user;
private final Persistence persistence; private final Persistence persistence;
@ -65,9 +65,9 @@ class RegistrationModel extends UIModel {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Inject @Inject
private RegistrationModel(WalletFacade walletFacade, User user, Persistence persistence) { private RegistrationModel(WalletService walletService, User user, Persistence persistence) {
this.walletFacade = walletFacade; this.walletService = walletService;
this.user = user; this.user = user;
this.persistence = persistence; this.persistence = persistence;
} }
@ -81,15 +81,15 @@ class RegistrationModel extends UIModel {
public void initialize() { public void initialize() {
super.initialize(); super.initialize();
if (walletFacade != null && walletFacade.getWallet() != null) { if (walletService != null && walletService.getWallet() != null) {
addressEntry = walletFacade.getRegistrationAddressEntry(); addressEntry = walletService.getRegistrationAddressEntry();
walletFacade.addBalanceListener(new BalanceListener(getAddressEntry().getAddress()) { walletService.addBalanceListener(new BalanceListener(getAddressEntry().getAddress()) {
@Override @Override
public void onBalanceChanged(@NotNull Coin balance) { public void onBalanceChanged(@NotNull Coin balance) {
updateBalance(balance); updateBalance(balance);
} }
}); });
updateBalance(walletFacade.getBalanceForAddress(getAddressEntry().getAddress())); updateBalance(walletService.getBalanceForAddress(getAddressEntry().getAddress()));
} }
} }
@ -140,7 +140,7 @@ class RegistrationModel extends UIModel {
} }
}; };
try { try {
walletFacade.payRegistrationFee(user.getStringifiedBankAccounts(), callback); walletService.payRegistrationFee(user.getStringifiedBankAccounts(), callback);
} catch (InsufficientMoneyException e) { } catch (InsufficientMoneyException e) {
payFeeErrorMessage.set("Fee payment failed with error: " + e.getMessage()); payFeeErrorMessage.set("Fee payment failed with error: " + e.getMessage());
} }
@ -151,8 +151,8 @@ class RegistrationModel extends UIModel {
// Getters // Getters
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
WalletFacade getWalletFacade() { WalletService getWalletService() {
return walletFacade; return walletService;
} }
Coin getFeeAsCoin() { Coin getFeeAsCoin() {

View file

@ -17,7 +17,7 @@
package io.bitsquare.gui.main.account.content.registration; package io.bitsquare.gui.main.account.content.registration;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.gui.PresentationModel; import io.bitsquare.gui.PresentationModel;
import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.locale.BSResources; import io.bitsquare.locale.BSResources;
@ -122,8 +122,8 @@ class RegistrationPM extends PresentationModel<RegistrationModel> {
// Getters // Getters
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
WalletFacade getWalletFacade() { WalletService getWalletService() {
return model.getWalletFacade(); return model.getWalletService();
} }
BSFormatter getFormatter() { BSFormatter getFormatter() {

View file

@ -87,7 +87,7 @@ public class RegistrationViewCB extends CachedViewCB<RegistrationPM> implements
// TODO find better solution // TODO find better solution
addressTextField.setOverlayManager(overlayManager); addressTextField.setOverlayManager(overlayManager);
balanceTextField.setup(presentationModel.getWalletFacade(), presentationModel.address.get(), balanceTextField.setup(presentationModel.getWalletService(), presentationModel.address.get(),
presentationModel.getFormatter()); presentationModel.getFormatter());
payButton.disableProperty().bind(presentationModel.isPayButtonDisabled); payButton.disableProperty().bind(presentationModel.isPayButtonDisabled);

View file

@ -25,7 +25,7 @@ import io.bitsquare.locale.Country;
import io.bitsquare.locale.CountryUtil; import io.bitsquare.locale.CountryUtil;
import io.bitsquare.locale.LanguageUtil; import io.bitsquare.locale.LanguageUtil;
import io.bitsquare.locale.Region; import io.bitsquare.locale.Region;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageService;
import io.bitsquare.persistence.Persistence; import io.bitsquare.persistence.Persistence;
import io.bitsquare.user.User; import io.bitsquare.user.User;
import io.bitsquare.util.DSAKeyUtil; import io.bitsquare.util.DSAKeyUtil;
@ -52,7 +52,7 @@ class RestrictionsModel extends UIModel {
private final User user; private final User user;
private final AccountSettings accountSettings; private final AccountSettings accountSettings;
private final Persistence persistence; private final Persistence persistence;
private final MessageFacade messageFacade; private final MessageService messageService;
final ObservableList<Locale> languageList = FXCollections.observableArrayList(); final ObservableList<Locale> languageList = FXCollections.observableArrayList();
final ObservableList<Country> countryList = FXCollections.observableArrayList(); final ObservableList<Country> countryList = FXCollections.observableArrayList();
@ -68,11 +68,11 @@ class RestrictionsModel extends UIModel {
@Inject @Inject
private RestrictionsModel(User user, AccountSettings accountSettings, Persistence persistence, private RestrictionsModel(User user, AccountSettings accountSettings, Persistence persistence,
MessageFacade messageFacade) { MessageService messageService) {
this.user = user; this.user = user;
this.accountSettings = accountSettings; this.accountSettings = accountSettings;
this.persistence = persistence; this.persistence = persistence;
this.messageFacade = messageFacade; this.messageService = messageService;
} }
@ -215,7 +215,7 @@ class RestrictionsModel extends UIModel {
accountSettings.addAcceptedArbitrator(arbitrator); accountSettings.addAcceptedArbitrator(arbitrator);
persistence.write(accountSettings); persistence.write(accountSettings);
messageFacade.addArbitrator(arbitrator); messageService.addArbitrator(arbitrator);
} }
} }
} }

View file

@ -17,7 +17,7 @@
package io.bitsquare.gui.main.account.content.seedwords; package io.bitsquare.gui.main.account.content.seedwords;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.gui.UIModel; import io.bitsquare.gui.UIModel;
import com.google.inject.Inject; import com.google.inject.Inject;
@ -38,9 +38,9 @@ class SeedWordsModel extends UIModel {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Inject @Inject
private SeedWordsModel(WalletFacade walletFacade) { private SeedWordsModel(WalletService walletService) {
if (walletFacade != null && walletFacade.getWallet() != null) if (walletService != null && walletService.getWallet() != null)
mnemonicCode = walletFacade.getWallet().getKeyChainSeed().getMnemonicCode(); mnemonicCode = walletService.getWallet().getKeyChainSeed().getMnemonicCode();
} }

View file

@ -17,7 +17,7 @@
package io.bitsquare.gui.main.funds.transactions; package io.bitsquare.gui.main.funds.transactions;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.btc.listeners.AddressConfidenceListener; import io.bitsquare.btc.listeners.AddressConfidenceListener;
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator; import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.gui.util.BSFormatter;
@ -41,7 +41,7 @@ public class TransactionsListItem {
private final StringProperty amount = new SimpleStringProperty(); private final StringProperty amount = new SimpleStringProperty();
private final StringProperty type = new SimpleStringProperty(); private final StringProperty type = new SimpleStringProperty();
private final WalletFacade walletFacade; private final WalletService walletService;
private final ConfidenceProgressIndicator progressIndicator; private final ConfidenceProgressIndicator progressIndicator;
@ -49,23 +49,23 @@ public class TransactionsListItem {
private String addressString; private String addressString;
private AddressConfidenceListener confidenceListener; private AddressConfidenceListener confidenceListener;
public TransactionsListItem(Transaction transaction, WalletFacade walletFacade, BSFormatter formatter) { public TransactionsListItem(Transaction transaction, WalletService walletService, BSFormatter formatter) {
this.walletFacade = walletFacade; this.walletService = walletService;
Coin valueSentToMe = transaction.getValueSentToMe(walletFacade.getWallet()); Coin valueSentToMe = transaction.getValueSentToMe(walletService.getWallet());
Coin valueSentFromMe = transaction.getValueSentFromMe(walletFacade.getWallet()); Coin valueSentFromMe = transaction.getValueSentFromMe(walletService.getWallet());
Address address = null; Address address = null;
if (valueSentToMe.isZero()) { if (valueSentToMe.isZero()) {
amount.set("-" + formatter.formatCoin(valueSentFromMe)); amount.set("-" + formatter.formatCoin(valueSentFromMe));
for (TransactionOutput transactionOutput : transaction.getOutputs()) { for (TransactionOutput transactionOutput : transaction.getOutputs()) {
if (!transactionOutput.isMine(walletFacade.getWallet())) { if (!transactionOutput.isMine(walletService.getWallet())) {
type.set("Sent to"); type.set("Sent to");
if (transactionOutput.getScriptPubKey().isSentToAddress() || if (transactionOutput.getScriptPubKey().isSentToAddress() ||
transactionOutput.getScriptPubKey().isPayToScriptHash()) { transactionOutput.getScriptPubKey().isPayToScriptHash()) {
address = address =
transactionOutput.getScriptPubKey().getToAddress(walletFacade.getWallet().getParams()); transactionOutput.getScriptPubKey().getToAddress(walletService.getWallet().getParams());
addressString = address.toString(); addressString = address.toString();
} }
else { else {
@ -79,11 +79,11 @@ public class TransactionsListItem {
type.set("Received with"); type.set("Received with");
for (TransactionOutput transactionOutput : transaction.getOutputs()) { for (TransactionOutput transactionOutput : transaction.getOutputs()) {
if (transactionOutput.isMine(walletFacade.getWallet())) { if (transactionOutput.isMine(walletService.getWallet())) {
if (transactionOutput.getScriptPubKey().isSentToAddress() || if (transactionOutput.getScriptPubKey().isSentToAddress() ||
transactionOutput.getScriptPubKey().isPayToScriptHash()) { transactionOutput.getScriptPubKey().isPayToScriptHash()) {
address = address =
transactionOutput.getScriptPubKey().getToAddress(walletFacade.getWallet().getParams()); transactionOutput.getScriptPubKey().getToAddress(walletService.getWallet().getParams());
addressString = address.toString(); addressString = address.toString();
} }
else { else {
@ -96,11 +96,11 @@ public class TransactionsListItem {
amount.set(formatter.formatCoin(valueSentToMe.subtract(valueSentFromMe))); amount.set(formatter.formatCoin(valueSentToMe.subtract(valueSentFromMe)));
boolean outgoing = false; boolean outgoing = false;
for (TransactionOutput transactionOutput : transaction.getOutputs()) { for (TransactionOutput transactionOutput : transaction.getOutputs()) {
if (!transactionOutput.isMine(walletFacade.getWallet())) { if (!transactionOutput.isMine(walletService.getWallet())) {
outgoing = true; outgoing = true;
if (transactionOutput.getScriptPubKey().isSentToAddress() || transactionOutput.getScriptPubKey() if (transactionOutput.getScriptPubKey().isSentToAddress() || transactionOutput.getScriptPubKey()
.isPayToScriptHash()) { .isPayToScriptHash()) {
address = transactionOutput.getScriptPubKey().getToAddress(walletFacade.getWallet().getParams address = transactionOutput.getScriptPubKey().getToAddress(walletService.getWallet().getParams
()); ());
addressString = address.toString(); addressString = address.toString();
} }
@ -131,20 +131,20 @@ public class TransactionsListItem {
Tooltip.install(progressIndicator, tooltip); Tooltip.install(progressIndicator, tooltip);
if (address != null) { if (address != null) {
confidenceListener = walletFacade.addAddressConfidenceListener(new AddressConfidenceListener(address) { confidenceListener = walletService.addAddressConfidenceListener(new AddressConfidenceListener(address) {
@Override @Override
public void onTransactionConfidenceChanged(TransactionConfidence confidence) { public void onTransactionConfidenceChanged(TransactionConfidence confidence) {
updateConfidence(confidence); updateConfidence(confidence);
} }
}); });
updateConfidence(walletFacade.getConfidenceForAddress(address)); updateConfidence(walletService.getConfidenceForAddress(address));
} }
} }
public void cleanup() { public void cleanup() {
walletFacade.removeAddressConfidenceListener(confidenceListener); walletService.removeAddressConfidenceListener(confidenceListener);
} }
private void updateConfidence(TransactionConfidence confidence) { private void updateConfidence(TransactionConfidence confidence) {

View file

@ -17,7 +17,7 @@
package io.bitsquare.gui.main.funds.transactions; package io.bitsquare.gui.main.funds.transactions;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.gui.CachedViewCB; import io.bitsquare.gui.CachedViewCB;
import io.bitsquare.gui.components.Popups; import io.bitsquare.gui.components.Popups;
import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.gui.util.BSFormatter;
@ -45,7 +45,7 @@ import org.slf4j.LoggerFactory;
public class TransactionsViewCB extends CachedViewCB { public class TransactionsViewCB extends CachedViewCB {
private static final Logger log = LoggerFactory.getLogger(TransactionsViewCB.class); private static final Logger log = LoggerFactory.getLogger(TransactionsViewCB.class);
private final WalletFacade walletFacade; private final WalletService walletService;
private final BSFormatter formatter; private final BSFormatter formatter;
private ObservableList<TransactionsListItem> transactionsListItems; private ObservableList<TransactionsListItem> transactionsListItems;
@ -59,8 +59,8 @@ public class TransactionsViewCB extends CachedViewCB {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Inject @Inject
private TransactionsViewCB(WalletFacade walletFacade, BSFormatter formatter) { private TransactionsViewCB(WalletService walletService, BSFormatter formatter) {
this.walletFacade = walletFacade; this.walletService = walletService;
this.formatter = formatter; this.formatter = formatter;
} }
@ -92,10 +92,10 @@ public class TransactionsViewCB extends CachedViewCB {
public void activate() { public void activate() {
super.activate(); super.activate();
List<Transaction> transactions = walletFacade.getWallet().getRecentTransactions(10000, true); List<Transaction> transactions = walletService.getWallet().getRecentTransactions(10000, true);
transactionsListItems = FXCollections.observableArrayList(); transactionsListItems = FXCollections.observableArrayList();
transactionsListItems.addAll(transactions.stream().map(transaction -> transactionsListItems.addAll(transactions.stream().map(transaction ->
new TransactionsListItem(transaction, walletFacade, formatter)).collect(Collectors.toList())); new TransactionsListItem(transaction, walletService, formatter)).collect(Collectors.toList()));
table.setItems(transactionsListItems); table.setItems(transactionsListItems);
} }

View file

@ -18,7 +18,7 @@
package io.bitsquare.gui.main.funds.withdrawal; package io.bitsquare.gui.main.funds.withdrawal;
import io.bitsquare.btc.AddressEntry; import io.bitsquare.btc.AddressEntry;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.btc.listeners.AddressConfidenceListener; import io.bitsquare.btc.listeners.AddressConfidenceListener;
import io.bitsquare.btc.listeners.BalanceListener; import io.bitsquare.btc.listeners.BalanceListener;
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator; import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
@ -42,7 +42,7 @@ public class WithdrawalListItem {
private final AddressEntry addressEntry; private final AddressEntry addressEntry;
private final WalletFacade walletFacade; private final WalletService walletService;
private final BSFormatter formatter; private final BSFormatter formatter;
private final AddressConfidenceListener confidenceListener; private final AddressConfidenceListener confidenceListener;
@ -52,9 +52,9 @@ public class WithdrawalListItem {
private Coin balance; private Coin balance;
public WithdrawalListItem(AddressEntry addressEntry, WalletFacade walletFacade, BSFormatter formatter) { public WithdrawalListItem(AddressEntry addressEntry, WalletService walletService, BSFormatter formatter) {
this.addressEntry = addressEntry; this.addressEntry = addressEntry;
this.walletFacade = walletFacade; this.walletService = walletService;
this.formatter = formatter; this.formatter = formatter;
this.addressString.set(getAddress().toString()); this.addressString.set(getAddress().toString());
@ -66,31 +66,31 @@ public class WithdrawalListItem {
progressIndicator.setPrefSize(24, 24); progressIndicator.setPrefSize(24, 24);
Tooltip.install(progressIndicator, tooltip); Tooltip.install(progressIndicator, tooltip);
confidenceListener = walletFacade.addAddressConfidenceListener(new AddressConfidenceListener(getAddress()) { confidenceListener = walletService.addAddressConfidenceListener(new AddressConfidenceListener(getAddress()) {
@Override @Override
public void onTransactionConfidenceChanged(TransactionConfidence confidence) { public void onTransactionConfidenceChanged(TransactionConfidence confidence) {
updateConfidence(confidence); updateConfidence(confidence);
} }
}); });
updateConfidence(walletFacade.getConfidenceForAddress(getAddress())); updateConfidence(walletService.getConfidenceForAddress(getAddress()));
// balance // balance
balanceLabel = new Label(); balanceLabel = new Label();
balanceListener = walletFacade.addBalanceListener(new BalanceListener(getAddress()) { balanceListener = walletService.addBalanceListener(new BalanceListener(getAddress()) {
@Override @Override
public void onBalanceChanged(Coin balance) { public void onBalanceChanged(Coin balance) {
updateBalance(balance); updateBalance(balance);
} }
}); });
updateBalance(walletFacade.getBalanceForAddress(getAddress())); updateBalance(walletService.getBalanceForAddress(getAddress()));
} }
public void cleanup() { public void cleanup() {
walletFacade.removeAddressConfidenceListener(confidenceListener); walletService.removeAddressConfidenceListener(confidenceListener);
walletFacade.removeBalanceListener(balanceListener); walletService.removeBalanceListener(balanceListener);
} }
private void updateBalance(Coin balance) { private void updateBalance(Coin balance) {

View file

@ -20,7 +20,7 @@ package io.bitsquare.gui.main.funds.withdrawal;
import io.bitsquare.btc.AddressEntry; import io.bitsquare.btc.AddressEntry;
import io.bitsquare.btc.FeePolicy; import io.bitsquare.btc.FeePolicy;
import io.bitsquare.btc.Restrictions; import io.bitsquare.btc.Restrictions;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.btc.listeners.BalanceListener; import io.bitsquare.btc.listeners.BalanceListener;
import io.bitsquare.gui.CachedViewCB; import io.bitsquare.gui.CachedViewCB;
import io.bitsquare.gui.components.Popups; import io.bitsquare.gui.components.Popups;
@ -63,7 +63,7 @@ public class WithdrawalViewCB extends CachedViewCB {
private static final Logger log = LoggerFactory.getLogger(WithdrawalViewCB.class); private static final Logger log = LoggerFactory.getLogger(WithdrawalViewCB.class);
private final WalletFacade walletFacade; private final WalletService walletService;
private final BSFormatter formatter; private final BSFormatter formatter;
private final ObservableList<WithdrawalListItem> addressList = FXCollections.observableArrayList(); private final ObservableList<WithdrawalListItem> addressList = FXCollections.observableArrayList();
@ -79,8 +79,8 @@ public class WithdrawalViewCB extends CachedViewCB {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Inject @Inject
private WithdrawalViewCB(WalletFacade walletFacade, BSFormatter formatter) { private WithdrawalViewCB(WalletService walletService, BSFormatter formatter) {
this.walletFacade = walletFacade; this.walletService = walletService;
this.formatter = formatter; this.formatter = formatter;
} }
@ -124,7 +124,7 @@ public class WithdrawalViewCB extends CachedViewCB {
fillList(); fillList();
table.setItems(addressList); table.setItems(addressList);
walletFacade.addBalanceListener(new BalanceListener() { walletService.addBalanceListener(new BalanceListener() {
@Override @Override
public void onBalanceChanged(Coin balance) { public void onBalanceChanged(Coin balance) {
fillList(); fillList();
@ -183,7 +183,7 @@ public class WithdrawalViewCB extends CachedViewCB {
"Are you sure you withdraw that amount?"); "Are you sure you withdraw that amount?");
if (Popups.isOK(response)) { if (Popups.isOK(response)) {
try { try {
walletFacade.sendFunds( walletService.sendFunds(
withdrawFromTextField.getText(), withdrawToTextField.getText(), withdrawFromTextField.getText(), withdrawToTextField.getText(),
amount, callback); amount, callback);
@ -214,10 +214,10 @@ public class WithdrawalViewCB extends CachedViewCB {
private void fillList() { private void fillList() {
addressList.clear(); addressList.clear();
List<AddressEntry> addressEntryList = walletFacade.getAddressEntryList(); List<AddressEntry> addressEntryList = walletService.getAddressEntryList();
addressList.addAll(addressEntryList.stream() addressList.addAll(addressEntryList.stream()
.filter(e -> walletFacade.getBalanceForAddress(e.getAddress()).isPositive()) .filter(e -> walletService.getBalanceForAddress(e.getAddress()).isPositive())
.map(anAddressEntryList -> new WithdrawalListItem(anAddressEntryList, walletFacade, formatter)) .map(anAddressEntryList -> new WithdrawalListItem(anAddressEntryList, walletService, formatter))
.collect(Collectors.toList())); .collect(Collectors.toList()));
} }

View file

@ -19,7 +19,7 @@ package io.bitsquare.gui.main.portfolio.pending;
import io.bitsquare.btc.AddressEntry; import io.bitsquare.btc.AddressEntry;
import io.bitsquare.btc.FeePolicy; import io.bitsquare.btc.FeePolicy;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.btc.listeners.TxConfidenceListener; import io.bitsquare.btc.listeners.TxConfidenceListener;
import io.bitsquare.gui.UIModel; import io.bitsquare.gui.UIModel;
import io.bitsquare.offer.Direction; import io.bitsquare.offer.Direction;
@ -58,7 +58,7 @@ class PendingTradesModel extends UIModel {
private static final Logger log = LoggerFactory.getLogger(PendingTradesModel.class); private static final Logger log = LoggerFactory.getLogger(PendingTradesModel.class);
private final TradeManager tradeManager; private final TradeManager tradeManager;
private final WalletFacade walletFacade; private final WalletService walletService;
private final User user; private final User user;
private final ObservableList<PendingTradesListItem> list = FXCollections.observableArrayList(); private final ObservableList<PendingTradesListItem> list = FXCollections.observableArrayList();
@ -82,9 +82,9 @@ class PendingTradesModel extends UIModel {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Inject @Inject
PendingTradesModel(TradeManager tradeManager, WalletFacade walletFacade, User user) { PendingTradesModel(TradeManager tradeManager, WalletService walletService, User user) {
this.tradeManager = tradeManager; this.tradeManager = tradeManager;
this.walletFacade = walletFacade; this.walletService = walletService;
this.user = user; this.user = user;
} }
@ -159,7 +159,7 @@ class PendingTradesModel extends UIModel {
trade.faultProperty().removeListener(faultChangeListener); trade.faultProperty().removeListener(faultChangeListener);
if (txConfidenceListener != null) if (txConfidenceListener != null)
walletFacade.removeTxConfidenceListener(txConfidenceListener); walletService.removeTxConfidenceListener(txConfidenceListener);
} }
selectedItem = item; selectedItem = item;
@ -180,8 +180,8 @@ class PendingTradesModel extends UIModel {
updateConfidence(confidence); updateConfidence(confidence);
} }
}; };
walletFacade.addTxConfidenceListener(txConfidenceListener); walletService.addTxConfidenceListener(txConfidenceListener);
updateConfidence(walletFacade.getConfidenceForTxId(txId.get())); updateConfidence(walletService.getConfidenceForTxId(txId.get()));
trade.stateProperty().addListener(stateChangeListener); trade.stateProperty().addListener(stateChangeListener);
tradeState.set(trade.stateProperty().get()); tradeState.set(trade.stateProperty().get());
@ -222,10 +222,10 @@ class PendingTradesModel extends UIModel {
} }
}; };
AddressEntry addressEntry = walletFacade.getAddressInfoByTradeID(getTrade().getId()); AddressEntry addressEntry = walletService.getAddressInfoByTradeID(getTrade().getId());
String fromAddress = addressEntry.getAddressString(); String fromAddress = addressEntry.getAddressString();
try { try {
walletFacade.sendFunds(fromAddress, toAddress, getAmountToWithdraw(), callback); walletService.sendFunds(fromAddress, toAddress, getAmountToWithdraw(), callback);
} catch (AddressFormatException | InsufficientMoneyException e) { } catch (AddressFormatException | InsufficientMoneyException e) {
e.printStackTrace(); e.printStackTrace();
log.error(e.getMessage()); log.error(e.getMessage());
@ -244,7 +244,7 @@ class PendingTradesModel extends UIModel {
if (Popups.isOK(response)) { if (Popups.isOK(response)) {
try { try {
walletFacade.sendFunds( walletService.sendFunds(
withdrawFromTextField.getText(), withdrawToTextField.getText(), withdrawFromTextField.getText(), withdrawToTextField.getText(),
changeAddressTextField.getText(), amount, callback); changeAddressTextField.getText(), amount, callback);
} catch (AddressFormatException e) { } catch (AddressFormatException e) {
@ -280,8 +280,8 @@ class PendingTradesModel extends UIModel {
return FeePolicy.TX_FEE.add(isOfferer() ? FeePolicy.CREATE_OFFER_FEE : FeePolicy.TAKE_OFFER_FEE); return FeePolicy.TX_FEE.add(isOfferer() ? FeePolicy.CREATE_OFFER_FEE : FeePolicy.TAKE_OFFER_FEE);
} }
WalletFacade getWalletFacade() { WalletService getWalletService() {
return walletFacade; return walletService;
} }
PendingTradesListItem getSelectedItem() { PendingTradesListItem getSelectedItem() {
@ -298,12 +298,12 @@ class PendingTradesModel extends UIModel {
} }
Coin getAmountToWithdraw() { Coin getAmountToWithdraw() {
AddressEntry addressEntry = walletFacade.getAddressInfoByTradeID(getTrade().getId()); AddressEntry addressEntry = walletService.getAddressInfoByTradeID(getTrade().getId());
log.debug("trade id " + getTrade().getId()); log.debug("trade id " + getTrade().getId());
log.debug("getAddressString " + addressEntry.getAddressString()); log.debug("getAddressString " + addressEntry.getAddressString());
log.debug("funds " + walletFacade.getBalanceForAddress(addressEntry.getAddress()).subtract(FeePolicy log.debug("funds " + walletService.getBalanceForAddress(addressEntry.getAddress()).subtract(FeePolicy
.TX_FEE).toString()); .TX_FEE).toString());
// return walletFacade.getBalanceForAddress(addressEntry.getAddress()).subtract(FeePolicy.TX_FEE); // return walletService.getBalanceForAddress(addressEntry.getAddress()).subtract(FeePolicy.TX_FEE);
// TODO handle overpaid securityDeposit // TODO handle overpaid securityDeposit
if (isOfferer()) if (isOfferer())
@ -322,7 +322,7 @@ class PendingTradesModel extends UIModel {
&& getTrade().getState() == Trade.State.DEPOSIT_PUBLISHED) { && getTrade().getState() == Trade.State.DEPOSIT_PUBLISHED) {
// only set it once when actual state is DEPOSIT_PUBLISHED, and remove listener afterwards // only set it once when actual state is DEPOSIT_PUBLISHED, and remove listener afterwards
getTrade().setState(Trade.State.DEPOSIT_CONFIRMED); getTrade().setState(Trade.State.DEPOSIT_CONFIRMED);
walletFacade.removeTxConfidenceListener(txConfidenceListener); walletService.removeTxConfidenceListener(txConfidenceListener);
txConfidenceListener = null; txConfidenceListener = null;
} }
} }

View file

@ -17,7 +17,7 @@
package io.bitsquare.gui.main.portfolio.pending; package io.bitsquare.gui.main.portfolio.pending;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.gui.PresentationModel; import io.bitsquare.gui.PresentationModel;
import io.bitsquare.gui.components.Popups; import io.bitsquare.gui.components.Popups;
import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.gui.util.BSFormatter;
@ -161,8 +161,8 @@ public class PendingTradesPM extends PresentationModel<PendingTradesModel> {
return model.isOfferer(); return model.isOfferer();
} }
WalletFacade getWalletFacade() { WalletService getWalletService() {
return model.getWalletFacade(); return model.getWalletService();
} }
PendingTradesListItem getSelectedItem() { PendingTradesListItem getSelectedItem() {

View file

@ -118,7 +118,7 @@ public class PendingTradesViewCB extends CachedViewCB<PendingTradesPM> {
table.setPlaceholder(new Label("No pending trades available")); table.setPlaceholder(new Label("No pending trades available"));
txIdChangeListener = (ov, oldValue, newValue) -> txIdChangeListener = (ov, oldValue, newValue) ->
txIdTextField.setup(presentationModel.getWalletFacade(), newValue); txIdTextField.setup(presentationModel.getWalletService(), newValue);
selectedItemChangeListener = (obsValue, oldValue, newValue) -> { selectedItemChangeListener = (obsValue, oldValue, newValue) -> {
if (oldValue != null && newValue != null) if (oldValue != null && newValue != null)
@ -154,7 +154,7 @@ public class PendingTradesViewCB extends CachedViewCB<PendingTradesPM> {
presentationModel.txId.addListener(txIdChangeListener); presentationModel.txId.addListener(txIdChangeListener);
presentationModel.fault.addListener(faultChangeListener); presentationModel.fault.addListener(faultChangeListener);
txIdTextField.setup(presentationModel.getWalletFacade(), presentationModel.txId.get()); txIdTextField.setup(presentationModel.getWalletService(), presentationModel.txId.get());
table.getSelectionModel().select(presentationModel.getSelectedItem()); table.getSelectionModel().select(presentationModel.getSelectedItem());
table.getSelectionModel().selectedItemProperty().addListener(selectedItemChangeListener); table.getSelectionModel().selectedItemProperty().addListener(selectedItemChangeListener);

View file

@ -22,7 +22,7 @@ import io.bitsquare.arbitrator.Arbitrator;
import io.bitsquare.bank.BankAccount; import io.bitsquare.bank.BankAccount;
import io.bitsquare.btc.AddressEntry; import io.bitsquare.btc.AddressEntry;
import io.bitsquare.btc.FeePolicy; import io.bitsquare.btc.FeePolicy;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.btc.listeners.BalanceListener; import io.bitsquare.btc.listeners.BalanceListener;
import io.bitsquare.gui.UIModel; import io.bitsquare.gui.UIModel;
import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.gui.util.BSFormatter;
@ -68,7 +68,7 @@ class CreateOfferModel extends UIModel {
private static final Logger log = LoggerFactory.getLogger(CreateOfferModel.class); private static final Logger log = LoggerFactory.getLogger(CreateOfferModel.class);
private final TradeManager tradeManager; private final TradeManager tradeManager;
private final WalletFacade walletFacade; private final WalletService walletService;
private final AccountSettings accountSettings; private final AccountSettings accountSettings;
private ApplicationPreferences applicationPreferences; private ApplicationPreferences applicationPreferences;
private final User user; private final User user;
@ -112,11 +112,11 @@ class CreateOfferModel extends UIModel {
// non private for testing // non private for testing
@Inject @Inject
public CreateOfferModel(TradeManager tradeManager, WalletFacade walletFacade, AccountSettings accountSettings, public CreateOfferModel(TradeManager tradeManager, WalletService walletService, AccountSettings accountSettings,
ApplicationPreferences applicationPreferences, User user, Persistence persistence, ApplicationPreferences applicationPreferences, User user, Persistence persistence,
BSFormatter formatter) { BSFormatter formatter) {
this.tradeManager = tradeManager; this.tradeManager = tradeManager;
this.walletFacade = walletFacade; this.walletService = walletService;
this.accountSettings = accountSettings; this.accountSettings = accountSettings;
this.applicationPreferences = applicationPreferences; this.applicationPreferences = applicationPreferences;
this.user = user; this.user = user;
@ -137,16 +137,16 @@ class CreateOfferModel extends UIModel {
offerFeeAsCoin.set(FeePolicy.CREATE_OFFER_FEE); offerFeeAsCoin.set(FeePolicy.CREATE_OFFER_FEE);
networkFeeAsCoin.set(FeePolicy.TX_FEE); networkFeeAsCoin.set(FeePolicy.TX_FEE);
if (walletFacade != null && walletFacade.getWallet() != null) { if (walletService != null && walletService.getWallet() != null) {
addressEntry = walletFacade.getAddressInfoByTradeID(offerId); addressEntry = walletService.getAddressInfoByTradeID(offerId);
walletFacade.addBalanceListener(new BalanceListener(getAddressEntry().getAddress()) { walletService.addBalanceListener(new BalanceListener(getAddressEntry().getAddress()) {
@Override @Override
public void onBalanceChanged(@NotNull Coin balance) { public void onBalanceChanged(@NotNull Coin balance) {
updateBalance(balance); updateBalance(balance);
} }
}); });
updateBalance(walletFacade.getBalanceForAddress(getAddressEntry().getAddress())); updateBalance(walletService.getBalanceForAddress(getAddressEntry().getAddress()));
} }
if (user != null) { if (user != null) {
@ -280,8 +280,8 @@ class CreateOfferModel extends UIModel {
this.direction = direction; this.direction = direction;
} }
WalletFacade getWalletFacade() { WalletService getWalletService() {
return walletFacade; return walletService;
} }
String getOfferId() { String getOfferId() {

View file

@ -17,7 +17,7 @@
package io.bitsquare.gui.main.trade.createoffer; package io.bitsquare.gui.main.trade.createoffer;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.gui.PresentationModel; import io.bitsquare.gui.PresentationModel;
import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.gui.util.validation.BtcValidator; import io.bitsquare.gui.util.validation.BtcValidator;
@ -295,8 +295,8 @@ class CreateOfferPM extends PresentationModel<CreateOfferModel> {
// Getters // Getters
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
WalletFacade getWalletFacade() { WalletService getWalletService() {
return model.getWalletFacade(); return model.getWalletService();
} }
BSFormatter getFormatter() { BSFormatter getFormatter() {

View file

@ -130,7 +130,7 @@ public class CreateOfferViewCB extends CachedViewCB<CreateOfferPM> {
setupListeners(); setupListeners();
setupBindings(); setupBindings();
balanceTextField.setup(presentationModel.getWalletFacade(), presentationModel.address.get(), balanceTextField.setup(presentationModel.getWalletService(), presentationModel.address.get(),
presentationModel.getFormatter()); presentationModel.getFormatter());
volumeTextField.setPromptText(BSResources.get("createOffer.volume.prompt", presentationModel.fiatCode.get())); volumeTextField.setPromptText(BSResources.get("createOffer.volume.prompt", presentationModel.fiatCode.get()));
} }

View file

@ -19,7 +19,7 @@ package io.bitsquare.gui.main.trade.takeoffer;
import io.bitsquare.btc.AddressEntry; import io.bitsquare.btc.AddressEntry;
import io.bitsquare.btc.FeePolicy; import io.bitsquare.btc.FeePolicy;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.btc.listeners.BalanceListener; import io.bitsquare.btc.listeners.BalanceListener;
import io.bitsquare.gui.UIModel; import io.bitsquare.gui.UIModel;
import io.bitsquare.offer.Offer; import io.bitsquare.offer.Offer;
@ -55,7 +55,7 @@ class TakeOfferModel extends UIModel {
private static final Logger log = LoggerFactory.getLogger(TakeOfferModel.class); private static final Logger log = LoggerFactory.getLogger(TakeOfferModel.class);
private final TradeManager tradeManager; private final TradeManager tradeManager;
private final WalletFacade walletFacade; private final WalletService walletService;
private final ApplicationPreferences applicationPreferences; private final ApplicationPreferences applicationPreferences;
private final Persistence persistence; private final Persistence persistence;
@ -83,10 +83,10 @@ class TakeOfferModel extends UIModel {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Inject @Inject
TakeOfferModel(TradeManager tradeManager, WalletFacade walletFacade, ApplicationPreferences applicationPreferences, TakeOfferModel(TradeManager tradeManager, WalletService walletService, ApplicationPreferences applicationPreferences,
Persistence persistence) { Persistence persistence) {
this.tradeManager = tradeManager; this.tradeManager = tradeManager;
this.walletFacade = walletFacade; this.walletService = walletService;
this.applicationPreferences = applicationPreferences; this.applicationPreferences = applicationPreferences;
this.persistence = persistence; this.persistence = persistence;
} }
@ -146,14 +146,14 @@ class TakeOfferModel extends UIModel {
calculateVolume(); calculateVolume();
calculateTotalToPay(); calculateTotalToPay();
addressEntry = walletFacade.getAddressInfoByTradeID(offer.getId()); addressEntry = walletService.getAddressInfoByTradeID(offer.getId());
walletFacade.addBalanceListener(new BalanceListener(addressEntry.getAddress()) { walletService.addBalanceListener(new BalanceListener(addressEntry.getAddress()) {
@Override @Override
public void onBalanceChanged(@NotNull Coin balance) { public void onBalanceChanged(@NotNull Coin balance) {
updateBalance(balance); updateBalance(balance);
} }
}); });
updateBalance(walletFacade.getBalanceForAddress(addressEntry.getAddress())); updateBalance(walletService.getBalanceForAddress(addressEntry.getAddress()));
} }
void takeOffer() { void takeOffer() {
@ -242,8 +242,8 @@ class TakeOfferModel extends UIModel {
// Getter // Getter
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
WalletFacade getWalletFacade() { WalletService getWalletService() {
return walletFacade; return walletService;
} }
AddressEntry getAddressEntry() { AddressEntry getAddressEntry() {

View file

@ -17,7 +17,7 @@
package io.bitsquare.gui.main.trade.takeoffer; package io.bitsquare.gui.main.trade.takeoffer;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.gui.PresentationModel; import io.bitsquare.gui.PresentationModel;
import io.bitsquare.gui.util.BSFormatter; import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.gui.util.validation.BtcValidator; import io.bitsquare.gui.util.validation.BtcValidator;
@ -232,8 +232,8 @@ class TakeOfferPM extends PresentationModel<TakeOfferModel> {
// Getters // Getters
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
WalletFacade getWalletFacade() { WalletService getWalletService() {
return model.getWalletFacade(); return model.getWalletService();
} }
BSFormatter getFormatter() { BSFormatter getFormatter() {

View file

@ -167,7 +167,7 @@ public class TakeOfferViewCB extends CachedViewCB<TakeOfferPM> {
volumeDescriptionLabel.setText(BSResources.get("takeOffer.amountPriceBox.volumeDescription", volumeDescriptionLabel.setText(BSResources.get("takeOffer.amountPriceBox.volumeDescription",
presentationModel.getFiatCode())); presentationModel.getFiatCode()));
balanceTextField.setup(presentationModel.getWalletFacade(), presentationModel.address.get(), balanceTextField.setup(presentationModel.getWalletService(), presentationModel.address.get(),
presentationModel.getFormatter()); presentationModel.getFormatter());
buyLabel.setText(presentationModel.getDirectionLabel()); buyLabel.setText(presentationModel.getDirectionLabel());

View file

@ -31,7 +31,7 @@ public abstract class MessageModule extends BitsquareModule {
@Override @Override
protected final void configure() { protected final void configure() {
bind(MessageFacade.class).to(messageFacade()).asEagerSingleton(); bind(MessageService.class).to(messageService()).asEagerSingleton();
doConfigure(); doConfigure();
} }
@ -39,10 +39,10 @@ public abstract class MessageModule extends BitsquareModule {
protected void doConfigure() { protected void doConfigure() {
} }
protected abstract Class<? extends MessageFacade> messageFacade(); protected abstract Class<? extends MessageService> messageService();
@Override @Override
protected void doClose(Injector injector) { protected void doClose(Injector injector) {
injector.getInstance(MessageFacade.class).shutDown(); injector.getInstance(MessageService.class).shutDown();
} }
} }

View file

@ -29,7 +29,7 @@ import java.security.PublicKey;
import java.util.Locale; import java.util.Locale;
public interface MessageFacade extends MessageBroker { public interface MessageService extends MessageBroker {
void sendMessage(Peer peer, Message message, OutgoingMessageListener listener); void sendMessage(Peer peer, Message message, OutgoingMessageListener listener);

View file

@ -17,7 +17,7 @@
package io.bitsquare.msg.tomp2p; package io.bitsquare.msg.tomp2p;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageService;
import io.bitsquare.msg.MessageModule; import io.bitsquare.msg.MessageModule;
import io.bitsquare.network.BootstrapNodes; import io.bitsquare.network.BootstrapNodes;
import io.bitsquare.network.Node; import io.bitsquare.network.Node;
@ -58,7 +58,7 @@ public class TomP2PMessageModule extends MessageModule {
} }
@Override @Override
protected Class<? extends MessageFacade> messageFacade() { protected Class<? extends MessageService> messageService() {
return TomP2PMessageFacade.class; return TomP2PMessageService.class;
} }
} }

View file

@ -19,7 +19,7 @@ package io.bitsquare.msg.tomp2p;
import io.bitsquare.arbitrator.Arbitrator; import io.bitsquare.arbitrator.Arbitrator;
import io.bitsquare.msg.Message; import io.bitsquare.msg.Message;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageService;
import io.bitsquare.msg.listeners.ArbitratorListener; import io.bitsquare.msg.listeners.ArbitratorListener;
import io.bitsquare.msg.listeners.BootstrapListener; import io.bitsquare.msg.listeners.BootstrapListener;
import io.bitsquare.msg.listeners.GetPeerAddressListener; import io.bitsquare.msg.listeners.GetPeerAddressListener;
@ -59,15 +59,15 @@ import static io.bitsquare.util.tomp2p.BaseFutureUtil.isSuccess;
/** /**
* That facade delivers direct messaging and DHT functionality from the TomP2P library * That service delivers direct messaging and DHT functionality from the TomP2P library
* It is the translating domain specific functionality to the messaging layer. * It is the translating domain specific functionality to the messaging layer.
* The TomP2P library codebase shall not be used outside that facade. * The TomP2P library codebase shall not be used outside that service.
* That way we limit the dependency of the TomP2P library only to that class (and it's sub components). * That way we limit the dependency of the TomP2P library only to that class (and it's sub components).
* <p> * <p>
* TODO: improve callbacks that Platform.runLater is not necessary. We call usually that methods form teh UI thread. * TODO: improve callbacks that Platform.runLater is not necessary. We call usually that methods form teh UI thread.
*/ */
class TomP2PMessageFacade implements MessageFacade { class TomP2PMessageService implements MessageService {
private static final Logger log = LoggerFactory.getLogger(TomP2PMessageFacade.class); private static final Logger log = LoggerFactory.getLogger(TomP2PMessageService.class);
private static final String ARBITRATORS_ROOT = "ArbitratorsRoot"; private static final String ARBITRATORS_ROOT = "ArbitratorsRoot";
private final TomP2PNode p2pNode; private final TomP2PNode p2pNode;
@ -82,7 +82,7 @@ class TomP2PMessageFacade implements MessageFacade {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
@Inject @Inject
public TomP2PMessageFacade(User user, TomP2PNode p2pNode) { public TomP2PMessageService(User user, TomP2PNode p2pNode) {
this.user = user; this.user = user;
this.p2pNode = p2pNode; this.p2pNode = p2pNode;
} }

View file

@ -18,11 +18,11 @@
package io.bitsquare.trade; package io.bitsquare.trade;
import io.bitsquare.account.AccountSettings; import io.bitsquare.account.AccountSettings;
import io.bitsquare.btc.BlockChainFacade; import io.bitsquare.btc.BlockChainService;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.crypto.CryptoFacade; import io.bitsquare.crypto.CryptoService;
import io.bitsquare.msg.Message; import io.bitsquare.msg.Message;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageService;
import io.bitsquare.network.Peer; import io.bitsquare.network.Peer;
import io.bitsquare.offer.Direction; import io.bitsquare.offer.Direction;
import io.bitsquare.offer.Offer; import io.bitsquare.offer.Offer;
@ -75,10 +75,10 @@ public class TradeManager {
private final User user; private final User user;
private final AccountSettings accountSettings; private final AccountSettings accountSettings;
private final Persistence persistence; private final Persistence persistence;
private final MessageFacade messageFacade; private final MessageService messageService;
private final BlockChainFacade blockChainFacade; private final BlockChainService blockChainService;
private final WalletFacade walletFacade; private final WalletService walletService;
private final CryptoFacade cryptoFacade; private final CryptoService cryptoService;
private final OfferRepository offerRepository; private final OfferRepository offerRepository;
//TODO store TakerAsSellerProtocol in trade //TODO store TakerAsSellerProtocol in trade
@ -100,16 +100,16 @@ public class TradeManager {
@Inject @Inject
public TradeManager(User user, AccountSettings accountSettings, Persistence persistence, public TradeManager(User user, AccountSettings accountSettings, Persistence persistence,
MessageFacade messageFacade, MessageService messageService,
BlockChainFacade blockChainFacade, WalletFacade walletFacade, CryptoFacade cryptoFacade, BlockChainService blockChainService, WalletService walletService, CryptoService cryptoService,
OfferRepository offerRepository) { OfferRepository offerRepository) {
this.user = user; this.user = user;
this.accountSettings = accountSettings; this.accountSettings = accountSettings;
this.persistence = persistence; this.persistence = persistence;
this.messageFacade = messageFacade; this.messageService = messageService;
this.blockChainFacade = blockChainFacade; this.blockChainService = blockChainService;
this.walletFacade = walletFacade; this.walletService = walletService;
this.cryptoFacade = cryptoFacade; this.cryptoService = cryptoService;
this.offerRepository = offerRepository; this.offerRepository = offerRepository;
Object offersObject = persistence.read(this, "offers"); Object offersObject = persistence.read(this, "offers");
@ -127,7 +127,7 @@ public class TradeManager {
closedTrades.putAll((Map<String, Trade>) closedTradesObject); closedTrades.putAll((Map<String, Trade>) closedTradesObject);
} }
messageFacade.addIncomingMessageListener(this::onIncomingTradeMessage); messageService.addIncomingMessageListener(this::onIncomingTradeMessage);
} }
@ -136,7 +136,7 @@ public class TradeManager {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
public void cleanup() { public void cleanup() {
messageFacade.removeIncomingMessageListener(this::onIncomingTradeMessage); messageService.removeIncomingMessageListener(this::onIncomingTradeMessage);
} }
@ -169,7 +169,7 @@ public class TradeManager {
CreateOfferCoordinator createOfferCoordinator = new CreateOfferCoordinator( CreateOfferCoordinator createOfferCoordinator = new CreateOfferCoordinator(
offer, offer,
walletFacade, walletService,
(transactionId) -> { (transactionId) -> {
try { try {
offer.setOfferFeePaymentTxID(transactionId.getHashAsString()); offer.setOfferFeePaymentTxID(transactionId.getHashAsString());
@ -246,10 +246,10 @@ public class TradeManager {
BuyerAcceptsOfferProtocol buyerAcceptsOfferProtocol = new BuyerAcceptsOfferProtocol(trade, BuyerAcceptsOfferProtocol buyerAcceptsOfferProtocol = new BuyerAcceptsOfferProtocol(trade,
sender, sender,
messageFacade, messageService,
walletFacade, walletService,
blockChainFacade, blockChainService,
cryptoFacade, cryptoService,
user, user,
new BuyerAcceptsOfferProtocolListener() { new BuyerAcceptsOfferProtocolListener() {
@Override @Override
@ -372,7 +372,7 @@ public class TradeManager {
}; };
SellerTakesOfferProtocol sellerTakesOfferProtocol = new SellerTakesOfferProtocol( SellerTakesOfferProtocol sellerTakesOfferProtocol = new SellerTakesOfferProtocol(
trade, listener, messageFacade, walletFacade, blockChainFacade, cryptoFacade, trade, listener, messageService, walletService, blockChainService, cryptoService,
user); user);
takerAsSellerProtocolMap.put(trade.getId(), sellerTakesOfferProtocol); takerAsSellerProtocolMap.put(trade.getId(), sellerTakesOfferProtocol);
sellerTakesOfferProtocol.start(); sellerTakesOfferProtocol.start();

View file

@ -17,7 +17,7 @@
package io.bitsquare.trade.protocol.createoffer; package io.bitsquare.trade.protocol.createoffer;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.offer.Offer; import io.bitsquare.offer.Offer;
import io.bitsquare.offer.OfferRepository; import io.bitsquare.offer.OfferRepository;
import io.bitsquare.trade.handlers.TransactionResultHandler; import io.bitsquare.trade.handlers.TransactionResultHandler;
@ -39,15 +39,15 @@ public class CreateOfferCoordinator {
private static final Logger log = LoggerFactory.getLogger(CreateOfferCoordinator.class); private static final Logger log = LoggerFactory.getLogger(CreateOfferCoordinator.class);
private final Offer offer; private final Offer offer;
private final WalletFacade walletFacade; private final WalletService walletService;
private final TransactionResultHandler resultHandler; private final TransactionResultHandler resultHandler;
private final FaultHandler faultHandler; private final FaultHandler faultHandler;
private final OfferRepository offerRepository; private final OfferRepository offerRepository;
public CreateOfferCoordinator(Offer offer, WalletFacade walletFacade, TransactionResultHandler resultHandler, public CreateOfferCoordinator(Offer offer, WalletService walletService, TransactionResultHandler resultHandler,
FaultHandler faultHandler, OfferRepository offerRepository) { FaultHandler faultHandler, OfferRepository offerRepository) {
this.offer = offer; this.offer = offer;
this.walletFacade = walletFacade; this.walletService = walletService;
this.resultHandler = resultHandler; this.resultHandler = resultHandler;
this.faultHandler = faultHandler; this.faultHandler = faultHandler;
this.offerRepository = offerRepository; this.offerRepository = offerRepository;
@ -64,7 +64,7 @@ public class CreateOfferCoordinator {
Transaction transaction; Transaction transaction;
try { try {
transaction = walletFacade.createOfferFeeTx(offer.getId()); transaction = walletService.createOfferFeeTx(offer.getId());
offer.setOfferFeePaymentTxID(transaction.getHashAsString()); offer.setOfferFeePaymentTxID(transaction.getHashAsString());
} catch (InsufficientMoneyException ex) { } catch (InsufficientMoneyException ex) {
faultHandler.handleFault( faultHandler.handleFault(
@ -76,7 +76,7 @@ public class CreateOfferCoordinator {
} }
try { try {
walletFacade.broadcastCreateOfferFeeTx(transaction, new FutureCallback<Transaction>() { walletService.broadcastCreateOfferFeeTx(transaction, new FutureCallback<Transaction>() {
@Override @Override
public void onSuccess(Transaction transaction) { public void onSuccess(Transaction transaction) {
log.info("sendResult onSuccess:" + transaction); log.info("sendResult onSuccess:" + transaction);

View file

@ -18,11 +18,11 @@
package io.bitsquare.trade.protocol.trade.offerer; package io.bitsquare.trade.protocol.trade.offerer;
import io.bitsquare.bank.BankAccount; import io.bitsquare.bank.BankAccount;
import io.bitsquare.btc.BlockChainFacade; import io.bitsquare.btc.BlockChainService;
import io.bitsquare.btc.FeePolicy; import io.bitsquare.btc.FeePolicy;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.crypto.CryptoFacade; import io.bitsquare.crypto.CryptoService;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageService;
import io.bitsquare.network.Peer; import io.bitsquare.network.Peer;
import io.bitsquare.offer.Offer; import io.bitsquare.offer.Offer;
import io.bitsquare.trade.Contract; import io.bitsquare.trade.Contract;
@ -96,10 +96,10 @@ public class BuyerAcceptsOfferProtocol {
// provided // provided
private final Trade trade; private final Trade trade;
private final Peer peer; private final Peer peer;
private final MessageFacade messageFacade; private final MessageService messageService;
private final WalletFacade walletFacade; private final WalletService walletService;
private final BlockChainFacade blockChainFacade; private final BlockChainService blockChainService;
private final CryptoFacade cryptoFacade; private final CryptoService cryptoService;
private final BuyerAcceptsOfferProtocolListener listener; private final BuyerAcceptsOfferProtocolListener listener;
// derived // derived
@ -139,19 +139,19 @@ public class BuyerAcceptsOfferProtocol {
public BuyerAcceptsOfferProtocol(Trade trade, public BuyerAcceptsOfferProtocol(Trade trade,
Peer peer, Peer peer,
MessageFacade messageFacade, MessageService messageService,
WalletFacade walletFacade, WalletService walletService,
BlockChainFacade blockChainFacade, BlockChainService blockChainService,
CryptoFacade cryptoFacade, CryptoService cryptoService,
User user, User user,
BuyerAcceptsOfferProtocolListener listener) { BuyerAcceptsOfferProtocolListener listener) {
this.trade = trade; this.trade = trade;
this.peer = peer; this.peer = peer;
this.listener = listener; this.listener = listener;
this.messageFacade = messageFacade; this.messageService = messageService;
this.walletFacade = walletFacade; this.walletService = walletService;
this.blockChainFacade = blockChainFacade; this.blockChainService = blockChainService;
this.cryptoFacade = cryptoFacade; this.cryptoService = cryptoService;
tradeId = trade.getId(); tradeId = trade.getId();
offer = trade.getOffer(); offer = trade.getOffer();
@ -163,8 +163,8 @@ public class BuyerAcceptsOfferProtocol {
accountId = user.getAccountId(); accountId = user.getAccountId();
messagePublicKey = user.getMessagePublicKey(); messagePublicKey = user.getMessagePublicKey();
accountKey = walletFacade.getRegistrationAddressEntry().getKey(); accountKey = walletService.getRegistrationAddressEntry().getKey();
payoutAddress = walletFacade.getAddressInfoByTradeID(tradeId).getAddressString(); payoutAddress = walletService.getAddressInfoByTradeID(tradeId).getAddressString();
state = State.Init; state = State.Init;
} }
@ -172,7 +172,7 @@ public class BuyerAcceptsOfferProtocol {
public void start() { public void start() {
log.debug("start called " + step++); log.debug("start called " + step++);
state = State.HandleTakeOfferRequest; state = State.HandleTakeOfferRequest;
HandleTakeOfferRequest.run(this::onResultHandleTakeOfferRequest, this::onFault, peer, messageFacade, HandleTakeOfferRequest.run(this::onResultHandleTakeOfferRequest, this::onFault, peer, messageService,
trade.getState(), tradeId); trade.getState(), tradeId);
} }
@ -213,7 +213,7 @@ public class BuyerAcceptsOfferProtocol {
// next task // next task
state = State.VerifyTakeOfferFeePayment; state = State.VerifyTakeOfferFeePayment;
VerifyTakeOfferFeePayment.run(this::onResultVerifyTakeOfferFeePayment, this::onFault, walletFacade, VerifyTakeOfferFeePayment.run(this::onResultVerifyTakeOfferFeePayment, this::onFault, walletService,
this.takeOfferFeeTxId); this.takeOfferFeeTxId);
} }
@ -222,7 +222,7 @@ public class BuyerAcceptsOfferProtocol {
Coin offererInputAmount = trade.getSecurityDeposit().add(FeePolicy.TX_FEE); Coin offererInputAmount = trade.getSecurityDeposit().add(FeePolicy.TX_FEE);
state = State.CreateDepositTx; state = State.CreateDepositTx;
CreateDepositTx.run(this::onResultCreateDepositTx, this::onFault, walletFacade, tradeId, offererInputAmount, CreateDepositTx.run(this::onResultCreateDepositTx, this::onFault, walletService, tradeId, offererInputAmount,
takerPubKey, arbitratorPubKey); takerPubKey, arbitratorPubKey);
} }
@ -236,7 +236,7 @@ public class BuyerAcceptsOfferProtocol {
RequestTakerDepositPayment.run(this::onResultRequestTakerDepositPayment, RequestTakerDepositPayment.run(this::onResultRequestTakerDepositPayment,
this::onFault, this::onFault,
peer, peer,
messageFacade, messageService,
tradeId, tradeId,
bankAccount, bankAccount,
accountId, accountId,
@ -286,7 +286,7 @@ public class BuyerAcceptsOfferProtocol {
// next task // next task
state = State.VerifyTakerAccount; state = State.VerifyTakerAccount;
VerifyTakerAccount.run(this::onResultVerifyTakerAccount, this::onFault, blockChainFacade, VerifyTakerAccount.run(this::onResultVerifyTakerAccount, this::onFault, blockChainService,
this.peersAccountId, this.peersBankAccount); this.peersAccountId, this.peersBankAccount);
} }
@ -297,7 +297,7 @@ public class BuyerAcceptsOfferProtocol {
state = State.VerifyAndSignContract; state = State.VerifyAndSignContract;
VerifyAndSignContract.run(this::onResultVerifyAndSignContract, VerifyAndSignContract.run(this::onResultVerifyAndSignContract,
this::onFault, this::onFault,
cryptoFacade, cryptoService,
accountId, accountId,
tradeAmount, tradeAmount,
takeOfferFeeTxId, takeOfferFeeTxId,
@ -320,7 +320,7 @@ public class BuyerAcceptsOfferProtocol {
state = State.SignAndPublishDepositTx; state = State.SignAndPublishDepositTx;
SignAndPublishDepositTx.run(this::onResultSignAndPublishDepositTx, SignAndPublishDepositTx.run(this::onResultSignAndPublishDepositTx,
this::onFault, this::onFault,
walletFacade, walletService,
preparedOffererDepositTxAsHex, preparedOffererDepositTxAsHex,
signedTakerDepositTxAsHex, signedTakerDepositTxAsHex,
txConnOutAsHex, txConnOutAsHex,
@ -335,7 +335,7 @@ public class BuyerAcceptsOfferProtocol {
listener.onDepositTxPublished(depositTransaction); listener.onDepositTxPublished(depositTransaction);
state = State.SendDepositTxIdToTaker; state = State.SendDepositTxIdToTaker;
SendDepositTxIdToTaker.run(this::onResultSendDepositTxIdToTaker, this::onFault, peer, messageFacade, SendDepositTxIdToTaker.run(this::onResultSendDepositTxIdToTaker, this::onFault, peer, messageService,
tradeId, depositTransaction); tradeId, depositTransaction);
} }
@ -378,8 +378,8 @@ public class BuyerAcceptsOfferProtocol {
SendSignedPayoutTx.run(this::onResultSendSignedPayoutTx, SendSignedPayoutTx.run(this::onResultSendSignedPayoutTx,
this::onFault, this::onFault,
peer, peer,
messageFacade, messageService,
walletFacade, walletService,
tradeId, tradeId,
peersPayoutAddress, peersPayoutAddress,
payoutAddress, payoutAddress,
@ -410,7 +410,7 @@ public class BuyerAcceptsOfferProtocol {
state = State.onPayoutTxPublishedMessage; state = State.onPayoutTxPublishedMessage;
Transaction payoutTx = new Transaction(walletFacade.getWallet().getParams(), Transaction payoutTx = new Transaction(walletService.getWallet().getParams(),
Utils.parseAsHexOrBase58(payoutTxAsHex)); Utils.parseAsHexOrBase58(payoutTxAsHex));
listener.onPayoutTxPublished(payoutTx); listener.onPayoutTxPublished(payoutTx);
} }

View file

@ -17,7 +17,7 @@
package io.bitsquare.trade.protocol.trade.offerer.tasks; package io.bitsquare.trade.protocol.trade.offerer.tasks;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.util.task.ExceptionHandler; import io.bitsquare.util.task.ExceptionHandler;
import org.bitcoinj.core.Coin; import org.bitcoinj.core.Coin;
@ -33,15 +33,15 @@ public class CreateDepositTx {
public static void run(ResultHandler resultHandler, public static void run(ResultHandler resultHandler,
ExceptionHandler exceptionHandler, ExceptionHandler exceptionHandler,
WalletFacade walletFacade, WalletService walletService,
String tradeId, String tradeId,
Coin offererInputAmount, Coin offererInputAmount,
String takerMultiSigPubKey, String takerMultiSigPubKey,
String arbitratorPubKeyAsHex) { String arbitratorPubKeyAsHex) {
log.trace("Run task"); log.trace("Run task");
try { try {
String offererPubKey = walletFacade.getAddressInfoByTradeID(tradeId).getPubKeyAsHexString(); String offererPubKey = walletService.getAddressInfoByTradeID(tradeId).getPubKeyAsHexString();
Transaction transaction = walletFacade.offererCreatesMSTxAndAddPayment( Transaction transaction = walletService.offererCreatesMSTxAndAddPayment(
offererInputAmount, offererPubKey, takerMultiSigPubKey, arbitratorPubKeyAsHex, tradeId); offererInputAmount, offererPubKey, takerMultiSigPubKey, arbitratorPubKeyAsHex, tradeId);
String preparedOffererDepositTxAsHex = Utils.HEX.encode(transaction.bitcoinSerialize()); String preparedOffererDepositTxAsHex = Utils.HEX.encode(transaction.bitcoinSerialize());

View file

@ -17,7 +17,7 @@
package io.bitsquare.trade.protocol.trade.offerer.tasks; package io.bitsquare.trade.protocol.trade.offerer.tasks;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageService;
import io.bitsquare.msg.listeners.OutgoingMessageListener; import io.bitsquare.msg.listeners.OutgoingMessageListener;
import io.bitsquare.network.Peer; import io.bitsquare.network.Peer;
import io.bitsquare.trade.Trade; import io.bitsquare.trade.Trade;
@ -31,7 +31,7 @@ public class HandleTakeOfferRequest {
private static final Logger log = LoggerFactory.getLogger(HandleTakeOfferRequest.class); private static final Logger log = LoggerFactory.getLogger(HandleTakeOfferRequest.class);
public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler, Peer peer, public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler, Peer peer,
MessageFacade messageFacade, Trade.State tradeState, String tradeId) { MessageService messageService, Trade.State tradeState, String tradeId) {
log.trace("Run task"); log.trace("Run task");
boolean takeOfferRequestAccepted = tradeState == Trade.State.OPEN; boolean takeOfferRequestAccepted = tradeState == Trade.State.OPEN;
if (!takeOfferRequestAccepted) { if (!takeOfferRequestAccepted) {
@ -39,7 +39,7 @@ public class HandleTakeOfferRequest {
} }
RespondToTakeOfferRequestMessage tradeMessage = RespondToTakeOfferRequestMessage tradeMessage =
new RespondToTakeOfferRequestMessage(tradeId, takeOfferRequestAccepted); new RespondToTakeOfferRequestMessage(tradeId, takeOfferRequestAccepted);
messageFacade.sendMessage(peer, tradeMessage, new OutgoingMessageListener() { messageService.sendMessage(peer, tradeMessage, new OutgoingMessageListener() {
@Override @Override
public void onResult() { public void onResult() {
log.trace("RespondToTakeOfferRequestMessage successfully arrived at peer"); log.trace("RespondToTakeOfferRequestMessage successfully arrived at peer");

View file

@ -18,7 +18,7 @@
package io.bitsquare.trade.protocol.trade.offerer.tasks; package io.bitsquare.trade.protocol.trade.offerer.tasks;
import io.bitsquare.bank.BankAccount; import io.bitsquare.bank.BankAccount;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageService;
import io.bitsquare.msg.listeners.OutgoingMessageListener; import io.bitsquare.msg.listeners.OutgoingMessageListener;
import io.bitsquare.network.Peer; import io.bitsquare.network.Peer;
import io.bitsquare.trade.protocol.trade.offerer.messages.RequestTakerDepositPaymentMessage; import io.bitsquare.trade.protocol.trade.offerer.messages.RequestTakerDepositPaymentMessage;
@ -34,7 +34,7 @@ public class RequestTakerDepositPayment {
public static void run(ResultHandler resultHandler, public static void run(ResultHandler resultHandler,
ExceptionHandler exceptionHandler, ExceptionHandler exceptionHandler,
Peer peer, Peer peer,
MessageFacade messageFacade, MessageService messageService,
String tradeId, String tradeId,
BankAccount bankAccount, BankAccount bankAccount,
String accountId, String accountId,
@ -44,7 +44,7 @@ public class RequestTakerDepositPayment {
log.trace("Run task"); log.trace("Run task");
RequestTakerDepositPaymentMessage tradeMessage = new RequestTakerDepositPaymentMessage( RequestTakerDepositPaymentMessage tradeMessage = new RequestTakerDepositPaymentMessage(
tradeId, bankAccount, accountId, offererPubKey, preparedOffererDepositTxAsHex, offererTxOutIndex); tradeId, bankAccount, accountId, offererPubKey, preparedOffererDepositTxAsHex, offererTxOutIndex);
messageFacade.sendMessage(peer, tradeMessage, new OutgoingMessageListener() { messageService.sendMessage(peer, tradeMessage, new OutgoingMessageListener() {
@Override @Override
public void onResult() { public void onResult() {
log.trace("RequestTakerDepositPaymentMessage successfully arrived at peer"); log.trace("RequestTakerDepositPaymentMessage successfully arrived at peer");

View file

@ -17,7 +17,7 @@
package io.bitsquare.trade.protocol.trade.offerer.tasks; package io.bitsquare.trade.protocol.trade.offerer.tasks;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageService;
import io.bitsquare.msg.listeners.OutgoingMessageListener; import io.bitsquare.msg.listeners.OutgoingMessageListener;
import io.bitsquare.network.Peer; import io.bitsquare.network.Peer;
import io.bitsquare.trade.protocol.trade.offerer.messages.DepositTxPublishedMessage; import io.bitsquare.trade.protocol.trade.offerer.messages.DepositTxPublishedMessage;
@ -34,12 +34,12 @@ public class SendDepositTxIdToTaker {
private static final Logger log = LoggerFactory.getLogger(SendDepositTxIdToTaker.class); private static final Logger log = LoggerFactory.getLogger(SendDepositTxIdToTaker.class);
public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler, Peer peer, public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler, Peer peer,
MessageFacade messageFacade, String tradeId, Transaction depositTransaction) { MessageService messageService, String tradeId, Transaction depositTransaction) {
log.trace("Run task"); log.trace("Run task");
DepositTxPublishedMessage tradeMessage = DepositTxPublishedMessage tradeMessage =
new DepositTxPublishedMessage(tradeId, Utils.HEX.encode(depositTransaction.bitcoinSerialize())); new DepositTxPublishedMessage(tradeId, Utils.HEX.encode(depositTransaction.bitcoinSerialize()));
messageFacade.sendMessage(peer, tradeMessage, new OutgoingMessageListener() { messageService.sendMessage(peer, tradeMessage, new OutgoingMessageListener() {
@Override @Override
public void onResult() { public void onResult() {
log.trace("DepositTxPublishedMessage successfully arrived at peer"); log.trace("DepositTxPublishedMessage successfully arrived at peer");

View file

@ -17,8 +17,8 @@
package io.bitsquare.trade.protocol.trade.offerer.tasks; package io.bitsquare.trade.protocol.trade.offerer.tasks;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageService;
import io.bitsquare.msg.listeners.OutgoingMessageListener; import io.bitsquare.msg.listeners.OutgoingMessageListener;
import io.bitsquare.network.Peer; import io.bitsquare.network.Peer;
import io.bitsquare.trade.protocol.trade.offerer.messages.BankTransferInitedMessage; import io.bitsquare.trade.protocol.trade.offerer.messages.BankTransferInitedMessage;
@ -39,8 +39,8 @@ public class SendSignedPayoutTx {
public static void run(ResultHandler resultHandler, public static void run(ResultHandler resultHandler,
ExceptionHandler exceptionHandler, ExceptionHandler exceptionHandler,
Peer peer, Peer peer,
MessageFacade messageFacade, MessageService messageService,
WalletFacade walletFacade, WalletService walletService,
String tradeId, String tradeId,
String takerPayoutAddress, String takerPayoutAddress,
String offererPayoutAddress, String offererPayoutAddress,
@ -52,7 +52,7 @@ public class SendSignedPayoutTx {
Coin offererPaybackAmount = tradeAmount.add(securityDeposit); Coin offererPaybackAmount = tradeAmount.add(securityDeposit);
@SuppressWarnings("UnnecessaryLocalVariable") Coin takerPaybackAmount = securityDeposit; @SuppressWarnings("UnnecessaryLocalVariable") Coin takerPaybackAmount = securityDeposit;
Pair<ECKey.ECDSASignature, String> result = walletFacade.offererCreatesAndSignsPayoutTx( Pair<ECKey.ECDSASignature, String> result = walletService.offererCreatesAndSignsPayoutTx(
depositTransactionId, offererPaybackAmount, takerPaybackAmount, takerPayoutAddress, tradeId); depositTransactionId, offererPaybackAmount, takerPaybackAmount, takerPayoutAddress, tradeId);
ECKey.ECDSASignature offererSignature = result.getKey(); ECKey.ECDSASignature offererSignature = result.getKey();
@ -68,7 +68,7 @@ public class SendSignedPayoutTx {
takerPaybackAmount, takerPaybackAmount,
offererPayoutAddress); offererPayoutAddress);
messageFacade.sendMessage(peer, tradeMessage, new OutgoingMessageListener() { messageService.sendMessage(peer, tradeMessage, new OutgoingMessageListener() {
@Override @Override
public void onResult() { public void onResult() {
log.trace("BankTransferInitedMessage successfully arrived at peer"); log.trace("BankTransferInitedMessage successfully arrived at peer");

View file

@ -17,7 +17,7 @@
package io.bitsquare.trade.protocol.trade.offerer.tasks; package io.bitsquare.trade.protocol.trade.offerer.tasks;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.util.task.ExceptionHandler; import io.bitsquare.util.task.ExceptionHandler;
import org.bitcoinj.core.Transaction; import org.bitcoinj.core.Transaction;
@ -34,7 +34,7 @@ public class SignAndPublishDepositTx {
public static void run(ResultHandler resultHandler, public static void run(ResultHandler resultHandler,
ExceptionHandler exceptionHandler, ExceptionHandler exceptionHandler,
WalletFacade walletFacade, WalletService walletService,
String preparedOffererDepositTxAsHex, String preparedOffererDepositTxAsHex,
String signedTakerDepositTxAsHex, String signedTakerDepositTxAsHex,
String txConnOutAsHex, String txConnOutAsHex,
@ -43,7 +43,7 @@ public class SignAndPublishDepositTx {
long takerTxOutIndex) { long takerTxOutIndex) {
log.trace("Run task"); log.trace("Run task");
try { try {
walletFacade.offererSignAndPublishTx(preparedOffererDepositTxAsHex, walletService.offererSignAndPublishTx(preparedOffererDepositTxAsHex,
signedTakerDepositTxAsHex, signedTakerDepositTxAsHex,
txConnOutAsHex, txConnOutAsHex,
txScriptSigAsHex, txScriptSigAsHex,

View file

@ -18,7 +18,7 @@
package io.bitsquare.trade.protocol.trade.offerer.tasks; package io.bitsquare.trade.protocol.trade.offerer.tasks;
import io.bitsquare.bank.BankAccount; import io.bitsquare.bank.BankAccount;
import io.bitsquare.crypto.CryptoFacade; import io.bitsquare.crypto.CryptoService;
import io.bitsquare.offer.Offer; import io.bitsquare.offer.Offer;
import io.bitsquare.trade.Contract; import io.bitsquare.trade.Contract;
import io.bitsquare.util.Utilities; import io.bitsquare.util.Utilities;
@ -37,7 +37,7 @@ public class VerifyAndSignContract {
public static void run(ResultHandler resultHandler, public static void run(ResultHandler resultHandler,
ExceptionHandler exceptionHandler, ExceptionHandler exceptionHandler,
CryptoFacade cryptoFacade, CryptoService cryptoService,
String accountId, String accountId,
Coin tradeAmount, Coin tradeAmount,
String takeOfferFeeTxId, String takeOfferFeeTxId,
@ -56,7 +56,7 @@ public class VerifyAndSignContract {
String contractAsJson = Utilities.objectToJson(contract); String contractAsJson = Utilities.objectToJson(contract);
log.trace("The 2 contracts as json does match"); log.trace("The 2 contracts as json does match");
String signature = cryptoFacade.signContract(registrationKey, contractAsJson); String signature = cryptoService.signContract(registrationKey, contractAsJson);
//log.trace("signature: " + signature); //log.trace("signature: " + signature);
resultHandler.onResult(contract, contractAsJson, signature); resultHandler.onResult(contract, contractAsJson, signature);
} }

View file

@ -17,7 +17,7 @@
package io.bitsquare.trade.protocol.trade.offerer.tasks; package io.bitsquare.trade.protocol.trade.offerer.tasks;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.util.task.ExceptionHandler; import io.bitsquare.util.task.ExceptionHandler;
import io.bitsquare.util.task.ResultHandler; import io.bitsquare.util.task.ResultHandler;
@ -27,11 +27,11 @@ import org.slf4j.LoggerFactory;
public class VerifyTakeOfferFeePayment { public class VerifyTakeOfferFeePayment {
private static final Logger log = LoggerFactory.getLogger(VerifyTakeOfferFeePayment.class); private static final Logger log = LoggerFactory.getLogger(VerifyTakeOfferFeePayment.class);
public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler, WalletFacade walletFacade, public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler, WalletService walletService,
String takeOfferFeeTxId) { String takeOfferFeeTxId) {
log.trace("Run task"); log.trace("Run task");
//TODO mocked yet, need a confidence listeners //TODO mocked yet, need a confidence listeners
int numOfPeersSeenTx = walletFacade.getNumOfPeersSeenTx(takeOfferFeeTxId); int numOfPeersSeenTx = walletService.getNumOfPeersSeenTx(takeOfferFeeTxId);
if (numOfPeersSeenTx > 2) { if (numOfPeersSeenTx > 2) {
resultHandler.handleResult(); resultHandler.handleResult();
} }

View file

@ -18,7 +18,7 @@
package io.bitsquare.trade.protocol.trade.offerer.tasks; package io.bitsquare.trade.protocol.trade.offerer.tasks;
import io.bitsquare.bank.BankAccount; import io.bitsquare.bank.BankAccount;
import io.bitsquare.btc.BlockChainFacade; import io.bitsquare.btc.BlockChainService;
import io.bitsquare.trade.protocol.trade.shared.tasks.VerifyPeerAccount; import io.bitsquare.trade.protocol.trade.shared.tasks.VerifyPeerAccount;
import io.bitsquare.util.task.ExceptionHandler; import io.bitsquare.util.task.ExceptionHandler;
import io.bitsquare.util.task.ResultHandler; import io.bitsquare.util.task.ResultHandler;
@ -30,9 +30,9 @@ public class VerifyTakerAccount {
private static final Logger log = LoggerFactory.getLogger(VerifyTakerAccount.class); private static final Logger log = LoggerFactory.getLogger(VerifyTakerAccount.class);
public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler, public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler,
BlockChainFacade blockChainFacade, String peersAccountId, BankAccount peersBankAccount) { BlockChainService blockChainService, String peersAccountId, BankAccount peersBankAccount) {
log.trace("Run task"); log.trace("Run task");
VerifyPeerAccount.run(resultHandler, exceptionHandler, blockChainFacade, peersAccountId, peersBankAccount); VerifyPeerAccount.run(resultHandler, exceptionHandler, blockChainService, peersAccountId, peersBankAccount);
} }
} }

View file

@ -18,7 +18,7 @@
package io.bitsquare.trade.protocol.trade.shared.tasks; package io.bitsquare.trade.protocol.trade.shared.tasks;
import io.bitsquare.bank.BankAccount; import io.bitsquare.bank.BankAccount;
import io.bitsquare.btc.BlockChainFacade; import io.bitsquare.btc.BlockChainService;
import io.bitsquare.util.task.ExceptionHandler; import io.bitsquare.util.task.ExceptionHandler;
import io.bitsquare.util.task.ResultHandler; import io.bitsquare.util.task.ResultHandler;
@ -29,10 +29,10 @@ public class VerifyPeerAccount {
private static final Logger log = LoggerFactory.getLogger(VerifyPeerAccount.class); private static final Logger log = LoggerFactory.getLogger(VerifyPeerAccount.class);
public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler, public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler,
BlockChainFacade blockChainFacade, String peersAccountId, BankAccount peersBankAccount) { BlockChainService blockChainService, String peersAccountId, BankAccount peersBankAccount) {
//TODO mocked yet //TODO mocked yet
if (blockChainFacade.verifyAccountRegistration()) { if (blockChainService.verifyAccountRegistration()) {
if (blockChainFacade.isAccountBlackListed(peersAccountId, peersBankAccount)) { if (blockChainService.isAccountBlackListed(peersAccountId, peersBankAccount)) {
log.error("Taker is blacklisted"); log.error("Taker is blacklisted");
exceptionHandler.handleException(new Exception("Taker is blacklisted")); exceptionHandler.handleException(new Exception("Taker is blacklisted"));
} }

View file

@ -18,10 +18,10 @@
package io.bitsquare.trade.protocol.trade.taker; package io.bitsquare.trade.protocol.trade.taker;
import io.bitsquare.bank.BankAccount; import io.bitsquare.bank.BankAccount;
import io.bitsquare.btc.BlockChainFacade; import io.bitsquare.btc.BlockChainService;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.crypto.CryptoFacade; import io.bitsquare.crypto.CryptoService;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageService;
import io.bitsquare.network.Peer; import io.bitsquare.network.Peer;
import io.bitsquare.offer.Offer; import io.bitsquare.offer.Offer;
import io.bitsquare.trade.Contract; import io.bitsquare.trade.Contract;
@ -86,10 +86,10 @@ public class SellerTakesOfferProtocol {
// provided data // provided data
private final Trade trade; private final Trade trade;
private final SellerTakesOfferProtocolListener listener; private final SellerTakesOfferProtocolListener listener;
private final MessageFacade messageFacade; private final MessageService messageService;
private final WalletFacade walletFacade; private final WalletService walletService;
private final BlockChainFacade blockChainFacade; private final BlockChainService blockChainService;
private final CryptoFacade cryptoFacade; private final CryptoService cryptoService;
// derived // derived
private final Offer offer; private final Offer offer;
@ -133,17 +133,17 @@ public class SellerTakesOfferProtocol {
public SellerTakesOfferProtocol(Trade trade, public SellerTakesOfferProtocol(Trade trade,
SellerTakesOfferProtocolListener listener, SellerTakesOfferProtocolListener listener,
MessageFacade messageFacade, MessageService messageService,
WalletFacade walletFacade, WalletService walletService,
BlockChainFacade blockChainFacade, BlockChainService blockChainService,
CryptoFacade cryptoFacade, CryptoService cryptoService,
User user) { User user) {
this.trade = trade; this.trade = trade;
this.listener = listener; this.listener = listener;
this.messageFacade = messageFacade; this.messageService = messageService;
this.walletFacade = walletFacade; this.walletService = walletService;
this.blockChainFacade = blockChainFacade; this.blockChainService = blockChainService;
this.cryptoFacade = cryptoFacade; this.cryptoService = cryptoService;
offer = trade.getOffer(); offer = trade.getOffer();
tradeId = trade.getId(); tradeId = trade.getId();
@ -158,8 +158,8 @@ public class SellerTakesOfferProtocol {
accountId = user.getAccountId(); accountId = user.getAccountId();
messagePublicKey = user.getMessagePublicKey(); messagePublicKey = user.getMessagePublicKey();
pubKeyForThatTrade = walletFacade.getAddressInfoByTradeID(tradeId).getPubKeyAsHexString(); pubKeyForThatTrade = walletService.getAddressInfoByTradeID(tradeId).getPubKeyAsHexString();
accountKey = walletFacade.getRegistrationAddressEntry().getKey(); accountKey = walletService.getRegistrationAddressEntry().getKey();
state = State.Init; state = State.Init;
} }
@ -167,7 +167,7 @@ public class SellerTakesOfferProtocol {
public void start() { public void start() {
log.debug("start called " + step++); log.debug("start called " + step++);
state = State.GetPeerAddress; state = State.GetPeerAddress;
GetPeerAddress.run(this::onResultGetPeerAddress, this::onFault, messageFacade, peersMessagePublicKey); GetPeerAddress.run(this::onResultGetPeerAddress, this::onFault, messageService, peersMessagePublicKey);
} }
public void onResultGetPeerAddress(Peer peer) { public void onResultGetPeerAddress(Peer peer) {
@ -175,7 +175,7 @@ public class SellerTakesOfferProtocol {
this.peer = peer; this.peer = peer;
state = State.RequestTakeOffer; state = State.RequestTakeOffer;
RequestTakeOffer.run(this::onResultRequestTakeOffer, this::onFault, peer, messageFacade, tradeId); RequestTakeOffer.run(this::onResultRequestTakeOffer, this::onFault, peer, messageService, tradeId);
} }
public void onResultRequestTakeOffer() { public void onResultRequestTakeOffer() {
@ -197,7 +197,7 @@ public class SellerTakesOfferProtocol {
if (message.isTakeOfferRequestAccepted()) { if (message.isTakeOfferRequestAccepted()) {
state = State.PayTakeOfferFee; state = State.PayTakeOfferFee;
listener.onTakeOfferRequestAccepted(trade); listener.onTakeOfferRequestAccepted(trade);
PayTakeOfferFee.run(this::onResultPayTakeOfferFee, this::onFault, walletFacade, tradeId); PayTakeOfferFee.run(this::onResultPayTakeOfferFee, this::onFault, walletService, tradeId);
} }
else { else {
listener.onTakeOfferRequestRejected(trade); listener.onTakeOfferRequestRejected(trade);
@ -211,7 +211,7 @@ public class SellerTakesOfferProtocol {
state = State.SendTakeOfferFeePayedTxId; state = State.SendTakeOfferFeePayedTxId;
SendTakeOfferFeePayedTxId.run(this::onResultSendTakeOfferFeePayedTxId, this::onFault, peer, SendTakeOfferFeePayedTxId.run(this::onResultSendTakeOfferFeePayedTxId, this::onFault, peer,
messageFacade, tradeId, takeOfferFeeTxId, tradeAmount, pubKeyForThatTrade); messageService, tradeId, takeOfferFeeTxId, tradeAmount, pubKeyForThatTrade);
} }
public void onResultSendTakeOfferFeePayedTxId() { public void onResultSendTakeOfferFeePayedTxId() {
@ -247,7 +247,7 @@ public class SellerTakesOfferProtocol {
// next task // next task
state = State.VerifyOffererAccount; state = State.VerifyOffererAccount;
VerifyOffererAccount.run(this::onResultVerifyOffererAccount, this::onFault, blockChainFacade, peersAccountId, VerifyOffererAccount.run(this::onResultVerifyOffererAccount, this::onFault, blockChainService, peersAccountId,
peersBankAccount); peersBankAccount);
} }
@ -257,7 +257,7 @@ public class SellerTakesOfferProtocol {
state = State.CreateAndSignContract; state = State.CreateAndSignContract;
CreateAndSignContract.run(this::onResultCreateAndSignContract, CreateAndSignContract.run(this::onResultCreateAndSignContract,
this::onFault, this::onFault,
cryptoFacade, cryptoService,
offer, offer,
tradeAmount, tradeAmount,
takeOfferFeeTxId, takeOfferFeeTxId,
@ -278,7 +278,7 @@ public class SellerTakesOfferProtocol {
trade.setContractTakerSignature(signature); trade.setContractTakerSignature(signature);
state = State.PayDeposit; state = State.PayDeposit;
PayDeposit.run(this::onResultPayDeposit, this::onFault, walletFacade, securityDeposit, tradeAmount, tradeId, PayDeposit.run(this::onResultPayDeposit, this::onFault, walletService, securityDeposit, tradeAmount, tradeId,
pubKeyForThatTrade, arbitratorPubKey, peersPubKey, preparedPeersDepositTxAsHex); pubKeyForThatTrade, arbitratorPubKey, peersPubKey, preparedPeersDepositTxAsHex);
} }
@ -291,8 +291,8 @@ public class SellerTakesOfferProtocol {
SendSignedTakerDepositTxAsHex.run(this::onResultSendSignedTakerDepositTxAsHex, SendSignedTakerDepositTxAsHex.run(this::onResultSendSignedTakerDepositTxAsHex,
this::onFault, this::onFault,
peer, peer,
messageFacade, messageService,
walletFacade, walletService,
bankAccount, bankAccount,
accountId, accountId,
messagePublicKey, messagePublicKey,
@ -320,7 +320,7 @@ public class SellerTakesOfferProtocol {
checkState(state.ordinal() >= State.SendSignedTakerDepositTxAsHex.ordinal()); checkState(state.ordinal() >= State.SendSignedTakerDepositTxAsHex.ordinal());
checkArgument(tradeId.equals(message.getTradeId())); checkArgument(tradeId.equals(message.getTradeId()));
//TODO takerCommitDepositTx should be in task as well //TODO takerCommitDepositTx should be in task as well
Transaction tx = walletFacade.takerCommitDepositTx(message.getDepositTxAsHex()); Transaction tx = walletService.takerCommitDepositTx(message.getDepositTxAsHex());
listener.onDepositTxPublished(tx); listener.onDepositTxPublished(tx);
} }
@ -370,7 +370,7 @@ public class SellerTakesOfferProtocol {
state = State.SignAndPublishPayoutTx; state = State.SignAndPublishPayoutTx;
SignAndPublishPayoutTx.run(this::onResultSignAndPublishPayoutTx, SignAndPublishPayoutTx.run(this::onResultSignAndPublishPayoutTx,
this::onFault, this::onFault,
walletFacade, walletService,
tradeId, tradeId,
depositTxAsHex, depositTxAsHex,
offererSignatureR, offererSignatureR,
@ -385,7 +385,7 @@ public class SellerTakesOfferProtocol {
listener.onPayoutTxPublished(trade, transaction); listener.onPayoutTxPublished(trade, transaction);
state = State.SendPayoutTxToOfferer; state = State.SendPayoutTxToOfferer;
SendPayoutTxToOfferer.run(this::onResultSendPayoutTxToOfferer, this::onFault, peer, messageFacade, SendPayoutTxToOfferer.run(this::onResultSendPayoutTxToOfferer, this::onFault, peer, messageService,
tradeId, payoutTxAsHex); tradeId, payoutTxAsHex);
} }

View file

@ -18,7 +18,7 @@
package io.bitsquare.trade.protocol.trade.taker.tasks; package io.bitsquare.trade.protocol.trade.taker.tasks;
import io.bitsquare.bank.BankAccount; import io.bitsquare.bank.BankAccount;
import io.bitsquare.crypto.CryptoFacade; import io.bitsquare.crypto.CryptoService;
import io.bitsquare.offer.Offer; import io.bitsquare.offer.Offer;
import io.bitsquare.trade.Contract; import io.bitsquare.trade.Contract;
import io.bitsquare.util.Utilities; import io.bitsquare.util.Utilities;
@ -37,7 +37,7 @@ public class CreateAndSignContract {
public static void run(ResultHandler resultHandler, public static void run(ResultHandler resultHandler,
ExceptionHandler exceptionHandler, ExceptionHandler exceptionHandler,
CryptoFacade cryptoFacade, CryptoService cryptoService,
Offer offer, Offer offer,
Coin tradeAmount, Coin tradeAmount,
String takeOfferFeeTxId, String takeOfferFeeTxId,
@ -54,7 +54,7 @@ public class CreateAndSignContract {
peersBankAccount, bankAccount, peersMessagePublicKey, messagePublicKey); peersBankAccount, bankAccount, peersMessagePublicKey, messagePublicKey);
String contractAsJson = Utilities.objectToJson(contract); String contractAsJson = Utilities.objectToJson(contract);
String signature = cryptoFacade.signContract(registrationKey, contractAsJson); String signature = cryptoService.signContract(registrationKey, contractAsJson);
resultHandler.onResult(contract, contractAsJson, signature); resultHandler.onResult(contract, contractAsJson, signature);
} catch (Throwable t) { } catch (Throwable t) {
log.error("Exception at sign contract " + t); log.error("Exception at sign contract " + t);

View file

@ -17,7 +17,7 @@
package io.bitsquare.trade.protocol.trade.taker.tasks; package io.bitsquare.trade.protocol.trade.taker.tasks;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageService;
import io.bitsquare.msg.listeners.GetPeerAddressListener; import io.bitsquare.msg.listeners.GetPeerAddressListener;
import io.bitsquare.network.Peer; import io.bitsquare.network.Peer;
import io.bitsquare.util.task.ExceptionHandler; import io.bitsquare.util.task.ExceptionHandler;
@ -31,9 +31,9 @@ public class GetPeerAddress {
private static final Logger log = LoggerFactory.getLogger(GetPeerAddress.class); private static final Logger log = LoggerFactory.getLogger(GetPeerAddress.class);
public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler, public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler,
MessageFacade messageFacade, PublicKey messagePublicKey) { MessageService messageService, PublicKey messagePublicKey) {
log.trace("Run task"); log.trace("Run task");
messageFacade.getPeerAddress(messagePublicKey, new GetPeerAddressListener() { messageService.getPeerAddress(messagePublicKey, new GetPeerAddressListener() {
@Override @Override
public void onResult(Peer peer) { public void onResult(Peer peer) {
log.trace("Received peer = " + peer.toString()); log.trace("Received peer = " + peer.toString());

View file

@ -17,7 +17,7 @@
package io.bitsquare.trade.protocol.trade.taker.tasks; package io.bitsquare.trade.protocol.trade.taker.tasks;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.util.task.ExceptionHandler; import io.bitsquare.util.task.ExceptionHandler;
import org.bitcoinj.core.Coin; import org.bitcoinj.core.Coin;
@ -32,7 +32,7 @@ public class PayDeposit {
public static void run(ResultHandler resultHandler, public static void run(ResultHandler resultHandler,
ExceptionHandler exceptionHandler, ExceptionHandler exceptionHandler,
WalletFacade walletFacade, WalletService walletService,
Coin securityDeposit, Coin securityDeposit,
Coin tradeAmount, Coin tradeAmount,
String tradeId, String tradeId,
@ -45,7 +45,7 @@ public class PayDeposit {
Coin amountToPay = tradeAmount.add(securityDeposit); Coin amountToPay = tradeAmount.add(securityDeposit);
Coin msOutputAmount = amountToPay.add(securityDeposit); Coin msOutputAmount = amountToPay.add(securityDeposit);
Transaction signedTakerDepositTx = walletFacade.takerAddPaymentAndSignTx(amountToPay, Transaction signedTakerDepositTx = walletService.takerAddPaymentAndSignTx(amountToPay,
msOutputAmount, msOutputAmount,
offererPubKey, offererPubKey,
pubKeyForThatTrade, pubKeyForThatTrade,

View file

@ -17,7 +17,7 @@
package io.bitsquare.trade.protocol.trade.taker.tasks; package io.bitsquare.trade.protocol.trade.taker.tasks;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.util.task.ExceptionHandler; import io.bitsquare.util.task.ExceptionHandler;
import org.bitcoinj.core.InsufficientMoneyException; import org.bitcoinj.core.InsufficientMoneyException;
@ -33,11 +33,11 @@ import org.slf4j.LoggerFactory;
public class PayTakeOfferFee { public class PayTakeOfferFee {
private static final Logger log = LoggerFactory.getLogger(PayTakeOfferFee.class); private static final Logger log = LoggerFactory.getLogger(PayTakeOfferFee.class);
public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler, WalletFacade walletFacade, public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler, WalletService walletService,
String tradeId) { String tradeId) {
log.trace("Run task"); log.trace("Run task");
try { try {
walletFacade.payTakeOfferFee(tradeId, new FutureCallback<Transaction>() { walletService.payTakeOfferFee(tradeId, new FutureCallback<Transaction>() {
@Override @Override
public void onSuccess(Transaction transaction) { public void onSuccess(Transaction transaction) {
log.debug("Take offer fee paid successfully. Transaction ID = " + transaction.getHashAsString()); log.debug("Take offer fee paid successfully. Transaction ID = " + transaction.getHashAsString());

View file

@ -17,7 +17,7 @@
package io.bitsquare.trade.protocol.trade.taker.tasks; package io.bitsquare.trade.protocol.trade.taker.tasks;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageService;
import io.bitsquare.msg.listeners.OutgoingMessageListener; import io.bitsquare.msg.listeners.OutgoingMessageListener;
import io.bitsquare.network.Peer; import io.bitsquare.network.Peer;
import io.bitsquare.trade.protocol.trade.taker.messages.RequestTakeOfferMessage; import io.bitsquare.trade.protocol.trade.taker.messages.RequestTakeOfferMessage;
@ -31,9 +31,9 @@ public class RequestTakeOffer {
private static final Logger log = LoggerFactory.getLogger(RequestTakeOffer.class); private static final Logger log = LoggerFactory.getLogger(RequestTakeOffer.class);
public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler, Peer peer, public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler, Peer peer,
MessageFacade messageFacade, String tradeId) { MessageService messageService, String tradeId) {
log.trace("Run task"); log.trace("Run task");
messageFacade.sendMessage(peer, new RequestTakeOfferMessage(tradeId), messageService.sendMessage(peer, new RequestTakeOfferMessage(tradeId),
new OutgoingMessageListener() { new OutgoingMessageListener() {
@Override @Override
public void onResult() { public void onResult() {

View file

@ -17,7 +17,7 @@
package io.bitsquare.trade.protocol.trade.taker.tasks; package io.bitsquare.trade.protocol.trade.taker.tasks;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageService;
import io.bitsquare.msg.listeners.OutgoingMessageListener; import io.bitsquare.msg.listeners.OutgoingMessageListener;
import io.bitsquare.network.Peer; import io.bitsquare.network.Peer;
import io.bitsquare.trade.protocol.trade.taker.messages.PayoutTxPublishedMessage; import io.bitsquare.trade.protocol.trade.taker.messages.PayoutTxPublishedMessage;
@ -31,10 +31,10 @@ public class SendPayoutTxToOfferer {
private static final Logger log = LoggerFactory.getLogger(SendPayoutTxToOfferer.class); private static final Logger log = LoggerFactory.getLogger(SendPayoutTxToOfferer.class);
public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler, Peer peer, public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler, Peer peer,
MessageFacade messageFacade, String tradeId, String payoutTxAsHex) { MessageService messageService, String tradeId, String payoutTxAsHex) {
log.trace("Run task"); log.trace("Run task");
PayoutTxPublishedMessage tradeMessage = new PayoutTxPublishedMessage(tradeId, payoutTxAsHex); PayoutTxPublishedMessage tradeMessage = new PayoutTxPublishedMessage(tradeId, payoutTxAsHex);
messageFacade.sendMessage(peer, tradeMessage, new OutgoingMessageListener() { messageService.sendMessage(peer, tradeMessage, new OutgoingMessageListener() {
@Override @Override
public void onResult() { public void onResult() {
log.trace("PayoutTxPublishedMessage successfully arrived at peer"); log.trace("PayoutTxPublishedMessage successfully arrived at peer");

View file

@ -18,8 +18,8 @@
package io.bitsquare.trade.protocol.trade.taker.tasks; package io.bitsquare.trade.protocol.trade.taker.tasks;
import io.bitsquare.bank.BankAccount; import io.bitsquare.bank.BankAccount;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageService;
import io.bitsquare.msg.listeners.OutgoingMessageListener; import io.bitsquare.msg.listeners.OutgoingMessageListener;
import io.bitsquare.network.Peer; import io.bitsquare.network.Peer;
import io.bitsquare.trade.protocol.trade.taker.messages.RequestOffererPublishDepositTxMessage; import io.bitsquare.trade.protocol.trade.taker.messages.RequestOffererPublishDepositTxMessage;
@ -40,8 +40,8 @@ public class SendSignedTakerDepositTxAsHex {
public static void run(ResultHandler resultHandler, public static void run(ResultHandler resultHandler,
ExceptionHandler exceptionHandler, ExceptionHandler exceptionHandler,
Peer peer, Peer peer,
MessageFacade messageFacade, MessageService messageService,
WalletFacade walletFacade, WalletService walletService,
BankAccount bankAccount, BankAccount bankAccount,
String accountId, String accountId,
PublicKey messagePublicKey, PublicKey messagePublicKey,
@ -65,10 +65,10 @@ public class SendSignedTakerDepositTxAsHex {
.bitcoinSerialize()), .bitcoinSerialize()),
contractAsJson, contractAsJson,
takerSignature, takerSignature,
walletFacade.getAddressInfoByTradeID(tradeId).getAddressString(), walletService.getAddressInfoByTradeID(tradeId).getAddressString(),
takerTxOutIndex, takerTxOutIndex,
offererTxOutIndex); offererTxOutIndex);
messageFacade.sendMessage(peer, tradeMessage, new OutgoingMessageListener() { messageService.sendMessage(peer, tradeMessage, new OutgoingMessageListener() {
@Override @Override
public void onResult() { public void onResult() {
log.trace("RequestOffererDepositPublicationMessage successfully arrived at peer"); log.trace("RequestOffererDepositPublicationMessage successfully arrived at peer");

View file

@ -17,7 +17,7 @@
package io.bitsquare.trade.protocol.trade.taker.tasks; package io.bitsquare.trade.protocol.trade.taker.tasks;
import io.bitsquare.msg.MessageFacade; import io.bitsquare.msg.MessageService;
import io.bitsquare.msg.listeners.OutgoingMessageListener; import io.bitsquare.msg.listeners.OutgoingMessageListener;
import io.bitsquare.network.Peer; import io.bitsquare.network.Peer;
import io.bitsquare.trade.protocol.trade.taker.messages.TakeOfferFeePayedMessage; import io.bitsquare.trade.protocol.trade.taker.messages.TakeOfferFeePayedMessage;
@ -35,7 +35,7 @@ public class SendTakeOfferFeePayedTxId {
public static void run(ResultHandler resultHandler, public static void run(ResultHandler resultHandler,
ExceptionHandler exceptionHandler, ExceptionHandler exceptionHandler,
Peer peer, Peer peer,
MessageFacade messageFacade, MessageService messageService,
String tradeId, String tradeId,
String takeOfferFeeTxId, String takeOfferFeeTxId,
Coin tradeAmount, Coin tradeAmount,
@ -44,7 +44,7 @@ public class SendTakeOfferFeePayedTxId {
TakeOfferFeePayedMessage msg = new TakeOfferFeePayedMessage(tradeId, takeOfferFeeTxId, tradeAmount, TakeOfferFeePayedMessage msg = new TakeOfferFeePayedMessage(tradeId, takeOfferFeeTxId, tradeAmount,
pubKeyForThatTradeAsHex); pubKeyForThatTradeAsHex);
messageFacade.sendMessage(peer, msg, new OutgoingMessageListener() { messageService.sendMessage(peer, msg, new OutgoingMessageListener() {
@Override @Override
public void onResult() { public void onResult() {
log.trace("TakeOfferFeePayedMessage successfully arrived at peer"); log.trace("TakeOfferFeePayedMessage successfully arrived at peer");

View file

@ -17,7 +17,7 @@
package io.bitsquare.trade.protocol.trade.taker.tasks; package io.bitsquare.trade.protocol.trade.taker.tasks;
import io.bitsquare.btc.WalletFacade; import io.bitsquare.btc.WalletService;
import io.bitsquare.util.task.ExceptionHandler; import io.bitsquare.util.task.ExceptionHandler;
import org.bitcoinj.core.Coin; import org.bitcoinj.core.Coin;
@ -36,7 +36,7 @@ public class SignAndPublishPayoutTx {
public static void run(ResultHandler resultHandler, public static void run(ResultHandler resultHandler,
ExceptionHandler exceptionHandler, ExceptionHandler exceptionHandler,
WalletFacade walletFacade, WalletService walletService,
String tradeId, String tradeId,
String depositTxAsHex, String depositTxAsHex,
String offererSignatureR, String offererSignatureR,
@ -47,7 +47,7 @@ public class SignAndPublishPayoutTx {
log.trace("Run task"); log.trace("Run task");
try { try {
walletFacade.takerSignsAndSendsTx(depositTxAsHex, walletService.takerSignsAndSendsTx(depositTxAsHex,
offererSignatureR, offererSignatureR,
offererSignatureS, offererSignatureS,
offererPaybackAmount, offererPaybackAmount,

View file

@ -18,7 +18,7 @@
package io.bitsquare.trade.protocol.trade.taker.tasks; package io.bitsquare.trade.protocol.trade.taker.tasks;
import io.bitsquare.bank.BankAccount; import io.bitsquare.bank.BankAccount;
import io.bitsquare.btc.BlockChainFacade; import io.bitsquare.btc.BlockChainService;
import io.bitsquare.trade.protocol.trade.shared.tasks.VerifyPeerAccount; import io.bitsquare.trade.protocol.trade.shared.tasks.VerifyPeerAccount;
import io.bitsquare.util.task.ExceptionHandler; import io.bitsquare.util.task.ExceptionHandler;
import io.bitsquare.util.task.ResultHandler; import io.bitsquare.util.task.ResultHandler;
@ -30,8 +30,8 @@ public class VerifyOffererAccount {
private static final Logger log = LoggerFactory.getLogger(VerifyOffererAccount.class); private static final Logger log = LoggerFactory.getLogger(VerifyOffererAccount.class);
public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler, public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler,
BlockChainFacade blockChainFacade, String peersAccountId, BankAccount peersBankAccount) { BlockChainService blockChainService, String peersAccountId, BankAccount peersBankAccount) {
log.trace("Run task"); log.trace("Run task");
VerifyPeerAccount.run(resultHandler, exceptionHandler, blockChainFacade, peersAccountId, peersBankAccount); VerifyPeerAccount.run(resultHandler, exceptionHandler, blockChainService, peersAccountId, peersBankAccount);
} }
} }