File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -238,13 +238,14 @@ public async Task CloseSession(Commitment commitment = Commitment.Confirmed)
238238
239239 // Get balance and calculate refund
240240 var balance = ( await GetBalance ( Account . PublicKey ) ) * SolLamports ;
241- var estimatedFees = await ActiveRpcClient . GetFeesAsync ( Commitment . Confirmed ) ;
242- var refund = balance - estimatedFees . Result . Value . FeeCalculator . LamportsPerSignature * 1 ;
241+ var estimatedFees = await ActiveRpcClient . GetFeeForMessageAsync ( tx . CompileMessage ( ) , Commitment . Confirmed ) ;
242+ var refund = balance - estimatedFees . Result . Value * 1 ;
243243 Debug . Log ( $ "LAMPORTS Balance: { balance } , Refund: { refund } ") ;
244244
245245 tx . Add ( RevokeSessionIX ( ) ) ;
246246 // Issue Refund
247- tx . Add ( SystemProgram . Transfer ( Account . PublicKey , _externalWallet . Account . PublicKey , ( ulong ) refund ) ) ;
247+ if ( refund != null )
248+ tx . Add ( SystemProgram . Transfer ( Account . PublicKey , _externalWallet . Account . PublicKey , ( ulong ) refund ) ) ;
248249 var rest = await SignAndSendTransaction ( tx , commitment : commitment ) ;
249250 DeleteSessionWallet ( ) ;
250251 }
You can’t perform that action at this time.
0 commit comments