Merge branch 'cbeams'

* cbeams:
  Refactor SignatureService
  Polish formatting
  Rename io.bitsquare.crypto.{Crypto=>Signature}Service
  Replace 'Facade' naming with 'Service' naming
This commit is contained in:
Chris Beams 2014-11-12 14:07:13 +01:00
commit d657763596
No known key found for this signature in database
GPG key ID: 3D214F8F5BC5ED73
68 changed files with 444 additions and 494 deletions

View file

@ -29,7 +29,7 @@ run {
processResources {
from(sourceSets.main.resources.srcDirs) {
include '**/*.properties'
filter(ReplaceTokens, tokens: [ 'app.version': project.version ])
filter(ReplaceTokens, tokens: ['app.version': project.version])
}
}

View file

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

View file

@ -41,7 +41,8 @@ public class BitsquareAppMain extends BitsquareExecutable {
protected void customizeOptionParsing(OptionParser parser) {
parser.accepts(USER_DATA_DIR_KEY, "User data directory").withRequiredArg().defaultsTo(DEFAULT_USER_DATA_DIR);
parser.accepts(APP_NAME_KEY, "Application name").withRequiredArg().defaultsTo(DEFAULT_APP_NAME);
parser.accepts(APP_DATA_DIR_KEY, "Application data directory").withRequiredArg().defaultsTo(DEFAULT_APP_DATA_DIR);
parser.accepts(APP_DATA_DIR_KEY, "Application data directory").withRequiredArg()
.defaultsTo(DEFAULT_APP_DATA_DIR);
parser.accepts(NAME_KEY, "Name of this node").withRequiredArg();
parser.accepts(PORT_KEY, "Port to listen on").withRequiredArg().defaultsTo(String.valueOf(Node.DEFAULT_PORT));
parser.accepts(BITCOIN_NETWORK_KEY).withRequiredArg().defaultsTo(BitcoinModule.DEFAULT_BITCOIN_NETWORK);

View file

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

View file

@ -22,11 +22,11 @@ import io.bitsquare.bank.BankAccount;
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
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.BalanceListener;
import io.bitsquare.btc.listeners.TxConfidenceListener;
import io.bitsquare.crypto.CryptoFacade;
import io.bitsquare.crypto.SignatureService;
import io.bitsquare.persistence.Persistence;
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: break that class up. maybe a bitsquarewallet
*/
public class WalletFacade {
private static final Logger log = LoggerFactory.getLogger(WalletFacade.class);
public class WalletService {
private static final Logger log = LoggerFactory.getLogger(WalletService.class);
private static final String LOCK_NAME = "lock";
public static final String DIR_KEY = "wallet.dir";
@ -105,7 +105,7 @@ public class WalletFacade {
private final NetworkParameters params;
private final FeePolicy feePolicy;
private final CryptoFacade cryptoFacade;
private final SignatureService signatureService;
private final Persistence persistence;
private final File walletDir;
private final String walletPrefix;
@ -123,12 +123,12 @@ public class WalletFacade {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public WalletFacade(NetworkParameters params, FeePolicy feePolicy, CryptoFacade cryptoFacade,
Persistence persistence, UserAgent userAgent,
@Named(DIR_KEY) File walletDir, @Named(PREFIX_KEY) String walletPrefix) {
public WalletService(NetworkParameters params, FeePolicy feePolicy, SignatureService signatureService,
Persistence persistence, UserAgent userAgent,
@Named(DIR_KEY) File walletDir, @Named(PREFIX_KEY) String walletPrefix) {
this.params = params;
this.feePolicy = feePolicy;
this.cryptoFacade = cryptoFacade;
this.signatureService = signatureService;
this.persistence = persistence;
this.walletDir = walletDir;
this.walletPrefix = walletPrefix;
@ -555,7 +555,7 @@ public class WalletFacade {
Transaction tx = new Transaction(params);
byte[] data = cryptoFacade.getEmbeddedAccountRegistrationData(
byte[] data = signatureService.digestMessageWithSignature(
getRegistrationAddressEntry().getKey(), stringifiedBankAccounts);
tx.addOutput(Transaction.MIN_NONDUST_OUTPUT, new ScriptBuilder().op(OP_RETURN).data(data).build());

View file

@ -1,113 +0,0 @@
/*
* This file is part of Bitsquare.
*
* Bitsquare is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.crypto;
import org.bitcoinj.core.ECKey;
import org.bitcoinj.core.Sha256Hash;
import org.bitcoinj.core.Utils;
import org.bitcoinj.crypto.KeyCrypterException;
import com.google.common.base.Charsets;
import java.nio.charset.Charset;
import java.security.SignatureException;
import javax.annotation.Nullable;
import javax.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongycastle.crypto.params.KeyParameter;
import org.spongycastle.util.encoders.Base64;
/**
* That facade delivers crypto functionality from the bitcoinJ library
* //TODO still very basic as not much used yet, missing implementations
*/
public class CryptoFacade {
private static final Logger log = LoggerFactory.getLogger(CryptoFacade.class);
@Inject
public CryptoFacade() {
}
// DeterministicKey does not support signMessage yet.
private String signMessage(ECKey key, String message, @Nullable KeyParameter aesKey) throws KeyCrypterException {
byte[] data = Utils.formatMessageForSigning(message);
Sha256Hash hash = Sha256Hash.createDouble(data);
ECKey.ECDSASignature sig = key.sign(hash, aesKey);
// Now we have to work backwards to figure out the recId needed to recover the signature.
int recId = -1;
for (int i = 0; i < 4; i++) {
ECKey k = ECKey.recoverFromSignature(i, sig, hash, key.isCompressed());
if (k != null && k.getPubKeyPoint().equals(key.getPubKeyPoint())) {
recId = i;
break;
}
}
if (recId == -1)
throw new RuntimeException("Could not construct a recoverable key. This should never happen.");
int headerByte = recId + 27 + (key.isCompressed() ? 4 : 0);
byte[] sigData = new byte[65]; // 1 header + 32 bytes for R + 32 bytes for S
sigData[0] = (byte) headerByte;
System.arraycopy(Utils.bigIntegerToBytes(sig.r, 32), 0, sigData, 1, 32);
System.arraycopy(Utils.bigIntegerToBytes(sig.s, 32), 0, sigData, 33, 32);
return new String(Base64.encode(sigData), Charset.forName("UTF-8"));
}
public byte[] getEmbeddedAccountRegistrationData(ECKey registrationKey, String stringifiedBankAccounts) {
String signedBankAccountIDs = signMessage(registrationKey, stringifiedBankAccounts, null);
return Utils.sha256hash160(
concatenateChunks(stringifiedBankAccounts, signedBankAccountIDs).getBytes(Charsets.UTF_8));
}
public String signContract(ECKey key, String contractAsJson) {
return signMessage(key, contractAsJson, null);
}
// registration
public boolean verifySignature(byte[] pubKey, String msg, String sig) {
try {
ECKey key = ECKey.fromPublicOnly(pubKey);
key.verifyMessage(msg, sig);
return true;
} catch (SignatureException e) {
return false;
}
}
public boolean verifyHash(String hashAsHexStringToVerify, String msg, String sig) {
String hashAsHexString = Utils.HEX.encode(createHash(msg, sig));
return hashAsHexString.equals(hashAsHexStringToVerify);
}
private byte[] createHash(String msg, String sig) {
byte[] hashBytes = concatenateChunks(msg, sig).getBytes(Charsets.UTF_8);
return Utils.sha256hash160(hashBytes);
}
private String concatenateChunks(String stringifiedBankAccounts, String signedBankAccountIDs) {
return stringifiedBankAccounts + signedBankAccountIDs;
}
}

View file

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

View file

@ -0,0 +1,57 @@
/*
* This file is part of Bitsquare.
*
* Bitsquare is free software: you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at
* your option) any later version.
*
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
* License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
*/
package io.bitsquare.crypto;
import org.bitcoinj.core.ECKey;
import org.bitcoinj.core.Sha256Hash;
import org.bitcoinj.core.Utils;
import com.google.common.base.Charsets;
import org.spongycastle.util.encoders.Base64;
public class SignatureService {
public String signMessage(ECKey key, String message) {
byte[] data = Utils.formatMessageForSigning(message);
Sha256Hash hash = Sha256Hash.createDouble(data);
ECKey.ECDSASignature sig = key.sign(hash, null);
// Now we have to work backwards to figure out the recId needed to recover the signature.
int recId = -1;
for (int i = 0; i < 4; i++) {
ECKey k = ECKey.recoverFromSignature(i, sig, hash, key.isCompressed());
if (k != null && k.getPubKeyPoint().equals(key.getPubKeyPoint())) {
recId = i;
break;
}
}
if (recId == -1)
throw new RuntimeException("Could not construct a recoverable key. This should never happen.");
int headerByte = recId + 27 + (key.isCompressed() ? 4 : 0);
byte[] sigData = new byte[65]; // 1 header + 32 bytes for R + 32 bytes for S
sigData[0] = (byte) headerByte;
System.arraycopy(Utils.bigIntegerToBytes(sig.r, 32), 0, sigData, 1, 32);
System.arraycopy(Utils.bigIntegerToBytes(sig.s, 32), 0, sigData, 33, 32);
return new String(Base64.encode(sigData), Charsets.UTF_8);
}
public byte[] digestMessageWithSignature(ECKey key, String message) {
String signedMessage = signMessage(key, message);
return Utils.sha256hash160(message.concat(signedMessage).getBytes(Charsets.UTF_8));
}
}

View file

@ -17,7 +17,7 @@
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.BalanceListener;
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
@ -74,23 +74,23 @@ public class BalanceTextField extends AnchorPane {
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;
walletFacade.addAddressConfidenceListener(new AddressConfidenceListener(address) {
walletService.addAddressConfidenceListener(new AddressConfidenceListener(address) {
@Override
public void onTransactionConfidenceChanged(TransactionConfidence confidence) {
updateConfidence(confidence);
}
});
updateConfidence(walletFacade.getConfidenceForAddress(address));
updateConfidence(walletService.getConfidenceForAddress(address));
walletFacade.addBalanceListener(new BalanceListener(address) {
walletService.addBalanceListener(new BalanceListener(address) {
@Override
public void onBalanceChanged(Coin 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;
/**
* 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 {
private static final Logger log = LoggerFactory.getLogger(SystemNotification.class);

View file

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

View file

@ -18,10 +18,10 @@
package io.bitsquare.gui.main;
import io.bitsquare.bank.BankAccount;
import io.bitsquare.btc.WalletFacade;
import io.bitsquare.btc.WalletService;
import io.bitsquare.gui.UIModel;
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.network.BootstrapState;
import io.bitsquare.persistence.Persistence;
@ -50,20 +50,20 @@ class MainModel extends UIModel {
private static final Logger log = LoggerFactory.getLogger(MainModel.class);
private final User user;
private final WalletFacade walletFacade;
private final MessageFacade messageFacade;
private final WalletService walletService;
private final MessageService messageService;
private final TradeManager tradeManager;
private final Persistence persistence;
private boolean messageFacadeInited;
private boolean walletFacadeInited;
private boolean facadesInitialised;
private boolean messageServiceInited;
private boolean walletServiceInited;
private boolean servicesInitialised;
final BooleanProperty backendReady = new SimpleBooleanProperty();
final DoubleProperty networkSyncProgress = new SimpleDoubleProperty(-1);
final IntegerProperty numPendingTrades = new SimpleIntegerProperty(0);
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
private MainModel(User user, WalletFacade walletFacade, MessageFacade messageFacade,
private MainModel(User user, WalletService walletService, MessageService messageService,
TradeManager tradeManager, Persistence persistence) {
this.user = user;
this.walletFacade = walletFacade;
this.messageFacade = messageFacade;
this.walletService = walletService;
this.messageService = messageService;
this.tradeManager = tradeManager;
this.persistence = persistence;
}
@ -105,13 +105,13 @@ class MainModel extends UIModel {
void initBackend() {
// 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
public void onCompleted() {
messageFacadeInited = true;
if (walletFacadeInited) onFacadesInitialised();
messageServiceInited = true;
if (walletServiceInited) onServicesInitialised();
}
@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() {
@Override
public void progress(double percentage) {
networkSyncProgress.set(percentage / 100.0);
if (facadesInitialised && percentage >= 100.0)
if (servicesInitialised && percentage >= 100.0)
backendReady.set(true);
}
@ -141,26 +141,26 @@ class MainModel extends UIModel {
public void doneDownload() {
networkSyncProgress.set(1.0);
if (facadesInitialised)
if (servicesInitialised)
backendReady.set(true);
}
};
WalletFacade.StartupListener startupListener = new WalletFacade.StartupListener() {
WalletService.StartupListener startupListener = new WalletService.StartupListener() {
@Override
public void completed() {
walletFacadeInited = true;
if (messageFacadeInited)
onFacadesInitialised();
walletServiceInited = true;
if (messageServiceInited)
onServicesInitialised();
}
@Override
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 void onFacadesInitialised() {
private void onServicesInitialised() {
tradeManager.getPendingTrades().addListener((MapChangeListener<String,
Trade>) change -> updateNumPendingTrades());
updateNumPendingTrades();
facadesInitialised = true;
servicesInitialised = true;
if (networkSyncProgress.get() >= 1.0)
backendReady.set(true);

View file

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

View file

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

View file

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

View file

@ -53,7 +53,7 @@ public class ArbitratorProfileViewCB extends CachedViewCB {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public ArbitratorProfileViewCB(ApplicationPreferences applicationPreferences, Persistence persistence,
public ArbitratorProfileViewCB(ApplicationPreferences applicationPreferences, Persistence persistence,
BSFormatter formatter) {
this.applicationPreferences = applicationPreferences;
this.persistence = persistence;

View file

@ -19,13 +19,13 @@ package io.bitsquare.gui.main.account.arbitrator.registration;
import io.bitsquare.arbitrator.Arbitrator;
import io.bitsquare.arbitrator.Reputation;
import io.bitsquare.btc.WalletFacade;
import io.bitsquare.btc.WalletService;
import io.bitsquare.gui.CachedViewCB;
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.locale.BSResources;
import io.bitsquare.locale.LanguageUtil;
import io.bitsquare.msg.MessageFacade;
import io.bitsquare.msg.MessageService;
import io.bitsquare.persistence.Persistence;
import io.bitsquare.user.User;
import io.bitsquare.util.DSAKeyUtil;
@ -65,8 +65,8 @@ public class ArbitratorRegistrationViewCB extends CachedViewCB {
private static final Logger log = LoggerFactory.getLogger(ArbitratorRegistrationViewCB.class);
private final Persistence persistence;
private final WalletFacade walletFacade;
private final MessageFacade messageFacade;
private final WalletService walletService;
private final MessageService messageService;
private final User user;
private final BSFormatter formatter;
private Arbitrator arbitrator = new Arbitrator();
@ -100,11 +100,11 @@ public class ArbitratorRegistrationViewCB extends CachedViewCB {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
private ArbitratorRegistrationViewCB(Persistence persistence, WalletFacade walletFacade,
MessageFacade messageFacade, User user, BSFormatter formatter) {
private ArbitratorRegistrationViewCB(Persistence persistence, WalletService walletService,
MessageService messageService, User user, BSFormatter formatter) {
this.persistence = persistence;
this.walletFacade = walletFacade;
this.messageFacade = messageFacade;
this.walletService = walletService;
this.messageService = messageService;
this.user = user;
this.formatter = formatter;
}
@ -322,7 +322,7 @@ public class ArbitratorRegistrationViewCB extends CachedViewCB {
}
}
messageFacade.addArbitrator(arbitrator);
messageService.addArbitrator(arbitrator);
}
@FXML
@ -344,8 +344,8 @@ public class ArbitratorRegistrationViewCB extends CachedViewCB {
"resolution.\n\nPlease pay in 2 BTC");
String securityDepositAddress = walletFacade.getRegistrationAddressEntry() != null ?
walletFacade.getRegistrationAddressEntry().toString() : "";
String securityDepositAddress = walletService.getRegistrationAddressEntry() != null ?
walletService.getRegistrationAddressEntry().toString() : "";
securityDepositAddressTextField.setText(securityDepositAddress);
AwesomeDude.setIcon(copyIcon, AwesomeIcon.COPY);
@ -356,9 +356,9 @@ public class ArbitratorRegistrationViewCB extends CachedViewCB {
clipboard.setContent(content);
});
paymentDoneButton.setDisable(walletFacade.getArbitratorDepositBalance().isZero());
log.debug("getArbitratorDepositBalance " + walletFacade.getArbitratorDepositBalance());
walletFacade.getWallet().addEventListener(new WalletEventListener() {
paymentDoneButton.setDisable(walletService.getArbitratorDepositBalance().isZero());
log.debug("getArbitratorDepositBalance " + walletService.getArbitratorDepositBalance());
walletService.getWallet().addEventListener(new WalletEventListener() {
@Override
public void onCoinsReceived(Wallet wallet, Transaction tx, Coin prevBalance, Coin newBalance) {
paymentDoneButton.setDisable(newBalance.isZero());
@ -431,7 +431,7 @@ public class ArbitratorRegistrationViewCB extends CachedViewCB {
private Arbitrator getEditedArbitrator() {
String pubKeyAsHex = walletFacade.getArbitratorDepositAddressEntry().getPubKeyAsHexString();
String pubKeyAsHex = walletService.getArbitratorDepositAddressEntry().getPubKeyAsHexString();
String messagePubKeyAsHex = DSAKeyUtil.getHexStringFromPublicKey(user.getMessagePublicKey());
String name = nameTextField.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.LanguageUtil;
import io.bitsquare.locale.Region;
import io.bitsquare.msg.MessageFacade;
import io.bitsquare.msg.MessageService;
import io.bitsquare.persistence.Persistence;
import io.bitsquare.user.User;
import io.bitsquare.util.DSAKeyUtil;
@ -59,7 +59,7 @@ class IrcAccountModel extends UIModel {
private final User user;
private final AccountSettings accountSettings;
private final MessageFacade messageFacade;
private final MessageService messageService;
private final Persistence persistence;
final StringProperty nickName = new SimpleStringProperty();
@ -78,11 +78,12 @@ class IrcAccountModel extends UIModel {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
IrcAccountModel(User user, Persistence persistence, AccountSettings accountSettings, MessageFacade messageFacade) {
IrcAccountModel(User user, Persistence persistence, AccountSettings accountSettings,
MessageService messageService) {
this.persistence = persistence;
this.user = user;
this.accountSettings = accountSettings;
this.messageFacade = messageFacade;
this.messageService = messageService;
}
@ -205,7 +206,7 @@ class IrcAccountModel extends UIModel {
accountSettings.addAcceptedArbitrator(arbitrator);
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.FeePolicy;
import io.bitsquare.btc.WalletFacade;
import io.bitsquare.btc.WalletService;
import io.bitsquare.btc.listeners.BalanceListener;
import io.bitsquare.gui.UIModel;
import io.bitsquare.persistence.Persistence;
@ -48,7 +48,7 @@ import org.slf4j.LoggerFactory;
class RegistrationModel extends UIModel {
private static final Logger log = LoggerFactory.getLogger(RegistrationModel.class);
private final WalletFacade walletFacade;
private final WalletService walletService;
private final User user;
private final Persistence persistence;
@ -65,9 +65,9 @@ class RegistrationModel extends UIModel {
///////////////////////////////////////////////////////////////////////////////////////////
@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.persistence = persistence;
}
@ -81,15 +81,15 @@ class RegistrationModel extends UIModel {
public void initialize() {
super.initialize();
if (walletFacade != null && walletFacade.getWallet() != null) {
addressEntry = walletFacade.getRegistrationAddressEntry();
walletFacade.addBalanceListener(new BalanceListener(getAddressEntry().getAddress()) {
if (walletService != null && walletService.getWallet() != null) {
addressEntry = walletService.getRegistrationAddressEntry();
walletService.addBalanceListener(new BalanceListener(getAddressEntry().getAddress()) {
@Override
public void onBalanceChanged(@NotNull Coin balance) {
updateBalance(balance);
}
});
updateBalance(walletFacade.getBalanceForAddress(getAddressEntry().getAddress()));
updateBalance(walletService.getBalanceForAddress(getAddressEntry().getAddress()));
}
}
@ -140,7 +140,7 @@ class RegistrationModel extends UIModel {
}
};
try {
walletFacade.payRegistrationFee(user.getStringifiedBankAccounts(), callback);
walletService.payRegistrationFee(user.getStringifiedBankAccounts(), callback);
} catch (InsufficientMoneyException e) {
payFeeErrorMessage.set("Fee payment failed with error: " + e.getMessage());
}
@ -151,8 +151,8 @@ class RegistrationModel extends UIModel {
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
WalletFacade getWalletFacade() {
return walletFacade;
WalletService getWalletService() {
return walletService;
}
Coin getFeeAsCoin() {

View file

@ -17,7 +17,7 @@
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.util.BSFormatter;
import io.bitsquare.locale.BSResources;
@ -122,8 +122,8 @@ class RegistrationPM extends PresentationModel<RegistrationModel> {
// Getters
///////////////////////////////////////////////////////////////////////////////////////////
WalletFacade getWalletFacade() {
return model.getWalletFacade();
WalletService getWalletService() {
return model.getWalletService();
}
BSFormatter getFormatter() {

View file

@ -87,7 +87,7 @@ public class RegistrationViewCB extends CachedViewCB<RegistrationPM> implements
// TODO find better solution
addressTextField.setOverlayManager(overlayManager);
balanceTextField.setup(presentationModel.getWalletFacade(), presentationModel.address.get(),
balanceTextField.setup(presentationModel.getWalletService(), presentationModel.address.get(),
presentationModel.getFormatter());
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.LanguageUtil;
import io.bitsquare.locale.Region;
import io.bitsquare.msg.MessageFacade;
import io.bitsquare.msg.MessageService;
import io.bitsquare.persistence.Persistence;
import io.bitsquare.user.User;
import io.bitsquare.util.DSAKeyUtil;
@ -52,7 +52,7 @@ class RestrictionsModel extends UIModel {
private final User user;
private final AccountSettings accountSettings;
private final Persistence persistence;
private final MessageFacade messageFacade;
private final MessageService messageService;
final ObservableList<Locale> languageList = FXCollections.observableArrayList();
final ObservableList<Country> countryList = FXCollections.observableArrayList();
@ -68,11 +68,11 @@ class RestrictionsModel extends UIModel {
@Inject
private RestrictionsModel(User user, AccountSettings accountSettings, Persistence persistence,
MessageFacade messageFacade) {
MessageService messageService) {
this.user = user;
this.accountSettings = accountSettings;
this.persistence = persistence;
this.messageFacade = messageFacade;
this.messageService = messageService;
}
@ -215,7 +215,7 @@ class RestrictionsModel extends UIModel {
accountSettings.addAcceptedArbitrator(arbitrator);
persistence.write(accountSettings);
messageFacade.addArbitrator(arbitrator);
messageService.addArbitrator(arbitrator);
}
}
}

View file

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

View file

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

View file

@ -17,7 +17,7 @@
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.components.Popups;
import io.bitsquare.gui.util.BSFormatter;
@ -45,7 +45,7 @@ import org.slf4j.LoggerFactory;
public class TransactionsViewCB extends CachedViewCB {
private static final Logger log = LoggerFactory.getLogger(TransactionsViewCB.class);
private final WalletFacade walletFacade;
private final WalletService walletService;
private final BSFormatter formatter;
private ObservableList<TransactionsListItem> transactionsListItems;
@ -59,8 +59,8 @@ public class TransactionsViewCB extends CachedViewCB {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
private TransactionsViewCB(WalletFacade walletFacade, BSFormatter formatter) {
this.walletFacade = walletFacade;
private TransactionsViewCB(WalletService walletService, BSFormatter formatter) {
this.walletService = walletService;
this.formatter = formatter;
}
@ -92,10 +92,10 @@ public class TransactionsViewCB extends CachedViewCB {
public void activate() {
super.activate();
List<Transaction> transactions = walletFacade.getWallet().getRecentTransactions(10000, true);
List<Transaction> transactions = walletService.getWallet().getRecentTransactions(10000, true);
transactionsListItems = FXCollections.observableArrayList();
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);
}

View file

@ -18,7 +18,7 @@
package io.bitsquare.gui.main.funds.withdrawal;
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.BalanceListener;
import io.bitsquare.gui.components.confidence.ConfidenceProgressIndicator;
@ -42,7 +42,7 @@ public class WithdrawalListItem {
private final AddressEntry addressEntry;
private final WalletFacade walletFacade;
private final WalletService walletService;
private final BSFormatter formatter;
private final AddressConfidenceListener confidenceListener;
@ -52,9 +52,9 @@ public class WithdrawalListItem {
private Coin balance;
public WithdrawalListItem(AddressEntry addressEntry, WalletFacade walletFacade, BSFormatter formatter) {
public WithdrawalListItem(AddressEntry addressEntry, WalletService walletService, BSFormatter formatter) {
this.addressEntry = addressEntry;
this.walletFacade = walletFacade;
this.walletService = walletService;
this.formatter = formatter;
this.addressString.set(getAddress().toString());
@ -66,31 +66,31 @@ public class WithdrawalListItem {
progressIndicator.setPrefSize(24, 24);
Tooltip.install(progressIndicator, tooltip);
confidenceListener = walletFacade.addAddressConfidenceListener(new AddressConfidenceListener(getAddress()) {
confidenceListener = walletService.addAddressConfidenceListener(new AddressConfidenceListener(getAddress()) {
@Override
public void onTransactionConfidenceChanged(TransactionConfidence confidence) {
updateConfidence(confidence);
}
});
updateConfidence(walletFacade.getConfidenceForAddress(getAddress()));
updateConfidence(walletService.getConfidenceForAddress(getAddress()));
// balance
balanceLabel = new Label();
balanceListener = walletFacade.addBalanceListener(new BalanceListener(getAddress()) {
balanceListener = walletService.addBalanceListener(new BalanceListener(getAddress()) {
@Override
public void onBalanceChanged(Coin balance) {
updateBalance(balance);
}
});
updateBalance(walletFacade.getBalanceForAddress(getAddress()));
updateBalance(walletService.getBalanceForAddress(getAddress()));
}
public void cleanup() {
walletFacade.removeAddressConfidenceListener(confidenceListener);
walletFacade.removeBalanceListener(balanceListener);
walletService.removeAddressConfidenceListener(confidenceListener);
walletService.removeBalanceListener(balanceListener);
}
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.FeePolicy;
import io.bitsquare.btc.Restrictions;
import io.bitsquare.btc.WalletFacade;
import io.bitsquare.btc.WalletService;
import io.bitsquare.btc.listeners.BalanceListener;
import io.bitsquare.gui.CachedViewCB;
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 final WalletFacade walletFacade;
private final WalletService walletService;
private final BSFormatter formatter;
private final ObservableList<WithdrawalListItem> addressList = FXCollections.observableArrayList();
@ -79,8 +79,8 @@ public class WithdrawalViewCB extends CachedViewCB {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
private WithdrawalViewCB(WalletFacade walletFacade, BSFormatter formatter) {
this.walletFacade = walletFacade;
private WithdrawalViewCB(WalletService walletService, BSFormatter formatter) {
this.walletService = walletService;
this.formatter = formatter;
}
@ -124,7 +124,7 @@ public class WithdrawalViewCB extends CachedViewCB {
fillList();
table.setItems(addressList);
walletFacade.addBalanceListener(new BalanceListener() {
walletService.addBalanceListener(new BalanceListener() {
@Override
public void onBalanceChanged(Coin balance) {
fillList();
@ -183,7 +183,7 @@ public class WithdrawalViewCB extends CachedViewCB {
"Are you sure you withdraw that amount?");
if (Popups.isOK(response)) {
try {
walletFacade.sendFunds(
walletService.sendFunds(
withdrawFromTextField.getText(), withdrawToTextField.getText(),
amount, callback);
@ -214,10 +214,10 @@ public class WithdrawalViewCB extends CachedViewCB {
private void fillList() {
addressList.clear();
List<AddressEntry> addressEntryList = walletFacade.getAddressEntryList();
List<AddressEntry> addressEntryList = walletService.getAddressEntryList();
addressList.addAll(addressEntryList.stream()
.filter(e -> walletFacade.getBalanceForAddress(e.getAddress()).isPositive())
.map(anAddressEntryList -> new WithdrawalListItem(anAddressEntryList, walletFacade, formatter))
.filter(e -> walletService.getBalanceForAddress(e.getAddress()).isPositive())
.map(anAddressEntryList -> new WithdrawalListItem(anAddressEntryList, walletService, formatter))
.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.FeePolicy;
import io.bitsquare.btc.WalletFacade;
import io.bitsquare.btc.WalletService;
import io.bitsquare.btc.listeners.TxConfidenceListener;
import io.bitsquare.gui.UIModel;
import io.bitsquare.offer.Direction;
@ -58,7 +58,7 @@ class PendingTradesModel extends UIModel {
private static final Logger log = LoggerFactory.getLogger(PendingTradesModel.class);
private final TradeManager tradeManager;
private final WalletFacade walletFacade;
private final WalletService walletService;
private final User user;
private final ObservableList<PendingTradesListItem> list = FXCollections.observableArrayList();
@ -82,9 +82,9 @@ class PendingTradesModel extends UIModel {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
PendingTradesModel(TradeManager tradeManager, WalletFacade walletFacade, User user) {
PendingTradesModel(TradeManager tradeManager, WalletService walletService, User user) {
this.tradeManager = tradeManager;
this.walletFacade = walletFacade;
this.walletService = walletService;
this.user = user;
}
@ -159,7 +159,7 @@ class PendingTradesModel extends UIModel {
trade.faultProperty().removeListener(faultChangeListener);
if (txConfidenceListener != null)
walletFacade.removeTxConfidenceListener(txConfidenceListener);
walletService.removeTxConfidenceListener(txConfidenceListener);
}
selectedItem = item;
@ -180,8 +180,8 @@ class PendingTradesModel extends UIModel {
updateConfidence(confidence);
}
};
walletFacade.addTxConfidenceListener(txConfidenceListener);
updateConfidence(walletFacade.getConfidenceForTxId(txId.get()));
walletService.addTxConfidenceListener(txConfidenceListener);
updateConfidence(walletService.getConfidenceForTxId(txId.get()));
trade.stateProperty().addListener(stateChangeListener);
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();
try {
walletFacade.sendFunds(fromAddress, toAddress, getAmountToWithdraw(), callback);
walletService.sendFunds(fromAddress, toAddress, getAmountToWithdraw(), callback);
} catch (AddressFormatException | InsufficientMoneyException e) {
e.printStackTrace();
log.error(e.getMessage());
@ -244,7 +244,7 @@ class PendingTradesModel extends UIModel {
if (Popups.isOK(response)) {
try {
walletFacade.sendFunds(
walletService.sendFunds(
withdrawFromTextField.getText(), withdrawToTextField.getText(),
changeAddressTextField.getText(), amount, callback);
} 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);
}
WalletFacade getWalletFacade() {
return walletFacade;
WalletService getWalletService() {
return walletService;
}
PendingTradesListItem getSelectedItem() {
@ -298,12 +298,12 @@ class PendingTradesModel extends UIModel {
}
Coin getAmountToWithdraw() {
AddressEntry addressEntry = walletFacade.getAddressInfoByTradeID(getTrade().getId());
AddressEntry addressEntry = walletService.getAddressInfoByTradeID(getTrade().getId());
log.debug("trade id " + getTrade().getId());
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());
// return walletFacade.getBalanceForAddress(addressEntry.getAddress()).subtract(FeePolicy.TX_FEE);
// return walletService.getBalanceForAddress(addressEntry.getAddress()).subtract(FeePolicy.TX_FEE);
// TODO handle overpaid securityDeposit
if (isOfferer())
@ -322,7 +322,7 @@ class PendingTradesModel extends UIModel {
&& getTrade().getState() == Trade.State.DEPOSIT_PUBLISHED) {
// only set it once when actual state is DEPOSIT_PUBLISHED, and remove listener afterwards
getTrade().setState(Trade.State.DEPOSIT_CONFIRMED);
walletFacade.removeTxConfidenceListener(txConfidenceListener);
walletService.removeTxConfidenceListener(txConfidenceListener);
txConfidenceListener = null;
}
}

View file

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

View file

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

View file

@ -35,7 +35,7 @@
<TitledGroupBg text="General application preferences" GridPane.rowSpan="8"/>
<Label text="Bitcoin denomination:" GridPane.rowIndex="0">
<GridPane.margin>
<GridPane.margin>
<Insets top="10"/>
</GridPane.margin>
</Label>

View file

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

View file

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

View file

@ -130,7 +130,7 @@ public class CreateOfferViewCB extends CachedViewCB<CreateOfferPM> {
setupListeners();
setupBindings();
balanceTextField.setup(presentationModel.getWalletFacade(), presentationModel.address.get(),
balanceTextField.setup(presentationModel.getWalletService(), presentationModel.address.get(),
presentationModel.getFormatter());
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.FeePolicy;
import io.bitsquare.btc.WalletFacade;
import io.bitsquare.btc.WalletService;
import io.bitsquare.btc.listeners.BalanceListener;
import io.bitsquare.gui.UIModel;
import io.bitsquare.offer.Offer;
@ -55,7 +55,7 @@ class TakeOfferModel extends UIModel {
private static final Logger log = LoggerFactory.getLogger(TakeOfferModel.class);
private final TradeManager tradeManager;
private final WalletFacade walletFacade;
private final WalletService walletService;
private final ApplicationPreferences applicationPreferences;
private final Persistence persistence;
@ -83,10 +83,10 @@ class TakeOfferModel extends UIModel {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
TakeOfferModel(TradeManager tradeManager, WalletFacade walletFacade, ApplicationPreferences applicationPreferences,
Persistence persistence) {
TakeOfferModel(TradeManager tradeManager, WalletService walletService,
ApplicationPreferences applicationPreferences, Persistence persistence) {
this.tradeManager = tradeManager;
this.walletFacade = walletFacade;
this.walletService = walletService;
this.applicationPreferences = applicationPreferences;
this.persistence = persistence;
}
@ -146,14 +146,14 @@ class TakeOfferModel extends UIModel {
calculateVolume();
calculateTotalToPay();
addressEntry = walletFacade.getAddressInfoByTradeID(offer.getId());
walletFacade.addBalanceListener(new BalanceListener(addressEntry.getAddress()) {
addressEntry = walletService.getAddressInfoByTradeID(offer.getId());
walletService.addBalanceListener(new BalanceListener(addressEntry.getAddress()) {
@Override
public void onBalanceChanged(@NotNull Coin balance) {
updateBalance(balance);
}
});
updateBalance(walletFacade.getBalanceForAddress(addressEntry.getAddress()));
updateBalance(walletService.getBalanceForAddress(addressEntry.getAddress()));
}
void takeOffer() {
@ -242,8 +242,8 @@ class TakeOfferModel extends UIModel {
// Getter
///////////////////////////////////////////////////////////////////////////////////////////
WalletFacade getWalletFacade() {
return walletFacade;
WalletService getWalletService() {
return walletService;
}
AddressEntry getAddressEntry() {

View file

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

View file

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

View file

@ -31,7 +31,7 @@ public abstract class MessageModule extends BitsquareModule {
@Override
protected final void configure() {
bind(MessageFacade.class).to(messageFacade()).asEagerSingleton();
bind(MessageService.class).to(messageService()).asEagerSingleton();
doConfigure();
}
@ -39,10 +39,10 @@ public abstract class MessageModule extends BitsquareModule {
protected void doConfigure() {
}
protected abstract Class<? extends MessageFacade> messageFacade();
protected abstract Class<? extends MessageService> messageService();
@Override
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;
public interface MessageFacade extends MessageBroker {
public interface MessageService extends MessageBroker {
void sendMessage(Peer peer, Message message, OutgoingMessageListener listener);

View file

@ -17,8 +17,8 @@
package io.bitsquare.msg.tomp2p;
import io.bitsquare.msg.MessageFacade;
import io.bitsquare.msg.MessageModule;
import io.bitsquare.msg.MessageService;
import io.bitsquare.network.BootstrapNodes;
import io.bitsquare.network.Node;
@ -42,7 +42,7 @@ public class TomP2PMessageModule extends MessageModule {
@Override
protected void doConfigure() {
bind(int.class).annotatedWith(Names.named(Node.PORT_KEY)).toInstance(
env.getProperty(Node.PORT_KEY, Integer.class, Node.DEFAULT_PORT));
env.getProperty(Node.PORT_KEY, Integer.class, Node.DEFAULT_PORT));
bind(TomP2PNode.class).asEagerSingleton();
bind(Node.class).annotatedWith(Names.named(BOOTSTRAP_NODE_KEY)).toInstance(
@ -58,7 +58,7 @@ public class TomP2PMessageModule extends MessageModule {
}
@Override
protected Class<? extends MessageFacade> messageFacade() {
return TomP2PMessageFacade.class;
protected Class<? extends MessageService> messageService() {
return TomP2PMessageService.class;
}
}

View file

@ -19,7 +19,7 @@ package io.bitsquare.msg.tomp2p;
import io.bitsquare.arbitrator.Arbitrator;
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.BootstrapListener;
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.
* 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).
* <p>
* TODO: improve callbacks that Platform.runLater is not necessary. We call usually that methods form teh UI thread.
*/
class TomP2PMessageFacade implements MessageFacade {
private static final Logger log = LoggerFactory.getLogger(TomP2PMessageFacade.class);
class TomP2PMessageService implements MessageService {
private static final Logger log = LoggerFactory.getLogger(TomP2PMessageService.class);
private static final String ARBITRATORS_ROOT = "ArbitratorsRoot";
private final TomP2PNode p2pNode;
@ -82,7 +82,7 @@ class TomP2PMessageFacade implements MessageFacade {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public TomP2PMessageFacade(User user, TomP2PNode p2pNode) {
public TomP2PMessageService(User user, TomP2PNode p2pNode) {
this.user = user;
this.p2pNode = p2pNode;
}

View file

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

View file

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

View file

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

View file

@ -17,7 +17,7 @@
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 org.bitcoinj.core.Coin;
@ -33,15 +33,15 @@ public class CreateDepositTx {
public static void run(ResultHandler resultHandler,
ExceptionHandler exceptionHandler,
WalletFacade walletFacade,
WalletService walletService,
String tradeId,
Coin offererInputAmount,
String takerMultiSigPubKey,
String arbitratorPubKeyAsHex) {
log.trace("Run task");
try {
String offererPubKey = walletFacade.getAddressInfoByTradeID(tradeId).getPubKeyAsHexString();
Transaction transaction = walletFacade.offererCreatesMSTxAndAddPayment(
String offererPubKey = walletService.getAddressInfoByTradeID(tradeId).getPubKeyAsHexString();
Transaction transaction = walletService.offererCreatesMSTxAndAddPayment(
offererInputAmount, offererPubKey, takerMultiSigPubKey, arbitratorPubKeyAsHex, tradeId);
String preparedOffererDepositTxAsHex = Utils.HEX.encode(transaction.bitcoinSerialize());

View file

@ -17,7 +17,7 @@
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.network.Peer;
import io.bitsquare.trade.Trade;
@ -31,7 +31,7 @@ public class HandleTakeOfferRequest {
private static final Logger log = LoggerFactory.getLogger(HandleTakeOfferRequest.class);
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");
boolean takeOfferRequestAccepted = tradeState == Trade.State.OPEN;
if (!takeOfferRequestAccepted) {
@ -39,7 +39,7 @@ public class HandleTakeOfferRequest {
}
RespondToTakeOfferRequestMessage tradeMessage =
new RespondToTakeOfferRequestMessage(tradeId, takeOfferRequestAccepted);
messageFacade.sendMessage(peer, tradeMessage, new OutgoingMessageListener() {
messageService.sendMessage(peer, tradeMessage, new OutgoingMessageListener() {
@Override
public void onResult() {
log.trace("RespondToTakeOfferRequestMessage successfully arrived at peer");

View file

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

View file

@ -17,7 +17,7 @@
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.network.Peer;
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);
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");
DepositTxPublishedMessage tradeMessage =
new DepositTxPublishedMessage(tradeId, Utils.HEX.encode(depositTransaction.bitcoinSerialize()));
messageFacade.sendMessage(peer, tradeMessage, new OutgoingMessageListener() {
messageService.sendMessage(peer, tradeMessage, new OutgoingMessageListener() {
@Override
public void onResult() {
log.trace("DepositTxPublishedMessage successfully arrived at peer");

View file

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

View file

@ -17,7 +17,7 @@
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 org.bitcoinj.core.Transaction;
@ -34,7 +34,7 @@ public class SignAndPublishDepositTx {
public static void run(ResultHandler resultHandler,
ExceptionHandler exceptionHandler,
WalletFacade walletFacade,
WalletService walletService,
String preparedOffererDepositTxAsHex,
String signedTakerDepositTxAsHex,
String txConnOutAsHex,
@ -43,7 +43,7 @@ public class SignAndPublishDepositTx {
long takerTxOutIndex) {
log.trace("Run task");
try {
walletFacade.offererSignAndPublishTx(preparedOffererDepositTxAsHex,
walletService.offererSignAndPublishTx(preparedOffererDepositTxAsHex,
signedTakerDepositTxAsHex,
txConnOutAsHex,
txScriptSigAsHex,

View file

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

View file

@ -17,7 +17,7 @@
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.ResultHandler;
@ -27,11 +27,11 @@ import org.slf4j.LoggerFactory;
public class VerifyTakeOfferFeePayment {
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) {
log.trace("Run task");
//TODO mocked yet, need a confidence listeners
int numOfPeersSeenTx = walletFacade.getNumOfPeersSeenTx(takeOfferFeeTxId);
int numOfPeersSeenTx = walletService.getNumOfPeersSeenTx(takeOfferFeeTxId);
if (numOfPeersSeenTx > 2) {
resultHandler.handleResult();
}

View file

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

View file

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

View file

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

View file

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

View file

@ -17,7 +17,7 @@
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 org.bitcoinj.core.Coin;
@ -32,7 +32,7 @@ public class PayDeposit {
public static void run(ResultHandler resultHandler,
ExceptionHandler exceptionHandler,
WalletFacade walletFacade,
WalletService walletService,
Coin securityDeposit,
Coin tradeAmount,
String tradeId,
@ -45,7 +45,7 @@ public class PayDeposit {
Coin amountToPay = tradeAmount.add(securityDeposit);
Coin msOutputAmount = amountToPay.add(securityDeposit);
Transaction signedTakerDepositTx = walletFacade.takerAddPaymentAndSignTx(amountToPay,
Transaction signedTakerDepositTx = walletService.takerAddPaymentAndSignTx(amountToPay,
msOutputAmount,
offererPubKey,
pubKeyForThatTrade,

View file

@ -17,7 +17,7 @@
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 org.bitcoinj.core.InsufficientMoneyException;
@ -33,11 +33,11 @@ import org.slf4j.LoggerFactory;
public class PayTakeOfferFee {
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) {
log.trace("Run task");
try {
walletFacade.payTakeOfferFee(tradeId, new FutureCallback<Transaction>() {
walletService.payTakeOfferFee(tradeId, new FutureCallback<Transaction>() {
@Override
public void onSuccess(Transaction transaction) {
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;
import io.bitsquare.msg.MessageFacade;
import io.bitsquare.msg.MessageService;
import io.bitsquare.msg.listeners.OutgoingMessageListener;
import io.bitsquare.network.Peer;
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);
public static void run(ResultHandler resultHandler, ExceptionHandler exceptionHandler, Peer peer,
MessageFacade messageFacade, String tradeId) {
MessageService messageService, String tradeId) {
log.trace("Run task");
messageFacade.sendMessage(peer, new RequestTakeOfferMessage(tradeId),
messageService.sendMessage(peer, new RequestTakeOfferMessage(tradeId),
new OutgoingMessageListener() {
@Override
public void onResult() {

View file

@ -17,7 +17,7 @@
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.network.Peer;
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);
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");
PayoutTxPublishedMessage tradeMessage = new PayoutTxPublishedMessage(tradeId, payoutTxAsHex);
messageFacade.sendMessage(peer, tradeMessage, new OutgoingMessageListener() {
messageService.sendMessage(peer, tradeMessage, new OutgoingMessageListener() {
@Override
public void onResult() {
log.trace("PayoutTxPublishedMessage successfully arrived at peer");

View file

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

View file

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

View file

@ -17,7 +17,7 @@
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 org.bitcoinj.core.Coin;
@ -36,7 +36,7 @@ public class SignAndPublishPayoutTx {
public static void run(ResultHandler resultHandler,
ExceptionHandler exceptionHandler,
WalletFacade walletFacade,
WalletService walletService,
String tradeId,
String depositTxAsHex,
String offererSignatureR,
@ -47,7 +47,7 @@ public class SignAndPublishPayoutTx {
log.trace("Run task");
try {
walletFacade.takerSignsAndSendsTx(depositTxAsHex,
walletService.takerSignsAndSendsTx(depositTxAsHex,
offererSignatureR,
offererSignatureS,
offererPaybackAmount,

View file

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

View file

@ -46,12 +46,15 @@ public class BitsquareEnvironmentTests {
.withProperty("key.y", "y.env");
ConfigurableEnvironment env = new BitsquareEnvironment(commandlineProps) {
@Override PropertySource<?> filesystemProperties() { return filesystemProps; }
@Override
PropertySource<?> filesystemProperties() {
return filesystemProps;
}
};
MutablePropertySources propertySources = env.getPropertySources();
assertThat(propertySources.precedenceOf(named(BITSQUARE_COMMANDLINE_PROPERTY_SOURCE_NAME)), equalTo(0));
assertThat(propertySources.precedenceOf(named(SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME)), equalTo(1));
assertThat(propertySources.precedenceOf(named(SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME)), equalTo(1));
assertThat(propertySources.precedenceOf(named(SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME)), equalTo(2));
assertThat(propertySources.precedenceOf(named(BITSQUARE_FILESYSTEM_PROPERTY_SOURCE_NAME)), equalTo(3));
assertThat(propertySources.precedenceOf(named(BITSQUARE_CLASSPATH_PROPERTY_SOURCE_NAME)), equalTo(4));

View file

@ -63,7 +63,7 @@ public class ViewLoaderTests {
@Before
public void setUp() {
OptionParser parser = new OptionParser();
BitsquareEnvironment env = new BitsquareEnvironment(parser.parse(new String[] {}));
BitsquareEnvironment env = new BitsquareEnvironment(parser.parse(new String[]{}));
Injector injector = Guice.createInjector(new BitsquareAppModule(env, TestApp.primaryStage));
ViewLoader.setInjector(injector);
}