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

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

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

Transaction.getParams介绍

暂无

代码示例

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

/** Creates a new inv message for the given transactions. */
  public static InventoryMessage with(Transaction... txns) {
    checkArgument(txns.length > 0);
    InventoryMessage result = new InventoryMessage(txns[0].getParams());
    for (Transaction tx : txns)
      result.addTransaction(tx);
    return result;
  }
}

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

/** Creates a new inv message for the given transactions. */
  public static InventoryMessage with(Transaction... txns) {
    checkArgument(txns.length > 0);
    InventoryMessage result = new InventoryMessage(txns[0].getParams());
    for (Transaction tx : txns)
      result.addTransaction(tx);
    return result;
  }
}

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

/** Creates a new inv message for the given transactions. */
  public static InventoryMessage with(Transaction... txns) {
    checkArgument(txns.length > 0);
    InventoryMessage result = new InventoryMessage(txns[0].getParams());
    for (Transaction tx : txns)
      result.addTransaction(tx);
    return result;
  }
}

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

/** Creates a new inv message for the given transactions. */
  public static InventoryMessage with(Transaction... txns) {
    checkArgument(txns.length > 0);
    InventoryMessage result = new InventoryMessage(txns[0].getParams());
    for (Transaction tx : txns)
      result.addTransaction(tx);
    return result;
  }
}

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

/**
 * Generates a Payment message based on the information in the PaymentRequest.
 * Provide transactions built by the wallet.
 * If the PaymentRequest did not specify a payment_url, returns null.
 * @param txns list of transactions to be included with the Payment message.
 * @param refundAddr will be used by the merchant to send money back if there was a problem.
 * @param memo is a message to include in the payment message sent to the merchant.
 */
@Nullable
public Protos.Payment getPayment(List<Transaction> txns, @Nullable Address refundAddr, @Nullable String memo)
    throws IOException, PaymentProtocolException.InvalidNetwork {
  if (paymentDetails.hasPaymentUrl()) {
    for (Transaction tx : txns)
      if (!tx.getParams().equals(params))
        throw new PaymentProtocolException.InvalidNetwork(params.getPaymentProtocolId());
    return PaymentProtocol.createPaymentMessage(txns, totalValue, refundAddr, memo, getMerchantData());
  } else {
    return null;
  }
}

代码示例来源:origin: dogecoin/libdohj

/**
 * Generates a Payment message based on the information in the PaymentRequest.
 * Provide transactions built by the wallet.
 * If the PaymentRequest did not specify a payment_url, returns null.
 * @param txns list of transactions to be included with the Payment message.
 * @param refundAddr will be used by the merchant to send money back if there was a problem.
 * @param memo is a message to include in the payment message sent to the merchant.
 */
public @Nullable Protos.Payment getPayment(List<Transaction> txns, @Nullable Address refundAddr, @Nullable String memo)
    throws IOException, PaymentProtocolException.InvalidNetwork {
  if (paymentDetails.hasPaymentUrl()) {
    for (Transaction tx : txns)
      if (!tx.getParams().equals(params))
        throw new PaymentProtocolException.InvalidNetwork(params.getPaymentProtocolId());
    return PaymentProtocol.createPaymentMessage(txns, totalValue, refundAddr, memo, getMerchantData());
  } else {
    return null;
  }
}

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

/**
 * Generates a Payment message based on the information in the PaymentRequest.
 * Provide transactions built by the wallet.
 * If the PaymentRequest did not specify a payment_url, returns null.
 * @param txns list of transactions to be included with the Payment message.
 * @param refundAddr will be used by the merchant to send money back if there was a problem.
 * @param memo is a message to include in the payment message sent to the merchant.
 */
@Nullable
public Protos.Payment getPayment(List<Transaction> txns, @Nullable Address refundAddr, @Nullable String memo)
    throws IOException, PaymentProtocolException.InvalidNetwork {
  if (paymentDetails.hasPaymentUrl()) {
    for (Transaction tx : txns)
      if (!tx.getParams().equals(params))
        throw new PaymentProtocolException.InvalidNetwork(params.getPaymentProtocolId());
    return PaymentProtocol.createPaymentMessage(txns, totalValue, refundAddr, memo, getMerchantData());
  } else {
    return null;
  }
}

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

/**
 * Generates a Payment message based on the information in the PaymentRequest.
 * Provide transactions built by the wallet.
 * If the PaymentRequest did not specify a payment_url, returns null.
 * @param txns list of transactions to be included with the Payment message.
 * @param refundAddr will be used by the merchant to send money back if there was a problem.
 * @param memo is a message to include in the payment message sent to the merchant.
 */
@Nullable
public Protos.Payment getPayment(List<Transaction> txns, @Nullable Address refundAddr, @Nullable String memo)
    throws IOException, PaymentProtocolException.InvalidNetwork {
  if (paymentDetails.hasPaymentUrl()) {
    for (Transaction tx : txns)
      if (!tx.getParams().equals(params))
        throw new PaymentProtocolException.InvalidNetwork(params.getPaymentProtocolId());
    return PaymentProtocol.createPaymentMessage(txns, totalValue, refundAddr, memo, getMerchantData());
  } else {
    return null;
  }
}

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

public BitTransaction(Sha256Hash transactionId, Transaction transaction, boolean isTrimmed,
           Value valueSent, Value valueReceived, @Nullable Value fee) {
  tx = checkNotNull(transaction);
  type = (CoinType) tx.getParams();
  this.isTrimmed = isTrimmed;
  if (isTrimmed) {
    hash = checkNotNull(transactionId);
    this.valueSent = checkNotNull(valueSent);
    this.valueReceived = checkNotNull(valueReceived);
    this.value = valueReceived.subtract(valueSent);
    this.fee = fee;
  } else {
    hash = null;
    this.valueSent = null;
    this.valueReceived = null;
    this.value = null;
    this.fee = null;
  }
}

代码示例来源:origin: openwalletGH/openwallet-android

public BitTransaction(Sha256Hash transactionId, Transaction transaction, boolean isTrimmed,
           Value valueSent, Value valueReceived, @Nullable Value fee) {
  tx = checkNotNull(transaction);
  type = (CoinType) tx.getParams();
  this.isTrimmed = isTrimmed;
  if (isTrimmed) {
    hash = checkNotNull(transactionId);
    this.valueSent = checkNotNull(valueSent);
    this.valueReceived = checkNotNull(valueReceived);
    this.value = valueReceived.subtract(valueSent);
    this.fee = fee;
  } else {
    hash = null;
    this.valueSent = null;
    this.valueReceived = null;
    this.value = null;
    this.fee = null;
  }
}

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

/**
 * Generates a Payment message based on the information in the PaymentRequest.
 * Provide transactions built by the wallet.
 * If the PaymentRequest did not specify a payment_url, returns null.
 * @param txns list of transactions to be included with the Payment message.
 * @param refundAddr will be used by the merchant to send money back if there was a problem.
 * @param memo is a message to include in the payment message sent to the merchant.
 */
@Nullable
public Protos.Payment getPayment(List<Transaction> txns, @Nullable Address refundAddr, @Nullable String memo)
    throws IOException, PaymentProtocolException.InvalidNetwork {
  if (paymentDetails.hasPaymentUrl()) {
    for (Transaction tx : txns) {
      // BIP70 doesn't allow for regtest in its network type. If we mismatch,
      // treat regtest transactions for a testnet payment request as a match.
      if (!tx.getParams().equals(params) &&
        (!tx.getParams().equals(RegTestParams.get()) || !params.equals(TestNet3Params.get())))
        throw new PaymentProtocolException.InvalidNetwork(params.getPaymentProtocolId());
    }
    return PaymentProtocol.createPaymentMessage(txns, totalValue, refundAddr, memo, getMerchantData());
  } else {
    return null;
  }
}

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

public static boolean isSelectable(Transaction tx) {
    // Only pick chain-included transactions, or transactions that are ours and pending.
    TransactionConfidence confidence = tx.getConfidence();
    TransactionConfidence.ConfidenceType type = confidence.getConfidenceType();
    return type.equals(TransactionConfidence.ConfidenceType.BUILDING) ||

        type.equals(TransactionConfidence.ConfidenceType.PENDING) &&
        confidence.getSource().equals(TransactionConfidence.Source.SELF) &&
        // In regtest mode we expect to have only one peer, so we won't see transactions propagate.
        // TODO: The value 1 below dates from a time when transactions we broadcast *to* were counted, set to 0
        (confidence.numBroadcastPeers() > 1 || tx.getParams().getId().equals(NetworkParameters.ID_REGTEST));
  }
}

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

public static boolean isSelectable(Transaction tx) {
    // Only pick chain-included transactions, or transactions that are ours and pending.
    TransactionConfidence confidence = tx.getConfidence();
    TransactionConfidence.ConfidenceType type = confidence.getConfidenceType();
    return type.equals(TransactionConfidence.ConfidenceType.BUILDING) ||

        type.equals(TransactionConfidence.ConfidenceType.PENDING) &&
        confidence.getSource().equals(TransactionConfidence.Source.SELF) &&
        // In regtest mode we expect to have only one peer, so we won't see transactions propagate.
        // TODO: The value 1 below dates from a time when transactions we broadcast *to* were counted, set to 0
        (confidence.numBroadcastPeers() > 1 || tx.getParams().getId().equals(NetworkParameters.ID_REGTEST));
  }
}

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

public static boolean isSelectable(Transaction tx) {
    // Only pick chain-included transactions, or transactions that are ours and pending.
    TransactionConfidence confidence = tx.getConfidence();
    TransactionConfidence.ConfidenceType type = confidence.getConfidenceType();
    return type.equals(TransactionConfidence.ConfidenceType.BUILDING) ||
        type.equals(TransactionConfidence.ConfidenceType.PENDING) &&
        confidence.getSource().equals(TransactionConfidence.Source.SELF) &&
        // In regtest mode we expect to have only one peer, so we won't see transactions propagate.
        // TODO: The value 1 below dates from a time when transactions we broadcast *to* were counted, set to 0
        (confidence.numBroadcastPeers() > 1 || tx.getParams().getId().equals(NetworkParameters.ID_REGTEST));
  }
}

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

public static boolean isSelectable(Transaction tx) {
    // Only pick chain-included transactions, or transactions that are ours and pending.
    TransactionConfidence confidence = tx.getConfidence();
    TransactionConfidence.ConfidenceType type = confidence.getConfidenceType();
    return type.equals(TransactionConfidence.ConfidenceType.BUILDING) ||

        type.equals(TransactionConfidence.ConfidenceType.PENDING) &&
        confidence.getSource().equals(TransactionConfidence.Source.SELF) &&
        // In regtest mode we expect to have only one peer, so we won't see transactions propagate.
        // TODO: The value 1 below dates from a time when transactions we broadcast *to* were counted, set to 0
        (confidence.numBroadcastPeers() > 1 || tx.getParams().getId().equals(NetworkParameters.ID_REGTEST));
  }
}

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

public static boolean isSelectable(Transaction tx, boolean usingInstantX) {
    // Only pick chain-included transactions, or transactions that are pending (whether ours or not).
    // InstantSend requires 6 confirmations
    TransactionConfidence confidence = tx.getConfidence();
    TransactionConfidence.ConfidenceType type = confidence.getConfidenceType();
    return (type.equals(TransactionConfidence.ConfidenceType.BUILDING) && (usingInstantX ? confidence.getDepthInBlocks() >= 6 : true)) ||
        type.equals(TransactionConfidence.ConfidenceType.PENDING) && (usingInstantX ? false : true) &&
            // In regtest mode we expect to have only one peer, so we won't see transactions propagate.
            // TODO: The value 1 below dates from a time when transactions we broadcast *to* were counted, set to 0
            (confidence.numBroadcastPeers() > 1 || tx.getParams() == RegTestParams.get());
  }
}

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

/**
 * Construct a SendRequest for a CPFP (child-pays-for-parent) transaction. The resulting transaction is already
 * completed, so you should directly proceed to signing and broadcasting/committing the transaction. CPFP is
 * currently only supported by a few miners, so use with care.
 */
public static SendRequest childPaysForParent(Wallet wallet, Transaction parentTransaction, Coin feeRaise) {
  TransactionOutput outputToSpend = null;
  for (final TransactionOutput output : parentTransaction.getOutputs()) {
    if (output.isMine(wallet) && output.isAvailableForSpending()
        && output.getValue().isGreaterThan(feeRaise)) {
      outputToSpend = output;
      break;
    }
  }
  // TODO spend another confirmed output of own wallet if needed
  checkNotNull(outputToSpend, "Can't find adequately sized output that spends to us");
  final Transaction tx = new Transaction(parentTransaction.getParams());
  tx.addInput(outputToSpend);
  tx.addOutput(outputToSpend.getValue().subtract(feeRaise), wallet.freshAddress(KeyPurpose.CHANGE));
  tx.setPurpose(Transaction.Purpose.RAISE_FEE);
  final SendRequest req = forTx(tx);
  req.completed = true;
  return req;
}

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

/**
 * Construct a SendRequest for a CPFP (child-pays-for-parent) transaction. The resulting transaction is already
 * completed, so you should directly proceed to signing and broadcasting/committing the transaction. CPFP is
 * currently only supported by a few miners, so use with care.
 */
public static SendRequest childPaysForParent(Wallet wallet, Transaction parentTransaction, Coin feeRaise) {
  TransactionOutput outputToSpend = null;
  for (final TransactionOutput output : parentTransaction.getOutputs()) {
    if (output.isMine(wallet) && output.isAvailableForSpending()
        && output.getValue().isGreaterThan(feeRaise)) {
      outputToSpend = output;
      break;
    }
  }
  // TODO spend another confirmed output of own wallet if needed
  checkNotNull(outputToSpend, "Can't find adequately sized output that spends to us");
  final Transaction tx = new Transaction(parentTransaction.getParams());
  tx.addInput(outputToSpend);
  tx.addOutput(outputToSpend.getValue().subtract(feeRaise), wallet.freshAddress(KeyPurpose.CHANGE));
  tx.setPurpose(Transaction.Purpose.RAISE_FEE);
  final SendRequest req = forTx(tx);
  req.completed = true;
  return req;
}

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

/**
 * Construct a SendRequest for a CPFP (child-pays-for-parent) transaction. The resulting transaction is already
 * completed, so you should directly proceed to signing and broadcasting/committing the transaction. CPFP is
 * currently only supported by a few miners, so use with care.
 */
public static SendRequest childPaysForParent(Wallet wallet, Transaction parentTransaction, Coin feeRaise) {
  TransactionOutput outputToSpend = null;
  for (final TransactionOutput output : parentTransaction.getOutputs()) {
    if (output.isMine(wallet) && output.isAvailableForSpending()
        && output.getValue().isGreaterThan(feeRaise)) {
      outputToSpend = output;
      break;
    }
  }
  // TODO spend another confirmed output of own wallet if needed
  checkNotNull(outputToSpend, "Can't find adequately sized output that spends to us");
  final Transaction tx = new Transaction(parentTransaction.getParams());
  tx.addInput(outputToSpend);
  tx.addOutput(outputToSpend.getValue().subtract(feeRaise), wallet.freshAddress(KeyPurpose.CHANGE));
  tx.setPurpose(Transaction.Purpose.RAISE_FEE);
  final SendRequest req = forTx(tx);
  req.completed = true;
  return req;
}

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

public TransactionOutPointWithValue(Transaction tx, int output) {
    this(new TransactionOutPoint(tx.getParams(), output, tx.getHash()),
        tx.getOutput(output).getValue(), tx.getOutput(output).getScriptPubKey());
  }
}

相关文章

微信公众号

最新文章

更多

Transaction类方法