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

Commit a6388a9

Browse files
author
cmd
committed
update
1 parent f0e93b8 commit a6388a9

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/client/class/signer.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { Buff } from '@cmdcode/buff'
1+
import { Buff, Bytes } from '@cmdcode/buff'
22
import { Signer, Wallet } from '@cmdcode/signer'
3-
import { SignerConfig } from '@/client/types.js'
43
import { EscrowClient } from './client.js'
54

65
import deposit_api from '../api/depositor.js'
@@ -9,16 +8,35 @@ import proposal_api from '../api/proposal.js'
98
import request_api from '../api/request.js'
109
import witness_api from '../api/witness.js'
1110

11+
import {
12+
ClientConfig,
13+
SignerConfig
14+
} from '@/client/types.js'
15+
1216
import {
1317
CredSignerAPI,
18+
Network,
1419
WalletAPI
1520
} from '@/types/index.js'
1621

1722
const DEFAULT_IDXGEN = () => Buff.now(4).num
1823

1924
export class EscrowSigner {
2025

26+
static create (
27+
config : ClientConfig,
28+
seed : Bytes,
29+
xpub ?: string
30+
) {
31+
const signer = new Signer({ seed })
32+
const wallet = (xpub !== undefined)
33+
? new Wallet(xpub)
34+
: Wallet.generate({ seed, network : config.network as Network })
35+
return new EscrowSigner({ ...config, signer, wallet })
36+
}
37+
2138
static load (
39+
config : ClientConfig,
2240
password : string,
2341
payload : string
2442
) {
@@ -28,7 +46,7 @@ export class EscrowSigner {
2846
const pass = Buff.str(password)
2947
const signer = Signer.restore(pass, encdata)
3048
const wallet = new Wallet(xpub)
31-
return new EscrowSigner({ signer, wallet })
49+
return new EscrowSigner({ ...config, signer, wallet })
3250
}
3351

3452
readonly _client : EscrowClient

0 commit comments

Comments
 (0)