Skip to content

Commit

Permalink
fixes wallet/multisig/getIdentity for undefined secrets (#5388)
Browse files Browse the repository at this point in the history
uses walletDb.getMultisigIdentityByName instead of looking up secret by name

since some identities may not have secrets (i.e., identities created using
Ledger) these identities won't be found when looking identities up using
walletDb.getMultisigSecretByName
  • Loading branch information
hughy authored Sep 19, 2024
1 parent 336bc06 commit a57ca30
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions ironfish/src/rpc/routes/wallet/multisig/getIdentity.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import { multisig } from '@ironfish/rust-nodejs'
import * as yup from 'yup'
import { RpcValidationError } from '../../../adapters/errors'
import { ApiNamespace } from '../../namespaces'
Expand Down Expand Up @@ -36,13 +35,11 @@ routes.register<typeof GetIdentityRequestSchema, GetIdentityResponse>(

const { name } = request.data

const secret = await context.wallet.walletDb.getMultisigSecretByName(name)
if (secret === undefined) {
const identity = await context.wallet.walletDb.getMultisigIdentityByName(name)
if (identity === undefined) {
throw new RpcValidationError(`No identity found with name ${name}`, 404)
}

const identity = new multisig.ParticipantSecret(secret).toIdentity()

request.end({ identity: identity.serialize().toString('hex') })
request.end({ identity: identity.toString('hex') })
},
)

0 comments on commit a57ca30

Please sign in to comment.