Skip to content

Commit

Permalink
Merge pull request #1688 from rsksmart/document-remasc-tx
Browse files Browse the repository at this point in the history
Documented RemascTransaction check usage across the platform
  • Loading branch information
Vovchyk authored Feb 9, 2022
2 parents e61178b + 0f84f14 commit f783c05
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
22 changes: 21 additions & 1 deletion rskj-core/src/main/java/co/rsk/remasc/RemascTransaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,27 @@
import static org.ethereum.rpc.TypeConverter.toUnformattedJsonHex;

/**
* Tx that invokes Remasc's processMinersFees method.
* <p>
* Tx that invokes Remasc's processMinersFees method.
* </p>
* <p>
* Use #{@link Transaction#isRemascTransaction(int, int)} if you have not yet parsed the transaction
* and it is still in binary format.
* </p>
* <p>
* Use <b></b><i></>instanceOf<i/><b/> to know if a parsed transaction is a remasc transaction.
* </p>
* <p>
* If you would like an easier way to know if a transaction is a Remasc transaction rather than using
* #{@link Transaction#isRemascTransaction(int, int)}, you could use:
* <blockquote>obj instanceOf RemascTransaction</blockquote>
* </p>
* <p>
* <b>NOTE:</b> Consider that <b></b><i></>instanceOf<i/><b/> only will work if you create an
* instance of this class, otherwise using #{@link Transaction#isRemascTransaction(int, int)} is more
* recommended and safe.
* </p>
*
* @author Oscar Guindzberg
*/
public class RemascTransaction extends Transaction {
Expand Down
14 changes: 14 additions & 0 deletions rskj-core/src/main/java/org/ethereum/core/Transaction.java
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,20 @@ public void setLocalCallTransaction(boolean isLocalCall) {
this.isLocalCall = isLocalCall;
}

/**
* <p>
* Returns true if the current transaction is a Remasc transaction by checking if the transaction position is the
* last one, if receive address is equals to #PrecompiledContracts.REMASC_ADDR and finally if there is a signature
* and data having value, gas limit and gas price equals to 0, otherwise returns false.
* </p>
* <p>
* Use this method when you don't know if the transaction is a remasc transaction from the parameters given above.
* </p>
*
* @param txPosition transaction position
* @param txsSize transaction size
* @return true if the current transaction is a Remasc transaction, otherwise returns false.
*/
public boolean isRemascTransaction(int txPosition, int txsSize) {
return isLastTx(txPosition, txsSize) && checkRemascAddress() && checkRemascTxZeroValues();
}
Expand Down

0 comments on commit f783c05

Please sign in to comment.