alexbosworth / ln-service

Node.js interface to LND
MIT License
318 stars 61 forks source link

subscribeToPayViaRequest ignores max_fee_mtokens=0 (max_fee=0 works) #141

Closed huumn closed 3 years ago

huumn commented 3 years ago

package.json

"ln-service": "^51.7.0",

I was testing route finding failures in my LAPP with max_fee_mtokens=0 but the payment kept succeeding with fees. Setting max_fee=0 gave the expected behavior (routing failed).

alexbosworth commented 3 years ago

Did you pass 0 or '0'?

huumn commented 3 years ago
  1. Went back and retested to make sure. The following succeeds with routing fees.
        // create the payment, subscribing to its status
        const sub = subscribeToPayViaRequest({
          lnd,
          request: invoice,
          // can't use max_fee_mtokens https://github.com/alexbosworth/ln-service/issues/141
          // max_fee: Number(maxFee),
          max_fee_mtokens: 0,
          pathfinding_timeout: 30000
        })
alexbosworth commented 3 years ago

Ok yes that's because max fee mtokens must be a string and not a Number. All mtoken values must be strings because JS cannot represent them in the Number, they are too large

I've added a check on this to error earlier

huumn commented 3 years ago

Ah! Good to know. I've probably made that same mistake elsewhere. Thank you!