Merge pull request #18 from gimme/fee-limit-percent
Add FEE_LIMIT_PERCENT setting
This commit is contained in:
commit
e0c19f38a0
3 changed files with 20 additions and 2 deletions
|
|
@ -43,7 +43,9 @@ Environment="LN_PORT=10009"
|
|||
Environment="LN_TLS_FILE=/home/ubuntu/boltcard/tls.cert"
|
||||
Environment="LN_MACAROON_FILE=/home/ubuntu/boltcard/SendPaymentV2.macaroon"
|
||||
|
||||
# FEE_LIMIT_SAT is the maximum lightning network fee to be paid
|
||||
# The maximum lightning network fee to be paid in percent of the payment amount.
|
||||
Environment="FEE_LIMIT_PERCENT=0.5"
|
||||
# Acceptable flat fee in sats that can exceed the percentage limit.
|
||||
Environment="FEE_LIMIT_SAT=10"
|
||||
|
||||
# email
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ This will give you a new 128 bit random key as a 32 character hex value.
|
|||
|
||||
This is due to your payment lightning node not finding a route to the merchant lightning node.
|
||||
It may help to open well funded channels to other well connected nodes.
|
||||
It may also help to increase your maximum network fee in your service variables, **FEE_LIMIT_SAT** .
|
||||
It may also help to increase your maximum network fee in your service variables, **FEE_LIMIT_SAT** / **FEE_LIMIT_PERCENT** .
|
||||
It can be useful to test paying invoices directly from your lightning node.
|
||||
|
||||
> Why do my payments take so long ?
|
||||
|
|
|
|||
16
lightning.go
16
lightning.go
|
|
@ -12,6 +12,7 @@ import (
|
|||
"time"
|
||||
"crypto/sha256"
|
||||
|
||||
decodepay "github.com/fiatjaf/ln-decodepay"
|
||||
lnrpc "github.com/lightningnetwork/lnd/lnrpc"
|
||||
invoicesrpc "github.com/lightningnetwork/lnd/lnrpc/invoicesrpc"
|
||||
routerrpc "github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||
|
|
@ -216,6 +217,21 @@ func pay_invoice(card_payment_id int, invoice string) {
|
|||
return
|
||||
}
|
||||
|
||||
fee_limit_percent_str := os.Getenv("FEE_LIMIT_PERCENT")
|
||||
fee_limit_percent, err := strconv.ParseFloat(fee_limit_percent_str, 64)
|
||||
if err != nil {
|
||||
log.WithFields(log.Fields{"card_payment_id": card_payment_id}).Warn(err)
|
||||
return
|
||||
}
|
||||
|
||||
bolt11, _ := decodepay.Decodepay(invoice)
|
||||
invoice_msats := bolt11.MSatoshi
|
||||
|
||||
fee_limit_product := int64((fee_limit_percent / 100) * (float64(invoice_msats) / 1000))
|
||||
if fee_limit_product > fee_limit_sat {
|
||||
fee_limit_sat = fee_limit_product
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue