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

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

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

Transaction.isMature介绍

[英]A transaction is mature if it is either a building coinbase tx that is as deep or deeper than the required coinbase depth, or a non-coinbase tx.
[中]如果交易是深度等于或大于所需coinbase深度的建筑coinbase tx,或者是非coinbase tx,则交易是成熟的。

代码示例

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

/**
 * Returns all the outputs that match addresses or scripts added via {@link #addWatchedAddress(Address)} or
 * {@link #addWatchedScripts(java.util.List)}.
 * @param excludeImmatureCoinbases Whether to ignore outputs that are unspendable due to being immature.
 */
public List<TransactionOutput> getWatchedOutputs(boolean excludeImmatureCoinbases) {
  lock.lock();
  keyChainGroupLock.lock();
  try {
    LinkedList<TransactionOutput> candidates = Lists.newLinkedList();
    for (Transaction tx : Iterables.concat(unspent.values(), pending.values())) {
      if (excludeImmatureCoinbases && !tx.isMature()) continue;
      for (TransactionOutput output : tx.getOutputs()) {
        if (!output.isAvailableForSpending()) continue;
        try {
          Script scriptPubKey = output.getScriptPubKey();
          if (!watchedScripts.contains(scriptPubKey)) continue;
          candidates.add(output);
        } catch (ScriptException e) {
          // Ignore
        }
      }
    }
    return candidates;
  } finally {
    keyChainGroupLock.unlock();
    lock.unlock();
  }
}

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

/**
 * Returns all the outputs that match addresses or scripts added via {@link #addWatchedAddress(Address)} or
 * {@link #addWatchedScripts(java.util.List)}.
 * @param excludeImmatureCoinbases Whether to ignore outputs that are unspendable due to being immature.
 */
public List<TransactionOutput> getWatchedOutputs(boolean excludeImmatureCoinbases) {
  lock.lock();
  keyChainGroupLock.lock();
  try {
    LinkedList<TransactionOutput> candidates = Lists.newLinkedList();
    for (Transaction tx : Iterables.concat(unspent.values(), pending.values())) {
      if (excludeImmatureCoinbases && !tx.isMature()) continue;
      for (TransactionOutput output : tx.getOutputs()) {
        if (!output.isAvailableForSpending()) continue;
        try {
          Script scriptPubKey = output.getScriptPubKey();
          if (!watchedScripts.contains(scriptPubKey)) continue;
          candidates.add(output);
        } catch (ScriptException e) {
          // Ignore
        }
      }
    }
    return candidates;
  } finally {
    keyChainGroupLock.unlock();
    lock.unlock();
  }
}

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

/**
 * Returns all the outputs that match addresses or scripts added via {@link #addWatchedAddress(Address)} or
 * {@link #addWatchedScripts(java.util.List)}.
 * @param excludeImmatureCoinbases Whether to ignore outputs that are unspendable due to being immature.
 */
public List<TransactionOutput> getWatchedOutputs(boolean excludeImmatureCoinbases) {
  lock.lock();
  keyChainGroupLock.lock();
  try {
    LinkedList<TransactionOutput> candidates = Lists.newLinkedList();
    for (Transaction tx : Iterables.concat(unspent.values(), pending.values())) {
      if (excludeImmatureCoinbases && !tx.isMature()) continue;
      for (TransactionOutput output : tx.getOutputs()) {
        if (!output.isAvailableForSpending()) continue;
        try {
          Script scriptPubKey = output.getScriptPubKey();
          if (!watchedScripts.contains(scriptPubKey)) continue;
          candidates.add(output);
        } catch (ScriptException e) {
          // Ignore
        }
      }
    }
    return candidates;
  } finally {
    keyChainGroupLock.unlock();
    lock.unlock();
  }
}

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

/**
 * Returns all the outputs that match addresses or scripts added via {@link #addWatchedAddress(Address)} or
 * {@link #addWatchedScripts(java.util.List)}.
 * @param excludeImmatureCoinbases Whether to ignore outputs that are unspendable due to being immature.
 */
public List<TransactionOutput> getWatchedOutputs(boolean excludeImmatureCoinbases) {
  lock.lock();
  keyChainGroupLock.lock();
  try {
    LinkedList<TransactionOutput> candidates = Lists.newLinkedList();
    for (Transaction tx : Iterables.concat(unspent.values(), pending.values())) {
      if (excludeImmatureCoinbases && !tx.isMature()) continue;
      for (TransactionOutput output : tx.getOutputs()) {
        if (!output.isAvailableForSpending()) continue;
        try {
          Script scriptPubKey = output.getScriptPubKey();
          if (!watchedScripts.contains(scriptPubKey)) continue;
          candidates.add(output);
        } catch (ScriptException e) {
          // Ignore
        }
      }
    }
    return candidates;
  } finally {
    keyChainGroupLock.unlock();
    lock.unlock();
  }
}

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

/**
 * Returns a list of all outputs that are being tracked by this wallet either from the {@link UTXOProvider}
 * (in this case the existence or not of private keys is ignored), or the wallets internal storage (the default)
 * taking into account the flags.
 *
 * @param excludeImmatureCoinbases Whether to ignore coinbase outputs that we will be able to spend in future once they mature.
 * @param excludeUnsignable Whether to ignore outputs that we are tracking but don't have the keys to sign for.
 */
public List<TransactionOutput> calculateAllSpendCandidates(boolean excludeImmatureCoinbases, boolean excludeUnsignable) {
  lock.lock();
  try {
    List<TransactionOutput> candidates;
    if (vUTXOProvider == null) {
      candidates = new ArrayList<>(myUnspents.size());
      for (TransactionOutput output : myUnspents) {
        if (excludeUnsignable && !canSignFor(output.getScriptPubKey())) continue;
        Transaction transaction = checkNotNull(output.getParentTransaction());
        if (excludeImmatureCoinbases && !transaction.isMature())
          continue;
        candidates.add(output);
      }
    } else {
      candidates = calculateAllSpendCandidatesFromUTXOProvider(excludeImmatureCoinbases);
    }
    return candidates;
  } finally {
    lock.unlock();
  }
}

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

/**
 * Returns a list of all outputs that are being tracked by this wallet either from the {@link UTXOProvider}
 * (in this case the existence or not of private keys is ignored), or the wallets internal storage (the default)
 * taking into account the flags.
 *
 * @param excludeImmatureCoinbases Whether to ignore coinbase outputs that we will be able to spend in future once they mature.
 * @param excludeUnsignable Whether to ignore outputs that we are tracking but don't have the keys to sign for.
 */
public List<TransactionOutput> calculateAllSpendCandidates(boolean excludeImmatureCoinbases, boolean excludeUnsignable) {
  lock.lock();
  try {
    List<TransactionOutput> candidates;
    if (vUTXOProvider == null) {
      candidates = new ArrayList<>(myUnspents.size());
      for (TransactionOutput output : myUnspents) {
        if (excludeUnsignable && !canSignFor(output.getScriptPubKey())) continue;
        Transaction transaction = checkNotNull(output.getParentTransaction());
        if (excludeImmatureCoinbases && !transaction.isMature())
          continue;
        candidates.add(output);
      }
    } else {
      candidates = calculateAllSpendCandidatesFromUTXOProvider(excludeImmatureCoinbases);
    }
    return candidates;
  } finally {
    lock.unlock();
  }
}

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

/**
 * Returns a list of all outputs that are being tracked by this wallet either from the {@link UTXOProvider}
 * (in this case the existence or not of private keys is ignored), or the wallets internal storage (the default)
 * taking into account the flags.
 *
 * @param excludeImmatureCoinbases Whether to ignore coinbase outputs that we will be able to spend in future once they mature.
 * @param excludeUnsignable Whether to ignore outputs that we are tracking but don't have the keys to sign for.
 */
public List<TransactionOutput> calculateAllSpendCandidates(boolean excludeImmatureCoinbases, boolean excludeUnsignable) {
  lock.lock();
  try {
    List<TransactionOutput> candidates;
    if (vUTXOProvider == null) {
      candidates = new ArrayList<TransactionOutput>(myUnspents.size());
      for (TransactionOutput output : myUnspents) {
        if (excludeUnsignable && !canSignFor(output.getScriptPubKey())) continue;
        Transaction transaction = checkNotNull(output.getParentTransaction());
        if (excludeImmatureCoinbases && !transaction.isMature())
          continue;
        candidates.add(output);
      }
    } else {
      candidates = calculateAllSpendCandidatesFromUTXOProvider(excludeImmatureCoinbases);
    }
    return candidates;
  } finally {
    lock.unlock();
  }
}

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

/**
 * Returns a list of all outputs that are being tracked by this wallet either from the {@link UTXOProvider}
 * (in this case the existence or not of private keys is ignored), or the wallets internal storage (the default)
 * taking into account the flags.
 *
 * @param excludeImmatureCoinbases Whether to ignore coinbase outputs that we will be able to spend in future once they mature.
 * @param excludeUnsignable Whether to ignore outputs that we are tracking but don't have the keys to sign for.
 */
public List<TransactionOutput> calculateAllSpendCandidates(boolean excludeImmatureCoinbases, boolean excludeUnsignable) {
  lock.lock();
  try {
    List<TransactionOutput> candidates;
    if (vUTXOProvider == null) {
      candidates = new ArrayList<TransactionOutput>(myUnspents.size());
      for (TransactionOutput output : myUnspents) {
        if (excludeUnsignable && !canSignFor(output.getScriptPubKey())) continue;
        Transaction transaction = checkNotNull(output.getParentTransaction());
        if (excludeImmatureCoinbases && !transaction.isMature())
          continue;
        candidates.add(output);
      }
    } else {
      candidates = calculateAllSpendCandidatesFromUTXOProvider(excludeImmatureCoinbases);
    }
    return candidates;
  } finally {
    lock.unlock();
  }
}

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

if (!excludeImmatureCoinbases || tx.isMature()) {
  for (TransactionOutput output : tx.getOutputs()) {
    if (output.isAvailableForSpending() && output.isMine(this)) {

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

if (!excludeImmatureCoinbases || tx.isMature()) {
  for (TransactionOutput output : tx.getOutputs()) {
    if (output.isAvailableForSpending() && output.isMine(this)) {

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

if (!excludeImmatureCoinbases || tx.isMature()) {
  for (TransactionOutput output : tx.getOutputs()) {
    if (output.isAvailableForSpending() && output.isMine(this)) {

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

if (!excludeImmatureCoinbases || tx.isMature()) {
  for (TransactionOutput output : tx.getOutputs()) {
    if (output.isAvailableForSpending() && output.isMine(this)) {

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

@Test
public void testIsMatureReturnsFalseIfTransactionIsCoinbaseAndConfidenceTypeIsNotEqualToBuilding() {
  Transaction tx = FakeTxBuilder.createFakeCoinbaseTx(PARAMS);
  tx.getConfidence().setConfidenceType(ConfidenceType.UNKNOWN);
  assertEquals(tx.isMature(), false);
  tx.getConfidence().setConfidenceType(ConfidenceType.PENDING);
  assertEquals(tx.isMature(), false);
  tx.getConfidence().setConfidenceType(ConfidenceType.DEAD);
  assertEquals(tx.isMature(), false);
}

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

assertTrue(!coinbaseTransaction.isMature());
  assertTrue(!coinbaseTransaction.isMature());
assertTrue(coinbaseTransaction.isMature());

相关文章

微信公众号

最新文章

更多

Transaction类方法