Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
cmd committed Jan 27, 2024
1 parent d6006b3 commit 80afc45
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 11 deletions.
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,13 +415,13 @@ Before making a deposit, we have to request an account from the escrow server. E
const pubkey = a_signer.pubkey
const locktime = 60 * 60 // 1 hour locktime
// Fetch a new account from the server.
const res = await client.deposit.request_acct(pubkey, locktime)
const res = await client.deposit.request({ pubkey, locktime })
// Check the response is valid.
if (!res.ok) throw new Error(res.error)
// Unpack the account data.
const { account } = res.data
// Validate the account is issued by the escrow server.
a_signer.deposit.verify_acct(account)
a_signer.deposit.verify_account(account)
```

> For more information on the `account` interface, [click here](docs/deposit.md).
Expand Down Expand Up @@ -519,6 +519,21 @@ export const settled_contract = res.data.contract
### API Demo

```md
/contract
/create
/fund
/list
/cancel
/read
/submit
/witness
deposit/
witness/
status
terms
```

Documentation coming soon!

## Development / Testing
Expand Down
2 changes: 1 addition & 1 deletion src/client/class/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function get_fetcher (
// Initialize the options object.
const req = new Request(url, init)
if (token !== undefined) {
req.headers.append('token', token)
req.headers.append('Authorization', 'Token ' + token)
}
// Run the fetcher method.
const res = await fetcher(req)
Expand Down
4 changes: 2 additions & 2 deletions src/client/class/signer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export class EscrowSigner {
payload : string
) {
const bytes = Buff.bech32(payload)
const encdata = bytes.subarray(0, 96)
const xpub = bytes.subarray(96).b58chk
const encdata = bytes.subarray(0, 64)
const xpub = bytes.subarray(64).b58chk
const pass = Buff.str(password)
const signer = Signer.restore(pass, encdata)
const wallet = new Wallet(xpub)
Expand Down
17 changes: 15 additions & 2 deletions test/scratch.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
import { Buff } from "@cmdcode/buff";
import { EscrowSigner } from '@scrow/core'
import { Buff } from '@cmdcode/buff'

console.log(Buff.str('alice').digest.hex)
const seed = Buff.str('alice').digest

console.log('seed:', seed.hex)

const signer = EscrowSigner.create({}, seed)

const backup = signer.save('test')

console.log('backup:', backup)

const signer2 = EscrowSigner.load({}, 'test', backup)

console.log('is restored:', signer.pubkey === signer2.pubkey)
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@
"@cmdcode/buff" "^2.2.4"
"@cmdcode/crypto-tools" "^2.6.10"

"@cmdcode/signer@1.3.11":
version "1.3.11"
resolved "https://registry.yarnpkg.com/@cmdcode/signer/-/signer-1.3.11.tgz#3d76cebdb01e0ff976ca0a0eb891cfe7c1fdc9e0"
integrity sha512-knsG0ilHzKEcIB7mh0iYaQRVVXUIbpxsgdkDTOgg+lvKsYrf/6hsJ7+mOiB4dJUaz7mlr6EUtq58XuVDToRazA==
"@cmdcode/signer@1.4.0":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@cmdcode/signer/-/signer-1.4.0.tgz#a8b3b89cd047fa0da2cdb661904c3dfb9caac0b5"
integrity sha512-jqMjF8SGn0M6O7qWY4KwnYXUQUJsB7z8jFtgrvgzSyq90DxUIuAnwI20L+YICrWDULihnfPgiQVkWq2hHnh1FA==
dependencies:
"@cmdcode/buff" "^2.2.4"
"@cmdcode/crypto-tools" "^2.7.5"
Expand Down

0 comments on commit 80afc45

Please sign in to comment.