@@ -39,6 +39,7 @@ import {
3939 KeychainWithEncryptedPrv ,
4040 KeyIndices ,
4141} from '../keychain' ;
42+ import { CreateLightningInvoiceParams , LightningInvoiceResponse } from '../../lightning' ;
4243import { getLightningAuthKey } from '../lightning/lightningWalletUtil' ;
4344import { IPendingApproval , PendingApproval , PendingApprovals } from '../pendingApproval' ;
4445import { GoStakingWallet , StakingWallet } from '../staking' ;
@@ -3180,6 +3181,39 @@ export class Wallet implements IWallet {
31803181 return this . _wallet ;
31813182 }
31823183
3184+ /**
3185+ * Create a lightning invoice for this wallet.
3186+ * Supported for OFC (trading) and BTC wallets.
3187+ * Uses the same wallet-platform endpoint as lnbtc wallets.
3188+ * @param params.valueSat - Invoice value in satoshis - if not provided, a zero-value invoice is created
3189+ * @param params.memo - Optional memo/description
3190+ * @param params.expiry - Optional expiry in seconds (not supported for trading wallets)
3191+ */
3192+ async createLightningInvoice ( params : CreateLightningInvoiceParams ) : Promise < LightningInvoiceResponse > {
3193+ const family = this . baseCoin . getFamily ( ) ;
3194+ if ( family !== 'ofc' && family !== 'btc' ) {
3195+ throw new Error ( 'createLightningInvoice is only supported for OFC and BTC wallets' ) ;
3196+ }
3197+
3198+ const body : Record < string , unknown > = { } ;
3199+ if ( params . valueSat !== undefined ) {
3200+ body . valueSat = params . valueSat ;
3201+ }
3202+ if ( params . memo !== undefined ) {
3203+ body . memo = params . memo ;
3204+ }
3205+ if ( params . expiry !== undefined ) {
3206+ body . expiry = params . expiry ;
3207+ }
3208+
3209+ const response = await this . bitgo
3210+ . post ( this . bitgo . url ( `/wallet/${ this . id ( ) } /lightning/invoice` , 2 ) )
3211+ . send ( body )
3212+ . result ( ) ;
3213+
3214+ return response as LightningInvoiceResponse ;
3215+ }
3216+
31833217 /**
31843218 * Create a trading account from this wallet
31853219 */
0 commit comments