Skip to content

Commit

Permalink
upgrades multisig signing commands to use ui.ledger (#5670)
Browse files Browse the repository at this point in the history
the ui.ledger function includes error handling and retry logic that will be
helpful when signing multisig transactions using the dkg ledger app
  • Loading branch information
hughy authored Nov 25, 2024
1 parent cb31f8d commit baf4107
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 20 deletions.
16 changes: 6 additions & 10 deletions ironfish-cli/src/commands/wallet/multisig/commitment/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,16 @@ export class CreateSigningCommitmentCommand extends IronfishCommand {
signers: string[],
): Promise<void> {
const ledger = new LedgerMultiSigner()
try {
await ledger.connect()
} catch (e) {
if (e instanceof Error) {
this.error(e.message)
} else {
throw e
}
}

const identityResponse = await client.wallet.multisig.getIdentity({ name: participantName })
const identity = identityResponse.content.identity

const rawCommitments = await ledger.dkgGetCommitments(unsignedTransaction)
const rawCommitments = await ui.ledger({
ledger,
message: 'Get Commitments',
approval: true,
action: () => ledger.dkgGetCommitments(unsignedTransaction),
})

const signingCommitment = multisig.SigningCommitment.fromRaw(
identity,
Expand Down
16 changes: 6 additions & 10 deletions ironfish-cli/src/commands/wallet/multisig/signature/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,16 @@ export class CreateSignatureShareCommand extends IronfishCommand {
frostSigningPackage: string,
): Promise<void> {
const ledger = new LedgerMultiSigner()
try {
await ledger.connect()
} catch (e) {
if (e instanceof Error) {
this.error(e.message)
} else {
throw e
}
}

const identityResponse = await client.wallet.multisig.getIdentity({ name: participantName })
const identity = identityResponse.content.identity

const frostSignatureShare = await ledger.dkgSign(unsignedTransaction, frostSigningPackage)
const frostSignatureShare = await ui.ledger({
ledger,
message: 'Sign Transaction',
approval: true,
action: () => ledger.dkgSign(unsignedTransaction, frostSigningPackage),
})

const signatureShare = multisig.SignatureShare.fromFrost(
frostSignatureShare,
Expand Down

0 comments on commit baf4107

Please sign in to comment.