• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java TransactionOutPoint类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: CSBalanceTxTransfers

import com.google.bitcoin.core.TransactionOutPoint; //导入依赖的package包/类
public CSBalanceTxTransfers(int AssetID,Transaction Tx)
{
    valid=true;
    inputs=new CSBalanceUpdate[Tx.getInputs().size()];
    int count=0;
    for(TransactionInput input : Tx.getInputs())
    {
        TransactionOutPoint outPoint=input.getOutpoint();
        if(outPoint != null)
        {
            CSBalanceEntry be=new CSBalanceEntry();
            inputs[count]=new CSBalanceUpdate(new CSTransactionOutput(outPoint.getHash(), (int)outPoint.getIndex()), AssetID, new CSBalanceEntry(), -1, null);
        }
        else
        {
            valid=false;
        }
        count++;
    }
            
    outputs=new CSBalanceUpdate[Tx.getOutputs().size()];
    for(int i=0;i<Tx.getOutputs().size();i++)
    {
        outputs[i]=null;
    }
}
 
开发者ID:coinspark,项目名称:sparkbit-bitcoinj,代码行数:27,代码来源:CSBalanceDatabase.java


示例2: createTx

import com.google.bitcoin.core.TransactionOutPoint; //导入依赖的package包/类
public static Transaction createTx(ECKey key, List<TransactionOutPoint> unspents, String topic, String message) throws Exception
{
    //create new transaction
    Transaction bulletin = new Transaction(Constants.NETWORK_PARAMETERS);

    //add inputs and message outputs
    addInputs(bulletin, unspents);
    addBulletinOutputs(bulletin, topic, message);

    //add change output to transaction
    addChangeOutput(key, bulletin, unspents);

    //sign the inputs
    BasicKeyChain keychain = new BasicKeyChain();
    keychain.importKey(key);
    bulletin.signInputs(SigHash.ALL, false, keychain);
    return bulletin;
}
 
开发者ID:alexkuck,项目名称:ahimsa-app,代码行数:19,代码来源:BulletinBuilder.java


示例3: getUnspentOutPoints

import com.google.bitcoin.core.TransactionOutPoint; //导入依赖的package包/类
public List<TransactionOutPoint> getUnspentOutPoints(Long min_coin_necessary)
{
    //get unspent transactions sorted in descending order
    List<TransactionOutPoint> db_unspent = getAllUnspentOutPoints();
    Coin min = Coin.valueOf( min_coin_necessary );

    ArrayList<TransactionOutPoint> unspents = new ArrayList<TransactionOutPoint>();
    Coin bal = Coin.ZERO;

    for(TransactionOutPoint outpoint : db_unspent)
    {
        if(bal.compareTo(min) >= 0)
            break;

        unspents.add(outpoint);
        bal = bal.add(outpoint.getConnectedOutput().getValue());
    }

    return unspents;
}
 
开发者ID:alexkuck,项目名称:ahimsa-app,代码行数:21,代码来源:AhimsaDB.java


示例4: getAllUnspentOutPoints

import com.google.bitcoin.core.TransactionOutPoint; //导入依赖的package包/类
public List<TransactionOutPoint> getAllUnspentOutPoints()
{
    //return all confirmed and unspent/pending transaction outputs in descending order by value

    String sql = "SELECT txouts.vout, transactions.raw FROM txouts JOIN transactions ON transactions.txid == txouts.txid " +
            "WHERE transactions.confirmed == 1 AND (txouts.status == 'unspent' OR txouts.status == 'pending') ORDER BY txouts.value DESC;";

    Cursor cursor = db.rawQuery(sql, null);
    ArrayList<TransactionOutPoint> result = new ArrayList<TransactionOutPoint>();

    while(cursor.moveToNext())
    {
        int vout = cursor.getInt(0);
        byte[] raw_tx = cursor.getBlob(1);

        Transaction parent_tx = new Transaction(Constants.NETWORK_PARAMETERS, cursor.getBlob(1));
        TransactionOutPoint outpoint = new TransactionOutPoint(Constants.NETWORK_PARAMETERS, vout, parent_tx);
        result.add( outpoint );
    }

    return result;
}
 
开发者ID:alexkuck,项目名称:ahimsa-app,代码行数:23,代码来源:AhimsaDB.java


示例5: addInputs

import com.google.bitcoin.core.TransactionOutPoint; //导入依赖的package包/类
private static void addInputs(Transaction tx, List<TransactionOutPoint> unspents)
{
    for(TransactionOutPoint outpoint : unspents)
    {
        tx.addInput(new TransactionInput(Constants.NETWORK_PARAMETERS, tx, new byte[]{}, outpoint));
    }
}
 
开发者ID:alexkuck,项目名称:ahimsa-app,代码行数:8,代码来源:BulletinBuilder.java


示例6: addChangeOutput

import com.google.bitcoin.core.TransactionOutPoint; //导入依赖的package包/类
private static void addChangeOutput(ECKey key, Transaction tx, List<TransactionOutPoint> unspents) throws Exception
{
    Coin fee        = Coin.valueOf(Constants.MIN_FEE);
    Coin in_coin    = totalInCoin(unspents);
    Coin out_coin   = totalOutCoin(tx);

    Coin total = Coin.ZERO.add(in_coin).subtract(out_coin).subtract(fee);

    String TAG = "BulletinBuilder";
    Log.d(TAG, "fee |" + fee.toString());
    Log.d(TAG, "in_coin |" + in_coin.toString());
    Log.d(TAG, "out_coin |" + out_coin.toString());
    Log.d(TAG, "total |" + total.toString());


    switch ( total.compareTo(Coin.ZERO) )
    {
        case  0:
        case  1:    break;
        case -1:    Log.d(TAG, Utils.bytesToHex(tx.bitcoinSerialize()) );
            throw new Exception("out_coin + fee exceeds in_coin | " + total.toString());
    }

    Coin min = Coin.valueOf( Constants.getStandardCoin() );
    Address default_addr = key.toAddress(Constants.NETWORK_PARAMETERS);

    while(total.compareTo(Coin.ZERO) == 1)
    {
        if(total.subtract(min).compareTo(min) >= 0)
        {
            tx.addOutput( new TransactionOutput(Constants.NETWORK_PARAMETERS, tx, min, default_addr) );
            total = total.subtract(min);
        }
        else
        {
            tx.addOutput( new TransactionOutput(Constants.NETWORK_PARAMETERS, tx, total, default_addr) );
            total = total.subtract(total);
        }
    }
}
 
开发者ID:alexkuck,项目名称:ahimsa-app,代码行数:41,代码来源:BulletinBuilder.java


示例7: totalInCoin

import com.google.bitcoin.core.TransactionOutPoint; //导入依赖的package包/类
private static Coin totalInCoin(List<TransactionOutPoint> db_unspent)
{
    Coin in_coin = Coin.ZERO;
    for(TransactionOutPoint output : db_unspent)
    {
        in_coin = in_coin.add(output.getConnectedOutput().getValue());
    }
    return in_coin;
}
 
开发者ID:alexkuck,项目名称:ahimsa-app,代码行数:10,代码来源:BulletinBuilder.java


示例8: createAndAddBulletin

import com.google.bitcoin.core.TransactionOutPoint; //导入依赖的package包/类
public Transaction createAndAddBulletin(String topic, String message, Long fee) throws Exception
{
    if(topic == null || topic.equals("") )
    {
        // Ensure topic and message content is proper
        //todo remove this
        topic = Constants.DEFAULT_TOPIC;
    }

    if(message == null)
    {
        message = "";
    }

    // Get the right amount of unspent transaction outputs to spend from
    List<TransactionOutPoint> unspents = db.getUnspentOutPoints(Constants.getStandardCoin());
    Log.d(TAG, "UNSPENT.TOSTRING() from CREATEANDADDBULLETIN()");
    Log.d(TAG, unspents.toString());

    // Create a bulletin using system's configuration file, a bitcoinj wallet, the unspent
    // txouts gathered, and the topic and message.
    Transaction bulletin = BulletinBuilder.createTx(key, unspents, topic, message);

    // Add this bulletin to the bulletin table
    // todo | atomicity (include with commit of transaction)
    db.addBulletin(bulletin.getHashAsString(), topic, message, fee);

    return bulletin;
}
 
开发者ID:alexkuck,项目名称:ahimsa-app,代码行数:30,代码来源:AhimsaWallet.java


示例9: getConnectedOutPoint

import com.google.bitcoin.core.TransactionOutPoint; //导入依赖的package包/类
public static TransactionOutPoint getConnectedOutPoint(
        TransactionInput input, Wallet wallet) {
    Sha256Hash id = input.getOutpoint().getHash();
    Transaction t = wallet.getTransaction(id);
    if (t == null) {
        System.out.println("tx " + id + " not found in wallet");
        return null;
    }
    return new TransactionOutPoint(wallet.getNetworkParameters(),
            (int) input.getOutpoint().getIndex(), t);
}
 
开发者ID:dustyneuron,项目名称:bitprivacy,代码行数:12,代码来源:WalletUtils.java


示例10: MyTransactionInput

import com.google.bitcoin.core.TransactionOutPoint; //导入依赖的package包/类
public MyTransactionInput(NetworkParameters params, Transaction parentTransaction, byte[] scriptBytes, TransactionOutPoint outpoint) {
	super(params, parentTransaction, scriptBytes, outpoint);
	
	this.params = params;
}
 
开发者ID:10xEngineer,项目名称:My-Wallet-Android,代码行数:6,代码来源:MyTransactionInput.java


示例11: sweepKey

import com.google.bitcoin.core.TransactionOutPoint; //导入依赖的package包/类
public void sweepKey(ECKey key, long fee,
                     int accountId, JSONArray outputs) {
    mLogger.info("sweepKey starting");

    mLogger.info("key addr " + key.toAddress(mParams).toString());

    Transaction tx = new Transaction(mParams);

    long balance = 0;
    ArrayList<Script> scripts = new ArrayList<Script>();
    try {
        for (int ii = 0; ii < outputs.length(); ++ii) {
            JSONObject output;
output = outputs.getJSONObject(ii);

            String tx_hash = output.getString("tx_hash");
            int tx_output_n = output.getInt("tx_output_n");
            String script = output.getString("script");

            // Reverse byte order, create hash.
            Sha256Hash hash =
                new Sha256Hash(WalletUtil.msgHexToBytes(tx_hash));
        
            tx.addInput(new TransactionInput
                        (mParams, tx, new byte[]{},
                         new TransactionOutPoint(mParams,
                                                 tx_output_n, hash)));

            scripts.add(new Script(Hex.decode(script)));
                
            balance += output.getLong("value");
        }
    } catch (JSONException e) {
        e.printStackTrace();
        throw new RuntimeException("trouble parsing unspent outputs");
    }

    // Compute balance - fee.
    long amount = balance - fee;
    mLogger.info(String.format("sweeping %d", amount));

    // Figure out the destination address.
    Address to = mHDReceiver.nextReceiveAddress();
    mLogger.info("sweeping to " + to.toString());

    // Add output.
    tx.addOutput(BigInteger.valueOf(amount), to);

    WalletUtil.signTransactionInputs(tx, Transaction.SigHash.ALL,
                                     key, scripts);

    mLogger.info("tx bytes: " +
                 new String(Hex.encode(tx.bitcoinSerialize())));

    // mKit.peerGroup().broadcastTransaction(tx);
    broadcastTransaction(mKit.peerGroup(), tx);

    mLogger.info("sweepKey finished");
}
 
开发者ID:ksedgwic,项目名称:BTCReceive,代码行数:60,代码来源:WalletService.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PacketChannelOpenConfirmation类代码示例发布时间:2022-05-22
下一篇:
Java HLL类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap