Skip to content
This repository was archived by the owner on Aug 30, 2022. It is now read-only.

Commit 0dc31df

Browse files
author
Jon La Marr
committed
Add overload to EOSFormatter
1 parent f90b5b5 commit 0dc31df

1 file changed

Lines changed: 21 additions & 3 deletions

File tree

eosiojava/src/main/java/one/block/eosiojava/utilities/EOSFormatter.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -818,27 +818,45 @@ public static String extractSerializedTransactionFromSignable(@NotNull String eo
818818
* <p>
819819
* Signable signature structure:
820820
* <p>
821-
* chainId + serialized transaction + 32 bytes of 0
821+
* chainId + serialized transaction + 32 bytes of serializedContextFreeData
822822
*
823823
* @param serializedTransaction - the serialized transaction to be converted to signable transaction
824824
* @param chainId - the chain id will be used inside the signature transaction structure.
825+
* @param serializedContextFreeData - the serialized context free data to be converted with transaction
825826
* @return - Signable transaction
826827
* @throws EOSFormatterError if inputs are invalid
827828
*/
828829
public static String prepareSerializedTransactionForSigning(@NotNull String serializedTransaction,
829-
@NotNull String chainId) throws EOSFormatterError {
830+
@NotNull String chainId, @NotNull String serializedContextFreeData) throws EOSFormatterError {
830831
if (serializedTransaction.isEmpty() || chainId.isEmpty()) {
831832
throw new EOSFormatterError(ErrorConstants.EMPTY_INPUT_PREPARE_SERIALIZIED_TRANS_FOR_SIGNING);
832833
}
833834

834-
String signableTransaction = chainId + serializedTransaction + Hex.toHexString(new byte[32]);
835+
String signableTransaction = chainId + serializedTransaction + serializedContextFreeData;
835836
if (signableTransaction.length() <= MINIMUM_SIGNABLE_TRANSACTION_LENGTH) {
836837
throw new EOSFormatterError(String.format(ErrorConstants.INVALID_INPUT_SIGNABLE_TRANS_LENGTH_EXTRACT_SERIALIZIED_TRANS_FROM_SIGNABLE, MINIMUM_SIGNABLE_TRANSACTION_LENGTH));
837838
}
838839

839840
return signableTransaction;
840841
}
841842

843+
/**
844+
* Preparing signable transaction for signing.
845+
* <p>
846+
* Signable signature structure:
847+
* <p>
848+
* chainId + serialized transaction + 32 bytes of 0
849+
*
850+
* @param serializedTransaction - the serialized transaction to be converted to signable transaction
851+
* @param chainId - the chain id will be used inside the signature transaction structure.
852+
* @return - Signable transaction
853+
* @throws EOSFormatterError if inputs are invalid
854+
*/
855+
public static String prepareSerializedTransactionForSigning(@NotNull String serializedTransaction,
856+
@NotNull String chainId) throws EOSFormatterError {
857+
return EOSFormatter.prepareSerializedTransactionForSigning(serializedTransaction, chainId, Hex.toHexString(new byte[32]));
858+
}
859+
842860
/**
843861
* This method converts a DER encoded private key, public key, or signature into the PEM
844862
* format.

0 commit comments

Comments
 (0)