@@ -132,7 +132,7 @@ public boolean isBalanceDiffConsistent(Set<Hash> approvedHashes, Map<Hash, Long>
132132 }
133133 Set <Hash > visitedHashes = new HashSet <>(approvedHashes );
134134 Map <Hash , Long > currentState = generateBalanceDiff (visitedHashes , tip ,
135- snapshotProvider .getLatestSnapshot ().getIndex ());
135+ snapshotProvider .getLatestSnapshot ().getIndex (), true );
136136 if (currentState == null ) {
137137 return false ;
138138 }
@@ -151,7 +151,7 @@ public boolean isBalanceDiffConsistent(Set<Hash> approvedHashes, Map<Hash, Long>
151151 }
152152
153153 @ Override
154- public Map <Hash , Long > generateBalanceDiff (Set <Hash > visitedTransactions , Hash startTransaction , int milestoneIndex )
154+ public Map <Hash , Long > generateBalanceDiff (Set <Hash > visitedTransactions , Hash startTransaction , int milestoneIndex , boolean allowGenesisReference )
155155 throws LedgerException {
156156
157157 Map <Hash , Long > state = new HashMap <>();
@@ -175,6 +175,18 @@ public Map<Hash, Long> generateBalanceDiff(Set<Hash> visitedTransactions, Hash s
175175
176176 boolean isEmptyTrunk = trunkTransactionViewModel .getType () == TransactionViewModel .PREFILLED_SLOT ;
177177 boolean isEmptyBranch = branchTransactionViewModel .getType () == TransactionViewModel .PREFILLED_SLOT ;
178+
179+ //Don't confirm non-solid txs.
180+ Hash genesisHash = Hash .NULL_HASH ;
181+ if (isEmptyTrunk && !allowGenesisReference ){
182+ return null ;
183+ }
184+ //proceed only if empty trunk or branch is genesis
185+ if ((isEmptyTrunk && !trunkTransactionViewModel .getHash ().equals (genesisHash ))||
186+ (isEmptyBranch && !branchTransactionViewModel .getHash ().equals (genesisHash ))){
187+ return null ;
188+ }
189+
178190 boolean isApprovedTrunk = (trunkTransactionViewModel .snapshotIndex () > 0 ) && (trunkTransactionViewModel .snapshotIndex () != milestoneIndex );
179191 boolean isApprovedBranch = (branchTransactionViewModel .snapshotIndex () > 0 ) && (branchTransactionViewModel .snapshotIndex () != milestoneIndex );
180192 boolean isLeafTrunk = isEmptyTrunk || visitedTransactions .contains (trunkTransactionViewModel .getHash ()) || isApprovedTrunk ;
@@ -286,7 +298,7 @@ private boolean generateStateDiff(MilestoneViewModel milestone) throws LedgerExc
286298 try {
287299 Hash tail = transactionViewModel .getHash ();
288300 Map <Hash , Long > balanceChanges = generateBalanceDiff (new HashSet <>(), tail ,
289- snapshotProvider .getLatestSnapshot ().getIndex ());
301+ snapshotProvider .getLatestSnapshot ().getIndex (), true );
290302 successfullyProcessed = balanceChanges != null ;
291303 if (successfullyProcessed ) {
292304 milestoneService .updateMilestoneIndexOfMilestoneTransactions (milestone .getHash (),
0 commit comments