use of org.ethereum.crypto.ECKey in project rskj by rsksmart.
the class GenNodeKeyId method main.
public static void main(String[] args) {
String generator = "";
if (args.length > 0) {
generator = args[0];
}
ECKey key;
if (generator.equals("")) {
key = new ECKey();
} else {
key = ECKey.fromPrivate(HashUtil.keccak256(generator.getBytes(StandardCharsets.UTF_8)));
}
String keybytes = Hex.toHexString(key.getPrivKeyBytes());
String pubkeybytes = Hex.toHexString(key.getPubKey());
String compressedpubkeybytes = Hex.toHexString(key.getPubKey(true));
String address = Hex.toHexString(key.getAddress());
String nodeid = Hex.toHexString(key.getNodeId());
System.out.println('{');
System.out.println(" \"privateKey\": \"" + keybytes + "\",");
System.out.println(" \"publicKey\": \"" + pubkeybytes + "\",");
System.out.println(" \"publicKeyCompressed\": \"" + compressedpubkeybytes + "\",");
System.out.println(" \"address\": \"" + address + "\",");
System.out.println(" \"nodeId\": \"" + nodeid + "\"");
System.out.println('}');
}
use of org.ethereum.crypto.ECKey in project rskj by rsksmart.
the class Wallet method addAccount.
public RskAddress addAccount() {
Account account = new Account(new ECKey());
saveAccount(account);
return account.getAddress();
}
use of org.ethereum.crypto.ECKey in project account-identity by cryptofiat.
the class EthereumService method transferAccountApprovalRight.
public void transferAccountApprovalRight(String newAddress) throws IOException {
newAddress = with0x(newAddress);
ECKey approver = getAccountApproverKey();
String txHash = sendTransaction(approver, appointAccountApproverFunction.encode(newAddress));
log.info("Account approval right transferred to " + newAddress + ". You must change your account approver key file accordingly. TxHash=" + txHash);
}
use of org.ethereum.crypto.ECKey in project account-identity by cryptofiat.
the class EthereumService method sendBalance.
public String sendBalance(String toAddress, String privKey, int nonceIncrement) throws IOException {
ECKey signer = ECKey.fromPrivate(Hex.decode(without0x(privKey)));
WalletServerAccountResponse addrDetails = wsService.getAccount(hex(signer.getAddress()));
return sendBalance(toAddress, privKey, nonceIncrement, addrDetails.getBalance());
}
use of org.ethereum.crypto.ECKey in project account-identity by cryptofiat.
the class EthereumService method sendBalance.
public String sendBalance(String toAddress, String privKey, int nonceIncrement, long amount) throws IOException {
ECKey signer = ECKey.fromPrivate(Hex.decode(without0x(privKey)));
ECKey sponsorKey = getAccountApproverKey();
WalletServerAccountResponse addrDetails = wsService.getAccount(hex(signer.getAddress()));
byte[] signatureArg = signDelegate(0, amount, addrDetails.getNonce() + 1 + nonceIncrement, without0x(toAddress), signer);
byte[] callData = transferFunction.encode(addrDetails.getNonce() + 1 + nonceIncrement, toAddress, amount, 0, signatureArg, hex(sponsorKey.getAddress()));
String txHash = sendTransaction(sponsorKey, callData, contractAddressForTransfers, nonceIncrement);
log.info("Submitted transfer and got Tx= " + txHash);
return txHash;
}
Aggregations