Java Code Examples for org.bitcoinj.core.Transaction#getConfidence()
The following examples show how to use
org.bitcoinj.core.Transaction#getConfidence() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultCoinSelector.java From bcm-android with GNU General Public License v3.0 | 5 votes |
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)); }
Example 2
Source File: MyceliumCoinSelector.java From bcm-android with GNU General Public License v3.0 | 5 votes |
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); }
Example 3
Source File: WalletService.java From bisq-core with GNU Affero General Public License v3.0 | 5 votes |
@Nullable public TransactionConfidence getConfidenceForTxId(String txId) { if (wallet != null) { Set<Transaction> transactions = wallet.getTransactions(false); for (Transaction tx : transactions) { if (tx.getHashAsString().equals(txId)) return tx.getConfidence(); } } return null; }
Example 4
Source File: BisqDefaultCoinSelector.java From bisq-core with GNU Affero General Public License v3.0 | 5 votes |
protected boolean isTxSpendable(Transaction tx) { TransactionConfidence confidence = tx.getConfidence(); TransactionConfidence.ConfidenceType type = confidence.getConfidenceType(); boolean isConfirmed = type.equals(TransactionConfidence.ConfidenceType.BUILDING); boolean isPending = type.equals(TransactionConfidence.ConfidenceType.PENDING); boolean isOwnTx = confidence.getSource().equals(TransactionConfidence.Source.SELF); return isConfirmed || (isPending && (permitForeignPendingTx || isOwnTx)); }
Example 5
Source File: DefaultCoinSelector.java From green_android with GNU General Public License v3.0 | 5 votes |
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)); }
Example 6
Source File: DefaultCoinSelector.java From GreenBits with GNU General Public License v3.0 | 5 votes |
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)); }
Example 7
Source File: WalletService.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
@Nullable public TransactionConfidence getConfidenceForTxId(String txId) { if (wallet != null) { Set<Transaction> transactions = wallet.getTransactions(false); for (Transaction tx : transactions) { if (tx.getHashAsString().equals(txId)) return tx.getConfidence(); } } return null; }
Example 8
Source File: BisqDefaultCoinSelector.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
protected boolean isTxSpendable(Transaction tx) { TransactionConfidence confidence = tx.getConfidence(); TransactionConfidence.ConfidenceType type = confidence.getConfidenceType(); boolean isConfirmed = type.equals(TransactionConfidence.ConfidenceType.BUILDING); boolean isPending = type.equals(TransactionConfidence.ConfidenceType.PENDING); boolean isOwnTx = confidence.getSource().equals(TransactionConfidence.Source.SELF); return isConfirmed || (isPending && (permitForeignPendingTx || isOwnTx)); }
Example 9
Source File: WalletProtobufSerializer.java From bcm-android with GNU General Public License v3.0 | 4 votes |
private WalletTransaction connectTransactionOutputs(final NetworkParameters params, final org.bitcoinj.wallet.Protos.Transaction txProto) throws UnreadableWalletException { Transaction tx = txMap.get(txProto.getHash()); final WalletTransaction.Pool pool; switch (txProto.getPool()) { case DEAD: pool = WalletTransaction.Pool.DEAD; break; case PENDING: pool = WalletTransaction.Pool.PENDING; break; case SPENT: pool = WalletTransaction.Pool.SPENT; break; case UNSPENT: pool = WalletTransaction.Pool.UNSPENT; break; // Upgrade old wallets: inactive pool has been merged with the pending pool. // Remove this some time after 0.9 is old and everyone has upgraded. // There should not be any spent outputs in this tx as old wallets would not allow them to be spent // in this state. case INACTIVE: case PENDING_INACTIVE: pool = WalletTransaction.Pool.PENDING; break; default: throw new UnreadableWalletException("Unknown transaction pool: " + txProto.getPool()); } for (int i = 0; i < tx.getOutputs().size(); i++) { TransactionOutput output = tx.getOutputs().get(i); final Protos.TransactionOutput transactionOutput = txProto.getTransactionOutput(i); if (transactionOutput.hasSpentByTransactionHash()) { final ByteString spentByTransactionHash = transactionOutput.getSpentByTransactionHash(); Transaction spendingTx = txMap.get(spentByTransactionHash); if (spendingTx == null) { throw new UnreadableWalletException(String.format(Locale.US, "Could not connect %s to %s", tx.getHashAsString(), byteStringToHash(spentByTransactionHash))); } final int spendingIndex = transactionOutput.getSpentByTransactionIndex(); TransactionInput input = checkNotNull(spendingTx.getInput(spendingIndex)); input.connect(output); } } if (txProto.hasConfidence()) { Protos.TransactionConfidence confidenceProto = txProto.getConfidence(); TransactionConfidence confidence = tx.getConfidence(); readConfidence(params, tx, confidenceProto, confidence); } return new WalletTransaction(pool, tx); }