Skip to content
This repository was archived by the owner on Jun 17, 2025. It is now read-only.

Commit da8d385

Browse files
author
cmd
committed
update
1 parent 0a80743 commit da8d385

17 files changed

+126
-613
lines changed

README.md

Lines changed: 59 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ Development & Testing
5151

5252
The protocol involves three parties:
5353

54-
**Members** : The participating members of the contract.
55-
**Funders** : Those depositing funds into the contract (may be members).
56-
**Platform** : The server hosting the escrow contract (BitEscrow API).
54+
**Members** : The participating members of the contract.
55+
**Funders** : Those depositing funds into the contract (may be members).
56+
**Agent** : The server agent hosting the escrow contract (BitEscrow API).
5757

5858
The protocol is split into three phases: `negotiation`, `funding`, and `settlement`. Each phase represents a round of communication in the protocol.
5959

@@ -86,17 +86,17 @@ The `members` of the contract must first negotiate and agree on a `proposal` doc
8686
}
8787
```
8888

89-
If desired, a service `provider` can host a platform for negotiating the proposal. The protocol is designed for third-parties to help with coordination, and offer their own services such as arbitration.
89+
If desired, a third-party can host the proposal. The protocol is designed for third-parties to help with negotiation, and offer their own services such as arbitration.
9090

91-
There is no specification placed on how to communicate a proposal between parties. There are already many great communication protocols that exist in the wild, and they all support JSON. Feel free to use your favorite one!
91+
There is no specification placed on how to communicate the proposal between parties. There are so many great communication protocols that exist in the wild, and they virtually all support JSON, so feel free to use your favorite one!
9292

93-
> Note: The `agent` does not arbitrate disputes or take part in negotiations. This is strictly by design. While BitEscrow may offer these services, the protocol is designed so that members and third-parties can negotiate freely, without the agent being involved.
93+
> Note: The server `agent` does not take part in negotiations or arbitrate disputes. This is strictly by design. While BitEscrow may offer these services, the protocol is designed so that members and third-parties can negotiate freely, without the agent being involved.
9494
9595
### Funding
9696

97-
Once a proposal is finalized, it is delivered to the `agent` server, who hosts the contract, and coordinates with `funders`.
97+
Once a final proposal has been delivered to our server, all terms and endorsements are validated, then a `contract` is formed. The contract is assigned a signing `agent`, which is used to coordinate deposits.
9898

99-
Each funder requests a `deposit` account from the agent. This account uses a 2-of-2 multi-signature address with a time-locked refund path.
99+
Each funder requests a deposit `account` from the agent. This account uses a 2-of-2 multi-signature address with a time-locked refund path.
100100

101101
```ts
102102
interface DepositAccount {
@@ -111,7 +111,7 @@ interface DepositAccount {
111111
}
112112
```
113113

114-
The funder then delivers a batch of pre-signed transactions which authorizes each of the spending paths of the contract.
114+
The funder then delivers a batch of pre-signed transactions (called a `covenant`), which authorizes each of the spending paths of the contract.
115115

116116
```ts
117117
interface CovenantData {
@@ -124,11 +124,11 @@ interface CovenantData {
124124
}
125125
```
126126

127-
Once the pre-signed `covenant` is made, the funds are locked in escrow. Once all deposits have bee locked and confirmed, the contract becomes active.
127+
Once the covenant is made, the funds are locked in escrow. Once all the required funds have bee locked and confirmed, the contract becomes active.
128128

129129
### Settlement
130130

131-
The final round of the escrow process is the `settlement`. This is the most fun part of the protocol, as members of the contract get to debate about how the money shall be spent.
131+
The final round of the escrow protocol is the `settlement`. This is the most exciting round, as members of the contract get to debate over how the money shall be spent.
132132

133133
When the contract becomes active, a virtual machine is started within the contract. This vm includes the `paths`, `programs`, and `tasks` specified in the proposal.
134134

@@ -198,11 +198,13 @@ Members of the contract can interact with the vm using signed statements, called
198198
}
199199
```
200200

201-
Each new statement updates the vm, and is added to a git-style commitment chain of hashes. Members can use the vm to settle on a spending path, or lock, unlock, and dispute paths.
201+
Members can use the vm to settle on a spending path, or lock, unlock, and dispute paths. Each statement that updates the vm is recorded into a hash-chain. The chain validates the full running history of the vm, from activation to settlement.
202202

203203
Once the contract vm has settled on a spending path, the agent will complete the relevant pre-signed transaction, and broadcast it, closing the contract.
204204

205-
The proposal, covenants, and witness statements combine to create a proof of validity on how the contract should be settled. If the platform broadcasts a transaction without a matching validity proof, then the reputation of the platform is damaged.
205+
The proposal, covenants, and vm combine to create a proof of validity. This proof covers how the contract should execute at any moment. There is zero ambiguity left to the `agent`.
206+
207+
Each contract settlement on mainnet will include a valid proof in order to keep our reputation intact.
206208

207209
### Protocol Flow
208210

@@ -269,151 +271,69 @@ In terms of security, speed, and simplicity, we believe this is the best non-cus
269271

270272
## How to Use
271273

272-
### Creating a Signer (for contract members)
273-
274-
Full example: [01_create_signer.ts](test/demo/01_create_signer.ts)
275-
276-
```ts
277-
import { Seed, Signer, Wallet } from '@cmdcode/signer'
274+
This readme will be an mixture of documentation and code examples. The full documentation is still a work in progress.
278275

279-
import { EscrowSigner } from '@scrow/core/client'
276+
The two main resources for example code are here:
280277

281-
const seed = Seed.generate.bytes()
282-
const xpub = 'enter your own xpub here'
278+
[test/client](test/client) : Example usage of the full BitEscrow API.
279+
[test/demo](test/demo) : Step-by-step example of the protocol.
283280

284-
const config = {
285-
hostname : 'http://localhost:3000',
286-
oracle : 'http://172.21.0.3:3000',
287-
signer : new Signer({ seed }),
288-
wallet : new Wallet(xpub)
289-
}
281+
### Protocol Demo
290282

291-
const client = new EscrowSigner(config)
292-
```
283+
Below is a step-by-step guide through the protocol.
293284

294-
### Creating a Client (for third parties)
295-
296-
Full example: [02_create_client.ts](test/demo/02_create_client.ts)
297-
298-
```ts
299-
import { EscrowClient } from '@scrow/core/client'
300-
301-
const config = {
302-
hostname : 'http://localhost:3000',
303-
oracle : 'http://172.21.0.3:3000'
304-
}
285+
> Click on a section to view the example code:
305286
306-
const client = new EscrowClient(config)
307-
```
287+
1. [Create a Client](test/demo/01_create_client.ts)
288+
2. [Create a Signer](test/demo/02_create_signer.ts)
289+
3. [Build a Proposal](test/demo/02_create_proposal.ts)
290+
4. [Roles and Endorsment](test/demo/02_roles_and_endorse.ts)
291+
5. [Create a Contract](test/demo/02_create_contract.ts)
292+
6. [Request a Deposit Accout](test/demo/02_request_account.ts)
293+
7. [Deposit funds into a Contract](test/demo/02_deposit_funds.ts)
294+
8. [Monitor a Contract](test/demo/02_check_contract.ts)
295+
9. [Settle a Contract](test/demo/02_settle_contract.ts)
308296

309-
### Creating a Proposal
297+
### API Demo
310298

311-
```ts
312-
import { EscrowProposal, RolePolicy } from '@scrow/core'
299+
Documentation coming soon!
313300

314-
export const proposal = new EscrowProposal({
315-
title : 'Basic two-party contract with third-party arbitration.',
316-
expires : 14400,
317-
network : 'signet',
318-
schedule : [[ 7200, 'close', 'payout|return' ]],
319-
value : 15000,
320-
})
321-
322-
export const roles : Record<string, RolePolicy> = {
323-
buyer : {
324-
paths : [
325-
[ 'heads', 10000 ],
326-
[ 'draw', 5000 ]
327-
],
328-
programs : [
329-
[ 'endorse', 'close', 'heads|tails', 2 ],
330-
[ 'endorse', 'dispute', 'heads|tails', 1 ]
331-
]
332-
},
333-
seller : {
334-
paths : [
335-
[ 'tails', 10000 ],
336-
[ 'draw', 5000 ]
337-
],
338-
programs : [
339-
[ 'endorse', 'close', 'heads|tails', 2 ],
340-
[ 'endorse', 'dispute', 'heads|tails', 1 ]
341-
]
342-
},
343-
agent : {
344-
payment : 5000,
345-
programs : [
346-
[ 'endorse', 'resolve', 'heads|tails', 1 ]
347-
]
348-
}
349-
}
350-
```
351-
352-
### Joining and Endorsing a Proposal
353-
354-
```ts
355-
const [ alice, bob, carol ] = signers
356-
357-
proposal.join(roles.buyer, alice)
358-
proposal.join(roles.seller, bob)
359-
proposal.join(roles.agent, carol)
360-
361-
const signatures = signers.map(mbr => {
362-
return mbr.endorse.proposal(proposal)
363-
})
364-
```
365-
366-
### Creating a Contract
367-
368-
```ts
369-
const res = await alice.client.contract.create(proposal, signatures)
301+
## Development / Testing
370302

371-
if (!res.ok) throw new Error(res.error)
303+
This project uses the following scripts:
372304

373-
const { contract } = res.data
305+
```md
306+
build : Compiles the contents of `src` folder to `dist`.
307+
demo <chain> : Runs the protocol demo for the provided chain.
308+
load <script> : Executes the script at the provided path.
309+
release : Builds and tests the current source for release.
310+
scratch : Executes the `test/scratch.ts` file.
311+
test : Runs the current test suite in `test/tape.ts`.
374312
```
375313

376-
### Requesting a Deposit Account
314+
Example of running the demo on the mutiny chain (using npm):
377315

378-
```ts
379-
// Request an account for the member to use.
380-
const res = await alice.deposit.request_acct({
381-
locktime : 60 * 60 // 1 hour locktime
382-
})
383-
384-
// Check the response is valid.
385-
if (!res.ok) throw new Error(res.error)
386-
387-
// Unpack some of the terms.
388-
const { account } = res.data
316+
```bash
317+
npm run demo mutiny
389318
```
390319

391-
## Development / Testing
392-
393-
The documentation for development and testing is currently being fleshed out for an open beta release.
320+
> The available chains are mutiny, signet, and testnet. Main chain coming soon!
394321
395-
If you want to see a naive end-to-end demonstration of the of the protocol, you can use the follwoing command:
322+
Example of running the current test suite in verbose mode:
396323

397324
```bash
398-
## Using Yarn:
399-
VERBOSE=true yarn test
400-
## Using NPM:
401325
VERBOSE=true npm run test
402326
```
403327

404-
This should spin up an isolated `regtest` version of Bitcoin core (which comes packaged with the repo), and run a flurry of methods which exercise the entire protocol. The full end-to-end test is located in `test/src/tests/e2e.test.ts`.
328+
Please stay tuned for more documentation and updates!
405329

406-
Over the next month, we'll be adding more concrete examples using the `EscrowClient`, plus opening our escrow server to public beta on `testnet` and `mutinynet`.
330+
## Questions / Issues
407331

408-
Please stay tuned!
409-
410-
## Issues / Questions / Comments
411-
412-
Please feel free to post any kind of issue on the tracker. All feedback is welcome.
332+
Please feel free to post questions or comments on the issue board. All feedback is welcome.
413333

414334
## Contribution
415335

416-
Help wanted. All contributions are welcome. :-)
336+
Help wanted. All contributions are welcome!
417337

418338
## Resources
419339

@@ -467,8 +387,14 @@ Not a run-time dependency, but I use this to incorporate bitcoin core directly i
467387

468388
https://github.com/cmdruid/core-cmd
469389

390+
**signer**
391+
392+
Reference implementation of the new hybrid signing device / wallet we are building for BitEscrow. The documentation needs to be updated. WIP.
393+
394+
https://github.com/cmdruid/signer
395+
470396
# Footnote
471397

472-
My inspiration for this project comes from the Bitcoin space, and the incredibly talented people that keep it alive. From them I gained my knowledge and spirit, and for that I am grateful.
398+
My inspiration for this project comes from the Bitcoin space, and the incredibly talented people that contribute. I will be forever grateful for their knowledge, kindness and spirit.
473399

474-
I wish for Bitcoin to win all the marbles; and become the new global reserve marbles that we all fight over. I firmly believe it will make the world a better place, and bring society towards a new golden age. Maybe we will become space-faring apes that reach beyond the moon.
400+
I wish for Bitcoin to win all the marbles; and be the new global reserve marbles that we fight over. I firmly believe a better money system will make the world a better place. Maybe we will reach beyond the moon.

docs/client.md

Lines changed: 0 additions & 119 deletions
This file was deleted.

0 commit comments

Comments
 (0)