11import { Key , SerializedKeyPair } from 'openpgp' ;
22import { IRequestTracer } from '../../../api' ;
3- import { KeychainsTriplet , ParsedTransaction , TransactionParams } from '../../baseCoin' ;
3+ import { type ITransactionRecipient , KeychainsTriplet , ParsedTransaction , TransactionParams } from '../../baseCoin' ;
44import { ApiKeyShare , Keychain } from '../../keychain' ;
55import { ApiVersion , Memo , WalletType } from '../../wallet' ;
66import { EDDSA , GShare , Signature , SignShare } from '../../../account-lib/mpc/tss' ;
@@ -532,16 +532,6 @@ export interface EncryptedSignerShareRecord extends ShareBaseRecord {
532532 type : EncryptedSignerShareType ;
533533}
534534
535- export type TSSParamsWithPrv = TSSParams & {
536- prv : string ;
537- mpcv2PartyId ?: 0 | 1 ;
538- } ;
539-
540- export type TSSParamsForMessageWithPrv = TSSParamsForMessage & {
541- prv : string ;
542- mpcv2PartyId ?: 0 | 1 ;
543- } ;
544-
545535export type BitgoPubKeyType = 'nitro' | 'onprem' ;
546536
547537export type TSSParams = {
@@ -557,6 +547,60 @@ export type TSSParamsForMessage = TSSParams & {
557547 bufferToSign : Buffer ;
558548} ;
559549
550+ /** At least one recipient (when using `recipientSource: TssTxRecipientSource.Explicit`). */
551+ export type NonEmptyRecipientList = [ ITransactionRecipient , ...ITransactionRecipient [ ] ] ;
552+
553+ /** txParams including a non-empty recipients list for strict signing verification typing. */
554+ export type TransactionParamsWithMandatoryRecipients = TransactionParams & {
555+ recipients : NonEmptyRecipientList ;
556+ } ;
557+
558+ export const TssTxRecipientSource = {
559+ /** Require txParams.recipients with at least one entry (enforced by TypeScript for this branch). */
560+ Explicit : 'explicit' ,
561+ /**
562+ * Default: txParams may be omitted or partial; verification uses coin-specific rules
563+ * (for example recipients from txRequest context).
564+ */
565+ Resolved : 'resolved' ,
566+ } as const ;
567+
568+ export type TssTxRecipientSource = ( typeof TssTxRecipientSource ) [ keyof typeof TssTxRecipientSource ] ;
569+
570+ export type TssSignTxExplicitRecipientParams = {
571+ txRequest : string | TxRequest ;
572+ reqId : IRequestTracer ;
573+ apiVersion ?: ApiVersion ;
574+ recipientSource : typeof TssTxRecipientSource . Explicit ;
575+ txParams : TransactionParamsWithMandatoryRecipients ;
576+ } ;
577+
578+ export type TssSignTxResolvedRecipientParams = {
579+ txRequest : string | TxRequest ;
580+ reqId : IRequestTracer ;
581+ apiVersion ?: ApiVersion ;
582+ recipientSource ?: typeof TssTxRecipientSource . Resolved ;
583+ txParams ?: TransactionParams ;
584+ } ;
585+
586+ /**
587+ * Parameters for TSS transaction signing ({@link ITssUtils.signTxRequest}).
588+ * Set {@link TssTxRecipientSource.Explicit} to require a non-empty txParams.recipients array at compile time.
589+ */
590+ export type TssSignTxRequestParams = TssSignTxExplicitRecipientParams | TssSignTxResolvedRecipientParams ;
591+
592+ export type TssSignTxRequestParamsWithPrv = TssSignTxRequestParams & {
593+ prv : string ;
594+ mpcv2PartyId ?: 0 | 1 ;
595+ } ;
596+
597+ export type TSSParamsWithPrv = TssSignTxRequestParamsWithPrv ;
598+
599+ export type TSSParamsForMessageWithPrv = TSSParamsForMessage & {
600+ prv : string ;
601+ mpcv2PartyId ?: 0 | 1 ;
602+ } ;
603+
560604export interface BitgoHeldBackupKeyShare {
561605 commonKeychain ?: string ;
562606 id : string ;
@@ -714,7 +758,7 @@ export interface ITssUtils<KeyShare = EDDSA.KeyShare> {
714758 originalPasscodeEncryptionCode ?: string ;
715759 isThirdPartyBackup ?: boolean ;
716760 } ) : Promise < KeychainsTriplet > ;
717- signTxRequest ( params : { txRequest : string | TxRequest ; prv : string ; reqId : IRequestTracer } ) : Promise < TxRequest > ;
761+ signTxRequest ( params : TssSignTxRequestParamsWithPrv ) : Promise < TxRequest > ;
718762 signTxRequestForMessage ( params : TSSParams ) : Promise < TxRequest > ;
719763 signEddsaTssUsingExternalSigner (
720764 txRequest : string | TxRequest ,
0 commit comments