mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-07-28 17:34:11 -04:00
Rename io.bitsquare.crypto.{Crypto=>Signature}Service
This commit is contained in:
parent
80758a0a47
commit
99dcea4001
8 changed files with 33 additions and 33 deletions
|
@ -20,7 +20,7 @@ package io.bitsquare.btc;
|
||||||
import io.bitsquare.btc.listeners.AddressConfidenceListener;
|
import io.bitsquare.btc.listeners.AddressConfidenceListener;
|
||||||
import io.bitsquare.btc.listeners.BalanceListener;
|
import io.bitsquare.btc.listeners.BalanceListener;
|
||||||
import io.bitsquare.btc.listeners.TxConfidenceListener;
|
import io.bitsquare.btc.listeners.TxConfidenceListener;
|
||||||
import io.bitsquare.crypto.CryptoService;
|
import io.bitsquare.crypto.SignatureService;
|
||||||
import io.bitsquare.persistence.Persistence;
|
import io.bitsquare.persistence.Persistence;
|
||||||
|
|
||||||
import org.bitcoinj.core.Address;
|
import org.bitcoinj.core.Address;
|
||||||
|
@ -105,7 +105,7 @@ public class WalletService {
|
||||||
|
|
||||||
private final NetworkParameters params;
|
private final NetworkParameters params;
|
||||||
private final FeePolicy feePolicy;
|
private final FeePolicy feePolicy;
|
||||||
private final CryptoService cryptoService;
|
private final SignatureService signatureService;
|
||||||
private final Persistence persistence;
|
private final Persistence persistence;
|
||||||
private final File walletDir;
|
private final File walletDir;
|
||||||
private final String walletPrefix;
|
private final String walletPrefix;
|
||||||
|
@ -123,12 +123,12 @@ public class WalletService {
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public WalletService(NetworkParameters params, FeePolicy feePolicy, CryptoService cryptoService,
|
public WalletService(NetworkParameters params, FeePolicy feePolicy, SignatureService signatureService,
|
||||||
Persistence persistence, UserAgent userAgent,
|
Persistence persistence, UserAgent userAgent,
|
||||||
@Named(DIR_KEY) File walletDir, @Named(PREFIX_KEY) String walletPrefix) {
|
@Named(DIR_KEY) File walletDir, @Named(PREFIX_KEY) String walletPrefix) {
|
||||||
this.params = params;
|
this.params = params;
|
||||||
this.feePolicy = feePolicy;
|
this.feePolicy = feePolicy;
|
||||||
this.cryptoService = cryptoService;
|
this.signatureService = signatureService;
|
||||||
this.persistence = persistence;
|
this.persistence = persistence;
|
||||||
this.walletDir = walletDir;
|
this.walletDir = walletDir;
|
||||||
this.walletPrefix = walletPrefix;
|
this.walletPrefix = walletPrefix;
|
||||||
|
@ -555,7 +555,7 @@ public class WalletService {
|
||||||
|
|
||||||
Transaction tx = new Transaction(params);
|
Transaction tx = new Transaction(params);
|
||||||
|
|
||||||
byte[] data = cryptoService.getEmbeddedAccountRegistrationData(
|
byte[] data = signatureService.getEmbeddedAccountRegistrationData(
|
||||||
getRegistrationAddressEntry().getKey(), stringifiedBankAccounts);
|
getRegistrationAddressEntry().getKey(), stringifiedBankAccounts);
|
||||||
tx.addOutput(Transaction.MIN_NONDUST_OUTPUT, new ScriptBuilder().op(OP_RETURN).data(data).build());
|
tx.addOutput(Transaction.MIN_NONDUST_OUTPUT, new ScriptBuilder().op(OP_RETURN).data(data).build());
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,6 @@ public class CryptoModule extends BitsquareModule {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bind(CryptoService.class).asEagerSingleton();
|
bind(SignatureService.class).asEagerSingleton();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,12 +42,12 @@ import org.spongycastle.util.encoders.Base64;
|
||||||
* That service delivers crypto functionality from the bitcoinJ library
|
* That service delivers crypto functionality from the bitcoinJ library
|
||||||
* //TODO still very basic as not much used yet, missing implementations
|
* //TODO still very basic as not much used yet, missing implementations
|
||||||
*/
|
*/
|
||||||
public class CryptoService {
|
public class SignatureService {
|
||||||
private static final Logger log = LoggerFactory.getLogger(CryptoService.class);
|
private static final Logger log = LoggerFactory.getLogger(SignatureService.class);
|
||||||
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public CryptoService() {
|
public SignatureService() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeterministicKey does not support signMessage yet.
|
// DeterministicKey does not support signMessage yet.
|
|
@ -20,7 +20,7 @@ package io.bitsquare.trade;
|
||||||
import io.bitsquare.account.AccountSettings;
|
import io.bitsquare.account.AccountSettings;
|
||||||
import io.bitsquare.btc.BlockChainService;
|
import io.bitsquare.btc.BlockChainService;
|
||||||
import io.bitsquare.btc.WalletService;
|
import io.bitsquare.btc.WalletService;
|
||||||
import io.bitsquare.crypto.CryptoService;
|
import io.bitsquare.crypto.SignatureService;
|
||||||
import io.bitsquare.msg.Message;
|
import io.bitsquare.msg.Message;
|
||||||
import io.bitsquare.msg.MessageService;
|
import io.bitsquare.msg.MessageService;
|
||||||
import io.bitsquare.network.Peer;
|
import io.bitsquare.network.Peer;
|
||||||
|
@ -78,7 +78,7 @@ public class TradeManager {
|
||||||
private final MessageService messageService;
|
private final MessageService messageService;
|
||||||
private final BlockChainService blockChainService;
|
private final BlockChainService blockChainService;
|
||||||
private final WalletService walletService;
|
private final WalletService walletService;
|
||||||
private final CryptoService cryptoService;
|
private final SignatureService signatureService;
|
||||||
private final OfferRepository offerRepository;
|
private final OfferRepository offerRepository;
|
||||||
|
|
||||||
//TODO store TakerAsSellerProtocol in trade
|
//TODO store TakerAsSellerProtocol in trade
|
||||||
|
@ -100,8 +100,8 @@ public class TradeManager {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public TradeManager(User user, AccountSettings accountSettings, Persistence persistence,
|
public TradeManager(User user, AccountSettings accountSettings, Persistence persistence,
|
||||||
MessageService messageService,
|
MessageService messageService, BlockChainService blockChainService,
|
||||||
BlockChainService blockChainService, WalletService walletService, CryptoService cryptoService,
|
WalletService walletService, SignatureService signatureService,
|
||||||
OfferRepository offerRepository) {
|
OfferRepository offerRepository) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
this.accountSettings = accountSettings;
|
this.accountSettings = accountSettings;
|
||||||
|
@ -109,7 +109,7 @@ public class TradeManager {
|
||||||
this.messageService = messageService;
|
this.messageService = messageService;
|
||||||
this.blockChainService = blockChainService;
|
this.blockChainService = blockChainService;
|
||||||
this.walletService = walletService;
|
this.walletService = walletService;
|
||||||
this.cryptoService = cryptoService;
|
this.signatureService = signatureService;
|
||||||
this.offerRepository = offerRepository;
|
this.offerRepository = offerRepository;
|
||||||
|
|
||||||
Object offersObject = persistence.read(this, "offers");
|
Object offersObject = persistence.read(this, "offers");
|
||||||
|
@ -249,7 +249,7 @@ public class TradeManager {
|
||||||
messageService,
|
messageService,
|
||||||
walletService,
|
walletService,
|
||||||
blockChainService,
|
blockChainService,
|
||||||
cryptoService,
|
signatureService,
|
||||||
user,
|
user,
|
||||||
new BuyerAcceptsOfferProtocolListener() {
|
new BuyerAcceptsOfferProtocolListener() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -372,7 +372,7 @@ public class TradeManager {
|
||||||
};
|
};
|
||||||
|
|
||||||
SellerTakesOfferProtocol sellerTakesOfferProtocol = new SellerTakesOfferProtocol(
|
SellerTakesOfferProtocol sellerTakesOfferProtocol = new SellerTakesOfferProtocol(
|
||||||
trade, listener, messageService, walletService, blockChainService, cryptoService,
|
trade, listener, messageService, walletService, blockChainService, signatureService,
|
||||||
user);
|
user);
|
||||||
takerAsSellerProtocolMap.put(trade.getId(), sellerTakesOfferProtocol);
|
takerAsSellerProtocolMap.put(trade.getId(), sellerTakesOfferProtocol);
|
||||||
sellerTakesOfferProtocol.start();
|
sellerTakesOfferProtocol.start();
|
||||||
|
|
|
@ -21,7 +21,7 @@ import io.bitsquare.bank.BankAccount;
|
||||||
import io.bitsquare.btc.BlockChainService;
|
import io.bitsquare.btc.BlockChainService;
|
||||||
import io.bitsquare.btc.FeePolicy;
|
import io.bitsquare.btc.FeePolicy;
|
||||||
import io.bitsquare.btc.WalletService;
|
import io.bitsquare.btc.WalletService;
|
||||||
import io.bitsquare.crypto.CryptoService;
|
import io.bitsquare.crypto.SignatureService;
|
||||||
import io.bitsquare.msg.MessageService;
|
import io.bitsquare.msg.MessageService;
|
||||||
import io.bitsquare.network.Peer;
|
import io.bitsquare.network.Peer;
|
||||||
import io.bitsquare.offer.Offer;
|
import io.bitsquare.offer.Offer;
|
||||||
|
@ -99,7 +99,7 @@ public class BuyerAcceptsOfferProtocol {
|
||||||
private final MessageService messageService;
|
private final MessageService messageService;
|
||||||
private final WalletService walletService;
|
private final WalletService walletService;
|
||||||
private final BlockChainService blockChainService;
|
private final BlockChainService blockChainService;
|
||||||
private final CryptoService cryptoService;
|
private final SignatureService signatureService;
|
||||||
private final BuyerAcceptsOfferProtocolListener listener;
|
private final BuyerAcceptsOfferProtocolListener listener;
|
||||||
|
|
||||||
// derived
|
// derived
|
||||||
|
@ -142,7 +142,7 @@ public class BuyerAcceptsOfferProtocol {
|
||||||
MessageService messageService,
|
MessageService messageService,
|
||||||
WalletService walletService,
|
WalletService walletService,
|
||||||
BlockChainService blockChainService,
|
BlockChainService blockChainService,
|
||||||
CryptoService cryptoService,
|
SignatureService signatureService,
|
||||||
User user,
|
User user,
|
||||||
BuyerAcceptsOfferProtocolListener listener) {
|
BuyerAcceptsOfferProtocolListener listener) {
|
||||||
this.trade = trade;
|
this.trade = trade;
|
||||||
|
@ -151,7 +151,7 @@ public class BuyerAcceptsOfferProtocol {
|
||||||
this.messageService = messageService;
|
this.messageService = messageService;
|
||||||
this.walletService = walletService;
|
this.walletService = walletService;
|
||||||
this.blockChainService = blockChainService;
|
this.blockChainService = blockChainService;
|
||||||
this.cryptoService = cryptoService;
|
this.signatureService = signatureService;
|
||||||
|
|
||||||
tradeId = trade.getId();
|
tradeId = trade.getId();
|
||||||
offer = trade.getOffer();
|
offer = trade.getOffer();
|
||||||
|
@ -297,7 +297,7 @@ public class BuyerAcceptsOfferProtocol {
|
||||||
state = State.VerifyAndSignContract;
|
state = State.VerifyAndSignContract;
|
||||||
VerifyAndSignContract.run(this::onResultVerifyAndSignContract,
|
VerifyAndSignContract.run(this::onResultVerifyAndSignContract,
|
||||||
this::onFault,
|
this::onFault,
|
||||||
cryptoService,
|
signatureService,
|
||||||
accountId,
|
accountId,
|
||||||
tradeAmount,
|
tradeAmount,
|
||||||
takeOfferFeeTxId,
|
takeOfferFeeTxId,
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
package io.bitsquare.trade.protocol.trade.offerer.tasks;
|
package io.bitsquare.trade.protocol.trade.offerer.tasks;
|
||||||
|
|
||||||
import io.bitsquare.bank.BankAccount;
|
import io.bitsquare.bank.BankAccount;
|
||||||
import io.bitsquare.crypto.CryptoService;
|
import io.bitsquare.crypto.SignatureService;
|
||||||
import io.bitsquare.offer.Offer;
|
import io.bitsquare.offer.Offer;
|
||||||
import io.bitsquare.trade.Contract;
|
import io.bitsquare.trade.Contract;
|
||||||
import io.bitsquare.util.Utilities;
|
import io.bitsquare.util.Utilities;
|
||||||
|
@ -37,7 +37,7 @@ public class VerifyAndSignContract {
|
||||||
|
|
||||||
public static void run(ResultHandler resultHandler,
|
public static void run(ResultHandler resultHandler,
|
||||||
ExceptionHandler exceptionHandler,
|
ExceptionHandler exceptionHandler,
|
||||||
CryptoService cryptoService,
|
SignatureService signatureService,
|
||||||
String accountId,
|
String accountId,
|
||||||
Coin tradeAmount,
|
Coin tradeAmount,
|
||||||
String takeOfferFeeTxId,
|
String takeOfferFeeTxId,
|
||||||
|
@ -56,7 +56,7 @@ public class VerifyAndSignContract {
|
||||||
String contractAsJson = Utilities.objectToJson(contract);
|
String contractAsJson = Utilities.objectToJson(contract);
|
||||||
|
|
||||||
log.trace("The 2 contracts as json does match");
|
log.trace("The 2 contracts as json does match");
|
||||||
String signature = cryptoService.signContract(registrationKey, contractAsJson);
|
String signature = signatureService.signContract(registrationKey, contractAsJson);
|
||||||
//log.trace("signature: " + signature);
|
//log.trace("signature: " + signature);
|
||||||
resultHandler.onResult(contract, contractAsJson, signature);
|
resultHandler.onResult(contract, contractAsJson, signature);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ package io.bitsquare.trade.protocol.trade.taker;
|
||||||
import io.bitsquare.bank.BankAccount;
|
import io.bitsquare.bank.BankAccount;
|
||||||
import io.bitsquare.btc.BlockChainService;
|
import io.bitsquare.btc.BlockChainService;
|
||||||
import io.bitsquare.btc.WalletService;
|
import io.bitsquare.btc.WalletService;
|
||||||
import io.bitsquare.crypto.CryptoService;
|
import io.bitsquare.crypto.SignatureService;
|
||||||
import io.bitsquare.msg.MessageService;
|
import io.bitsquare.msg.MessageService;
|
||||||
import io.bitsquare.network.Peer;
|
import io.bitsquare.network.Peer;
|
||||||
import io.bitsquare.offer.Offer;
|
import io.bitsquare.offer.Offer;
|
||||||
|
@ -89,7 +89,7 @@ public class SellerTakesOfferProtocol {
|
||||||
private final MessageService messageService;
|
private final MessageService messageService;
|
||||||
private final WalletService walletService;
|
private final WalletService walletService;
|
||||||
private final BlockChainService blockChainService;
|
private final BlockChainService blockChainService;
|
||||||
private final CryptoService cryptoService;
|
private final SignatureService signatureService;
|
||||||
|
|
||||||
// derived
|
// derived
|
||||||
private final Offer offer;
|
private final Offer offer;
|
||||||
|
@ -136,14 +136,14 @@ public class SellerTakesOfferProtocol {
|
||||||
MessageService messageService,
|
MessageService messageService,
|
||||||
WalletService walletService,
|
WalletService walletService,
|
||||||
BlockChainService blockChainService,
|
BlockChainService blockChainService,
|
||||||
CryptoService cryptoService,
|
SignatureService signatureService,
|
||||||
User user) {
|
User user) {
|
||||||
this.trade = trade;
|
this.trade = trade;
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
this.messageService = messageService;
|
this.messageService = messageService;
|
||||||
this.walletService = walletService;
|
this.walletService = walletService;
|
||||||
this.blockChainService = blockChainService;
|
this.blockChainService = blockChainService;
|
||||||
this.cryptoService = cryptoService;
|
this.signatureService = signatureService;
|
||||||
|
|
||||||
offer = trade.getOffer();
|
offer = trade.getOffer();
|
||||||
tradeId = trade.getId();
|
tradeId = trade.getId();
|
||||||
|
@ -257,7 +257,7 @@ public class SellerTakesOfferProtocol {
|
||||||
state = State.CreateAndSignContract;
|
state = State.CreateAndSignContract;
|
||||||
CreateAndSignContract.run(this::onResultCreateAndSignContract,
|
CreateAndSignContract.run(this::onResultCreateAndSignContract,
|
||||||
this::onFault,
|
this::onFault,
|
||||||
cryptoService,
|
signatureService,
|
||||||
offer,
|
offer,
|
||||||
tradeAmount,
|
tradeAmount,
|
||||||
takeOfferFeeTxId,
|
takeOfferFeeTxId,
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
package io.bitsquare.trade.protocol.trade.taker.tasks;
|
package io.bitsquare.trade.protocol.trade.taker.tasks;
|
||||||
|
|
||||||
import io.bitsquare.bank.BankAccount;
|
import io.bitsquare.bank.BankAccount;
|
||||||
import io.bitsquare.crypto.CryptoService;
|
import io.bitsquare.crypto.SignatureService;
|
||||||
import io.bitsquare.offer.Offer;
|
import io.bitsquare.offer.Offer;
|
||||||
import io.bitsquare.trade.Contract;
|
import io.bitsquare.trade.Contract;
|
||||||
import io.bitsquare.util.Utilities;
|
import io.bitsquare.util.Utilities;
|
||||||
|
@ -37,7 +37,7 @@ public class CreateAndSignContract {
|
||||||
|
|
||||||
public static void run(ResultHandler resultHandler,
|
public static void run(ResultHandler resultHandler,
|
||||||
ExceptionHandler exceptionHandler,
|
ExceptionHandler exceptionHandler,
|
||||||
CryptoService cryptoService,
|
SignatureService signatureService,
|
||||||
Offer offer,
|
Offer offer,
|
||||||
Coin tradeAmount,
|
Coin tradeAmount,
|
||||||
String takeOfferFeeTxId,
|
String takeOfferFeeTxId,
|
||||||
|
@ -54,7 +54,7 @@ public class CreateAndSignContract {
|
||||||
peersBankAccount, bankAccount, peersMessagePublicKey, messagePublicKey);
|
peersBankAccount, bankAccount, peersMessagePublicKey, messagePublicKey);
|
||||||
|
|
||||||
String contractAsJson = Utilities.objectToJson(contract);
|
String contractAsJson = Utilities.objectToJson(contract);
|
||||||
String signature = cryptoService.signContract(registrationKey, contractAsJson);
|
String signature = signatureService.signContract(registrationKey, contractAsJson);
|
||||||
resultHandler.onResult(contract, contractAsJson, signature);
|
resultHandler.onResult(contract, contractAsJson, signature);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
log.error("Exception at sign contract " + t);
|
log.error("Exception at sign contract " + t);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue