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

Java TransactionInput类代码示例

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

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



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

示例1: isOutpointOneWeOffered

import com.google.bitcoin.core.TransactionInput; //导入依赖的package包/类
private boolean isOutpointOneWeOffered(TransactionInput input) {
	try {
		byte[] bytes = input.getOutpoint().getHash().getBytes();
		String hexHash = new String(Hex.encode(bytes));
						
		long inputIndex = input.getOutpoint().getIndex();

	    Log.d("SharedCoin", "SharedCoin isOutpointOneWeOffered hexHash: " + hexHash);
	    Log.d("SharedCoin", "SharedCoin isOutpointOneWeOffered inputIndex: " + inputIndex);

	    for (int i = 0; i < this.offered_outpoints.size(); i++) {
	    	JSONObject request_outpoint = (JSONObject) this.offered_outpoints.get(i);
	    	String hash = (String) request_outpoint.get("hash");
	    	long index =  SharedCoin.getLongFromLong(request_outpoint, "index");
	    	if (hash.equals(hexHash) && index == inputIndex) {
	    		return true;
	    	}
    	}
	    
	} catch (Exception e) {
		e.printStackTrace();
	}
    
          return false;
}
 
开发者ID:10xEngineer,项目名称:My-Wallet-Android,代码行数:26,代码来源:SharedCoin.java


示例2: CSBalanceTxTransfers

import com.google.bitcoin.core.TransactionInput; //导入依赖的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


示例3: computeSecret

import com.google.bitcoin.core.TransactionInput; //导入依赖的package包/类
protected void computeSecret() throws VerificationException {
	for (TransactionInput input : tx.getInputs()) {
		List<ScriptChunk> chunks = input.getScriptSig().getChunks();
		if (chunks.size() == 5) {
			byte[] data = chunks.get(SECRET_POSITION).data;
			if (hash != null) {
				if (Arrays.equals(hash, LotteryUtils.calcDoubleHash(data))) {
					possibleSecrets.add(data);
					return;
				}
			}
			else {
				possibleSecrets.add(data);
			}
		}
	}
	
	if (possibleSecrets.size() == 0) {
		throw new VerificationException("Not an Open transaction.");
	}
}
 
开发者ID:lukmaz,项目名称:BitcoinLottery,代码行数:22,代码来源:OpenTx.java


示例4: getFirstFromAddress

import com.google.bitcoin.core.TransactionInput; //导入依赖的package包/类
@CheckForNull
public static Address getFirstFromAddress(@Nonnull final Transaction tx)
{
	if (tx.isCoinBase())
		return null;

	try
	{
		for (final TransactionInput input : tx.getInputs())
		{
			return input.getFromAddress();
		}

		throw new IllegalStateException();
	}
	catch (final ScriptException x)
	{
		// this will happen on inputs connected to coinbase transactions
		return null;
	}
}
 
开发者ID:9cat,项目名称:templecoin-android-wallet,代码行数:22,代码来源:WalletUtils.java


示例5: buildRawTx

import com.google.bitcoin.core.TransactionInput; //导入依赖的package包/类
private static String buildRawTx() {
	ScriptBuilder builder = new ScriptBuilder();
	builder.op(OP_DEPTH).op(OP_1).op(OP_NUMEQUAL).op(OP_IF)
			.data("name of nakakamoto".getBytes()).op(OP_DROP)
			.op(OP_RIPEMD160).op(OP_RIPEMD160)
			.data(doublehash160("satoshi".getBytes())).op(OP_EQUAL)
			.op(OP_ELSE).op(OP_DUP).op(OP_HASH160)
			.data(doublehash160("Haha".getBytes())).op(OP_EQUALVERIFY)
			.op(OP_CHECKSIG).op(OP_ENDIF);

	Script outputScript = builder.build();
	Transaction tx1 = new Transaction(MainNetParams.get());
	tx1.addInput(new TransactionInput(MainNetParams.get(), tx1,
			new byte[] {}));
	ECKey key = new ECKey();
	tx1.addOutput(Bitcoins.toSatoshiEndBully(), key);
	Transaction tx2 = new Transaction(MainNetParams.get());

	tx2.addInput(tx1.getOutput(0));
	tx2.addOutput(Bitcoins.toSatoshiEndBully(), outputScript);
	tx2.addOutput(Bitcoins.toSatoshiEndBully(), key);
	System.out.println(tx2);
	String rawTx = BaseEncoding.base16().encode(
			tx2.unsafeBitcoinSerialize());
	return rawTx;
}
 
开发者ID:y12studio,项目名称:bkbc-tools,代码行数:27,代码来源:HintScriptBuilder.java


示例6: buildRawTx

import com.google.bitcoin.core.TransactionInput; //导入依赖的package包/类
private static String buildRawTx() {
	ProtoBlue puf = ProtoBlue.newBuilder().setBkbcValue(200855)
			.setProtoType(Type.TEST).setExchangeType(ExType.BTC_TWD)
			.setVersion(VerType.TEST1).build();
	System.out.println(puf);

	ScriptBuilder builder = new ScriptBuilder();
	builder.op(OP_RETURN).data(puf.toByteArray());

	Script outputScript = builder.build();
	Transaction tx1 = new Transaction(MainNetParams.get());
	tx1.addInput(new TransactionInput(MainNetParams.get(), tx1,
			new byte[] {}));
	ECKey key = new ECKey();
	tx1.addOutput(Bitcoins.toSatoshiEndBully(), key);
	Transaction tx2 = new Transaction(MainNetParams.get());

	tx2.addInput(tx1.getOutput(0));
	tx2.addOutput(Bitcoins.toSatoshiEndBully(), key);
	tx2.addOutput(Bitcoins.toSatoshiEndBully(), outputScript);
	System.out.println(tx2);
	String rawTx = BaseEncoding.base16().encode(
			tx2.unsafeBitcoinSerialize());
	return rawTx;
}
 
开发者ID:y12studio,项目名称:bkbc-tools,代码行数:26,代码来源:ScriptOpReturnBuilder.java


示例7: onCoinsReceived

import com.google.bitcoin.core.TransactionInput; //导入依赖的package包/类
@Override
public void onCoinsReceived(final Transaction tx, final long result)
{
	try {
		System.out.println("onCoinsReceived()");

		if (tx.getInputs() == null || tx.getInputs().size() == 0) {
			notifyCoinbaseReceived(BigInteger.valueOf(result));
		} else {
			final TransactionInput input = tx.getInputs().get(0);

			final Address from = input.getFromAddress();

			handler.post(new Runnable()
			{
				public void run()
				{
					notifyCoinsReceived(from, BigInteger.valueOf(result));

					notifyWidgets();

				}
			});
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:10xEngineer,项目名称:My-Wallet-Android,代码行数:29,代码来源:WebsocketService.java


示例8: addInputs

import com.google.bitcoin.core.TransactionInput; //导入依赖的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


示例9: onTransaction

import com.google.bitcoin.core.TransactionInput; //导入依赖的package包/类
@Override
public void onTransaction(Peer peer, Transaction tx) {
	try {
		log.info("TxLockTime {}", tx.getLockTime());
		log.info("TxIn{}/Out{}", tx.getInputs().size(), tx
				.getOutputs().size());
		log.info("Saw Tx {}", tx);
		if (_debug) {
			for (TransactionInput tin : tx.getInputs()) {
				log.info("InputSequenceNumber {}",
						tin.getSequenceNumber());

				if (tin.getSequenceNumber() == TransactionInput.NO_SEQUENCE) {
					log.info("InputSequenceNumber==UINT_MAX lock time ignored");
				}

				log.info("InputScriptSig {}", tin.getScriptSig()
						.toString());
				log.info("InputOutpoint previous output hash {}",
						tin.getOutpoint().getHash());
				log.info("InputOutpoint previous output index {}",
						tin.getOutpoint().getIndex());
				TransactionOutput tout = tin.getOutpoint()
						.getConnectedOutput();
				// Map<Sha256Hash, Integer> appearInHashes =
				// preTx.getAppearsInHashes();
				log.info("OutpointTx output", tout);
			}
		}
	} catch (ScriptException e) {
		e.printStackTrace();
	}
}
 
开发者ID:y12studio,项目名称:bkbc-tools,代码行数:34,代码来源:DebugPeerEventListener.java


示例10: newTxInput

import com.google.bitcoin.core.TransactionInput; //导入依赖的package包/类
/**
 * <p>Construct a TxInput message based on the given transaction </p>
 *
 * @param tx    The Bitcoinj transaction
 * @param index The index of the input transaction to work with
 *
 * @return A TxInput message representing the transaction input
 */
public static TrezorMessage.TxInput newTxInput(Transaction tx, int index) {

  Preconditions.checkNotNull(tx, "Transaction must be present");
  Preconditions.checkElementIndex(index, tx.getInputs().size(), "TransactionInput not present at index " + index);

  // Input index is valid
  TransactionInput txInput = tx.getInput(index);
  TrezorMessage.TxInput.Builder builder = TrezorMessage.TxInput.newBuilder();
  builder.setIndex(index);

  // Fill in the input addresses
  long prevIndex = txInput.getOutpoint().getIndex();
  byte[] prevHash = txInput.getOutpoint().getHash().getBytes();

  // In Bitcoinj "nanocoins" are Satoshis
  long satoshiAmount = txInput.getConnectedOutput().getValue().longValue();
  builder.setAmount(satoshiAmount);

  try {
    byte[] scriptSig = txInput.getScriptSig().toString().getBytes();
    builder.setScriptSig(ByteString.copyFrom(scriptSig));

    builder.setPrevIndex((int) prevIndex);
    builder.setPrevHash(ByteString.copyFrom(prevHash));

    builder.addAddressN(0);
    builder.addAddressN(index);

    return builder.build();

  } catch (ScriptException e) {
    throw new IllegalStateException(e);
  }

}
 
开发者ID:Multibit-Legacy,项目名称:trezorj,代码行数:44,代码来源:TrezorMessageUtils.java


示例11: chooseOutputs

import com.google.bitcoin.core.TransactionInput; //导入依赖的package包/类
private List<TransactionOutput> chooseOutputs(BigInteger value) {
	SendRequest tempRequest = SendRequest.to(getKey().toAddress(params),
			value);
	this.vWallet.completeTx(tempRequest);
	List<TransactionOutput> outputs = new ArrayList<TransactionOutput>();
	for (TransactionInput in : tempRequest.tx.getInputs()) {
		outputs.add(in.getConnectedOutput());
	}
	return outputs;
}
 
开发者ID:aakselrod,项目名称:libtxchain-java,代码行数:11,代码来源:Peer.java


示例12: signMyInputs

import com.google.bitcoin.core.TransactionInput; //导入依赖的package包/类
void signMyInputs(Transaction tx) {
	// This is to sign only MY OWN inputs in a transaction
	try {
		for (int i = 0; i < tx.getInputs().size(); i++) {
			TransactionInput in = tx.getInput(i);
			TransactionOutput cOut = in.getConnectedOutput();
			Script pubKey = cOut.getScriptPubKey();
			if (cOut.isMine(this.vWallet)) {
				TransactionSignature sig = tx.calculateSignature(i,
						getKey(), pubKey, SigHash.ALL, false);
				if (pubKey.isSentToAddress()
						&& (pubKey.getToAddress(params).equals(getKey()
								.toAddress(params)))) {
					in.setScriptSig(new ScriptBuilder()
							.data(sig.encodeToBitcoin())
							.data(getKey().getPubKey()).build());
				} else if (pubKey.isSentToRawPubKey()
						&& (pubKey.getPubKey().equals(getKey().getPubKey()))) {
					in.setScriptSig(new ScriptBuilder().data(
							sig.encodeToBitcoin()).build());
				}
			}
		}
	} catch (Exception e) {
		// No exception handling for this demo
		e.printStackTrace();
	}
}
 
开发者ID:aakselrod,项目名称:libtxchain-java,代码行数:29,代码来源:Peer.java


示例13: checkExpire

import com.google.bitcoin.core.TransactionInput; //导入依赖的package包/类
void checkExpire() {
	TransactionConfidence conf = getConfidence(this.refundTransaction);
	if ((conf == null) || (conf.getDepthInBlocks() == 0)) {  
		for (WalletTransaction wtx:getParentPeer().wallet().getWalletTransactions()) {
			if (wtx.getTransaction().getHash() == id()) {
				TransactionInput txin = wtx.getTransaction().getOutput(0).getSpentBy();
				if (txin != null) {
					this.refundTransaction = txin.getParentTransaction();
				}
				break;
			}
		}
	}
}
 
开发者ID:aakselrod,项目名称:libtxchain-java,代码行数:15,代码来源:PaymentChannel.java


示例14: getConnectedOutPoint

import com.google.bitcoin.core.TransactionInput; //导入依赖的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


示例15: sweepKey

import com.google.bitcoin.core.TransactionInput; //导入依赖的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


示例16: validateGenesis

import com.google.bitcoin.core.TransactionInput; //导入依赖的package包/类
private boolean validateGenesis(PeerGroup pg) 
{
    CSAssetState initialState=assetValidationState;
    
    if(pg == null)
    {
        return false;
    }
    
    if(genesis != null)
    {
        if(firstSpentTxID != null)
        {
            return false; 
        }
    }
    
    if(assetRef == null)
    {
        assetValidationState = CSAssetState.NO_KEY;
        return (assetValidationState != initialState);
    }
    
    CSEventBus.INSTANCE.postAsyncEvent(CSEventType.ASSET_VALIDATION_STARTED, assetID);
    
    assetValidationState= CSAssetState.NOT_VALIDATED_YET;
    log.info("Asset: Retrieving genesis information for asset " + assetID + ", AssetRef " + assetRef.toString());
    
    Block block=pg.getBlock((int)assetRef.getBlockNum());    

    if(block == null)
    {
        assetValidationState= CSAssetState.BLOCK_NOT_FOUND;
        log.info("Asset: Cannot find block with height " + (int)assetRef.getBlockNum());
        return (assetValidationState != initialState);
    }

    Transaction tx=block.getTransactionByOffset((int)assetRef.getTxOffset());
    if(tx == null)
    {
        assetValidationState= CSAssetState.TX_NOT_FOUND;
        log.info("Asset: Cannot find transaction with offset " + (int)assetRef.getTxOffset() + " in block " +
                block.getHashAsString());
        return (assetValidationState != initialState);
    }
    
    if(!Arrays.equals(Arrays.copyOf(assetRef.getTxIDPrefix(),CoinSparkAssetRef.COINSPARK_ASSETREF_TXID_PREFIX_LEN), 
                      Arrays.copyOf(tx.getHash().getBytes(),CoinSparkAssetRef.COINSPARK_ASSETREF_TXID_PREFIX_LEN)))
    {
        assetValidationState= CSAssetState.TX_NOT_FOUND;
        log.info("Asset: TxID prefix doesn't match, need " + CSUtils.byte2Hex(assetRef.getTxIDPrefix()) + ", found " +
                CSUtils.byte2Hex(Arrays.copyOf(tx.getHash().getBytes(),CoinSparkAssetRef.COINSPARK_ASSETREF_TXID_PREFIX_LEN)));
        return (assetValidationState != initialState);           
    }
    
    genTxID=tx.getHash().toString();
    genesis=new CSTransactionAssets(tx).getGenesis();   
    
    TransactionInput firstInput=tx.getInput(0);
    if(firstInput != null)
    {            
        firstSpentTxID=firstInput.getOutpoint().getHash().toString();
        firstSpentVout=firstInput.getOutpoint().getIndex();
    }
    
    if(firstInput == null)
    {
        genesis=null;
    }
    
    assetValidationState= CSAssetState.NOT_VALIDATED_YET;
    if(genesis==null)
    {
        assetValidationState=CSAssetState.GENESIS_NOT_FOUND;
    }
    
    return (assetValidationState != initialState);
}
 
开发者ID:coinspark,项目名称:sparkbit-bitcoinj,代码行数:79,代码来源:CSAsset.java


示例17: validateIsCompute

import com.google.bitcoin.core.TransactionInput; //导入依赖的package包/类
protected void validateIsCompute(List<PutMoneyTx> inputs) throws VerificationException {
	if (inputs != null) {
		noPlayers = inputs.size();
	}
	else {
		noPlayers = tx.getInputs().size();
	}
	if (noPlayers < 2 || noPlayers != tx.getInputs().size()) {
		throw new VerificationException("Wrong number of inputs.");
	}
	else if (tx.getOutputs().size() != 1) {
		throw new VerificationException("Wrong number of outputs.");
	}
	else if (tx.isCoinBase() || tx.isTimeLocked()) {
		throw new VerificationException("Not a Compute transaction");
	}
	for (int k = 0; k < tx.getInputs().size(); ++k) {
		TransactionInput in = tx.getInput(k);
		if (in.hasSequence()) {
			throw new VerificationException("Wrong sequence number.");
		}
		else if (in.getScriptSig().getChunks().size() != 2) {
			throw new VerificationException("Wrong sig script.");
		}
		if (inputs != null) {
			in.connect(inputs.get(k).getOut());
			in.verify();
		}
	}
	
	tx.verify();
	
	computeMinLength();
	computeSecretsHashes();
	computePks();
	computeSignatures();
	
	if (minLength < 0 || !Arrays.equals(tx.getOutput(0).getScriptPubKey().getProgram(), calculateOutScript().getProgram())) {
		throw new VerificationException("Wrong out script.");
	}
}
 
开发者ID:lukmaz,项目名称:BitcoinLottery,代码行数:42,代码来源:ComputeTx.java


示例18: commitTransaction

import com.google.bitcoin.core.TransactionInput; //导入依赖的package包/类
public void commitTransaction(Transaction tx, Long highest_block, Boolean confirmed)
{
    // This function asks the database to store the change outputs of the bulletin as unspent
    // outputs. Additionally, the transaction is stored as unconfirmed.

    if ( !db.hasTx(tx) )
    {
        // Add raw transaction to database.
        db.addTx(tx, confirmed, highest_block);

        // Add all relevant future outpoints to ahimsaDB.
        int vout = 0;
        for(TransactionOutput out : tx.getOutputs())
        {
            Log.d(TAG, "commitTransaction() | " + out.toString());
            Log.d(TAG, "isRelevant(): " + isRelevant(out));
            if(isRelevant(out))
            {
                Log.d(TAG, "txout(): " + out.toString());
                db.addTxOut(out, vout);
            }
            vout++;
        }

        // Flag funding outs as spent.
        boolean unreserve_required = false;
        for(TransactionInput in : tx.getInputs())
        {
            String previous_txid = in.getOutpoint().getHash().toString();
            Long previous_vout = in.getOutpoint().getIndex();

            Log.d(TAG, "tx_in previous_txid | " + previous_txid);
            Log.d(TAG, "tx_in previous_vout | " + previous_vout);

            if( db.setStatusSpent(previous_txid, previous_vout) )
            {
                unreserve_required = true;
            }
        }

        // Spent an unreserved txout, must remove a reserved txout.
        if (unreserve_required)
        {
            db.unreserveTxOuts(Constants.getStandardCoin());
        }

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


示例19: close

import com.google.bitcoin.core.TransactionInput; //导入依赖的package包/类
void close() {
	Transaction closingTransaction;
	// This and other similar code should really use a deep copy or serialize/deserialize
	if (this.refundTransaction.getLockTime() <= this.lastSentTransaction.getLockTime()) {
		closingTransaction = this.refundTransaction;
	} else {
		closingTransaction = this.lastSentTransaction;
	}
	closingTransaction.setLockTime(getParentPeer().chain().getBestChainHeight() - 1);
	closingTransaction.getInput(0).setSequenceNumber(TransactionInput.NO_SEQUENCE - 1);
	// It might be a good idea to consider removing the hash preimage check from the
	// criteria to close the channel, obviating the need for a redeem transaction
	try {
		closingTransaction.getInput(0).setScriptSig(new ScriptBuilder()
			.data(closingTransaction.calculateSignature(0, getParentPeerKey(),
					this.setupTransaction.getOutput(0).getScriptPubKey(),
					SigHash.ALL, false).encodeToBitcoin())
			.build());
	} catch (Exception e) {
		// No exception handling for this demo
		e.printStackTrace();
	}
	closingTransaction = getPeer().closeChannel(getParentPeerKey(), id(), closingTransaction);
	getParentPeer().wallet().addWalletTransaction(
			new WalletTransaction(Pool.PENDING, closingTransaction));
	getParentPeer().peerGroup().broadcastTransaction(closingTransaction);
	this.redeemTransaction = new Transaction(getParentPeer().params());
	this.redeemTransaction.addOutput(
			closingTransaction.getOutput(this.iAmInitiator ? 0 : 1).getValue().subtract(this.initialFee),
			getParentPeerKey().toAddress(getParentPeer().params()));
	this.redeemTransaction.addInput(closingTransaction.getOutput(this.iAmInitiator ? 0 : 1));
	this.redeemTransaction.getInput(0).setScriptSig(
			new ScriptBuilder()
			.data(this.redeemTransaction.calculateSignature(0, getParentPeerKey(), null,
					closingTransaction.getOutput(this.iAmInitiator ? 0 : 1).getScriptBytes(), SigHash.ALL, false)
					.encodeToBitcoin())
			.data(this.committedPreImage)
			.build());
	getParentPeer().wallet().addWalletTransaction(
			new WalletTransaction(WalletTransaction.Pool.PENDING, this.redeemTransaction));
	getParentPeer().peerGroup().broadcastTransaction(this.redeemTransaction);
	this.state = State.CLOSING;
}
 
开发者ID:aakselrod,项目名称:libtxchain-java,代码行数:44,代码来源:PaymentChannel.java


示例20: getConnectedOutput

import com.google.bitcoin.core.TransactionInput; //导入依赖的package包/类
public static TransactionOutput getConnectedOutput(TransactionInput input,
        Wallet wallet) {
    int idx = (int) input.getOutpoint().getIndex();
    Sha256Hash txId = input.getOutpoint().getHash();
    return wallet.getTransaction(txId).getOutput(idx);
}
 
开发者ID:dustyneuron,项目名称:bitprivacy,代码行数:7,代码来源:WalletUtils.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java EclipseCompiler类代码示例发布时间:2022-05-22
下一篇:
Java MinecartInteractEvent类代码示例发布时间: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