mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-12-25 05:06:45 +00:00
cormorant: support coinbase transactions
This commit is contained in:
parent
02a0a3277b
commit
6a5060c0c8
4 changed files with 11 additions and 5 deletions
|
@ -70,7 +70,7 @@ class CoinCell extends TreeTableCell<Entry, Number> implements ConfirmationsList
|
||||||
setContextMenu(contextMenu);
|
setContextMenu(contextMenu);
|
||||||
|
|
||||||
if(entry instanceof TransactionEntry transactionEntry) {
|
if(entry instanceof TransactionEntry transactionEntry) {
|
||||||
tooltip.showConfirmations(transactionEntry.confirmationsProperty());
|
tooltip.showConfirmations(transactionEntry.confirmationsProperty(), transactionEntry.isCoinbase());
|
||||||
|
|
||||||
if(transactionEntry.isConfirming()) {
|
if(transactionEntry.isConfirming()) {
|
||||||
ConfirmationProgressIndicator arc = new ConfirmationProgressIndicator(transactionEntry.getConfirmations());
|
ConfirmationProgressIndicator arc = new ConfirmationProgressIndicator(transactionEntry.getConfirmations());
|
||||||
|
@ -119,6 +119,7 @@ class CoinCell extends TreeTableCell<Entry, Number> implements ConfirmationsList
|
||||||
private static final class CoinTooltip extends Tooltip {
|
private static final class CoinTooltip extends Tooltip {
|
||||||
private final IntegerProperty confirmationsProperty = new SimpleIntegerProperty();
|
private final IntegerProperty confirmationsProperty = new SimpleIntegerProperty();
|
||||||
private boolean showConfirmations;
|
private boolean showConfirmations;
|
||||||
|
private boolean isCoinbase;
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
public void setValue(String value) {
|
public void setValue(String value) {
|
||||||
|
@ -126,8 +127,9 @@ class CoinCell extends TreeTableCell<Entry, Number> implements ConfirmationsList
|
||||||
setTooltipText();
|
setTooltipText();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showConfirmations(IntegerProperty txEntryConfirmationsProperty) {
|
public void showConfirmations(IntegerProperty txEntryConfirmationsProperty, boolean coinbase) {
|
||||||
showConfirmations = true;
|
showConfirmations = true;
|
||||||
|
isCoinbase = coinbase;
|
||||||
|
|
||||||
int confirmations = txEntryConfirmationsProperty.get();
|
int confirmations = txEntryConfirmationsProperty.get();
|
||||||
if(confirmations < BlockTransactionHash.BLOCKS_TO_FULLY_CONFIRM) {
|
if(confirmations < BlockTransactionHash.BLOCKS_TO_FULLY_CONFIRM) {
|
||||||
|
@ -155,7 +157,7 @@ class CoinCell extends TreeTableCell<Entry, Number> implements ConfirmationsList
|
||||||
if(confirmations == 0) {
|
if(confirmations == 0) {
|
||||||
return "Unconfirmed in mempool";
|
return "Unconfirmed in mempool";
|
||||||
} else if(confirmations < BlockTransactionHash.BLOCKS_TO_FULLY_CONFIRM) {
|
} else if(confirmations < BlockTransactionHash.BLOCKS_TO_FULLY_CONFIRM) {
|
||||||
return confirmations + " confirmation" + (confirmations == 1 ? "" : "s");
|
return confirmations + " confirmation" + (confirmations == 1 ? "" : "s") + (isCoinbase ? ", immature coinbase" : "");
|
||||||
} else {
|
} else {
|
||||||
return BlockTransactionHash.BLOCKS_TO_FULLY_CONFIRM + "+ confirmations";
|
return BlockTransactionHash.BLOCKS_TO_FULLY_CONFIRM + "+ confirmations";
|
||||||
}
|
}
|
||||||
|
|
|
@ -433,7 +433,7 @@ public class BitcoindClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(listTransaction.category() == Category.receive) {
|
if(listTransaction.category() == Category.receive || listTransaction.category() == Category.immature || listTransaction.category() == Category.generate) {
|
||||||
//Transactions received to an address can be added directly
|
//Transactions received to an address can be added directly
|
||||||
Address address = Address.fromString(listTransaction.address());
|
Address address = Address.fromString(listTransaction.address());
|
||||||
String updatedScriptHash = store.addAddressTransaction(address, listTransaction);
|
String updatedScriptHash = store.addAddressTransaction(address, listTransaction);
|
||||||
|
|
|
@ -19,7 +19,7 @@ public class Store {
|
||||||
private final Map<String, MempoolEntry> mempoolEntries = new HashMap<>();
|
private final Map<String, MempoolEntry> mempoolEntries = new HashMap<>();
|
||||||
|
|
||||||
public String addAddressTransaction(Address address, ListTransaction listTransaction) {
|
public String addAddressTransaction(Address address, ListTransaction listTransaction) {
|
||||||
if(listTransaction.category() == Category.receive) {
|
if(listTransaction.category() == Category.receive || listTransaction.category() == Category.immature || listTransaction.category() == Category.generate) {
|
||||||
fundingAddresses.put(new HashIndex(Sha256Hash.wrap(listTransaction.txid()), listTransaction.vout()), address);
|
fundingAddresses.put(new HashIndex(Sha256Hash.wrap(listTransaction.txid()), listTransaction.vout()), address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,6 +97,10 @@ public class TransactionEntry extends Entry implements Comparable<TransactionEnt
|
||||||
return blockTransaction.getConfirmations(AppServices.getCurrentBlockHeight() == null ? getWallet().getStoredBlockHeight() : AppServices.getCurrentBlockHeight());
|
return blockTransaction.getConfirmations(AppServices.getCurrentBlockHeight() == null ? getWallet().getStoredBlockHeight() : AppServices.getCurrentBlockHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isCoinbase() {
|
||||||
|
return blockTransaction.getTransaction() != null && !blockTransaction.getTransaction().getInputs().isEmpty() && blockTransaction.getTransaction().getInputs().get(0).isCoinBase();
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isComplete(Map<HashIndex, BlockTransactionHashIndex> walletTxos) {
|
public boolean isComplete(Map<HashIndex, BlockTransactionHashIndex> walletTxos) {
|
||||||
int validEntries = 0;
|
int validEntries = 0;
|
||||||
for(TransactionInput txInput : blockTransaction.getTransaction().getInputs()) {
|
for(TransactionInput txInput : blockTransaction.getTransaction().getInputs()) {
|
||||||
|
|
Loading…
Reference in a new issue