@@ -14,7 +14,7 @@ import {
1414 State ,
1515 Type ,
1616} from '../pendingApproval' ;
17- import { RequestTracer } from '../utils' ;
17+ import { RequestTracer , RequestType } from '../utils' ;
1818import { IWallet } from '../wallet' ;
1919import { BuildParams } from '../wallet/BuildParams' ;
2020import { IRequestTracer } from '../../api' ;
@@ -23,6 +23,8 @@ import EddsaUtils from '../utils/tss/eddsa';
2323import { EcdsaMPCv2Utils , EcdsaUtils } from '../utils/tss/ecdsa' ;
2424import { KeyShare as EcdsaKeyShare } from '../utils/tss/ecdsa/types' ;
2525import { KeyShare as EddsaKeyShare } from '../utils/tss/eddsa/types' ;
26+ import { sendTxRequest } from '../tss/common' ;
27+ import assert from 'assert' ;
2628
2729type PreApproveResult = {
2830 txHex : string ;
@@ -341,10 +343,17 @@ export class PendingApproval implements IPendingApproval {
341343 *
342344 * Therefore, if neither of these is true, the transaction cannot be recreated, which is reflected in the if
343345 * statement below.
346+ *
347+ * Lightning transactions cannot be recreated.
344348 */
345349 private canRecreateTransaction ( params : ApproveOptions ) : boolean {
346350 const isColdWallet = ! ! _ . get ( this . wallet , '_wallet.isCold' ) ;
347351 const isOFCWallet = this . baseCoin . getFamily ( ) === 'ofc' ; // Off-chain transactions don't need to be rebuilt
352+ const isLightningWallet = this . baseCoin . getFamily ( ) === 'lnbtc' ;
353+ if ( isLightningWallet ) {
354+ return false ;
355+ }
356+
348357 if ( ! params . xprv && ! ( params . walletPassphrase && ! isColdWallet && ! isOFCWallet ) ) {
349358 return false ;
350359 }
@@ -420,13 +429,22 @@ export class PendingApproval implements IPendingApproval {
420429 private async postApprove ( params : ApproveOptions = { } , reqId : IRequestTracer ) : Promise < void > {
421430 switch ( this . type ( ) ) {
422431 case Type . TRANSACTION_REQUEST_FULL :
423- // TransactionRequestFull for SMH or SMC wallets can only be signed after pending approval is approved
424- if (
425- this . _pendingApproval . state === State . APPROVED &&
426- this . canRecreateTransaction ( params ) &&
427- this . baseCoin . supportsTss ( )
428- ) {
429- await this . recreateAndSignTSSTransaction ( params , reqId ) ;
432+ if ( this . _pendingApproval . state === State . APPROVED ) {
433+ // After we approve a lightning transaction, we should proceed with submitting the payment
434+ if ( this . baseCoin . getFamily ( ) === 'lnbtc' ) {
435+ assert ( this . _pendingApproval . txRequestId , 'Missing txRequestId' ) ;
436+ // this.populateWallet is called before this so we should be good here
437+ assert ( this . wallet ?. id ( ) , 'Missing wallet id' ) ;
438+ await sendTxRequest (
439+ this . bitgo ,
440+ this . wallet ?. id ( ) as string ,
441+ this . _pendingApproval . txRequestId ,
442+ RequestType . tx ,
443+ reqId
444+ ) ;
445+ } else if ( this . canRecreateTransaction ( params ) && this . baseCoin . supportsTss ( ) ) {
446+ await this . recreateAndSignTSSTransaction ( params , reqId ) ;
447+ }
430448 }
431449 }
432450 }
0 commit comments