本文整理汇总了Java中com.google.bitcoin.core.Transaction.getOutputs方法的典型用法代码示例。如果您正苦于以下问题:Java Transaction.getOutputs方法的具体用法?Java Transaction.getOutputs怎么用?Java Transaction.getOutputs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.bitcoin.core.Transaction
的用法示例。
在下文中一共展示了Transaction.getOutputs方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isStandard
import com.google.bitcoin.core.Transaction; //导入方法依赖的package包/类
/**
* <p>Checks if a transaction is considered "standard" by the reference client's IsStandardTx and AreInputsStandard
* functions.</p>
*
* <p>Note that this method currently only implements a minimum of checks. More to be added later.</p>
*/
public static RuleViolation isStandard(Transaction tx) {
// TODO: Finish this function off.
if (tx.getVersion() > 1 || tx.getVersion() < 1) {
log.warn("TX considered non-standard due to unknown version number {}", tx.getVersion());
return RuleViolation.VERSION;
}
final List<TransactionOutput> outputs = tx.getOutputs();
for (int i = 0; i < outputs.size(); i++) {
TransactionOutput output = outputs.get(i);
if (output.getMinNonDustValue().compareTo(output.getValue()) > 0) {
log.warn("TX considered non-standard due to output {} being dusty", i);
return RuleViolation.DUST;
}
}
return RuleViolation.NONE;
}
示例2: isStandard
import com.google.bitcoin.core.Transaction; //导入方法依赖的package包/类
/**
* <p>Checks if a transaction is considered "standard" by the reference client's IsStandardTx and AreInputsStandard
* functions.</p>
*
* <p>Note that this method currently only implements a minimum of checks. More to be added later.</p>
*/
public static RuleViolation isStandard(Transaction tx) {
// TODO: Finish this function off.
if (tx.getVersion() > 1 || tx.getVersion() < 1) {
log.warn("TX considered non-standard due to unknown version number {}", tx.getVersion());
return RuleViolation.VERSION;
}
final List<TransactionOutput> outputs = tx.getOutputs();
for (int i = 0; i < outputs.size(); i++) {
TransactionOutput output = outputs.get(i);
if (MIN_ANALYSIS_NONDUST_OUTPUT.compareTo(output.getValue()) > 0) {
log.warn("TX considered non-standard due to output {} being dusty", i);
return RuleViolation.DUST;
}
}
return RuleViolation.NONE;
}
示例3: getFirstToAddress
import com.google.bitcoin.core.Transaction; //导入方法依赖的package包/类
@CheckForNull
public static Address getFirstToAddress(@Nonnull final Transaction tx)
{
try
{
for (final TransactionOutput output : tx.getOutputs())
{
return output.getScriptPubKey().getToAddress(Constants.NETWORK_PARAMETERS);
}
throw new IllegalStateException();
}
catch (final ScriptException x)
{
return null;
}
}
示例4: isInternal
import com.google.bitcoin.core.Transaction; //导入方法依赖的package包/类
public static boolean isInternal(@Nonnull final Transaction tx)
{
if (tx.isCoinBase())
return false;
final List<TransactionOutput> outputs = tx.getOutputs();
if (outputs.size() != 1)
return false;
try
{
final TransactionOutput output = outputs.get(0);
final Script scriptPubKey = output.getScriptPubKey();
if (!scriptPubKey.isSentToRawPubKey())
return false;
return true;
}
catch (final ScriptException x)
{
return false;
}
}
示例5: determineOutputsToOfferNextStage
import com.google.bitcoin.core.Transaction; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void determineOutputsToOfferNextStage(String tx_hex, ObjectSuccessCallback objectSuccessCallback) {
try {
Log.d("SharedCoin", "SharedCoin determineOutputsToOfferNextStage ");
Transaction tx = new Transaction(this.sharedCoin.params, Hex.decode(tx_hex.getBytes()), 0, null, false, true, Message.UNKNOWN_LENGTH);
List<TransactionOutput> transactionOutputs = tx.getOutputs();
JSONArray outpoints_to_offer_next_stage = new JSONArray();
Log.d("SharedCoin", "SharedCoin determineOutputsToOfferNextStage transactionOutputs.size() " + transactionOutputs.size());
for (int i = 0; i < transactionOutputs.size(); i++) {
TransactionOutput output = transactionOutputs.get(i);
Log.d("SharedCoin", "SharedCoin determineOutputsToOfferNextStage i " + i);
if (isOutputOneWeRequested(output)) {
if (isOutputChange(output)) {
JSONObject dict = new JSONObject();
dict.put("hash", null);
dict.put("index", (long) i);
dict.put("value", output.getValue().toString());
outpoints_to_offer_next_stage.add(dict);
}
}
}
Log.d("SharedCoin", "SharedCoin determineOutputsToOfferNextStage outpoints_to_offer_next_stage.size " + outpoints_to_offer_next_stage.size());
objectSuccessCallback.onSuccess(outpoints_to_offer_next_stage);
} catch (ProtocolException e) {
objectSuccessCallback.onFail(e.getLocalizedMessage());
e.printStackTrace();
}
}
示例6: isStandard
import com.google.bitcoin.core.Transaction; //导入方法依赖的package包/类
/**
* <p>Checks if a transaction is considered "standard" by the reference client's IsStandardTx and AreInputsStandard
* functions.</p>
*
* <p>Note that this method currently only implements a minimum of checks. More to be added later.</p>
*
* @return Either null if the transaction is standard, or the first transaction found which is considered nonstandard
*/
public Transaction isStandard(Transaction tx) {
if (tx.getVersion() > 1 || tx.getVersion() < 1)
return tx;
for (TransactionOutput output : tx.getOutputs()) {
if (output.getMinNonDustValue().compareTo(output.getValue()) > 0)
return tx;
}
return null;
}
示例7: isStandard
import com.google.bitcoin.core.Transaction; //导入方法依赖的package包/类
/**
* <p>Checks if a transaction is considered "standard" by the reference client's IsStandardTx and AreInputsStandard
* functions.</p>
*
* <p>Note that this method currently only implements a minimum of checks. More to be added later.</p>
*
* @return Either null if the transaction is standard, or the first transaction found which is considered nonstandard
*/
public Transaction isStandard(Transaction tx) {
if (tx.getVersion() > 1 || tx.getVersion() < 1)
return tx;
/* CSPK-mike START */
/* Bitcoin 0.9 allows zero values for non-standard outputs */
/*
for (TransactionOutput output : tx.getOutputs()) {
if (MIN_ANALYSIS_NONDUST_OUTPUT.compareTo(output.getValue()) > 0)
return tx;
*/
boolean txNonStandard=false;
for (TransactionOutput output : tx.getOutputs()) {
if (MIN_ANALYSIS_NONDUST_OUTPUT.compareTo(output.getValue()) > 0)
{
byte[] scriptBytes = output.getScriptBytes();
if(CoinSparkBase.scriptIsRegular(scriptBytes)) // Zero value is allowed by Bitcoin 0.9 for OP_RETRUN outputs
{
return tx;
}
}
}
/* CSPK-mike START */
return null;
}
示例8: totalOutCoin
import com.google.bitcoin.core.Transaction; //导入方法依赖的package包/类
private static Coin totalOutCoin(Transaction tx)
{
Coin out_coin = Coin.ZERO;
for(TransactionOutput out : tx.getOutputs())
{
out_coin = out_coin.add(out.getValue());
}
return out_coin;
}
示例9: isRelevant
import com.google.bitcoin.core.Transaction; //导入方法依赖的package包/类
public boolean isRelevant(Transaction tx)
{
for(TransactionOutput out : tx.getOutputs())
if(isRelevant(out))
return true;
return false;
}
示例10: CSTransactionAssets
import com.google.bitcoin.core.Transaction; //导入方法依赖的package包/类
public CSTransactionAssets(Transaction ParentTx)
{
this.parentTransaction = ParentTx;
byte [] txnMetaData = null;
for (TransactionOutput output : ParentTx.getOutputs())
{
byte[] scriptBytes = output.getScriptBytes();
if(!CoinSparkBase.scriptIsRegular(scriptBytes))
{
txnMetaData=CoinSparkBase.scriptToMetadata(scriptBytes);
}
}
if(txnMetaData != null)
{
genesis = new CoinSparkGenesis();
if (!genesis.decode(txnMetaData))
{
genesis=null;
}
transfers = new CoinSparkTransferList();
if (!transfers.decode(txnMetaData, ParentTx.getInputs().size(), ParentTx.getOutputs().size()))
{
transfers=null;
}
message=new CoinSparkMessage();
if(!message.decode(txnMetaData, ParentTx.getOutputs().size()))
{
message=null;
}
paymentRef=new CoinSparkPaymentRef();
if(!paymentRef.decode(txnMetaData))
{
paymentRef=null;
}
}
}
示例11: commitTransaction
import com.google.bitcoin.core.Transaction; //导入方法依赖的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());
}
}
}
示例12: appendApplicationInfo
import com.google.bitcoin.core.Transaction; //导入方法依赖的package包/类
public static void appendApplicationInfo(@Nonnull final Appendable report, @Nonnull final WalletApplication application) throws IOException
{
try
{
final PackageManager pm = application.getPackageManager();
final PackageInfo pi = pm.getPackageInfo(application.getPackageName(), 0);
final long now = System.currentTimeMillis();
report.append("Version: " + pi.versionName + " (" + pi.versionCode + ")\n");
report.append("Package: " + pi.packageName + "\n");
report.append("Test/Prod: " + (Constants.TEST ? "test" : "prod") + "\n");
report.append("Time: " + String.format("%tF %tT %tz", now, now, now) + "\n");
report.append("Time of launch: "
+ String.format("%tF %tT %tz", TIME_CREATE_APPLICATION, TIME_CREATE_APPLICATION, TIME_CREATE_APPLICATION) + "\n");
report.append("Time of last update: " + String.format("%tF %tT %tz", pi.lastUpdateTime, pi.lastUpdateTime, pi.lastUpdateTime) + "\n");
report.append("Time of first install: " + String.format("%tF %tT %tz", pi.firstInstallTime, pi.firstInstallTime, pi.firstInstallTime)
+ "\n");
report.append("Network: " + Constants.NETWORK_PARAMETERS.getId() + "\n");
final Wallet wallet = application.getWallet();
report.append("Keychain size: " + wallet.getKeychainSize() + "\n");
final Set<Transaction> transactions = wallet.getTransactions(true);
int numInputs = 0;
int numOutputs = 0;
int numSpentOutputs = 0;
for (final Transaction tx : transactions)
{
numInputs += tx.getInputs().size();
final List<TransactionOutput> outputs = tx.getOutputs();
numOutputs += outputs.size();
for (final TransactionOutput txout : outputs)
{
if (!txout.isAvailableForSpending())
numSpentOutputs++;
}
}
report.append("Transactions: " + transactions.size() + "\n");
report.append("Inputs: " + numInputs + "\n");
report.append("Outputs: " + numOutputs + " (spent: " + numSpentOutputs + ")\n");
report.append("Last block seen: " + wallet.getLastBlockSeenHeight() + " (" + wallet.getLastBlockSeenHash() + ")\n");
report.append("Databases:");
for (final String db : application.databaseList())
report.append(" " + db);
report.append("\n");
final File filesDir = application.getFilesDir();
report.append("\nContents of FilesDir " + filesDir + ":\n");
appendDir(report, filesDir, 0);
final File logDir = application.getDir("log", Context.MODE_PRIVATE);
report.append("\nContents of LogDir " + logDir + ":\n");
appendDir(report, logDir, 0);
}
catch (final NameNotFoundException x)
{
throw new IOException(x);
}
}