File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -216,6 +216,28 @@ func (w *resultStreamWrapper) Recv() (*lnrpc.Payment, error) {
216216		amountMsat  :=  lnwire .MilliSatoshi (w .amountMsat )
217217		milliSatsFP  :=  rfqmath .MilliSatoshiToUnits (amountMsat , * rate )
218218		numUnits  :=  milliSatsFP .ScaleTo (0 ).ToUint64 ()
219+ 
220+ 		// If the calculated number of units is 0 then the asset rate 
221+ 		// was not sufficient to represent the value of this payment. 
222+ 		if  numUnits  ==  0  {
223+ 			// We will calculate the minimum amount that can be 
224+ 			// effectively sent with this asset by calculating the 
225+ 			// value of a single asset unit, based on the provided 
226+ 			// asset rate. 
227+ 
228+ 			// We create the single unit. 
229+ 			unit  :=  rfqmath .FixedPointFromUint64 [rfqmath.BigInt ](
230+ 				1 , 0 ,
231+ 			)
232+ 			// We derive the minimum amount. 
233+ 			minAmt  :=  rfqmath .UnitsToMilliSatoshi (unit , * rate )
234+ 
235+ 			// We return the error to the user. 
236+ 			return  nil , fmt .Errorf ("smallest payment with asset " + 
237+ 				"rate %v is %v, cannot send %v" ,
238+ 				rate .ToUint64 (), minAmt , amountMsat )
239+ 		}
240+ 
219241		msatPerUnit  :=  uint64 (w .amountMsat ) /  numUnits 
220242
221243		fmt .Printf ("Got quote for %v asset units at %v msat/unit from " + 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments