Skip to content

Commit 93886b8

Browse files
committed
feat: use passphrase for validator registration/update
1 parent 63c405e commit 93886b8

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎src/main/java/org/arkecosystem/crypto/utils/TransactionEncoder.java‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public static String validatorRegistration(String passphrase) {
4646
return encode(
4747
ContractAbiType.CONSENSUS,
4848
AbiFunction.VALIDATOR_REGISTRATION,
49-
Arrays.asList("0x" + Hex.encode(pop.pk), "0x" + Hex.encode(pop.pop)));
49+
Arrays.asList(addHexPrefix(Hex.encode(pop.pk)), addHexPrefix(Hex.encode(pop.pop))));
5050
}
5151

5252
public static String validatorResignation() {
@@ -61,7 +61,7 @@ public static String validatorUpdate(String passphrase) {
6161
return encode(
6262
ContractAbiType.CONSENSUS,
6363
AbiFunction.UPDATE_VALIDATOR,
64-
Arrays.asList("0x" + Hex.encode(pop.pk), "0x" + Hex.encode(pop.pop)));
64+
Arrays.asList(addHexPrefix(Hex.encode(pop.pk)), addHexPrefix(Hex.encode(pop.pop))));
6565
}
6666

6767
public static String vote(String voteAddress) {
@@ -84,5 +84,7 @@ private static String encode(ContractAbiType type, AbiFunction function, List<Ob
8484
}
8585
}
8686

87-
87+
private static String addHexPrefix(String value) {
88+
return value.startsWith("0x") ? value : "0x" + value;
89+
}
8890
}

0 commit comments

Comments
 (0)