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

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

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

Transaction.addOutput介绍

[英]Creates an output based on the given address and value, adds it to this transaction, and returns the new output.
[中]基于给定的地址和值创建输出,将其添加到此事务中,然后返回新的输出。

代码示例

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

/**
 * Creates an output that pays to the given pubkey directly (no address) with the given value, adds it to this
 * transaction, and returns the new output.
 */
public TransactionOutput addOutput(Coin value, ECKey pubkey) {
  return addOutput(new TransactionOutput(params, this, value, pubkey));
}

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

/**
 * Creates an output that pays to the given pubkey directly (no address) with the given value, adds it to this
 * transaction, and returns the new output.
 */
public TransactionOutput addOutput(Coin value, ECKey pubkey) {
  return addOutput(new TransactionOutput(params, this, value, pubkey));
}

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

/**
 * Creates an output that pays to the given pubkey directly (no address) with the given value, adds it to this
 * transaction, and returns the new output.
 */
public TransactionOutput addOutput(Coin value, ECKey pubkey) {
  return addOutput(new TransactionOutput(params, this, value, pubkey));
}

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

/**
 * Creates an output based on the given address and value, adds it to this transaction, and returns the new output.
 */
public TransactionOutput addOutput(Coin value, Address address) {
  return addOutput(new TransactionOutput(params, this, value, address));
}

代码示例来源:origin: Coinomi/coinomi-android

public void addAllOutputs(List<TransactionOutput> outputs) {
  checkArgument(outputs.size() == numberOfOutputs, "Number of outputs don't match");
  if (trimmedOutputs != null) {
    trimmedOutputs = null;
  }
  long index = 0;
  for (TransactionOutput output : outputs) {
    super.addOutput(new TrimmedOutput(output, index++, this));
  }
}

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

/**
 * Creates an output that pays to the given script. The address and key forms are specialisations of this method,
 * you won't normally need to use it unless you're doing unusual things.
 */
public TransactionOutput addOutput(Coin value, Script script) {
  return addOutput(new TransactionOutput(params, this, value, script.getProgram()));
}

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

/**
 * Creates an output that pays to the given script. The address and key forms are specialisations of this method,
 * you won't normally need to use it unless you're doing unusual things.
 */
public TransactionOutput addOutput(Coin value, Script script) {
  return addOutput(new TransactionOutput(params, this, value, script.getProgram()));
}

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

/**
 * Creates an output that pays to the given script. The address and key forms are specialisations of this method,
 * you won't normally need to use it unless you're doing unusual things.
 */
public TransactionOutput addOutput(Coin value, Script script) {
  return addOutput(new TransactionOutput(params, this, value, script.getProgram()));
}

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

public static SendRequest emptyWallet(Address destination) {
  SendRequest req = new SendRequest();
  final NetworkParameters parameters = destination.getParameters();
  checkNotNull(parameters, "Address is for an unknown network");
  req.tx = new Transaction(parameters);
  req.tx.addOutput(Coin.ZERO, destination);
  req.emptyWallet = true;
  return req;
}

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

public static SendRequest toCLTVPaymentChannel(NetworkParameters params, BigInteger time, ECKey from, ECKey to, Coin value) {
  SendRequest req = new SendRequest();
  Script output = ScriptBuilder.createCLTVPaymentChannelOutput(time, from, to);
  req.tx = new Transaction(params);
  req.tx.addOutput(value, output);
  return req;
}

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

public static SendRequest toCLTVPaymentChannel(NetworkParameters params, BigInteger time, ECKey from, ECKey to, Coin value) {
  SendRequest req = new SendRequest();
  Script output = ScriptBuilder.createCLTVPaymentChannelOutput(time, from, to);
  req.tx = new Transaction(params);
  req.tx.addOutput(value, output);
  return req;
}

代码示例来源:origin: blockchain/thunder

public Transaction getClosingTransaction (ChannelStatus channelStatus, float feePerByte) {
  //For the sake of privacy (and simplicity) we use lexicographically ordering here, as defined in BIP69
  Transaction transaction = new Transaction(Constants.getNetwork());
  transaction.addInput(channel.anchorTxHash, 0, Tools.getDummyScript());
  //TODO deduct the transaction fee correctly from both amounts
  //TODO would be better to have another address on file that we can use here..
  long feePerParty = (Tools.getTransactionFees(2, 2, feePerByte) / 2);
  transaction.addOutput(Coin.valueOf(channelStatus.amountClient - feePerParty), channel.channelStatus.addressClient);
  transaction.addOutput(Coin.valueOf(channelStatus.amountServer - feePerParty), channel.channelStatus.addressServer);
  return Tools.applyBIP69(transaction);
}

代码示例来源:origin: Coinomi/coinomi-android

public static BitSendRequest emptyWallet(BitAddress destination) {
  checkNotNull(destination.getType(), "Address is for an unknown network");
  checkTypeCompatibility(destination.getType());
  BitSendRequest req = new BitSendRequest(destination.getType());
  Transaction tx = new Transaction(req.type);
  tx.addOutput(Coin.ZERO, destination);
  req.tx = new BitTransaction(tx);
  req.emptyWallet = true;
  return req;
}

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

/**
 * Returns a {@link SendRequest} suitable for broadcasting to the network.
 */
public SendRequest getSendRequest() {
  Transaction tx = new Transaction(params);
  for (Protos.Output output : paymentDetails.getOutputsList())
    tx.addOutput(new TransactionOutput(params, tx, Coin.valueOf(output.getAmount()), output.getScript().toByteArray()));
  return SendRequest.forTx(tx).fromPaymentDetails(paymentDetails);
}

代码示例来源:origin: blockchain/thunder

public void fillAnchorTransactionWithoutSignatures (WalletHelper walletHelper) {
  long totalAmount = channelStatus.amountServer + channelStatus.amountClient;
  if (anchorTx == null) {
    Script anchorScriptServer = getAnchorScriptOutput();
    Script anchorScriptServerP2SH = ScriptBuilder.createP2SHOutputScript(anchorScriptServer);
    anchorTx = new Transaction(Constants.getNetwork());
    anchorTx.addOutput(Coin.valueOf(totalAmount), anchorScriptServerP2SH);
  }
  anchorTx = walletHelper.addInputs(anchorTx, channelStatus.amountServer, channelStatus.feePerByte);
  anchorTxHash = anchorTx.getHash();
}

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

@Test
public void opReturnOneOutputWithValueTest() throws Exception {
  // Tests basic send of transaction with one output that destroys coins and has an OP_RETURN.
  receiveATransaction(wallet, myAddress);
  Transaction tx = new Transaction(PARAMS);
  Coin messagePrice = CENT;
  Script script = ScriptBuilder.createOpReturnScript("hello world!".getBytes());
  tx.addOutput(messagePrice, script);
  SendRequest request = SendRequest.forTx(tx);
  wallet.completeTx(request);
}

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

protected synchronized SendRequest makeUnsignedChannelContract(Coin valueToMe) {
  Transaction tx = new Transaction(wallet.getParams());
  if (!getTotalValue().subtract(valueToMe).equals(Coin.ZERO)) {
    tx.addOutput(getTotalValue().subtract(valueToMe), getClientKey().toAddress(wallet.getParams()));
  }
  tx.addInput(contract.getOutput(0));
  return SendRequest.forTx(tx);
}

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

protected synchronized SendRequest makeUnsignedChannelContract(Coin valueToMe) {
  Transaction tx = new Transaction(wallet.getParams());
  if (!getTotalValue().subtract(valueToMe).equals(Coin.ZERO)) {
    tx.addOutput(getTotalValue().subtract(valueToMe), getClientKey().toAddress(wallet.getParams()));
  }
  tx.addInput(contract.getOutput(0));
  return SendRequest.forTx(tx);
}

代码示例来源:origin: Coinomi/coinomi-android

@Test
public void serializeTransactionsBtc() throws Exception, Bip44KeyLookAheadExceededException {
  WalletPocketHD account = new WalletPocketHD(rootKey, BTC, null, null);
  Transaction tx = new Transaction(BTC);
  tx.addOutput(BTC.oneCoin().toCoin(), account.getReceiveAddress());
  account.addNewTransactionIfNeeded(tx);
  testWalletSerializationForCoin(account);
}

代码示例来源:origin: Coinomi/coinomi-android

@Test
public void serializeTransactionsNbt() throws Exception, Bip44KeyLookAheadExceededException {
  WalletPocketHD account = new WalletPocketHD(rootKey, NBT, null, null);
  Transaction tx = new Transaction(NBT);
  tx.addOutput(NBT.oneCoin().toCoin(), account.getReceiveAddress());
  account.addNewTransactionIfNeeded(tx);
  testWalletSerializationForCoin(account);
}

相关文章

微信公众号

最新文章

更多

Transaction类方法