diff --git a/modules/abstract-utxo/src/keychains.ts b/modules/abstract-utxo/src/keychains.ts index 60f73ac60e..bb5a77a413 100644 --- a/modules/abstract-utxo/src/keychains.ts +++ b/modules/abstract-utxo/src/keychains.ts @@ -1,9 +1,10 @@ +import assert from 'assert'; import * as t from 'io-ts'; import * as utxolib from '@bitgo/utxo-lib'; import { IRequestTracer, IWallet, KeyIndices, promiseProps, Triple } from '@bitgo/sdk-core'; import { AbstractUtxoCoin } from './abstractUtxoCoin'; -import assert from 'assert'; +import { UtxoWallet } from './wallet'; /* @@ -64,3 +65,17 @@ export async function fetchKeychains( assert(UtxoNamedKeychains.is(result)); return result; } + +export const KeySignatures = t.partial({ + backupPub: t.string, + bitgoPub: t.string, +}); + +export type KeySignatures = t.TypeOf; + +export function getKeySignatures(wallet: UtxoWallet): KeySignatures | undefined { + if (t.partial({ keySignatures: KeySignatures }).is(wallet._wallet)) { + return wallet._wallet.keySignatures; + } + return undefined; +} diff --git a/modules/abstract-utxo/src/transaction/fixedScript/parseTransaction.ts b/modules/abstract-utxo/src/transaction/fixedScript/parseTransaction.ts index d7b2fa435e..ef719eb0d3 100644 --- a/modules/abstract-utxo/src/transaction/fixedScript/parseTransaction.ts +++ b/modules/abstract-utxo/src/transaction/fixedScript/parseTransaction.ts @@ -11,7 +11,7 @@ import { ParsedTransaction, ParseTransactionOptions, } from '../../abstractUtxoCoin'; -import { fetchKeychains, toKeychainTriple, UtxoKeychain, UtxoNamedKeychains } from '../../keychains'; +import { fetchKeychains, getKeySignatures, toKeychainTriple, UtxoKeychain, UtxoNamedKeychains } from '../../keychains'; /** * @param first @@ -206,7 +206,7 @@ export async function parseTransaction( return { keychains, - keySignatures: _.get(wallet, '_wallet.keySignatures', {}), + keySignatures: getKeySignatures(wallet) ?? {}, outputs: allOutputDetails, missingOutputs, explicitExternalOutputs,