Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
cmd committed Jan 26, 2024
1 parent f0e93b8 commit a6388a9
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/client/class/signer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Buff } from '@cmdcode/buff'
import { Buff, Bytes } from '@cmdcode/buff'
import { Signer, Wallet } from '@cmdcode/signer'
import { SignerConfig } from '@/client/types.js'
import { EscrowClient } from './client.js'

import deposit_api from '../api/depositor.js'
Expand All @@ -9,16 +8,35 @@ import proposal_api from '../api/proposal.js'
import request_api from '../api/request.js'
import witness_api from '../api/witness.js'

import {
ClientConfig,
SignerConfig
} from '@/client/types.js'

import {
CredSignerAPI,
Network,
WalletAPI
} from '@/types/index.js'

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

export class EscrowSigner {

static create (
config : ClientConfig,
seed : Bytes,
xpub ?: string
) {
const signer = new Signer({ seed })
const wallet = (xpub !== undefined)
? new Wallet(xpub)
: Wallet.generate({ seed, network : config.network as Network })
return new EscrowSigner({ ...config, signer, wallet })
}

static load (
config : ClientConfig,
password : string,
payload : string
) {
Expand All @@ -28,7 +46,7 @@ export class EscrowSigner {
const pass = Buff.str(password)
const signer = Signer.restore(pass, encdata)
const wallet = new Wallet(xpub)
return new EscrowSigner({ signer, wallet })
return new EscrowSigner({ ...config, signer, wallet })
}

readonly _client : EscrowClient
Expand Down

0 comments on commit a6388a9

Please sign in to comment.