From e02d76b41d698902a075eba59e041bffe2b2c4db Mon Sep 17 00:00:00 2001 From: cmd Date: Fri, 23 Feb 2024 12:30:58 -0600 Subject: [PATCH] update --- demo/api/contract/read.ts | 2 +- demo/api/deposit/close.ts | 45 +++- demo/api/deposit/commit.ts | 72 ++++++ demo/api/deposit/digest.ts | 8 + demo/api/deposit/list.ts | 12 +- demo/api/deposit/lock.ts | 18 +- demo/api/deposit/read.ts | 8 + demo/api/deposit/register.ts | 37 ++- demo/api/deposit/request.ts | 10 +- demo/api/deposit/status.ts | 24 ++ demo/api/witness/read.ts | 14 +- docs/api/deposit.md | 252 ++++++++++++++++++- docs/api/witness.md | 23 ++ docs/examples/deposit_account.md | 15 ++ docs/examples/deposit_closed.md | 32 +++ docs/examples/deposit_commit.md | 281 +++++++++++++++++++++ docs/examples/deposit_data.md | 32 +++ docs/examples/deposit_digest.md | 18 ++ docs/examples/deposit_list.md | 366 ++++++++++++++++++++++++++++ docs/examples/deposit_locked.md | 53 ++++ docs/examples/deposit_registered.md | 0 docs/examples/deposit_status.md | 8 + src/client/api/client/oracle.ts | 32 ++- src/client/api/signer/request.ts | 1 - 24 files changed, 1321 insertions(+), 42 deletions(-) create mode 100644 demo/api/deposit/commit.ts create mode 100644 demo/api/deposit/status.ts create mode 100644 docs/examples/deposit_commit.md create mode 100644 docs/examples/deposit_data.md delete mode 100644 docs/examples/deposit_registered.md diff --git a/demo/api/contract/read.ts b/demo/api/contract/read.ts index ce187a5a..f9578848 100644 --- a/demo/api/contract/read.ts +++ b/demo/api/contract/read.ts @@ -1,6 +1,6 @@ /** * Contract API Demo for endpoint: - * /api/contract/:cid/read + * /api/contract/:cid * * You can run this demo using the shell command: * yarn load demo/api/contract/read diff --git a/demo/api/deposit/close.ts b/demo/api/deposit/close.ts index 22bb0d34..3491472f 100644 --- a/demo/api/deposit/close.ts +++ b/demo/api/deposit/close.ts @@ -1,10 +1,51 @@ +/** + * Deposit API Demo for endpoint: + * /api/deposit/:dpid/close + * + * You can run this demo using the shell command: + * yarn load demo/api/deposit/close + */ + import { print_banner } from '@scrow/test' +import { sleep } from '@scrow/demo/util.js' +import { config } from '@scrow/demo/00_demo_config.js' import { client } from '@scrow/demo/01_create_client.js' -import { depositor } from './request.js' -import { open_deposit } from './register.js' +import { signers } from '@scrow/demo/02_create_signer.js' +import { open_deposit } from '@scrow/demo/api/deposit/register.js' +// Unpack our polling config. +const [ ival, retries ] = config.poll // Define the dpid for the deposit we are using. const dpid = open_deposit.dpid + +// Fetch the current contract data. +let res_status = await client.deposit.status(dpid), + tries = 1 + +print_banner('awaiting confirmation of deposit') +console.log('depending on the network, this could take a while!\n') + +// While our response is ok, but the contract is not active (and we have tries): +while ( + res_status.ok && + res_status.data.deposit.status !== 'open' && + tries < retries +) { + // Print our current status to console. + console.log(`[${tries}/${retries}] re-checking deposit in ${ival} seconds...`) + // Sleep for interval seconds. + await sleep(ival * 1000) + // Fetch the latest contract data. + res_status = await client.deposit.status(dpid) + // Increment our tries counter + tries += 1 +} + +// If the response failed, throw error. +if (!res_status.ok) throw new Error(res_status.error) + +// Define our funder for the deposit. +const depositor = signers[0] // Define a txfee for the close transaction. const txfee = 1000 // Generate a lock request from the depositor. diff --git a/demo/api/deposit/commit.ts b/demo/api/deposit/commit.ts new file mode 100644 index 00000000..afa760a0 --- /dev/null +++ b/demo/api/deposit/commit.ts @@ -0,0 +1,72 @@ +/** + * Deposit API Demo for endpoint: + * /api/deposit/:dpid/commit + * + * You can run this demo using the shell command: + * yarn load demo/api/deposit/commit + */ + +import { print_banner } from '@scrow/test' +import { config } from '@scrow/demo/00_demo_config.js' +import { client } from '@scrow/demo/01_create_client.js' +import { signers } from '@scrow/demo/02_create_signer.js' +import { new_contract } from '@scrow/demo/05_create_contract.js' +import { new_account } from '@scrow/demo/06_request_account.js' + +import { + fund_mutiny_address, + fund_regtest_address, + sleep +} from '@scrow/demo/util.js' + +// Unpack account details. +const { address } = new_account +// Define how much sats we want to deposit +const amt_total = 20_000 +// Also compute a total amount in bitcoin. +const btc_total = amt_total / 100_000_000 + +/** ========== [ Print Deposit Info ] ========== **/ + +switch (config.network) { + case 'mutiny': + fund_mutiny_address(address, amt_total) + break + case 'regtest': + fund_regtest_address(address, amt_total) + break + default: + print_banner('make a deposit') + console.log('copy this address :', address) + console.log('send this amount :', `${amt_total} sats || ${btc_total} btc`) + console.log('get funds here :', config.faucet, '\n') +} + +await sleep(2000) + +/** ========== [ Poll Deposit Status ] ========== **/ + +// Define our polling interval and retries. +const [ ival, retries ] = config.poll +// Poll for utxos from the account address. +const utxos = await client.oracle.poll_address(address, ival, retries, true) + +print_banner('address utxos') +console.log('utxos:', utxos) + +// Get the output data from the utxo. +const utxo = utxos[0].txspend +// Define our funder for the deposit. +const depositor = signers[0] +// Generate a commit request from the depositor. +const req = depositor.account.commit(new_account, new_contract, utxo) +// Deliver our commit request to the server. +const res = await client.deposit.commit(req) +// Check the response is valid. +if (!res.ok) throw new Error(res.error) +// Unpack our data object. +const locked_deposit = res.data.deposit + +print_banner('open deposit') +console.dir(locked_deposit, { depth: null }) +console.log('\n') diff --git a/demo/api/deposit/digest.ts b/demo/api/deposit/digest.ts index 49b1c53d..75df28bb 100644 --- a/demo/api/deposit/digest.ts +++ b/demo/api/deposit/digest.ts @@ -1,3 +1,11 @@ +/** + * Deposit API Demo for endpoint: + * /api/deposit/:dpid/digest + * + * You can run this demo using the shell command: + * yarn load demo/api/deposit/digest + */ + import { print_banner } from '@scrow/test' import { client } from '@scrow/demo/01_create_client.js' import { locked_deposit } from '@scrow/demo/07_deposit_funds.js' diff --git a/demo/api/deposit/list.ts b/demo/api/deposit/list.ts index b999a56d..70482b9b 100644 --- a/demo/api/deposit/list.ts +++ b/demo/api/deposit/list.ts @@ -1,7 +1,17 @@ +/** + * Deposit API Demo for endpoint: + * /api/deposit/list/:pubkey + * + * You can run this demo using the shell command: + * yarn load demo/api/deposit/list + */ + import { print_banner } from '@scrow/test' import { client } from '@scrow/demo/01_create_client.js' -import { depositor } from '@scrow/demo/07_deposit_funds.js' +import { signers } from '@scrow/demo/02_create_signer.js' +// Define our funder for the deposit. +const depositor = signers[0] // Generate a request token. const req = depositor.request.deposit_list() // Deliver the request and token. diff --git a/demo/api/deposit/lock.ts b/demo/api/deposit/lock.ts index e31b6810..a0b0d0e6 100644 --- a/demo/api/deposit/lock.ts +++ b/demo/api/deposit/lock.ts @@ -1,15 +1,25 @@ +/** + * Deposit API Demo for endpoint: + * /api/deposit/:dpid/lock + * + * You can run this demo using the shell command: + * yarn load demo/api/deposit/lock + */ + import { print_banner } from '@scrow/test' import { client } from '@scrow/demo/01_create_client.js' +import { signers } from '@scrow/demo/02_create_signer.js' import { new_contract } from '@scrow/demo/05_create_contract.js' -import { depositor } from './request.js' -import { open_deposit } from './register.js' +import { open_deposit } from '@scrow/demo/api/deposit/register.js' +// Define our funder for the deposit. +const depositor = signers[0] // Define the dpid for the deposit we are using. const dpid = open_deposit.dpid // Generate a lock request from the depositor. -const lock_req = depositor.account.lock(new_contract, open_deposit) +const req = depositor.account.lock(new_contract, open_deposit) // Deliver the request and token. -const res = await client.deposit.lock(dpid, lock_req) +const res = await client.deposit.lock(dpid, req) // Check the response is valid. if (!res.ok) throw new Error(res.error) // Unpack our response data. diff --git a/demo/api/deposit/read.ts b/demo/api/deposit/read.ts index 35c47389..efe78b92 100644 --- a/demo/api/deposit/read.ts +++ b/demo/api/deposit/read.ts @@ -1,3 +1,11 @@ +/** + * Deposit API Demo for endpoint: + * /api/deposit/:dpid + * + * You can run this demo using the shell command: + * yarn load demo/api/deposit/read + */ + import { print_banner } from '@scrow/test' import { client } from '@scrow/demo/01_create_client.js' import { locked_deposit } from '@scrow/demo/07_deposit_funds.js' diff --git a/demo/api/deposit/register.ts b/demo/api/deposit/register.ts index ab2762fe..e9e95483 100644 --- a/demo/api/deposit/register.ts +++ b/demo/api/deposit/register.ts @@ -1,3 +1,11 @@ +/** + * Deposit API Demo for endpoint: + * /api/deposit/:dpid/register + * + * You can run this demo using the shell command: + * yarn load demo/api/deposit/register + */ + import { print_banner } from '@scrow/test' import { config } from '@scrow/demo/00_demo_config.js' import { client } from '@scrow/demo/01_create_client.js' @@ -10,7 +18,7 @@ import { } from '@scrow/demo/util.js' // Unpack account details. -const { address, deposit_pk, sequence, spend_xpub }= new_account +const { address, deposit_pk, sequence, spend_xpub } = new_account // Define how much sats we want to deposit const amt_total = 20_000 // Also compute a total amount in bitcoin. @@ -36,35 +44,20 @@ await sleep(2000) /** ========== [ Poll Deposit Status ] ========== **/ +// Define our polling interval and retries. const [ ival, retries ] = config.poll - -let tries = 1, - utxos = await client.oracle.get_address_utxos(address) - -// While there are no utxos (and we still have tries): -while (utxos.length === 0 && tries < retries) { - // Print current status to console. - console.log(`[${tries}/${retries}] checking address in ${ival} seconds...`) - // Sleep for interval number of secords. - await sleep(ival * 1000) - // Check again for utxos at address. - utxos = await client.oracle.get_address_utxos(address) - // Increment our tries counter - tries += 1 -} - -// If we still have no utxos, throw error. -if (utxos.length === 0) throw new Error('utxo not found') +// Poll for utxos from the account address. +const utxos = await client.oracle.poll_address(address, ival, retries, true) print_banner('address utxos') console.log('utxos:', utxos) // Get the output data from the utxo. -const utxo = utxos[0].txspend +const utxo = utxos[0].txspend // Create a registration request. -const reg_req = { deposit_pk, sequence, spend_xpub, utxo } +const req = { deposit_pk, sequence, spend_xpub, utxo } // Deliver our registration request to the server. -const res = await client.deposit.register(reg_req) +const res = await client.deposit.register(req) // Check the response is valid. if (!res.ok) throw new Error(res.error) // Unpack our data object. diff --git a/demo/api/deposit/request.ts b/demo/api/deposit/request.ts index 4b74fcc2..094fcf84 100644 --- a/demo/api/deposit/request.ts +++ b/demo/api/deposit/request.ts @@ -1,9 +1,17 @@ +/** + * Deposit API Demo for endpoint: + * /api/deposit/request + * + * You can run this demo using the shell command: + * yarn load demo/api/deposit/request + */ + import { print_banner } from '@scrow/test' import { client } from '@scrow/demo/01_create_client.js' import { signers } from '@scrow/demo/02_create_signer.js' // Define our funder for the deposit. -export const depositor = signers[0] +const depositor = signers[0] // Define our deposit locktime. const locktime = 60 * 60 // 1 hour locktime // Get an account request from the funder device. diff --git a/demo/api/deposit/status.ts b/demo/api/deposit/status.ts new file mode 100644 index 00000000..9f77b6bd --- /dev/null +++ b/demo/api/deposit/status.ts @@ -0,0 +1,24 @@ +/** + * Deposit API Demo for endpoint: + * /api/deposit/:dpid/status + * + * You can run this demo using the shell command: + * yarn load demo/api/deposit/status + */ + +import { print_banner } from '@scrow/test' +import { client } from '@scrow/demo/01_create_client.js' +import { locked_deposit } from '@scrow/demo/07_deposit_funds.js' + +// Define the deposit id we will use. +const dpid = locked_deposit.dpid +// Request to read a deposit via dpid. +const res = await client.deposit.status(dpid) +// Check the response is valid. +if (!res.ok) throw new Error(res.error) +// Unpack the data response +const deposit = res.data.deposit + +print_banner('deposit status') +console.dir(deposit, { depth : null }) +console.log('\n') diff --git a/demo/api/witness/read.ts b/demo/api/witness/read.ts index db7c5351..3a9c3749 100644 --- a/demo/api/witness/read.ts +++ b/demo/api/witness/read.ts @@ -1,3 +1,11 @@ +/** + * Witness API Demo for endpoint: + * /api/witness/:wid + * + * You can run this demo using the shell command: + * yarn load demo/api/witness/read + */ + import { print_banner } from '@scrow/test' import { client } from '@scrow/demo/01_create_client.js' import { witness } from '@scrow/demo/09_settle_contract.js' @@ -9,8 +17,8 @@ const res = await client.witness.read(wid) // Check the response is valid. if (!res.ok) throw new Error(res.error) // Unpack the data object. -const fetched_witness = res.data.witness +const statement = res.data.witness -print_banner('witness') -console.dir(fetched_witness, { depth : null }) +print_banner('witness statement') +console.dir(statement, { depth : null }) console.log('\n') diff --git a/docs/api/deposit.md b/docs/api/deposit.md index c5d87c21..fe9a6b0b 100644 --- a/docs/api/deposit.md +++ b/docs/api/deposit.md @@ -53,6 +53,33 @@ interface AccountDataResponse { } ``` +**Example Request** + +```ts +import { client } from '@scrow/demo/01_create_client.js' +import { signers } from '@scrow/demo/02_create_signer.js' + +// Define our funder for the deposit. +export const depositor = signers[0] +// Define our deposit locktime. +const locktime = 60 * 60 // 1 hour locktime +// Get an account request from the funder device. +const acct_req = depositor.account.create(locktime) +// Submit the account request to the server +const acct_res = await client.deposit.request(acct_req) +// Check the response is valid. +if (!acct_res.ok) throw new Error(acct_res.error) +// Unpack our data response. +const new_account = acct_res.data.account +``` + +> You can run this code in our live [replit instance](https://replit.com/@cscottdev/escrow-core#demo/api/deposit/request.ts) using the shell command: +> `yarn load demo/api/deposit/request` + +**Example Response** + +- [JSON Data](../examples/deposit_account.md) + **Related Interfaces:** - [DepositAccount](../data/deposit.md#depositaccount) @@ -76,11 +103,11 @@ body : JSON.stringify(register_request) ```ts interface RegisterRequest { - deposit_pk : string // Public key of the funder making the deposit. - return_psig : string // Pre-authorization for returning the deposit. - sequence : number // Locktime converted into a sequence value. - spend_xpub : string // The extended key used for returning funds. - utxo : TxOutput // The unspent output to register as a deposit. + deposit_pk : string // Public key of the funder making the deposit. + return_psig : string // Pre-authorization for returning the deposit. + sequence : number // Locktime converted into a sequence value. + spend_xpub : string // The extended key used for returning funds. + utxo : TxOutput // The unspent output to register as a deposit. } ``` @@ -94,6 +121,38 @@ interface DepositDataResponse { } ``` +**Example Request** + +```ts +import { config } from '@scrow/demo/00_demo_config.js' +import { client } from '@scrow/demo/01_create_client.js' +import { new_account } from '@scrow/demo/06_request_account.js' + +// Unpack account details. +const { address, deposit_pk, sequence, spend_xpub } = new_account +// Define our polling interval and retries. +const [ ival, retries ] = config.poll +// Poll for utxos from the account address. +const utxos = await client.oracle.poll_address(address, ival, retries, true) +// Get the output data from the utxo. +const utxo = utxos[0].txspend +// Create a registration request. +const req = { deposit_pk, sequence, spend_xpub, utxo } +// Deliver our registration request to the server. +const res = await client.deposit.register(reg_req) +// Check the response is valid. +if (!res.ok) throw new Error(res.error) +// Unpack our data object. +const open_deposit = res.data.deposit +``` + +> You can run this code in our live [replit instance](https://replit.com/@cscottdev/escrow-core#demo/api/deposit/register.ts) using the shell command: +> `yarn load demo/api/deposit/register` + +**Example Response** + +- [JSON Data](../examples/deposit_data.md) + **Related Interfaces:** - [DepositData](../data/deposit.md#depositdata) @@ -138,6 +197,37 @@ interface FundDataResponse { } ``` +**Example Request** + +```ts +import { config } from '@scrow/demo/00_demo_config.js' +import { client } from '@scrow/demo/01_create_client.js' +import { new_contract } from '@scrow/demo/05_create_contract.js' +import { new_account } from '@scrow/demo/06_request_account.js' + +// Define our polling interval and retries. +const [ ival, retries ] = config.poll +// Poll for utxos from the account address. +const utxos = await client.oracle.poll_address(address, ival, retries, true) +// Get the output data from the utxo. +const utxo = utxos[0].txspend +// Generate a commit request from the depositor. +const req = depositor.account.commit(new_account, new_contract, utxo) +// Deliver our commit request to the server. +const res = await client.deposit.commit(req) +// Check the response is valid. +if (!res.ok) throw new Error(res.error) +// Unpack our data object. +const locked_deposit = res.data.deposit +``` + +> You can run this code in our live [replit instance](https://replit.com/@cscottdev/escrow-core#demo/api/deposit/commit.ts) using the shell command: +> `yarn load demo/api/deposit/commit` + +**Example Response** + +- [JSON Data](../examples/deposit_commit.md) + **Related Interfaces:** - [ContractData](../data/contract.md#contractdata) @@ -169,6 +259,31 @@ interface DepositListResponse { } ``` +**Example Request** + +```ts +import { client } from '@scrow/demo/01_create_client.js' +import { signers } from '@scrow/demo/02_create_signer.js' + +// Define our funder for the deposit. +const depositor = signers[0] +// Generate a request token. +const req = depositor.request.deposit_list() +// Deliver the request and token. +const res = await client.deposit.list(depositor.pubkey, req) +// Check the response is valid. +if (!res.ok) throw new Error(res.error) +// Unpack our response data. +const deposits = res.data.deposits +``` + +> You can run this code in our live [replit instance](https://replit.com/@cscottdev/escrow-core#demo/api/deposit/list.ts) using the shell command: +> `yarn load demo/api/deposit/list` + +**Example Response** + +- [JSON Data](../examples/deposit_list.md) + **Related Interfaces:** - [DepositData](../data/deposit.md#depositdata) @@ -196,6 +311,29 @@ interface DepositDataResponse { } ``` +**Example Request** + +```ts +import { client } from '@scrow/demo/01_create_client.js' +import { locked_deposit } from '@scrow/demo/07_deposit_funds.js' + +// Define the deposit id we will use. +const dpid = locked_deposit.dpid +// Request to read a deposit via dpid. +const res = await client.deposit.read(dpid) +// Check the response is valid. +if (!res.ok) throw new Error(res.error) +// Unpack the data response +const deposit = res.data.deposit +``` + +> You can run this code in our live [replit instance](https://replit.com/@cscottdev/escrow-core#demo/api/deposit/read.ts) using the shell command: +> `yarn load demo/api/deposit/read` + +**Example Response** + +- [JSON Data](../examples/deposit_data.md) + **Related Interfaces:** - [DepositData](../data/deposit.md#depositdata) @@ -234,6 +372,35 @@ interface FundDataResponse { } ``` +**Example Request** + +```ts +import { client } from '@scrow/demo/01_create_client.js' +import { new_contract } from '@scrow/demo/05_create_contract.js' +import { signers } from '@scrow/demo/02_create_signer.js' +import { open_deposit } from '@scrow/demo/api/deposit/register.js' + +// Define our funder for the deposit. +const depositor = signers[0] +// Define the dpid for the deposit we are using. +const dpid = open_deposit.dpid +// Generate a lock request from the depositor. +const req = depositor.account.lock(new_contract, open_deposit) +// Deliver the request and token. +const res = await client.deposit.lock(dpid, req) +// Check the response is valid. +if (!res.ok) throw new Error(res.error) +// Unpack our response data. +const { contract, deposit } = res.data +``` + +> You can run this code in our live [replit instance](https://replit.com/@cscottdev/escrow-core#demo/api/deposit/lock.ts) using the shell command: +> `yarn load demo/api/deposit/lock` + +**Example Response** + +- [JSON Data](../examples/deposit_commit.md) + **Related Interfaces:** - [ContractData](../data/contract.md#contractdata) @@ -266,6 +433,29 @@ export interface DepositStatusResponse { } ``` +**Example Request** + +```ts +import { client } from '@scrow/demo/01_create_client.js' +import { locked_deposit } from '@scrow/demo/07_deposit_funds.js' + +// Define the deposit id we will use. +const dpid = locked_deposit.dpid +// Request to read a deposit via dpid. +const res = await client.deposit.status(dpid) +// Check the response is valid. +if (!res.ok) throw new Error(res.error) +// Unpack the data response +const deposit = res.data.deposit +``` + +> You can run this code in our live [replit instance](https://replit.com/@cscottdev/escrow-core#demo/api/deposit/status.ts) using the shell command: +> `yarn load demo/api/deposit/status` + +**Example Response** + +- [JSON Data](../examples/deposit_status.md) + **Related Interfaces:** - [DepositStatus](../data/deposit.md#depositstatus) @@ -293,6 +483,28 @@ interface DepositDigestResponse { } ``` +**Example Request** + +```ts +import { client } from '@scrow/demo/01_create_client.js' +import { locked_deposit } from '@scrow/demo/07_deposit_funds.js' + +// Define the deposit id we will use. +const dpid = locked_deposit.dpid +// Request to read a deposit via dpid. +const res = await client.deposit.digest(dpid) +// Check the response is valid. +if (!res.ok) throw new Error(res.error) +// Unpack the data response +const deposit = res.data.deposit +``` + +> You can run this code in our live [replit instance](https://replit.com/@cscottdev/escrow-core#demo/api/deposit/digest.ts) using the shell command: +> `yarn load demo/api/deposit/digest` + +**Example Response** + +- [JSON Data](../examples/deposit_digest.md) **Related Interfaces:** - [DepositDigest](../data/deposit.md#depositdigest) @@ -332,6 +544,36 @@ interface DepositDataResponse { } ``` +**Example Request** + +```ts +import { client } from '@scrow/demo/01_create_client.js' +import { signers } from '@scrow/demo/02_create_signer.js' +import { open_deposit } from '@scrow/demo/api/deposit/register.js' + +// Define our funder for the deposit. +const depositor = signers[0] +// Define the dpid for the deposit we are using. +const dpid = open_deposit.dpid +// Define a txfee for the close transaction. +const txfee = 1000 +// Generate a lock request from the depositor. +const close_req = depositor.account.close(open_deposit, txfee) +// Deliver the request and token. +const res = await client.deposit.close(dpid, close_req) +// Check the response is valid. +if (!res.ok) throw new Error(res.error) +// Unpack our response data. +const closed_deposit = res.data.deposit +``` + +> You can run this code in our live [replit instance](https://replit.com/@cscottdev/escrow-core#demo/api/deposit/close.ts) using the shell command: +> `yarn load demo/api/deposit/close` + +**Example Response** + +- [JSON Data](../examples/deposit_closed.md) + **Related Interfaces:** - [DepositData](../data/deposit.md#depositdata) diff --git a/docs/api/witness.md b/docs/api/witness.md index f501c6c5..5ece7391 100644 --- a/docs/api/witness.md +++ b/docs/api/witness.md @@ -33,6 +33,29 @@ interface WitnessDataResponse { } ``` +**Example Request** + +```ts +import { client } from '@scrow/demo/01_create_client.js' +import { witness } from '@scrow/demo/09_settle_contract.js' + +// Define the witness id we will use. +const wid = witness.wid +// Fetch a contract from the server by cid. +const res = await client.witness.read(wid) +// Check the response is valid. +if (!res.ok) throw new Error(res.error) +// Unpack the data object. +const statement = res.data.witness +``` + +> You can run this code in our live [replit instance](https://replit.com/@cscottdev/escrow-core#demo/api/witness/read.ts) using the shell command: +> `yarn load demo/api/witness/read` + +**Example Response** + +- [JSON Data](../examples/witness_data.md) + **Related Interfaces:** - [WitnessData](../data/witness.md#witnessdata) diff --git a/docs/examples/deposit_account.md b/docs/examples/deposit_account.md index e69de29b..a21682af 100644 --- a/docs/examples/deposit_account.md +++ b/docs/examples/deposit_account.md @@ -0,0 +1,15 @@ +# Deposit Account + +```json +{ + "acct_id": "e342b0436e7229f554999364512b13f42519986a8ab727650e66db0285f39991", + "acct_sig": "466a981f401456c00a0bd13caa5b996c9e2de7b5462d3061d0bd2e431c68659439718ab04ab93eca4d20faaf7974200efa0da6ce2a49caf6c99c794ad77a912c", + "address": "tb1pxu5agnanwymsfxwef0qqaavaxlzy5fx04ac56rkzxjj0lcjmak0qnqsgky", + "agent_id": "8e1d9085f568bf8add8107a74384858654014be54b175ed567cc2617168eec0b", + "agent_pk": "599e68d27a0570d0bb9af86236e221015983093fb797999e0d2f9d630be81594", + "created_at": 1708708161, + "deposit_pk": "9997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be", + "sequence": 4194311, + "spend_xpub": "tpubDFkbHQMTUHub1qXXB7Jf9eSqW4r9T4t9pTTuibdzD7K8D3SX22cfR9BWdtf6zHwSup4oHh4Z2mzsHKr4rZ9UgkkBDz6nJm3CnuN7gqjMuPr" +} +``` \ No newline at end of file diff --git a/docs/examples/deposit_closed.md b/docs/examples/deposit_closed.md index e69de29b..e87789dc 100644 --- a/docs/examples/deposit_closed.md +++ b/docs/examples/deposit_closed.md @@ -0,0 +1,32 @@ +# Closed Deposit + +```json +{ + "status": "spent", + "agent_id": "67be9db61cfd1eae092ff9d449e5d0175906da36b6338cb773652a970691e984", + "agent_pk": "067d8e3e294895925a4fa8dd006bd46c2d1e3593f491809d096bb65ad8d00e44", + "agent_pn": "a97d5ee2e6f0ef6670c091d96ccfd8d34487a6c9bac9a90db84e59896df01871e5f05f747b542bf4f7c32f1ca20bdcc7df90258f653afb2a174a4b9f827e4a75", + "covenant": null, + "created_at": 1708712443, + "dpid": "7cc6ceff7738b7c146be7700e6031b8b5fce269e3c6eb6b51bc99b500e9ce3c6", + "deposit_pk": "9997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be", + "return_psig": null, + "sequence": 4194311, + "spend_xpub": "tpubDDvmykn1mdU4yUtanf5ZQA4mi6N2WZwAESD6NrdPuEwVK42y3ACSk6rotuPTX2jqMjWsHEz3LpidnLoZekSeDP6RbXkBH9jzTo4ernuN5sU", + "updated_at": 1708712448, + "txid": "45a283a5a250fddb67c4d90d46c99f97a180d765b4a4480d17bdcf1f8fda7fe6", + "vout": 0, + "value": 20000, + "scriptkey": "5120fbb797a7250146fcaaf7df2a47aa4816b2eee3f949d58f169446e63fbcb0a2e0", + "confirmed": true, + "block_hash": "000002ab80fcf563f94f4c6a49fdc0abee73fa47f4dc6fa2167017f722c7b3a6", + "block_height": 862660, + "block_time": 1708712430, + "expires_at": 1708716014, + "spent": true, + "spent_at": 1708712448, + "spent_txid": "bfc010bfbe372eee46a6efdc620ecf480a80158d453ad7cb256c21b92c7943de", + "settled": false, + "settled_at": null +} +``` \ No newline at end of file diff --git a/docs/examples/deposit_commit.md b/docs/examples/deposit_commit.md new file mode 100644 index 00000000..81260e2b --- /dev/null +++ b/docs/examples/deposit_commit.md @@ -0,0 +1,281 @@ +# Comitted Deposit + +```json +{ + "contract": { + "activated": 1708710452, + "agent_fee": [ + 1000, + "tb1pd4r8ren69077tv5nqj2923hkeqwpjpkzumsagqkyzxegzztn9amshhsmvm" + ], + "balance": 20000, + "cid": "57ec337f28aee8765c544cd277e8574e1baa312abd329eb2fba2453dd7316442", + "deadline": 1708711013, + "est_txfee": 180, + "est_txsize": 180, + "expires_at": 1708724852, + "feerate": 1, + "outputs": [ + [ + "draw", + "0200000000038813000000000000160014b29a34811350c7550466e503673afeec8231f0438813000000000000160014fd901163f35bfd244fa4dfb99dfc7ec91bb02af2e8030000000000002251206d4671e67a2bfde5b29304945546f6c81c1906c2e6e1d402c411b28109732f7700000000" + ], + [ + "heads", + "02000000000210270000000000001600144582e8b37beb7e785b0e76433d63d11702bf0033e8030000000000002251206d4671e67a2bfde5b29304945546f6c81c1906c2e6e1d402c411b28109732f7700000000" + ], + [ + "return", + "02000000000210270000000000001600146a8f30e42f81d23c6e24f34c0ecad822b757e490e8030000000000002251206d4671e67a2bfde5b29304945546f6c81c1906c2e6e1d402c411b28109732f7700000000" + ], + [ + "tails", + "0200000000021027000000000000160014f5bab8567d46b31944413ab9b0971d6785492b13e8030000000000002251206d4671e67a2bfde5b29304945546f6c81c1906c2e6e1d402c411b28109732f7700000000" + ] + ], + "members": [ + { + "id": "c4990b0bd337a609866a93b5b6af0fb036f0fdb8e37d595da730b5f3542b794a", + "pub": "7f53ca0ca294f361db790d87aff6f6f5354d4bf8a2d81a0ab1734c28706db6c9", + "sig": "ee731ec52a23e6f0d73a35c2d11a89beb2ae5da1515588a872518fd41ad7a4e996223726275c9a0b129b04aba0dd2d8b871c80e5ac6485f59dac7cfbd34b9f20", + "xpub": "tpubDESZEQAEhAFBPX6euAm6g8G5orUFQqwcLuf7Y5uhHW7S2iY7dUsWSDzgTD4s7wesaJ1fu2gxqVr3E2uMuid3ApLRvkPSTuWYxrx3bBSnfLL" + }, + { + "id": "f96b8b702d90c8da5d917a271e57db7a5392b693b9b2072d7bf784ff7a602b88", + "pub": "5a35682c29aa82a9676ec1dddb9a79300be8cf8cd5a9cb4c0d917fcdac20ad59", + "sig": "2dc44441cf7bd753d4b9a6fbc6d5b74c36b05c594991175bc1d20128b7ad2b886f199eadfe5ce73a8539ca8df303938b4fb48667dc1cce1d09d7d7dfa85f895a", + "xpub": "tpubDDvdCgtaY8AP9YU5bbeYDiQowJM3MqrrEKVWX5V7ocYfpHCACKauXCDTH5YURLyHqb5DVrLWp1ENwQ5VKkBDTWq21HdBJdnbkP6SzhN9Ps6" + }, + { + "id": "d8628920e4bb5b495809d134b7828e1e25298093135b5ef8b72d768af0153e53", + "pub": "095b8459d6c64c982a40377490d9b614156e433a5384b527031cd96e9a44f2b7", + "sig": "ecbf57b849a8fd14218612ba54c48b42698d3e601697bd9da2ba73ded9c1808a864bcaedb0681e2646439776ebd7dd61ab7e90c900fcb708a2f6fa0d579d1068", + "xpub": "tpubDFQPUSZbXWHPQ1sDgtqu7vPbHss5N3oPuC9oMWXm8tGy3LaQydRrqnocfu1afoYMv32NMPf5anLMGgdKaAKVYsRiZS5yjXUfnUPT2mw4Aht" + } + ], + "moderator": "9094567ba7245794198952f68e5723ac5866ad2f67dd97223db40e14c15b092e", + "pending": 0, + "prop_id": "885a78f9b481da82385c39b83a127b97ebe17a3e4561170169718ab37a1ecf4a", + "pubkeys": [ + "9997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be", + "4edfcf9dfe6c0b5c83d1ab3f78d1b39a46ebac6798e08e19761f5ed89ec83c10", + "9094567ba7245794198952f68e5723ac5866ad2f67dd97223db40e14c15b092e" + ], + "published": 1708710413, + "signatures": [ + "9997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be940cc71bd81d73c63f499509fae4e341fb8cf56f30bb210066b46f0e6c0e06ef868f2e15d9668db1d298274c5f613e3402b72f959f48cc28d0ca8ad88cedacca", + "4edfcf9dfe6c0b5c83d1ab3f78d1b39a46ebac6798e08e19761f5ed89ec83c10c05a9d0a187d65547bdc1254cc4f9f46335dcb701d00e995d2b835a38365ad74a5196bffab0496650d1f3fe8827d17118bdfc951da37c250511cc8859c046ff0", + "9094567ba7245794198952f68e5723ac5866ad2f67dd97223db40e14c15b092efaa3eb03aea84224fb6af582764da192bdbdd299f0e9a81dd76bcd9588afbf9dc614a3999d75e8ed735d5dea99cbdde78414eef59a43f7b786fcdf3657e5df7b" + ], + "status": "active", + "subtotal": 11000, + "terms": { + "content": "", + "duration": 14400, + "moderator": "9094567ba7245794198952f68e5723ac5866ad2f67dd97223db40e14c15b092e", + "network": "mutiny", + "paths": [ + [ + "return", + 10000, + "tb1qd28npep0s8frcm3y7dxqajkcy2m40eysplyr9v" + ], + [ + "heads", + 10000, + "tb1qgkpw3vmmadl8skcwwepn6c73zupt7qpngxjd4l" + ], + [ + "draw", + 5000, + "tb1qlkgpzclnt07jgnaym7uemlr7eydmq2hjtc7ksa" + ], + [ + "tails", + 10000, + "tb1q7kats4nag6e3j3zp82ump9cav7z5j2cn78glgf" + ], + [ + "draw", + 5000, + "tb1qk2drfqgn2rr42prxu5pkwwh7ajprruzr8yhhlf" + ] + ], + "payments": [], + "programs": [ + [ + "endorse", + "close", + "*", + 2, + "7f53ca0ca294f361db790d87aff6f6f5354d4bf8a2d81a0ab1734c28706db6c9", + "5a35682c29aa82a9676ec1dddb9a79300be8cf8cd5a9cb4c0d917fcdac20ad59" + ], + [ + "endorse", + "dispute", + "heads|tails", + 1, + "7f53ca0ca294f361db790d87aff6f6f5354d4bf8a2d81a0ab1734c28706db6c9", + "5a35682c29aa82a9676ec1dddb9a79300be8cf8cd5a9cb4c0d917fcdac20ad59" + ], + [ + "endorse", + "resolve", + "*", + 1, + "095b8459d6c64c982a40377490d9b614156e433a5384b527031cd96e9a44f2b7" + ] + ], + "schedule": [ + [ + 7200, + "close", + "*" + ] + ], + "title": "Basic two-party contract with third-party arbitration.", + "value": 10000, + "version": 1 + }, + "total": 11180, + "txin_count": 1, + "updated_at": 1708710452, + "vm_state": { + "commits": [], + "error": null, + "head": "57ec337f28aee8765c544cd277e8574e1baa312abd329eb2fba2453dd7316442", + "output": null, + "paths": [ + [ + "draw", + 0 + ], + [ + "heads", + 0 + ], + [ + "return", + 0 + ], + [ + "tails", + 0 + ] + ], + "programs": [ + [ + "a788d518bd78bc2f1151bfda49cbb881100ea2b68d5ae8d242bf7f7142d7b87d", + "endorse", + "close", + "*", + 2, + "7f53ca0ca294f361db790d87aff6f6f5354d4bf8a2d81a0ab1734c28706db6c9", + "5a35682c29aa82a9676ec1dddb9a79300be8cf8cd5a9cb4c0d917fcdac20ad59" + ], + [ + "57f0cb2c943a23b3420d7ba2b29acc63a50fca20b95582ad42882799507aa0ee", + "endorse", + "dispute", + "heads|tails", + 1, + "7f53ca0ca294f361db790d87aff6f6f5354d4bf8a2d81a0ab1734c28706db6c9", + "5a35682c29aa82a9676ec1dddb9a79300be8cf8cd5a9cb4c0d917fcdac20ad59" + ], + [ + "c57e95964608214e26761681eb6536b387a20ceb0105c1f96f46f1e9a56d5a91", + "endorse", + "resolve", + "*", + 1, + "095b8459d6c64c982a40377490d9b614156e433a5384b527031cd96e9a44f2b7" + ] + ], + "start": 1708710452, + "steps": 0, + "store": [ + [ + "a788d518bd78bc2f1151bfda49cbb881100ea2b68d5ae8d242bf7f7142d7b87d", + "[]" + ], + [ + "57f0cb2c943a23b3420d7ba2b29acc63a50fca20b95582ad42882799507aa0ee", + "[]" + ], + [ + "c57e95964608214e26761681eb6536b387a20ceb0105c1f96f46f1e9a56d5a91", + "[]" + ] + ], + "status": "init", + "tasks": [ + [ + 7200, + "close", + "*" + ] + ], + "updated": 1708710452 + }, + "vout_size": 115, + "agent_id": "456dffabaaebe54af066f82746903c0715d6d37f3ff97a3e25951c993bc2686e", + "agent_pk": "e0b0884083e9e7750acc1aacceef6469929c9c80178d2d3aa45a2a8fbf249e6e", + "agent_pn": "f89971eeb85a83f787ca67fb286bce7571f35169ed0bdf278772837944f3a1a31514d1ac21934184dcb844292f9816f7317e165505643cc767f85588c534f95a", + "spent": false, + "spent_at": null, + "spent_txid": null, + "settled": false, + "settled_at": null + }, + "deposit": { + "status": "locked", + "agent_id": "c5c23e2b0eda849c910d17970a526fa563e6a6328965df385825b44c4d5e9abe", + "agent_pk": "15db4568941452e309be10e45e46f6418ea5b2a41e6acac50836308267956aec", + "agent_pn": "db6e5c7fd28ee2be6fbe802b36303635d038489c8ecff4a7d997838165b19e4934e6307cf95c9ff3afee2004fae6b6a72623949568a3a1e97b4e5b169b8ef182", + "covenant": { + "cid": "57ec337f28aee8765c544cd277e8574e1baa312abd329eb2fba2453dd7316442", + "pnonce": "636153d9f438eb3d54ebdf3e74c29164c26c6f97c9847965c45503b71195de980bf0ce6390ae1c242caf68500c611d267cdfcdf79b554dc7deae58a2f3a7f020", + "psigs": [ + [ + "draw", + "5a46b9c32a23d9d7a78a57015d5a0d982fc6396e8fd680dba4f45b4f41bd692b9997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803bec26b54a34ec0bec3dfffc478a84300255f06bb69aca883abcd0ecd07621d682bad9bd80ad5342763cf96c0c6a7c0918510c122dfd536e954ad83f68703597cbe" + ], + [ + "heads", + "f2cb4f7d633415f101aee89a9533e1780efeea310fb23021d8d62ac09cc747379997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be9176d1a8e7906cac0de774d76dc3d343882d200960bf36076e1b77c496237abc01348e29001eb0a51c0940ea8944accdec5f4811cbc28ef9b541ff82489f6aca" + ], + [ + "return", + "5b3ac68fbcc1453942d817311192424ca000f41170f99831409758b40593dbc89997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803bed05a811f19e5976cae72f9dd55b404d2e40fb4a7fbb00d56d540bfcefbb9466b927a47a95c63d3bfdcc8f6f38ec69ef3a1fcc6df54ca131a8cd4156cc5da0b74" + ], + [ + "tails", + "8af0a886abb937b05a89ae31172a473926927c9f40ac2a01555c01299978dc049997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803beb23fe695021b74467544ddb5dee79b7bf8b3177d00d5e218ea9a3f336603971334859cdf4fd5ef7b81454c51861a6119ef6f29ff0f0d9564b77096dab2dc889d" + ] + ] + }, + "created_at": 1708710439, + "dpid": "86ca4353a8deb493e838c56d0f4be1f6416e524eff6cb57f89dbd9dc2df17cbe", + "deposit_pk": "9997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be", + "return_psig": null, + "sequence": 4194311, + "spend_xpub": "tpubDESZEQAEhAFBV48iKkGcS1mGLHh32jCAyguHrkKjzDvJVWZt4L2FkJJvfVDSviveAV3jJfkHgYuMaaX5oujYxmuUiFL2L28LFSeaS5FQbF7", + "updated_at": 1708710453, + "txid": "56b8201b8cc005d94235511b5ef98fc8c1dc87d25874450897cbf8150cdc81d9", + "vout": 1, + "value": 20000, + "scriptkey": "5120af9d7b154b0c3a57c6e6428c6ace7c773ce27ccbc63aac02702fc43a27cd33e8", + "confirmed": true, + "block_hash": "0000001b05b9886a8b5fbfd82b05cae1dc96c3f0cc897f17780d0862c22b6878", + "block_height": 862595, + "block_time": 1708710432, + "expires_at": 1708714016, + "spent": false, + "spent_at": null, + "spent_txid": null, + "settled": false, + "settled_at": null + } +} +``` \ No newline at end of file diff --git a/docs/examples/deposit_data.md b/docs/examples/deposit_data.md new file mode 100644 index 00000000..bedec530 --- /dev/null +++ b/docs/examples/deposit_data.md @@ -0,0 +1,32 @@ +# Deposit Data + +```json +{ + "agent_id": "03ba079a69e895393b6571611ded44fb4ef4cf12433a6d706c93a4a6e3f94c05", + "agent_pk": "6cfe1d11949134989bdef9b135399a966407b46512e39a3a064a248be3ae422d", + "agent_pn": "a589cb2bdd7ba2aa3ed0f28e311113295bc1ce60062f3317b1f410ad1be9968bdb23bb52d051bf24801da4fcee1dc6e7d001acb6a668b32ec768e7d01cf07b21", + "block_hash": "0000022698ff744d9c079aab7e03b55c535724aa5e858524ce6b1d256b1a4612", + "block_height": 862569, + "block_time": 1708709630, + "confirmed": true, + "covenant": null, + "created_at": 1708709649, + "deposit_pk": "9997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be", + "dpid": "951e947af7de0e23955a417a0382b471eb12e8b0b6348b7a1e27a87bcc0eeefa", + "expires_at": 1708713214, + "return_psig": null, + "scriptkey": "51201a3fdc8869c0f5e0726fc98521d20f047c905de5e7d2bfdd75115148a346cbf4", + "sequence": 4194311, + "settled": false, + "settled_at": null, + "spend_xpub": "tpubDFGnByxJJpD6iM577bWs3xCjrJUb8XDazDtq7B9SC6xRwCmmL3FBQx9tbzXZqwsia811KuRhEaKJ96m33FaRtGo7fxVvvZDoXpz1tQ2n62g", + "spent": false, + "spent_at": null, + "spent_txid": null, + "status": "open", + "txid": "091719b68faa2a5a8545762228d4ab295e38dc51bc43a3cc6d9b712acf09700e", + "updated_at": 1708709649, + "value": 20000, + "vout": 0 +} +``` \ No newline at end of file diff --git a/docs/examples/deposit_digest.md b/docs/examples/deposit_digest.md index e69de29b..1adff576 100644 --- a/docs/examples/deposit_digest.md +++ b/docs/examples/deposit_digest.md @@ -0,0 +1,18 @@ +# Deposit Digest + +```json +{ + "block_height": 862625, + "cid": "f78b01f7f2a4d324f341424880484da3c3d7d76b268157bb1ed41659d2216e1a", + "confirmed": true, + "expires_at": 1708714939, + "settled": false, + "spent": false, + "spent_txid": null, + "status": "locked", + "updated_at": 1708711363, + "txid": "cca263cf2d4634bdfbbb550a5ed61135319a0dc8bc089d26e81e631e321031b0", + "value": 11180, + "vout": 0 +} +``` \ No newline at end of file diff --git a/docs/examples/deposit_list.md b/docs/examples/deposit_list.md index e69de29b..83f47d54 100644 --- a/docs/examples/deposit_list.md +++ b/docs/examples/deposit_list.md @@ -0,0 +1,366 @@ +# Deposit List + +```json +[ + { + "status": "spent", + "agent_id": "ccec64b04808c28b04a17d51abfcf1c4ca964012fa38a04bea39b0f09a305d47", + "agent_pk": "88b1e84e33ebaa2377c8c392e43b7c64a639be7246b8da1f89f7638976a68382", + "agent_pn": "e73195c4a73e9bf00d45eb43304c8729fdb8c8a4ee667b721fe677413fb40c8041c17eb3bb1af2ef2eb7061111004eb7dc54ceac5d3c43f487f6259521968a06", + "covenant": { + "cid": "fad493747e3dda3b00456087078c10b5482dad98b66a36d47e7d74b2b7028f95", + "pnonce": "ddfc0d0ad1137aae1e38a751c63dd1ece702580f863830a12118b71e4272e0601f0d812139d876cc7e3e1d2665a4809bea1b1fefde6ded5b153c09ed4f0ef860", + "psigs": [ + [ + "draw", + "1e3df2bb234c4449318b29b6fa516157035cf81b717d2c9308e43ee3415b52989997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be7cb1cff994ac106e1cd6494ba8a7028ee3204937153f16635314ff2196736aa7a18ad34f0f2b214ebe68108c411dd9e700c66845b50c2e993392deb44211da0f" + ], + [ + "heads", + "25a747e100d9b1f9b7079ffa523b31e6e33574f0bc7847c43f42d249d923af569997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be4fa5cb61b04e3495bed5cae84475819da4c3a8e7febfb5b4f6fd76956a0a7f5be62b77d375df0a5bc836bf7d80d4f8dc8502143eea2a5df5e174cfe12d0176b8" + ], + [ + "tails", + "b84ee942f6239fb866c2d1ee62773212d9bd5bd87578c1c487c7578b24e942289997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be69355866c5de7085bfd68293ad5cc6564a22827cad917dfa194e685efffba8789e7de326eefa46fc05761fd3a9e32c3980eaec9b411bea3391457fa5b8be366a" + ] + ] + }, + "created_at": 1708379721, + "dpid": "6cb76d4ed67ea687ae21510ee337d96ca07370dca720f1ecfd560dfb7b1c785e", + "deposit_pk": "9997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be", + "return_psig": null, + "sequence": 4194311, + "spend_xpub": "tpubDEapvwLgqBkCsX8AHcCH2qkVyMPNHCkn2dEJkLCbnWhpdri6X5BVe9r1n1QSxhYMywnSN8cEFT3wMT5ZnXxSERGTkpXWSbaP1BxNGUev3BR", + "updated_at": 1708379764, + "txid": "8c050bfe3d6261513d1655e08c70d45d2f684e27ca6ba93bafcfb11ece3b8365", + "vout": 1, + "value": 16211, + "scriptkey": "5120324829737c546c8c0e154083a075bf6490672992d184ab70980b16b2a43c7abe", + "confirmed": true, + "block_hash": "000002214da71b66400ee5287d37403b56d0a99d4c4ae3969eabd32389b8c0aa", + "block_height": 851911, + "block_time": 1708379735, + "expires_at": 1708383319, + "spent": true, + "spent_at": 1708379764, + "spent_txid": "d9a8c08660a3b0596771f2ffe22651bad0493ffb5db8e927f02cd47d555fd9f0", + "settled": false, + "settled_at": null + }, + { + "status": "spent", + "agent_id": "5b5e4eb790a4261c54851e8059f4892bde3e365469b3e8cc44ad7c6ea2f75fa5", + "agent_pk": "8f13a0db4e5d52ac6bf69c786fab3ca763894f0979412b84129c697add2726be", + "agent_pn": "fa314abbf5ea3de4a1dd74a48c6b4d16778bca90b19a85fdb8450d7678b8145f39268b7b43066afdf0ebf318e959e50f0aeb60dedc74ac721429d750464a8d59", + "covenant": { + "cid": "25383b74156b0806c975cfaaffed75218c17ee2c432c138972ab0d09eca161f9", + "pnonce": "b54e87f1a4beb49843ab54753c47161d68a2f18ae2807b725180a913ab1cf11dc664dec18f967f3f22d61e2960d9d3864fdd94502a45ef3bcdffbbbfd0aa01cb", + "psigs": [ + [ + "draw", + "6adb838b935e082ec40ed90ce739f0cedaa0868c656c2d106ec00393def438639997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803befa0094fd927a8cb112de9f2d67a2a881d59a5c09f22f7b3192fe870294f93bc36ebdda60407c72943477391d35c759181c7123b93108d0db013a100b405dc57d" + ], + [ + "heads", + "3f0e5281fae18b13ee32b48ac85c0ba00be9a06637db6fbd0def69c32c52ce609997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be29e5f94f82d7aff4489e3e6de15ba6c57c80e54666b2f2c5b76fd9e624be00218afb1dfd82bc20d8cf3ffb4ff483397801639a6e9232f957a989bfbd8d01f051" + ], + [ + "tails", + "06fa05848412a5d81970feaaae71136044fde64cffca41b5900022d421a06a209997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be2437036771589282d3aa1d79e667c82a9259003f191121c6e5774c83118e08f3a66ce3b7b9e7ea5b96ec7bbe3c0c0a98a9d8fb44bafabb4c8dba2bfd00d1cc74" + ] + ] + }, + "created_at": 1708010690, + "dpid": "a5943736c12e89a56c216eeb0be6f7fe5683eae99e7944ad68627037d1c1b323", + "deposit_pk": "9997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be", + "return_psig": null, + "sequence": 4194311, + "spend_xpub": "tpubDEahCoXko9rmc8w2upfJG26KW1Dk6VsRLqnqoNJWCEYiSjytFmfSpBj8REJk7aAbdJH5EXhb82XSDHm1LkPpghc4yjy9djUHEDdZ6GAzhcU", + "updated_at": 1708010726, + "txid": "1d47c0a4ab81267481ec69035ff92ff6eba991f28f0e598651760e0df7612618", + "vout": 1, + "value": 16211, + "scriptkey": "5120b2d22218438b04c80d8182172a93c07c94a491c1a8fe63f0e9162335eee5300c", + "confirmed": true, + "block_hash": "000000537281060fd4c9c883a0f891be5d2c63b88611069573cea645a4486807", + "block_height": 839990, + "block_time": 1708010691, + "expires_at": 1708014275, + "spent": true, + "spent_at": 1708010726, + "spent_txid": "9c38dbab0a476a667a4ebc360942831fd5c858d6233cec2c9f4b4a20c28e13ad", + "settled": false, + "settled_at": null + }, + { + "status": "spent", + "agent_id": "c1ad011c4cba6d61d7bb66c8848b0d1d4be68ae488d38777baf08d872e039065", + "agent_pk": "f39bf9518e7a3333d1be977d62d16ddd0f82a7f9628f49086816b4be00989f68", + "agent_pn": "724ccbf826522e5ea44d1a827f9fa1c233f1426f38cb3db7281bffac1d55c3553fbe07e548de046f3b3df396a31433c7093f84f3d5e74a38dca008d164fdfc63", + "covenant": { + "cid": "8cdd209d53724661235c61693ee2100bebf7965ea09a228bdd731c1be139199c", + "pnonce": "82767cc8fc83544253fcf9c998e45e20493a5e64227a168c5b8708e8a41f135455b173e5cfa98632e208b3b48d02f2a2fae7c54bb5afb0bf2a0eabeebf7af106", + "psigs": [ + [ + "draw", + "4b5f91b5387f3c6a512ae6afe81cbef5eabedf2469f465d4aecfb37122ea59d49997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803beb06cf3bb537ba388b270c953018a1e06677188a9765d6d77a107d19b5966a1ad38ba97ffa08d01f882afebba0001ef4def0249200ba1e5106d5bcb2cb0ede41e" + ], + [ + "heads", + "c70fdbbb2183c629acc2d43a361c434eec8defb1652035607763a464488e53119997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be07f4c5ee7ea1cf7834397703d1c6db3fab47ca1bc09463fe713dc7fa790a951bd329a2fe488010df79c2a84c3ad166f5e11c9ad6b4b4566325809e8956ab3a4e" + ], + [ + "tails", + "0b0bb45cffedd23437e036c2bc79ed599b55810a7eb5bf04d98b1858aed246fd9997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be5365ee30d6cc813193e8b7a3695be8968333c5589555e41cafc231c89e73389449fadf1d4e5d4e7a63b1aaaa5f307fe11bb3dd13e27b1f84195eb98779e0d055" + ] + ] + }, + "created_at": 1707872897, + "dpid": "d22821b468ef05d8167f250bff2fce7ff5a73d66e790252901840e3f40cc0e58", + "deposit_pk": "9997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be", + "return_psig": null, + "sequence": 4194311, + "spend_xpub": "tpubDFmywm5mbDxiDJGAECWeAJxxKm5zvRkQtNMeERBkHLHpDv79sMCg2Xp9ZWqNoHGcGqDykHF921wKfKmd8aUXhT26HQpZTHVYNoMREMLsWSz", + "updated_at": 1707872935, + "txid": "86c13940cf99963b6aee94810375b2d182a6fd0ff2ec3934a1fc49e93674eadb", + "vout": 0, + "value": 16211, + "scriptkey": "5120fb2afe1d56cfde6ad56cb03321ed2cca70fcef77a69f193c2067466c6203218d", + "confirmed": true, + "block_hash": "000002622f991a30b9911fed6ad6272c13fbe2bc3fa08ea4284de17adbbab934", + "block_height": 835547, + "block_time": 1707872914, + "expires_at": 1707876498, + "spent": true, + "spent_at": 1707872935, + "spent_txid": "984128593a4d164cc988b76659144de79c820083e0806e2698d8d1b76eeea75a", + "settled": false, + "settled_at": null + }, + { + "status": "spent", + "agent_id": "da0c99e30c4fbc6d3ec2a5fdb8e7d5b672e2817f826747ea029ebb7b2f793265", + "agent_pk": "0573e76a56987aca6c1ee5c8f6f0d304398ef9832bcd620fd0884fdaf3f30eec", + "agent_pn": "42cc12bf57a1906c74a035ded52929876467f81fdce9aa31c273e9121504b73caebc273105f5ca78184b42ee7be0991f916b9963f7629943d1f783804d23da79", + "covenant": { + "cid": "82c63cfd3a51e87d2f146c387643d9d797c8f523fb746a8be98f2b9984f5de34", + "pnonce": "8417768d058d0d340d5a126398f5592cd70cdd371cbe05daafae2c2ddaaa7f01dee19a348e5824157921c6c942b67e4a06c768e819d68048adc0f2789fc7bf5f", + "psigs": [ + [ + "draw", + "ce49cb0daa4126657e38ad894f7a55d646898aa4275190c2ab74aa2d6d30fc629997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803bee9fc720dbcb7235d576807dd26987c6dad89b782f06547a34d84666d6fa3287cc7f793a1e4fbc005b0e6af8fac4e2d799f57f31a0d3c79a95ad5ed37375810a4" + ], + [ + "heads", + "7c502ff3dbd4deed18415ca4d64ee59ddbb9f657f9a84b38a0547d55369628209997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803bed054e485c3a4913e32250c245983c80d2b4bcde93e20dcc118085b0ba635189346e935992a7b9ebc3c62d421e048354edc56fc5c96381786a02c71fa026c582f" + ], + [ + "tails", + "70f0b1eab7bffae4be6796e8f9845d42737ac888be6fef8792618f48e8863be19997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be6ce012d72cf2601d3fbce24258b3f7eaa1f2b56b7b8bcbb61a40c9fb2a757082fbac014e8ca798eb8a71e75224059b5c6591b5e942436ebc51cc9eef5922d352" + ] + ] + }, + "created_at": 1707872796, + "dpid": "da803f7dbbfa1fac2b29e5ed8835013bc5b3870fb70c488a51b735767cc540cd", + "deposit_pk": "9997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be", + "return_psig": null, + "sequence": 4194311, + "spend_xpub": "tpubDEEqakAKb4zrjmRBDiHMtLe9UmrazLxcNgcXy1VSXhhymxpcSNeFkSsRn2Dh6rbmU89Sa2yuspVxC8jWorKd77Nc2h2q4Lz95ErTmBmsbtL", + "updated_at": 1707872798, + "txid": "3f9f09e10c118f6eb49ad6fb25225c5b327f421f39fef17a34693081279d8be6", + "vout": 0, + "value": 16211, + "scriptkey": "5120e0fa20c6d8eb5c9322ae9efd12165885f1b80bcc2c801e901c3c37988628f922", + "confirmed": true, + "block_hash": "000001e5eeff47d0f2b2fb488de36ae021ef637852fe691be97f27eee2551b3a", + "block_height": 835543, + "block_time": 1707872792, + "expires_at": 1707876376, + "spent": true, + "spent_at": 1707872798, + "spent_txid": "2f538fed0879ff43f6298ea969ea51a53bd2cb5eb51fa056b495b9a5cb20575a", + "settled": false, + "settled_at": null + }, + { + "status": "spent", + "agent_id": "f27bfb85679ed793c236ee3adb9ac247e5fd8401609630000230fbd86a69f762", + "agent_pk": "f70c2d8bdb9ac4d2e1aaa3e8df2e81190719bf2002b96f5638e2595e0d31e8f0", + "agent_pn": "e171400a13e617e4d05bb1d643140a0a3ecae201c177beaf2fdeedcbd64e92265f747e5bc26fc4946b17e539c92c7989ac0da072cd8f812758652227fde1c213", + "covenant": { + "cid": "3480080fdf7fb09483638b3422ef6a743a646c01ef310768cf83cb2ccd3bac64", + "pnonce": "5c47611a15994c8fb9140bfda18f7f0e2b36f68e993e3a1574b77628f80cb6ba79bad89bb31c63cdcd328ac470a5e901016cf81dc28c0f44e4697386e7780639", + "psigs": [ + [ + "draw", + "46d13352c31cb0558e7e69a7f6ee152ad1a5d6900abe11b7b93729930662786d9997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be33bf365b292fe4415e8912ce6eddc88e6cf2d543050c8d52d9a5dc16f5fb30b16b9e77ed8d16e2012c5d87606558e624ca6786c63f3a60411c0e280c9cc62dad" + ], + [ + "heads", + "2d60c0abf492d18321e666e51eab10f4faa8abf98304f647447feb9e16e873a39997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be865854d809495639bf822d2b7d6eeada54098573c0a8f2f3df3cd34a383e07af0230544bc184e787571df20f4a74e2191035b2e6ddaf5c1bb0de49d311a58f6d" + ], + [ + "tails", + "b762156118c792ca394e6675769954b5950b3be3392b6fd0f29103a86cab8d7e9997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be98183e283f35a7cfcb879017182606eb5b386c4ff3ef756ec235496e9386b3ca99559994b2575bf9e51c5bd269bae3248b62291b6140ad2063b96045b3e12625" + ] + ] + }, + "created_at": 1707872599, + "dpid": "2e65b78bd2c14e868f95190c9fef06e620850880192c247aa81fb1911924b1dd", + "deposit_pk": "9997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be", + "return_psig": null, + "sequence": 4194311, + "spend_xpub": "tpubDDv7vn96xAjFkfsvKrVxuquF28LNRZ9HaGuDgckoeSToChYNXPKJBReDYsUU8LZh3gkigUHMfkbJGjdAVazifoSw2G8Yv1PtHTJpJctquH8", + "updated_at": 1707872642, + "txid": "8641059aa0b8eb68bbe666a9f29500d993bbfa0e4f40ec41eb6e288d5f17d924", + "vout": 0, + "value": 16211, + "scriptkey": "512077c93c58ca6515229471ffd785de5702f2a264edf935c4545fa97593e785434b", + "confirmed": true, + "block_hash": "000001c4615160e9ea0770470974362e267c7cd442bf9695804e3e011c662357", + "block_height": 835537, + "block_time": 1707872600, + "expires_at": 1707876184, + "spent": true, + "spent_at": 1707872642, + "spent_txid": "e53bfeff42b419b6665dd6958c104a24fdeff4d0043ee242b398e0f5805fdcf0", + "settled": false, + "settled_at": null + }, + { + "status": "spent", + "agent_id": "da67dba4b03986c44a3d58cecc8ddf55cc873b623087e03c456b5495c8c6b2eb", + "agent_pk": "38ab191db6b930fb9da7cad7e67c2499e2feccd85717089cf576a04ab94f191d", + "agent_pn": "fe0c3afbd0d177ee3994a70d5304509a57c799bcf54f1c3c91e35e1f2fae4f0f4fd8beb02d908a7198a7125943f2592ad073388c37bf5c399e8b7826a154f612", + "covenant": { + "cid": "f7c3cae880374e2206147f012ee12e9a53c9e58a3677b7aca9ba3c3b195625fe", + "pnonce": "161f25c494d43af1d29e9023d6313e90e2e74b3ee9bc7b05fb4a622bd13a12f41ba4fcee31548469090dc03f29e8c6fea6cab1fdf272ef2811bd54449ed9478d", + "psigs": [ + [ + "draw", + "c8c1aad237f40871a72334de4f8ddf29aa2be58e442924d424755e71fc5789379997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be20048c8abaa26169e91cff0fdce880640fa622ed1d36213b3de6a7f333b19def2147e3fbfa0d9721ddbcaaddb6379ea225ebc0344d053580567f77cec8596925" + ], + [ + "heads", + "b8ed24816ea6dc8f5a4c716b018a255d28afde092c099b4fcd15a4a9378effad9997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be6c0c586426776a40ccebfaf9e17118b0de3ccde8d3f8e6978c7334591e72ebc7bf29ff384c9250c74860e985fc45a028a67ae4f0dc2dd26645e00bf7509301bf" + ], + [ + "tails", + "ee2b4d74699a66e01ce0a8638f6fdc264940f0474ec158bc153526580e5561029997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803beb9f89096f994b0d29e0e13a1a771d3f140df317f6af468e577838c7c0395ac87bef9d1a685cab9e9c28ffd72f28c5ff1af8a29e0805aeec33be262d004d4fd5a" + ] + ] + }, + "created_at": 1707524763, + "dpid": "9f16d1ac2a96d2a6c973fb2d1d895251b18c2990ab8f12218fb1f7dd4188e259", + "deposit_pk": "9997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be", + "return_psig": null, + "sequence": 4194311, + "spend_xpub": "tpubDDw7ruKtZUezCzdX2a8cpPrFwmCFqm6ZbqZWhEggqRNhbjfuH8n9W24BKemxTUNvddQs2p7pX7uNoFTQP46SDAYmqV1BrioTNEi8XLuzePE", + "updated_at": 1707524803, + "txid": "3d3c54afa233a56e38c8f05f001764476aba8de2e712332d375477d6b86ecb6f", + "vout": 1, + "value": 16211, + "scriptkey": "5120005d8275c35fa1107d2ee2f30a3a3243b57cfffb9af97bb64de0b30b76ff96c3", + "confirmed": true, + "block_hash": "00000092f02e49d087ead73fbf89eac3b1dfa7704be84b7a6b04b06a15b3456a", + "block_height": 824308, + "block_time": 1707524763, + "expires_at": 1707528347, + "spent": true, + "spent_at": 1707524803, + "spent_txid": "fd39cb3fa3ddb1ff1788ee0b4990665f355cdee3d9bfc2b0cb59a3d4fba5eb47", + "settled": false, + "settled_at": null + }, + { + "status": "spent", + "agent_id": "6a976fe55c8bb3c474dd499208d878436f16a78aef32dab73aed0039fc5281b4", + "agent_pk": "4c92f17d167b7274e689d1ce5f4d230521e9854d0928e276dd27b253ff853009", + "agent_pn": "f63bfd5595f3b8033da8709e1cea9bf1ba517eade41030364e4184a83239e15102f9df0ae3e4086b4b21b8c63d3b006e7793af731cbe9cb48cfc00bf14e81584", + "covenant": { + "cid": "e9096df6d1d09022b74c2c8562a2014e7b349573ad41f4d513bff11ae9fa34a0", + "pnonce": "119419c78bb5497c38b0ea0c02d323c8107a14b6186a4d819c3a5de5d2d3f2ce2fa563bfd96d45bbe2da92138e5abf76c4b8edab841c4344af443267b6b3b0ad", + "psigs": [ + [ + "draw", + "1c0eb6472bc19e913b99ac57b529cd48907e7d1df901608539d17a4832740a1e9997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be985b70ea53b7974246153592a81d160ff26b3c703150e6a867f86e378aaa26363b40028485301c3735dce264bc6cc0188d5003dc2cf225f6443a0a82e7dd8cf6" + ], + [ + "heads", + "f630339fa7784e05402b396cfd43c7046748cab414f6d127fd7d1f514801d0e19997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803bec958dfefe34a9393ad61bbaedd2e39ea0e012936d65bcd8ce551d6795ff5b546553d1f8586ac3472059026f42ac1e7f819aed7164c71d277053a9d8832c9819a" + ], + [ + "tails", + "e1158dc834f69a3944d91b75bb1843f680965c6a284d80553eb83166080d15219997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803bec4ca375f55d1a5df18c76a2ba9c268b879084ae89bab7517c181944a743c54c9417719fb03f382188b8a770a1f94500a24183b895c843163919a6deb1758c741" + ] + ] + }, + "created_at": 1707338397, + "dpid": "93e114833ba1dd7c46f7fa9bce9f08eacd468821bee518fa46b896101f23cb64", + "deposit_pk": "9997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be", + "return_psig": null, + "sequence": 4194311, + "spend_xpub": "tpubDErNqyuqRMavFHmpY71oXnN1H2S4Yti82BwYQQYUph7jytTsjJjkUh5GemoaHPeg3ivk4yL1JJhbdoamcdQTKibLvbVXu3yS43X5xTVQPZY", + "updated_at": 1707338434, + "txid": "22af66256f7a6488307632a82292777ed8012f0de1b83c00c387d4d9ce300cae", + "vout": 0, + "value": 16211, + "scriptkey": "5120e47df368ff4fbf2bfbe66b109d17294567102766f74e681e64c8aedeadc40d8a", + "confirmed": true, + "block_hash": "00000038b49fc49735466d94f2dd78f206ff72b38cead065c8f9d321e46480cb", + "block_height": 818298, + "block_time": 1707338404, + "expires_at": 1707341988, + "spent": true, + "spent_at": 1707338434, + "spent_txid": "9655c411904ce5484aaa883f7b6ec118170563c797a82ec0b74e9e9a473aee24", + "settled": false, + "settled_at": null + }, + { + "status": "spent", + "agent_id": "1970197e70d5c9ab9818e797ff51c4f84c061d902ef857fa2d3f5d3d44164d26", + "agent_pk": "497aad65280a9a3e562de826b0e100da7d276936c64b1c0ef90767922bb71c81", + "agent_pn": "1348cc2ffee3378c6e32b3650bde21deecddd602bd85c3aca14297e6efafd9db2a2563494c56a80f12161d788dae39e324ab0149f90df2fd0aa03f09288282a5", + "covenant": { + "cid": "48fcaa6cc28e249859340477f450d172d1eac28bb0a9e6b93d4be4789dea7f27", + "pnonce": "77b2e2b5658dcf963e260d887b0dbdefcc04d604336d5cbb8183e88ad05fab5ca30c75993cec60df1980b983bebffd61d81ca7f00d8663d2b5e5b206114e8691", + "psigs": [ + [ + "draw", + "cec192bc60aff25f92067941787a8a685012f40ed09d642a524e62cede4cc45c9997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be0348694ebe7d6c65b5e1bff5a60578c6546e9ef3c6bd345cb738c7b0dee236f288b25cde7ed600831d2cd3335f3a17ce0b4ae3dfd5e69c2c7b16d081bf67ac59" + ], + [ + "heads", + "0382f968ae51595b642d7daf8d56c26e3479219347574570772ffded65c55f879997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be0999569e7cc94c41923ad6dec593e03c3ce905f123c126f3e13c1d59ea8b3322309451790e165cbb949ae95dd0e321502a04604bba731deaf349a833f4235e78" + ], + [ + "tails", + "46ff4ef40e9c19e9dd6cb21660e78235cec53ab6abb975bccb8c429e4477f4489997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803bee19d090e240c3a8963d72d6975ceed53c276ebb524ffa86b4f5547d60c3be6d3bd64118bf2ebea6191611346316c41cd16e696df2db5d77095fe20cdeaec1974" + ] + ] + }, + "created_at": 1707287279, + "dpid": "f138e5454a8f3952e547622dfa84330fb665267f539a1feaf3731f9b327b3e6c", + "deposit_pk": "9997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be", + "return_psig": null, + "sequence": 4194311, + "spend_xpub": "tpubDEkUEXK8E7kuYFjh8dRHntJoiAiwNjFmxsboWTQY8BDbK4RJXzzsEsqqMQteYoQ5WNJzW7Rrf13uEULSsqBbaecatGCKVJGt1FEr3PmdT6c", + "updated_at": 1707287317, + "txid": "6d741edb05d948d3dc2d2ad705aabcd208f183cb7c6f7c59788ae78fecdc6a9e", + "vout": 0, + "value": 16211, + "scriptkey": "512069b0de4ae3f332f13c18e19c2086457c336d5caeedf5c0d40b3bb3f41341e7ae", + "confirmed": true, + "block_hash": "0000035261e206454fdf5bf03123a4168caf2f1cd35079e5a218e392aa09a863", + "block_height": 816650, + "block_time": 1707287289, + "expires_at": 1707290873, + "spent": true, + "spent_at": 1707287317, + "spent_txid": "4e8940af89214348ee87caec2ef9190adcdf16758377d526fa8282b7fc551d37", + "settled": false, + "settled_at": null + } +] +``` \ No newline at end of file diff --git a/docs/examples/deposit_locked.md b/docs/examples/deposit_locked.md index e69de29b..af83780d 100644 --- a/docs/examples/deposit_locked.md +++ b/docs/examples/deposit_locked.md @@ -0,0 +1,53 @@ +# Locked Deposit + +```json +{ + "agent_id": "37e8059ed43b4e9f824d12b54a6c7368f63fd3650e27cf2e9f2b948713cdb584", + "agent_pk": "70f50b3a553329fdd60370fe16b46470d8323a41617ed3770199708148072a52", + "agent_pn": "e2b2bd44af7b85ba230db4b7fe11de01abc6625476ae5638ae4040090e52f96a03930aa3e36770df4a0c8f3eaec950c7ebf477ec8a9a89b66c35a0df623e912b", + "block_hash": "0000031c24c769b7dc71dc75f70bdb3894ffded76448bbea63eea84b6e605dec", + "block_height": 862576, + "block_time": 1708709845, + "confirmed": true, + "covenant": { + "cid": "2a1fd8a5701a2df396802f18c79e9e06c1037d2efcf6765c33d441299efa9092", + "pnonce": "1d63b905ee3b28580c29e2ea90bca4db9904586987deae6dec5306c29ccc548cf979a88b71ba145272b24b73c2158186b34bb70e658c52768b7b0c03278dbb64", + "psigs": [ + [ + "draw", + "20eba79446a3708b5ec8f04616dbd36c6e9b2951a0e852488fa9b94175bc64a39997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be4d81263b3103836874f46585b2daf7263984448988dafebbb8b9d053abf5d184da3296d5ba3d3fded55799ed73dcaedadd5c921120e61eeaa5979a3edaf6cc38" + ], + [ + "heads", + "bde9c0594c5de5c2a36073d6e5d3bf1ff1d060f0b3516573252086ead4fd095f9997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803bedb177399abaf3d0b7e85214eb0b28e0013cf5085f022a4913b7bc678475c181b3db772235801c1495b31467a1a78f4461cbdbd9225e183699dd65052403d485c" + ], + [ + "return", + "88084db33abbbede11d375b40b0b6d7843350a29c754452c30d2440119e473559997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be80e88991d0116ad5e018fb8145cbe86d988e3d75c32f971c85345cd886091ca6574126439689af22bb675bcaae8ce2f42254d598b6c8f108eed91990f29790fa" + ], + [ + "tails", + "7d013f3bc4c12b34f28a2d58b33626e3af7e763b93406e0af11db1199cfc28539997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be85be368b5350fbbd0f43b48e90b6d0b0ffd3c4b24d3ef4f6e24f9860310a98d9eb4df4f3e999240670e101659acddc79e5183f28090a502923ce51e945de6839" + ] + ] + }, + "created_at": 1708709860, + "deposit_pk": "9997a497d964fc1a62885b05a51166a65a90df00492c8d7cf61d6accf54803be", + "dpid": "65217cfa7828e6fdb412889a28b2857f6f0d9da64cb8d6bd8e5e24f88ff4ba75", + "expires_at": 1708713429, + "return_psig": null, + "scriptkey": "5120ab7abb867c5f2cc40e6aa4fc0177807136c06cfc8e97d5d1dfb623200a58196b", + "sequence": 4194311, + "settled": false, + "settled_at": null, + "spend_xpub": "tpubDEbu5KrzgEBbEiGfAPMgJ9fwm2eYqoAAirsu8CgDGa8N7xhP5QWPyoCGY1XUz8saF1QdLZhpHNGmzHu7CjmqUWZHHtiDCvrwSDHiLp8V9Lp", + "spent": false, + "spent_at": null, + "spent_txid": null, + "status": "locked", + "txid": "ad1fa7fa6add3ac56d1c535a44ca3d4ed7e4ccfcfb82eaffbf9646d37865e834", + "updated_at": 1708709860, + "value": 20000, + "vout": 0 +} +``` \ No newline at end of file diff --git a/docs/examples/deposit_registered.md b/docs/examples/deposit_registered.md deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/examples/deposit_status.md b/docs/examples/deposit_status.md index e69de29b..367d7961 100644 --- a/docs/examples/deposit_status.md +++ b/docs/examples/deposit_status.md @@ -0,0 +1,8 @@ +# Deposit Status + +```json +{ + "status": "locked", + "updated_at": 1708711280 +} +``` \ No newline at end of file diff --git a/src/client/api/client/oracle.ts b/src/client/api/client/oracle.ts index 28668ac5..0f1b9da2 100644 --- a/src/client/api/client/oracle.ts +++ b/src/client/api/client/oracle.ts @@ -9,9 +9,10 @@ import { get_address_utxos } from '@/lib/oracle.js' -import { OracleQuery } from '@/types/index.js' +import { OracleQuery, OracleSpendData } from '@/types/index.js' import * as assert from '@/assert.js' +import { sleep } from '@/lib/util.js' function broadcast_tx_api (client : EscrowClient) { return async (txhex : string) => { @@ -53,6 +54,32 @@ function get_addr_utxos_api (client : EscrowClient) { } } +function poll_address_api (client : EscrowClient) { + return async ( + address : string, + interval : number, + retries : number, + verbose = false + ) => { + let tries = 0, + utxos : OracleSpendData[] = [] + for (let i = 0; i < retries; i++) { + if (utxos.length > 0) { + return utxos + } else { + utxos = await get_address_utxos(client._oracle, address) + tries += 1 + if (verbose) { + const msg = `[${tries}/${retries}] checking address in ${interval} seconds...` + console.log(msg) + } + await sleep(interval * 1000) + } + } + throw new Error('polling timed out') + } +} + export default function (client : EscrowClient) { return { broadcast_tx : broadcast_tx_api(client), @@ -60,6 +87,7 @@ export default function (client : EscrowClient) { fee_target : get_fee_target_api(client), get_txdata : get_txdata_api(client), get_utxo : get_utxo_api(client), - get_address_utxos : get_addr_utxos_api(client) + get_address_utxos : get_addr_utxos_api(client), + poll_address : poll_address_api(client) } } \ No newline at end of file diff --git a/src/client/api/signer/request.ts b/src/client/api/signer/request.ts index 4927add5..c778e41b 100644 --- a/src/client/api/signer/request.ts +++ b/src/client/api/signer/request.ts @@ -8,7 +8,6 @@ export function request_deposit_list_api (signer : EscrowSigner) { const host = signer.client.host const url = `${host}/api/deposit/list/${pub}` const content = 'GET' + url - console.log('preimg:', content) return signer._signer.gen_token(content) } }