mirror of
https://github.com/haveno-dex/haveno.git
synced 2025-04-19 07:15:54 -04:00
Add support for serverside regtest mode
This commit is contained in:
parent
eadfa64a31
commit
598db75bfc
@ -23,6 +23,7 @@ import io.bitsquare.app.BitsquareEnvironment;
|
||||
import io.bitsquare.app.BitsquareExecutable;
|
||||
import io.bitsquare.app.UpdateProcess;
|
||||
import io.bitsquare.btc.BitcoinNetwork;
|
||||
import io.bitsquare.btc.RegTestHost;
|
||||
import io.bitsquare.p2p.BootstrapNodes;
|
||||
import io.bitsquare.p2p.Node;
|
||||
import io.bitsquare.util.joptsimple.EnumValueConverter;
|
||||
@ -134,6 +135,13 @@ public class BitsquareAppMain extends BitsquareExecutable {
|
||||
.withRequiredArg()
|
||||
.ofType(BitcoinNetwork.class)
|
||||
.withValuesConvertedBy(new EnumValueConverter(BitcoinNetwork.class));
|
||||
|
||||
parser.accepts(RegTestHost.KEY, description("", RegTestHost.DEFAULT))
|
||||
.withRequiredArg()
|
||||
.ofType(RegTestHost.class)
|
||||
.withValuesConvertedBy(new EnumValueConverter(RegTestHost.class));
|
||||
|
||||
|
||||
parser.accepts(BOOTSTRAP_NODE_NAME_KEY, description("", BootstrapNodes.DEFAULT.getName()))
|
||||
.withRequiredArg();
|
||||
parser.accepts(BOOTSTRAP_NODE_IP_KEY, description("", BootstrapNodes.DEFAULT.getIp()))
|
||||
|
@ -41,6 +41,7 @@ public class BitcoinModule extends BitsquareModule {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(BitcoinNetwork.class).toInstance(env.getProperty(BitcoinNetwork.KEY, BitcoinNetwork.class, BitcoinNetwork.DEFAULT));
|
||||
bind(RegTestHost.class).toInstance(env.getProperty(RegTestHost.KEY, RegTestHost.class, RegTestHost.DEFAULT));
|
||||
bind(FeePolicy.class).in(Singleton.class);
|
||||
|
||||
bindConstant().annotatedWith(named(UserAgent.NAME_KEY)).to(env.getRequiredProperty(UserAgent.NAME_KEY));
|
||||
|
27
core/src/main/java/io/bitsquare/btc/RegTestHost.java
Normal file
27
core/src/main/java/io/bitsquare/btc/RegTestHost.java
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* This file is part of Bitsquare.
|
||||
*
|
||||
* Bitsquare is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or (at
|
||||
* your option) any later version.
|
||||
*
|
||||
* Bitsquare is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with Bitsquare. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package io.bitsquare.btc;
|
||||
|
||||
public enum RegTestHost {
|
||||
|
||||
LOCALHOST(),
|
||||
BITSQUARE(); // 188.226.179.109
|
||||
|
||||
public static final String KEY = "bitcoin.regtest.host";
|
||||
public static final RegTestHost DEFAULT = BITSQUARE;
|
||||
}
|
@ -29,6 +29,7 @@ import org.bitcoinj.core.Coin;
|
||||
import org.bitcoinj.core.DownloadProgressTracker;
|
||||
import org.bitcoinj.core.InsufficientMoneyException;
|
||||
import org.bitcoinj.core.NetworkParameters;
|
||||
import org.bitcoinj.core.PeerAddress;
|
||||
import org.bitcoinj.core.Transaction;
|
||||
import org.bitcoinj.core.TransactionConfidence;
|
||||
import org.bitcoinj.core.TransactionInput;
|
||||
@ -49,6 +50,9 @@ import com.google.common.util.concurrent.Service;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@ -87,6 +91,7 @@ public class WalletService {
|
||||
private final Observable<Double> downloadProgress = downloadListener.getObservable();
|
||||
private final WalletEventListener walletEventListener = new BitsquareWalletEventListener();
|
||||
|
||||
private RegTestHost regTestHost;
|
||||
private final TradeWalletService tradeWalletService;
|
||||
private final AddressEntryList addressEntryList;
|
||||
private final NetworkParameters params;
|
||||
@ -106,9 +111,10 @@ public class WalletService {
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@Inject
|
||||
public WalletService(BitcoinNetwork bitcoinNetwork, SignatureService signatureService,
|
||||
public WalletService(BitcoinNetwork bitcoinNetwork, RegTestHost regTestHost, SignatureService signatureService,
|
||||
TradeWalletService tradeWalletService, AddressEntryList addressEntryList, UserAgent userAgent,
|
||||
@Named(DIR_KEY) File walletDir, @Named(PREFIX_KEY) String walletPrefix) {
|
||||
this.regTestHost = regTestHost;
|
||||
this.tradeWalletService = tradeWalletService;
|
||||
this.addressEntryList = addressEntryList;
|
||||
this.params = bitcoinNetwork.getParameters();
|
||||
@ -153,7 +159,16 @@ public class WalletService {
|
||||
// Now configure and start the appkit. This will take a second or two - we could show a temporary splash screen
|
||||
// or progress widget to keep the user engaged whilst we initialise, but we don't.
|
||||
if (params == RegTestParams.get()) {
|
||||
walletAppKit.connectToLocalHost(); // You should run a regtest mode bitcoind locally.
|
||||
if (regTestHost == RegTestHost.BITSQUARE) {
|
||||
try {
|
||||
walletAppKit.setPeerNodes(new PeerAddress(InetAddress.getByName("188.226.179.109"), params.getPort()));
|
||||
} catch (UnknownHostException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
else if (regTestHost == RegTestHost.LOCALHOST) {
|
||||
walletAppKit.connectToLocalHost(); // You should run a regtest mode bitcoind locally.}
|
||||
}
|
||||
}
|
||||
else if (params == MainNetParams.get()) {
|
||||
// Checkpoints are block headers that ship inside our app: for a new user, we pick the last header
|
||||
|
@ -24,7 +24,7 @@
|
||||
AnchorPane.rightAnchor="0" AnchorPane.topAnchor="0"
|
||||
xmlns:fx="http://javafx.com/fxml">
|
||||
|
||||
<Tab fx:id="preferencesTab" text="Preferences" closable="false"/>
|
||||
<Tab fx:id="networkSettingsTab" text="Network info" closable="false"/>
|
||||
<Tab fx:id="preferencesTab" text="Preferences" closable="false"/>
|
||||
|
||||
</TabPane>
|
||||
|
Loading…
x
Reference in New Issue
Block a user