org.bitcoinj.core.Transaction.getLockTime()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(10.2k)|赞(0)|评价(0)|浏览(151)

本文整理了Java中org.bitcoinj.core.Transaction.getLockTime()方法的一些代码示例,展示了Transaction.getLockTime()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Transaction.getLockTime()方法的具体详情如下:
包路径:org.bitcoinj.core.Transaction
类名称:Transaction
方法名:getLockTime

Transaction.getLockTime介绍

[英]Transactions can have an associated lock time, specified either as a block height or in seconds since the UNIX epoch. A transaction is not allowed to be confirmed by miners until the lock time is reached, and since Bitcoin 0.8+ a transaction that did not end its lock period (non final) is considered to be non standard and won't be relayed or included in the memory pool either.
[中]事务可以有一个关联的锁定时间,可以指定为块高度,也可以指定自UNIX纪元以来的秒数。在达到锁定时间之前,矿工不允许确认交易,而且由于比特币0.8+未结束锁定期(非最终)的交易被视为非标准交易,也不会被中继或包含在内存池中。

代码示例

代码示例来源:origin: fr.acinq/bitcoinj-core

long expiryTimeSeconds() {
  switch (majorVersion) {
    case 1:
      return refund.getLockTime() + 60 * 5;
    case 2:
      return expiryTime + 60 * 5;
    default:
      throw new IllegalStateException("Invalid version");
  }
}

代码示例来源:origin: greenaddress/GreenBits

long expiryTimeSeconds() {
  switch (majorVersion) {
    case 1:
      return refund.getLockTime() + 60 * 5;
    case 2:
      return expiryTime + 60 * 5;
    default:
      throw new IllegalStateException("Invalid version");
  }
}

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

long expiryTimeSeconds() {
  switch (majorVersion) {
    case 1:
      return refund.getLockTime() + 60 * 5;
    case 2:
      return expiryTime + 60 * 5;
    default:
      throw new IllegalStateException("Invalid version");
  }
}

代码示例来源:origin: HashEngineering/dashj

long expiryTimeSeconds() {
  switch (majorVersion) {
    case 1:
      return refund.getLockTime() + 60 * 5;
    case 2:
      return expiryTime + 60 * 5;
    default:
      throw new IllegalStateException("Invalid version");
  }
}

代码示例来源:origin: greenaddress/GreenBits

/**
 * Returns either the lock time as a date, if it was specified in seconds, or an estimate based on the time in
 * the current head block if it was specified as a block time.
 */
public Date estimateLockTime(AbstractBlockChain chain) {
  if (lockTime < LOCKTIME_THRESHOLD)
    return chain.estimateBlockTime((int)getLockTime());
  else
    return new Date(getLockTime()*1000);
}

代码示例来源:origin: fr.acinq/bitcoinj-core

/**
 * Returns either the lock time as a date, if it was specified in seconds, or an estimate based on the time in
 * the current head block if it was specified as a block time.
 */
public Date estimateLockTime(AbstractBlockChain chain) {
  if (lockTime < LOCKTIME_THRESHOLD)
    return chain.estimateBlockTime((int)getLockTime());
  else
    return new Date(getLockTime()*1000);
}

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

/**
 * Returns either the lock time as a date, if it was specified in seconds, or an estimate based on the time in
 * the current head block if it was specified as a block time.
 */
public Date estimateLockTime(AbstractBlockChain chain) {
  if (lockTime < LOCKTIME_THRESHOLD)
    return chain.estimateBlockTime((int)getLockTime());
  else
    return new Date(getLockTime()*1000);
}

代码示例来源:origin: HashEngineering/dashj

/**
 * Returns either the lock time as a date, if it was specified in seconds, or an estimate based on the time in
 * the current head block if it was specified as a block time.
 */
public Date estimateLockTime(AbstractBlockChain chain) {
  if (lockTime < LOCKTIME_THRESHOLD)
    return chain.estimateBlockTime((int)getLockTime());
  else
    return new Date(getLockTime()*1000);
}

代码示例来源:origin: fr.acinq/bitcoinj-core

/**
 * <p>Returns true if this transaction is considered finalized and can be placed in a block. Non-finalized
 * transactions won't be included by miners and can be replaced with newer versions using sequence numbers.
 * This is useful in certain types of <a href="http://en.bitcoin.it/wiki/Contracts">contracts</a>, such as
 * micropayment channels.</p>
 *
 * <p>Note that currently the replacement feature is disabled in Bitcoin Core and will need to be
 * re-activated before this functionality is useful.</p>
 */
public boolean isFinal(int height, long blockTimeSeconds) {
  long time = getLockTime();
  return time < (time < LOCKTIME_THRESHOLD ? height : blockTimeSeconds) || !isTimeLocked();
}

代码示例来源:origin: greenaddress/GreenBits

/**
 * <p>Returns true if this transaction is considered finalized and can be placed in a block. Non-finalized
 * transactions won't be included by miners and can be replaced with newer versions using sequence numbers.
 * This is useful in certain types of <a href="http://en.bitcoin.it/wiki/Contracts">contracts</a>, such as
 * micropayment channels.</p>
 *
 * <p>Note that currently the replacement feature is disabled in Bitcoin Core and will need to be
 * re-activated before this functionality is useful.</p>
 */
public boolean isFinal(int height, long blockTimeSeconds) {
  long time = getLockTime();
  return time < (time < LOCKTIME_THRESHOLD ? height : blockTimeSeconds) || !isTimeLocked();
}

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

/**
 * <p>Returns true if this transaction is considered finalized and can be placed in a block. Non-finalized
 * transactions won't be included by miners and can be replaced with newer versions using sequence numbers.
 * This is useful in certain types of <a href="http://en.bitcoin.it/wiki/Contracts">contracts</a>, such as
 * micropayment channels.</p>
 *
 * <p>Note that currently the replacement feature is disabled in Bitcoin Core and will need to be
 * re-activated before this functionality is useful.</p>
 */
public boolean isFinal(int height, long blockTimeSeconds) {
  long time = getLockTime();
  return time < (time < LOCKTIME_THRESHOLD ? height : blockTimeSeconds) || !isTimeLocked();
}

代码示例来源:origin: HashEngineering/dashj

/**
 * <p>Returns true if this transaction is considered finalized and can be placed in a block. Non-finalized
 * transactions won't be included by miners and can be replaced with newer versions using sequence numbers.
 * This is useful in certain types of <a href="http://en.bitcoin.it/wiki/Contracts">contracts</a>, such as
 * micropayment channels.</p>
 *
 * <p>Note that currently the replacement feature is disabled in Bitcoin Core and will need to be
 * re-activated before this functionality is useful.</p>
 */
public boolean isFinal(int height, long blockTimeSeconds) {
  long time = getLockTime();
  return time < (time < LOCKTIME_THRESHOLD ? height : blockTimeSeconds) || !isTimeLocked();
}

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

/**
 * <p>A transaction is time locked if at least one of its inputs is non-final and it has a lock time</p>
 *
 * <p>To check if this transaction is final at a given height and time, see {@link Transaction#isFinal(int, long)}
 * </p>
 */
public boolean isTimeLocked() {
  if (getLockTime() == 0)
    return false;
  for (TransactionInput input : getInputs())
    if (input.hasSequence())
      return true;
  return false;
}

代码示例来源:origin: greenaddress/GreenBits

/**
 * <p>A transaction is time locked if at least one of its inputs is non-final and it has a lock time</p>
 *
 * <p>To check if this transaction is final at a given height and time, see {@link Transaction#isFinal(int, long)}
 * </p>
 */
public boolean isTimeLocked() {
  if (getLockTime() == 0)
    return false;
  for (TransactionInput input : getInputs())
    if (input.hasSequence())
      return true;
  return false;
}

代码示例来源:origin: fr.acinq/bitcoinj-core

/**
 * <p>A transaction is time locked if at least one of its inputs is non-final and it has a lock time</p>
 *
 * <p>To check if this transaction is final at a given height and time, see {@link Transaction#isFinal(int, long)}
 * </p>
 */
public boolean isTimeLocked() {
  if (getLockTime() == 0)
    return false;
  for (TransactionInput input : getInputs())
    if (input.hasSequence())
      return true;
  return false;
}

代码示例来源:origin: HashEngineering/dashj

/**
 * <p>A transaction is time-locked if at least one of its inputs is non-final and it has a lock time. A transaction can
 * also have a relative lock time which this method doesn't tell. Use {@link #hasRelativeLockTime()} to find out.</p>
 *
 * <p>To check if this transaction is final at a given height and time, see {@link Transaction#isFinal(int, long)}
 * </p>
 */
public boolean isTimeLocked() {
  if (getLockTime() == 0)
    return false;
  for (TransactionInput input : getInputs())
    if (input.hasSequence())
      return true;
  return false;
}

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

PaymentChannelV1ClientState(StoredClientChannel storedClientChannel, Wallet wallet) throws VerificationException {
  super(storedClientChannel, wallet);
  // The PaymentChannelClientConnection handles storedClientChannel.active and ensures we aren't resuming channels
  this.multisigContract = checkNotNull(storedClientChannel.contract);
  this.multisigScript = multisigContract.getOutput(0).getScriptPubKey();
  this.refundTx = checkNotNull(storedClientChannel.refund);
  this.refundFees = checkNotNull(storedClientChannel.refundFees);
  this.expiryTime = refundTx.getLockTime();
  this.totalValue = multisigContract.getOutput(0).getValue();
  stateMachine.transition(State.READY);
  initWalletListeners();
}

代码示例来源:origin: fr.acinq/bitcoinj-core

PaymentChannelV1ClientState(StoredClientChannel storedClientChannel, Wallet wallet) throws VerificationException {
  super(storedClientChannel, wallet);
  // The PaymentChannelClientConnection handles storedClientChannel.active and ensures we aren't resuming channels
  this.multisigContract = checkNotNull(storedClientChannel.contract);
  this.multisigScript = multisigContract.getOutput(0).getScriptPubKey();
  this.refundTx = checkNotNull(storedClientChannel.refund);
  this.refundFees = checkNotNull(storedClientChannel.refundFees);
  this.expiryTime = refundTx.getLockTime();
  this.totalValue = multisigContract.getOutput(0).getValue();
  stateMachine.transition(State.READY);
  initWalletListeners();
}

代码示例来源:origin: HashEngineering/dashj

PaymentChannelV1ClientState(StoredClientChannel storedClientChannel, Wallet wallet) throws VerificationException {
  super(storedClientChannel, wallet);
  // The PaymentChannelClientConnection handles storedClientChannel.active and ensures we aren't resuming channels
  this.multisigContract = checkNotNull(storedClientChannel.contract);
  this.multisigScript = multisigContract.getOutput(0).getScriptPubKey();
  this.refundTx = checkNotNull(storedClientChannel.refund);
  this.refundFees = checkNotNull(storedClientChannel.refundFees);
  this.expiryTime = refundTx.getLockTime();
  this.totalValue = multisigContract.getOutput(0).getValue();
  stateMachine.transition(State.READY);
  initWalletListeners();
}

代码示例来源:origin: greenaddress/GreenBits

PaymentChannelV1ClientState(StoredClientChannel storedClientChannel, Wallet wallet) throws VerificationException {
  super(storedClientChannel, wallet);
  // The PaymentChannelClientConnection handles storedClientChannel.active and ensures we aren't resuming channels
  this.multisigContract = checkNotNull(storedClientChannel.contract);
  this.multisigScript = multisigContract.getOutput(0).getScriptPubKey();
  this.refundTx = checkNotNull(storedClientChannel.refund);
  this.refundFees = checkNotNull(storedClientChannel.refundFees);
  this.expiryTime = refundTx.getLockTime();
  this.totalValue = multisigContract.getOutput(0).getValue();
  stateMachine.transition(State.READY);
  initWalletListeners();
}

相关文章

微信公众号

最新文章

更多

Transaction类方法