本文整理汇总了Java中com.google.bitcoin.params.RegTestParams类的典型用法代码示例。如果您正苦于以下问题:Java RegTestParams类的具体用法?Java RegTestParams怎么用?Java RegTestParams使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RegTestParams类属于com.google.bitcoin.params包,在下文中一共展示了RegTestParams类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: selectable
import com.google.bitcoin.params.RegTestParams; //导入依赖的package包/类
@Test
public void selectable() throws Exception {
Transaction t;
t = new Transaction(params);
t.getConfidence().setConfidenceType(TransactionConfidence.ConfidenceType.PENDING);
assertFalse(DefaultCoinSelector.isSelectable(t));
t.getConfidence().setSource(TransactionConfidence.Source.SELF);
assertFalse(DefaultCoinSelector.isSelectable(t));
t.getConfidence().markBroadcastBy(new PeerAddress(InetAddress.getByName("1.2.3.4")));
assertFalse(DefaultCoinSelector.isSelectable(t));
t.getConfidence().markBroadcastBy(new PeerAddress(InetAddress.getByName("5.6.7.8")));
assertTrue(DefaultCoinSelector.isSelectable(t));
t = new Transaction(params);
t.getConfidence().setConfidenceType(TransactionConfidence.ConfidenceType.BUILDING);
assertTrue(DefaultCoinSelector.isSelectable(t));
t = new Transaction(RegTestParams.get());
t.getConfidence().setConfidenceType(TransactionConfidence.ConfidenceType.PENDING);
t.getConfidence().setSource(TransactionConfidence.Source.SELF);
assertTrue(DefaultCoinSelector.isSelectable(t));
}
开发者ID:HashEngineering,项目名称:megacoinj,代码行数:21,代码来源:DefaultCoinSelectorTest.java
示例2: initializeKit
import com.google.bitcoin.params.RegTestParams; //导入依赖的package包/类
private WalletAppKit initializeKit() {
BriefLogFormatter.init();
final NetworkParameters params = getNetworkParameters();
final String filePrefix = getFilePrefix();
// Start up a basic app using a class that automates some boilerplate.
final WalletAppKit tmpKit = new WalletAppKit(params, new File(config.getInstallDirectory()), filePrefix);
tmpKit.setAutoSave(true);
tmpKit.setUserAgent("killbill", "1.0");
if (params == RegTestParams.get()) {
// Regression test mode is designed for testing and development only, so there's no public network for it.
// If you pick this mode, you're expected to be running a local "bitcoind -regtest" instance.
tmpKit.connectToLocalHost();
}
return tmpKit;
}
开发者ID:killbill,项目名称:killbill-bitcoin-plugin,代码行数:20,代码来源:BitcoinManager.java
示例3: isSelectable
import com.google.bitcoin.params.RegTestParams; //导入依赖的package包/类
public static boolean isSelectable(Transaction tx) {
// Only pick chain-included transactions, or transactions that are ours and pending.
TransactionConfidence confidence = tx.getConfidence();
TransactionConfidence.ConfidenceType type = confidence.getConfidenceType();
return type.equals(TransactionConfidence.ConfidenceType.BUILDING) ||
type.equals(TransactionConfidence.ConfidenceType.PENDING) &&
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());
}
开发者ID:HashEngineering,项目名称:megacoinj,代码行数:13,代码来源:DefaultCoinSelector.java
示例4: getNetworkParameters
import com.google.bitcoin.params.RegTestParams; //导入依赖的package包/类
@VisibleForTesting
NetworkParameters getNetworkParameters() {
NetworkParameters params;
if (config.getNetworkName().equals("testnet")) {
params = TestNet3Params.get();
} else if (config.getNetworkName().equals("regtest")) {
params = RegTestParams.get();
} else {
params = MainNetParams.get();
}
return params;
}
开发者ID:killbill,项目名称:killbill-bitcoin-plugin,代码行数:13,代码来源:BitcoinManager.java
示例5: isSelectable
import com.google.bitcoin.params.RegTestParams; //导入依赖的package包/类
public static boolean isSelectable(Transaction tx, int requiredNumBroadcastPeers) {
// Only pick chain-included transactions, or transactions that are ours and pending.
TransactionConfidence confidence = tx.getConfidence();
TransactionConfidence.ConfidenceType type = confidence.getConfidenceType();
return type.equals(TransactionConfidence.ConfidenceType.BUILDING) ||
type.equals(TransactionConfidence.ConfidenceType.PENDING) &&
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() >= requiredNumBroadcastPeers || tx.getParams() == RegTestParams.get());
}
开发者ID:coinspark,项目名称:sparkbit-bitcoinj,代码行数:13,代码来源:DefaultCoinSelector.java
示例6: main
import com.google.bitcoin.params.RegTestParams; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// This line makes the log output more compact and easily read, especially when using the JDK log adapter.
BriefLogFormatter.init();
if (args.length < 1) {
System.err.println("Usage: address-to-send-back-to [regtest|testnet]");
return;
}
// Figure out which network we should connect to. Each one gets its own set of files.
NetworkParameters params;
String filePrefix;
if (args.length > 1 && args[1].equals("testnet")) {
params = TestNet3Params.get();
filePrefix = "forwarding-service-testnet";
} else if (args.length > 1 && args[1].equals("regtest")) {
params = RegTestParams.get();
filePrefix = "forwarding-service-regtest";
} else {
params = MainNetParams.get();
filePrefix = "forwarding-service";
}
// Parse the address given as the first parameter.
forwardingAddress = new Address(params, args[0]);
// Start up a basic app using a class that automates some boilerplate.
kit = new WalletAppKit(params, new File("."), filePrefix);
if (params == RegTestParams.get()) {
// Regression test mode is designed for testing and development only, so there's no public network for it.
// If you pick this mode, you're expected to be running a local "bitcoind -regtest" instance.
kit.connectToLocalHost();
}
// Download the block chain and wait until it's done.
kit.startAndWait();
// We want to know when we receive money.
kit.wallet().addEventListener(new AbstractWalletEventListener() {
@Override
public void onCoinsReceived(Wallet w, Transaction tx, BigInteger prevBalance, BigInteger newBalance) {
// Runs in the dedicated "user thread" (see bitcoinj docs for more info on this).
//
// The transaction "tx" can either be pending, or included into a block (we didn't see the broadcast).
BigInteger value = tx.getValueSentToMe(w);
System.out.println("Received tx for " + Utils.bitcoinValueToFriendlyString(value) + ": " + tx);
System.out.println("Transaction will be forwarded after it confirms.");
// Wait until it's made it into the block chain (may run immediately if it's already there).
//
// For this dummy app of course, we could just forward the unconfirmed transaction. If it were
// to be double spent, no harm done. Wallet.allowSpendingUnconfirmedTransactions() would have to
// be called in onSetupCompleted() above. But we don't do that here to demonstrate the more common
// case of waiting for a block.
Futures.addCallback(tx.getConfidence().getDepthFuture(1), new FutureCallback<Transaction>() {
@Override
public void onSuccess(Transaction result) {
// "result" here is the same as "tx" above, but we use it anyway for clarity.
forwardCoins(result);
}
@Override
public void onFailure(Throwable t) {
// This kind of future can't fail, just rethrow in case something weird happens.
throw new RuntimeException(t);
}
});
}
});
Address sendToAddress = kit.wallet().getKeys().get(0).toAddress(params);
System.out.println("Send coins to: " + sendToAddress);
System.out.println("Waiting for coins to arrive. Press Ctrl-C to quit.");
try {
Thread.sleep(Long.MAX_VALUE);
} catch (InterruptedException ignored) {}
}
开发者ID:HashEngineering,项目名称:megacoinj,代码行数:77,代码来源:ForwardingService.java
示例7: init
import com.google.bitcoin.params.RegTestParams; //导入依赖的package包/类
private void init(Stage mainWindow) throws IOException {
if (System.getProperty("os.name").toLowerCase().contains("mac")) {
AquaFx.style();
}
// Load the GUI. The Controller class will be automagically created and wired up.
URL location = getClass().getResource("main.fxml");
FXMLLoader loader = new FXMLLoader(location);
mainUI = loader.load();
Controller controller = loader.getController();
// Configure the window with a StackPane so we can overlay things on top of the main UI.
uiStack = new StackPane(mainUI);
mainWindow.setTitle(APP_NAME);
final Scene scene = new Scene(uiStack);
TextFieldValidator.configureScene(scene); // Add CSS that we need.
mainWindow.setScene(scene);
// Make log output concise.
BriefLogFormatter.init();
// Tell bitcoinj to run event handlers on the JavaFX UI thread. This keeps things simple and means
// we cannot forget to switch threads when adding event handlers. Unfortunately, the DownloadListener
// we give to the app kit is currently an exception and runs on a library thread. It'll get fixed in
// a future version.
Threading.USER_THREAD = Platform::runLater;
// Create the app kit. It won't do any heavyweight initialization until after we start it.
bitcoin = new WalletAppKit(params, new File("."), APP_NAME);
if (params == RegTestParams.get()) {
bitcoin.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
// in the checkpoints file and then download the rest from the network. It makes things much faster.
// Checkpoint files are made using the BuildCheckpoints tool and usually we have to download the
// last months worth or more (takes a few seconds).
bitcoin.setCheckpoints(getClass().getResourceAsStream("checkpoints"));
}
// 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.
bitcoin.setDownloadListener(controller.progressBarUpdater())
.setBlockingStartup(false)
.setUserAgent(APP_NAME, "1.0")
.startAndWait();
// Don't make the user wait for confirmations for now, as the intention is they're sending it their own money!
bitcoin.wallet().allowSpendingUnconfirmedTransactions();
bitcoin.peerGroup().setMaxConnections(11);
System.out.println(bitcoin.wallet());
controller.onBitcoinSetup();
mainWindow.show();
}
开发者ID:HashEngineering,项目名称:megacoinj,代码行数:49,代码来源:Main.java
示例8: main
import com.google.bitcoin.params.RegTestParams; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// This line makes the log output more compact and easily read, especially when using the JDK log adapter.
BriefLogFormatter.init();
if (args.length < 1) {
System.err.println("Usage: address-to-send-back-to [regtest|testnet]");
return;
}
// Figure out which network we should connect to. Each one gets its own set of files.
NetworkParameters params;
String filePrefix;
if (args.length > 1 && args[1].equals("testnet")) {
params = TestNet3Params.get();
filePrefix = "forwarding-service-testnet";
} else if (args.length > 1 && args[1].equals("regtest")) {
params = RegTestParams.get();
filePrefix = "forwarding-service-regtest";
} else {
params = MainNetParams.get();
filePrefix = "forwarding-service";
}
// Parse the address given as the first parameter.
forwardingAddress = new Address(params, args[0]);
// Start up a basic app using a class that automates some boilerplate.
kit = new WalletAppKit(params, new File("."), filePrefix);
if (params == RegTestParams.get()) {
// Regression test mode is designed for testing and development only, so there's no public network for it.
// If you pick this mode, you're expected to be running a local "bitcoind -regtest" instance.
kit.connectToLocalHost();
}
// Download the block chain and wait until it's done.
kit.startAsync();
kit.awaitRunning();
// We want to know when we receive money.
kit.wallet().addEventListener(new AbstractWalletEventListener() {
@Override
public void onCoinsReceived(Wallet w, Transaction tx, BigInteger prevBalance, BigInteger newBalance) {
// Runs in the dedicated "user thread" (see bitcoinj docs for more info on this).
//
// The transaction "tx" can either be pending, or included into a block (we didn't see the broadcast).
BigInteger value = tx.getValueSentToMe(w);
System.out.println("Received tx for " + Utils.bitcoinValueToFriendlyString(value) + ": " + tx);
System.out.println("Transaction will be forwarded after it confirms.");
// Wait until it's made it into the block chain (may run immediately if it's already there).
//
// For this dummy app of course, we could just forward the unconfirmed transaction. If it were
// to be double spent, no harm done. Wallet.allowSpendingUnconfirmedTransactions() would have to
// be called in onSetupCompleted() above. But we don't do that here to demonstrate the more common
// case of waiting for a block.
Futures.addCallback(tx.getConfidence().getDepthFuture(1), new FutureCallback<Transaction>() {
@Override
public void onSuccess(Transaction result) {
// "result" here is the same as "tx" above, but we use it anyway for clarity.
forwardCoins(result);
}
@Override
public void onFailure(Throwable t) {
// This kind of future can't fail, just rethrow in case something weird happens.
throw new RuntimeException(t);
}
});
}
});
Address sendToAddress = kit.wallet().getKeys().get(0).toAddress(params);
System.out.println("Send coins to: " + sendToAddress);
System.out.println("Waiting for coins to arrive. Press Ctrl-C to quit.");
try {
Thread.sleep(Long.MAX_VALUE);
} catch (InterruptedException ignored) {}
}
开发者ID:HashEngineering,项目名称:quarkcoinj,代码行数:78,代码来源:ForwardingService.java
示例9: init
import com.google.bitcoin.params.RegTestParams; //导入依赖的package包/类
private void init(Stage mainWindow) throws IOException {
if (System.getProperty("os.name").toLowerCase().contains("mac")) {
AquaFx.style();
}
// Load the GUI. The Controller class will be automagically created and wired up.
URL location = getClass().getResource("main.fxml");
FXMLLoader loader = new FXMLLoader(location);
mainUI = loader.load();
Controller controller = loader.getController();
// Configure the window with a StackPane so we can overlay things on top of the main UI.
uiStack = new StackPane(mainUI);
mainWindow.setTitle(APP_NAME);
final Scene scene = new Scene(uiStack);
TextFieldValidator.configureScene(scene); // Add CSS that we need.
mainWindow.setScene(scene);
// Make log output concise.
BriefLogFormatter.init();
// Tell bitcoinj to run event handlers on the JavaFX UI thread. This keeps things simple and means
// we cannot forget to switch threads when adding event handlers. Unfortunately, the DownloadListener
// we give to the app kit is currently an exception and runs on a library thread. It'll get fixed in
// a future version.
Threading.USER_THREAD = Platform::runLater;
// Create the app kit. It won't do any heavyweight initialization until after we start it.
bitcoin = new WalletAppKit(params, new File("."), APP_NAME);
if (params == RegTestParams.get()) {
bitcoin.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
// in the checkpoints file and then download the rest from the network. It makes things much faster.
// Checkpoint files are made using the BuildCheckpoints tool and usually we have to download the
// last months worth or more (takes a few seconds).
bitcoin.setCheckpoints(getClass().getResourceAsStream("checkpoints"));
// As an example!
bitcoin.useTor();
}
// 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.
bitcoin.setDownloadListener(controller.progressBarUpdater())
.setBlockingStartup(false)
.setUserAgent(APP_NAME, "1.0");
bitcoin.startAsync();
bitcoin.awaitRunning();
// Don't make the user wait for confirmations for now, as the intention is they're sending it their own money!
bitcoin.wallet().allowSpendingUnconfirmedTransactions();
bitcoin.peerGroup().setMaxConnections(11);
System.out.println(bitcoin.wallet());
controller.onBitcoinSetup();
mainWindow.show();
}
开发者ID:HashEngineering,项目名称:quarkcoinj,代码行数:52,代码来源:Main.java
示例10: setup
import com.google.bitcoin.params.RegTestParams; //导入依赖的package包/类
private static void setup() throws BlockStoreException {
if (store != null) return; // Already done.
// Will create a fresh chain if one doesn't exist or there is an issue with this one.
if (!chainFileName.exists() && wallet.getTransactions(true).size() > 0) {
// No chain, so reset the wallet as we will be downloading from scratch.
System.out.println("Chain file is missing so clearing transactions from the wallet.");
reset();
}
if (mode == ValidationMode.SPV) {
store = new SPVBlockStore(params, chainFileName);
chain = new BlockChain(params, wallet, store);
} else if (mode == ValidationMode.FULL) {
FullPrunedBlockStore s = new H2FullPrunedBlockStore(params, chainFileName.getAbsolutePath(), 5000);
store = s;
chain = new FullPrunedBlockChain(params, wallet, s);
}
// This will ensure the wallet is saved when it changes.
wallet.autosaveToFile(walletFile, 200, TimeUnit.MILLISECONDS, null);
peers = new PeerGroup(params, chain);
peers.setUserAgent("WalletTool", "1.0");
peers.addWallet(wallet);
if (options.has("peers")) {
String peersFlag = (String) options.valueOf("peers");
String[] peerAddrs = peersFlag.split(",");
for (String peer : peerAddrs) {
try {
peers.addAddress(new PeerAddress(InetAddress.getByName(peer), params.getPort()));
} catch (UnknownHostException e) {
System.err.println("Could not understand peer domain name/IP address: " + peer + ": " + e.getMessage());
System.exit(1);
}
}
} else {
if (params == RegTestParams.get()) {
log.info("Assuming regtest node on localhost");
peers.addAddress(InetAddress.getLoopbackAddress());
} else {
peers.addPeerDiscovery(new DnsDiscovery(params));
}
}
}
开发者ID:keremhd,项目名称:mintcoinj,代码行数:42,代码来源:WalletTool.java
示例11: main
import com.google.bitcoin.params.RegTestParams; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
// This line makes the log output more compact and easily read, especially when using the JDK log adapter.
BriefLogFormatter.init();
if (args.length < 2) {
System.err.println("Usage: address-to-send-back-to [regtest|testnet]");
return;
}
// Figure out which network we should connect to. Each one gets its own set of files.
NetworkParameters params;
String filePrefix;
if (args[1].equals("testnet")) {
params = TestNet3Params.get();
filePrefix = "forwarding-service-testnet";
} else if (args[1].equals("regtest")) {
params = RegTestParams.get();
filePrefix = "forwarding-service-regtest";
} else {
params = MainNetParams.get();
filePrefix = "forwarding-service";
}
// Parse the address given as the first parameter.
forwardingAddress = new Address(params, args[0]);
// Start up a basic app using a class that automates some boilerplate.
kit = new WalletAppKit(params, new File("."), filePrefix);
if (params == RegTestParams.get()) {
// Regression test mode is designed for testing and development only, so there's no public network for it.
// If you pick this mode, you're expected to be running a local "bitcoind -regtest" instance.
kit.connectToLocalHost();
}
// Download the block chain and wait until it's done.
kit.startAndWait();
// We want to know when we receive money.
kit.wallet().addEventListener(new AbstractWalletEventListener() {
@Override
public void onCoinsReceived(Wallet w, Transaction tx, BigInteger prevBalance, BigInteger newBalance) {
// Runs in the dedicated "user thread" (see bitcoinj docs for more info on this).
//
// The transaction "tx" can either be pending, or included into a block (we didn't see the broadcast).
BigInteger value = tx.getValueSentToMe(w);
System.out.println("Received tx for " + Utils.bitcoinValueToFriendlyString(value) + ": " + tx);
System.out.println("Transaction will be forwarded after it confirms.");
// Wait until it's made it into the block chain (may run immediately if it's already there).
//
// For this dummy app of course, we could just forward the unconfirmed transaction. If it were
// to be double spent, no harm done. Wallet.allowSpendingUnconfirmedTransactions() would have to
// be called in onSetupCompleted() above. But we don't do that here to demonstrate the more common
// case of waiting for a block.
Futures.addCallback(tx.getConfidence().getDepthFuture(1), new FutureCallback<Transaction>() {
@Override
public void onSuccess(Transaction result) {
// "result" here is the same as "tx" above, but we use it anyway for clarity.
forwardCoins(result);
}
@Override
public void onFailure(Throwable t) {
// This kind of future can't fail, just rethrow in case something weird happens.
throw new RuntimeException(t);
}
});
}
});
Address sendToAddress = kit.wallet().getKeys().get(0).toAddress(params);
System.out.println("Send coins to: " + sendToAddress);
System.out.println("Waiting for coins to arrive. Press Ctrl-C to quit.");
try {
Thread.sleep(Long.MAX_VALUE);
} catch (InterruptedException ignored) {}
}
开发者ID:sserrano44,项目名称:bitcoinj-watcher-service,代码行数:77,代码来源:ForwardingService.java
注:本文中的com.google.bitcoin.params.RegTestParams类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论