mirror of
https://github.com/sparrowwallet/drongo.git
synced 2024-11-05 03:26:43 +00:00
add coin selection filter to exclude immature coinbase outputs
This commit is contained in:
parent
c04c249450
commit
57290a20a1
2 changed files with 24 additions and 0 deletions
|
@ -23,6 +23,7 @@ public class Transaction extends ChildMessage {
|
||||||
public static final long MAX_BLOCK_LOCKTIME = 500000000L;
|
public static final long MAX_BLOCK_LOCKTIME = 500000000L;
|
||||||
public static final int WITNESS_SCALE_FACTOR = 4;
|
public static final int WITNESS_SCALE_FACTOR = 4;
|
||||||
public static final int DEFAULT_SEGWIT_FLAG = 1;
|
public static final int DEFAULT_SEGWIT_FLAG = 1;
|
||||||
|
public static final int COINBASE_MATURITY_THRESHOLD = 100;
|
||||||
|
|
||||||
//Min feerate for defining dust, defined in sats/vByte
|
//Min feerate for defining dust, defined in sats/vByte
|
||||||
//From: https://github.com/bitcoin/bitcoin/blob/0.19/src/policy/policy.h#L50
|
//From: https://github.com/bitcoin/bitcoin/blob/0.19/src/policy/policy.h#L50
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.sparrowwallet.drongo.wallet;
|
||||||
|
|
||||||
|
import com.sparrowwallet.drongo.protocol.Transaction;
|
||||||
|
|
||||||
|
public class CoinbaseUtxoFilter implements UtxoFilter {
|
||||||
|
private final Wallet wallet;
|
||||||
|
|
||||||
|
public CoinbaseUtxoFilter(Wallet wallet) {
|
||||||
|
this.wallet = wallet;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isEligible(BlockTransactionHashIndex candidate) {
|
||||||
|
//Disallow immature coinbase outputs
|
||||||
|
BlockTransaction blockTransaction = wallet.getTransactions().get(candidate.getHash());
|
||||||
|
if(blockTransaction != null && blockTransaction.getTransaction() != null && blockTransaction.getTransaction().isCoinBase()
|
||||||
|
&& wallet.getStoredBlockHeight() != null && candidate.getConfirmations(wallet.getStoredBlockHeight()) < Transaction.COINBASE_MATURITY_THRESHOLD) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue