|
1 | 1 | import { FormattedOfflineVaultTxInfo, BackupKeyRecoveryTransansaction } from '@bitgo/abstract-utxo'; |
2 | 2 | import { AbstractEthLikeNewCoins } from '@bitgo/abstract-eth'; |
3 | 3 | import { CoinFamily } from '@bitgo/statics'; |
4 | | -import { BaseCoin, BitGo } from 'bitgo'; |
| 4 | +import { BaseCoin } from 'bitgo'; |
5 | 5 | import { AbstractUtxoCoin, Eos, Stx, Xtz } from 'bitgo/dist/types/src/v2/coins'; |
6 | | -import { RequestTracer } from '@bitgo/sdk-core'; |
7 | | -import { EnclavedExpressClient } from '../api/master/clients/enclavedExpressClient'; |
8 | 6 |
|
9 | 7 | export function isEthLikeCoin(coin: BaseCoin): coin is AbstractEthLikeNewCoins { |
10 | 8 | const isEthPure = isFamily(coin, CoinFamily.ETH); |
@@ -63,67 +61,3 @@ export function isFormattedOfflineVaultTxInfo( |
63 | 61 | ): obj is FormattedOfflineVaultTxInfo { |
64 | 62 | return obj && 'txInfo' in obj && 'txHex' in obj && 'feeInfo' in obj; |
65 | 63 | } |
66 | | - |
67 | | -/** |
68 | | - * Fetch wallet and signing keychain, with validation for source and pubkey. |
69 | | - * Throws with a clear error if not found or mismatched. |
70 | | - */ |
71 | | -export async function getWalletAndSigningKeychain({ |
72 | | - bitgo, |
73 | | - coin, |
74 | | - walletId, |
75 | | - params, |
76 | | - reqId, |
77 | | - KeyIndices, |
78 | | -}: { |
79 | | - bitgo: BitGo; |
80 | | - coin: string; |
81 | | - walletId: string; |
82 | | - params: { source: 'user' | 'backup'; pubkey?: string }; |
83 | | - reqId: RequestTracer; |
84 | | - KeyIndices: { USER: number; BACKUP: number; BITGO: number }; |
85 | | -}) { |
86 | | - const baseCoin = bitgo.coin(coin); |
87 | | - |
88 | | - const wallet = await baseCoin.wallets().get({ id: walletId, reqId }); |
89 | | - |
90 | | - if (!wallet) { |
91 | | - throw new Error(`Wallet ${walletId} not found`); |
92 | | - } |
93 | | - |
94 | | - const keyIdIndex = params.source === 'user' ? KeyIndices.USER : KeyIndices.BACKUP; |
95 | | - const signingKeychain = await baseCoin.keychains().get({ |
96 | | - id: wallet.keyIds()[keyIdIndex], |
97 | | - }); |
98 | | - |
99 | | - if (!signingKeychain || !signingKeychain.pub) { |
100 | | - throw new Error(`Signing keychain for ${params.source} not found`); |
101 | | - } |
102 | | - |
103 | | - if (params.pubkey && params.pubkey !== signingKeychain.pub) { |
104 | | - throw new Error(`Pub provided does not match the keychain on wallet for ${params.source}`); |
105 | | - } |
106 | | - |
107 | | - return { baseCoin, wallet, signingKeychain }; |
108 | | -} |
109 | | - |
110 | | -/** |
111 | | - * Create a custom signing function that delegates to enclavedExpressClient.signMultisig. |
112 | | - */ |
113 | | -export function makeCustomSigningFunction({ |
114 | | - enclavedExpressClient, |
115 | | - source, |
116 | | - pub, |
117 | | -}: { |
118 | | - enclavedExpressClient: EnclavedExpressClient; |
119 | | - source: 'user' | 'backup'; |
120 | | - pub: string; |
121 | | -}) { |
122 | | - return async function customSigningFunction(signParams: any) { |
123 | | - return enclavedExpressClient.signMultisig({ |
124 | | - txPrebuild: signParams.txPrebuild, |
125 | | - source, |
126 | | - pub, |
127 | | - }); |
128 | | - }; |
129 | | -} |
0 commit comments