本文整理了Java中org.bitcoinj.core.BlockChain.addWallet()
方法的一些代码示例,展示了BlockChain.addWallet()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BlockChain.addWallet()
方法的具体详情如下:
包路径:org.bitcoinj.core.BlockChain
类名称:BlockChain
方法名:addWallet
暂无
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
/**
* <p>Constructs a BlockChain connected to the given wallet and store. To obtain a {@link Wallet} you can construct
* one from scratch, or you can deserialize a saved wallet from disk using
* {@link Wallet#loadFromFile(java.io.File, WalletExtension...)}</p>
*
* <p>For the store, you should use {@link org.bitcoinj.store.SPVBlockStore} or you could also try a
* {@link org.bitcoinj.store.MemoryBlockStore} if you want to hold all headers in RAM and don't care about
* disk serialization (this is rare).</p>
*/
public BlockChain(Context context, Wallet wallet, BlockStore blockStore) throws BlockStoreException {
this(context, new ArrayList<Wallet>(), blockStore);
addWallet(wallet);
}
代码示例来源:origin: Multibit-Legacy/multibit-hd
public void addWalletToBlockChain(Wallet wallet) {
if (blockChain != null && wallet != null) {
log.trace("Adding wallet {} to blockChain {}", wallet, blockChain);
blockChain.addWallet(wallet);
} else {
log.debug("Could not add wallet to blockChain - one or more is missing");
}
}
代码示例来源:origin: greenaddress/GreenBits
/**
* <p>Constructs a BlockChain connected to the given wallet and store. To obtain a {@link Wallet} you can construct
* one from scratch, or you can deserialize a saved wallet from disk using
* {@link Wallet#loadFromFile(java.io.File, WalletExtension...)}</p>
*
* <p>For the store, you should use {@link org.bitcoinj.store.SPVBlockStore} or you could also try a
* {@link org.bitcoinj.store.MemoryBlockStore} if you want to hold all headers in RAM and don't care about
* disk serialization (this is rare).</p>
*/
public BlockChain(Context context, Wallet wallet, BlockStore blockStore) throws BlockStoreException {
this(context, new ArrayList<Wallet>(), blockStore);
addWallet(wallet);
}
代码示例来源:origin: fr.acinq/bitcoinj-core
/**
* <p>Constructs a BlockChain connected to the given wallet and store. To obtain a {@link Wallet} you can construct
* one from scratch, or you can deserialize a saved wallet from disk using
* {@link Wallet#loadFromFile}</p>
*
* <p>For the store, you should use {@link org.bitcoinj.store.SPVBlockStore} or you could also try a
* {@link org.bitcoinj.store.MemoryBlockStore} if you want to hold all headers in RAM and don't care about
* disk serialization (this is rare).</p>
*/
public BlockChain(Context context, Wallet wallet, BlockStore blockStore) throws BlockStoreException {
this(context, new ArrayList<Wallet>(), blockStore);
addWallet(wallet);
}
代码示例来源:origin: HashEngineering/dashj
/**
* <p>Constructs a BlockChain connected to the given wallet and store. To obtain a {@link Wallet} you can construct
* one from scratch, or you can deserialize a saved wallet from disk using
* {@link Wallet#loadFromFile(java.io.File, WalletExtension...)}</p>
*
* <p>For the store, you should use {@link org.bitcoinj.store.SPVBlockStore} or you could also try a
* {@link org.bitcoinj.store.MemoryBlockStore} if you want to hold all headers in RAM and don't care about
* disk serialization (this is rare).</p>
*/
public BlockChain(Context context, Wallet wallet, BlockStore blockStore) throws BlockStoreException {
this(context, new ArrayList<Wallet>(), blockStore);
addWallet(wallet);
}
代码示例来源:origin: ICOnator/ICOnator-backend
private void walletSetUp() {
this.wallet = new Wallet(this.bitcoinContext);
this.bitcoinBlockchain.addWallet(wallet);
bitcoinPeerGroup.addWallet(wallet);
}
代码示例来源:origin: ICOnator/ICOnator-backend
public BitcoinTestPaymentService(BlockChain bitcoinBlockchain,
Context bitcoinContext,
NetworkParameters bitcoinNetworkParameters,
PeerGroup peerGroup,
String walletPassword, String walletPath)
throws IOException, CipherException, UnreadableWalletException {
this.bitcoinBlockchain = bitcoinBlockchain;
this.bitcoinContext = bitcoinContext;
this.bitcoinNetworkParameters = bitcoinNetworkParameters;
this.peerGroup = peerGroup;
File walletFile = new File(walletPath);
if (walletFile.exists()) {
LOG.info("Wallet exists... trying to load from: {}", walletPath);
this.bitcoinWallet = Wallet.loadFromFile(new File(walletPath));
} else {
LOG.info("Wallet does NOT exist... creating one.", walletPath);
this.bitcoinWallet = new Wallet(this.bitcoinContext);
this.bitcoinWallet.saveToFile(walletFile);
}
LOG.info("Wallet loaded: address={}", this.bitcoinWallet.currentReceiveAddress());
this.bitcoinWallet.autosaveToFile(walletFile, 500, TimeUnit.MILLISECONDS, null);
this.bitcoinBlockchain.addWallet(this.bitcoinWallet);
peerGroup.addWallet(this.bitcoinWallet);
}
代码示例来源:origin: Multibit-Legacy/multibit-hd
blockChain.addWallet(wallet);
log.debug("Created block chain '{}' with height '{}'", blockChain, blockChain.getBestChainHeight());
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
vPeerGroup.addPeerDiscovery(discovery != null ? discovery : new DnsDiscovery(params));
vChain.addWallet(vWallet);
vPeerGroup.addWallet(vWallet);
onSetupCompleted();
代码示例来源:origin: fr.acinq/bitcoinj-core
vPeerGroup.addPeerDiscovery(discovery != null ? discovery : new DnsDiscovery(params));
vChain.addWallet(vWallet);
vPeerGroup.addWallet(vWallet);
onSetupCompleted();
代码示例来源:origin: greenaddress/GreenBits
vPeerGroup.addPeerDiscovery(discovery != null ? discovery : new DnsDiscovery(params));
vChain.addWallet(vWallet);
vPeerGroup.addWallet(vWallet);
onSetupCompleted();
代码示例来源:origin: HashEngineering/dashj
vPeerGroup.addPeerDiscovery(discovery != null ? discovery : new DnsDiscovery(params));
vChain.addWallet(vWallet);
vPeerGroup.addWallet(vWallet);
onSetupCompleted();
代码示例来源:origin: HashEngineering/dashj
chain.addWallet(wallet);
peers.addWallet(wallet);
代码示例来源:origin: greenaddress/GreenBits
@Override
@Before
public void setUp() throws Exception {
Utils.setMockClock(); // Use mock clock
super.setUp();
Context.propagate(new Context(PARAMS, 100, Coin.ZERO, false));
wallet.addExtension(new StoredPaymentChannelClientStates(wallet, new TransactionBroadcaster() {
@Override
public TransactionBroadcast broadcastTransaction(Transaction tx) {
fail();
return null;
}
}));
sendMoneyToWallet(AbstractBlockChain.NewBlockType.BEST_CHAIN, COIN);
chain = new BlockChain(PARAMS, wallet, blockStore); // Recreate chain as sendMoneyToWallet will confuse it
serverWallet = new Wallet(PARAMS);
serverKey = serverWallet.freshReceiveKey();
chain.addWallet(serverWallet);
broadcasts = new LinkedBlockingQueue<>();
mockBroadcaster = new TransactionBroadcaster() {
@Override
public TransactionBroadcast broadcastTransaction(Transaction tx) {
SettableFuture<Transaction> future = SettableFuture.create();
broadcasts.add(new TxFuturePair(tx, future));
return TransactionBroadcast.createMockBroadcast(tx, future);
}
};
}
代码示例来源:origin: greenaddress/GreenBits
@Test
public void receiveTxBroadcastOnAddedWallet() throws Exception {
// Check that when we receive transactions on all our peers, we do the right thing.
peerGroup.start();
// Create a peer.
InboundMessageQueuer p1 = connectPeer(1);
Wallet wallet2 = new Wallet(PARAMS);
ECKey key2 = wallet2.freshReceiveKey();
Address address2 = key2.toAddress(PARAMS);
peerGroup.addWallet(wallet2);
blockChain.addWallet(wallet2);
assertEquals(BloomFilter.class, waitForOutbound(p1).getClass());
assertEquals(MemoryPoolMessage.class, waitForOutbound(p1).getClass());
Coin value = COIN;
Transaction t1 = FakeTxBuilder.createFakeTx(PARAMS, value, address2);
InventoryMessage inv = new InventoryMessage(PARAMS);
inv.addTransaction(t1);
inbound(p1, inv);
assertTrue(outbound(p1) instanceof GetDataMessage);
inbound(p1, t1);
// Asks for dependency.
GetDataMessage getdata = (GetDataMessage) outbound(p1);
assertNotNull(getdata);
inbound(p1, new NotFoundMessage(PARAMS, getdata.getItems()));
pingAndWait(p1);
assertEquals(value, wallet2.getBalance(Wallet.BalanceType.ESTIMATED));
}
代码示例来源:origin: greenaddress/GreenBits
@Test
public void rollbackBlockStore() throws Exception {
// This test simulates an issue on Android, that causes the VM to crash while receiving a block, so that the
// block store is persisted but the wallet is not.
Block b1 = PARAMS.getGenesisBlock().createNextBlock(coinbaseTo);
Block b2 = b1.createNextBlock(coinbaseTo);
// Add block 1, no frills.
assertTrue(chain.add(b1));
assertEquals(b1.cloneAsHeader(), chain.getChainHead().getHeader());
assertEquals(1, chain.getBestChainHeight());
assertEquals(1, wallet.getLastBlockSeenHeight());
// Add block 2 while wallet is disconnected, to simulate crash.
chain.removeWallet(wallet);
assertTrue(chain.add(b2));
assertEquals(b2.cloneAsHeader(), chain.getChainHead().getHeader());
assertEquals(2, chain.getBestChainHeight());
assertEquals(1, wallet.getLastBlockSeenHeight());
// Add wallet back. This will detect the height mismatch and repair the damage done.
chain.addWallet(wallet);
assertEquals(b1.cloneAsHeader(), chain.getChainHead().getHeader());
assertEquals(1, chain.getBestChainHeight());
assertEquals(1, wallet.getLastBlockSeenHeight());
// Now add block 2 correctly.
assertTrue(chain.add(b2));
assertEquals(b2.cloneAsHeader(), chain.getChainHead().getHeader());
assertEquals(2, chain.getBestChainHeight());
assertEquals(2, wallet.getLastBlockSeenHeight());
}
}
代码示例来源:origin: greenaddress/GreenBits
ECKey receiveKey = wallet2.freshReceiveKey();
int height = 1;
chain.addWallet(wallet2);
内容来源于网络,如有侵权,请联系作者删除!