Class: CypherPokerAccount

CypherPokerAccount(cypherpokerRef, initDataopt)

Information and functionality associated with a single managed account. The account is independently managed by either a TTP service or a smart contract and represents a deposit by the player that can be used to provide a balance in games.

Constructor

new CypherPokerAccount(cypherpokerRef, initDataopt)

Creates a new player account instance.
Parameters:
Name Type Attributes Default Description
cypherpokerRef CypherPoker A reference to a CypherPoker instance through which managed account requests can be made.
initData Object <optional>
null Data with which to initialize the new instance.
Source:

Members

address

Properties:
Name Type Description
address String The managed cryptocurrency deposit address associated with the account. Typically the address is also the unique account identifier (CypherPokerAccount#id), but may differ.
Source:

balance

Properties:
Name Type Default Description
balance BigInteger "0" The current total account balance. Note that this is different than the CypherPokerPlayer#balance property which reflects the player balance for a single game (e.g. buy-in).
Source:

cashoutPending

Properties:
Name Type Default Description
cashoutPending Boolean false True if a cashout operation is currently pending (incomplete), false otherwise.
Source:

(readonly) cypherpoker

Properties:
Name Type Description
cypherpoker CypherPoker A reference to the active CypherPoker instance through which API functions can be invoked.
Source:

domains

Properties:
Name Type Description
domains Array Each element in this indexed array is a domain, URL, API, or other service identifier with which this account is associated. Using this account with other domains / services will most likely result in an "account not found" error.
Source:

fees

Properties:
Name Type Description
fees Object Any fees (e.g. miner) associated with the account, usually--but not always--returned with the most recent the API call. Some fees may be mandatory while others are simply suggested/default.
Source:

network

Properties:
Name Type Description
network String The network sub-type, if applicable. For example, if CypherPokerAccount#type is "bitcoin", the network may be "main" or "test3".
Source:

password

Properties:
Name Type Default Description
password String null The password associated with the account.
Source:

type

Properties:
Name Type Description
type String The type of cryptocurrency associated with the CypherPokerAccount#address. Valid types include: "bitcoin"
Source:

Methods

(async) callAccountAPI(action, paramsopt, APIFuncopt) → {Promise}

Asynchronously calls the account API and returns the JSON-RPC 2.0 result / error of the call.
Parameters:
Name Type Attributes Default Description
action String The account action to apply to the APIFunc call. This value is automatically appended to the params object as an action property and will override any existing action property.
params Object <optional>
null The parameters to include with the remote function call. If null, an empty params object is created.
APIFunc String <optional>
"CP_Account" The remote API function to invoke.
Source:
Returns:
The promise resolves with the parsed JSON-RPC 2.0 result or error (native object) of the call. Currently there is no rejection state.
Type
Promise

(async) cashout(amount, toAddress, feesopt) → {Promise}

Partially or fully cashes out the account, sending the funds to a specified address.
Parameters:
Name Type Attributes Default Description
amount String | Number | BigInteger The full amount to send to toAddress, including miner fees. This value is in the smallest denominition of the associated cryptocurrency (e.g. satoshis if type="bitcoin").
toAddress String The target or receiving address. This address must be of the same cryptocurrency type and on the same network as this account.
fees String | Number | BigInteger <optional>
null The miner fee to include in this transaction in the smallest denomination of the associated cryptocurrency. If null, the default miner fee is used. The amount that will be received by toAddress will be the sending amount minus this value.
Source:
Returns:
The promise resolves with a an object containing information about the transaction or rejects with a standard Error object.
Type
Promise

(async) create() → {Promise}

Creates a new account by calling the CP_Account/new RPC service using the properties of this instance.
Source:
Returns:
The promise resolves with a true value if the account was succcessfully created, false otherwise.
Type
Promise

toObject(includePasswordopt) → {Object}

Returns a condensed data object with copies of most of the properties of this instance. Use the returned data from this function rathen than using JSON.stringify on the instance as this may cause a circular reference error.
Parameters:
Name Type Attributes Default Description
includePassword Boolean <optional>
false If true, the account password is included in the returned data.
Source:
Returns:
A condensed data object containing copies of the most properties of this instance.
Type
Object

(async) transfer(amount, toAccount) → {Promise}

Partially or fully transfers the account balance to another account.
Parameters:
Name Type Description
amount String | Number | BigInteger The full amount to transfer to toAccount. This value is in the smallest denominition of the associated cryptocurrency (e.g. satoshis if type="bitcoin").
toAccount String The target or receiving account. This account must be of the same cryptocurrency type and on the same network as this account.
Source:
Returns:
The promise resolves with a true value if the transfer was successfully completed. An Error object is included with a rejection.
Type
Promise

(async) update() → {Promise}

Updates this account's properties by calling the CP_Account/info RPC service.
Source:
Returns:
The promise resolves with a true value if the account was succcessfully updated. An Error object is included with a rejection.
Type
Promise