[bisq-network/bisq-core] Parse opreturn before other outputs (#175)

Manfred Karrer notifications at github.com
Mon Sep 3 16:30:50 UTC 2018


ManfredKarrer commented on this pull request.



> @@ -138,14 +138,12 @@ public TxOutput getLastTxOutput() {
 
 
     /**
-     * OpReturn output might contain the lockTime in case of a LockTx. It has to be the last output.
-     * We store technically the lockTime there as is is stored in the OpReturn data but conceptually we want to provide
-     * it from the transaction.
+     * The locktime is stored in the LOCKUP txOutput, which is the first txOutput.

Hm... I am not sure if the first output is a good place here. Technically its the opReturn output, conceptually its the tx (thats why we use a delegate there).

> @@ -154,6 +158,9 @@ public TxParser(PeriodService periodService,
                     DevEnv.logErrorAndThrowIfDevMode(msg);
                 }
             } else {
+                // TODO(SQ): The transaction has already been parsed here and the individual txouputs are considered
+                // spendable or otherwise correct. Perhaps this check should be done earlier.
+

I think you are correct. Should be probably done earlier 

> @@ -115,11 +115,15 @@ public TxParser(PeriodService periodService,
             // We keep the temporary opReturn type in the parsingModel object.
             checkArgument(!outputs.isEmpty(), "outputs must not be empty");
             int lastIndex = outputs.size() - 1;
-            txOutputParser.processOpReturnCandidate(outputs.get(lastIndex));
+            int lastNonOpReturnIndex = lastIndex;
+            if (txOutputParser.processOpReturnCandidate(outputs.get(lastIndex))) {
+                txOutputParser.processTxOutput(true, outputs.get(lastIndex), lastIndex);

I am not 100% if that can cause problems. We can discuss tomorrow.

> @@ -81,8 +82,9 @@ public void processGenesisTxOutput(TempTx genesisTx) {
         }
     }
 
-    void processOpReturnCandidate(TempTxOutput txOutput) {
+    boolean processOpReturnCandidate(TempTxOutput txOutput) {

If we return a boolean we should rename to make that more clear (e.g. isOpReturnCandidate)

> @@ -164,6 +166,7 @@ private void handleBsqOutput(TempTxOutput txOutput, int index, long txOutputValu
             optionalVoteRevealUnlockStakeOutput = Optional.of(txOutput);
         } else if (isFirstOutput && opReturnTypeCandidate == OpReturnType.LOCKUP) {
             bsqOutput = TxOutputType.LOCKUP;
+            txOutput.setLockTime(lockTime);

Why put it in first output? Technically its in opReturn, conceptually in Tx.

-- 
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-core/pull/175#pullrequestreview-151844278
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.bisq.network/pipermail/bisq-github/attachments/20180903/5150deb2/attachment.html>


More information about the bisq-github mailing list