public static Context getOrCreate(NetworkParameters params) { Context context; try { context = get(); } catch (IllegalStateException e) { log.warn("Implicitly creating context. This is a migration step and this message will eventually go away."); context = new Context(params); return context; } if (context.getParams() != params) throw new IllegalStateException("Context does not match implicit network params: " + context.getParams() + " vs " + params); return context; }
/** * Constructs a block chain 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...)} */ public FullPrunedBlockChain(NetworkParameters params, Wallet wallet, FullPrunedBlockStore blockStore) throws BlockStoreException { this(Context.getOrCreate(params), wallet, blockStore); }
@Override public void run() { try { Context.propagate(context); r.run(); } catch (Exception e) { log.error("Exception in thread", e); Throwables.propagate(e); } } }, name);
/** Use "Context.get().getConfidenceTable()" instead */ @Deprecated @Nullable public TxConfidenceTable getMemoryPool() { return Context.get().getConfidenceTable(); }
/** * Creates a new WalletAppKit, with a newly created {@link Context}. Files will be stored in the given directory. */ public WalletAppKit(NetworkParameters params, File directory, String filePrefix) { this(new Context(params), directory, filePrefix); }
if (Context.get().isEnsureMinRequiredFee()) {
@Override public NetworkParameters getParams() { return context.getParams(); } }
/** * Construct a BitcoinClient from Network Parameters, URI, user name, and password. * @param netParams Correct Network Parameters for destination server * @param server URI of the Bitcoin RPC server * @param rpcuser Username (if required) * @param rpcpassword Password (if required) */ public BitcoinClient(NetworkParameters netParams, URI server, String rpcuser, String rpcpassword) { super(server, rpcuser, rpcpassword); this.context = new Context(netParams); mapper.registerModule(new RpcClientModule(context.getParams())); }
protected void watchCloseConfirmations() { // When we see the close transaction get enough confirmations, we can just delete the record // of this channel along with the refund tx from the wallet, because we're not going to need // any of that any more. final TransactionConfidence confidence = storedChannel.close.getConfidence(); int numConfirms = Context.get().getEventHorizon(); ListenableFuture<TransactionConfidence> future = confidence.getDepthFuture(numConfirms, Threading.SAME_THREAD); Futures.addCallback(future, new FutureCallback<TransactionConfidence>() { @Override public void onSuccess(TransactionConfidence result) { deleteChannelFromWallet(); } @Override public void onFailure(Throwable t) { Throwables.propagate(t); } }); }
public Masternode(NetworkParameters params, byte [] payload, int cursor) { super(params, payload, cursor); context = Context.get(); //calculateScoreTest(); }
/** * Returns the confidence object for this transaction from the {@link org.bitcoinj.core.TxConfidenceTable} * referenced by the given {@link Context}. */ public TransactionConfidence getConfidence(Context context) { return getConfidence(context.getConfidenceTable()); }
@Before public void setup() throws Exception { BriefLogFormatter.init(); Context context = new Context(PARAMS); table = context.getConfidenceTable(); Address to = new ECKey().toAddress(PARAMS); Address change = new ECKey().toAddress(PARAMS); tx1 = FakeTxBuilder.createFakeTxWithChangeAddress(PARAMS, COIN, to, change); tx2 = FakeTxBuilder.createFakeTxWithChangeAddress(PARAMS, COIN, to, change); assertEquals(tx1.getHash(), tx2.getHash()); address1 = new PeerAddress(PARAMS, InetAddress.getByAddress(new byte[] { 127, 0, 0, 1 })); address2 = new PeerAddress(PARAMS, InetAddress.getByAddress(new byte[] { 127, 0, 0, 2 })); address3 = new PeerAddress(PARAMS, InetAddress.getByAddress(new byte[] { 127, 0, 0, 3 })); }
protected void setChainHead(StoredBlock chainHead) throws BlockStoreException { doSetChainHead(chainHead); synchronized (chainHeadLock) { this.chainHead = chainHead; } Context.get().updatedChainHead(chainHead); }
if (confidence.incrementDepthInBlocks() > context.getEventHorizon()) confidence.clearBroadcastBy(); confidenceChanged.put(tx, TransactionConfidence.Listener.ChangeReason.DEPTH);
case MasterNodeQuarum: break; case MasterNodeAnnounce: if(context.isLiteMode()) break; masternodeBroadcasts.add(item); break; case MasterNodePing: if(context.isLiteMode()) break; masternodePings.add(item); break; TransactionConfidence conf = context.getConfidenceTable().seen(item.hash, this.getAddress()); if (conf.numBroadcastPeers() > 1) { TransactionConfidence conf = context.getConfidenceTable().seen(item.hash, this.getAddress()); if (conf.numBroadcastPeers() > 1) {
public void setUp() throws Exception { BriefLogFormatter.init(); Context.propagate(new Context(PARAMS, 100, Coin.ZERO, false)); wallet = new Wallet(PARAMS); myKey = wallet.currentReceiveKey(); myAddress = myKey.toAddress(PARAMS); blockStore = new MemoryBlockStore(PARAMS); chain = new BlockChain(PARAMS, wallet, blockStore); }
/** * Creates a new WalletAppKit, with a newly created {@link Context}. Files will be stored in the given directory. */ public WalletAppKit(NetworkParameters params, File directory, String filePrefix, boolean useSegwit) { this(new Context(params), directory, filePrefix, useSegwit); }
if (Context.get().isEnsureMinRequiredFee()) {