AccountApi
public protocol AccountApi : BaseApi
Undocumented
-
exist(byName:)
Default implementationCheck if the account exist.
Default Implementation
Declaration
Swift
func exist(byName name: String) -> Single<Bool>
Parameters
name
Account name.
Return Value
true
if account exist. -
exist(byId:)
Default implementationCheck if the account exist.
Default Implementation
Declaration
Swift
func exist(byId id: AccountObjectIdConvertible) -> Single<Bool>
Parameters
id
Account id as
AccountObjectId
orString
format.Return Value
true
if account exist. -
exist(byReference:)
Default implementationCheck if the account exist.
Default Implementation
Declaration
Swift
func exist(byReference ref: Account.Reference) -> Single<Bool>
Parameters
ref
Account id or name.
Return Value
true
if account exist. -
get(byName:)
Default implementationGet account by name.
Throws
DCoreException.Network.notFound
if account does not exist.Default Implementation
Declaration
Swift
func get(byName name: String) -> Single<Account>
Parameters
name
Account name.
Return Value
An
Account
if exist. -
get(byId:)
Default implementationGet account by id.
Throws
DCoreException.Network.notFound
if account does not exist.Default Implementation
Declaration
Swift
func get(byId id: AccountObjectIdConvertible) -> Single<Account>
Parameters
id
Account id as
AccountObjectId
orString
format.Return Value
An
Account
if exist. -
get(byReference:)
Default implementationGet account by reference (id or name) in
String
format.Throws
DCoreException.Network.notFound
if account does not exist.Default Implementation
Parameters
ref
Account id or name.
Return Value
An
Account
if exist. -
getAll(byIds:)
Default implementationGet accounts by ids.
Default Implementation
Declaration
Swift
func getAll(byIds ids: [AccountObjectIdConvertible]) -> Single<[Account]>
Parameters
ids
Account ids as
AccountObjectId
orString
format.Return Value
An
[Account]
array. -
getAll(byNames:)
Default implementationGet accounts by names.
Default Implementation
Declaration
Swift
func getAll(byNames names: [String]) -> Single<[Account]>
Parameters
names
Account names.
Return Value
An
[Account]
array. -
getFullAccounts(byReferences:subscribe:)
Default implementationGet all objects relevant to the specified accounts and subscribe to updates.
Default Implementation
Declaration
Swift
func getFullAccounts(byReferences refs: [Account.Reference], subscribe: Bool) -> Single<[String : FullAccount]>
Parameters
refs
Account references (id or name) in
String
format.subscribe
true
to subscribe to updates, defaultfalse
.Return Value
Map
[String: FullAccount]
of names or ids to account, or empty map if not present. -
findAllReferences(byKeys:)
Default implementationGet accounts ids by public key addresses.
Default Implementation
Declaration
Swift
func findAllReferences(byKeys keys: [Address]) -> Single<[[AccountObjectId]]>
Parameters
keys
Formatted public keys of the account, eg. DCT5j2bMj7XVWLxUW7AXeMiYPambYFZfCcMroXDvbCfX1VoswcZG4.
Return Value
All
[[AccountObjectId]]
account references by given keys. -
findAllReferences(byId:)
Default implementationGet all accounts that refer to the account id in their owner or active authorities.
Default Implementation
Declaration
Swift
func findAllReferences(byId id: AccountObjectIdConvertible) -> Single<[AccountObjectId]>
Parameters
id
Account id as
AccountObjectId
orString
format.Return Value
All
[[AccountObjectId]]
account references by given keys. -
findAllRelative(byLower:limit:)
Default implementationGet names and ids for registered accounts.
Default Implementation
Declaration
Swift
func findAllRelative(byLower bound: String, limit: Int) -> Single<[String : AccountObjectId]>
Parameters
bound
Lower bound of the first name to return.
limit
Number of items to get, max/default
1000
Return Value
Map
[String: AccountObjectId]
of account names to corresponding ids. -
findAll(by:order:id:limit:)
Default implementationGet accounts that match lookup expression.
Default Implementation
Declaration
Swift
func findAll(by expression: String, order: SearchOrder.Accounts, id: AccountObjectId, limit: Int) -> Single<[Account]>
Parameters
expression
Will try to partially match account name or id.
order
Sort data by field, default
SearchOrder.Accounts.nameDesc
.id
Object id to start searching from, default
0.0.0
.limit
Number of items to get, max/default
1000
.Return Value
Array
[Account]
of accounts. -
countAll()
Default implementationGet the total number of registered accounts.
Default Implementation
Declaration
Swift
func countAll() -> Single<UInt64>
Return Value
Number of registered accounts.
-
createCredentials(byName:wif:)
Default implementationCreate account credentails by account name.
Throws
DCoreException.Network.notFound
if account does not exist.Default Implementation
Declaration
Swift
func createCredentials(byName name: String, wif: String) -> Single<Credentials>
Parameters
name
Account name.
wif
Private key in wif base58 format, eg. 5Jd7zdvxXYNdUfnEXt5XokrE3zwJSs734yQ36a1YaqioRTGGLtn.
Return Value
Account
Credentials
. -
createCredentials(byName:encryptedWif:passphrase:)
Default implementationCreate account credentails by account name.
Throws
DCoreException.Network.notFound
if account does not exist.Default Implementation
Declaration
Swift
func createCredentials(byName name: String, encryptedWif wif: String, passphrase: String) -> Single<Credentials>
Parameters
name
Account name.
wif
Private key in AES encrypted format.
passphrase
Keypass to unlock encrypted private key.
Return Value
Account
Credentials
. -
create(_:registrar:fee:)
Default implementationCreate account.
Throws
DCoreException.Network.alreadyFound
if account with given name already exist.Default Implementation
Declaration
Swift
func create(_ account: SubmitAccount, registrar: Credentials, fee: AssetAmount) -> Single<TransactionConfirmation>
Parameters
account
SubmitAccount object with name and public key (Address).
registrar
Credentials of account which will pay operation fee.
fee
AssetAmount
fee for the operation, if leftAssetAmount.unset
the fee will be computed in DCT asset, defaultAssetAmount.unset
.Return Value
TransactionConfirmation
that account was created. -
update(credentials:options:active:owner:fee:)
Default implementationUpdate account.
Default Implementation
Declaration
Swift
func update(credentials: Credentials, options: Options?, active: Authority?, owner: Authority?, fee: AssetAmount) -> Single<TransactionConfirmation>
Parameters
credentials
Credentials of account to update.
options
new account options.
active
new active authority.
owner
new owner authority.
fee
AssetAmount
fee for the operation, if leftAssetAmount.unset
the fee will be computed in DCT asset, defaultAssetAmount.unset
.Return Value
TransactionConfirmation
that account was updated. -
createTransfer(from:to:amount:message:encrypted:fee:)
Default implementationCreate transfer operation between two accounts using credentails.
Default Implementation
Declaration
Swift
func createTransfer(from credentials: Credentials, to: Account.Reference, amount: AssetAmount, message: String?, encrypted: Bool, fee: AssetAmount) -> Single<TransferOperation>
Parameters
credentails
Sender account credentials.
to
Receiver account reference.
amount
AssetAmount
to send with asset type.message
Message (Optional).
encrypted
If message present, encrypted is visible only for sender and receiver, unencrypted is visible publicly, default
true
.fee
AssetAmount
fee for the operation, if leftAssetAmount.unset
the fee will be computed in DCT asset, defaultAssetAmount.unset
.Return Value
-
createTransfer(from:to:amount:fee:)
Default implementationCreate transfer operation between two accounts using credentails.
Default Implementation
Declaration
Swift
func createTransfer(from credentials: Credentials, to: Account.Reference, amount: AssetAmount, fee: AssetAmount) -> Single<TransferOperation>
Parameters
credentails
Sender account credentials.
to
Receiver account reference.
amount
AssetAmount
to send with asset type.fee
AssetAmount
fee for the operation, if leftAssetAmount.unset
the fee will be computed in DCT asset, defaultAssetAmount.unset
.Return Value
-
transfer(from:to:amount:message:encrypted:fee:)
Default implementationMake a transfer between two accounts
Default Implementation
Declaration
Swift
func transfer(from credentials: Credentials, to: Account.Reference, amount: AssetAmount, message: String?, encrypted: Bool, fee: AssetAmount) -> Single<TransactionConfirmation>
Parameters
credentails
Sender account credentials.
to
Receiver account reference.
amount
AssetAmount
to send with asset type.message
Message (Optional).
encrypted
If message present, encrypted is visible only for sender and receiver, unencrypted is visible publicly, default
true
.fee
AssetAmount
fee for the operation, if leftAssetAmount.unset
the fee will be computed in DCT asset, defaultAssetAmount.unset
.Return Value
A transaction confirmation.
-
transfer(from:to:amount:fee:)
Default implementationMake a transfer between two accounts
Default Implementation
Declaration
Swift
func transfer(from credentials: Credentials, to: Account.Reference, amount: AssetAmount, fee: AssetAmount) -> Single<TransactionConfirmation>
Parameters
credentails
Sender account credentials.
to
Receiver account reference.
amount
AssetAmount
to send with asset type.fee
AssetAmount
fee for the operation, if leftAssetAmount.unset
the fee will be computed in DCT asset, defaultAssetAmount.unset
.Return Value
A transaction confirmation.