Renamed TradeService to TradeWalletService

This commit is contained in:
Manfred Karrer 2015-03-17 09:22:44 +01:00
parent 1a5118f601
commit 9a46ef7c4d
12 changed files with 24 additions and 24 deletions

View file

@ -75,15 +75,15 @@ import static com.google.inject.internal.util.$Preconditions.*;
OUT[1] Taker payout address OUT[1] Taker payout address
*/ */
public class TradeService { public class TradeWalletService {
private static final Logger log = LoggerFactory.getLogger(TradeService.class); private static final Logger log = LoggerFactory.getLogger(TradeWalletService.class);
private final NetworkParameters params; private final NetworkParameters params;
private final Wallet wallet; private final Wallet wallet;
private final WalletAppKit walletAppKit; private final WalletAppKit walletAppKit;
private final FeePolicy feePolicy; private final FeePolicy feePolicy;
public TradeService(NetworkParameters params, Wallet wallet, WalletAppKit walletAppKit, FeePolicy feePolicy) { public TradeWalletService(NetworkParameters params, Wallet wallet, WalletAppKit walletAppKit, FeePolicy feePolicy) {
this.params = params; this.params = params;
this.wallet = wallet; this.wallet = wallet;
this.walletAppKit = walletAppKit; this.walletAppKit = walletAppKit;

View file

@ -110,7 +110,7 @@ public class WalletService {
private AddressEntry arbitratorDepositAddressEntry; private AddressEntry arbitratorDepositAddressEntry;
private @GuardedBy(LOCK_NAME) List<AddressEntry> addressEntryList = new ArrayList<>(); private @GuardedBy(LOCK_NAME) List<AddressEntry> addressEntryList = new ArrayList<>();
private TradeService tradeService; private TradeWalletService tradeWalletService;
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
// Constructor // Constructor
@ -155,7 +155,7 @@ public class WalletService {
walletAppKit.peerGroup().setBloomFilterFalsePositiveRate(0.00001); walletAppKit.peerGroup().setBloomFilterFalsePositiveRate(0.00001);
initWallet(); initWallet();
tradeService = new TradeService(params, wallet, walletAppKit, feePolicy); tradeWalletService = new TradeWalletService(params, wallet, walletAppKit, feePolicy);
status.onCompleted(); status.onCompleted();
} }
@ -475,8 +475,8 @@ public class WalletService {
// Transactions // Transactions
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
public TradeService getTradeService() { public TradeWalletService getTradeWalletService() {
return tradeService; return tradeWalletService;
} }
public void payRegistrationFee(String stringifiedBankAccounts, FutureCallback<Transaction> callback) throws public void payRegistrationFee(String stringifiedBankAccounts, FutureCallback<Transaction> callback) throws

View file

@ -54,7 +54,7 @@ public class BroadcastCreateOfferFeeTx extends Task<PlaceOfferModel> {
Coin balance = model.getWalletService().getBalanceForAddress(addressEntry.getAddress()); Coin balance = model.getWalletService().getBalanceForAddress(addressEntry.getAddress());
if (balance.compareTo(totalsNeeded) >= 0) { if (balance.compareTo(totalsNeeded) >= 0) {
model.getWalletService().getTradeService().broadcastCreateOfferFeeTx(model.getTransaction(), new FutureCallback<Transaction>() { model.getWalletService().getTradeWalletService().broadcastCreateOfferFeeTx(model.getTransaction(), new FutureCallback<Transaction>() {
@Override @Override
public void onSuccess(Transaction transaction) { public void onSuccess(Transaction transaction) {
log.info("Broadcast of offer fee payment succeeded: transaction = " + transaction.toString()); log.info("Broadcast of offer fee payment succeeded: transaction = " + transaction.toString());

View file

@ -36,7 +36,7 @@ public class CreateOfferFeeTx extends Task<PlaceOfferModel> {
@Override @Override
protected void doRun() { protected void doRun() {
try { try {
Transaction transaction = model.getWalletService().getTradeService().createOfferFeeTx( Transaction transaction = model.getWalletService().getTradeWalletService().createOfferFeeTx(
model.getWalletService().getAddressEntry(model.getOffer().getId())); model.getWalletService().getAddressEntry(model.getOffer().getId()));
// We assume there will be no tx malleability. We add a check later in case the published offer has a different hash. // We assume there will be no tx malleability. We add a check later in case the published offer has a different hash.

View file

@ -20,7 +20,7 @@ package io.bitsquare.trade.protocol.trade;
import io.bitsquare.bank.BankAccount; import io.bitsquare.bank.BankAccount;
import io.bitsquare.btc.AddressEntry; import io.bitsquare.btc.AddressEntry;
import io.bitsquare.btc.BlockChainService; import io.bitsquare.btc.BlockChainService;
import io.bitsquare.btc.TradeService; import io.bitsquare.btc.TradeWalletService;
import io.bitsquare.btc.WalletService; import io.bitsquare.btc.WalletService;
import io.bitsquare.crypto.SignatureService; import io.bitsquare.crypto.SignatureService;
import io.bitsquare.offer.Offer; import io.bitsquare.offer.Offer;
@ -55,7 +55,7 @@ public class OfferSharedModel extends SharedModel {
private final DeterministicKey registrationKeyPair; private final DeterministicKey registrationKeyPair;
private final byte[] arbitratorPubKey; private final byte[] arbitratorPubKey;
private final AddressEntry addressEntry; private final AddressEntry addressEntry;
private final TradeService tradeService; private final TradeWalletService tradeWalletService;
// data written/read by tasks // data written/read by tasks
private TradeMessage tradeMessage; private TradeMessage tradeMessage;
@ -74,7 +74,7 @@ public class OfferSharedModel extends SharedModel {
this.signatureService = signatureService; this.signatureService = signatureService;
id = offer.getId(); id = offer.getId();
tradeService = walletService.getTradeService(); tradeWalletService = walletService.getTradeWalletService();
//TODO use default arbitrator for now //TODO use default arbitrator for now
arbitratorPubKey = offer.getArbitrators().get(0).getPubKey(); arbitratorPubKey = offer.getArbitrators().get(0).getPubKey();
registrationPubKey = walletService.getRegistrationAddressEntry().getPubKey(); registrationPubKey = walletService.getRegistrationAddressEntry().getPubKey();
@ -91,8 +91,8 @@ public class OfferSharedModel extends SharedModel {
return id; return id;
} }
public TradeService getTradeService() { public TradeWalletService getTradeWalletService() {
return tradeService; return tradeWalletService;
} }
public TradeMessage getTradeMessage() { public TradeMessage getTradeMessage() {

View file

@ -19,7 +19,7 @@ package io.bitsquare.trade.protocol.trade.offerer.tasks;
import io.bitsquare.btc.AddressEntry; import io.bitsquare.btc.AddressEntry;
import io.bitsquare.btc.FeePolicy; import io.bitsquare.btc.FeePolicy;
import io.bitsquare.btc.TradeService; import io.bitsquare.btc.TradeWalletService;
import io.bitsquare.trade.protocol.trade.offerer.BuyerAsOffererModel; import io.bitsquare.trade.protocol.trade.offerer.BuyerAsOffererModel;
import io.bitsquare.util.taskrunner.Task; import io.bitsquare.util.taskrunner.Task;
import io.bitsquare.util.taskrunner.TaskRunner; import io.bitsquare.util.taskrunner.TaskRunner;
@ -41,7 +41,7 @@ public class GetOffererDepositTxInputs extends Task<BuyerAsOffererModel> {
try { try {
Coin offererInputAmount = model.getTrade().getSecurityDeposit().add(FeePolicy.TX_FEE); Coin offererInputAmount = model.getTrade().getSecurityDeposit().add(FeePolicy.TX_FEE);
AddressEntry addressInfo = model.getAddressEntry(); AddressEntry addressInfo = model.getAddressEntry();
TradeService.TransactionDataResult result = model.getTradeService().offererCreatesDepositTxInputs(offererInputAmount, addressInfo); TradeWalletService.TransactionDataResult result = model.getTradeWalletService().offererCreatesDepositTxInputs(offererInputAmount, addressInfo);
model.setOffererConnectedOutputsForAllInputs(result.getConnectedOutputsForAllInputs()); model.setOffererConnectedOutputsForAllInputs(result.getConnectedOutputsForAllInputs());
model.setOffererOutputs(result.getOutputs()); model.setOffererOutputs(result.getOutputs());

View file

@ -44,7 +44,7 @@ public class SignAndPublishDepositTx extends Task<BuyerAsOffererModel> {
protected void doRun() { protected void doRun() {
try { try {
Coin offererInputAmount = model.getTrade().getSecurityDeposit().add(FeePolicy.TX_FEE); Coin offererInputAmount = model.getTrade().getSecurityDeposit().add(FeePolicy.TX_FEE);
model.getTradeService().offererSignsAndPublishTx( model.getTradeWalletService().offererSignsAndPublishTx(
model.getTakerDepositTx(), model.getTakerDepositTx(),
model.getOffererConnectedOutputsForAllInputs(), model.getOffererConnectedOutputsForAllInputs(),
model.getTakerConnectedOutputsForAllInputs(), model.getTakerConnectedOutputsForAllInputs(),

View file

@ -17,7 +17,7 @@
package io.bitsquare.trade.protocol.trade.offerer.tasks; package io.bitsquare.trade.protocol.trade.offerer.tasks;
import io.bitsquare.btc.TradeService; import io.bitsquare.btc.TradeWalletService;
import io.bitsquare.trade.Trade; import io.bitsquare.trade.Trade;
import io.bitsquare.trade.protocol.trade.offerer.BuyerAsOffererModel; import io.bitsquare.trade.protocol.trade.offerer.BuyerAsOffererModel;
import io.bitsquare.util.taskrunner.Task; import io.bitsquare.util.taskrunner.Task;
@ -43,7 +43,7 @@ public class SignPayoutTx extends Task<BuyerAsOffererModel> {
Coin offererPayoutAmount = trade.getTradeAmount().add(securityDeposit); Coin offererPayoutAmount = trade.getTradeAmount().add(securityDeposit);
@SuppressWarnings("UnnecessaryLocalVariable") Coin takerPayoutAmount = securityDeposit; @SuppressWarnings("UnnecessaryLocalVariable") Coin takerPayoutAmount = securityDeposit;
TradeService.TransactionDataResult result = model.getTradeService().offererCreatesAndSignsPayoutTx( TradeWalletService.TransactionDataResult result = model.getTradeWalletService().offererCreatesAndSignsPayoutTx(
trade.getDepositTx(), trade.getDepositTx(),
offererPayoutAmount, offererPayoutAmount,
takerPayoutAmount, takerPayoutAmount,

View file

@ -41,7 +41,7 @@ public class PayTakeOfferFee extends Task<SellerAsTakerModel> {
@Override @Override
protected void doRun() { protected void doRun() {
try { try {
model.getTradeService().payTakeOfferFee(model.getAddressEntry(), new FutureCallback<Transaction>() { model.getTradeWalletService().payTakeOfferFee(model.getAddressEntry(), new FutureCallback<Transaction>() {
@Override @Override
public void onSuccess(Transaction transaction) { public void onSuccess(Transaction transaction) {
log.debug("Take offer fee paid successfully. Transaction ID = " + transaction.getHashAsString()); log.debug("Take offer fee paid successfully. Transaction ID = " + transaction.getHashAsString());

View file

@ -41,7 +41,7 @@ public class SignAndPublishPayoutTx extends Task<SellerAsTakerModel> {
@Override @Override
protected void doRun() { protected void doRun() {
try { try {
model.getTradeService().takerSignsAndPublishPayoutTx( model.getTradeWalletService().takerSignsAndPublishPayoutTx(
model.getPublishedDepositTx(), model.getPublishedDepositTx(),
model.getOffererSignature(), model.getOffererSignature(),
model.getOffererPayoutAmount(), model.getOffererPayoutAmount(),

View file

@ -37,7 +37,7 @@ public class TakerCommitDepositTx extends Task<SellerAsTakerModel> {
@Override @Override
protected void doRun() { protected void doRun() {
try { try {
Transaction transaction = model.getTradeService().takerCommitsDepositTx(model.getPublishedDepositTx()); Transaction transaction = model.getTradeWalletService().takerCommitsDepositTx(model.getPublishedDepositTx());
model.getTrade().setDepositTx(transaction); model.getTrade().setDepositTx(transaction);
model.getTrade().setState(Trade.State.DEPOSIT_PUBLISHED); model.getTrade().setState(Trade.State.DEPOSIT_PUBLISHED);

View file

@ -18,7 +18,7 @@
package io.bitsquare.trade.protocol.trade.taker.tasks; package io.bitsquare.trade.protocol.trade.taker.tasks;
import io.bitsquare.btc.FeePolicy; import io.bitsquare.btc.FeePolicy;
import io.bitsquare.btc.TradeService; import io.bitsquare.btc.TradeWalletService;
import io.bitsquare.trade.Trade; import io.bitsquare.trade.Trade;
import io.bitsquare.trade.protocol.trade.taker.SellerAsTakerModel; import io.bitsquare.trade.protocol.trade.taker.SellerAsTakerModel;
import io.bitsquare.util.taskrunner.Task; import io.bitsquare.util.taskrunner.Task;
@ -42,7 +42,7 @@ public class TakerCreatesAndSignsDepositTx extends Task<SellerAsTakerModel> {
Coin takerInputAmount = model.getTrade().getTradeAmount().add(model.getTrade().getSecurityDeposit()).add(FeePolicy.TX_FEE); Coin takerInputAmount = model.getTrade().getTradeAmount().add(model.getTrade().getSecurityDeposit()).add(FeePolicy.TX_FEE);
Coin msOutputAmount = takerInputAmount.add(model.getTrade().getSecurityDeposit()); Coin msOutputAmount = takerInputAmount.add(model.getTrade().getSecurityDeposit());
TradeService.TransactionDataResult result = model.getTradeService().takerCreatesAndSignsDepositTx( TradeWalletService.TransactionDataResult result = model.getTradeWalletService().takerCreatesAndSignsDepositTx(
takerInputAmount, takerInputAmount,
msOutputAmount, msOutputAmount,
model.getOffererConnectedOutputsForAllInputs(), model.getOffererConnectedOutputsForAllInputs(),