Package org.nervos.muta.wallet
Class Account
- java.lang.Object
-
- org.nervos.muta.wallet.Account
-
public class Account extends java.lang.Object
Account is a class to hold all private key, public key and address info, and is on duty of sign tx
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static byte[]
convertBech32AddressToBytesAddress(java.lang.String bech32Address)
Get inner address in bech32 format and return in byte arraystatic java.lang.String
convertBech32AddressToHexAddress(java.lang.String bech32Address)
Get inner address in bech32 format and return in hex stringstatic java.lang.String
convertBech32AddressToHexAddress(java.lang.String bech32Address, java.lang.String hrp)
static java.lang.String
convertBytesAddressToBech32Address(byte[] address)
Get bech32 format address from inner address in byte arraystatic java.lang.String
convertHexAddressToBech32Address(java.lang.String address)
Get bech32 format address from inner address in hex stringstatic java.lang.String
convertHexAddressToBech32Address(java.lang.String address, java.lang.String hrp)
static Account
defaultAccount()
Return account with default private key, this is easy in dev and test envstatic Account
fromByteArray(byte[] b)
Create account by private key in byte[] formatstatic Account
fromHexString(java.lang.String hexString)
Create account by private key in hex string formatstatic Account
generate()
Create account by a random private keyAddress
getAddress()
byte[]
getAddressByteArray()
java.lang.String
getAddressHex()
java.lang.String
getBech32Address()
GAddress
getGAddress()
java.math.BigInteger
getPrivateKeyBigInteger()
byte[]
getPrivateKeyByteArray()
java.lang.String
getPrivateKeyHex()
byte[]
getPublicKeyByteArray()
org.bouncycastle.math.ec.ECPoint
getPublicKeyECPoint()
java.lang.String
getPublicKeyHex()
byte[]
sign(byte[] msgHash)
Sign a data by this account's private key, the data should be a digest of certain messagestatic boolean
validate_bech32_address(java.lang.String bech32Address, java.lang.String hrp)
-
-
-
Method Detail
-
fromHexString
public static Account fromHexString(java.lang.String hexString)
Create account by private key in hex string format- Parameters:
hexString
- private key in hex string- Returns:
- created account
-
fromByteArray
public static Account fromByteArray(byte[] b)
Create account by private key in byte[] format- Parameters:
b
- private key in byte[] format- Returns:
- created account
-
generate
public static Account generate()
Create account by a random private key- Returns:
- created account
-
defaultAccount
public static Account defaultAccount()
Return account with default private key, this is easy in dev and test env- Returns:
- created account
-
convertBech32AddressToBytesAddress
public static byte[] convertBech32AddressToBytesAddress(java.lang.String bech32Address)
Get inner address in bech32 format and return in byte array- Parameters:
bech32Address
- address in bech32 format- Returns:
- inner address in byte array
-
convertBech32AddressToHexAddress
public static java.lang.String convertBech32AddressToHexAddress(java.lang.String bech32Address)
Get inner address in bech32 format and return in hex string- Parameters:
bech32Address
- address in bech32 format- Returns:
- inner address in hex string
-
convertBech32AddressToHexAddress
public static java.lang.String convertBech32AddressToHexAddress(java.lang.String bech32Address, java.lang.String hrp)
-
convertBytesAddressToBech32Address
public static java.lang.String convertBytesAddressToBech32Address(byte[] address)
Get bech32 format address from inner address in byte array- Parameters:
address
- address in bech32 format- Returns:
- bech32 address
-
convertHexAddressToBech32Address
public static java.lang.String convertHexAddressToBech32Address(java.lang.String address)
Get bech32 format address from inner address in hex string- Parameters:
address
- address in bech32 format- Returns:
- bech32 address
-
convertHexAddressToBech32Address
public static java.lang.String convertHexAddressToBech32Address(java.lang.String address, java.lang.String hrp)
-
getPrivateKeyByteArray
public byte[] getPrivateKeyByteArray()
-
getPrivateKeyHex
public java.lang.String getPrivateKeyHex()
-
getPrivateKeyBigInteger
public java.math.BigInteger getPrivateKeyBigInteger()
-
getPublicKeyByteArray
public byte[] getPublicKeyByteArray()
-
getPublicKeyHex
public java.lang.String getPublicKeyHex()
-
getPublicKeyECPoint
public org.bouncycastle.math.ec.ECPoint getPublicKeyECPoint()
-
getAddressByteArray
public byte[] getAddressByteArray()
-
getGAddress
public GAddress getGAddress()
-
getAddress
public Address getAddress()
-
getAddressHex
public java.lang.String getAddressHex()
-
getBech32Address
public java.lang.String getBech32Address()
-
sign
public byte[] sign(byte[] msgHash)
Sign a data by this account's private key, the data should be a digest of certain message- Parameters:
msgHash
- digest of message- Returns:
- signed signature
-
validate_bech32_address
public static boolean validate_bech32_address(java.lang.String bech32Address, java.lang.String hrp)
-
-