mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 15:10:44 +01:00
Rename all appearances of squ to bsq
This commit is contained in:
parent
073302827b
commit
60597cec88
62 changed files with 509 additions and 512 deletions
|
@ -22,9 +22,9 @@ import io.bitsquare.app.AppModule;
|
|||
import io.bitsquare.app.AppOptionKeys;
|
||||
import io.bitsquare.btc.provider.fee.FeeService;
|
||||
import io.bitsquare.btc.provider.price.PriceFeedService;
|
||||
import io.bitsquare.btc.provider.squ.SquUtxoFeedService;
|
||||
import io.bitsquare.btc.provider.squ.BsqUtxoFeedService;
|
||||
import io.bitsquare.btc.wallet.BsqWalletService;
|
||||
import io.bitsquare.btc.wallet.BtcWalletService;
|
||||
import io.bitsquare.btc.wallet.SquWalletService;
|
||||
import io.bitsquare.btc.wallet.TradeWalletService;
|
||||
import io.bitsquare.btc.wallet.WalletsSetup;
|
||||
import io.bitsquare.http.HttpClient;
|
||||
|
@ -61,11 +61,11 @@ public class BitcoinModule extends AppModule {
|
|||
bind(AddressEntryList.class).in(Singleton.class);
|
||||
bind(WalletsSetup.class).in(Singleton.class);
|
||||
bind(BtcWalletService.class).in(Singleton.class);
|
||||
bind(SquWalletService.class).in(Singleton.class);
|
||||
bind(BsqWalletService.class).in(Singleton.class);
|
||||
bind(TradeWalletService.class).in(Singleton.class);
|
||||
|
||||
bind(HttpClient.class).in(Singleton.class);
|
||||
bind(SquUtxoFeedService.class).in(Singleton.class);
|
||||
bind(BsqUtxoFeedService.class).in(Singleton.class);
|
||||
bind(PriceFeedService.class).in(Singleton.class);
|
||||
bind(FeeService.class).in(Singleton.class);
|
||||
}
|
||||
|
|
|
@ -6,11 +6,11 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
public class SquUtxoFeedData {
|
||||
private static final Logger log = LoggerFactory.getLogger(SquUtxoFeedData.class);
|
||||
public class BsqUtxoFeedData {
|
||||
private static final Logger log = LoggerFactory.getLogger(BsqUtxoFeedData.class);
|
||||
private Set<UTXO> utxoSet;
|
||||
|
||||
public SquUtxoFeedData(Set<UTXO> utxoSet) {
|
||||
public BsqUtxoFeedData(Set<UTXO> utxoSet) {
|
||||
this.utxoSet = utxoSet;
|
||||
}
|
||||
|
|
@ -20,26 +20,26 @@ import java.util.Set;
|
|||
|
||||
import static org.bitcoinj.core.Utils.HEX;
|
||||
|
||||
public class SquUtxoFeedProvider extends HttpClientProvider {
|
||||
private static final Logger log = LoggerFactory.getLogger(SquUtxoFeedProvider.class);
|
||||
public class BsqUtxoFeedProvider extends HttpClientProvider {
|
||||
private static final Logger log = LoggerFactory.getLogger(BsqUtxoFeedProvider.class);
|
||||
|
||||
public SquUtxoFeedProvider(HttpClient httpClient, String baseUrl) {
|
||||
public BsqUtxoFeedProvider(HttpClient httpClient, String baseUrl) {
|
||||
super(httpClient, baseUrl, false);
|
||||
}
|
||||
|
||||
public Tuple2<Map<String, Long>, SquUtxoFeedData> getSquUtxo() throws IOException, HttpException {
|
||||
/* String json = httpClient.requestWithGET("getSquUtxo", "User-Agent", "Bitsquare/" + Version.VERSION + ", uid:" + httpClient.getUid());
|
||||
public Tuple2<Map<String, Long>, BsqUtxoFeedData> getBsqUtxo() throws IOException, HttpException {
|
||||
/* String json = httpClient.requestWithGET("getBsqUtxo", "User-Agent", "Bitsquare/" + Version.VERSION + ", uid:" + httpClient.getUid());
|
||||
LinkedTreeMap<String, Object> linkedTreeMap = new Gson().fromJson(json, LinkedTreeMap.class);
|
||||
Map<String, Long> tsMap = new HashMap<>();
|
||||
tsMap.put("getSquUtxoTs", ((Double) linkedTreeMap.get("getSquUtxoTs")).longValue());
|
||||
tsMap.put("getBsqUtxoTs", ((Double) linkedTreeMap.get("getBsqUtxoTs")).longValue());
|
||||
|
||||
LinkedTreeMap<String, Double> dataMap = (LinkedTreeMap<String, Double>) linkedTreeMap.get("data");
|
||||
// SquUtxoData squUtxoData = new SquUtxoData(dataMap.get("txFee").longValue(), dataMap.get("createOfferFee").longValue(), dataMap.get("takeOfferFee").longValue());
|
||||
// BsqUtxoData squUtxoData = new BsqUtxoData(dataMap.get("txFee").longValue(), dataMap.get("createOfferFee").longValue(), dataMap.get("takeOfferFee").longValue());
|
||||
*/
|
||||
|
||||
// mock
|
||||
Map<String, Long> tsMap = new HashMap<>();
|
||||
tsMap.put("getSquUtxoTs", 1L);
|
||||
tsMap.put("getBsqUtxoTs", 1L);
|
||||
|
||||
Set<UTXO> utxoSet = new HashSet<>();
|
||||
|
||||
|
@ -100,9 +100,9 @@ Sends 0.00 BTC and receives 0.00001 BTC, total value 0.00001 BTC.
|
|||
|
||||
//
|
||||
|
||||
SquUtxoFeedData squUtxoFeedData = new SquUtxoFeedData(utxoSet);
|
||||
BsqUtxoFeedData bsqUtxoFeedData = new BsqUtxoFeedData(utxoSet);
|
||||
|
||||
return new Tuple2<>(tsMap, squUtxoFeedData);
|
||||
return new Tuple2<>(tsMap, bsqUtxoFeedData);
|
||||
}
|
||||
|
||||
@Override
|
|
@ -9,23 +9,23 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
public class SquUtxoFeedRequest {
|
||||
private static final Logger log = LoggerFactory.getLogger(SquUtxoFeedRequest.class);
|
||||
public class BsqUtxoFeedRequest {
|
||||
private static final Logger log = LoggerFactory.getLogger(BsqUtxoFeedRequest.class);
|
||||
|
||||
private static final ListeningExecutorService executorService = Utilities.getListeningExecutorService("FeeRequest", 3, 5, 10 * 60);
|
||||
|
||||
public SquUtxoFeedRequest() {
|
||||
public BsqUtxoFeedRequest() {
|
||||
}
|
||||
|
||||
public SettableFuture<Tuple2<Map<String, Long>, SquUtxoFeedData>> getFees(SquUtxoFeedProvider provider) {
|
||||
final SettableFuture<Tuple2<Map<String, Long>, SquUtxoFeedData>> resultFuture = SettableFuture.create();
|
||||
ListenableFuture<Tuple2<Map<String, Long>, SquUtxoFeedData>> future = executorService.submit(() -> {
|
||||
Thread.currentThread().setName("SquUtxoRequest-" + provider.toString());
|
||||
return provider.getSquUtxo();
|
||||
public SettableFuture<Tuple2<Map<String, Long>, BsqUtxoFeedData>> getFees(BsqUtxoFeedProvider provider) {
|
||||
final SettableFuture<Tuple2<Map<String, Long>, BsqUtxoFeedData>> resultFuture = SettableFuture.create();
|
||||
ListenableFuture<Tuple2<Map<String, Long>, BsqUtxoFeedData>> future = executorService.submit(() -> {
|
||||
Thread.currentThread().setName("BsqUtxoRequest-" + provider.toString());
|
||||
return provider.getBsqUtxo();
|
||||
});
|
||||
|
||||
Futures.addCallback(future, new FutureCallback<Tuple2<Map<String, Long>, SquUtxoFeedData>>() {
|
||||
public void onSuccess(Tuple2<Map<String, Long>, SquUtxoFeedData> squUtxoData) {
|
||||
Futures.addCallback(future, new FutureCallback<Tuple2<Map<String, Long>, BsqUtxoFeedData>>() {
|
||||
public void onSuccess(Tuple2<Map<String, Long>, BsqUtxoFeedData> squUtxoData) {
|
||||
log.debug("Received squUtxo of {}\nfrom provider {}", squUtxoData, provider);
|
||||
resultFuture.set(squUtxoData);
|
||||
}
|
|
@ -39,11 +39,11 @@ import java.util.function.Consumer;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class SquUtxoFeedService {
|
||||
private static final Logger log = LoggerFactory.getLogger(SquUtxoFeedService.class);
|
||||
public class BsqUtxoFeedService {
|
||||
private static final Logger log = LoggerFactory.getLogger(BsqUtxoFeedService.class);
|
||||
|
||||
private final SquUtxoFeedProvider squUtxoFeedProvider;
|
||||
private SquUtxoFeedData data;
|
||||
private final BsqUtxoFeedProvider bsqUtxoFeedProvider;
|
||||
private BsqUtxoFeedData data;
|
||||
private Map<String, Long> timeStampMap;
|
||||
private long epochInSecondAtLastRequest;
|
||||
|
||||
|
@ -52,27 +52,27 @@ public class SquUtxoFeedService {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public SquUtxoFeedService(HttpClient httpClient,
|
||||
public BsqUtxoFeedService(HttpClient httpClient,
|
||||
ProvidersRepository providersRepository) {
|
||||
this.squUtxoFeedProvider = new SquUtxoFeedProvider(httpClient, providersRepository.getBaseUrl());
|
||||
this.bsqUtxoFeedProvider = new BsqUtxoFeedProvider(httpClient, providersRepository.getBaseUrl());
|
||||
}
|
||||
|
||||
public void onAllServicesInitialized() {
|
||||
requestSquUtxo(null, null);
|
||||
requestBsqUtxo(null, null);
|
||||
}
|
||||
|
||||
public void requestSquUtxo(@Nullable Consumer<Set<UTXO>> resultHandler, @Nullable FaultHandler faultHandler) {
|
||||
public void requestBsqUtxo(@Nullable Consumer<Set<UTXO>> resultHandler, @Nullable FaultHandler faultHandler) {
|
||||
//TODO add throttle
|
||||
Log.traceCall();
|
||||
SquUtxoFeedRequest squUtxoRequest = new SquUtxoFeedRequest();
|
||||
SettableFuture<Tuple2<Map<String, Long>, SquUtxoFeedData>> future = squUtxoRequest.getFees(squUtxoFeedProvider);
|
||||
Futures.addCallback(future, new FutureCallback<Tuple2<Map<String, Long>, SquUtxoFeedData>>() {
|
||||
BsqUtxoFeedRequest squUtxoRequest = new BsqUtxoFeedRequest();
|
||||
SettableFuture<Tuple2<Map<String, Long>, BsqUtxoFeedData>> future = squUtxoRequest.getFees(bsqUtxoFeedProvider);
|
||||
Futures.addCallback(future, new FutureCallback<Tuple2<Map<String, Long>, BsqUtxoFeedData>>() {
|
||||
@Override
|
||||
public void onSuccess(@Nullable Tuple2<Map<String, Long>, SquUtxoFeedData> result) {
|
||||
public void onSuccess(@Nullable Tuple2<Map<String, Long>, BsqUtxoFeedData> result) {
|
||||
UserThread.execute(() -> {
|
||||
checkNotNull(result, "Result must not be null at getFees");
|
||||
timeStampMap = result.first;
|
||||
epochInSecondAtLastRequest = timeStampMap.get("getSquUtxoTs");
|
||||
epochInSecondAtLastRequest = timeStampMap.get("getBsqUtxoTs");
|
||||
data = result.second;
|
||||
if (resultHandler != null)
|
||||
resultHandler.accept(data.getUtxoSet());
|
|
@ -36,7 +36,7 @@ import java.util.List;
|
|||
* possible. This means that the transaction is the most likely to get confirmed. Note that this means we may end up
|
||||
* "spending" more priority than would be required to get the transaction we are creating confirmed.
|
||||
*/
|
||||
public abstract class BsDefaultCoinSelector implements CoinSelector {
|
||||
public abstract class BitsquareDefaultCoinSelector implements CoinSelector {
|
||||
@Override
|
||||
public CoinSelection select(Coin target, List<TransactionOutput> candidates) {
|
||||
ArrayList<TransactionOutput> selected = new ArrayList<>();
|
|
@ -37,16 +37,16 @@ class BitsquareKeyChainFactory implements KeyChainFactory {
|
|||
|
||||
@Override
|
||||
public DeterministicKeyChain makeKeyChain(Protos.Key key, Protos.Key firstSubKey, DeterministicSeed seed, KeyCrypter crypter, boolean isMarried) {
|
||||
return useBitcoinDeterministicKeyChain ? new BtcDeterministicKeyChain(seed, crypter) : new SquDeterministicKeyChain(seed, crypter);
|
||||
return useBitcoinDeterministicKeyChain ? new BtcDeterministicKeyChain(seed, crypter) : new BsqDeterministicKeyChain(seed, crypter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeterministicKeyChain makeWatchingKeyChain(Protos.Key key, Protos.Key firstSubKey, DeterministicKey accountKey,
|
||||
boolean isFollowingKey, boolean isMarried) throws UnreadableWalletException {
|
||||
ImmutableList<ChildNumber> accountPath = useBitcoinDeterministicKeyChain ? BtcDeterministicKeyChain.BIP44_BTC_ACCOUNT_PATH : SquDeterministicKeyChain.BIP44_SQU_ACCOUNT_PATH;
|
||||
ImmutableList<ChildNumber> accountPath = useBitcoinDeterministicKeyChain ? BtcDeterministicKeyChain.BIP44_BTC_ACCOUNT_PATH : BsqDeterministicKeyChain.BIP44_BSQ_ACCOUNT_PATH;
|
||||
if (!accountKey.getPath().equals(accountPath))
|
||||
throw new UnreadableWalletException("Expecting account key but found key with path: " +
|
||||
HDUtils.formatPath(accountKey.getPath()));
|
||||
return useBitcoinDeterministicKeyChain ? new BtcDeterministicKeyChain(accountKey, isFollowingKey) : new SquDeterministicKeyChain(accountKey, isFollowingKey);
|
||||
return useBitcoinDeterministicKeyChain ? new BtcDeterministicKeyChain(accountKey, isFollowingKey) : new BsqDeterministicKeyChain(accountKey, isFollowingKey);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ class BitsquareKeyChainGroup extends KeyChainGroup {
|
|||
|
||||
@Override
|
||||
public void createAndActivateNewHDChain() {
|
||||
DeterministicKeyChain chain = useBitcoinDeterministicKeyChain ? new BtcDeterministicKeyChain(new SecureRandom()) : new SquDeterministicKeyChain(new SecureRandom());
|
||||
DeterministicKeyChain chain = useBitcoinDeterministicKeyChain ? new BtcDeterministicKeyChain(new SecureRandom()) : new BsqDeterministicKeyChain(new SecureRandom());
|
||||
chain.setLookaheadSize(lookaheadSize);
|
||||
addAndActivateHDChain(chain);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package io.bitsquare.btc.wallet;
|
||||
|
||||
import io.bitsquare.dao.blockchain.SquUTXO;
|
||||
import io.bitsquare.dao.blockchain.BsqUTXO;
|
||||
import org.bitcoinj.core.Transaction;
|
||||
import org.bitcoinj.core.TransactionConfidence;
|
||||
import org.bitcoinj.core.TransactionOutput;
|
||||
|
@ -35,22 +35,22 @@ import java.util.Set;
|
|||
* We use a specialized version of the CoinSelector based on the DefaultCoinSelector implementation.
|
||||
* We lookup for spendable outputs which matches our address of our address.
|
||||
*/
|
||||
class SquCoinSelector extends BsDefaultCoinSelector {
|
||||
private static final Logger log = LoggerFactory.getLogger(SquCoinSelector.class);
|
||||
class BsqCoinSelector extends BitsquareDefaultCoinSelector {
|
||||
private static final Logger log = LoggerFactory.getLogger(BsqCoinSelector.class);
|
||||
|
||||
private final boolean permitForeignPendingTx;
|
||||
|
||||
private Map<Script, Set<SquUTXO>> utxoSetByScriptMap = new HashMap<>();
|
||||
private Map<Script, Set<BsqUTXO>> utxoSetByScriptMap = new HashMap<>();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public SquCoinSelector(boolean permitForeignPendingTx) {
|
||||
public BsqCoinSelector(boolean permitForeignPendingTx) {
|
||||
this.permitForeignPendingTx = permitForeignPendingTx;
|
||||
}
|
||||
|
||||
public void setUtxoSet(Set<SquUTXO> utxoSet) {
|
||||
public void setUtxoSet(Set<BsqUTXO> utxoSet) {
|
||||
utxoSet.stream().forEach(utxo -> {
|
||||
Script script = utxo.getScript();
|
||||
if (!utxoSetByScriptMap.containsKey(script))
|
|
@ -28,37 +28,37 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.security.SecureRandom;
|
||||
|
||||
class SquDeterministicKeyChain extends DeterministicKeyChain {
|
||||
private static final Logger log = LoggerFactory.getLogger(SquDeterministicKeyChain.class);
|
||||
class BsqDeterministicKeyChain extends DeterministicKeyChain {
|
||||
private static final Logger log = LoggerFactory.getLogger(BsqDeterministicKeyChain.class);
|
||||
|
||||
// See https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki
|
||||
// https://github.com/satoshilabs/slips/blob/master/slip-0044.md
|
||||
// We use 139 (0x80000000) as coin_type for BSQ
|
||||
// TODO register once the token name is fix
|
||||
public static final ImmutableList<ChildNumber> BIP44_SQU_ACCOUNT_PATH = ImmutableList.of(
|
||||
// TODO register
|
||||
public static final ImmutableList<ChildNumber> BIP44_BSQ_ACCOUNT_PATH = ImmutableList.of(
|
||||
new ChildNumber(44, true),
|
||||
new ChildNumber(139, true),
|
||||
ChildNumber.ZERO_HARDENED);
|
||||
|
||||
public SquDeterministicKeyChain(SecureRandom random) {
|
||||
public BsqDeterministicKeyChain(SecureRandom random) {
|
||||
super(random);
|
||||
}
|
||||
|
||||
public SquDeterministicKeyChain(DeterministicKey accountKey, boolean isFollowingKey) {
|
||||
public BsqDeterministicKeyChain(DeterministicKey accountKey, boolean isFollowingKey) {
|
||||
super(accountKey, isFollowingKey);
|
||||
}
|
||||
|
||||
public SquDeterministicKeyChain(DeterministicSeed seed, KeyCrypter crypter) {
|
||||
public BsqDeterministicKeyChain(DeterministicSeed seed, KeyCrypter crypter) {
|
||||
super(seed, crypter);
|
||||
}
|
||||
|
||||
public SquDeterministicKeyChain(DeterministicSeed seed) {
|
||||
public BsqDeterministicKeyChain(DeterministicSeed seed) {
|
||||
super(seed);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ImmutableList<ChildNumber> getAccountPath() {
|
||||
return BIP44_SQU_ACCOUNT_PATH;
|
||||
return BIP44_BSQ_ACCOUNT_PATH;
|
||||
}
|
||||
|
||||
}
|
|
@ -24,8 +24,8 @@ import org.bitcoinj.core.UTXO;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class SquUtxoTransactionOutput extends TransactionOutput {
|
||||
private static final Logger log = LoggerFactory.getLogger(SquUtxoTransactionOutput.class);
|
||||
public class BsqUtxoTransactionOutput extends TransactionOutput {
|
||||
private static final Logger log = LoggerFactory.getLogger(BsqUtxoTransactionOutput.class);
|
||||
private UTXO output;
|
||||
private int chainHeight;
|
||||
|
||||
|
@ -35,7 +35,7 @@ public class SquUtxoTransactionOutput extends TransactionOutput {
|
|||
* @param params The network parameters.
|
||||
* @param output The stored output (free standing).
|
||||
*/
|
||||
public SquUtxoTransactionOutput(NetworkParameters params, UTXO output, int chainHeight) {
|
||||
public BsqUtxoTransactionOutput(NetworkParameters params, UTXO output, int chainHeight) {
|
||||
super(params, null, output.getValue(), output.getScript().getProgram());
|
||||
this.output = output;
|
||||
this.chainHeight = chainHeight;
|
|
@ -30,10 +30,10 @@ import java.util.Set;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
public class SquWallet extends Wallet {
|
||||
private static final Logger log = LoggerFactory.getLogger(SquWallet.class);
|
||||
public class BsqWallet extends Wallet {
|
||||
private static final Logger log = LoggerFactory.getLogger(BsqWallet.class);
|
||||
|
||||
public SquWallet(NetworkParameters params, KeyChainGroup keyChainGroup) {
|
||||
public BsqWallet(NetworkParameters params, KeyChainGroup keyChainGroup) {
|
||||
super(params, keyChainGroup);
|
||||
}
|
||||
|
|
@ -25,8 +25,8 @@ import io.bitsquare.btc.exceptions.WalletException;
|
|||
import io.bitsquare.btc.provider.fee.FeeService;
|
||||
import io.bitsquare.common.handlers.ErrorMessageHandler;
|
||||
import io.bitsquare.common.handlers.ResultHandler;
|
||||
import io.bitsquare.dao.blockchain.SquBlockchainManager;
|
||||
import io.bitsquare.dao.blockchain.SquUTXO;
|
||||
import io.bitsquare.dao.blockchain.BsqBlockchainManager;
|
||||
import io.bitsquare.dao.blockchain.BsqUTXO;
|
||||
import io.bitsquare.user.Preferences;
|
||||
import org.bitcoinj.core.*;
|
||||
import org.bitcoinj.script.Script;
|
||||
|
@ -48,11 +48,11 @@ import static com.google.common.base.Preconditions.checkArgument;
|
|||
* WalletService handles all non trade specific wallet and bitcoin related services.
|
||||
* It startup the wallet app kit and initialized the wallet.
|
||||
*/
|
||||
public class SquWalletService extends WalletService {
|
||||
private static final Logger log = LoggerFactory.getLogger(SquWalletService.class);
|
||||
public class BsqWalletService extends WalletService {
|
||||
private static final Logger log = LoggerFactory.getLogger(BsqWalletService.class);
|
||||
|
||||
private final SquBlockchainManager squBlockchainManager;
|
||||
private final SquCoinSelector squCoinSelector;
|
||||
private final BsqBlockchainManager bsqBlockchainManager;
|
||||
private final BsqCoinSelector bsqCoinSelector;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -60,19 +60,19 @@ public class SquWalletService extends WalletService {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public SquWalletService(WalletsSetup walletsSetup,
|
||||
SquBlockchainManager squBlockchainManager,
|
||||
public BsqWalletService(WalletsSetup walletsSetup,
|
||||
BsqBlockchainManager bsqBlockchainManager,
|
||||
Preferences preferences,
|
||||
FeeService feeService) {
|
||||
super(walletsSetup,
|
||||
preferences,
|
||||
feeService);
|
||||
this.squBlockchainManager = squBlockchainManager;
|
||||
this.squCoinSelector = new SquCoinSelector(true);
|
||||
this.bsqBlockchainManager = bsqBlockchainManager;
|
||||
this.bsqCoinSelector = new BsqCoinSelector(true);
|
||||
|
||||
walletsSetup.addSetupCompletedHandler(() -> {
|
||||
wallet = walletsSetup.getSquWallet();
|
||||
wallet.setCoinSelector(squCoinSelector);
|
||||
wallet = walletsSetup.getBsqWallet();
|
||||
wallet.setCoinSelector(bsqCoinSelector);
|
||||
|
||||
wallet.addEventListener(new BitsquareWalletEventListener());
|
||||
wallet.addEventListener(new AbstractWalletEventListener() {
|
||||
|
@ -146,13 +146,13 @@ public class SquWalletService extends WalletService {
|
|||
// UTXO
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
public void requestSquUtxo(@Nullable ResultHandler resultHandler, @Nullable ErrorMessageHandler errorMessageHandler) {
|
||||
if (squBlockchainManager.isUtxoAvailable()) {
|
||||
applyUtxoSetToUTXOProvider(squBlockchainManager.getUtxoByTxIdMap());
|
||||
public void requestBsqUtxo(@Nullable ResultHandler resultHandler, @Nullable ErrorMessageHandler errorMessageHandler) {
|
||||
if (bsqBlockchainManager.isUtxoAvailable()) {
|
||||
applyUtxoSetToUTXOProvider(bsqBlockchainManager.getUtxoByTxIdMap());
|
||||
if (resultHandler != null)
|
||||
resultHandler.handleResult();
|
||||
} else {
|
||||
squBlockchainManager.addUtxoListener(utxoByTxIdMap -> {
|
||||
bsqBlockchainManager.addUtxoListener(utxoByTxIdMap -> {
|
||||
applyUtxoSetToUTXOProvider(utxoByTxIdMap);
|
||||
if (resultHandler != null)
|
||||
resultHandler.handleResult();
|
||||
|
@ -160,12 +160,12 @@ public class SquWalletService extends WalletService {
|
|||
}
|
||||
}
|
||||
|
||||
private void applyUtxoSetToUTXOProvider(Map<String, Map<Integer, SquUTXO>> utxoByTxIdMap) {
|
||||
Set<SquUTXO> utxoSet = new HashSet<>();
|
||||
private void applyUtxoSetToUTXOProvider(Map<String, Map<Integer, BsqUTXO>> utxoByTxIdMap) {
|
||||
Set<BsqUTXO> utxoSet = new HashSet<>();
|
||||
utxoByTxIdMap.entrySet().stream()
|
||||
.forEach(e -> e.getValue().entrySet().stream()
|
||||
.forEach(u -> utxoSet.add(u.getValue())));
|
||||
squCoinSelector.setUtxoSet(utxoSet);
|
||||
bsqCoinSelector.setUtxoSet(utxoSet);
|
||||
}
|
||||
|
||||
|
||||
|
@ -246,9 +246,9 @@ public class SquWalletService extends WalletService {
|
|||
public Transaction getPreparedBurnFeeTx(Coin fee) throws WalletException, TransactionVerificationException,
|
||||
InsufficientMoneyException, ChangeBelowDustException {
|
||||
Transaction tx = new Transaction(params);
|
||||
CoinSelection coinSelection = squCoinSelector.select(fee, getTransactionOutputsFromUtxoProvider());
|
||||
CoinSelection coinSelection = bsqCoinSelector.select(fee, getTransactionOutputsFromUtxoProvider());
|
||||
coinSelection.gathered.stream().forEach(tx::addInput);
|
||||
Coin change = squCoinSelector.getChange(fee, coinSelection);
|
||||
Coin change = bsqCoinSelector.getChange(fee, coinSelection);
|
||||
if (change.isPositive())
|
||||
tx.addOutput(change, getUnusedAddress());
|
||||
|
|
@ -29,7 +29,7 @@ import java.util.Set;
|
|||
* We use a specialized version of the CoinSelector based on the DefaultCoinSelector implementation.
|
||||
* We lookup for spendable outputs which matches any of our addresses.
|
||||
*/
|
||||
class BtcCoinSelector extends BsDefaultCoinSelector {
|
||||
class BtcCoinSelector extends BitsquareDefaultCoinSelector {
|
||||
private static final Logger log = LoggerFactory.getLogger(BtcCoinSelector.class);
|
||||
|
||||
private NetworkParameters params;
|
||||
|
|
|
@ -126,9 +126,9 @@ public class BtcWalletService extends WalletService {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
public Transaction completePreparedSendSquTx(Transaction preparedSquTx, boolean isSendTx) throws
|
||||
public Transaction completePreparedSendBsqTx(Transaction preparedBsqTx, boolean isSendTx) throws
|
||||
TransactionVerificationException, WalletException, InsufficientFundsException, InsufficientMoneyException {
|
||||
// preparedSquTx has following structure:
|
||||
// preparedBsqTx has following structure:
|
||||
// inputs [1-n] BSQ inputs
|
||||
// outputs [0-1] BSQ receivers output
|
||||
// outputs [0-1] BSQ change output
|
||||
|
@ -140,13 +140,13 @@ public class BtcWalletService extends WalletService {
|
|||
// outputs [0-1] BSQ change output
|
||||
// outputs [0-1] BTC change output
|
||||
// mining fee: BTC mining fee
|
||||
return completePreparedSquTx(preparedSquTx, isSendTx, null);
|
||||
return completePreparedBsqTx(preparedBsqTx, isSendTx, null);
|
||||
}
|
||||
|
||||
public Transaction completePreparedSquTx(Transaction preparedSquTx, boolean isSendTx, @Nullable byte[] opReturnData) throws
|
||||
public Transaction completePreparedBsqTx(Transaction preparedBsqTx, boolean isSendTx, @Nullable byte[] opReturnData) throws
|
||||
TransactionVerificationException, WalletException, InsufficientFundsException, InsufficientMoneyException {
|
||||
|
||||
// preparedSquTx has following structure:
|
||||
// preparedBsqTx has following structure:
|
||||
// inputs [1-n] BSQ inputs
|
||||
// outputs [0-1] BSQ receivers output
|
||||
// outputs [0-1] BSQ change output
|
||||
|
@ -181,9 +181,9 @@ public class BtcWalletService extends WalletService {
|
|||
checkNotNull(changeAddress, "changeAddress must not be null");
|
||||
|
||||
final BtcCoinSelector coinSelector = new BtcCoinSelector(params, walletsSetup.getAddressesByContext(AddressEntry.Context.AVAILABLE));
|
||||
final List<TransactionInput> preparedSquTxInputs = preparedSquTx.getInputs();
|
||||
final List<TransactionOutput> preparedSquTxOutputs = preparedSquTx.getOutputs();
|
||||
int numInputs = preparedSquTxInputs.size() + 1; // We add 1 for the BTC fee input
|
||||
final List<TransactionInput> preparedBsqTxInputs = preparedBsqTx.getInputs();
|
||||
final List<TransactionOutput> preparedBsqTxOutputs = preparedBsqTx.getOutputs();
|
||||
int numInputs = preparedBsqTxInputs.size() + 1; // We add 1 for the BTC fee input
|
||||
Transaction resultTx = null;
|
||||
boolean isFeeInTolerance;
|
||||
do {
|
||||
|
@ -195,13 +195,13 @@ public class BtcWalletService extends WalletService {
|
|||
}
|
||||
|
||||
Transaction tx = new Transaction(params);
|
||||
preparedSquTxInputs.stream().forEach(tx::addInput);
|
||||
preparedBsqTxInputs.stream().forEach(tx::addInput);
|
||||
|
||||
if (forcedChangeValue.isZero()) {
|
||||
preparedSquTxOutputs.stream().forEach(tx::addOutput);
|
||||
preparedBsqTxOutputs.stream().forEach(tx::addOutput);
|
||||
} else {
|
||||
//TODO test that case
|
||||
checkArgument(preparedSquTxOutputs.size() == 0, "preparedSquTxOutputs.size must be null in that code branch");
|
||||
checkArgument(preparedBsqTxOutputs.size() == 0, "preparedBsqTxOutputs.size must be null in that code branch");
|
||||
tx.addOutput(forcedChangeValue, changeAddress);
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ public class BtcWalletService extends WalletService {
|
|||
while (forcedChangeValue.isPositive() || isFeeInTolerance);
|
||||
|
||||
// Sign all BTC inputs
|
||||
for (int i = preparedSquTxInputs.size(); i < resultTx.getInputs().size(); i++) {
|
||||
for (int i = preparedBsqTxInputs.size(); i < resultTx.getInputs().size(); i++) {
|
||||
TransactionInput txIn = resultTx.getInputs().get(i);
|
||||
checkArgument(txIn.getConnectedOutput() != null && txIn.getConnectedOutput().isMine(wallet),
|
||||
"txIn.getConnectedOutput() is not in our wallet. That must not happen.");
|
||||
|
|
|
@ -62,15 +62,15 @@ public class WalletConfig extends AbstractIdleService {
|
|||
private static final Logger log = LoggerFactory.getLogger(WalletConfig.class);
|
||||
|
||||
private final String btcWalletFilePrefix;
|
||||
private final String squWalletFilePrefix;
|
||||
private final String bsqWalletFilePrefix;
|
||||
private volatile Wallet vBtcWallet;
|
||||
private volatile Wallet vSquWallet;
|
||||
private volatile Wallet vBsqWallet;
|
||||
private volatile File vBtcWalletFile;
|
||||
private volatile File vSquWalletFile;
|
||||
private volatile File vBsqWalletFile;
|
||||
@Nullable
|
||||
private DeterministicSeed seed;
|
||||
private int btcWalletLookaheadSize = -1;
|
||||
private int squWalletLookaheadSize = -1;
|
||||
private int bsqWalletLookaheadSize = -1;
|
||||
|
||||
private final NetworkParameters params;
|
||||
private volatile BlockChain vChain;
|
||||
|
@ -94,17 +94,14 @@ public class WalletConfig extends AbstractIdleService {
|
|||
private double bloomFilterFPRate = -1;
|
||||
private Socks5Proxy socks5Proxy;
|
||||
|
||||
/**
|
||||
* Creates a new WalletAppKitBitSquare, with a newly created {@link Context}. Files will be stored in the given directory.
|
||||
*/
|
||||
public WalletConfig(NetworkParameters params, Socks5Proxy socks5Proxy,
|
||||
File directory, String btcWalletFilePrefix,
|
||||
String squWalletFilePrefix) {
|
||||
String bsqWalletFilePrefix) {
|
||||
this.context = new Context(params);
|
||||
this.params = checkNotNull(context.getParams());
|
||||
this.directory = checkNotNull(directory);
|
||||
this.btcWalletFilePrefix = checkNotNull(btcWalletFilePrefix);
|
||||
this.squWalletFilePrefix = squWalletFilePrefix;
|
||||
this.bsqWalletFilePrefix = bsqWalletFilePrefix;
|
||||
this.socks5Proxy = socks5Proxy;
|
||||
|
||||
if (!Utils.isAndroidRuntime()) {
|
||||
|
@ -119,17 +116,17 @@ public class WalletConfig extends AbstractIdleService {
|
|||
// This is called when we load an existing wallet
|
||||
// We have already the chain here so we can use this to distinguish.
|
||||
List<DeterministicKeyChain> deterministicKeyChains = keyChainGroup.getDeterministicKeyChains();
|
||||
if (!deterministicKeyChains.isEmpty() && deterministicKeyChains.get(0) instanceof SquDeterministicKeyChain)
|
||||
return new SquWallet(params, keyChainGroup);
|
||||
if (!deterministicKeyChains.isEmpty() && deterministicKeyChains.get(0) instanceof BsqDeterministicKeyChain)
|
||||
return new BsqWallet(params, keyChainGroup);
|
||||
else
|
||||
return new Wallet(params, keyChainGroup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Wallet create(NetworkParameters params, KeyChainGroup keyChainGroup, boolean isSquWallet) {
|
||||
public Wallet create(NetworkParameters params, KeyChainGroup keyChainGroup, boolean isBsqWallet) {
|
||||
// This is called at first startup when we create the wallet
|
||||
if (isSquWallet)
|
||||
return new SquWallet(params, keyChainGroup);
|
||||
if (isBsqWallet)
|
||||
return new BsqWallet(params, keyChainGroup);
|
||||
else
|
||||
return new Wallet(params, keyChainGroup);
|
||||
}
|
||||
|
@ -139,7 +136,7 @@ public class WalletConfig extends AbstractIdleService {
|
|||
public interface BitsquareWalletFactory extends WalletProtobufSerializer.WalletFactory {
|
||||
Wallet create(NetworkParameters params, KeyChainGroup keyChainGroup);
|
||||
|
||||
Wallet create(NetworkParameters params, KeyChainGroup keyChainGroup, boolean isSquWallet);
|
||||
Wallet create(NetworkParameters params, KeyChainGroup keyChainGroup, boolean isBsqWallet);
|
||||
}
|
||||
|
||||
public Socks5Proxy getProxy() {
|
||||
|
@ -302,8 +299,8 @@ public class WalletConfig extends AbstractIdleService {
|
|||
return this;
|
||||
}
|
||||
|
||||
public WalletConfig setSquWalletLookaheadSize(int lookaheadSize) {
|
||||
this.squWalletLookaheadSize = lookaheadSize;
|
||||
public WalletConfig setBsqWalletLookaheadSize(int lookaheadSize) {
|
||||
this.bsqWalletLookaheadSize = lookaheadSize;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -381,12 +378,12 @@ public class WalletConfig extends AbstractIdleService {
|
|||
vBtcWallet = createOrLoadWallet(vBtcWalletFile, shouldReplayWallet, seed, keyChainGroup, false);
|
||||
|
||||
// BSQ walelt
|
||||
vSquWalletFile = new File(directory, squWalletFilePrefix + ".wallet");
|
||||
vBsqWalletFile = new File(directory, bsqWalletFilePrefix + ".wallet");
|
||||
if (seed != null)
|
||||
keyChainGroup = new BitsquareKeyChainGroup(params, new SquDeterministicKeyChain(seed), false, squWalletLookaheadSize);
|
||||
keyChainGroup = new BitsquareKeyChainGroup(params, new BsqDeterministicKeyChain(seed), false, bsqWalletLookaheadSize);
|
||||
else
|
||||
keyChainGroup = new BitsquareKeyChainGroup(params, new SquDeterministicKeyChain(vBtcWallet.getKeyChainSeed()), false, squWalletLookaheadSize);
|
||||
vSquWallet = createOrLoadWallet(vSquWalletFile, shouldReplayWallet, seed, keyChainGroup, true);
|
||||
keyChainGroup = new BitsquareKeyChainGroup(params, new BsqDeterministicKeyChain(vBtcWallet.getKeyChainSeed()), false, bsqWalletLookaheadSize);
|
||||
vBsqWallet = createOrLoadWallet(vBsqWalletFile, shouldReplayWallet, seed, keyChainGroup, true);
|
||||
|
||||
// Initiate Bitcoin network objects (block store, blockchain and peer group)
|
||||
vStore = provideBlockStore(chainFile);
|
||||
|
@ -444,9 +441,9 @@ public class WalletConfig extends AbstractIdleService {
|
|||
vPeerGroup.addPeerDiscovery(discovery != null ? discovery : new DnsDiscovery(params));
|
||||
}
|
||||
vChain.addWallet(vBtcWallet);
|
||||
vChain.addWallet(vSquWallet);
|
||||
vChain.addWallet(vBsqWallet);
|
||||
vPeerGroup.addWallet(vBtcWallet);
|
||||
vPeerGroup.addWallet(vSquWallet);
|
||||
vPeerGroup.addWallet(vBsqWallet);
|
||||
onSetupCompleted();
|
||||
|
||||
if (blockingStartup) {
|
||||
|
@ -479,7 +476,7 @@ public class WalletConfig extends AbstractIdleService {
|
|||
}
|
||||
|
||||
private Wallet createOrLoadWallet(File walletFile, boolean shouldReplayWallet, @Nullable DeterministicSeed seed,
|
||||
BitsquareKeyChainGroup keyChainGroup, boolean isSquWallet)
|
||||
BitsquareKeyChainGroup keyChainGroup, boolean isBsqWallet)
|
||||
throws Exception {
|
||||
Wallet wallet;
|
||||
|
||||
|
@ -489,7 +486,7 @@ public class WalletConfig extends AbstractIdleService {
|
|||
if (walletFile.exists()) {
|
||||
wallet = loadWallet(walletFile, shouldReplayWallet, keyChainGroup.isUseBitcoinDeterministicKeyChain());
|
||||
} else {
|
||||
wallet = createWallet(keyChainGroup, isSquWallet);
|
||||
wallet = createWallet(keyChainGroup, isBsqWallet);
|
||||
wallet.freshReceiveKey();
|
||||
wallet.saveToFile(walletFile);
|
||||
}
|
||||
|
@ -522,9 +519,9 @@ public class WalletConfig extends AbstractIdleService {
|
|||
return wallet;
|
||||
}
|
||||
|
||||
private Wallet createWallet(BitsquareKeyChainGroup keyChainGroup, boolean isSquWallet) {
|
||||
private Wallet createWallet(BitsquareKeyChainGroup keyChainGroup, boolean isBsqWallet) {
|
||||
checkNotNull(walletFactory, "walletFactory must not be null");
|
||||
return walletFactory.create(params, keyChainGroup, isSquWallet);
|
||||
return walletFactory.create(params, keyChainGroup, isBsqWallet);
|
||||
}
|
||||
|
||||
private void maybeMoveOldWalletOutOfTheWay(File walletFile, DeterministicSeed restoreFromSeed) {
|
||||
|
@ -565,12 +562,12 @@ public class WalletConfig extends AbstractIdleService {
|
|||
Context.propagate(context);
|
||||
vPeerGroup.stop();
|
||||
vBtcWallet.saveToFile(vBtcWalletFile);
|
||||
vSquWallet.saveToFile(vSquWalletFile);
|
||||
vBsqWallet.saveToFile(vBsqWalletFile);
|
||||
vStore.close();
|
||||
|
||||
vPeerGroup = null;
|
||||
vBtcWallet = null;
|
||||
vSquWallet = null;
|
||||
vBsqWallet = null;
|
||||
vStore = null;
|
||||
vChain = null;
|
||||
} catch (BlockStoreException e) {
|
||||
|
@ -597,9 +594,9 @@ public class WalletConfig extends AbstractIdleService {
|
|||
return vBtcWallet;
|
||||
}
|
||||
|
||||
public Wallet getSquWallet() {
|
||||
public Wallet getBsqWallet() {
|
||||
checkState(state() == State.STARTING || state() == State.RUNNING, "Cannot call until startup is complete");
|
||||
return vSquWallet;
|
||||
return vBsqWallet;
|
||||
}
|
||||
|
||||
public PeerGroup peerGroup() {
|
||||
|
|
|
@ -36,7 +36,7 @@ public class WalletsManager {
|
|||
|
||||
private final BtcWalletService btcWalletService;
|
||||
private final TradeWalletService tradeWalletService;
|
||||
private final SquWalletService squWalletService;
|
||||
private final BsqWalletService bsqWalletService;
|
||||
private final WalletsSetup walletsSetup;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -44,21 +44,21 @@ public class WalletsManager {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public WalletsManager(BtcWalletService btcWalletService, TradeWalletService tradeWalletService, SquWalletService squWalletService, WalletsSetup walletsSetup) {
|
||||
public WalletsManager(BtcWalletService btcWalletService, TradeWalletService tradeWalletService, BsqWalletService bsqWalletService, WalletsSetup walletsSetup) {
|
||||
this.btcWalletService = btcWalletService;
|
||||
this.tradeWalletService = tradeWalletService;
|
||||
this.squWalletService = squWalletService;
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
this.walletsSetup = walletsSetup;
|
||||
}
|
||||
|
||||
public void decryptWallets(KeyParameter aesKey) {
|
||||
btcWalletService.decryptWallet(aesKey);
|
||||
squWalletService.decryptWallet(aesKey);
|
||||
bsqWalletService.decryptWallet(aesKey);
|
||||
tradeWalletService.setAesKey(null);
|
||||
}
|
||||
|
||||
public void encryptWallets(KeyCrypterScrypt keyCrypterScrypt, KeyParameter aesKey) {
|
||||
squWalletService.encryptWallet(keyCrypterScrypt, aesKey);
|
||||
bsqWalletService.encryptWallet(keyCrypterScrypt, aesKey);
|
||||
btcWalletService.encryptWallet(keyCrypterScrypt, aesKey);
|
||||
|
||||
// we save the key for the trade wallet as we don't require passwords here
|
||||
|
@ -69,7 +69,7 @@ public class WalletsManager {
|
|||
return "BTC Wallet:\n" +
|
||||
btcWalletService.getWalletAsString(includePrivKeys) +
|
||||
"\n\nBSQ Wallet:\n" +
|
||||
squWalletService.getWalletAsString(includePrivKeys);
|
||||
bsqWalletService.getWalletAsString(includePrivKeys);
|
||||
}
|
||||
|
||||
public void restoreSeedWords(@Nullable DeterministicSeed seed, ResultHandler resultHandler, ExceptionHandler exceptionHandler) {
|
||||
|
@ -85,11 +85,11 @@ public class WalletsManager {
|
|||
}
|
||||
|
||||
public boolean areWalletsEncrypted() {
|
||||
return btcWalletService.isEncrypted() && squWalletService.isEncrypted();
|
||||
return btcWalletService.isEncrypted() && bsqWalletService.isEncrypted();
|
||||
}
|
||||
|
||||
public boolean areWalletsAvailable() {
|
||||
return btcWalletService.isWalletReady() && squWalletService.isWalletReady();
|
||||
return btcWalletService.isWalletReady() && bsqWalletService.isWalletReady();
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,13 +110,13 @@ public class WalletsManager {
|
|||
|
||||
public boolean hasPositiveBalance() {
|
||||
return btcWalletService.getBalance(Wallet.BalanceType.AVAILABLE)
|
||||
.add(squWalletService.getBalance(Wallet.BalanceType.AVAILABLE))
|
||||
.add(bsqWalletService.getBalance(Wallet.BalanceType.AVAILABLE))
|
||||
.isPositive();
|
||||
}
|
||||
|
||||
public void setAesKey(KeyParameter aesKey) {
|
||||
btcWalletService.setAesKey(aesKey);
|
||||
squWalletService.setAesKey(aesKey);
|
||||
bsqWalletService.setAesKey(aesKey);
|
||||
tradeWalletService.setAesKey(aesKey);
|
||||
}
|
||||
|
||||
|
|
|
@ -77,9 +77,9 @@ public class WalletsSetup {
|
|||
private final int socks5DiscoverMode;
|
||||
private WalletConfig walletConfig;
|
||||
private Wallet btcWallet;
|
||||
private Wallet squWallet;
|
||||
private final String walletFileName = "Bitsquare";
|
||||
private final String tokenWalletFileName = "BSQ";
|
||||
private Wallet bsqWallet;
|
||||
private final String walletFileName = "Bitsquare_BTC";
|
||||
private final String bsqWalletFileName = "Bitsquare_BSQ";
|
||||
private final Long bloomFilterTweak;
|
||||
private KeyParameter aesKey;
|
||||
private final Storage<Long> storage;
|
||||
|
@ -160,16 +160,16 @@ public class WalletsSetup {
|
|||
log.debug("Use socks5Proxy for bitcoinj: " + socks5Proxy);
|
||||
|
||||
// If seed is non-null it means we are restoring from backup.
|
||||
walletConfig = new WalletConfig(params, socks5Proxy, walletDir, walletFileName, tokenWalletFileName) {
|
||||
walletConfig = new WalletConfig(params, socks5Proxy, walletDir, walletFileName, bsqWalletFileName) {
|
||||
@Override
|
||||
protected void onSetupCompleted() {
|
||||
btcWallet = walletConfig.getBtcWallet();
|
||||
squWallet = walletConfig.getSquWallet();
|
||||
bsqWallet = walletConfig.getBsqWallet();
|
||||
|
||||
// Don't make the user wait for confirmations for now, as the intention is they're sending it
|
||||
// their own money!
|
||||
btcWallet.allowSpendingUnconfirmedTransactions();
|
||||
squWallet.allowSpendingUnconfirmedTransactions();
|
||||
bsqWallet.allowSpendingUnconfirmedTransactions();
|
||||
|
||||
if (params != RegTestParams.get())
|
||||
walletConfig.peerGroup().setMaxConnections(11);
|
||||
|
@ -246,7 +246,7 @@ public class WalletsSetup {
|
|||
// never need to update a bloom filter, which would weaken privacy.
|
||||
// As we use 2 wallets (BTC, BSQ) we generate 1333 + 266 keys in total.
|
||||
walletConfig.setBtcWalletLookaheadSize(500);
|
||||
walletConfig.setSquWalletLookaheadSize(100);
|
||||
walletConfig.setBsqWalletLookaheadSize(100);
|
||||
|
||||
// Calculation is derived from: https://www.reddit.com/r/Bitcoin/comments/2vrx6n/privacy_in_bitcoinj_android_wallet_multibit_hive/coknjuz
|
||||
// No. of false positives (56M keys in the blockchain):
|
||||
|
@ -388,7 +388,7 @@ public class WalletsSetup {
|
|||
|
||||
void backupWallets() {
|
||||
FileUtil.rollingBackup(walletDir, walletFileName + ".wallet", 20);
|
||||
FileUtil.rollingBackup(walletDir, tokenWalletFileName + ".wallet", 20);
|
||||
FileUtil.rollingBackup(walletDir, bsqWalletFileName + ".wallet", 20);
|
||||
}
|
||||
|
||||
void clearBackups() {
|
||||
|
@ -408,8 +408,8 @@ public class WalletsSetup {
|
|||
return btcWallet;
|
||||
}
|
||||
|
||||
public Wallet getSquWallet() {
|
||||
return squWallet;
|
||||
public Wallet getBsqWallet() {
|
||||
return bsqWallet;
|
||||
}
|
||||
|
||||
public NetworkParameters getParams() {
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
package io.bitsquare.dao;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.btc.provider.squ.SquUtxoFeedService;
|
||||
import io.bitsquare.btc.wallet.SquWalletService;
|
||||
import io.bitsquare.dao.blockchain.SquBlockchainException;
|
||||
import io.bitsquare.dao.blockchain.SquBlockchainManager;
|
||||
import io.bitsquare.btc.provider.squ.BsqUtxoFeedService;
|
||||
import io.bitsquare.btc.wallet.BsqWalletService;
|
||||
import io.bitsquare.dao.blockchain.BsqBlockchainException;
|
||||
import io.bitsquare.dao.blockchain.BsqBlockchainManager;
|
||||
import io.bitsquare.dao.compensation.CompensationRequestManager;
|
||||
import io.bitsquare.dao.vote.VotingManager;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -30,10 +30,10 @@ import org.slf4j.LoggerFactory;
|
|||
public class DaoManager {
|
||||
private static final Logger log = LoggerFactory.getLogger(DaoManager.class);
|
||||
|
||||
private final SquBlockchainManager squBlockchainManager;
|
||||
private final SquWalletService squWalletService;
|
||||
private final BsqBlockchainManager bsqBlockchainManager;
|
||||
private final BsqWalletService bsqWalletService;
|
||||
private final DaoPeriodService daoPeriodService;
|
||||
private final SquUtxoFeedService squUtxoFeedService;
|
||||
private final BsqUtxoFeedService bsqUtxoFeedService;
|
||||
private final VotingManager voteManager;
|
||||
private final CompensationRequestManager compensationRequestManager;
|
||||
|
||||
|
@ -42,26 +42,26 @@ public class DaoManager {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public DaoManager(SquBlockchainManager squBlockchainManager,
|
||||
SquWalletService squWalletService,
|
||||
public DaoManager(BsqBlockchainManager bsqBlockchainManager,
|
||||
BsqWalletService bsqWalletService,
|
||||
DaoPeriodService daoPeriodService,
|
||||
SquUtxoFeedService squUtxoFeedService,
|
||||
BsqUtxoFeedService bsqUtxoFeedService,
|
||||
VotingManager voteManager,
|
||||
CompensationRequestManager compensationRequestManager) {
|
||||
this.squBlockchainManager = squBlockchainManager;
|
||||
this.squWalletService = squWalletService;
|
||||
this.bsqBlockchainManager = bsqBlockchainManager;
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
this.daoPeriodService = daoPeriodService;
|
||||
this.squUtxoFeedService = squUtxoFeedService;
|
||||
this.bsqUtxoFeedService = bsqUtxoFeedService;
|
||||
this.voteManager = voteManager;
|
||||
this.compensationRequestManager = compensationRequestManager;
|
||||
}
|
||||
|
||||
public void onAllServicesInitialized() throws SquBlockchainException {
|
||||
public void onAllServicesInitialized() throws BsqBlockchainException {
|
||||
daoPeriodService.onAllServicesInitialized();
|
||||
squUtxoFeedService.onAllServicesInitialized();
|
||||
bsqUtxoFeedService.onAllServicesInitialized();
|
||||
voteManager.onAllServicesInitialized();
|
||||
compensationRequestManager.onAllServicesInitialized();
|
||||
squBlockchainManager.onAllServicesInitialized();
|
||||
bsqBlockchainManager.onAllServicesInitialized();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -19,10 +19,10 @@ package io.bitsquare.dao;
|
|||
|
||||
import com.google.inject.Singleton;
|
||||
import io.bitsquare.app.AppModule;
|
||||
import io.bitsquare.dao.blockchain.BsqBlockchainManager;
|
||||
import io.bitsquare.dao.blockchain.BsqBlockchainRpcService;
|
||||
import io.bitsquare.dao.blockchain.BsqBlockchainService;
|
||||
import io.bitsquare.dao.blockchain.RpcOptionKeys;
|
||||
import io.bitsquare.dao.blockchain.SquBlockchainManager;
|
||||
import io.bitsquare.dao.blockchain.SquBlockchainRpcService;
|
||||
import io.bitsquare.dao.blockchain.SquBlockchainService;
|
||||
import io.bitsquare.dao.compensation.CompensationRequestManager;
|
||||
import io.bitsquare.dao.vote.VotingDefaultValues;
|
||||
import io.bitsquare.dao.vote.VotingManager;
|
||||
|
@ -43,8 +43,8 @@ public class DaoModule extends AppModule {
|
|||
@Override
|
||||
protected void configure() {
|
||||
bind(DaoManager.class).in(Singleton.class);
|
||||
bind(SquBlockchainManager.class).in(Singleton.class);
|
||||
bind(SquBlockchainService.class).to(SquBlockchainRpcService.class).in(Singleton.class);
|
||||
bind(BsqBlockchainManager.class).in(Singleton.class);
|
||||
bind(BsqBlockchainService.class).to(BsqBlockchainRpcService.class).in(Singleton.class);
|
||||
bind(DaoPeriodService.class).in(Singleton.class);
|
||||
bind(VotingService.class).in(Singleton.class);
|
||||
|
||||
|
|
|
@ -24,29 +24,29 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class SquBlock {
|
||||
private static final Logger log = LoggerFactory.getLogger(SquBlock.class);
|
||||
public class BsqBlock {
|
||||
private static final Logger log = LoggerFactory.getLogger(BsqBlock.class);
|
||||
|
||||
public final int blockHeight;
|
||||
public final List<String> txIds;
|
||||
|
||||
private Map<String, SquTransaction> squTransactions = new HashMap<>();
|
||||
private Map<String, BsqTransaction> bsqTransactions = new HashMap<>();
|
||||
|
||||
public SquBlock(List<String> txIds, int blockHeight) {
|
||||
public BsqBlock(List<String> txIds, int blockHeight) {
|
||||
this.txIds = txIds;
|
||||
this.blockHeight = blockHeight;
|
||||
}
|
||||
|
||||
public void addSquTransaction(SquTransaction squTransaction) {
|
||||
squTransactions.put(squTransaction.txId, squTransaction);
|
||||
public void addBsqTransaction(BsqTransaction bsqTransaction) {
|
||||
bsqTransactions.put(bsqTransaction.txId, bsqTransaction);
|
||||
}
|
||||
|
||||
public SquTransaction getSquTransaction(String txId) {
|
||||
return squTransactions.get(txId);
|
||||
public BsqTransaction getBsqTransaction(String txId) {
|
||||
return bsqTransactions.get(txId);
|
||||
}
|
||||
|
||||
public Map<String, SquTransaction> getTransactions() {
|
||||
return squTransactions;
|
||||
public Map<String, BsqTransaction> getTransactions() {
|
||||
return bsqTransactions;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,11 +54,11 @@ public class SquBlock {
|
|||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
SquBlock squBlock = (SquBlock) o;
|
||||
BsqBlock bsqBlock = (BsqBlock) o;
|
||||
|
||||
if (blockHeight != squBlock.blockHeight) return false;
|
||||
if (txIds != null ? !txIds.equals(squBlock.txIds) : squBlock.txIds != null) return false;
|
||||
return !(squTransactions != null ? !squTransactions.equals(squBlock.squTransactions) : squBlock.squTransactions != null);
|
||||
if (blockHeight != bsqBlock.blockHeight) return false;
|
||||
if (txIds != null ? !txIds.equals(bsqBlock.txIds) : bsqBlock.txIds != null) return false;
|
||||
return !(bsqTransactions != null ? !bsqTransactions.equals(bsqBlock.bsqTransactions) : bsqBlock.bsqTransactions != null);
|
||||
|
||||
}
|
||||
|
||||
|
@ -66,16 +66,16 @@ public class SquBlock {
|
|||
public int hashCode() {
|
||||
int result = blockHeight;
|
||||
result = 31 * result + (txIds != null ? txIds.hashCode() : 0);
|
||||
result = 31 * result + (squTransactions != null ? squTransactions.hashCode() : 0);
|
||||
result = 31 * result + (bsqTransactions != null ? bsqTransactions.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SquBlock{" +
|
||||
return "BsqBlock{" +
|
||||
"blockHeight=" + blockHeight +
|
||||
", txIds=" + txIds +
|
||||
", squTransactions=" + squTransactions +
|
||||
", bsqTransactions=" + bsqTransactions +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -17,12 +17,12 @@
|
|||
|
||||
package io.bitsquare.dao.blockchain;
|
||||
|
||||
public class SquBlockchainException extends Exception {
|
||||
public SquBlockchainException(String message) {
|
||||
public class BsqBlockchainException extends Exception {
|
||||
public BsqBlockchainException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public SquBlockchainException(String message, Throwable cause) {
|
||||
public BsqBlockchainException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
|
@ -30,16 +30,16 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class SquBlockchainManager {
|
||||
private static final Logger log = LoggerFactory.getLogger(SquBlockchainManager.class);
|
||||
public class BsqBlockchainManager {
|
||||
private static final Logger log = LoggerFactory.getLogger(BsqBlockchainManager.class);
|
||||
|
||||
private final SquBlockchainService blockchainService;
|
||||
private final BsqBlockchainService blockchainService;
|
||||
|
||||
// regtest
|
||||
public static final String GENESIS_TX_ID = "c01129ff48082f8f9613dd505899359227cb71aa457903359cfd0ca9c152dcd6";
|
||||
public static final int GENESIS_BLOCK_HEIGHT = 103;
|
||||
|
||||
protected Map<String, Map<Integer, SquUTXO>> utxoByTxIdMap;
|
||||
protected Map<String, Map<Integer, BsqUTXO>> utxoByTxIdMap;
|
||||
private List<UtxoListener> utxoListeners = new ArrayList<>();
|
||||
private boolean isUtxoAvailable;
|
||||
protected int chainHeadHeight;
|
||||
|
@ -50,7 +50,7 @@ public class SquBlockchainManager {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public SquBlockchainManager(SquBlockchainService blockchainService) {
|
||||
public BsqBlockchainManager(BsqBlockchainService blockchainService) {
|
||||
this.blockchainService = blockchainService;
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class SquBlockchainManager {
|
|||
});
|
||||
}
|
||||
|
||||
public Map<String, Map<Integer, SquUTXO>> getUtxoByTxIdMap() {
|
||||
public Map<String, Map<Integer, BsqUTXO>> getUtxoByTxIdMap() {
|
||||
return utxoByTxIdMap;
|
||||
}
|
||||
|
||||
|
@ -88,12 +88,12 @@ public class SquBlockchainManager {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
protected void setupComplete() {
|
||||
ListenableFuture<Tuple2<Map<String, Map<Integer, SquUTXO>>, Integer>> future = blockchainService.syncFromGenesis(GENESIS_BLOCK_HEIGHT, GENESIS_TX_ID);
|
||||
Futures.addCallback(future, new FutureCallback<Tuple2<Map<String, Map<Integer, SquUTXO>>, Integer>>() {
|
||||
ListenableFuture<Tuple2<Map<String, Map<Integer, BsqUTXO>>, Integer>> future = blockchainService.syncFromGenesis(GENESIS_BLOCK_HEIGHT, GENESIS_TX_ID);
|
||||
Futures.addCallback(future, new FutureCallback<Tuple2<Map<String, Map<Integer, BsqUTXO>>, Integer>>() {
|
||||
@Override
|
||||
public void onSuccess(Tuple2<Map<String, Map<Integer, SquUTXO>>, Integer> tulpe) {
|
||||
public void onSuccess(Tuple2<Map<String, Map<Integer, BsqUTXO>>, Integer> tulpe) {
|
||||
UserThread.execute(() -> {
|
||||
SquBlockchainManager.this.utxoByTxIdMap = tulpe.first;
|
||||
BsqBlockchainManager.this.utxoByTxIdMap = tulpe.first;
|
||||
chainHeadHeight = tulpe.second;
|
||||
isUtxoAvailable = true;
|
||||
utxoListeners.stream().forEach(e -> e.onUtxoChanged(utxoByTxIdMap));
|
||||
|
@ -103,11 +103,11 @@ public class SquBlockchainManager {
|
|||
if (block != null) {
|
||||
UserThread.execute(() -> {
|
||||
try {
|
||||
blockchainService.parseBlock(new SquBlock(block.getTx(), block.getHeight()),
|
||||
blockchainService.parseBlock(new BsqBlock(block.getTx(), block.getHeight()),
|
||||
GENESIS_BLOCK_HEIGHT,
|
||||
GENESIS_TX_ID,
|
||||
utxoByTxIdMap);
|
||||
} catch (SquBlockchainException e) {
|
||||
} catch (BsqBlockchainException e) {
|
||||
//TODO
|
||||
e.printStackTrace();
|
||||
}
|
|
@ -55,8 +55,8 @@ import java.util.stream.Collectors;
|
|||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.bitcoinj.core.Utils.HEX;
|
||||
|
||||
public class SquBlockchainRpcService extends SquBlockchainService {
|
||||
private static final Logger log = LoggerFactory.getLogger(SquBlockchainRpcService.class);
|
||||
public class BsqBlockchainRpcService extends BsqBlockchainService {
|
||||
private static final Logger log = LoggerFactory.getLogger(BsqBlockchainRpcService.class);
|
||||
|
||||
private final String rpcUser;
|
||||
private final String rpcPassword;
|
||||
|
@ -74,7 +74,7 @@ public class SquBlockchainRpcService extends SquBlockchainService {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public SquBlockchainRpcService(@Named(RpcOptionKeys.RPC_USER) String rpcUser,
|
||||
public BsqBlockchainRpcService(@Named(RpcOptionKeys.RPC_USER) String rpcUser,
|
||||
@Named(RpcOptionKeys.RPC_PASSWORD) String rpcPassword,
|
||||
@Named(RpcOptionKeys.RPC_PORT) String rpcPort,
|
||||
@Named(RpcOptionKeys.RPC_BLOCK_PORT) String rpcBlockPort,
|
||||
|
@ -113,16 +113,16 @@ public class SquBlockchainRpcService extends SquBlockchainService {
|
|||
log.info("Setup took {} ms", System.currentTimeMillis() - startTs);
|
||||
return client;
|
||||
} catch (IOException | BitcoindException | CommunicationException e) {
|
||||
throw new SquBlockchainException(e.getMessage(), e);
|
||||
throw new BsqBlockchainException(e.getMessage(), e);
|
||||
}
|
||||
} catch (URISyntaxException | IOException e) {
|
||||
throw new SquBlockchainException(e.getMessage(), e);
|
||||
throw new BsqBlockchainException(e.getMessage(), e);
|
||||
}
|
||||
});
|
||||
|
||||
Futures.addCallback(future, new FutureCallback<BtcdClientImpl>() {
|
||||
public void onSuccess(BtcdClientImpl client) {
|
||||
SquBlockchainRpcService.this.client = client;
|
||||
BsqBlockchainRpcService.this.client = client;
|
||||
resultHandler.handleResult();
|
||||
}
|
||||
|
||||
|
@ -133,10 +133,10 @@ public class SquBlockchainRpcService extends SquBlockchainService {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ListenableFuture<Tuple2<Map<String, Map<Integer, SquUTXO>>, Integer>> syncFromGenesis(int genesisBlockHeight, String genesisTxId) {
|
||||
protected ListenableFuture<Tuple2<Map<String, Map<Integer, BsqUTXO>>, Integer>> syncFromGenesis(int genesisBlockHeight, String genesisTxId) {
|
||||
return rpcRequestsExecutor.submit(() -> {
|
||||
long startTs = System.currentTimeMillis();
|
||||
Map<String, Map<Integer, SquUTXO>> utxoByTxIdMap = new HashMap<>();
|
||||
Map<String, Map<Integer, BsqUTXO>> utxoByTxIdMap = new HashMap<>();
|
||||
int chainHeadHeight = requestChainHeadHeight();
|
||||
parseBlockchain(utxoByTxIdMap, chainHeadHeight, genesisBlockHeight, genesisTxId);
|
||||
log.info("syncFromGenesis took {} ms", System.currentTimeMillis() - startTs);
|
||||
|
@ -161,7 +161,7 @@ public class SquBlockchainRpcService extends SquBlockchainService {
|
|||
*//* try {
|
||||
// parseTransaction(transaction.getTxId(), GENESIS_TX_ID, client.getBlockCount(), tempUtxoByTxIdMap, utxoByTxIdMap);
|
||||
printUtxoMap(utxoByTxIdMap);
|
||||
} catch (BitcoindException | CommunicationException | SquBlockchainException e) {
|
||||
} catch (BitcoindException | CommunicationException | BsqBlockchainException e) {
|
||||
//TODO
|
||||
e.printStackTrace();
|
||||
}*//*
|
||||
|
@ -180,25 +180,25 @@ public class SquBlockchainRpcService extends SquBlockchainService {
|
|||
}
|
||||
|
||||
@Override
|
||||
SquTransaction requestTransaction(String txId) throws SquBlockchainException {
|
||||
BsqTransaction requestTransaction(String txId) throws BsqBlockchainException {
|
||||
try {
|
||||
RawTransaction rawTransaction = getRawTransaction(txId);
|
||||
return new SquTransaction(txId,
|
||||
return new BsqTransaction(txId,
|
||||
rawTransaction.getVIn()
|
||||
.stream()
|
||||
.filter(rawInput -> rawInput != null && rawInput.getVOut() != null && rawInput.getTxId() != null)
|
||||
.map(rawInput -> new SquTxInput(rawInput.getVOut(), rawInput.getTxId(), rawTransaction.getHex()))
|
||||
.map(rawInput -> new BsqTxInput(rawInput.getVOut(), rawInput.getTxId(), rawTransaction.getHex()))
|
||||
.collect(Collectors.toList()),
|
||||
rawTransaction.getVOut()
|
||||
.stream()
|
||||
.filter(e -> e != null && e.getN() != null && e.getValue() != null && e.getScriptPubKey() != null)
|
||||
.map(e -> new SquTxOutput(e.getN(),
|
||||
.map(e -> new BsqTxOutput(e.getN(),
|
||||
Coin.valueOf(e.getValue().movePointRight(8).longValue()),
|
||||
e.getScriptPubKey().getAddresses(),
|
||||
e.getScriptPubKey().getHex() != null ? new Script(HEX.decode(e.getScriptPubKey().getHex())) : null))
|
||||
.collect(Collectors.toList()));
|
||||
} catch (BitcoindException | CommunicationException e) {
|
||||
throw new SquBlockchainException(e.getMessage(), e);
|
||||
throw new BsqBlockchainException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
|
@ -24,16 +24,16 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.io.File;
|
||||
|
||||
public class SquBlockchainRpcServiceMain {
|
||||
private static final Logger log = LoggerFactory.getLogger(SquBlockchainRpcServiceMain.class);
|
||||
public class BsqBlockchainRpcServiceMain {
|
||||
private static final Logger log = LoggerFactory.getLogger(BsqBlockchainRpcServiceMain.class);
|
||||
|
||||
public static void main(String[] args) throws SquBlockchainException {
|
||||
public static void main(String[] args) throws BsqBlockchainException {
|
||||
Log.setup(System.getProperty("user.home") + File.separator + "BlockchainRpcServiceMain");
|
||||
Log.setLevel(Level.WARN);
|
||||
|
||||
// regtest uses port 18332, mainnet 8332
|
||||
SquBlockchainRpcService blockchainRpcService = new SquBlockchainRpcService(args[0], args[1], args[2], args[3], args[4]);
|
||||
SquBlockchainManager squBlockchainManager = new SquBlockchainManager(blockchainRpcService);
|
||||
squBlockchainManager.onAllServicesInitialized();
|
||||
BsqBlockchainRpcService blockchainRpcService = new BsqBlockchainRpcService(args[0], args[1], args[2], args[3], args[4]);
|
||||
BsqBlockchainManager bsqBlockchainManager = new BsqBlockchainManager(blockchainRpcService);
|
||||
bsqBlockchainManager.onAllServicesInitialized();
|
||||
}
|
||||
}
|
|
@ -36,10 +36,10 @@ import java.util.stream.Collectors;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
abstract public class SquBlockchainService {
|
||||
private static final Logger log = LoggerFactory.getLogger(SquBlockchainService.class);
|
||||
abstract public class BsqBlockchainService {
|
||||
private static final Logger log = LoggerFactory.getLogger(BsqBlockchainService.class);
|
||||
|
||||
protected Map<String, Map<Integer, SquUTXO>> utxoByTxIdMap;
|
||||
protected Map<String, Map<Integer, BsqUTXO>> utxoByTxIdMap;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -47,7 +47,7 @@ abstract public class SquBlockchainService {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public SquBlockchainService() {
|
||||
public BsqBlockchainService() {
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,7 +57,7 @@ abstract public class SquBlockchainService {
|
|||
|
||||
abstract void setup(ResultHandler resultHandler, ErrorMessageHandler errorMessageHandler);
|
||||
|
||||
abstract ListenableFuture<Tuple2<Map<String, Map<Integer, SquUTXO>>, Integer>> syncFromGenesis(int genesisBlockHeight, String genesisTxId);
|
||||
abstract ListenableFuture<Tuple2<Map<String, Map<Integer, BsqUTXO>>, Integer>> syncFromGenesis(int genesisBlockHeight, String genesisTxId);
|
||||
|
||||
abstract void syncFromGenesisCompete(String genesisTxId, int genesisBlockHeight, Consumer<Block> onNewBlockHandler);
|
||||
|
||||
|
@ -65,20 +65,20 @@ abstract public class SquBlockchainService {
|
|||
|
||||
abstract Block requestBlock(int i) throws BitcoindException, CommunicationException;
|
||||
|
||||
abstract SquTransaction requestTransaction(String txId) throws SquBlockchainException;
|
||||
abstract BsqTransaction requestTransaction(String txId) throws BsqBlockchainException;
|
||||
|
||||
Map<String, Map<Integer, SquUTXO>> parseBlockchain(Map<String, Map<Integer, SquUTXO>> utxoByTxIdMap,
|
||||
Map<String, Map<Integer, BsqUTXO>> parseBlockchain(Map<String, Map<Integer, BsqUTXO>> utxoByTxIdMap,
|
||||
int chainHeadHeight,
|
||||
int genesisBlockHeight,
|
||||
String genesisTxId)
|
||||
throws SquBlockchainException {
|
||||
throws BsqBlockchainException {
|
||||
try {
|
||||
//log.info("blockCount=" + chainHeadHeight);
|
||||
long startTs = System.currentTimeMillis();
|
||||
for (int blockHeight = genesisBlockHeight; blockHeight <= chainHeadHeight; blockHeight++) {
|
||||
Block block = requestBlock(blockHeight);
|
||||
//log.info("blockHeight=" + blockHeight);
|
||||
parseBlock(new SquBlock(block.getTx(), block.getHeight()),
|
||||
parseBlock(new BsqBlock(block.getTx(), block.getHeight()),
|
||||
genesisBlockHeight,
|
||||
genesisTxId,
|
||||
utxoByTxIdMap);
|
||||
|
@ -86,26 +86,26 @@ abstract public class SquBlockchainService {
|
|||
printUtxoMap(utxoByTxIdMap);
|
||||
// log.info("Took {} ms", System.currentTimeMillis() - startTs);
|
||||
} catch (BitcoindException | CommunicationException e) {
|
||||
throw new SquBlockchainException(e.getMessage(), e);
|
||||
throw new BsqBlockchainException(e.getMessage(), e);
|
||||
}
|
||||
return utxoByTxIdMap;
|
||||
}
|
||||
|
||||
void parseBlock(SquBlock block,
|
||||
void parseBlock(BsqBlock block,
|
||||
int genesisBlockHeight,
|
||||
String genesisTxId,
|
||||
Map<String, Map<Integer, SquUTXO>> utxoByTxIdMap)
|
||||
throws SquBlockchainException {
|
||||
Map<String, Map<Integer, BsqUTXO>> utxoByTxIdMap)
|
||||
throws BsqBlockchainException {
|
||||
int blockHeight = block.blockHeight;
|
||||
log.debug("Parse block at height={} ", blockHeight);
|
||||
// We add all transactions to the block
|
||||
List<String> txIds = block.txIds;
|
||||
for (String txId : txIds) {
|
||||
block.addSquTransaction(requestTransaction(txId));
|
||||
block.addBsqTransaction(requestTransaction(txId));
|
||||
}
|
||||
|
||||
// First we check for the genesis tx
|
||||
Map<String, SquTransaction> transactionsMap = block.getTransactions();
|
||||
Map<String, BsqTransaction> transactionsMap = block.getTransactions();
|
||||
if (blockHeight == genesisBlockHeight) {
|
||||
transactionsMap.entrySet().stream()
|
||||
.filter(entry -> entry.getKey().equals(genesisTxId))
|
||||
|
@ -115,8 +115,8 @@ abstract public class SquBlockchainService {
|
|||
resolveConnectedTxs(transactionsMap.values(), utxoByTxIdMap, blockHeight, 0, 100);
|
||||
}
|
||||
|
||||
void resolveConnectedTxs(Collection<SquTransaction> transactions,
|
||||
Map<String, Map<Integer, SquUTXO>> utxoByTxIdMap,
|
||||
void resolveConnectedTxs(Collection<BsqTransaction> transactions,
|
||||
Map<String, Map<Integer, BsqUTXO>> utxoByTxIdMap,
|
||||
int blockHeight,
|
||||
int recursions,
|
||||
int maxRecursions) {
|
||||
|
@ -127,12 +127,12 @@ abstract public class SquBlockchainService {
|
|||
// is an orphaned tx.
|
||||
// connectedTxs: Those who have inputs in the UTXO set
|
||||
// orphanTxs: Those who have inputs from other txs in the same block
|
||||
Set<SquTransaction> connectedTxs = new HashSet<>();
|
||||
Set<SquTransaction> orphanTxs = new HashSet<>();
|
||||
Set<BsqTransaction> connectedTxs = new HashSet<>();
|
||||
Set<BsqTransaction> orphanTxs = new HashSet<>();
|
||||
outerLoop:
|
||||
for (SquTransaction transaction : transactions) {
|
||||
for (BsqTransaction transaction : transactions) {
|
||||
boolean isConnected = false;
|
||||
for (SquTxInput input : transaction.inputs) {
|
||||
for (BsqTxInput input : transaction.inputs) {
|
||||
String spendingTxId = input.spendingTxId;
|
||||
if (spendingTxIdSet.contains(spendingTxId)) {
|
||||
// We have an input in one of the blocks transactions, so we cannot process that tx now.
|
||||
|
@ -141,7 +141,7 @@ abstract public class SquBlockchainService {
|
|||
continue outerLoop;
|
||||
} else if (utxoByTxIdMap.containsKey(spendingTxId)) {
|
||||
// If we find the tx in the utxo set we set the isConnected flag.
|
||||
Map<Integer, SquUTXO> utxoByIndexMap = utxoByTxIdMap.get(spendingTxId);
|
||||
Map<Integer, BsqUTXO> utxoByIndexMap = utxoByTxIdMap.get(spendingTxId);
|
||||
if (utxoByIndexMap != null && utxoByIndexMap.containsKey(input.spendingOuptuIndex)) {
|
||||
// Our input has a connection to an tx from the utxo set
|
||||
isConnected = true;
|
||||
|
@ -154,7 +154,7 @@ abstract public class SquBlockchainService {
|
|||
}
|
||||
|
||||
// Now we check if our connected txs are valid BSQ transactions
|
||||
for (SquTransaction transaction : connectedTxs) {
|
||||
for (BsqTransaction transaction : connectedTxs) {
|
||||
verifyTransaction(transaction, blockHeight, utxoByTxIdMap);
|
||||
}
|
||||
//log.info("orphanTxs " + orphanTxs);
|
||||
|
@ -162,7 +162,7 @@ abstract public class SquBlockchainService {
|
|||
resolveConnectedTxs(orphanTxs, utxoByTxIdMap, blockHeight, ++recursions, maxRecursions);
|
||||
}
|
||||
|
||||
private Set<String> getSpendingTxIdSet(Collection<SquTransaction> transactions) {
|
||||
private Set<String> getSpendingTxIdSet(Collection<BsqTransaction> transactions) {
|
||||
Set<String> txIdSet = transactions.stream().map(tx -> tx.txId).collect(Collectors.toSet());
|
||||
Set<String> spendingTxIdSet = new HashSet<>();
|
||||
transactions.stream()
|
||||
|
@ -175,21 +175,21 @@ abstract public class SquBlockchainService {
|
|||
return spendingTxIdSet;
|
||||
}
|
||||
|
||||
private void verifyTransaction(SquTransaction squTransaction,
|
||||
private void verifyTransaction(BsqTransaction bsqTransaction,
|
||||
int blockHeight,
|
||||
Map<String, Map<Integer, SquUTXO>> utxoByTxIdMap
|
||||
Map<String, Map<Integer, BsqUTXO>> utxoByTxIdMap
|
||||
) {
|
||||
String txId = squTransaction.txId;
|
||||
List<SquTxOutput> outputs = squTransaction.outputs;
|
||||
String txId = bsqTransaction.txId;
|
||||
List<BsqTxOutput> outputs = bsqTransaction.outputs;
|
||||
|
||||
Coin availableValue = Coin.ZERO;
|
||||
for (SquTxInput input : squTransaction.inputs) {
|
||||
for (BsqTxInput input : bsqTransaction.inputs) {
|
||||
String spendingTxId = input.spendingTxId;
|
||||
if (utxoByTxIdMap.containsKey(spendingTxId)) {
|
||||
Map<Integer, SquUTXO> utxoByIndexMap = utxoByTxIdMap.get(spendingTxId);
|
||||
Map<Integer, BsqUTXO> utxoByIndexMap = utxoByTxIdMap.get(spendingTxId);
|
||||
Integer index = input.spendingOuptuIndex;
|
||||
if (utxoByIndexMap.containsKey(index)) {
|
||||
SquUTXO utxo = utxoByIndexMap.get(index);
|
||||
BsqUTXO utxo = utxoByIndexMap.get(index);
|
||||
|
||||
utxoByIndexMap.remove(index);
|
||||
availableValue = availableValue.add(utxo.getValue());
|
||||
|
@ -202,12 +202,12 @@ abstract public class SquBlockchainService {
|
|||
}
|
||||
// If we have an input spending tokens we iterate the outputs
|
||||
if (availableValue.isPositive()) {
|
||||
Map<Integer, SquUTXO> utxoByIndexMap = utxoByTxIdMap.containsKey(txId) ?
|
||||
Map<Integer, BsqUTXO> utxoByIndexMap = utxoByTxIdMap.containsKey(txId) ?
|
||||
utxoByTxIdMap.get(txId) :
|
||||
new HashMap<>();
|
||||
// We sort by index, inputs are tokens as long there is enough input value
|
||||
for (int i = 0; i < outputs.size(); i++) {
|
||||
SquTxOutput squOutput = outputs.get(i);
|
||||
BsqTxOutput squOutput = outputs.get(i);
|
||||
List<String> addresses = squOutput.addresses;
|
||||
// Only at raw MS outputs addresses have more then 1 entry
|
||||
// We do not support raw MS for BSQ
|
||||
|
@ -216,7 +216,7 @@ abstract public class SquBlockchainService {
|
|||
availableValue = availableValue.subtract(squOutput.value);
|
||||
if (!availableValue.isNegative()) {
|
||||
// We are spending available tokens
|
||||
SquUTXO utxo = new SquUTXO(txId,
|
||||
BsqUTXO utxo = new BsqUTXO(txId,
|
||||
squOutput.index,
|
||||
squOutput.value,
|
||||
blockHeight,
|
||||
|
@ -237,7 +237,7 @@ abstract public class SquBlockchainService {
|
|||
if (availableValue.isPositive()) {
|
||||
log.warn("BSQ have been left which was not spent. Burned BSQ amount={}, tx={}",
|
||||
availableValue.value,
|
||||
squTransaction.toString());
|
||||
bsqTransaction.toString());
|
||||
}
|
||||
if (!utxoByIndexMap.isEmpty() && !utxoByTxIdMap.containsKey(txId)) {
|
||||
boolean wasEmpty = utxoByTxIdMap.put(txId, utxoByIndexMap) == null;
|
||||
|
@ -248,21 +248,21 @@ abstract public class SquBlockchainService {
|
|||
|
||||
|
||||
@VisibleForTesting
|
||||
void parseGenesisTx(SquTransaction squTransaction, int blockHeight, Map<String, Map<Integer, SquUTXO>> utxoByTxIdMap) {
|
||||
String txId = squTransaction.txId;
|
||||
List<SquTxOutput> outputs = squTransaction.outputs;
|
||||
void parseGenesisTx(BsqTransaction bsqTransaction, int blockHeight, Map<String, Map<Integer, BsqUTXO>> utxoByTxIdMap) {
|
||||
String txId = bsqTransaction.txId;
|
||||
List<BsqTxOutput> outputs = bsqTransaction.outputs;
|
||||
|
||||
// Genesis tx uses all outputs as BSQ outputs
|
||||
Map<Integer, SquUTXO> utxoByIndexMap = new HashMap<>();
|
||||
Map<Integer, BsqUTXO> utxoByIndexMap = new HashMap<>();
|
||||
for (int i = 0; i < outputs.size(); i++) {
|
||||
SquTxOutput output = outputs.get(i);
|
||||
BsqTxOutput output = outputs.get(i);
|
||||
List<String> addresses = output.addresses;
|
||||
// Only at raw MS outputs addresses have more then 1 entry
|
||||
// We do not support raw MS for BSQ
|
||||
if (addresses.size() == 1) {
|
||||
String address = addresses.get(0);
|
||||
//TODO set coinbase to true after testing
|
||||
SquUTXO utxo = new SquUTXO(txId,
|
||||
BsqUTXO utxo = new BsqUTXO(txId,
|
||||
output.index,
|
||||
output.value,
|
||||
blockHeight,
|
||||
|
@ -277,7 +277,7 @@ abstract public class SquBlockchainService {
|
|||
checkArgument(wasEmpty, "We must not have that tx in the map. txId=" + txId);
|
||||
}
|
||||
|
||||
void printUtxoMap(Map<String, Map<Integer, SquUTXO>> utxoByTxIdMap) {
|
||||
void printUtxoMap(Map<String, Map<Integer, BsqUTXO>> utxoByTxIdMap) {
|
||||
StringBuilder sb = new StringBuilder("utxoByTxIdMap:\n");
|
||||
utxoByTxIdMap.entrySet().stream().forEach(e -> {
|
||||
sb.append("TxId: ").append(e.getKey()).append("\n");
|
|
@ -22,14 +22,14 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public class SquTransaction {
|
||||
private static final Logger log = LoggerFactory.getLogger(SquTransaction.class);
|
||||
public class BsqTransaction {
|
||||
private static final Logger log = LoggerFactory.getLogger(BsqTransaction.class);
|
||||
|
||||
public final String txId;
|
||||
public final List<SquTxInput> inputs;
|
||||
public final List<SquTxOutput> outputs;
|
||||
public final List<BsqTxInput> inputs;
|
||||
public final List<BsqTxOutput> outputs;
|
||||
|
||||
public SquTransaction(String txId, List<SquTxInput> inputs, List<SquTxOutput> outputs) {
|
||||
public BsqTransaction(String txId, List<BsqTxInput> inputs, List<BsqTxOutput> outputs) {
|
||||
this.txId = txId;
|
||||
this.inputs = inputs;
|
||||
this.outputs = outputs;
|
||||
|
@ -40,7 +40,7 @@ public class SquTransaction {
|
|||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
SquTransaction that = (SquTransaction) o;
|
||||
BsqTransaction that = (BsqTransaction) o;
|
||||
|
||||
if (txId != null ? !txId.equals(that.txId) : that.txId != null) return false;
|
||||
if (inputs != null ? !inputs.equals(that.inputs) : that.inputs != null) return false;
|
||||
|
@ -58,7 +58,7 @@ public class SquTransaction {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SquTransaction{" +
|
||||
return "BsqTransaction{" +
|
||||
"txId='" + txId + '\'' +
|
||||
", inputs=" + inputs +
|
||||
", outputs=" + outputs +
|
|
@ -20,14 +20,14 @@ package io.bitsquare.dao.blockchain;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class SquTxInput {
|
||||
private static final Logger log = LoggerFactory.getLogger(SquTxInput.class);
|
||||
public class BsqTxInput {
|
||||
private static final Logger log = LoggerFactory.getLogger(BsqTxInput.class);
|
||||
|
||||
public final int spendingOuptuIndex;
|
||||
public final String spendingTxId;
|
||||
public final String txId;
|
||||
|
||||
public SquTxInput(int spendingOuptuIndex, String spendingTxId, String txId) {
|
||||
public BsqTxInput(int spendingOuptuIndex, String spendingTxId, String txId) {
|
||||
this.spendingOuptuIndex = spendingOuptuIndex;
|
||||
this.spendingTxId = spendingTxId;
|
||||
this.txId = txId;
|
||||
|
@ -38,7 +38,7 @@ public class SquTxInput {
|
|||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
SquTxInput that = (SquTxInput) o;
|
||||
BsqTxInput that = (BsqTxInput) o;
|
||||
|
||||
if (spendingOuptuIndex != that.spendingOuptuIndex) return false;
|
||||
if (spendingTxId != null ? !spendingTxId.equals(that.spendingTxId) : that.spendingTxId != null) return false;
|
||||
|
@ -56,7 +56,7 @@ public class SquTxInput {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SquTxInput{" +
|
||||
return "BsqTxInput{" +
|
||||
"spendingOuptuIndex=" + spendingOuptuIndex +
|
||||
", spendingTxId='" + spendingTxId + '\'' +
|
||||
", txId='" + txId + '\'' +
|
|
@ -24,15 +24,15 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public class SquTxOutput {
|
||||
private static final Logger log = LoggerFactory.getLogger(SquTxOutput.class);
|
||||
public class BsqTxOutput {
|
||||
private static final Logger log = LoggerFactory.getLogger(BsqTxOutput.class);
|
||||
|
||||
public final int index;
|
||||
public final Coin value;
|
||||
public final List<String> addresses;
|
||||
public final Script script;
|
||||
|
||||
public SquTxOutput(int index, Coin value, List<String> addresses, Script script) {
|
||||
public BsqTxOutput(int index, Coin value, List<String> addresses, Script script) {
|
||||
this.index = index;
|
||||
this.value = value;
|
||||
this.addresses = addresses;
|
||||
|
@ -44,7 +44,7 @@ public class SquTxOutput {
|
|||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
SquTxOutput that = (SquTxOutput) o;
|
||||
BsqTxOutput that = (BsqTxOutput) o;
|
||||
|
||||
if (index != that.index) return false;
|
||||
if (value != null ? !value.equals(that.value) : that.value != null) return false;
|
||||
|
@ -64,7 +64,7 @@ public class SquTxOutput {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SquTxOutput{" +
|
||||
return "BsqTxOutput{" +
|
||||
"index=" + index +
|
||||
", value=" + value +
|
||||
", addresses=" + addresses +
|
|
@ -28,10 +28,10 @@ import org.slf4j.LoggerFactory;
|
|||
// Estimation for UTXO set: 1 UTXO object has 78 byte
|
||||
// 1000 UTXOs - 10 000 UTXOs: 78kb -780kb
|
||||
|
||||
public class SquUTXO extends UTXO {
|
||||
private static final Logger log = LoggerFactory.getLogger(SquUTXO.class);
|
||||
public class BsqUTXO extends UTXO {
|
||||
private static final Logger log = LoggerFactory.getLogger(BsqUTXO.class);
|
||||
|
||||
public SquUTXO(String txId, long index, Coin value, int height, boolean coinBase, Script script, String address) {
|
||||
public BsqUTXO(String txId, long index, Coin value, int height, boolean coinBase, Script script, String address) {
|
||||
super(Sha256Hash.wrap(Utils.HEX.decode(txId)), index, value, height, coinBase, script, address);
|
||||
}
|
||||
|
|
@ -4,5 +4,5 @@ package io.bitsquare.dao.blockchain;
|
|||
import java.util.Map;
|
||||
|
||||
public interface UtxoListener {
|
||||
void onUtxoChanged(Map<String, Map<Integer, SquUTXO>> utxoByTxIdMap);
|
||||
void onUtxoChanged(Map<String, Map<Integer, BsqUTXO>> utxoByTxIdMap);
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ package io.bitsquare.dao.compensation;
|
|||
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.inject.Inject;
|
||||
import io.bitsquare.btc.wallet.BsqWalletService;
|
||||
import io.bitsquare.btc.wallet.BtcWalletService;
|
||||
import io.bitsquare.btc.wallet.SquWalletService;
|
||||
import io.bitsquare.dao.DaoPeriodService;
|
||||
import io.bitsquare.dao.vote.VotingDefaultValues;
|
||||
import io.bitsquare.p2p.P2PService;
|
||||
|
@ -45,7 +45,7 @@ public class CompensationRequestManager {
|
|||
private final P2PService p2PService;
|
||||
private final DaoPeriodService daoPeriodService;
|
||||
private final BtcWalletService btcWalletService;
|
||||
private final SquWalletService squWalletService;
|
||||
private final BsqWalletService bsqWalletService;
|
||||
private final VotingDefaultValues votingDefaultValues;
|
||||
private final Storage<ArrayList<CompensationRequest>> compensationRequestsStorage;
|
||||
|
||||
|
@ -61,14 +61,14 @@ public class CompensationRequestManager {
|
|||
@Inject
|
||||
public CompensationRequestManager(P2PService p2PService,
|
||||
BtcWalletService btcWalletService,
|
||||
SquWalletService squWalletService,
|
||||
BsqWalletService bsqWalletService,
|
||||
DaoPeriodService daoPeriodService,
|
||||
VotingDefaultValues votingDefaultValues,
|
||||
Storage<ArrayList<CompensationRequest>> compensationRequestsStorage) {
|
||||
this.p2PService = p2PService;
|
||||
this.daoPeriodService = daoPeriodService;
|
||||
this.btcWalletService = btcWalletService;
|
||||
this.squWalletService = squWalletService;
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
this.votingDefaultValues = votingDefaultValues;
|
||||
this.compensationRequestsStorage = compensationRequestsStorage;
|
||||
|
||||
|
@ -127,7 +127,7 @@ public class CompensationRequestManager {
|
|||
}
|
||||
|
||||
public void fundCompensationRequest(CompensationRequest compensationRequest, Coin amount, FutureCallback<Transaction> callback) {
|
||||
btcWalletService.fundCompensationRequest(amount, compensationRequest.getCompensationRequestPayload().btcAddress, squWalletService.getUnusedAddress(), callback);
|
||||
btcWalletService.fundCompensationRequest(amount, compensationRequest.getCompensationRequestPayload().btcAddress, bsqWalletService.getUnusedAddress(), callback);
|
||||
}
|
||||
|
||||
public void setSelectedCompensationRequest(CompensationRequest selectedCompensationRequest) {
|
||||
|
|
|
@ -41,10 +41,10 @@ public final class VoteItemsList extends ArrayList<VoteItem> implements Persista
|
|||
public VoteItemsList(VotingDefaultValues votingDefaultValues) {
|
||||
add(new VoteItem(CREATE_OFFER_FEE_IN_BTC, "Create offer fee (in BTC Satoshi)", votingDefaultValues));
|
||||
add(new VoteItem(TAKE_OFFER_FEE_IN_BTC, "Take offer fee (in BTC Satoshi)", votingDefaultValues));
|
||||
add(new VoteItem(CREATE_OFFER_FEE_IN_SQU, "Create offer fee (in BSQ)", votingDefaultValues));
|
||||
add(new VoteItem(TAKE_OFFER_FEE_IN_SQU, "Take offer fee (in BSQ)", votingDefaultValues));
|
||||
add(new VoteItem(CREATE_COMPENSATION_REQUEST_FEE_IN_SQU, "Compensation request fee (in BSQ)", votingDefaultValues));
|
||||
add(new VoteItem(VOTING_FEE_IN_SQU, "Voting fee (in BSQ)", votingDefaultValues));
|
||||
add(new VoteItem(CREATE_OFFER_FEE_IN_BSQ, "Create offer fee (in BSQ)", votingDefaultValues));
|
||||
add(new VoteItem(TAKE_OFFER_FEE_IN_BSQ, "Take offer fee (in BSQ)", votingDefaultValues));
|
||||
add(new VoteItem(CREATE_COMPENSATION_REQUEST_FEE_IN_BSQ, "Compensation request fee (in BSQ)", votingDefaultValues));
|
||||
add(new VoteItem(VOTING_FEE_IN_BSQ, "Voting fee (in BSQ)", votingDefaultValues));
|
||||
|
||||
add(new VoteItem(COMPENSATION_REQUEST_PERIOD_IN_BLOCKS, "Compensation request period (in blocks)", votingDefaultValues));
|
||||
add(new VoteItem(VOTING_PERIOD_IN_BLOCKS, "Voting period (in blocks)", votingDefaultValues));
|
||||
|
|
|
@ -34,10 +34,10 @@ public class VotingDefaultValues {
|
|||
|
||||
public static final long CREATE_OFFER_FEE_IN_BTC_AT_GENESIS = 30_000;
|
||||
public static final long TAKE_OFFER_FEE_IN_BTC_AT_GENESIS = 80_000;
|
||||
public static final long CREATE_OFFER_FEE_IN_SQU_AT_GENESIS = 333;
|
||||
public static final long TAKE_OFFER_FEE_IN_SQU_AT_GENESIS = 444;
|
||||
public static final long CREATE_COMPENSATION_REQUEST_FEE_IN_SQU_AT_GENESIS = 7777;
|
||||
public static final long VOTING_FEE_IN_SQU_AT_GENESIS = 8888;
|
||||
public static final long CREATE_OFFER_FEE_IN_BSQ_AT_GENESIS = 333;
|
||||
public static final long TAKE_OFFER_FEE_IN_BSQ_AT_GENESIS = 444;
|
||||
public static final long CREATE_COMPENSATION_REQUEST_FEE_IN_BSQ_AT_GENESIS = 7777;
|
||||
public static final long VOTING_FEE_IN_BSQ_AT_GENESIS = 8888;
|
||||
|
||||
// 144 blocks is 1 day
|
||||
public static final long COMPENSATION_REQUEST_PERIOD_IN_BLOCKS_AT_GENESIS = 2880; // 20 days
|
||||
|
@ -61,10 +61,10 @@ public class VotingDefaultValues {
|
|||
|
||||
private long createOfferFeeInBtc = CREATE_OFFER_FEE_IN_BTC_AT_GENESIS;
|
||||
private long takeOfferFeeInBtc = TAKE_OFFER_FEE_IN_BTC_AT_GENESIS;
|
||||
private long createOfferFeeInSqu = CREATE_OFFER_FEE_IN_SQU_AT_GENESIS;
|
||||
private long takeOfferFeeInSqu = TAKE_OFFER_FEE_IN_SQU_AT_GENESIS;
|
||||
private long createCompensationRequestFeeInSqu = CREATE_COMPENSATION_REQUEST_FEE_IN_SQU_AT_GENESIS;
|
||||
private long votingFeeInSqu = VOTING_FEE_IN_SQU_AT_GENESIS;
|
||||
private long createOfferFeeInBsq = CREATE_OFFER_FEE_IN_BSQ_AT_GENESIS;
|
||||
private long takeOfferFeeInBsq = TAKE_OFFER_FEE_IN_BSQ_AT_GENESIS;
|
||||
private long createCompensationRequestFeeInBsq = CREATE_COMPENSATION_REQUEST_FEE_IN_BSQ_AT_GENESIS;
|
||||
private long votingFeeInBsq = VOTING_FEE_IN_BSQ_AT_GENESIS;
|
||||
|
||||
private long compensationRequestPeriodInBlocks = COMPENSATION_REQUEST_PERIOD_IN_BLOCKS_AT_GENESIS;
|
||||
private long votingPeriodInBlocks = VOTING_PERIOD_IN_BLOCKS_AT_GENESIS;
|
||||
|
@ -111,14 +111,14 @@ public class VotingDefaultValues {
|
|||
return createOfferFeeInBtc;
|
||||
case TAKE_OFFER_FEE_IN_BTC:
|
||||
return takeOfferFeeInBtc;
|
||||
case CREATE_OFFER_FEE_IN_SQU:
|
||||
return createOfferFeeInSqu;
|
||||
case TAKE_OFFER_FEE_IN_SQU:
|
||||
return takeOfferFeeInSqu;
|
||||
case CREATE_COMPENSATION_REQUEST_FEE_IN_SQU:
|
||||
return createCompensationRequestFeeInSqu;
|
||||
case VOTING_FEE_IN_SQU:
|
||||
return votingFeeInSqu;
|
||||
case CREATE_OFFER_FEE_IN_BSQ:
|
||||
return createOfferFeeInBsq;
|
||||
case TAKE_OFFER_FEE_IN_BSQ:
|
||||
return takeOfferFeeInBsq;
|
||||
case CREATE_COMPENSATION_REQUEST_FEE_IN_BSQ:
|
||||
return createCompensationRequestFeeInBsq;
|
||||
case VOTING_FEE_IN_BSQ:
|
||||
return votingFeeInBsq;
|
||||
|
||||
case COMPENSATION_REQUEST_PERIOD_IN_BLOCKS:
|
||||
return compensationRequestPeriodInBlocks;
|
||||
|
@ -160,17 +160,17 @@ public class VotingDefaultValues {
|
|||
case TAKE_OFFER_FEE_IN_BTC:
|
||||
takeOfferFeeInBtc = value;
|
||||
break;
|
||||
case CREATE_OFFER_FEE_IN_SQU:
|
||||
createOfferFeeInSqu = value;
|
||||
case CREATE_OFFER_FEE_IN_BSQ:
|
||||
createOfferFeeInBsq = value;
|
||||
break;
|
||||
case TAKE_OFFER_FEE_IN_SQU:
|
||||
takeOfferFeeInSqu = value;
|
||||
case TAKE_OFFER_FEE_IN_BSQ:
|
||||
takeOfferFeeInBsq = value;
|
||||
break;
|
||||
case CREATE_COMPENSATION_REQUEST_FEE_IN_SQU:
|
||||
createCompensationRequestFeeInSqu = value;
|
||||
case CREATE_COMPENSATION_REQUEST_FEE_IN_BSQ:
|
||||
createCompensationRequestFeeInBsq = value;
|
||||
break;
|
||||
case VOTING_FEE_IN_SQU:
|
||||
votingFeeInSqu = value;
|
||||
case VOTING_FEE_IN_BSQ:
|
||||
votingFeeInBsq = value;
|
||||
break;
|
||||
|
||||
case COMPENSATION_REQUEST_PERIOD_IN_BLOCKS:
|
||||
|
@ -271,20 +271,20 @@ public class VotingDefaultValues {
|
|||
this.takeOfferFeeInBtc = takeOfferFeeInBtc;
|
||||
}
|
||||
|
||||
public long getCreateCompensationRequestFeeInSqu() {
|
||||
return createCompensationRequestFeeInSqu;
|
||||
public long getCreateCompensationRequestFeeInBsq() {
|
||||
return createCompensationRequestFeeInBsq;
|
||||
}
|
||||
|
||||
public void setCreateCompensationRequestFeeInSqu(long createCompensationRequestFeeInSqu) {
|
||||
this.createCompensationRequestFeeInSqu = createCompensationRequestFeeInSqu;
|
||||
public void setCreateCompensationRequestFeeInBsq(long createCompensationRequestFeeInBsq) {
|
||||
this.createCompensationRequestFeeInBsq = createCompensationRequestFeeInBsq;
|
||||
}
|
||||
|
||||
public long getVotingFeeInSqu() {
|
||||
return votingFeeInSqu;
|
||||
public long getVotingFeeInBsq() {
|
||||
return votingFeeInBsq;
|
||||
}
|
||||
|
||||
public void setVotingFeeInSqu(long votingFeeInSqu) {
|
||||
this.votingFeeInSqu = votingFeeInSqu;
|
||||
public void setVotingFeeInBsq(long votingFeeInBsq) {
|
||||
this.votingFeeInBsq = votingFeeInBsq;
|
||||
}
|
||||
|
||||
public long getConversionRate() {
|
||||
|
|
|
@ -21,8 +21,8 @@ import com.google.common.annotations.VisibleForTesting;
|
|||
import com.google.inject.Inject;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.btc.provider.fee.FeeService;
|
||||
import io.bitsquare.btc.wallet.BsqWalletService;
|
||||
import io.bitsquare.btc.wallet.BtcWalletService;
|
||||
import io.bitsquare.btc.wallet.SquWalletService;
|
||||
import io.bitsquare.common.util.Utilities;
|
||||
import io.bitsquare.dao.DaoPeriodService;
|
||||
import io.bitsquare.dao.compensation.CompensationRequest;
|
||||
|
@ -50,7 +50,7 @@ public class VotingManager {
|
|||
public static final String ERROR_MSG_INVALID_COMP_REQ_VAL = "We found an accepted vote at a not voted request.";
|
||||
|
||||
private final BtcWalletService btcWalletService;
|
||||
private final SquWalletService squWalletService;
|
||||
private final BsqWalletService bsqWalletService;
|
||||
private FeeService feeService;
|
||||
private final Storage<ArrayList<VoteItemsList>> voteItemCollectionsStorage;
|
||||
private CompensationRequestManager compensationRequestManager;
|
||||
|
@ -61,14 +61,14 @@ public class VotingManager {
|
|||
|
||||
@Inject
|
||||
public VotingManager(BtcWalletService btcWalletService,
|
||||
SquWalletService squWalletService,
|
||||
BsqWalletService bsqWalletService,
|
||||
FeeService feeService,
|
||||
Storage<ArrayList<VoteItemsList>> voteItemCollectionsStorage,
|
||||
CompensationRequestManager compensationRequestManager,
|
||||
DaoPeriodService daoPeriodService,
|
||||
VotingDefaultValues votingDefaultValues) {
|
||||
this.btcWalletService = btcWalletService;
|
||||
this.squWalletService = squWalletService;
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
this.feeService = feeService;
|
||||
this.voteItemCollectionsStorage = voteItemCollectionsStorage;
|
||||
this.compensationRequestManager = compensationRequestManager;
|
||||
|
@ -83,7 +83,7 @@ public class VotingManager {
|
|||
@VisibleForTesting
|
||||
VotingManager(VotingDefaultValues votingDefaultValues) {
|
||||
this.btcWalletService = null;
|
||||
this.squWalletService = null;
|
||||
this.bsqWalletService = null;
|
||||
this.feeService = null;
|
||||
this.voteItemCollectionsStorage = null;
|
||||
this.compensationRequestManager = null;
|
||||
|
|
|
@ -20,10 +20,10 @@ package io.bitsquare.dao.vote;
|
|||
public enum VotingType {
|
||||
CREATE_OFFER_FEE_IN_BTC((byte) 0x01),
|
||||
TAKE_OFFER_FEE_IN_BTC((byte) 0x02),
|
||||
CREATE_OFFER_FEE_IN_SQU((byte) 0x03),
|
||||
TAKE_OFFER_FEE_IN_SQU((byte) 0x04),
|
||||
CREATE_COMPENSATION_REQUEST_FEE_IN_SQU((byte) 0x05),
|
||||
VOTING_FEE_IN_SQU((byte) 0x06),
|
||||
CREATE_OFFER_FEE_IN_BSQ((byte) 0x03),
|
||||
TAKE_OFFER_FEE_IN_BSQ((byte) 0x04),
|
||||
CREATE_COMPENSATION_REQUEST_FEE_IN_BSQ((byte) 0x05),
|
||||
VOTING_FEE_IN_BSQ((byte) 0x06),
|
||||
|
||||
COMPENSATION_REQUEST_PERIOD_IN_BLOCKS((byte) 0x10),
|
||||
VOTING_PERIOD_IN_BLOCKS((byte) 0x11),
|
||||
|
|
|
@ -83,6 +83,7 @@ public class CurrencyUtil {
|
|||
result.add(new CryptoCurrency("REP", "Augur", true));
|
||||
result.add(new CryptoCurrency("BATL", "Battlestars"));
|
||||
result.add(new CryptoCurrency("BIGUP", "BigUp"));
|
||||
result.add(new CryptoCurrency("BSQ", "bisq Token"));
|
||||
result.add(new CryptoCurrency("BITAUD", "BitAUD", true));
|
||||
result.add(new CryptoCurrency("BITCHF", "BitCHF", true));
|
||||
result.add(new CryptoCurrency("BITCNY", "BitCNY", true));
|
||||
|
@ -92,13 +93,12 @@ public class CurrencyUtil {
|
|||
result.add(new CryptoCurrency("BITNZD", "BitNZD", true));
|
||||
result.add(new CryptoCurrency("BITSEK", "BitSEK", true));
|
||||
result.add(new CryptoCurrency("BITSGD", "BitSGD", true));
|
||||
result.add(new CryptoCurrency("GBYTE", "Byte"));
|
||||
result.add(new CryptoCurrency("SYNQ", "BitSYNQ"));
|
||||
result.add(new CryptoCurrency("BTS", "BitShares"));
|
||||
result.add(new CryptoCurrency("BITUSD", "BitUSD", true));
|
||||
result.add(new CryptoCurrency("BLK", "Blackcoin"));
|
||||
result.add(new CryptoCurrency("BSQ", "bisq Tokens"));
|
||||
result.add(new CryptoCurrency("BURST", "Burstcoin"));
|
||||
result.add(new CryptoCurrency("GBYTE", "Byte"));
|
||||
result.add(new CryptoCurrency("CLAM", "Clams"));
|
||||
result.add(new CryptoCurrency("CLOAK", "CloakCoin"));
|
||||
result.add(new CryptoCurrency("CMT", "Comet"));
|
||||
|
@ -219,6 +219,7 @@ public class CurrencyUtil {
|
|||
|
||||
public static List<CryptoCurrency> getMainCryptoCurrencies() {
|
||||
final List<CryptoCurrency> result = new ArrayList<>();
|
||||
result.add(new CryptoCurrency("BSQ", "bisq Token"));
|
||||
result.add(new CryptoCurrency("XMR", "Monero"));
|
||||
result.add(new CryptoCurrency("ZEC", "Zcash"));
|
||||
result.add(new CryptoCurrency("SC", "Siacoin"));
|
||||
|
@ -227,14 +228,10 @@ public class CurrencyUtil {
|
|||
result.add(new CryptoCurrency("STEEM", "STEEM"));
|
||||
result.add(new CryptoCurrency("MT", "Mycelium Token", true));
|
||||
result.add(new CryptoCurrency("REP", "Augur", true));
|
||||
result.add(new CryptoCurrency("FLO", "FlorinCoin"));
|
||||
result.add(new CryptoCurrency("LTC", "Litecoin"));
|
||||
result.add(new CryptoCurrency("DASH", "Dash"));
|
||||
result.add(new CryptoCurrency("NMC", "Namecoin"));
|
||||
result.add(new CryptoCurrency("NBT", "NuBits"));
|
||||
result.add(new CryptoCurrency("DOGE", "Dogecoin"));
|
||||
result.add(new CryptoCurrency("NXT", "Nxt"));
|
||||
result.add(new CryptoCurrency("BTS", "BitShares"));
|
||||
|
||||
result.sort(TradeCurrency::compareTo);
|
||||
return result;
|
||||
|
|
|
@ -38,13 +38,13 @@ import static junit.framework.Assert.assertTrue;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
*/
|
||||
|
||||
public class SquBlockchainServiceTest {
|
||||
private static final Logger log = LoggerFactory.getLogger(SquBlockchainServiceTest.class);
|
||||
private MockSquBlockchainService squBlockchainService;
|
||||
public class BsqBlockchainServiceTest {
|
||||
private static final Logger log = LoggerFactory.getLogger(BsqBlockchainServiceTest.class);
|
||||
private MockBsqBlockchainService squBlockchainService;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
squBlockchainService = new MockSquBlockchainService();
|
||||
squBlockchainService = new MockBsqBlockchainService();
|
||||
}
|
||||
|
||||
@After
|
||||
|
@ -52,23 +52,23 @@ public class SquBlockchainServiceTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testGenesisBlock() throws SquBlockchainException, BitcoindException, CommunicationException {
|
||||
public void testGenesisBlock() throws BsqBlockchainException, BitcoindException, CommunicationException {
|
||||
int genesisBlockHeight = 0;
|
||||
String genesisTxId = "000000a4d94cb612b5d722d531083f59f317d5dea1db4a191f61b2ab34af2627";
|
||||
buildGenesisBlock(genesisBlockHeight, genesisTxId);
|
||||
Map<String, Map<Integer, SquUTXO>> utxoByTxIdMap = squBlockchainService.parseBlockchain(new HashMap<>(),
|
||||
Map<String, Map<Integer, BsqUTXO>> utxoByTxIdMap = squBlockchainService.parseBlockchain(new HashMap<>(),
|
||||
squBlockchainService.requestChainHeadHeight(),
|
||||
genesisBlockHeight,
|
||||
genesisTxId);
|
||||
SquUTXO squUTXO1 = utxoByTxIdMap.get(genesisTxId).get(0);
|
||||
SquUTXO squUTXO2 = utxoByTxIdMap.get(genesisTxId).get(1);
|
||||
BsqUTXO bsqUTXO1 = utxoByTxIdMap.get(genesisTxId).get(0);
|
||||
BsqUTXO bsqUTXO2 = utxoByTxIdMap.get(genesisTxId).get(1);
|
||||
assertEquals(1, utxoByTxIdMap.size());
|
||||
assertEquals("addressGen1", squUTXO1.getAddress());
|
||||
assertEquals("addressGen2", squUTXO2.getAddress());
|
||||
assertEquals("addressGen1", bsqUTXO1.getAddress());
|
||||
assertEquals("addressGen2", bsqUTXO2.getAddress());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenToTx1Block1() throws SquBlockchainException, BitcoindException, CommunicationException {
|
||||
public void testGenToTx1Block1() throws BsqBlockchainException, BitcoindException, CommunicationException {
|
||||
int genesisBlockHeight = 0;
|
||||
String genesisTxId = "000000a4d94cb612b5d722d531083f59f317d5dea1db4a191f61b2ab34af2627";
|
||||
buildGenesisBlock(genesisBlockHeight, genesisTxId);
|
||||
|
@ -83,20 +83,20 @@ public class SquBlockchainServiceTest {
|
|||
0.00001000,
|
||||
"addressTx1");
|
||||
|
||||
Map<String, Map<Integer, SquUTXO>> utxoByTxIdMap = squBlockchainService.parseBlockchain(new HashMap<>(),
|
||||
Map<String, Map<Integer, BsqUTXO>> utxoByTxIdMap = squBlockchainService.parseBlockchain(new HashMap<>(),
|
||||
squBlockchainService.requestChainHeadHeight(),
|
||||
genesisBlockHeight,
|
||||
genesisTxId);
|
||||
|
||||
SquUTXO squUTXO1 = utxoByTxIdMap.get(genesisTxId).get(0);
|
||||
SquUTXO squUTXO2 = utxoByTxIdMap.get(txId).get(0);
|
||||
BsqUTXO bsqUTXO1 = utxoByTxIdMap.get(genesisTxId).get(0);
|
||||
BsqUTXO bsqUTXO2 = utxoByTxIdMap.get(txId).get(0);
|
||||
assertEquals(2, utxoByTxIdMap.size());
|
||||
assertEquals("addressGen1", squUTXO1.getAddress());
|
||||
assertEquals("addressTx1", squUTXO2.getAddress());
|
||||
assertEquals("addressGen1", bsqUTXO1.getAddress());
|
||||
assertEquals("addressTx1", bsqUTXO2.getAddress());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenToTx1toTx2Block1() throws SquBlockchainException, BitcoindException, CommunicationException {
|
||||
public void testGenToTx1toTx2Block1() throws BsqBlockchainException, BitcoindException, CommunicationException {
|
||||
int genesisBlockHeight = 0;
|
||||
String genesisTxId = "000000a4d94cb612b5d722d531083f59f317d5dea1db4a191f61b2ab34af2627";
|
||||
buildGenesisBlock(genesisBlockHeight, genesisTxId);
|
||||
|
@ -121,20 +121,20 @@ public class SquBlockchainServiceTest {
|
|||
0.00001000,
|
||||
"addressTx2");
|
||||
|
||||
Map<String, Map<Integer, SquUTXO>> utxoByTxIdMap = squBlockchainService.parseBlockchain(new HashMap<>(),
|
||||
Map<String, Map<Integer, BsqUTXO>> utxoByTxIdMap = squBlockchainService.parseBlockchain(new HashMap<>(),
|
||||
squBlockchainService.requestChainHeadHeight(),
|
||||
genesisBlockHeight,
|
||||
genesisTxId);
|
||||
|
||||
SquUTXO squUTXO1 = utxoByTxIdMap.get(genesisTxId).get(0);
|
||||
SquUTXO squUTXO2 = utxoByTxIdMap.get(tx2Id).get(0);
|
||||
BsqUTXO bsqUTXO1 = utxoByTxIdMap.get(genesisTxId).get(0);
|
||||
BsqUTXO bsqUTXO2 = utxoByTxIdMap.get(tx2Id).get(0);
|
||||
assertEquals(2, utxoByTxIdMap.size());
|
||||
assertEquals("addressGen1", squUTXO1.getAddress());
|
||||
assertEquals("addressTx2", squUTXO2.getAddress());
|
||||
assertEquals("addressGen1", bsqUTXO1.getAddress());
|
||||
assertEquals("addressTx2", bsqUTXO2.getAddress());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenToTx1toTx2AndGenToTx2Block1() throws SquBlockchainException, BitcoindException, CommunicationException {
|
||||
public void testGenToTx1toTx2AndGenToTx2Block1() throws BsqBlockchainException, BitcoindException, CommunicationException {
|
||||
int genesisBlockHeight = 0;
|
||||
String genesisTxId = "000000a4d94cb612b5d722d531083f59f317d5dea1db4a191f61b2ab34af2627";
|
||||
buildGenesisBlock(genesisBlockHeight, genesisTxId);
|
||||
|
@ -169,16 +169,16 @@ public class SquBlockchainServiceTest {
|
|||
tx2.setVOut(rawOutputs);
|
||||
|
||||
|
||||
Map<String, Map<Integer, SquUTXO>> utxoByTxIdMap = squBlockchainService.parseBlockchain(new HashMap<>(),
|
||||
Map<String, Map<Integer, BsqUTXO>> utxoByTxIdMap = squBlockchainService.parseBlockchain(new HashMap<>(),
|
||||
squBlockchainService.requestChainHeadHeight(),
|
||||
genesisBlockHeight,
|
||||
genesisTxId);
|
||||
|
||||
SquUTXO squUTXO1 = utxoByTxIdMap.get(tx2Id).get(0);
|
||||
SquUTXO squUTXO2 = utxoByTxIdMap.get(tx2Id).get(1);
|
||||
BsqUTXO bsqUTXO1 = utxoByTxIdMap.get(tx2Id).get(0);
|
||||
BsqUTXO bsqUTXO2 = utxoByTxIdMap.get(tx2Id).get(1);
|
||||
assertEquals(1, utxoByTxIdMap.size());
|
||||
assertEquals("addressTx3a", squUTXO1.getAddress());
|
||||
assertEquals("addressTx3b", squUTXO2.getAddress());
|
||||
assertEquals("addressTx3a", bsqUTXO1.getAddress());
|
||||
assertEquals("addressTx3b", bsqUTXO2.getAddress());
|
||||
}
|
||||
|
||||
|
||||
|
@ -204,7 +204,7 @@ public class SquBlockchainServiceTest {
|
|||
return rawTransaction;
|
||||
}
|
||||
|
||||
private void buildGenesisBlock(int genesisBlockHeight, String genesisTxId) throws SquBlockchainException, BitcoindException, CommunicationException {
|
||||
private void buildGenesisBlock(int genesisBlockHeight, String genesisTxId) throws BsqBlockchainException, BitcoindException, CommunicationException {
|
||||
RawTransaction genesisRawTransaction = getRawTransaction(genesisBlockHeight, genesisTxId);
|
||||
|
||||
List<RawInput> rawInputs = new ArrayList<>();
|
||||
|
@ -258,8 +258,8 @@ public class SquBlockchainServiceTest {
|
|||
}
|
||||
}
|
||||
|
||||
class MockSquBlockchainService extends SquBlockchainRpcService {
|
||||
private static final Logger log = LoggerFactory.getLogger(MockSquBlockchainService.class);
|
||||
class MockBsqBlockchainService extends BsqBlockchainRpcService {
|
||||
private static final Logger log = LoggerFactory.getLogger(MockBsqBlockchainService.class);
|
||||
private List<Block> blocks;
|
||||
private int chainHeadHeight;
|
||||
private String genesisTxId;
|
||||
|
@ -268,7 +268,7 @@ class MockSquBlockchainService extends SquBlockchainRpcService {
|
|||
private Map<Integer, List<RawTransaction>> txsInBlockMap = new HashMap<>();
|
||||
private Map<Integer, List<String>> txIdsInBlockMap = new HashMap<>();
|
||||
|
||||
public MockSquBlockchainService() {
|
||||
public MockBsqBlockchainService() {
|
||||
super(null, null, null, null, null);
|
||||
}
|
||||
|
|
@ -205,7 +205,7 @@ public class BitsquareApp extends Application {
|
|||
showEmptyWalletPopup(injector.getInstance(BtcWalletService.class));
|
||||
} else if (DevFlags.DEV_MODE && new KeyCodeCombination(KeyCode.B, KeyCombination.SHORTCUT_DOWN).match(keyEvent) || new KeyCodeCombination(KeyCode.E, KeyCombination.CONTROL_DOWN).match(keyEvent)) {
|
||||
// BSQ empty wallet not public yet
|
||||
showEmptyWalletPopup(injector.getInstance(SquWalletService.class));
|
||||
showEmptyWalletPopup(injector.getInstance(BsqWalletService.class));
|
||||
} else if (new KeyCodeCombination(KeyCode.M, KeyCombination.ALT_DOWN).match(keyEvent)) {
|
||||
showSendAlertMessagePopup();
|
||||
} else if (new KeyCodeCombination(KeyCode.F, KeyCombination.ALT_DOWN).match(keyEvent)) {
|
||||
|
@ -416,7 +416,7 @@ public class BitsquareApp extends Application {
|
|||
});
|
||||
injector.getInstance(WalletsSetup.class).shutDown();
|
||||
injector.getInstance(BtcWalletService.class).shutDown();
|
||||
injector.getInstance(SquWalletService.class).shutDown();
|
||||
injector.getInstance(BsqWalletService.class).shutDown();
|
||||
});
|
||||
});
|
||||
// we wait max 20 sec.
|
||||
|
|
|
@ -29,7 +29,7 @@ import io.bitsquare.gui.common.view.guice.InjectorViewFactory;
|
|||
import io.bitsquare.gui.main.MainView;
|
||||
import io.bitsquare.gui.main.offer.offerbook.OfferBook;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.gui.util.SQUFormatter;
|
||||
import io.bitsquare.gui.util.BsqFormatter;
|
||||
import io.bitsquare.gui.util.Transitions;
|
||||
import io.bitsquare.gui.util.validation.*;
|
||||
import io.bitsquare.locale.BSResources;
|
||||
|
@ -60,7 +60,7 @@ public class GuiModule extends AppModule {
|
|||
|
||||
bind(OfferBook.class).in(Singleton.class);
|
||||
bind(BSFormatter.class).in(Singleton.class);
|
||||
bind(SQUFormatter.class).in(Singleton.class);
|
||||
bind(BsqFormatter.class).in(Singleton.class);
|
||||
|
||||
bind(IBANValidator.class).in(Singleton.class);
|
||||
bind(BtcValidator.class).in(Singleton.class);
|
||||
|
|
|
@ -96,7 +96,7 @@ public class CryptoCurrencyForm extends PaymentMethodForm {
|
|||
@Override
|
||||
protected void autoFillNameTextField() {
|
||||
if (useCustomAccountNameCheckBox != null && !useCustomAccountNameCheckBox.isSelected()) {
|
||||
String currency = paymentAccount.getSingleTradeCurrency() != null ? paymentAccount.getSingleTradeCurrency().getCode() : "?";
|
||||
String currency = paymentAccount.getSingleTradeCurrency() != null ? paymentAccount.getSingleTradeCurrency().getCode() : "";
|
||||
if (currency != null) {
|
||||
String address = addressInputTextField.getText();
|
||||
address = StringUtils.abbreviate(address, 9);
|
||||
|
@ -120,11 +120,14 @@ public class CryptoCurrencyForm extends PaymentMethodForm {
|
|||
|
||||
@Override
|
||||
public void updateAllInputsValid() {
|
||||
altCoinAddressValidator.setCurrencyCode(cryptoCurrencyAccount.getSelectedTradeCurrency().getCode());
|
||||
TradeCurrency selectedTradeCurrency = cryptoCurrencyAccount.getSelectedTradeCurrency();
|
||||
if (selectedTradeCurrency != null) {
|
||||
altCoinAddressValidator.setCurrencyCode(selectedTradeCurrency.getCode());
|
||||
allInputsValid.set(isAccountNameValid()
|
||||
&& altCoinAddressValidator.validate(cryptoCurrencyAccount.getAddress()).isValid
|
||||
&& cryptoCurrencyAccount.getSingleTradeCurrency() != null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addTradeCurrencyComboBox() {
|
||||
|
|
|
@ -42,7 +42,7 @@ import io.bitsquare.common.Timer;
|
|||
import io.bitsquare.common.UserThread;
|
||||
import io.bitsquare.common.crypto.*;
|
||||
import io.bitsquare.dao.DaoManager;
|
||||
import io.bitsquare.dao.blockchain.SquBlockchainException;
|
||||
import io.bitsquare.dao.blockchain.BsqBlockchainException;
|
||||
import io.bitsquare.filter.FilterManager;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.common.model.ViewModel;
|
||||
|
@ -551,7 +551,7 @@ public class MainViewModel implements ViewModel {
|
|||
|
||||
try {
|
||||
daoManager.onAllServicesInitialized();
|
||||
} catch (SquBlockchainException e) {
|
||||
} catch (BsqBlockchainException e) {
|
||||
new Popup<>().error(e.toString()).show();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0"
|
||||
xmlns:fx="http://javafx.com/fxml">
|
||||
|
||||
<Tab fx:id="tokenWalletTab" text="Token wallet" closable="false"/>
|
||||
<Tab fx:id="bsqWalletTab" text="BSQ wallet" closable="false"/>
|
||||
<Tab fx:id="CompensationTab" text="Compensation" closable="false"/>
|
||||
<Tab fx:id="votingTab" text="Voting" closable="false"/>
|
||||
</TabPane>
|
||||
|
|
|
@ -17,15 +17,15 @@
|
|||
|
||||
package io.bitsquare.gui.main.dao;
|
||||
|
||||
import io.bitsquare.btc.wallet.SquWalletService;
|
||||
import io.bitsquare.btc.wallet.BsqWalletService;
|
||||
import io.bitsquare.gui.Navigation;
|
||||
import io.bitsquare.gui.common.model.Activatable;
|
||||
import io.bitsquare.gui.common.view.*;
|
||||
import io.bitsquare.gui.main.MainView;
|
||||
import io.bitsquare.gui.main.dao.compensation.CompensationView;
|
||||
import io.bitsquare.gui.main.dao.voting.VotingView;
|
||||
import io.bitsquare.gui.main.dao.wallet.TokenWalletView;
|
||||
import io.bitsquare.gui.main.dao.wallet.dashboard.TokenDashboardView;
|
||||
import io.bitsquare.gui.main.dao.wallet.BsqWalletView;
|
||||
import io.bitsquare.gui.main.dao.wallet.dashboard.BsqDashboardView;
|
||||
import io.bitsquare.user.Preferences;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.fxml.FXML;
|
||||
|
@ -38,7 +38,7 @@ import javax.inject.Inject;
|
|||
public class DaoView extends ActivatableViewAndModel<TabPane, Activatable> {
|
||||
|
||||
@FXML
|
||||
Tab tokenWalletTab, CompensationTab, votingTab;
|
||||
Tab bsqWalletTab, CompensationTab, votingTab;
|
||||
|
||||
private Navigation.Listener navigationListener;
|
||||
private ChangeListener<Tab> tabChangeListener;
|
||||
|
@ -46,17 +46,17 @@ public class DaoView extends ActivatableViewAndModel<TabPane, Activatable> {
|
|||
private final ViewLoader viewLoader;
|
||||
private final Navigation navigation;
|
||||
private Preferences preferences;
|
||||
private SquWalletService squWalletService;
|
||||
private BsqWalletService bsqWalletService;
|
||||
private Tab selectedTab;
|
||||
private TokenWalletView tokenWalletView;
|
||||
private BsqWalletView bsqWalletView;
|
||||
|
||||
|
||||
@Inject
|
||||
private DaoView(CachingViewLoader viewLoader, Navigation navigation, Preferences preferences, SquWalletService squWalletService) {
|
||||
private DaoView(CachingViewLoader viewLoader, Navigation navigation, Preferences preferences, BsqWalletService bsqWalletService) {
|
||||
this.viewLoader = viewLoader;
|
||||
this.navigation = navigation;
|
||||
this.preferences = preferences;
|
||||
this.squWalletService = squWalletService;
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -64,19 +64,19 @@ public class DaoView extends ActivatableViewAndModel<TabPane, Activatable> {
|
|||
navigationListener = viewPath -> {
|
||||
if (viewPath.size() == 3 && viewPath.indexOf(DaoView.class) == 1) {
|
||||
if (CompensationTab == null && viewPath.get(2).equals(CompensationView.class))
|
||||
navigation.navigateTo(MainView.class, DaoView.class, TokenWalletView.class, TokenDashboardView.class);
|
||||
navigation.navigateTo(MainView.class, DaoView.class, BsqWalletView.class, BsqDashboardView.class);
|
||||
else
|
||||
loadView(viewPath.tip());
|
||||
}
|
||||
};
|
||||
|
||||
tabChangeListener = (ov, oldValue, newValue) -> {
|
||||
if (newValue == tokenWalletTab) {
|
||||
Class<? extends View> selectedViewClass = tokenWalletView.getSelectedViewClass();
|
||||
if (newValue == bsqWalletTab) {
|
||||
Class<? extends View> selectedViewClass = bsqWalletView.getSelectedViewClass();
|
||||
if (selectedViewClass == null)
|
||||
navigation.navigateTo(MainView.class, DaoView.class, TokenWalletView.class, TokenDashboardView.class);
|
||||
navigation.navigateTo(MainView.class, DaoView.class, BsqWalletView.class, BsqDashboardView.class);
|
||||
else
|
||||
navigation.navigateTo(MainView.class, DaoView.class, TokenWalletView.class, selectedViewClass);
|
||||
navigation.navigateTo(MainView.class, DaoView.class, BsqWalletView.class, selectedViewClass);
|
||||
} else if (newValue == CompensationTab) {
|
||||
navigation.navigateTo(MainView.class, DaoView.class, CompensationView.class);
|
||||
} else if (newValue == votingTab) {
|
||||
|
@ -92,8 +92,8 @@ public class DaoView extends ActivatableViewAndModel<TabPane, Activatable> {
|
|||
|
||||
if (navigation.getCurrentPath().size() == 2 && navigation.getCurrentPath().get(1) == DaoView.class) {
|
||||
Tab selectedItem = root.getSelectionModel().getSelectedItem();
|
||||
if (selectedItem == tokenWalletTab)
|
||||
navigation.navigateTo(MainView.class, DaoView.class, TokenWalletView.class);
|
||||
if (selectedItem == bsqWalletTab)
|
||||
navigation.navigateTo(MainView.class, DaoView.class, BsqWalletView.class);
|
||||
else if (selectedItem == CompensationTab)
|
||||
navigation.navigateTo(MainView.class, DaoView.class, CompensationView.class);
|
||||
else if (selectedItem == votingTab)
|
||||
|
@ -109,9 +109,9 @@ public class DaoView extends ActivatableViewAndModel<TabPane, Activatable> {
|
|||
|
||||
private void loadView(Class<? extends View> viewClass) {
|
||||
View view = viewLoader.load(viewClass);
|
||||
if (view instanceof TokenWalletView) {
|
||||
selectedTab = tokenWalletTab;
|
||||
tokenWalletView = (TokenWalletView) view;
|
||||
if (view instanceof BsqWalletView) {
|
||||
selectedTab = bsqWalletTab;
|
||||
bsqWalletView = (BsqWalletView) view;
|
||||
} else if (view instanceof CompensationView) {
|
||||
selectedTab = CompensationTab;
|
||||
} else if (view instanceof VotingView) {
|
||||
|
|
|
@ -23,9 +23,9 @@ import io.bitsquare.btc.InsufficientFundsException;
|
|||
import io.bitsquare.btc.exceptions.TransactionVerificationException;
|
||||
import io.bitsquare.btc.exceptions.WalletException;
|
||||
import io.bitsquare.btc.provider.fee.FeeService;
|
||||
import io.bitsquare.btc.wallet.BsqWalletService;
|
||||
import io.bitsquare.btc.wallet.BtcWalletService;
|
||||
import io.bitsquare.btc.wallet.ChangeBelowDustException;
|
||||
import io.bitsquare.btc.wallet.SquWalletService;
|
||||
import io.bitsquare.common.crypto.KeyRing;
|
||||
import io.bitsquare.common.util.MathUtils;
|
||||
import io.bitsquare.common.util.Utilities;
|
||||
|
@ -64,7 +64,7 @@ public class CreateCompensationRequestView extends ActivatableView<GridPane, Voi
|
|||
private Button createButton;
|
||||
|
||||
private final PublicKey p2pStorageSignaturePubKey;
|
||||
private final SquWalletService squWalletService;
|
||||
private final BsqWalletService bsqWalletService;
|
||||
private final BtcWalletService btcWalletService;
|
||||
private final FeeService feeService;
|
||||
private final CompensationRequestManager compensationRequestManager;
|
||||
|
@ -79,9 +79,9 @@ public class CreateCompensationRequestView extends ActivatableView<GridPane, Voi
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private CreateCompensationRequestView(SquWalletService squWalletService, BtcWalletService btcWalletService, FeeService feeService,
|
||||
private CreateCompensationRequestView(BsqWalletService bsqWalletService, BtcWalletService btcWalletService, FeeService feeService,
|
||||
CompensationRequestManager compensationRequestManager, P2PService p2PService, KeyRing keyRing, BSFormatter btcFormatter) {
|
||||
this.squWalletService = squWalletService;
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
this.btcWalletService = btcWalletService;
|
||||
this.feeService = feeService;
|
||||
this.compensationRequestManager = compensationRequestManager;
|
||||
|
@ -127,22 +127,22 @@ public class CreateCompensationRequestView extends ActivatableView<GridPane, Voi
|
|||
|
||||
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
|
||||
Coin createCompensationRequestFee = feeService.getCreateCompensationRequestFee();
|
||||
Transaction preparedSendTx = squWalletService.getPreparedBurnFeeTx(createCompensationRequestFee);
|
||||
Transaction preparedSendTx = bsqWalletService.getPreparedBurnFeeTx(createCompensationRequestFee);
|
||||
|
||||
checkArgument(!preparedSendTx.getInputs().isEmpty(), "preparedSendTx inputs must not be empty");
|
||||
|
||||
// We use the key of the first BSQ input for signing the data
|
||||
TransactionOutput connectedOutput = preparedSendTx.getInputs().get(0).getConnectedOutput();
|
||||
checkNotNull(connectedOutput, "connectedOutput must not be null");
|
||||
DeterministicKey squKeyPair = squWalletService.findKeyFromPubKeyHash(connectedOutput.getScriptPubKey().getPubKeyHash());
|
||||
checkNotNull(squKeyPair, "squKeyPair must not be null");
|
||||
DeterministicKey bsqKeyPair = bsqWalletService.findKeyFromPubKeyHash(connectedOutput.getScriptPubKey().getPubKeyHash());
|
||||
checkNotNull(bsqKeyPair, "bsqKeyPair must not be null");
|
||||
|
||||
// We get the JSON of the object excluding signature and feeTxId
|
||||
String payloadAsJson = StringUtils.deleteWhitespace(Utilities.objectToJson(compensationRequestPayload));
|
||||
log.error(payloadAsJson);
|
||||
// Signs a text message using the standard Bitcoin messaging signing format and returns the signature as a base64
|
||||
// encoded string.
|
||||
String signature = squKeyPair.signMessage(payloadAsJson);
|
||||
String signature = bsqKeyPair.signMessage(payloadAsJson);
|
||||
compensationRequestPayload.setSignature(signature);
|
||||
|
||||
String dataAndSig = payloadAsJson + signature;
|
||||
|
@ -154,8 +154,8 @@ public class CreateCompensationRequestView extends ActivatableView<GridPane, Voi
|
|||
|
||||
|
||||
//TODO 1 Btc output (small payment to own compensation receiving address)
|
||||
Transaction txWithBtcFee = btcWalletService.completePreparedSquTx(preparedSendTx, false, hash);
|
||||
Transaction signedTx = squWalletService.signTx(txWithBtcFee);
|
||||
Transaction txWithBtcFee = btcWalletService.completePreparedBsqTx(preparedSendTx, false, hash);
|
||||
Transaction signedTx = bsqWalletService.signTx(txWithBtcFee);
|
||||
Coin miningFee = signedTx.getFee();
|
||||
int txSize = signedTx.bitcoinSerialize().length;
|
||||
new Popup().headLine("Confirm compensation request fee payment transaction")
|
||||
|
@ -168,11 +168,11 @@ public class CreateCompensationRequestView extends ActivatableView<GridPane, Voi
|
|||
.actionButtonText("Yes")
|
||||
.onAction(() -> {
|
||||
try {
|
||||
squWalletService.commitTx(txWithBtcFee);
|
||||
bsqWalletService.commitTx(txWithBtcFee);
|
||||
// We need to create another instance, otherwise the tx would trigger an invalid state exception
|
||||
// if it gets committed 2 times
|
||||
btcWalletService.commitTx(btcWalletService.getClonedTransaction(txWithBtcFee));
|
||||
squWalletService.broadcastTx(signedTx, new FutureCallback<Transaction>() {
|
||||
bsqWalletService.broadcastTx(signedTx, new FutureCallback<Transaction>() {
|
||||
@Override
|
||||
public void onSuccess(@Nullable Transaction transaction) {
|
||||
checkNotNull(transaction, "Transaction must not be null at broadcastTx callback.");
|
||||
|
|
|
@ -22,9 +22,9 @@ import io.bitsquare.btc.InsufficientFundsException;
|
|||
import io.bitsquare.btc.exceptions.TransactionVerificationException;
|
||||
import io.bitsquare.btc.exceptions.WalletException;
|
||||
import io.bitsquare.btc.provider.fee.FeeService;
|
||||
import io.bitsquare.btc.wallet.BsqWalletService;
|
||||
import io.bitsquare.btc.wallet.BtcWalletService;
|
||||
import io.bitsquare.btc.wallet.ChangeBelowDustException;
|
||||
import io.bitsquare.btc.wallet.SquWalletService;
|
||||
import io.bitsquare.common.UserThread;
|
||||
import io.bitsquare.common.util.MathUtils;
|
||||
import io.bitsquare.dao.compensation.CompensationRequest;
|
||||
|
@ -35,8 +35,8 @@ import io.bitsquare.gui.common.view.FxmlView;
|
|||
import io.bitsquare.gui.components.TitledGroupBg;
|
||||
import io.bitsquare.gui.main.overlays.popups.Popup;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.gui.util.BsqFormatter;
|
||||
import io.bitsquare.gui.util.Layout;
|
||||
import io.bitsquare.gui.util.SQUFormatter;
|
||||
import javafx.beans.property.DoubleProperty;
|
||||
import javafx.beans.property.SimpleDoubleProperty;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
|
@ -71,10 +71,10 @@ public class VoteView extends ActivatableView<GridPane, Void> {
|
|||
|
||||
private int gridRow = 0;
|
||||
private CompensationRequestManager compensationRequestManager;
|
||||
private SquWalletService squWalletService;
|
||||
private BsqWalletService bsqWalletService;
|
||||
private BtcWalletService btcWalletService;
|
||||
private FeeService feeService;
|
||||
private SQUFormatter squFormatter;
|
||||
private BsqFormatter bsqFormatter;
|
||||
private BSFormatter btcFormatter;
|
||||
private VotingManager voteManager;
|
||||
private Button voteButton;
|
||||
|
@ -92,14 +92,14 @@ public class VoteView extends ActivatableView<GridPane, Void> {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private VoteView(CompensationRequestManager compensationRequestManager, SquWalletService squWalletService,
|
||||
BtcWalletService btcWalletService, FeeService feeService, SQUFormatter squFormatter,
|
||||
private VoteView(CompensationRequestManager compensationRequestManager, BsqWalletService bsqWalletService,
|
||||
BtcWalletService btcWalletService, FeeService feeService, BsqFormatter bsqFormatter,
|
||||
BSFormatter btcFormatter, VotingManager voteManager) {
|
||||
this.compensationRequestManager = compensationRequestManager;
|
||||
this.squWalletService = squWalletService;
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
this.btcWalletService = btcWalletService;
|
||||
this.feeService = feeService;
|
||||
this.squFormatter = squFormatter;
|
||||
this.bsqFormatter = bsqFormatter;
|
||||
this.btcFormatter = btcFormatter;
|
||||
this.voteManager = voteManager;
|
||||
}
|
||||
|
@ -212,9 +212,9 @@ public class VoteView extends ActivatableView<GridPane, Void> {
|
|||
byte[] opReturnData = voteManager.calculateOpReturnData(voteItemsList);
|
||||
try {
|
||||
Coin votingTxFee = feeService.getVotingTxFee();
|
||||
Transaction preparedVotingTx = squWalletService.getPreparedBurnFeeTx(votingTxFee);
|
||||
Transaction txWithBtcFee = btcWalletService.completePreparedSquTx(preparedVotingTx, false, opReturnData);
|
||||
Transaction signedTx = squWalletService.signTx(txWithBtcFee);
|
||||
Transaction preparedVotingTx = bsqWalletService.getPreparedBurnFeeTx(votingTxFee);
|
||||
Transaction txWithBtcFee = btcWalletService.completePreparedBsqTx(preparedVotingTx, false, opReturnData);
|
||||
Transaction signedTx = bsqWalletService.signTx(txWithBtcFee);
|
||||
Coin miningFee = signedTx.getFee();
|
||||
int txSize = signedTx.bitcoinSerialize().length;
|
||||
new Popup().headLine("Confirm voting fee payment transaction")
|
||||
|
@ -227,11 +227,11 @@ public class VoteView extends ActivatableView<GridPane, Void> {
|
|||
.actionButtonText("Yes")
|
||||
.onAction(() -> {
|
||||
try {
|
||||
squWalletService.commitTx(txWithBtcFee);
|
||||
bsqWalletService.commitTx(txWithBtcFee);
|
||||
// We need to create another instance, otherwise the tx would trigger an invalid state exception
|
||||
// if it gets committed 2 times
|
||||
btcWalletService.commitTx(btcWalletService.getClonedTransaction(txWithBtcFee));
|
||||
squWalletService.broadcastTx(signedTx, new FutureCallback<Transaction>() {
|
||||
bsqWalletService.broadcastTx(signedTx, new FutureCallback<Transaction>() {
|
||||
@Override
|
||||
public void onSuccess(@Nullable Transaction transaction) {
|
||||
checkNotNull(transaction, "Transaction must not be null at doSend callback.");
|
||||
|
|
|
@ -17,9 +17,9 @@
|
|||
|
||||
package io.bitsquare.gui.main.dao.wallet;
|
||||
|
||||
import io.bitsquare.btc.wallet.SquWalletService;
|
||||
import io.bitsquare.btc.wallet.BsqWalletService;
|
||||
import io.bitsquare.gui.main.overlays.popups.Popup;
|
||||
import io.bitsquare.gui.util.SQUFormatter;
|
||||
import io.bitsquare.gui.util.BsqFormatter;
|
||||
import javafx.scene.control.TextField;
|
||||
import org.bitcoinj.core.*;
|
||||
import org.bitcoinj.script.Script;
|
||||
|
@ -32,8 +32,8 @@ import java.util.List;
|
|||
public class BalanceUtil {
|
||||
private static final Logger log = LoggerFactory.getLogger(BalanceUtil.class);
|
||||
|
||||
private final SquWalletService squWalletService;
|
||||
private final SQUFormatter formatter;
|
||||
private final BsqWalletService bsqWalletService;
|
||||
private final BsqFormatter formatter;
|
||||
private TextField balanceTextField;
|
||||
private WalletEventListener walletEventListener;
|
||||
|
||||
|
@ -42,8 +42,8 @@ public class BalanceUtil {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private BalanceUtil(SquWalletService squWalletService, SQUFormatter formatter) {
|
||||
this.squWalletService = squWalletService;
|
||||
private BalanceUtil(BsqWalletService bsqWalletService, BsqFormatter formatter) {
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
this.formatter = formatter;
|
||||
}
|
||||
|
||||
|
@ -91,8 +91,8 @@ public class BalanceUtil {
|
|||
}
|
||||
|
||||
private void requestUtxo() {
|
||||
squWalletService.requestSquUtxo(() -> {
|
||||
balanceTextField.setText(formatter.formatCoinWithCode(squWalletService.getAvailableBalance()));
|
||||
bsqWalletService.requestBsqUtxo(() -> {
|
||||
balanceTextField.setText(formatter.formatCoinWithCode(bsqWalletService.getAvailableBalance()));
|
||||
}, errorMessage -> {
|
||||
new Popup<>().warning(errorMessage);
|
||||
});
|
||||
|
@ -100,11 +100,11 @@ public class BalanceUtil {
|
|||
|
||||
public void activate() {
|
||||
requestUtxo();
|
||||
squWalletService.addEventListener(walletEventListener);
|
||||
bsqWalletService.addEventListener(walletEventListener);
|
||||
}
|
||||
|
||||
public void deactivate() {
|
||||
squWalletService.removeEventListener(walletEventListener);
|
||||
bsqWalletService.removeEventListener(walletEventListener);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
|
||||
<?import javafx.scene.layout.*?>
|
||||
<AnchorPane fx:id="root" fx:controller="io.bitsquare.gui.main.dao.wallet.TokenWalletView"
|
||||
<AnchorPane fx:id="root" fx:controller="io.bitsquare.gui.main.dao.wallet.BsqWalletView"
|
||||
prefHeight="660.0" prefWidth="1000.0"
|
||||
xmlns:fx="http://javafx.com/fxml">
|
||||
|
|
@ -23,10 +23,10 @@ import io.bitsquare.gui.Navigation;
|
|||
import io.bitsquare.gui.common.view.*;
|
||||
import io.bitsquare.gui.main.MainView;
|
||||
import io.bitsquare.gui.main.dao.DaoView;
|
||||
import io.bitsquare.gui.main.dao.wallet.dashboard.TokenDashboardView;
|
||||
import io.bitsquare.gui.main.dao.wallet.receive.TokenReceiveView;
|
||||
import io.bitsquare.gui.main.dao.wallet.send.TokenSendView;
|
||||
import io.bitsquare.gui.main.dao.wallet.tx.TokenTransactionsView;
|
||||
import io.bitsquare.gui.main.dao.wallet.dashboard.BsqDashboardView;
|
||||
import io.bitsquare.gui.main.dao.wallet.receive.BsqReceiveView;
|
||||
import io.bitsquare.gui.main.dao.wallet.send.BsqSendView;
|
||||
import io.bitsquare.gui.main.dao.wallet.tx.BsqTransactionsView;
|
||||
import io.bitsquare.gui.util.Colors;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
import javafx.fxml.FXML;
|
||||
|
@ -42,7 +42,7 @@ import javafx.scene.paint.Paint;
|
|||
import javax.inject.Inject;
|
||||
|
||||
@FxmlView
|
||||
public class TokenWalletView extends ActivatableViewAndModel {
|
||||
public class BsqWalletView extends ActivatableViewAndModel {
|
||||
|
||||
private final ViewLoader viewLoader;
|
||||
private final Navigation navigation;
|
||||
|
@ -58,7 +58,7 @@ public class TokenWalletView extends ActivatableViewAndModel {
|
|||
private Class<? extends View> selectedViewClass;
|
||||
|
||||
@Inject
|
||||
private TokenWalletView(CachingViewLoader viewLoader, Navigation navigation) {
|
||||
private BsqWalletView(CachingViewLoader viewLoader, Navigation navigation) {
|
||||
this.viewLoader = viewLoader;
|
||||
this.navigation = navigation;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class TokenWalletView extends ActivatableViewAndModel {
|
|||
@Override
|
||||
public void initialize() {
|
||||
listener = viewPath -> {
|
||||
if (viewPath.size() != 4 || viewPath.indexOf(TokenWalletView.class) != 2)
|
||||
if (viewPath.size() != 4 || viewPath.indexOf(BsqWalletView.class) != 2)
|
||||
return;
|
||||
|
||||
selectedViewClass = viewPath.tip();
|
||||
|
@ -74,10 +74,10 @@ public class TokenWalletView extends ActivatableViewAndModel {
|
|||
};
|
||||
|
||||
ToggleGroup toggleGroup = new ToggleGroup();
|
||||
dashboard = new MenuItem(navigation, toggleGroup, "Dashboard", TokenDashboardView.class, AwesomeIcon.DASHBOARD);
|
||||
send = new MenuItem(navigation, toggleGroup, "Send", TokenSendView.class, AwesomeIcon.SIGNOUT);
|
||||
receive = new MenuItem(navigation, toggleGroup, "Receive", TokenReceiveView.class, AwesomeIcon.SIGNIN);
|
||||
transactions = new MenuItem(navigation, toggleGroup, "Transactions", TokenTransactionsView.class, AwesomeIcon.TABLE);
|
||||
dashboard = new MenuItem(navigation, toggleGroup, "Dashboard", BsqDashboardView.class, AwesomeIcon.DASHBOARD);
|
||||
send = new MenuItem(navigation, toggleGroup, "Send", BsqSendView.class, AwesomeIcon.SIGNOUT);
|
||||
receive = new MenuItem(navigation, toggleGroup, "Receive", BsqReceiveView.class, AwesomeIcon.SIGNIN);
|
||||
transactions = new MenuItem(navigation, toggleGroup, "Transactions", BsqTransactionsView.class, AwesomeIcon.TABLE);
|
||||
leftVBox.getChildren().addAll(dashboard, send, receive, transactions);
|
||||
}
|
||||
|
||||
|
@ -90,14 +90,14 @@ public class TokenWalletView extends ActivatableViewAndModel {
|
|||
|
||||
navigation.addListener(listener);
|
||||
ViewPath viewPath = navigation.getCurrentPath();
|
||||
if (viewPath.size() == 3 && viewPath.indexOf(TokenWalletView.class) == 2 ||
|
||||
if (viewPath.size() == 3 && viewPath.indexOf(BsqWalletView.class) == 2 ||
|
||||
viewPath.size() == 2 && viewPath.indexOf(DaoView.class) == 1) {
|
||||
if (selectedViewClass == null)
|
||||
selectedViewClass = TokenDashboardView.class;
|
||||
selectedViewClass = BsqDashboardView.class;
|
||||
|
||||
loadView(selectedViewClass);
|
||||
|
||||
} else if (viewPath.size() == 4 && viewPath.indexOf(TokenWalletView.class) == 2) {
|
||||
} else if (viewPath.size() == 4 && viewPath.indexOf(BsqWalletView.class) == 2) {
|
||||
selectedViewClass = viewPath.get(3);
|
||||
loadView(selectedViewClass);
|
||||
}
|
||||
|
@ -117,10 +117,10 @@ public class TokenWalletView extends ActivatableViewAndModel {
|
|||
View view = viewLoader.load(viewClass);
|
||||
content.getChildren().setAll(view.getRoot());
|
||||
|
||||
if (view instanceof TokenDashboardView) dashboard.setSelected(true);
|
||||
else if (view instanceof TokenSendView) send.setSelected(true);
|
||||
else if (view instanceof TokenReceiveView) receive.setSelected(true);
|
||||
else if (view instanceof TokenTransactionsView) transactions.setSelected(true);
|
||||
if (view instanceof BsqDashboardView) dashboard.setSelected(true);
|
||||
else if (view instanceof BsqSendView) send.setSelected(true);
|
||||
else if (view instanceof BsqReceiveView) receive.setSelected(true);
|
||||
else if (view instanceof BsqTransactionsView) transactions.setSelected(true);
|
||||
}
|
||||
|
||||
public Class<? extends View> getSelectedViewClass() {
|
||||
|
@ -178,7 +178,7 @@ class MenuItem extends ToggleButton {
|
|||
}
|
||||
|
||||
public void activate() {
|
||||
setOnAction((event) -> navigation.navigateTo(MainView.class, DaoView.class, TokenWalletView.class, viewClass));
|
||||
setOnAction((event) -> navigation.navigateTo(MainView.class, DaoView.class, BsqWalletView.class, viewClass));
|
||||
selectedProperty().addListener(selectedPropertyChangeListener);
|
||||
disableProperty().addListener(disablePropertyChangeListener);
|
||||
}
|
|
@ -18,7 +18,7 @@
|
|||
-->
|
||||
|
||||
<?import javafx.scene.layout.*?>
|
||||
<GridPane fx:id="root" fx:controller="io.bitsquare.gui.main.dao.wallet.dashboard.TokenDashboardView"
|
||||
<GridPane fx:id="root" fx:controller="io.bitsquare.gui.main.dao.wallet.dashboard.BsqDashboardView"
|
||||
hgap="5.0" vgap="5.0"
|
||||
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="-10.0"
|
|
@ -17,12 +17,12 @@
|
|||
|
||||
package io.bitsquare.gui.main.dao.wallet.dashboard;
|
||||
|
||||
import io.bitsquare.btc.wallet.SquWalletService;
|
||||
import io.bitsquare.btc.wallet.BsqWalletService;
|
||||
import io.bitsquare.gui.common.view.ActivatableView;
|
||||
import io.bitsquare.gui.common.view.FxmlView;
|
||||
import io.bitsquare.gui.main.dao.wallet.BalanceUtil;
|
||||
import io.bitsquare.gui.util.BsqFormatter;
|
||||
import io.bitsquare.gui.util.Layout;
|
||||
import io.bitsquare.gui.util.SQUFormatter;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.GridPane;
|
||||
|
||||
|
@ -32,12 +32,12 @@ import static io.bitsquare.gui.util.FormBuilder.addLabelTextField;
|
|||
import static io.bitsquare.gui.util.FormBuilder.addTitledGroupBg;
|
||||
|
||||
@FxmlView
|
||||
public class TokenDashboardView extends ActivatableView<GridPane, Void> {
|
||||
public class BsqDashboardView extends ActivatableView<GridPane, Void> {
|
||||
|
||||
private TextField balanceTextField;
|
||||
|
||||
private final SquWalletService squWalletService;
|
||||
private final SQUFormatter formatter;
|
||||
private final BsqWalletService bsqWalletService;
|
||||
private final BsqFormatter formatter;
|
||||
private BalanceUtil balanceUtil;
|
||||
|
||||
private final int gridRow = 0;
|
||||
|
@ -47,8 +47,8 @@ public class TokenDashboardView extends ActivatableView<GridPane, Void> {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private TokenDashboardView(SquWalletService squWalletService, SQUFormatter formatter, BalanceUtil balanceUtil) {
|
||||
this.squWalletService = squWalletService;
|
||||
private BsqDashboardView(BsqWalletService bsqWalletService, BsqFormatter formatter, BalanceUtil balanceUtil) {
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
this.formatter = formatter;
|
||||
|
||||
this.balanceUtil = balanceUtil;
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
|
||||
<?import javafx.scene.layout.*?>
|
||||
<GridPane fx:id="root" fx:controller="io.bitsquare.gui.main.dao.wallet.receive.TokenReceiveView"
|
||||
<GridPane fx:id="root" fx:controller="io.bitsquare.gui.main.dao.wallet.receive.BsqReceiveView"
|
||||
hgap="5.0" vgap="5.0"
|
||||
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="-10.0"
|
|
@ -18,7 +18,7 @@
|
|||
package io.bitsquare.gui.main.dao.wallet.receive;
|
||||
|
||||
import io.bitsquare.app.DevFlags;
|
||||
import io.bitsquare.btc.wallet.SquWalletService;
|
||||
import io.bitsquare.btc.wallet.BsqWalletService;
|
||||
import io.bitsquare.common.UserThread;
|
||||
import io.bitsquare.gui.common.view.ActivatableView;
|
||||
import io.bitsquare.gui.common.view.FxmlView;
|
||||
|
@ -26,9 +26,9 @@ import io.bitsquare.gui.components.AddressTextField;
|
|||
import io.bitsquare.gui.components.InputTextField;
|
||||
import io.bitsquare.gui.main.dao.wallet.BalanceUtil;
|
||||
import io.bitsquare.gui.main.overlays.windows.QRCodeWindow;
|
||||
import io.bitsquare.gui.util.BsqFormatter;
|
||||
import io.bitsquare.gui.util.GUIUtil;
|
||||
import io.bitsquare.gui.util.Layout;
|
||||
import io.bitsquare.gui.util.SQUFormatter;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.Tooltip;
|
||||
|
@ -49,15 +49,15 @@ import java.util.concurrent.TimeUnit;
|
|||
import static io.bitsquare.gui.util.FormBuilder.*;
|
||||
|
||||
@FxmlView
|
||||
public class TokenReceiveView extends ActivatableView<GridPane, Void> {
|
||||
public class BsqReceiveView extends ActivatableView<GridPane, Void> {
|
||||
|
||||
private ImageView qrCodeImageView;
|
||||
private AddressTextField addressTextField;
|
||||
private InputTextField amountTextField;
|
||||
private TextField balanceTextField;
|
||||
|
||||
private final SquWalletService squWalletService;
|
||||
private final SQUFormatter formatter;
|
||||
private final BsqWalletService bsqWalletService;
|
||||
private final BsqFormatter formatter;
|
||||
private BalanceUtil balanceUtil;
|
||||
|
||||
private int gridRow = 0;
|
||||
|
@ -70,11 +70,11 @@ public class TokenReceiveView extends ActivatableView<GridPane, Void> {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private TokenReceiveView(SquWalletService squWalletService, SQUFormatter formatter, BalanceUtil balanceUtil) {
|
||||
this.squWalletService = squWalletService;
|
||||
private BsqReceiveView(BsqWalletService bsqWalletService, BsqFormatter formatter, BalanceUtil balanceUtil) {
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
this.formatter = formatter;
|
||||
this.balanceUtil = balanceUtil;
|
||||
paymentLabelString = "Fund Bitsquare token wallet";
|
||||
paymentLabelString = "Fund Bitsquare BSQ wallet";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -84,7 +84,7 @@ public class TokenReceiveView extends ActivatableView<GridPane, Void> {
|
|||
balanceUtil.setBalanceTextField(balanceTextField);
|
||||
balanceUtil.initialize();
|
||||
|
||||
addTitledGroupBg(root, ++gridRow, 3, "Fund your token wallet", Layout.GROUP_DISTANCE);
|
||||
addTitledGroupBg(root, ++gridRow, 3, "Fund your BSQ wallet", Layout.GROUP_DISTANCE);
|
||||
|
||||
qrCodeImageView = new ImageView();
|
||||
qrCodeImageView.setStyle("-fx-cursor: hand;");
|
||||
|
@ -115,7 +115,7 @@ public class TokenReceiveView extends ActivatableView<GridPane, Void> {
|
|||
() -> new QRCodeWindow(getBitcoinURI()).show(),
|
||||
200, TimeUnit.MILLISECONDS)
|
||||
));
|
||||
addressTextField.setAddress(squWalletService.freshReceiveAddress().toString());
|
||||
addressTextField.setAddress(bsqWalletService.freshReceiveAddress().toString());
|
||||
updateQRCode();
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
|
||||
<?import javafx.scene.layout.*?>
|
||||
<GridPane fx:id="root" fx:controller="io.bitsquare.gui.main.dao.wallet.send.TokenSendView"
|
||||
<GridPane fx:id="root" fx:controller="io.bitsquare.gui.main.dao.wallet.send.BsqSendView"
|
||||
hgap="5.0" vgap="5.0"
|
||||
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="-10.0"
|
|
@ -23,8 +23,8 @@ import io.bitsquare.btc.InsufficientFundsException;
|
|||
import io.bitsquare.btc.exceptions.TransactionVerificationException;
|
||||
import io.bitsquare.btc.exceptions.WalletException;
|
||||
import io.bitsquare.btc.provider.fee.FeeService;
|
||||
import io.bitsquare.btc.wallet.BsqWalletService;
|
||||
import io.bitsquare.btc.wallet.BtcWalletService;
|
||||
import io.bitsquare.btc.wallet.SquWalletService;
|
||||
import io.bitsquare.common.util.MathUtils;
|
||||
import io.bitsquare.gui.common.view.ActivatableView;
|
||||
import io.bitsquare.gui.common.view.FxmlView;
|
||||
|
@ -32,8 +32,8 @@ import io.bitsquare.gui.components.InputTextField;
|
|||
import io.bitsquare.gui.main.dao.wallet.BalanceUtil;
|
||||
import io.bitsquare.gui.main.overlays.popups.Popup;
|
||||
import io.bitsquare.gui.util.BSFormatter;
|
||||
import io.bitsquare.gui.util.BsqFormatter;
|
||||
import io.bitsquare.gui.util.Layout;
|
||||
import io.bitsquare.gui.util.SQUFormatter;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.layout.GridPane;
|
||||
|
@ -49,15 +49,15 @@ import javax.inject.Inject;
|
|||
import static io.bitsquare.gui.util.FormBuilder.*;
|
||||
|
||||
@FxmlView
|
||||
public class TokenSendView extends ActivatableView<GridPane, Void> {
|
||||
public class BsqSendView extends ActivatableView<GridPane, Void> {
|
||||
|
||||
|
||||
private TextField balanceTextField;
|
||||
|
||||
private final SquWalletService squWalletService;
|
||||
private final BsqWalletService bsqWalletService;
|
||||
private final BtcWalletService btcWalletService;
|
||||
private final FeeService feeService;
|
||||
private final BSFormatter squFormatter;
|
||||
private final BSFormatter bsqFormatter;
|
||||
private BSFormatter btcFormatter;
|
||||
private BalanceUtil balanceUtil;
|
||||
|
||||
|
@ -71,12 +71,12 @@ public class TokenSendView extends ActivatableView<GridPane, Void> {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private TokenSendView(SquWalletService squWalletService, BtcWalletService btcWalletService, FeeService feeService, SQUFormatter squFormatter, BSFormatter btcFormatter, BalanceUtil balanceUtil) {
|
||||
this.squWalletService = squWalletService;
|
||||
private BsqSendView(BsqWalletService bsqWalletService, BtcWalletService btcWalletService, FeeService feeService, BsqFormatter bsqFormatter, BSFormatter btcFormatter, BalanceUtil balanceUtil) {
|
||||
this.bsqWalletService = bsqWalletService;
|
||||
this.btcWalletService = btcWalletService;
|
||||
this.feeService = feeService;
|
||||
|
||||
this.squFormatter = squFormatter;
|
||||
this.bsqFormatter = bsqFormatter;
|
||||
this.btcFormatter = btcFormatter;
|
||||
this.balanceUtil = balanceUtil;
|
||||
}
|
||||
|
@ -104,32 +104,32 @@ public class TokenSendView extends ActivatableView<GridPane, Void> {
|
|||
|
||||
sendButton.setOnAction((event) -> {
|
||||
String receiversAddressString = receiversAddressInputTextField.getText();
|
||||
Coin receiverAmount = squFormatter.parseToCoin(amountInputTextField.getText());
|
||||
Coin receiverAmount = bsqFormatter.parseToCoin(amountInputTextField.getText());
|
||||
try {
|
||||
Transaction preparedSendTx = squWalletService.getPreparedSendTx(receiversAddressString, receiverAmount);
|
||||
Transaction txWithBtcFee = btcWalletService.completePreparedSendSquTx(preparedSendTx, true);
|
||||
Transaction signedTx = squWalletService.signTx(txWithBtcFee);
|
||||
Transaction preparedSendTx = bsqWalletService.getPreparedSendTx(receiversAddressString, receiverAmount);
|
||||
Transaction txWithBtcFee = btcWalletService.completePreparedSendBsqTx(preparedSendTx, true);
|
||||
Transaction signedTx = bsqWalletService.signTx(txWithBtcFee);
|
||||
|
||||
Coin miningFee = signedTx.getFee();
|
||||
int txSize = signedTx.bitcoinSerialize().length;
|
||||
new Popup().headLine("Confirm withdrawal request")
|
||||
.confirmation("Sending: " + squFormatter.formatCoinWithCode(receiverAmount) + "\n" +
|
||||
.confirmation("Sending: " + bsqFormatter.formatCoinWithCode(receiverAmount) + "\n" +
|
||||
/* "From address: " + withdrawFromTextField.getText() + "\n" +*/
|
||||
"Receiver address: " + receiversAddressString + "\n" +
|
||||
"Transaction fee: " + btcFormatter.formatCoinWithCode(miningFee) + " (" +
|
||||
MathUtils.roundDouble(((double) miningFee.value / (double) txSize), 2) +
|
||||
" Satoshis/byte)\n" +
|
||||
"Transaction size: " + (txSize / 1000d) + " Kb\n\n" +
|
||||
/*"The recipient will receive: " + squFormatter.formatCoinWithCode(receiverAmount) + "\n\n" +*/
|
||||
/*"The recipient will receive: " + bsqFormatter.formatCoinWithCode(receiverAmount) + "\n\n" +*/
|
||||
"Are you sure you want to withdraw that amount?")
|
||||
.actionButtonText("Yes")
|
||||
.onAction(() -> {
|
||||
try {
|
||||
squWalletService.commitTx(txWithBtcFee);
|
||||
bsqWalletService.commitTx(txWithBtcFee);
|
||||
// We need to create another instance, otherwise the tx would trigger an invalid state exception
|
||||
// if it gets committed 2 times
|
||||
btcWalletService.commitTx(btcWalletService.getClonedTransaction(txWithBtcFee));
|
||||
squWalletService.broadcastTx(signedTx, new FutureCallback<Transaction>() {
|
||||
bsqWalletService.broadcastTx(signedTx, new FutureCallback<Transaction>() {
|
||||
@Override
|
||||
public void onSuccess(@Nullable Transaction transaction) {
|
||||
if (transaction != null) {
|
|
@ -18,7 +18,7 @@
|
|||
-->
|
||||
|
||||
<?import javafx.scene.layout.*?>
|
||||
<GridPane fx:id="root" fx:controller="io.bitsquare.gui.main.dao.wallet.tx.TokenTransactionsView"
|
||||
<GridPane fx:id="root" fx:controller="io.bitsquare.gui.main.dao.wallet.tx.BsqTransactionsView"
|
||||
hgap="5.0" vgap="5.0"
|
||||
AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0"
|
||||
AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="-10.0"
|
|
@ -24,7 +24,7 @@ import javafx.scene.layout.GridPane;
|
|||
import javax.inject.Inject;
|
||||
|
||||
@FxmlView
|
||||
public class TokenTransactionsView extends ActivatableView<GridPane, Void> {
|
||||
public class BsqTransactionsView extends ActivatableView<GridPane, Void> {
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -32,7 +32,7 @@ public class TokenTransactionsView extends ActivatableView<GridPane, Void> {
|
|||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
private TokenTransactionsView() {
|
||||
private BsqTransactionsView() {
|
||||
}
|
||||
|
||||
@Override
|
|
@ -23,11 +23,11 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class SQUFormatter extends BSFormatter {
|
||||
private static final Logger log = LoggerFactory.getLogger(SQUFormatter.class);
|
||||
public class BsqFormatter extends BSFormatter {
|
||||
private static final Logger log = LoggerFactory.getLogger(BsqFormatter.class);
|
||||
|
||||
@Inject
|
||||
private SQUFormatter() {
|
||||
private BsqFormatter() {
|
||||
super();
|
||||
coinFormat = new MonetaryFormat().shift(5).minDecimals(0).code(5, "BSQ").minDecimals(3);
|
||||
}
|
|
@ -8,8 +8,8 @@ import io.bitsquare.app.BitsquareEnvironment;
|
|||
import io.bitsquare.app.Log;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.arbitration.ArbitratorManager;
|
||||
import io.bitsquare.btc.wallet.BsqWalletService;
|
||||
import io.bitsquare.btc.wallet.BtcWalletService;
|
||||
import io.bitsquare.btc.wallet.SquWalletService;
|
||||
import io.bitsquare.btc.wallet.WalletsSetup;
|
||||
import io.bitsquare.common.CommonOptionKeys;
|
||||
import io.bitsquare.common.UserThread;
|
||||
|
@ -144,7 +144,7 @@ public class Headless {
|
|||
});
|
||||
injector.getInstance(WalletsSetup.class).shutDown();
|
||||
injector.getInstance(BtcWalletService.class).shutDown();
|
||||
injector.getInstance(SquWalletService.class).shutDown();
|
||||
injector.getInstance(BsqWalletService.class).shutDown();
|
||||
});
|
||||
});
|
||||
// we wait max 5 sec.
|
||||
|
|
|
@ -8,8 +8,8 @@ import io.bitsquare.app.BitsquareEnvironment;
|
|||
import io.bitsquare.app.Log;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.arbitration.ArbitratorManager;
|
||||
import io.bitsquare.btc.wallet.BsqWalletService;
|
||||
import io.bitsquare.btc.wallet.BtcWalletService;
|
||||
import io.bitsquare.btc.wallet.SquWalletService;
|
||||
import io.bitsquare.btc.wallet.WalletsSetup;
|
||||
import io.bitsquare.common.CommonOptionKeys;
|
||||
import io.bitsquare.common.UserThread;
|
||||
|
@ -147,7 +147,7 @@ public class Monitor {
|
|||
});
|
||||
injector.getInstance(WalletsSetup.class).shutDown();
|
||||
injector.getInstance(BtcWalletService.class).shutDown();
|
||||
injector.getInstance(SquWalletService.class).shutDown();
|
||||
injector.getInstance(BsqWalletService.class).shutDown();
|
||||
});
|
||||
});
|
||||
// we wait max 5 sec.
|
||||
|
|
|
@ -8,8 +8,8 @@ import io.bitsquare.app.BitsquareEnvironment;
|
|||
import io.bitsquare.app.Log;
|
||||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.arbitration.ArbitratorManager;
|
||||
import io.bitsquare.btc.wallet.BsqWalletService;
|
||||
import io.bitsquare.btc.wallet.BtcWalletService;
|
||||
import io.bitsquare.btc.wallet.SquWalletService;
|
||||
import io.bitsquare.btc.wallet.WalletsSetup;
|
||||
import io.bitsquare.common.CommonOptionKeys;
|
||||
import io.bitsquare.common.UserThread;
|
||||
|
@ -113,7 +113,7 @@ public class SeedNode {
|
|||
});
|
||||
injector.getInstance(WalletsSetup.class).shutDown();
|
||||
injector.getInstance(BtcWalletService.class).shutDown();
|
||||
injector.getInstance(SquWalletService.class).shutDown();
|
||||
injector.getInstance(BsqWalletService.class).shutDown();
|
||||
});
|
||||
});
|
||||
// we wait max 5 sec.
|
||||
|
|
|
@ -9,8 +9,8 @@ import io.bitsquare.app.Log;
|
|||
import io.bitsquare.app.Version;
|
||||
import io.bitsquare.arbitration.ArbitratorManager;
|
||||
import io.bitsquare.btc.provider.price.PriceFeedService;
|
||||
import io.bitsquare.btc.wallet.BsqWalletService;
|
||||
import io.bitsquare.btc.wallet.BtcWalletService;
|
||||
import io.bitsquare.btc.wallet.SquWalletService;
|
||||
import io.bitsquare.btc.wallet.WalletsSetup;
|
||||
import io.bitsquare.common.CommonOptionKeys;
|
||||
import io.bitsquare.common.UserThread;
|
||||
|
@ -126,7 +126,7 @@ public class Statistics {
|
|||
});
|
||||
injector.getInstance(WalletsSetup.class).shutDown();
|
||||
injector.getInstance(BtcWalletService.class).shutDown();
|
||||
injector.getInstance(SquWalletService.class).shutDown();
|
||||
injector.getInstance(BsqWalletService.class).shutDown();
|
||||
});
|
||||
});
|
||||
// we wait max 5 sec.
|
||||
|
|
Loading…
Add table
Reference in a new issue