When testing for specific network, use network ID.

This commit is contained in:
Andreas Schildbach
2015-12-05 16:39:05 +01:00
parent f48f17bf46
commit e19297ab2a
3 changed files with 4 additions and 4 deletions

View File

@@ -264,7 +264,7 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha
this.context = context;
this.params = context.getParams();
this.keychain = checkNotNull(keyChainGroup);
if (params == UnitTestParams.get())
if (params.getId().equals(NetworkParameters.ID_UNITTESTNET))
this.keychain.setLookaheadSize(5); // Cut down excess computation for unit tests.
// If this keychain was created fresh just now (new wallet), make HD so a backup can be made immediately
// without having to call current/freshReceiveKey. If there are already keys in the chain of any kind then
@@ -3438,7 +3438,7 @@ public class Wallet extends BaseTaggableObject implements Serializable, BlockCha
*/
public Transaction createSend(Address address, Coin value) throws InsufficientMoneyException {
SendRequest req = SendRequest.to(address, value);
if (params == UnitTestParams.get())
if (params.getId().equals(NetworkParameters.ID_UNITTESTNET))
req.shuffleOutputs = false;
completeTx(req);
return req.tx;

View File

@@ -318,7 +318,7 @@ public class WalletAppKit extends AbstractIdleService {
for (PeerAddress addr : peerAddresses) vPeerGroup.addAddress(addr);
vPeerGroup.setMaxConnections(peerAddresses.length);
peerAddresses = null;
} else if (params != RegTestParams.get() && !useTor) {
} else if (!params.getId().equals(NetworkParameters.ID_REGTEST) && !useTor) {
vPeerGroup.addPeerDiscovery(discovery != null ? discovery : new DnsDiscovery(params));
}
vChain.addWallet(vWallet);

View File

@@ -85,6 +85,6 @@ public class DefaultCoinSelector implements CoinSelector {
confidence.getSource().equals(TransactionConfidence.Source.SELF) &&
// In regtest mode we expect to have only one peer, so we won't see transactions propagate.
// TODO: The value 1 below dates from a time when transactions we broadcast *to* were counted, set to 0
(confidence.numBroadcastPeers() > 1 || tx.getParams() == RegTestParams.get());
(confidence.numBroadcastPeers() > 1 || tx.getParams().getId().equals(NetworkParameters.ID_REGTEST));
}
}