Skip to content

Commit

Permalink
Upgrade wallet:multisig:sign to use ui.ledger
Browse files Browse the repository at this point in the history
This uses the new ledger UI action so that it will wait for the user to connect and unlock their ledger.
  • Loading branch information
NullSoldier committed Oct 7, 2024
1 parent 5f1d60d commit ff5406e
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions ironfish-cli/src/commands/wallet/multisig/sign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,6 @@ export class SignMultisigTransactionCommand extends IronfishCommand {

if (flags.ledger) {
ledger = new LedgerMultiSigner(this.logger)
try {
await ledger.connect()
} catch (e) {
if (e instanceof Error) {
this.error(e.message)
} else {
throw e
}
}
}

let multisigAccountName: string
Expand Down Expand Up @@ -387,11 +378,16 @@ export class SignMultisigTransactionCommand extends IronfishCommand {
const signingPackage = new multisig.SigningPackage(Buffer.from(signingPackageString, 'hex'))

if (ledger) {
const frostSignatureShare = await ledger.dkgSign(
unsignedTransaction.publicKeyRandomness(),
signingPackage.frostSigningPackage().toString('hex'),
unsignedTransaction.hash().toString('hex'),
)
const frostSignatureShare = await ui.ledger({
ledger,
message: 'Sign Transaction',
action: () =>
ledger.dkgSign(
unsignedTransaction.publicKeyRandomness(),
signingPackage.frostSigningPackage().toString('hex'),
unsignedTransaction.hash().toString('hex'),
),
})

signatureShare = multisig.SignatureShare.fromFrost(
frostSignatureShare,
Expand Down Expand Up @@ -515,7 +511,11 @@ export class SignMultisigTransactionCommand extends IronfishCommand {

let commitment
if (ledger) {
await ledger.reviewTransaction(unsignedTransactionHex)
await ui.ledger({
ledger,
message: 'Review Transaction',
action: () => ledger.reviewTransaction(unsignedTransactionHex),
})

commitment = await this.createSigningCommitmentWithLedger(
ledger,
Expand Down Expand Up @@ -545,7 +545,11 @@ export class SignMultisigTransactionCommand extends IronfishCommand {
transactionHash: Buffer,
signers: string[],
): Promise<string> {
const rawCommitments = await ledger.dkgGetCommitments(transactionHash.toString('hex'))
const rawCommitments = await ui.ledger({
ledger,
message: 'Get Commitments',
action: () => ledger.dkgGetCommitments(transactionHash.toString('hex')),
})

const sigingCommitment = multisig.SigningCommitment.fromRaw(
participant.identity,
Expand Down

0 comments on commit ff5406e

Please sign in to comment.