mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-23 06:55:08 +01:00
Use burnedBsq field in Tx for burnedFee and invalidatedBsq
In case of an invalid tx we burn all available BSQ input. We only know that at parsing time. We renamed the burntFee field to burntBsq to make it more generic and use it for the burnt fee in case if a normal tx and as invalidatedBsq in case of an invalid tx.
This commit is contained in:
parent
823cec086c
commit
d5fc7cb97e
13 changed files with 121 additions and 85 deletions
|
@ -1420,7 +1420,7 @@ message Tx {
|
|||
// Because of the way how PB implements inheritence we need to use the super class as type
|
||||
repeated BaseTxOutput tx_outputs = 1;
|
||||
TxType txType = 2;
|
||||
int64 burnt_fee = 3;
|
||||
int64 burnt_bsq = 3;
|
||||
}
|
||||
|
||||
enum TxType {
|
||||
|
|
|
@ -544,8 +544,13 @@ public class DaoFacade implements DaoSetupService {
|
|||
return daoStateService.getTotalAmountOfConfiscatedTxOutputs();
|
||||
}
|
||||
|
||||
public long getBurnedBsqOfAllInvalidTxs() {
|
||||
return daoStateService.getBurnedBsqOfAllInvalidTxs();
|
||||
public long getTotalAmountOfInvalidatedBsq() {
|
||||
return daoStateService.getTotalAmountOfInvalidatedBsq();
|
||||
}
|
||||
|
||||
// Contains burned fee and invalidated bsq due invalid txs
|
||||
public long getTotalAmountOfBurntBsq() {
|
||||
return daoStateService.getTotalAmountOfBurntBsq();
|
||||
}
|
||||
|
||||
public List<Tx> getInvalidTxs() {
|
||||
|
@ -603,7 +608,7 @@ public class DaoFacade implements DaoSetupService {
|
|||
return daoStateService.getIssuanceSet(issuanceType).size();
|
||||
}
|
||||
|
||||
public Set<Tx> getFeeTxs() {
|
||||
public Set<Tx> getBurntFeeTxs() {
|
||||
return daoStateService.getBurntFeeTxs();
|
||||
}
|
||||
|
||||
|
|
|
@ -145,13 +145,12 @@ public class DaoStateMonitoringService implements DaoSetupService, DaoStateListe
|
|||
@Override
|
||||
public void onDaoStateChanged(Block block) {
|
||||
long genesisTotalSupply = daoStateService.getGenesisTotalSupply().value;
|
||||
long totalBurntFee = daoStateService.getTotalBurntFee();
|
||||
long compensationIssuance = daoStateService.getTotalIssuedAmount(IssuanceType.COMPENSATION);
|
||||
long reimbursementIssuance = daoStateService.getTotalIssuedAmount(IssuanceType.REIMBURSEMENT);
|
||||
long totalInvalidAmount = daoStateService.getBurnedBsqOfAllInvalidTxs();
|
||||
long totalAmountOfBurntBsq = daoStateService.getTotalAmountOfBurntBsq();
|
||||
// confiscated funds are still in the utxo set
|
||||
long sumUtxo = daoStateService.getUnspentTxOutputMap().values().stream().mapToLong(BaseTxOutput::getValue).sum();
|
||||
long sumBsq = genesisTotalSupply + compensationIssuance + reimbursementIssuance - totalBurntFee - totalInvalidAmount;
|
||||
long sumBsq = genesisTotalSupply + compensationIssuance + reimbursementIssuance - totalAmountOfBurntBsq;
|
||||
|
||||
if (sumBsq != sumUtxo) {
|
||||
utxoMismatches.add(new UtxoMismatch(block.getHeight(), sumUtxo, sumBsq));
|
||||
|
|
|
@ -193,7 +193,8 @@ public class ExportJsonFilesService implements DaoSetupService {
|
|||
getJsonTxOutputs(tx),
|
||||
jsonTxType,
|
||||
jsonTxTypeDisplayString,
|
||||
daoStateService.getBurntFee(tx.getId()),
|
||||
tx.getBurntFee(),
|
||||
tx.getInvalidatedBsq(),
|
||||
tx.getUnlockBlockHeight());
|
||||
}
|
||||
|
||||
|
@ -239,7 +240,8 @@ public class ExportJsonFilesService implements DaoSetupService {
|
|||
btcAmount,
|
||||
tx.getBlockHeight(),
|
||||
isBsqTxOutputType,
|
||||
daoStateService.getBurntFee(tx.getId()),
|
||||
tx.getBurntFee(),
|
||||
tx.getInvalidatedBsq(),
|
||||
txOutput.getAddress(),
|
||||
scriptPubKey,
|
||||
spentInfo,
|
||||
|
|
|
@ -36,9 +36,26 @@ class JsonTx {
|
|||
private final JsonTxType txType;
|
||||
private final String txTypeDisplayString;
|
||||
private final long burntFee;
|
||||
private final long invalidatedBsq;
|
||||
// If not set it is -1. LockTime of 0 is a valid value.
|
||||
private final int unlockBlockHeight;
|
||||
|
||||
JsonTx(String id, int blockHeight, String blockHash, long time, List<JsonTxInput> inputs,
|
||||
List<JsonTxOutput> outputs, JsonTxType txType, String txTypeDisplayString, long burntFee,
|
||||
long invalidatedBsq, int unlockBlockHeight) {
|
||||
this.id = id;
|
||||
this.blockHeight = blockHeight;
|
||||
this.blockHash = blockHash;
|
||||
this.time = time;
|
||||
this.inputs = inputs;
|
||||
this.outputs = outputs;
|
||||
this.txType = txType;
|
||||
this.txTypeDisplayString = txTypeDisplayString;
|
||||
this.burntFee = burntFee;
|
||||
this.invalidatedBsq = invalidatedBsq;
|
||||
this.unlockBlockHeight = unlockBlockHeight;
|
||||
}
|
||||
|
||||
// Enums must not be used directly for hashCode or equals as it delivers the Object.hashCode (internal address)!
|
||||
// The equals and hashCode methods cannot be overwritten in Enums.
|
||||
@Override
|
||||
|
@ -50,6 +67,7 @@ class JsonTx {
|
|||
return blockHeight == jsonTx.blockHeight &&
|
||||
time == jsonTx.time &&
|
||||
burntFee == jsonTx.burntFee &&
|
||||
invalidatedBsq == jsonTx.invalidatedBsq &&
|
||||
unlockBlockHeight == jsonTx.unlockBlockHeight &&
|
||||
Objects.equals(txVersion, jsonTx.txVersion) &&
|
||||
Objects.equals(id, jsonTx.id) &&
|
||||
|
@ -62,7 +80,7 @@ class JsonTx {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
return Objects.hash(super.hashCode(), txVersion, id, blockHeight, blockHash, time, inputs, outputs, txType.name(), txTypeDisplayString, burntFee, unlockBlockHeight);
|
||||
return Objects.hash(super.hashCode(), txVersion, id, blockHeight, blockHash, time, inputs, outputs,
|
||||
txType.name(), txTypeDisplayString, burntFee, invalidatedBsq, unlockBlockHeight);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ class JsonTxOutput {
|
|||
private final int height;
|
||||
private final boolean isVerified; // isBsqTxOutputType
|
||||
private final long burntFee;
|
||||
private final long invalidatedBsq;
|
||||
private final String address;
|
||||
@Nullable
|
||||
private final JsonScriptPubKey scriptPubKey;
|
||||
|
@ -50,6 +51,31 @@ class JsonTxOutput {
|
|||
private final int lockTime;
|
||||
private final boolean isUnspent;
|
||||
|
||||
JsonTxOutput(String txId, int index, long bsqAmount, long btcAmount, int height, boolean isVerified, long burntFee,
|
||||
long invalidatedBsq, String address, JsonScriptPubKey scriptPubKey, JsonSpentInfo spentInfo,
|
||||
long time, JsonTxType txType, String txTypeDisplayString, JsonTxOutputType txOutputType,
|
||||
String txOutputTypeDisplayString, String opReturn, int lockTime, boolean isUnspent) {
|
||||
this.txId = txId;
|
||||
this.index = index;
|
||||
this.bsqAmount = bsqAmount;
|
||||
this.btcAmount = btcAmount;
|
||||
this.height = height;
|
||||
this.isVerified = isVerified;
|
||||
this.burntFee = burntFee;
|
||||
this.invalidatedBsq = invalidatedBsq;
|
||||
this.address = address;
|
||||
this.scriptPubKey = scriptPubKey;
|
||||
this.spentInfo = spentInfo;
|
||||
this.time = time;
|
||||
this.txType = txType;
|
||||
this.txTypeDisplayString = txTypeDisplayString;
|
||||
this.txOutputType = txOutputType;
|
||||
this.txOutputTypeDisplayString = txOutputTypeDisplayString;
|
||||
this.opReturn = opReturn;
|
||||
this.lockTime = lockTime;
|
||||
this.isUnspent = isUnspent;
|
||||
}
|
||||
|
||||
String getId() {
|
||||
return txId + ":" + index;
|
||||
}
|
||||
|
@ -68,6 +94,7 @@ class JsonTxOutput {
|
|||
height == that.height &&
|
||||
isVerified == that.isVerified &&
|
||||
burntFee == that.burntFee &&
|
||||
invalidatedBsq == that.invalidatedBsq &&
|
||||
time == that.time &&
|
||||
lockTime == that.lockTime &&
|
||||
isUnspent == that.isUnspent &&
|
||||
|
@ -86,6 +113,8 @@ class JsonTxOutput {
|
|||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
return Objects.hash(super.hashCode(), txVersion, txId, index, bsqAmount, btcAmount, height, isVerified, burntFee, address, scriptPubKey, spentInfo, time, txType.name(), txTypeDisplayString, txOutputType, txOutputTypeDisplayString, opReturn, lockTime, isUnspent);
|
||||
return Objects.hash(super.hashCode(), txVersion, txId, index, bsqAmount, btcAmount, height, isVerified,
|
||||
burntFee, invalidatedBsq, address, scriptPubKey, spentInfo, time, txType.name(), txTypeDisplayString,
|
||||
txOutputType, txOutputTypeDisplayString, opReturn, lockTime, isUnspent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,12 +55,7 @@ public class TempTx extends BaseTx {
|
|||
// Mutable data
|
||||
@Nullable
|
||||
private TxType txType;
|
||||
private long burntFee;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// PROTO BUFFER
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
private long burntBsq;
|
||||
|
||||
private TempTx(String txVersion,
|
||||
String id,
|
||||
|
@ -70,7 +65,7 @@ public class TempTx extends BaseTx {
|
|||
ImmutableList<TxInput> txInputs,
|
||||
ImmutableList<TempTxOutput> tempTxOutputs,
|
||||
@Nullable TxType txType,
|
||||
long burntFee) {
|
||||
long burntBsq) {
|
||||
super(txVersion,
|
||||
id,
|
||||
blockHeight,
|
||||
|
@ -79,7 +74,7 @@ public class TempTx extends BaseTx {
|
|||
txInputs);
|
||||
this.tempTxOutputs = tempTxOutputs;
|
||||
this.txType = txType;
|
||||
this.burntFee = burntFee;
|
||||
this.burntBsq = burntBsq;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -87,7 +82,7 @@ public class TempTx extends BaseTx {
|
|||
return "TempTx{" +
|
||||
"\n txOutputs=" + tempTxOutputs +
|
||||
",\n txType=" + txType +
|
||||
",\n burntFee=" + burntFee +
|
||||
",\n burntBsq=" + burntBsq +
|
||||
"\n} " + super.toString();
|
||||
}
|
||||
|
||||
|
@ -103,13 +98,13 @@ public class TempTx extends BaseTx {
|
|||
String name = txType != null ? txType.name() : "";
|
||||
String name1 = tempTx.txType != null ? tempTx.txType.name() : "";
|
||||
boolean isTxTypeEquals = name.equals(name1);
|
||||
return burntFee == tempTx.burntFee &&
|
||||
return burntBsq == tempTx.burntBsq &&
|
||||
Objects.equals(tempTxOutputs, tempTx.tempTxOutputs) &&
|
||||
isTxTypeEquals;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), tempTxOutputs, txType, burntFee);
|
||||
return Objects.hash(super.hashCode(), tempTxOutputs, txType, burntBsq);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ public class TxParser {
|
|||
long burntBsq = remainingInputValue + burntBondValue;
|
||||
boolean hasBurntBsq = burntBsq > 0;
|
||||
if (hasBurntBsq)
|
||||
tempTx.setBurntFee(burntBsq);
|
||||
tempTx.setBurntBsq(burntBsq);
|
||||
|
||||
|
||||
//****************************************************************************************
|
||||
|
@ -161,9 +161,7 @@ public class TxParser {
|
|||
if (isTxInvalid(tempTx, bsqOutputFound, hasBurntBond)) {
|
||||
tempTx.setTxType(TxType.INVALID);
|
||||
// We consider all BSQ inputs as burned if the tx is invalid.
|
||||
// It might be that the invalid tx had a BSQ fee. To avoid that we count the burned BSQ twice we set the
|
||||
// burnedFee to 0.
|
||||
tempTx.setBurntFee(0);
|
||||
tempTx.setBurntBsq(accumulatedInputValue);
|
||||
txOutputParser.invalidateUTXOCandidates();
|
||||
log.warn("We have destroyed BSQ because of an invalid tx. Burned BSQ={}. tx={}", accumulatedInputValue / 100D, tempTx);
|
||||
} else if (txType == TxType.IRREGULAR) {
|
||||
|
|
|
@ -21,7 +21,6 @@ import bisq.core.dao.DaoSetupService;
|
|||
import bisq.core.dao.governance.bond.BondConsensus;
|
||||
import bisq.core.dao.governance.param.Param;
|
||||
import bisq.core.dao.state.model.DaoState;
|
||||
import bisq.core.dao.state.model.blockchain.BaseTxOutput;
|
||||
import bisq.core.dao.state.model.blockchain.Block;
|
||||
import bisq.core.dao.state.model.blockchain.SpentInfo;
|
||||
import bisq.core.dao.state.model.blockchain.Tx;
|
||||
|
@ -387,9 +386,7 @@ public class DaoStateService implements DaoSetupService {
|
|||
}
|
||||
|
||||
public long getTotalBurntFee() {
|
||||
return getTxStream()
|
||||
.mapToLong(Tx::getBurntFee)
|
||||
.sum();
|
||||
return getTxStream().mapToLong(Tx::getBurntFee).sum();
|
||||
}
|
||||
|
||||
public Set<Tx> getBurntFeeTxs() {
|
||||
|
@ -816,25 +813,13 @@ public class DaoStateService implements DaoSetupService {
|
|||
.sum();
|
||||
}
|
||||
|
||||
public long getBurnedBsqOfAllInvalidTxs() {
|
||||
return getTxStream()
|
||||
.filter(e -> e.getTxType() == TxType.INVALID)
|
||||
.mapToLong(this::getBurnedBsqOfInvalidTx)
|
||||
.sum();
|
||||
public long getTotalAmountOfInvalidatedBsq() {
|
||||
return getTxStream().mapToLong(Tx::getInvalidatedBsq).sum();
|
||||
}
|
||||
|
||||
public long getBurnedBsqOfInvalidTx(Tx tx) {
|
||||
return tx.getTxInputs().stream()
|
||||
.map(TxInput::getConnectedTxOutputKey)
|
||||
.flatMap(txOutputKey -> getTxOutput(txOutputKey).stream())
|
||||
.filter(txOutput -> txOutput.getTxOutputType() == TxOutputType.GENESIS_OUTPUT ||
|
||||
txOutput.getTxOutputType() == TxOutputType.BSQ_OUTPUT ||
|
||||
txOutput.getTxOutputType() == TxOutputType.BLIND_VOTE_LOCK_STAKE_OUTPUT ||
|
||||
txOutput.getTxOutputType() == TxOutputType.VOTE_REVEAL_UNLOCK_STAKE_OUTPUT ||
|
||||
txOutput.getTxOutputType() == TxOutputType.LOCKUP_OUTPUT ||
|
||||
txOutput.getTxOutputType() == TxOutputType.UNLOCK_OUTPUT)
|
||||
.mapToLong(BaseTxOutput::getValue)
|
||||
.sum();
|
||||
// Contains burnt fee and invalidated bsq due invalid txs
|
||||
public long getTotalAmountOfBurntBsq() {
|
||||
return getTxStream().mapToLong(Tx::getBurntBsq).sum();
|
||||
}
|
||||
|
||||
// Confiscate bond
|
||||
|
|
|
@ -57,13 +57,14 @@ public final class Tx extends BaseTx implements PersistablePayload, ImmutableDao
|
|||
tempTx.getTxInputs(),
|
||||
txOutputs,
|
||||
tempTx.getTxType(),
|
||||
tempTx.getBurntFee());
|
||||
tempTx.getBurntBsq());
|
||||
}
|
||||
|
||||
private final ImmutableList<TxOutput> txOutputs;
|
||||
@Nullable
|
||||
private final TxType txType;
|
||||
private final long burntFee;
|
||||
// Can be burned fee or in case of an invalid tx the burned BSQ from all BSQ inputs
|
||||
private final long burntBsq;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -78,7 +79,7 @@ public final class Tx extends BaseTx implements PersistablePayload, ImmutableDao
|
|||
ImmutableList<TxInput> txInputs,
|
||||
ImmutableList<TxOutput> txOutputs,
|
||||
@Nullable TxType txType,
|
||||
long burntFee) {
|
||||
long burntBsq) {
|
||||
super(txVersion,
|
||||
id,
|
||||
blockHeight,
|
||||
|
@ -87,7 +88,7 @@ public final class Tx extends BaseTx implements PersistablePayload, ImmutableDao
|
|||
txInputs);
|
||||
this.txOutputs = txOutputs;
|
||||
this.txType = txType;
|
||||
this.burntFee = burntFee;
|
||||
this.burntBsq = burntBsq;
|
||||
|
||||
}
|
||||
|
||||
|
@ -97,7 +98,7 @@ public final class Tx extends BaseTx implements PersistablePayload, ImmutableDao
|
|||
.addAllTxOutputs(txOutputs.stream()
|
||||
.map(TxOutput::toProtoMessage)
|
||||
.collect(Collectors.toList()))
|
||||
.setBurntFee(burntFee);
|
||||
.setBurntBsq(burntBsq);
|
||||
Optional.ofNullable(txType).ifPresent(txType -> builder.setTxType(txType.toProtoMessage()));
|
||||
return getBaseTxBuilder().setTx(builder).build();
|
||||
}
|
||||
|
@ -122,7 +123,7 @@ public final class Tx extends BaseTx implements PersistablePayload, ImmutableDao
|
|||
txInputs,
|
||||
outputs,
|
||||
TxType.fromProto(protoTx.getTxType()),
|
||||
protoTx.getBurntFee());
|
||||
protoTx.getBurntBsq());
|
||||
}
|
||||
|
||||
|
||||
|
@ -135,6 +136,18 @@ public final class Tx extends BaseTx implements PersistablePayload, ImmutableDao
|
|||
}
|
||||
|
||||
|
||||
public long getBurntBsq() {
|
||||
return burntBsq;
|
||||
}
|
||||
|
||||
public long getBurntFee() {
|
||||
return txType == TxType.INVALID ? 0 : burntBsq;
|
||||
}
|
||||
|
||||
public long getInvalidatedBsq() {
|
||||
return txType == TxType.INVALID ? burntBsq : 0;
|
||||
}
|
||||
|
||||
public int getLockTime() {
|
||||
return getLockupOutput().getLockTime();
|
||||
}
|
||||
|
@ -158,7 +171,7 @@ public final class Tx extends BaseTx implements PersistablePayload, ImmutableDao
|
|||
return "Tx{" +
|
||||
"\n txOutputs=" + txOutputs +
|
||||
",\n txType=" + txType +
|
||||
",\n burntFee=" + burntFee +
|
||||
",\n burntBsq=" + burntBsq +
|
||||
"\n} " + super.toString();
|
||||
}
|
||||
|
||||
|
@ -175,13 +188,13 @@ public final class Tx extends BaseTx implements PersistablePayload, ImmutableDao
|
|||
String name1 = tx.txType != null ? tx.txType.name() : "";
|
||||
boolean isTxTypeEquals = name.equals(name1);
|
||||
|
||||
return burntFee == tx.burntFee &&
|
||||
return burntBsq == tx.burntBsq &&
|
||||
Objects.equals(txOutputs, tx.txOutputs) &&
|
||||
isTxTypeEquals;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), txOutputs, txType, burntFee);
|
||||
return Objects.hash(super.hashCode(), txOutputs, txType, burntBsq);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -291,16 +291,15 @@ public class BsqDashboardView extends ActivatableView<GridPane, Void> implements
|
|||
Coin issuedAmountFromGenesis = daoFacade.getGenesisTotalSupply();
|
||||
Coin issuedAmountFromCompRequests = Coin.valueOf(daoFacade.getTotalIssuedAmount(IssuanceType.COMPENSATION));
|
||||
Coin issuedAmountFromReimbursementRequests = Coin.valueOf(daoFacade.getTotalIssuedAmount(IssuanceType.REIMBURSEMENT));
|
||||
Coin burntFee = Coin.valueOf(daoFacade.getTotalBurntFee());
|
||||
Coin totalConfiscatedAmount = Coin.valueOf(daoFacade.getTotalAmountOfConfiscatedTxOutputs());
|
||||
Coin burnedBsqOfAllInvalidTxs = Coin.valueOf(daoFacade.getBurnedBsqOfAllInvalidTxs());
|
||||
// Contains burnt fee and invalidated bsq due invalid txs
|
||||
Coin totalAmountOfBurntBsq = Coin.valueOf(daoFacade.getTotalAmountOfBurntBsq());
|
||||
|
||||
availableAmount = issuedAmountFromGenesis
|
||||
.add(issuedAmountFromCompRequests)
|
||||
.add(issuedAmountFromReimbursementRequests)
|
||||
.subtract(burntFee)
|
||||
.subtract(totalConfiscatedAmount)
|
||||
.subtract(burnedBsqOfAllInvalidTxs);
|
||||
.subtract(totalAmountOfBurntBsq)
|
||||
.subtract(totalConfiscatedAmount);
|
||||
|
||||
availableAmountTextField.setText(bsqFormatter.formatAmountWithGroupSeparatorAndCode(availableAmount));
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ import bisq.core.dao.state.DaoStateListener;
|
|||
import bisq.core.dao.state.DaoStateService;
|
||||
import bisq.core.dao.state.model.blockchain.Block;
|
||||
import bisq.core.dao.state.model.blockchain.Tx;
|
||||
import bisq.core.dao.state.model.blockchain.TxType;
|
||||
import bisq.core.dao.state.model.governance.Issuance;
|
||||
import bisq.core.dao.state.model.governance.IssuanceType;
|
||||
import bisq.core.locale.GlobalSettings;
|
||||
|
@ -90,8 +89,8 @@ public class SupplyView extends ActivatableView<GridPane, Void> implements DaoSt
|
|||
|
||||
private int gridRow = 0;
|
||||
private TextField genesisIssueAmountTextField, compRequestIssueAmountTextField, reimbursementAmountTextField,
|
||||
burntAmountTextField, totalLockedUpAmountTextField, totalUnlockingAmountTextField,
|
||||
totalUnlockedAmountTextField, totalConfiscatedAmountTextField, burnedBsqOfAllInvalidTxsTextField;
|
||||
totalBurntFeeAmountTextField, totalLockedUpAmountTextField, totalUnlockingAmountTextField,
|
||||
totalUnlockedAmountTextField, totalConfiscatedAmountTextField, totalAmountOfInvalidatedBsqTextField;
|
||||
private XYChart.Series<Number, Number> seriesBSQIssued, seriesBSQBurnt;
|
||||
|
||||
private static final Map<String, TemporalAdjuster> ADJUSTERS = new HashMap<>();
|
||||
|
@ -168,9 +167,9 @@ public class SupplyView extends ActivatableView<GridPane, Void> implements DaoSt
|
|||
private void createSupplyReducedInformation() {
|
||||
addTitledGroupBg(root, ++gridRow, 2, Res.get("dao.factsAndFigures.supply.burnt"), Layout.GROUP_DISTANCE);
|
||||
|
||||
burntAmountTextField = addTopLabelReadOnlyTextField(root, gridRow,
|
||||
totalBurntFeeAmountTextField = addTopLabelReadOnlyTextField(root, gridRow,
|
||||
Res.get("dao.factsAndFigures.supply.burntAmount"), Layout.FIRST_ROW_AND_GROUP_DISTANCE).second;
|
||||
burnedBsqOfAllInvalidTxsTextField = addTopLabelReadOnlyTextField(root, gridRow, 1,
|
||||
totalAmountOfInvalidatedBsqTextField = addTopLabelReadOnlyTextField(root, gridRow, 1,
|
||||
Res.get("dao.factsAndFigures.supply.invalidTxs"), Layout.FIRST_ROW_AND_GROUP_DISTANCE).second;
|
||||
|
||||
seriesBSQBurnt = new XYChart.Series<>();
|
||||
|
@ -272,20 +271,20 @@ public class SupplyView extends ActivatableView<GridPane, Void> implements DaoSt
|
|||
Coin issuedAmountFromReimbursementRequests = Coin.valueOf(daoFacade.getTotalIssuedAmount(IssuanceType.REIMBURSEMENT));
|
||||
reimbursementAmountTextField.setText(bsqFormatter.formatAmountWithGroupSeparatorAndCode(issuedAmountFromReimbursementRequests));
|
||||
|
||||
Coin burntFee = Coin.valueOf(daoFacade.getTotalBurntFee());
|
||||
Coin totalBurntFee = Coin.valueOf(daoFacade.getTotalBurntFee());
|
||||
Coin totalLockedUpAmount = Coin.valueOf(daoFacade.getTotalLockupAmount());
|
||||
Coin totalUnlockingAmount = Coin.valueOf(daoFacade.getTotalAmountOfUnLockingTxOutputs());
|
||||
Coin totalUnlockedAmount = Coin.valueOf(daoFacade.getTotalAmountOfUnLockedTxOutputs());
|
||||
Coin totalConfiscatedAmount = Coin.valueOf(daoFacade.getTotalAmountOfConfiscatedTxOutputs());
|
||||
Coin burnedBsqOfAllInvalidTxs = Coin.valueOf(daoFacade.getBurnedBsqOfAllInvalidTxs());
|
||||
Coin totalAmountOfInvalidatedBsq = Coin.valueOf(daoFacade.getTotalAmountOfInvalidatedBsq());
|
||||
|
||||
burntAmountTextField.setText("-" + bsqFormatter.formatAmountWithGroupSeparatorAndCode(burntFee));
|
||||
totalBurntFeeAmountTextField.setText("-" + bsqFormatter.formatAmountWithGroupSeparatorAndCode(totalBurntFee));
|
||||
totalLockedUpAmountTextField.setText(bsqFormatter.formatAmountWithGroupSeparatorAndCode(totalLockedUpAmount));
|
||||
totalUnlockingAmountTextField.setText(bsqFormatter.formatAmountWithGroupSeparatorAndCode(totalUnlockingAmount));
|
||||
totalUnlockedAmountTextField.setText(bsqFormatter.formatAmountWithGroupSeparatorAndCode(totalUnlockedAmount));
|
||||
totalConfiscatedAmountTextField.setText(bsqFormatter.formatAmountWithGroupSeparatorAndCode(totalConfiscatedAmount));
|
||||
String minusSign = burnedBsqOfAllInvalidTxs.isPositive() ? "-" : "";
|
||||
burnedBsqOfAllInvalidTxsTextField.setText(minusSign + bsqFormatter.formatAmountWithGroupSeparatorAndCode(burnedBsqOfAllInvalidTxs));
|
||||
String minusSign = totalAmountOfInvalidatedBsq.isPositive() ? "-" : "";
|
||||
totalAmountOfInvalidatedBsqTextField.setText(minusSign + bsqFormatter.formatAmountWithGroupSeparatorAndCode(totalAmountOfInvalidatedBsq));
|
||||
|
||||
updateCharts();
|
||||
}
|
||||
|
@ -307,13 +306,7 @@ public class SupplyView extends ActivatableView<GridPane, Void> implements DaoSt
|
|||
ZonedDateTime zonedDateTime = date.atStartOfDay(ZoneId.systemDefault());
|
||||
return new XYChart.Data<Number, Number>(zonedDateTime.toInstant().getEpochSecond(), burntBsqByMonth.get(date)
|
||||
.stream()
|
||||
.mapToDouble(tx -> {
|
||||
if (tx.getTxType() == TxType.INVALID) {
|
||||
return daoStateService.getBurnedBsqOfInvalidTx(tx);
|
||||
} else {
|
||||
return tx.getBurntFee();
|
||||
}
|
||||
})
|
||||
.mapToDouble(Tx::getBurntBsq)
|
||||
.sum()
|
||||
);
|
||||
})
|
||||
|
|
|
@ -51,10 +51,10 @@ public class BSQTransactionsView extends ActivatableView<GridPane, Void> impleme
|
|||
private final Preferences preferences;
|
||||
|
||||
private int gridRow = 0;
|
||||
private TextField allTxTextField, burntTxTextField,
|
||||
private TextField allTxTextField, burntFeeTxsTextField,
|
||||
utxoTextField, compensationIssuanceTxTextField,
|
||||
reimbursementIssuanceTxTextField,
|
||||
invalidTxTextField;
|
||||
invalidTxsTextField;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Constructor, lifecycle
|
||||
|
@ -107,9 +107,9 @@ public class BSQTransactionsView extends ActivatableView<GridPane, Void> impleme
|
|||
reimbursementIssuanceTxTextField = addTopLabelReadOnlyTextField(root, gridRow, columnIndex,
|
||||
Res.get("dao.factsAndFigures.transactions.reimbursementIssuanceTx"),
|
||||
Layout.FIRST_ROW_AND_GROUP_DISTANCE).second;
|
||||
burntTxTextField = addTopLabelReadOnlyTextField(root, ++gridRow, columnIndex,
|
||||
burntFeeTxsTextField = addTopLabelReadOnlyTextField(root, ++gridRow, columnIndex,
|
||||
Res.get("dao.factsAndFigures.transactions.burntTx")).second;
|
||||
invalidTxTextField = addTopLabelReadOnlyTextField(root, ++gridRow, columnIndex,
|
||||
invalidTxsTextField = addTopLabelReadOnlyTextField(root, ++gridRow, columnIndex,
|
||||
Res.get("dao.factsAndFigures.transactions.invalidTx")).second;
|
||||
}
|
||||
|
||||
|
@ -145,8 +145,8 @@ public class BSQTransactionsView extends ActivatableView<GridPane, Void> impleme
|
|||
utxoTextField.setText(String.valueOf(daoFacade.getUnspentTxOutputs().size()));
|
||||
compensationIssuanceTxTextField.setText(String.valueOf(daoFacade.getNumIssuanceTransactions(IssuanceType.COMPENSATION)));
|
||||
reimbursementIssuanceTxTextField.setText(String.valueOf(daoFacade.getNumIssuanceTransactions(IssuanceType.REIMBURSEMENT)));
|
||||
burntTxTextField.setText(String.valueOf(daoFacade.getFeeTxs().size()));
|
||||
invalidTxTextField.setText(String.valueOf(daoFacade.getInvalidTxs().size()));
|
||||
burntFeeTxsTextField.setText(String.valueOf(daoFacade.getBurntFeeTxs().size()));
|
||||
invalidTxsTextField.setText(String.valueOf(daoFacade.getInvalidTxs().size()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue