Skip to main content

Account API

Reference guide for the Escrow Account API.

EndpointDescription
/api/account/requestRequest a new deposit account.
/api/account/registerRegister a deposit of funds.
/api/account/commitRegister funds for a contract.

Notice any mistakes, or something missing? Please let us know!
You can submit an issue here: Submit Issue


Request a Deposit Account

Request a new deposit account from the escrow server.

Request Format

method   : 'POST'
endpoint : '/api/account/request'
headers : { 'content-type' : 'application/json' }
body : JSON.stringify(account_request)

Request Body

interface AccountRequest {
deposit_pk : string // Public key belonging the user making the deposit.
locktime ?: number // Desired locktime (in seconds) for account recovery.
network : ChainNetwork // The block-chain network to use.
return_addr : string // The return address to use when closing the deposit.
}

Response Interface

interface AccountDataResponse {
data : {
account : AccountData
}
}

Example Request

// Get an account request from the signing device.
const req = signer.account.request(locktime, return_addr)
// Submit the request to the server.
const res = await client.account.request(req)
// Check the response is valid.
if (!res.ok) throw new Error(res.error)
// Unpack the response data.
const { account } = res.data

See the full code example here.

Example Response

Related Interfaces:


Register a Deposit

Register a utxo that has been sent to a deposit address.

Request Format

method   : 'POST'
endpoint : '/api/account/register'
headers : { 'content-type' : 'application/json' }
body : JSON.stringify(register_request)

Request Body

interface RegisterRequest {
agent_tkn : string // The agent token provided by the server.
deposit_pk : string // Public key belonging the funder's signing device.
locktime : number // Desired locktime (in seconds) to hold funds in escrow.
network : ChainNetwork // The block-chain network to use.
return_addr : string // The return address to use when closing the deposit.
return_psig : string // Pre-authorization for returning the deposit.
return_rate : number // The transaction fee amount to use when closing the deposit.
utxo : TxOutput // The unspent output to register as a deposit.
}

Response Interface

interface DepositDataResponse {
data : {
deposit : DepositData
}
}

Example Request

// Create a registration request.
const req = signer.account.register(new_account, return_rate, utxo)
// Deliver our registration request to the server.
const res = await client.account.register(req)
// Check the response is valid.
if (!res.ok) throw new Error(res.error)
// Unpack our data object.
const { deposit } = res.data

See the full code example here.

Example Response

Related Interfaces:


Commit a Deposit

Register and commit a utxo to a published contract.

Request Format

method   : 'POST'
endpoint : '/api/account/commit'
headers : { 'content-type' : 'application/json' }
body : JSON.stringify(commit_request)

Request Body

interface CommitRequest extends RegisterRequest {
...RegisterRequest
covenant : CovenantData // Covenant that locks the UTXO.
}

Response Interface

interface FundDataResponse {
data : {
contract : ContractData
deposit : DepositData
}
}

Example Request

// Generate a commit request from the depositor.
const req = signer.account.commit(new_account, new_contract, return_rate, utxo)
// Deliver our commit request to the server.
const res = await client.account.commit(req)
// Check the response is valid.
if (!res.ok) throw new Error(res.error)
// Unpack our data object.
const { contract, deposit } = res.data

See the full code example here.

Example Response

Related Interfaces: