Class AccountModule

AccountModule is class that provides methods to obtain information from DCore node's Account module API.

Hierarchy

Index

Constructors

constructor

Methods

createAccountWithBrainkey

  • createAccountWithBrainkey(brainkey: string, accountName: string, registrar: string, registrarPrivateKey: string): Promise<Operation>
  • Create account in DCore blockchain network with keys derived from provided brain key. https://docs.decent.ch/developer/classgraphene_1_1wallet_1_1detail_1_1wallet__api__impl.html#a758d05a5f090adbc249258881775d222

    NOTE: This method create account with owner, active and memo key set to same value. Recommended to use Utils.derivePrivateKey to derive keys from brainkey and then register account with option to set these keys to different values.

    Parameters

    • brainkey: string

      Brain key for keys derivation. Use brain key from Utils.suggestBrainKey.

    • accountName: string

      Name for new account. String with alphanumerical symbols and dash. Example: 'new-account2'

    • registrar: string

      Registrar account id, who pay for account registration in format '1.2.X'. Example: '1.2.345'

    • registrarPrivateKey: string

      Registrar private key in WIF(hex)(Wallet Import Format) format.

    Returns Promise<Operation>

    Value confirming successful transaction broadcasting.

exportWallet

  • exportWallet(accountId: string, password: string, privateKeys: string[], additionalElGamalPrivateKeys?: string[]): Promise<WalletExport>

getAccountBalanceForTransaction

  • getAccountBalanceForTransaction(accountId: string, historyId: string): Promise<HistoryBalanceObject>

getAccountById

  • getAccountById(id: string): Promise<Account>

getAccountByName

  • getAccountByName(name: string): Promise<Account>

getAccountCount

  • getAccountCount(): Promise<number>

getAccountHistory

  • List of all transaction operations in history of user. NOTE: Operations can be filtered using Chain.ChainOperationType https://docs.decent.ch/developer/group___history_a_p_i.html#ga2bfce814ce4adde1c30e63662f3fa18c

    Parameters

    • accountId: string

      Account id in format '1.2.X'. Example: '1.2.345'

    • Optional historyOptions: HistoryOptions

      Optional HistoryOptions object to configure fromId and resultLimit for paging. fromId: Id of HistoryRecord from what to start list from. Default: '1.7.0' resultLimit: Number of HistoryRecords in result. Default: 100(Max) NOTE: List is in DESC order. Therefore fromId of operation suppose to be last in received list.

    Returns Promise<HistoryRecord[]>

    List of HistoryRecord objects.

getBalance

  • getBalance(accountId: string, assetId?: string, convertAsset?: boolean): Promise<number>

getTransactionById

  • getTransactionById(transactionId: string): Promise<any>

getTransactionHistory

  • deprecated

    This method will be removed in future DCore update. Use getAccountHistory or searchAccountHistory instead

    Parameters

    • accountId: string

      Account id in format '1.2.X'. Example: "1.2.345"

    • Default value privateKeys: string[] = []

      Array of private keys in case private/public pair has been changed in blockchain account, using for example cli_wallet, to be able of decrypt older memo messages from transactions.

    • Default value order: SearchAccountHistoryOrder = SearchAccountHistoryOrder.timeDesc

      Order of TransactionRecords in result. Default is .timeDesc.

    • Default value startObjectId: string = "0.0.0"

      Id of TransactionRecord to start search from for paging purposes. Default 0.0.0

    • Default value resultLimit: number = 100

      Number of transaction history records in result. Use for paging. Default 100(max)

    Returns Promise<TransactionRecord[]>

    List of TransactionRecord.List of TransactionRecord.

isTransactionConfirmed

  • isTransactionConfirmed(accountId: string, transactionId: string): Promise<boolean>
  • Verifies if block in that transaction was processed to is irreversible. NOTE: Unverified blocks still can be reversed.

    NOTICE: Transaction object with id in form '1.7.X' can be fetched from AccountModule.getAccountHistory method.

    Parameters

    • accountId: string

      Account id in format '1.2.X'. Example: '1.2.30'

    • transactionId: string

      Transaction id in format '1.7.X'.

    Returns Promise<boolean>

    Returns 'true' if transaction is in irreversible block, 'false' otherwise.

listAccountBalances

  • listAccountBalances(id: string, convertAssets?: boolean): Promise<Asset[]>

listAccounts

registerAccount

  • registerAccount(name: string, ownerKey: string, activeKey: string, memoKey: string, registrar: string, registrarPrivateKey: string, broadcast?: boolean): Promise<Operation>
  • Parameters

    • name: string

      Name of newly created account.

    • ownerKey: string

      Public key to be used as owner key in WIF(hex)(Wallet Import Format) format.

    • activeKey: string

      Public key to be used as active key in WIF(hex)(Wallet Import Format) format.

    • memoKey: string

      Public key used to memo encryption in WIF(hex)(Wallet Import Format) format.

    • registrar: string

      Registrar account id who pay account creation transaction fee.

    • registrarPrivateKey: string

      Registrar private key, in WIF(hex)(Wallet Import Format) format, for account register transaction to be signed with.

    • Default value broadcast: boolean = true

      Transaction is broadcasted if set to true

    Returns Promise<Operation>

    Value confirming successful transaction broadcasting.

searchAccountBalanceHistory

  • searchAccountBalanceHistory(accountId: string, assetList?: string[], partnerId?: string, fromBlockNumber?: number, toBlockNumber?: number, offset?: number, limit?: number): Promise<HistoryBalanceObject[]>
  • Return list of account's transaction history with additional information about balance change and multiple options for filtering.

    Parameters

    • accountId: string

      Account id to list history for in format '1.2.X'. Example: '1.2.345'/

    • Default value assetList: string[] = []

      List of asset ids to filter transaction with these assets. Format ['1.3.X'], example: ['1.3.0', '1.3.34']. Default is [] - no asset filtering.

    • Default value partnerId: string = null

      Account id of partner to/from whom transaction was done. In format '1.2.X, example: '1.2.345'. Default is 'null'.

    • Default value fromBlockNumber: number = null

      Block number to start from. Default is 'null' - filter from start.

    • Default value toBlockNumber: number = null

      Block number to end at. Default is 'null' - filter to end.

    • Default value offset: number = 0

      Offstet in transaction list for paging purpose. Default is 0 - start at begining.

    • Default value limit: number = 100

      Number of records to be listed. Default is 100.

    Returns Promise<HistoryBalanceObject[]>

searchAccountHistory

  • Parameters

    • accountId: string

      Account id in format '1.2.X'. Example: "1.2.345"

    • Default value privateKeys: string[] = []

      Array of private keys in case private/public pair has been changed in blockchain account, using for example cli_wallet, to be able of decrypt older memo messages from transactions.

    • Default value order: SearchAccountHistoryOrder = SearchAccountHistoryOrder.timeDesc

      Order of TransactionRecords in result. Default is .timeDesc.

    • Default value startObjectId: string = "0.0.0"

      Id of TransactionRecord to start search from for paging purposes. Default 0.0.0

    • Default value resultLimit: number = 100

      Number of transaction history records in result. Use for paging. Default 100(max)

    • Default value convertAssets: boolean = false

      Optional parameter to convert amounts and fees of TransactionRecords from blockchain asset amount format to right precision format of asset. Example: 100000000 => 1 DCT. Default: false.

    Returns Promise<TransactionRecord[]>

    List of TransactionRecord.

searchAccounts

  • searchAccounts(searchTerm?: string, order?: AccountOrder, id?: string, limit?: number): Promise<Account>

searchMinerVoting

  • searchMinerVoting(accountName: string, keyword: string, myVotes?: boolean, sort?: MinerOrder, fromMinerId?: string, limit?: number): Promise<MinerInfo[]>

transfer

  • transfer(amount: number, assetId: string, fromAccount: string, toAccount: string, memo: string, privateKey: string, broadcast?: boolean): Promise<Operation>
  • Parameters

    • amount: number
    • assetId: string
    • fromAccount: string
    • toAccount: string
    • memo: string
    • privateKey: string
    • Default value broadcast: boolean = true

    Returns Promise<Operation>

transfer2

  • transfer2(amount: number, assetId: string, fromAccount: string, toAccount: string, memo: string, privateKey: string, broadcast?: boolean): Promise<Operation>
  • Parameters

    • amount: number
    • assetId: string
    • fromAccount: string
    • toAccount: string
    • memo: string
    • privateKey: string
    • Default value broadcast: boolean = true

    Returns Promise<Operation>

updateAccount

Powered by DECENT