Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes createSigningShare RPC to take an account name #4690

Merged
merged 2 commits into from
Feb 6, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions ironfish/src/rpc/routes/wallet/multisig/createSigningShare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
import { createSigningShare, UnsignedTransaction } from '@ironfish/rust-nodejs'
import * as yup from 'yup'
import { AssertMultiSig } from '../../../../wallet'
import { AssertIsSignerMultiSig } from '../../../../wallet/account/encoder/multiSigKeys'
import { ApiNamespace } from '../../namespaces'
import { routes } from '../../router'
import { AssertHasRpcContext } from '../../rpcContext'
import { getAccount } from '../utils'

export type CreateSigningShareRequest = {
account: string
signingPackage: string
keyPackage: string
unsignedTransaction: string
seed: number // TODO: remove when we have deterministic nonces
}
Expand All @@ -19,8 +23,8 @@ export type CreateSigningShareResponse = {

export const CreateSigningShareRequestSchema: yup.ObjectSchema<CreateSigningShareRequest> = yup
.object({
account: yup.string().defined(),
signingPackage: yup.string().defined(),
keyPackage: yup.string().defined(),
unsignedTransaction: yup.string().defined(),
seed: yup.number().defined(),
})
Expand All @@ -36,13 +40,19 @@ export const CreateSigningShareResponseSchema: yup.ObjectSchema<CreateSigningSha
routes.register<typeof CreateSigningShareRequestSchema, CreateSigningShareResponse>(
`${ApiNamespace.wallet}/multisig/createSigningShare`,
CreateSigningShareRequestSchema,
(request, _context): void => {
(request, node): void => {
AssertHasRpcContext(request, node, 'wallet')

const account = getAccount(node.wallet, request.data.account)
AssertMultiSig(account)
AssertIsSignerMultiSig(account.multiSigKeys)

const unsigned = new UnsignedTransaction(
Buffer.from(request.data.unsignedTransaction, 'hex'),
)
const result = createSigningShare(
request.data.signingPackage,
request.data.keyPackage,
account.multiSigKeys.keyPackage,
unsigned.publicKeyRandomness(),
request.data.seed,
)
Expand Down
Loading