/** * Generates a new key chain with entropy selected randomly from the given {@link java.security.SecureRandom} * object and of the requested size in bits. */ public DeterministicKeyChain(SecureRandom random, int bits) { this(random, bits, DEFAULT_PASSPHRASE_FOR_MNEMONIC, Utils.currentTimeSeconds()); }
/** * Generates a new key chain with entropy selected randomly from the given {@link java.security.SecureRandom} * object and the default entropy size. */ public DeterministicKeyChain(SecureRandom random) { this(random, DeterministicSeed.DEFAULT_SEED_ENTROPY_BITS, DEFAULT_PASSPHRASE_FOR_MNEMONIC, Utils.currentTimeSeconds()); }
/** * Generates a new key chain with entropy selected randomly from the given {@link java.security.SecureRandom} * object and the default entropy size. */ public DeterministicKeyChain(SecureRandom random, boolean useSegwit) { this(random, DeterministicSeed.DEFAULT_SEED_ENTROPY_BITS, DEFAULT_PASSPHRASE_FOR_MNEMONIC, Utils.currentTimeSeconds(), useSegwit); }
/** * Generates a new key chain with entropy selected randomly from the given {@link java.security.SecureRandom} * object and the default entropy size. */ public DeterministicKeyChain(SecureRandom random) { this(random, DeterministicSeed.DEFAULT_SEED_ENTROPY_BITS, DEFAULT_PASSPHRASE_FOR_MNEMONIC, Utils.currentTimeSeconds()); }
/** * Generates a new key chain with entropy selected randomly from the given {@link java.security.SecureRandom} * object and of the requested size in bits. */ public DeterministicKeyChain(SecureRandom random, int bits) { this(random, bits, DEFAULT_PASSPHRASE_FOR_MNEMONIC, Utils.currentTimeSeconds()); }
/** * Generates a new key chain with entropy selected randomly from the given {@link java.security.SecureRandom} * object and the default entropy size. */ public DeterministicKeyChain(SecureRandom random) { this(random, DeterministicSeed.DEFAULT_SEED_ENTROPY_BITS, DEFAULT_PASSPHRASE_FOR_MNEMONIC, Utils.currentTimeSeconds()); }
/** * Create a block sending 50BTC as a coinbase transaction to the public key specified. * This method is intended for test use only. */ @VisibleForTesting Block createNextBlockWithCoinbase(long version, byte[] pubKey, final int height) { return createNextBlock(null, version, (TransactionOutPoint) null, Utils.currentTimeSeconds(), pubKey, FIFTY_COINS, height); }
@VisibleForTesting public Block createNextBlockWithCoinbase(long version, byte[] pubKey, Coin coinbaseValue, final int height) { return createNextBlock(null, version, (TransactionOutPoint) null, Utils.currentTimeSeconds(), pubKey, coinbaseValue, height); }
/** * Create a block sending 50BTC as a coinbase transaction to the public key specified. * This method is intended for test use only. */ @VisibleForTesting Block createNextBlockWithCoinbase(long version, byte[] pubKey, final int height) { return createNextBlock(null, version, (TransactionOutPoint) null, Utils.currentTimeSeconds(), pubKey, FIFTY_COINS, height); }
private void checkTimestamp() throws VerificationException { // Allow injection of a fake clock to allow unit testing. long currentTime = Utils.currentTimeSeconds(); if (time > currentTime + ALLOWED_TIME_DRIFT) throw new VerificationException(String.format(Locale.US, "Block too far in future: %d vs %d", time, currentTime + ALLOWED_TIME_DRIFT)); }
private void checkTimestamp() throws VerificationException { // Allow injection of a fake clock to allow unit testing. long currentTime = Utils.currentTimeSeconds(); if (time > currentTime + ALLOWED_TIME_DRIFT) throw new VerificationException(String.format(Locale.US, "Block too far in future: %d vs %d", time, currentTime + ALLOWED_TIME_DRIFT)); }
/** * Create a block sending 50BTC as a coinbase transaction to the public key specified. * This method is intended for test use only. */ @VisibleForTesting Block createNextBlockWithCoinbase(long version, byte[] pubKey, final int height) { return createNextBlock(null, version, (TransactionOutPoint) null, Utils.currentTimeSeconds(), pubKey, FIFTY_COINS, height); }
@VisibleForTesting public Block createNextBlockWithCoinbase(long version, byte[] pubKey, Coin coinbaseValue, final int height) { return createNextBlock(null, version, (TransactionOutPoint) null, Utils.currentTimeSeconds(), pubKey, coinbaseValue, height); }
@VisibleForTesting public Block createNextBlockWithCoinbase(long version, byte[] pubKey, Coin coinbaseValue, final int height) { return createNextBlock(null, version, (TransactionOutPoint) null, Utils.currentTimeSeconds(), pubKey, coinbaseValue, height); }
void BumpAssetLastTime(String strFuncName) { if(isSynced() || isFailed()) return; nTimeLastBumped = Utils.currentTimeSeconds(); log.info("mnsync--CMasternodeSync::BumpAssetLastTime -- "+ strFuncName); }
/** * Checks if the channel is expired, setting state to {@link State#EXPIRED}, removing this channel from wallet * storage and throwing an {@link IllegalStateException} if it is. */ public synchronized void checkNotExpired() { if (Utils.currentTimeSeconds() > getExpiryTime()) { stateMachine.transition(State.EXPIRED); disconnectFromChannel(); throw new IllegalStateException("Channel expired"); } }
/** * Checks if the channel is expired, setting state to {@link State#EXPIRED}, removing this channel from wallet * storage and throwing an {@link IllegalStateException} if it is. */ public synchronized void checkNotExpired() { if (Utils.currentTimeSeconds() > getExpiryTime()) { stateMachine.transition(State.EXPIRED); disconnectFromChannel(); throw new IllegalStateException("Channel expired"); } }
/** Emulates receiving a valid block that builds on top of the chain. */ public static BlockPair createFakeBlock(BlockStore blockStore, int height, Transaction... transactions) { return createFakeBlock(blockStore, Block.BLOCK_VERSION_GENESIS, Utils.currentTimeSeconds(), height, transactions); }
@Test public void keyCreationTime() throws Exception { Utils.setMockClock(); long now = Utils.currentTimeSeconds(); wallet = new Wallet(PARAMS); assertEquals(now, wallet.getEarliestKeyCreationTime()); Utils.rollMockClock(60); wallet.freshReceiveKey(); assertEquals(now, wallet.getEarliestKeyCreationTime()); }
@Test public void scriptCreationTime() throws Exception { Utils.setMockClock(); long now = Utils.currentTimeSeconds(); wallet = new Wallet(PARAMS); assertEquals(now, wallet.getEarliestKeyCreationTime()); Utils.rollMockClock(-120); wallet.addWatchedAddress(OTHER_ADDRESS); wallet.freshReceiveKey(); assertEquals(now - 120, wallet.getEarliestKeyCreationTime()); }