public class LegacyWallet extends java.lang.Object implements Wallet
Modifier and Type | Field and Description |
---|---|
protected WalletApi |
delegate |
protected ExceptionConverter<WalletException> |
exceptionConverter |
protected org.slf4j.Logger |
logger |
protected WalletType |
type |
Constructor and Description |
---|
LegacyWallet() |
Modifier and Type | Method and Description |
---|---|
void |
bindKeyStore(java.security.KeyStore keyStore)
Bind a keystore with wallet.
|
void |
cacheChainIdHash()
Cache chain id hash with current node.
|
void |
cacheChainIdHash(ChainIdHash chainIdHash)
Cache chain id hash with corresponding
chainIdHash . |
void |
close() |
TxHash |
commit(RawTransaction rawTransaction)
Sign and commit transaction.
|
TxHash |
commit(Transaction signedTransaction)
Commit a signed transaction.
|
TxHash |
createName(java.lang.String name)
Create name info of a current account.
|
ContractTxHash |
deploy(ContractDefinition contractDefinition)
Deploy smart contract.
|
ContractTxHash |
deploy(ContractDefinition contractDefinition,
Fee fee)
Deploy smart contract.
|
ContractTxHash |
execute(ContractInvocation contractInvocation)
Execute a smart contract function.
|
ContractTxHash |
execute(ContractInvocation contractInvocation,
Fee fee)
Execute a smart contract function.
|
java.lang.String |
exportKey(Authentication authentication)
Export an aergo key of a current account with encrypted.
|
Account |
getAccount()
Get a current account.
|
AccountState |
getAccountState()
Get state of current account.
|
AccountState |
getAccountState(Account account)
Get account state by address.
|
AccountState |
getAccountState(AccountAddress accountAddress)
Get account state by account.
|
BlockHash |
getBestBlockHash()
Get best block hash.
|
long |
getBestBlockHeight()
Get best block height.
|
Block |
getBlock(BlockHash blockHash)
Get block by hash.
|
Block |
getBlock(long height)
Get block by height.
|
BlockchainStatus |
getBlockchainStatus()
Get blockchain status.
|
BlockMetadata |
getBlockMetadata(BlockHash blockHash)
Get block metadata by hash.
|
BlockMetadata |
getBlockMetadata(long height)
Get block metadata by height.
|
ChainIdHash |
getCachedChainIdHash()
Get cached chain id hash.
|
ChainIdHash |
getChainIdHash()
Get chain id hash.
|
ChainInfo |
getChainInfo()
Get chain info of current node.
|
ChainStats |
getChainStats()
Get chain stats of current node.
|
ContractInterface |
getContractInterface(ContractAddress contractAddress)
Get smart contract interface corresponding to contract address.
|
AccountAddress |
getNameOwner(java.lang.String name)
Get owner of an account name.
|
AccountAddress |
getNameOwner(java.lang.String name,
long blockNumber)
Get owner of an account name at block number
blockNumber . |
NodeStatus |
getNodeStatus()
Get status of current node.
|
ContractTxReceipt |
getReceipt(ContractTxHash contractTxHash)
Get receipt of transaction.
|
long |
getRecentlyUsedNonce()
Get recently used nonce value.
|
ServerInfo |
getServerInfo(java.util.List<java.lang.String> categories)
Get server info of current node.
|
StakeInfo |
getStakingInfo()
Get staking information of current account.
|
StakeInfo |
getStakingInfo(Account account)
Get staking information of
account . |
StakeInfo |
getStakingInfo(AccountAddress accountAddress)
Get staking information of
accountAddress . |
Transaction |
getTransaction(TxHash txHash)
Get transaction.
|
AccountTotalVote |
getVotes()
Get votes which current account votes for.
|
AccountTotalVote |
getVotesOf(Account account)
Get votes which
account votes for. |
AccountTotalVote |
getVotesOf(AccountAddress accountAddress)
Get votes which
accountAddress votes for. |
long |
incrementAndGetNonce()
Increment an nonce and get it.
|
java.util.List<BlockMetadata> |
listBlockMetadatas(BlockHash blockHash,
int size)
Get block metadatas of
size backward starting from block for provided hash. |
java.util.List<BlockMetadata> |
listBlockMetadatas(long height,
int size)
Get block metadatas of
size backward starting from block for provided height. |
java.util.List<ElectedCandidate> |
listElected(java.lang.String voteId,
int showCount)
Get elected candidates per
voteId for current round. |
java.util.List<ElectedCandidate> |
listElectedBps(int showCount)
Get elected block producers for current round.
|
java.util.List<Event> |
listEvents(EventFilter filter)
List events corresponding with event filter.
|
java.util.List<Identity> |
listKeyStoreIdentities()
Get all the stored identities in a binded key store.
|
java.util.List<Peer> |
listNodePeers()
Get blockchain peer addresses.
|
java.util.List<PeerMetric> |
listPeerMetrics()
Get metrics of peers.
|
java.util.List<AccountAddress> |
listServerKeyStoreAccounts()
Get account list on a server key store.
|
Account |
loadAccount(Authentication authentication)
Unlock and load account corresponding with
authentication . |
boolean |
lock(Authentication authentication)
Lock current account with
Authentication . |
ContractResult |
query(ContractInvocation contractInvocation)
Query the smart contract state by calling smart contract function.
|
void |
saveKey(AergoKey key,
Identity identity,
java.lang.String password)
Save an aergo key to the key store.
|
void |
saveKey(AergoKey key,
java.lang.String password)
Save an aergo key to the key store.
|
TxHash |
send(AccountAddress recipient,
Aer amount)
Send aer with
fee . |
TxHash |
send(AccountAddress recipient,
Aer amount,
BytesValue payload)
Send aer with
fee and payload . |
TxHash |
send(AccountAddress recipient,
Aer amount,
Fee fee)
Send aer with
fee . |
TxHash |
send(AccountAddress recipient,
Aer amount,
Fee fee,
BytesValue payload)
Send aer with
fee and payload . |
TxHash |
send(java.lang.String recipient,
Aer amount)
Send aer.
|
TxHash |
send(java.lang.String recipient,
Aer amount,
BytesValue payload)
Send aer and
payload . |
TxHash |
send(java.lang.String recipient,
Aer amount,
Fee fee)
Send aer with
fee . |
TxHash |
send(java.lang.String recipient,
Aer amount,
Fee fee,
BytesValue payload)
Send aer with
fee and payload . |
Transaction |
sign(RawTransaction rawTransaction)
Sign for transaction.
|
TxHash |
stake(Aer amount)
Staking an account with amount of a current account.
|
void |
storeKeyStore(java.lang.String path,
java.lang.String password)
Store the keystore to the path.
|
Subscription<Event> |
subscribeEvent(EventFilter filter,
StreamObserver<Event> observer)
Subscribe event corresponding with event filter.
|
Subscription<Block> |
subscribeNewBlock(StreamObserver<Block> observer)
Subscribe block stream which is triggered everytime new block is generated.
|
Subscription<BlockMetadata> |
subscribeNewBlockMetadata(StreamObserver<BlockMetadata> observer)
Subscribe block metadata stream which is triggered everytime new block is generated.
|
boolean |
unlock(Authentication authentication)
Unlock account with
Authentication . |
TxHash |
unstake(Aer amount)
Unstaking an account with amount of a current account.
|
TxHash |
updateName(java.lang.String name,
AccountAddress newOwner)
Update name info of to an new owner.
|
boolean |
verify(Transaction transaction)
Verify transaction.
|
TxHash |
vote(java.lang.String voteId,
java.util.List<java.lang.String> candidates)
Vote to
candidates with voteId . |
TxHash |
voteBp(java.util.List<java.lang.String> candidates)
Vote to bp
candidates . |
protected final transient org.slf4j.Logger logger
protected final ExceptionConverter<WalletException> exceptionConverter
protected final WalletType type
protected WalletApi delegate
public Account getAccount()
AccountHoldable
getAccount
in interface AccountHoldable
public AccountTotalVote getVotes()
AccountHoldable
getVotes
in interface AccountHoldable
public long getRecentlyUsedNonce()
AccountHoldable
getRecentlyUsedNonce
in interface AccountHoldable
public long incrementAndGetNonce()
AccountHoldable
incrementAndGetNonce
in interface AccountHoldable
public void bindKeyStore(java.security.KeyStore keyStore)
KeyManageable
WalletType.Secure
.
For other wallet type, do nothing.bindKeyStore
in interface KeyManageable
keyStore
- a java keystorepublic void saveKey(AergoKey key, java.lang.String password)
KeyManageable
WalletType.Naive
.saveKey
in interface KeyManageable
key
- an aergo keypassword
- an encrypt keypublic void saveKey(AergoKey key, Identity identity, java.lang.String password)
KeyManageable
WalletType.Naive
.saveKey
in interface KeyManageable
key
- an aergo keyidentity
- an identity to save keypassword
- an encrypt keypublic java.lang.String exportKey(Authentication authentication)
KeyManageable
exportKey
in interface KeyManageable
authentication
- an authenticationpublic java.util.List<Identity> listKeyStoreIdentities()
KeyManageable
listKeyStoreIdentities
in interface KeyManageable
public boolean unlock(Authentication authentication)
KeyManageable
Authentication
.unlock
in interface KeyManageable
authentication
- an authenticationpublic boolean lock(Authentication authentication)
KeyManageable
Authentication
.lock
in interface KeyManageable
authentication
- an authenticationpublic void storeKeyStore(java.lang.String path, java.lang.String password)
KeyManageable
WalletType.Secure
. For other wallet type, do nothing.storeKeyStore
in interface KeyManageable
path
- a pathpassword
- a password used in storing key storepublic AccountState getAccountState()
AccountHoldable
getAccountState
in interface AccountHoldable
public AccountState getAccountState(Account account)
QueryClient
getAccountState
in interface QueryClient
account
- an accountpublic AccountState getAccountState(AccountAddress accountAddress)
QueryClient
getAccountState
in interface QueryClient
accountAddress
- account addresspublic AccountAddress getNameOwner(java.lang.String name)
QueryClient
getNameOwner
in interface QueryClient
name
- an name of accountpublic AccountAddress getNameOwner(java.lang.String name, long blockNumber)
QueryClient
blockNumber
.getNameOwner
in interface QueryClient
name
- an name of accountblockNumber
- a block numberpublic StakeInfo getStakingInfo()
AccountHoldable
getStakingInfo
in interface AccountHoldable
public StakeInfo getStakingInfo(Account account)
QueryClient
account
.getStakingInfo
in interface QueryClient
account
- an account to check staking informationpublic StakeInfo getStakingInfo(AccountAddress accountAddress)
QueryClient
accountAddress
.getStakingInfo
in interface QueryClient
accountAddress
- an account address to check staking informationpublic java.util.List<ElectedCandidate> listElectedBps(int showCount)
QueryClient
listElectedBps
in interface QueryClient
showCount
- a show countpublic java.util.List<ElectedCandidate> listElected(java.lang.String voteId, int showCount)
QueryClient
voteId
for current round.listElected
in interface QueryClient
voteId
- a vote idshowCount
- a show countpublic AccountTotalVote getVotesOf(Account account)
QueryClient
account
votes for.getVotesOf
in interface QueryClient
account
- an accountpublic AccountTotalVote getVotesOf(AccountAddress accountAddress)
QueryClient
accountAddress
votes for.getVotesOf
in interface QueryClient
accountAddress
- an account addresspublic java.util.List<AccountAddress> listServerKeyStoreAccounts()
QueryClient
listServerKeyStoreAccounts
in interface QueryClient
public BlockHash getBestBlockHash()
QueryClient
getBestBlockHash
in interface QueryClient
public long getBestBlockHeight()
QueryClient
getBestBlockHeight
in interface QueryClient
public ChainIdHash getChainIdHash()
QueryClient
getChainIdHash
in interface QueryClient
public BlockchainStatus getBlockchainStatus()
QueryClient
getBlockchainStatus
in interface QueryClient
public ChainInfo getChainInfo()
QueryClient
getChainInfo
in interface QueryClient
public ChainStats getChainStats()
QueryClient
getChainStats
in interface QueryClient
public java.util.List<Peer> listNodePeers()
QueryClient
listNodePeers
in interface QueryClient
public java.util.List<PeerMetric> listPeerMetrics()
QueryClient
listPeerMetrics
in interface QueryClient
public ServerInfo getServerInfo(java.util.List<java.lang.String> categories)
QueryClient
getServerInfo
in interface QueryClient
categories
- a categoriespublic NodeStatus getNodeStatus()
QueryClient
getNodeStatus
in interface QueryClient
public BlockMetadata getBlockMetadata(BlockHash blockHash)
QueryClient
getBlockMetadata
in interface QueryClient
blockHash
- block hashpublic BlockMetadata getBlockMetadata(long height)
QueryClient
getBlockMetadata
in interface QueryClient
height
- block's heightpublic java.util.List<BlockMetadata> listBlockMetadatas(BlockHash blockHash, int size)
QueryClient
size
backward starting from block for provided hash.listBlockMetadatas
in interface QueryClient
blockHash
- block hashsize
- block list size whose upper bound is 1000public java.util.List<BlockMetadata> listBlockMetadatas(long height, int size)
QueryClient
size
backward starting from block for provided height.listBlockMetadatas
in interface QueryClient
height
- block's heightsize
- block list size whose upper bound is 1000public Block getBlock(BlockHash blockHash)
QueryClient
getBlock
in interface QueryClient
blockHash
- block hashpublic Block getBlock(long height)
QueryClient
getBlock
in interface QueryClient
height
- block's heightpublic Subscription<BlockMetadata> subscribeNewBlockMetadata(StreamObserver<BlockMetadata> observer)
QueryClient
subscribeNewBlockMetadata
in interface QueryClient
observer
- a stream observer which is invoked on new block metadatapublic Subscription<Block> subscribeNewBlock(StreamObserver<Block> observer)
QueryClient
subscribeNewBlock
in interface QueryClient
observer
- a stream observer which is invoked on new blockpublic Transaction getTransaction(TxHash txHash)
QueryClient
getTransaction
in interface QueryClient
txHash
- transaction's hashpublic ContractTxReceipt getReceipt(ContractTxHash contractTxHash)
QueryClient
getReceipt
in interface QueryClient
contractTxHash
- contract transaction hashpublic ContractInterface getContractInterface(ContractAddress contractAddress)
QueryClient
getContractInterface
in interface QueryClient
contractAddress
- contract addresspublic ContractResult query(ContractInvocation contractInvocation)
QueryClient
query
in interface QueryClient
contractInvocation
- a contract invocationpublic java.util.List<Event> listEvents(EventFilter filter)
QueryClient
listEvents
in interface QueryClient
filter
- an event filterpublic Subscription<Event> subscribeEvent(EventFilter filter, StreamObserver<Event> observer)
QueryClient
subscribeEvent
in interface QueryClient
filter
- an event filterobserver
- a stream observer which is invoked on eventpublic ChainIdHash getCachedChainIdHash()
Wallet
getCachedChainIdHash
in interface Wallet
public void cacheChainIdHash()
Wallet
cacheChainIdHash
in interface Wallet
public void cacheChainIdHash(ChainIdHash chainIdHash)
Wallet
chainIdHash
.cacheChainIdHash
in interface Wallet
chainIdHash
- a chain id hashpublic Account loadAccount(Authentication authentication)
Wallet
authentication
.loadAccount
in interface Wallet
authentication
- an authenticationpublic Transaction sign(RawTransaction rawTransaction)
Wallet
public boolean verify(Transaction transaction)
Wallet
public TxHash createName(java.lang.String name)
Wallet
createName
in interface Wallet
name
- an new namepublic TxHash updateName(java.lang.String name, AccountAddress newOwner)
Wallet
updateName
in interface Wallet
name
- an already binded namenewOwner
- an new owner of namepublic TxHash stake(Aer amount)
Wallet
public TxHash unstake(Aer amount)
Wallet
public TxHash voteBp(java.util.List<java.lang.String> candidates)
Wallet
candidates
.public TxHash vote(java.lang.String voteId, java.util.List<java.lang.String> candidates)
Wallet
candidates
with voteId
.public TxHash send(java.lang.String recipient, Aer amount)
Wallet
public TxHash send(java.lang.String recipient, Aer amount, Fee fee)
Wallet
fee
.public TxHash send(java.lang.String recipient, Aer amount, BytesValue payload)
Wallet
payload
.public TxHash send(java.lang.String recipient, Aer amount, Fee fee, BytesValue payload)
Wallet
fee
and payload
.public TxHash send(AccountAddress recipient, Aer amount)
Wallet
fee
.public TxHash send(AccountAddress recipient, Aer amount, Fee fee)
Wallet
fee
.public TxHash send(AccountAddress recipient, Aer amount, BytesValue payload)
Wallet
fee
and payload
.public TxHash send(AccountAddress recipient, Aer amount, Fee fee, BytesValue payload)
Wallet
fee
and payload
.public TxHash commit(RawTransaction rawTransaction)
Wallet
public TxHash commit(Transaction signedTransaction)
Wallet
public ContractTxHash deploy(ContractDefinition contractDefinition)
Wallet
public ContractTxHash deploy(ContractDefinition contractDefinition, Fee fee)
Wallet
public ContractTxHash execute(ContractInvocation contractInvocation)
Wallet
public ContractTxHash execute(ContractInvocation contractInvocation, Fee fee)
Wallet
public void close()
Wallet
close
in interface KeyManageable
close
in interface QueryClient
close
in interface Wallet
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable