当前位置: 首页>>代码示例>>Java>>正文


Java TransactionOutPoint类代码示例

本文整理汇总了Java中org.bitcoinj.core.TransactionOutPoint的典型用法代码示例。如果您正苦于以下问题:Java TransactionOutPoint类的具体用法?Java TransactionOutPoint怎么用?Java TransactionOutPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TransactionOutPoint类属于org.bitcoinj.core包,在下文中一共展示了TransactionOutPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBloomFilter

import org.bitcoinj.core.TransactionOutPoint; //导入依赖的package包/类
/**
 * <p>Gets a bloom filter that contains all of the public keys from this wallet, and which will provide the given
 * false-positive rate if it has size elements. Keep in mind that you will get 2 elements in the bloom filter for
 * each key in the wallet, for the public key and the hash of the public key (address form).</p>
 * 
 * <p>This is used to generate a BloomFilter which can be {@link BloomFilter#merge(BloomFilter)}d with another.
 * It could also be used if you have a specific target for the filter's size.</p>
 * 
 * <p>See the docs for {@link BloomFilter#BloomFilter(int, double, long, org.bitcoinj.core.BloomFilter.BloomUpdate)} for a brief explanation of anonymity when using bloom
 * filters.</p>
 */
@Override @GuardedBy("keyChainGroupLock")
public BloomFilter getBloomFilter(int size, double falsePositiveRate, long nTweak) {
    beginBloomFilterCalculation();
    try {
        BloomFilter filter = keyChainGroup.getBloomFilter(size, falsePositiveRate, nTweak);
        for (Script script : watchedScripts) {
            for (ScriptChunk chunk : script.getChunks()) {
                // Only add long (at least 64 bit) data to the bloom filter.
                // If any long constants become popular in scripts, we will need logic
                // here to exclude them.
                if (!chunk.isOpCode() && chunk.data.length >= MINIMUM_BLOOM_DATA_LENGTH) {
                    filter.insert(chunk.data);
                }
            }
        }
        for (TransactionOutPoint point : bloomOutPoints)
            filter.insert(point.unsafeBitcoinSerialize());
        return filter;
    } finally {
        endBloomFilterCalculation();
    }
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:34,代码来源:Wallet.java

示例2: getBloomFilter

import org.bitcoinj.core.TransactionOutPoint; //导入依赖的package包/类
/**
 * <p>Gets a bloom filter that contains all of the public keys from this wallet, and which will provide the given
 * false-positive rate if it has size elements. Keep in mind that you will get 2 elements in the bloom filter for
 * each key in the wallet, for the public key and the hash of the public key (address form).</p>
 * 
 * <p>This is used to generate a BloomFilter which can be {@link BloomFilter#merge(BloomFilter)}d with another.
 * It could also be used if you have a specific target for the filter's size.</p>
 * 
 * <p>See the docs for {@link BloomFilter(int, double)} for a brief explanation of anonymity when using bloom
 * filters.</p>
 */
@Override @GuardedBy("keyChainGroupLock")
public BloomFilter getBloomFilter(int size, double falsePositiveRate, long nTweak) {
    beginBloomFilterCalculation();
    try {
        BloomFilter filter = keyChainGroup.getBloomFilter(size, falsePositiveRate, nTweak);
        for (Script script : watchedScripts) {
            for (ScriptChunk chunk : script.getChunks()) {
                // Only add long (at least 64 bit) data to the bloom filter.
                // If any long constants become popular in scripts, we will need logic
                // here to exclude them.
                if (!chunk.isOpCode() && chunk.data.length >= MINIMUM_BLOOM_DATA_LENGTH) {
                    filter.insert(chunk.data);
                }
            }
        }
        for (TransactionOutPoint point : bloomOutPoints)
            filter.insert(point.unsafeBitcoinSerialize());
        return filter;
    } finally {
        endBloomFilterCalculation();
    }
}
 
开发者ID:Grant-Redmond,项目名称:cryptwallet,代码行数:34,代码来源:Wallet.java

示例3: watchingScriptsBloomFilter

import org.bitcoinj.core.TransactionOutPoint; //导入依赖的package包/类
@Test
public void watchingScriptsBloomFilter() throws Exception {
    assertFalse(wallet.isRequiringUpdateAllBloomFilter());

    Address watchedAddress = new ECKey().toAddress(PARAMS);
    Transaction t1 = createFakeTx(PARAMS, CENT, watchedAddress);
    TransactionOutPoint outPoint = new TransactionOutPoint(PARAMS, 0, t1);
    wallet.addWatchedAddress(watchedAddress);

    assertTrue(wallet.isRequiringUpdateAllBloomFilter());
    // Note that this has a 1e-12 chance of failing this unit test due to a false positive
    assertFalse(wallet.getBloomFilter(1e-12).contains(outPoint.unsafeBitcoinSerialize()));

    sendMoneyToWallet(BlockChain.NewBlockType.BEST_CHAIN, t1);
    assertTrue(wallet.getBloomFilter(1e-12).contains(outPoint.unsafeBitcoinSerialize()));
}
 
开发者ID:Grant-Redmond,项目名称:cryptwallet,代码行数:17,代码来源:WalletTest.java

示例4: removeScriptsBloomFilter

import org.bitcoinj.core.TransactionOutPoint; //导入依赖的package包/类
@Test
public void removeScriptsBloomFilter() throws Exception {
    List<Address> addressesForRemoval = new ArrayList<Address>();
    for (int i = 0; i < 10; i++) {
        Address watchedAddress = new ECKey().toAddress(PARAMS);
        addressesForRemoval.add(watchedAddress);
        wallet.addWatchedAddress(watchedAddress);
    }

    wallet.removeWatchedAddresses(addressesForRemoval);

    for (Address addr : addressesForRemoval) {
        Transaction t1 = createFakeTx(PARAMS, CENT, addr);
        TransactionOutPoint outPoint = new TransactionOutPoint(PARAMS, 0, t1);

        // Note that this has a 1e-12 chance of failing this unit test due to a false positive
        assertFalse(wallet.getBloomFilter(1e-12).contains(outPoint.unsafeBitcoinSerialize()));

        sendMoneyToWallet(BlockChain.NewBlockType.BEST_CHAIN, t1);
        assertFalse(wallet.getBloomFilter(1e-12).contains(outPoint.unsafeBitcoinSerialize()));
    }
}
 
开发者ID:Grant-Redmond,项目名称:cryptwallet,代码行数:23,代码来源:WalletTest.java

示例5: getRawTxFee

import org.bitcoinj.core.TransactionOutPoint; //导入依赖的package包/类
@Nullable
public Value getRawTxFee(TransactionWatcherWallet wallet) {
    Preconditions.checkState(!isTrimmed, "Cannot get raw tx fee from a trimmed transaction");
    Value fee = type.value(0);
    for (TransactionInput input : tx.getInputs()) {
        TransactionOutPoint outPoint = input.getOutpoint();
        BitTransaction inTx = wallet.getTransaction(outPoint.getHash());
        if (inTx == null || !inTx.isOutputAvailable((int) outPoint.getIndex())) {
            return null;
        }
        TransactionOutput txo = inTx.getOutput((int) outPoint.getIndex());
        fee = fee.add(txo.getValue());
    }
    for (TransactionOutput output : getOutputs()) {
        fee = fee.subtract(output.getValue());
    }
    return fee;
}
 
开发者ID:filipnyquist,项目名称:lbry-android,代码行数:19,代码来源:BitTransaction.java

示例6: getUnspentForScriptHash

import org.bitcoinj.core.TransactionOutPoint; //导入依赖的package包/类
@Override
public synchronized Collection<TransactionOutPoint> getUnspentForScriptHash(ByteString prefix)
{ 
  Collection<ByteString> txinfo = db_map.getSet(prefix, 10000);

  LinkedList<TransactionOutPoint> outs = new LinkedList<TransactionOutPoint>();

    for(ByteString key : txinfo)
    {
      
      ByteString tx_data = key.substring(0,32);
      ByteBuffer bb = ByteBuffer.wrap(key.substring(32).toByteArray());
      bb.order(java.nio.ByteOrder.LITTLE_ENDIAN);
      int idx=bb.getInt();

      Sha256Hash tx_id = new Sha256Hash(tx_data.toByteArray());
      TransactionOutPoint o = new TransactionOutPoint(jelly.getNetworkParameters(), idx, tx_id);
      outs.add(o);
     
    }

  return outs;
}
 
开发者ID:fireduck64,项目名称:jelectrum,代码行数:24,代码来源:SimpleUtxoMgr.java

示例7: putTxOutSpents

import org.bitcoinj.core.TransactionOutPoint; //导入依赖的package包/类
public void putTxOutSpents(Transaction tx)
{
  LinkedList<String> tx_outs = new LinkedList<String>();

    for(TransactionInput in : tx.getInputs())
    {
        if (!in.isCoinBase())
        {
            TransactionOutPoint out = in.getOutpoint();
            String key = out.getHash().toString() + ":" + out.getIndex();
            //file_db.addTxOutSpentByMap(key, tx.getHash());
            tx_outs.add(key);

        }
    }
}
 
开发者ID:fireduck64,项目名称:jelectrum,代码行数:17,代码来源:Importer.java

示例8: areSomeInputsPending

import org.bitcoinj.core.TransactionOutPoint; //导入依赖的package包/类
public boolean areSomeInputsPending(Transaction tx)
{
  MemPoolInfo info = latest_info;
  if (info == null) return false; //Hard to say

  for(TransactionInput tx_in : tx.getInputs())
  {
    if (!tx_in.isCoinBase())
    {
      TransactionOutPoint tx_out = tx_in.getOutpoint();
      Sha256Hash parent_hash = tx_out.getHash();
      if (info.tx_set.contains(parent_hash)) return true;
    }
  }
  return false;
}
 
开发者ID:fireduck64,项目名称:jelectrum,代码行数:17,代码来源:MemPooler.java

示例9: removeScriptsBloomFilter

import org.bitcoinj.core.TransactionOutPoint; //导入依赖的package包/类
@Test
public void removeScriptsBloomFilter() throws Exception {
    List<Address> addressesForRemoval = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        Address watchedAddress = new ECKey().toAddress(PARAMS);
        addressesForRemoval.add(watchedAddress);
        wallet.addWatchedAddress(watchedAddress);
    }

    wallet.removeWatchedAddresses(addressesForRemoval);

    for (Address addr : addressesForRemoval) {
        Transaction t1 = createFakeTx(PARAMS, CENT, addr);
        TransactionOutPoint outPoint = new TransactionOutPoint(PARAMS, 0, t1);

        // Note that this has a 1e-12 chance of failing this unit test due to a false positive
        assertFalse(wallet.getBloomFilter(1e-12).contains(outPoint.unsafeBitcoinSerialize()));

        sendMoneyToWallet(BlockChain.NewBlockType.BEST_CHAIN, t1);
        assertFalse(wallet.getBloomFilter(1e-12).contains(outPoint.unsafeBitcoinSerialize()));
    }
}
 
开发者ID:bitcoinj,项目名称:bitcoinj,代码行数:23,代码来源:WalletTest.java

示例10: marriedKeychainBloomFilter

import org.bitcoinj.core.TransactionOutPoint; //导入依赖的package包/类
@Test
public void marriedKeychainBloomFilter() throws Exception {
    createMarriedWallet(2, 2);
    Address address = wallet.currentReceiveAddress();

    assertTrue(wallet.getBloomFilter(0.001).contains(address.getHash160()));

    Transaction t1 = createFakeTx(PARAMS, CENT, address);
    TransactionOutPoint outPoint = new TransactionOutPoint(PARAMS, 0, t1);

    assertFalse(wallet.getBloomFilter(0.001).contains(outPoint.unsafeBitcoinSerialize()));

    sendMoneyToWallet(BlockChain.NewBlockType.BEST_CHAIN, t1);
    assertTrue(wallet.getBloomFilter(0.001).contains(outPoint.unsafeBitcoinSerialize()));
}
 
开发者ID:Grant-Redmond,项目名称:cryptwallet,代码行数:16,代码来源:WalletTest.java

示例11: getValueSent

import org.bitcoinj.core.TransactionOutPoint; //导入依赖的package包/类
public Value getValueSent(TransactionWatcherWallet wallet) {
    if (isTrimmed) {
        return getValueSent();
    } else {
        tx.ensureParsed();
        // Find the value of the inputs that draw value from the wallet
        Value sent = type.value(0);
        Map<Sha256Hash, BitTransaction> transactions = wallet.getTransactions();
        for (TransactionInput input : tx.getInputs()) {
            TransactionOutPoint outPoint = input.getOutpoint();
            // This input is taking value from a transaction in our wallet. To discover the value,
            // we must find the connected transaction.
            OutPointOutput connected = wallet.getUnspentTxOutput(outPoint);
            if (connected == null) {
                BitTransaction spendingTx = transactions.get(outPoint.getHash());
                int index = (int) outPoint.getIndex();
                if (spendingTx != null && spendingTx.isOutputAvailable(index)) {
                    connected = new OutPointOutput(spendingTx, index);
                }
            }

            if (connected == null)
                continue;

            // The connected output may be the change to the sender of a previous input sent to this wallet. In this
            // case we ignore it.
            if (!connected.getOutput().isMineOrWatched(wallet))
                continue;

            sent = sent.add(connected.getValue());
        }

        return sent;
    }
}
 
开发者ID:filipnyquist,项目名称:lbry-android,代码行数:36,代码来源:BitTransaction.java

示例12: getUnspentTxOutput

import org.bitcoinj.core.TransactionOutPoint; //导入依赖的package包/类
public OutPointOutput getUnspentTxOutput(TransactionOutPoint outPoint) {
    lock.lock();
    try {
        return unspentOutputs.get(TrimmedOutPoint.get(outPoint));
    } finally {
        lock.unlock();
    }
}
 
开发者ID:filipnyquist,项目名称:lbry-android,代码行数:9,代码来源:TransactionWatcherWallet.java

示例13: listUnspentOutPoints

import org.bitcoinj.core.TransactionOutPoint; //导入依赖的package包/类
public List<TransactionOutPoint> listUnspentOutPoints(Address fromAddress) throws JsonRPCStatusException, IOException {
    List<Address> addresses = Collections.singletonList(fromAddress);
    List<UnspentOutput> unspentOutputsRPC = listUnspent(0, defaultMaxConf, addresses); // RPC UnspentOutput objects
    List<TransactionOutPoint> unspentOutPoints = new ArrayList<TransactionOutPoint>();
    for (UnspentOutput it : unspentOutputsRPC) {
        unspentOutPoints.add(new TransactionOutPoint(getNetParams(), it.getVout(), it.getTxid()));
    }
    return unspentOutPoints;
}
 
开发者ID:ConsensusJ,项目名称:consensusj,代码行数:10,代码来源:BitcoinExtendedClient.java

示例14: getUnspentForAddress

import org.bitcoinj.core.TransactionOutPoint; //导入依赖的package包/类
public synchronized Collection<TransactionOutPoint> getUnspentForAddress(Address a)
{ 
  String prefix = getPrefixForAddress(a);

  Collection<String> keys = getByKey("").getKeysByPrefix(prefix, this);

  LinkedList<TransactionOutPoint> outs = new LinkedList<TransactionOutPoint>();

  try
  {
    for(String key : keys)
    {
      byte[] key_data=Hex.decodeHex(key.toCharArray());
      ByteBuffer bb = ByteBuffer.wrap(key_data);
      bb.order(java.nio.ByteOrder.LITTLE_ENDIAN);
      bb.position(20);
      byte[] tx_data = new byte[32];
      bb.get(tx_data);
      int idx=bb.getInt();
      Sha256Hash tx_id = new Sha256Hash(tx_data);
      TransactionOutPoint o = new TransactionOutPoint(jelly.getNetworkParameters(), idx, tx_id);
      outs.add(o);
     
    }
  }
  catch(org.apache.commons.codec.DecoderException e)
  { 
    throw new RuntimeException(e);
  }



  return outs;
}
 
开发者ID:fireduck64,项目名称:jelectrum,代码行数:35,代码来源:UtxoTrieMgr.java

示例15: getKeyForInput

import org.bitcoinj.core.TransactionOutPoint; //导入依赖的package包/类
public String getKeyForInput(TransactionInput in)
{
  if (in.isCoinBase()) return null;
  try
  {   
    byte[] public_key=null; 
    Address a = in.getFromAddress();
    public_key = a.getHash160();

    return getKey(public_key, in.getOutpoint().getHash(), (int)in.getOutpoint().getIndex());
  }
  catch(ScriptException e)
  {
    //Lets try this the other way
    try
    {   

      TransactionOutPoint out_p = in.getOutpoint();

      Transaction src_tx = tx_util.getTransaction(out_p.getHash());
      TransactionOutput out = src_tx.getOutput((int)out_p.getIndex());
      return getKeyForOutput(out, (int)out_p.getIndex());
    }
    catch(ScriptException e2)
    {   
      return null;
    }
  }

 
}
 
开发者ID:fireduck64,项目名称:jelectrum,代码行数:32,代码来源:UtxoTrieMgr.java


注:本文中的org.bitcoinj.core.TransactionOutPoint类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。