[bisq-network/bisq] [WIP] Apply rule to not allow BSQ outputs after BTC output for regular txs (#3413)
sqrrm
notifications at github.com
Sun Oct 20 10:24:21 UTC 2019
sqrrm commented on this pull request.
> + // After the hard fork activation we fix a bug with a transaction which would have interpreted the
+ // vote fee output as BSQ if the vote fee was >= miner fee.
+ // Such a tx was never created but as we don't know if it will happen before activation date we cannot
+ // enforce the bug fix which represents a rule change before the activation date.
+ handleIssuanceCandidateOutput(tempTxOutput);
+ } else if (isHardForkActivated(tempTxOutput) && isBlindVoteFeeOutput(tempTxOutput)) {
+ // After the hard fork activation we fix a bug with a transaction which would have interpreted the
+ // issuance output as BSQ if the availableInputValue was >= issuance amount.
+ // Such a tx was never created but as we don't know if it will happen before activation date we cannot
+ // enforce the bug fix which represents a rule change before the activation date.
Comments are switched, vote fee comment for issuance and vice versa
> + private boolean isBlindVoteFeeOutput(TempTxOutput tempTxOutput) {
+ if (!optionalOpReturnType.isPresent()) {
+ return false;
+ }
+
+ if (optionalOpReturnType.get() != OpReturnType.BLIND_VOTE) {
+ return false;
+ }
+
+ // If it is the vote stake output we return false.
+ if (tempTxOutput.getIndex() == 0) {
+ return false;
+ }
+
+ // There must be a vote fee left
+ if (availableInputValue <= 0) {
I think there is always a vote fee left here if any fee was paid at all
> +
+ private void handleIssuanceCandidateOutput(TempTxOutput tempTxOutput) {
+ // We do not permit more BSQ outputs after the issuance candidate.
+ prohibitMoreBsqOutputs = true;
+
+ // We store the candidate but we don't apply the TxOutputType yet as we need to verify the fee after all
+ // outputs are parsed and check the phase. The TxParser will do that....
+ optionalIssuanceCandidate = Optional.of(tempTxOutput);
+ }
+
+ private void handleBlindVoteFeeOutput(TempTxOutput tempTxOutput) {
+ tempTxOutput.setTxOutputType(TxOutputType.BTC_OUTPUT);
+ prohibitMoreBsqOutputs = true;
+ }
+
+ private boolean isBlindVoteFeeOutput(TempTxOutput tempTxOutput) {
I don't understand the naming of this method
> + if (availableInputValue <= 0) {
+ return false;
+ }
+
+ // Burned BSQ output is last output before opReturn.
+ // We could have also a BSQ change output as last output before opReturn but that will
+ // be detected at blindVoteFee check.
+ // We always have the BSQ change before the burned BSQ output if both are present.
+ checkArgument(optionalOpReturnIndex.isPresent());
+ if (tempTxOutput.getIndex() != optionalOpReturnIndex.get() - 1) {
+ return false;
+ }
+
+ // Without checking the fee we would not be able to distinguish between 2 structurally same transactions, one
+ // where the output is burned BSQ and one where it is a BSQ change output.
+ long blindVoteFee = daoStateService.getParamValueAsCoin(Param.BLIND_VOTE_FEE, tempTxOutput.getBlockHeight()).value;
I feel it would be better to disallow any other BSQ outputs than the vote stake output for blind vote txs. I think the code would be easier to read and I don't see any other use case.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/bisq-network/bisq/pull/3413#pullrequestreview-304251526
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20191020/a3556af9/attachment-0001.html>
More information about the bisq-github
mailing list