diff --git a/ironfish/src/rpc/routes/wallet/__importTestCases__/2p6p0_json_multisig.txt b/ironfish/src/rpc/routes/wallet/__importTestCases__/2p6p0_json_multisig.txt new file mode 100644 index 0000000000..fa5508d71a --- /dev/null +++ b/ironfish/src/rpc/routes/wallet/__importTestCases__/2p6p0_json_multisig.txt @@ -0,0 +1 @@ +{"version":4,"name":"multisig-test-0","spendingKey":null,"viewKey":"293d96b68049736f3cf75eae4b34e0cb7ef4123e0a932d0950ed29993c8f320732217bef15f3b4fb91604456e36d473036b2b71c55ae2792154164849894cfb2","incomingViewKey":"cf53348203c66c3196580d47e32f57e0c9096b4a1e15d5ddc7f4d0c51374d703","outgoingViewKey":"3ceb1aae767b95524ef4352c95ed5e45fb654d9466d22c00157723a3f03d1fb2","publicAddress":"4d740a396b33cea2755342847a3869c1f7b693f5b3839298344c9b0548151c98","createdAt":{"hash":"000000df3bee7c0486981e1c41776bd2e3272a96bf2ca65f5b77a855b8effdf8","sequence":66},"multisigKeys":{"publicKeyPackage":"a600000000c3d2051e02fa165dea65cfb13778b4b6b2ef4fad6045f1ac72e33d122c303ff08b1cf101067bf9c0e2f1cd4b422e930531173f2baaf865b61afaecffcfae20354445635f57a38ba803ede7410f01bba3e18cc043ad504690c88dff3b45d2ba64d05c92c50a23caf37a66cf7a18bfb7390b94fc508a5c8c5027c4f1b39f4f0336f9740a8a69293d96b68049736f3cf75eae4b34e0cb7ef4123e0a932d0950ed29993c8f32070200000072c60942feac595aa83bb0856c264dfc070b8f3c765ca9434054fde21a2806938184b7c5421c5efa9e8f4ba3295ffc229fa05925f08f6ae9837ba4ac6b720a2a44a10c8e761faa2534149c33c7864c4b780d4d83409e5ca3d9428f1f09b0b0476137feb8a8f73cb3d2515110f1b82e88a2af2708a2961ef6c9e15541e288dcad03723729d1b6af022a4c5d67e126a3a79700d5b346577d2ecb1d3b543f4f4f18f2bb43850fb4fd8b554732a11de1b8f0ab65717f01b79c8fd5b459507a65e78c5432454de9de1722f33846ce2bead0b9ad50290edb96b065f2cbc80762518d39a209de1c3e7d998314b3fc9380cdd3b98bd363ec486317bd1e72b8628e61163403040200","identity":"723729d1b6af022a4c5d67e126a3a79700d5b346577d2ecb1d3b543f4f4f18f2bb43850fb4fd8b554732a11de1b8f0ab65717f01b79c8fd5b459507a65e78c5432454de9de1722f33846ce2bead0b9ad50290edb96b065f2cbc80762518d39a209de1c3e7d998314b3fc9380cdd3b98bd363ec486317bd1e72b8628e6116340304"},"proofAuthorizingKey":"c1ecf0f5baa2656f358154decb9011383dccbee08e06f1d9d308d992d03fcf0a"} \ No newline at end of file diff --git a/ironfish/src/rpc/routes/wallet/serializers.ts b/ironfish/src/rpc/routes/wallet/serializers.ts index 477256564f..c477c27b68 100644 --- a/ironfish/src/rpc/routes/wallet/serializers.ts +++ b/ironfish/src/rpc/routes/wallet/serializers.ts @@ -5,6 +5,7 @@ import { Config } from '../../../fileStores' import { BufferUtils, CurrencyUtils } from '../../../utils' import { Account, Wallet } from '../../../wallet' import { + isMultisigHardwareSignerImport, isMultisigSignerImport, isMultisigSignerTrustedDealerImport, MultisigKeysImport, @@ -107,6 +108,13 @@ export function deserializeRpcAccountMultisigKeys( } } + if (isMultisigHardwareSignerImport(rpcMultisigKeys)) { + return { + publicKeyPackage: rpcMultisigKeys.publicKeyPackage, + identity: rpcMultisigKeys.identity, + } + } + if (isMultisigSignerTrustedDealerImport(rpcMultisigKeys)) { return { publicKeyPackage: rpcMultisigKeys.publicKeyPackage, diff --git a/ironfish/src/wallet/exporter/accountImport.ts b/ironfish/src/wallet/exporter/accountImport.ts index 57ca171f84..3652cc0f47 100644 --- a/ironfish/src/wallet/exporter/accountImport.ts +++ b/ironfish/src/wallet/exporter/accountImport.ts @@ -11,6 +11,7 @@ import { isValidSpendingKey, isValidViewKey, } from '../validator' +import { isSignerMultisig } from '../walletdb/multisigKeys' import { MultisigKeysImport } from './multisig' export type AccountImport = { @@ -58,7 +59,7 @@ export function toAccountImport( if (viewOnly) { value.spendingKey = null - if (value.multisigKeys) { + if (value.multisigKeys && isSignerMultisig(value.multisigKeys)) { value.multisigKeys = { publicKeyPackage: value.multisigKeys.publicKeyPackage, } diff --git a/ironfish/src/wallet/exporter/multisig.ts b/ironfish/src/wallet/exporter/multisig.ts index 4215bc44e1..df2c871744 100644 --- a/ironfish/src/wallet/exporter/multisig.ts +++ b/ironfish/src/wallet/exporter/multisig.ts @@ -1,7 +1,11 @@ /* 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 { MultisigKeys, MultisigSigner } from '../interfaces/multisigKeys' +import { + MultisigHardwareSigner, + MultisigKeys, + MultisigSigner, +} from '../interfaces/multisigKeys' export interface MultisigSignerTrustedDealerImport { identity: string @@ -18,8 +22,14 @@ export function isMultisigSignerImport(data: MultisigKeysImport): data is Multis return 'secret' in data } +export function isMultisigHardwareSignerImport( + data: MultisigKeysImport, +): data is MultisigHardwareSigner { + return 'identity' in data && !('keyPackage' in data) +} + export function isMultisigSignerTrustedDealerImport( data: MultisigKeysImport, ): data is MultisigSignerTrustedDealerImport { - return 'identity' in data + return 'identity' in data && 'keyPackage' in data }