Skip to content

Commit 35fdca6

Browse files
Merge pull request #5281 from BitGo/BTC-1450.impl-getKeySignatures
feat(abstract-utxo): add getKeySignatures function
2 parents 29d3d55 + cbbf6e3 commit 35fdca6

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

modules/abstract-utxo/src/keychains.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import assert from 'assert';
12
import * as t from 'io-ts';
23
import * as utxolib from '@bitgo/utxo-lib';
34
import { IRequestTracer, IWallet, KeyIndices, promiseProps, Triple } from '@bitgo/sdk-core';
45

56
import { AbstractUtxoCoin } from './abstractUtxoCoin';
6-
import assert from 'assert';
7+
import { UtxoWallet } from './wallet';
78

89
/*
910
@@ -64,3 +65,17 @@ export async function fetchKeychains(
6465
assert(UtxoNamedKeychains.is(result));
6566
return result;
6667
}
68+
69+
export const KeySignatures = t.partial({
70+
backupPub: t.string,
71+
bitgoPub: t.string,
72+
});
73+
74+
export type KeySignatures = t.TypeOf<typeof KeySignatures>;
75+
76+
export function getKeySignatures(wallet: UtxoWallet): KeySignatures | undefined {
77+
if (t.partial({ keySignatures: KeySignatures }).is(wallet._wallet)) {
78+
return wallet._wallet.keySignatures;
79+
}
80+
return undefined;
81+
}

modules/abstract-utxo/src/transaction/fixedScript/parseTransaction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
ParsedTransaction,
1212
ParseTransactionOptions,
1313
} from '../../abstractUtxoCoin';
14-
import { fetchKeychains, toKeychainTriple, UtxoKeychain, UtxoNamedKeychains } from '../../keychains';
14+
import { fetchKeychains, getKeySignatures, toKeychainTriple, UtxoKeychain, UtxoNamedKeychains } from '../../keychains';
1515

1616
/**
1717
* @param first
@@ -206,7 +206,7 @@ export async function parseTransaction<TNumber extends bigint | number>(
206206

207207
return {
208208
keychains,
209-
keySignatures: _.get(wallet, '_wallet.keySignatures', {}),
209+
keySignatures: getKeySignatures(wallet) ?? {},
210210
outputs: allOutputDetails,
211211
missingOutputs,
212212
explicitExternalOutputs,

0 commit comments

Comments
 (0)