---
# System prepended metadata

title: getfeerange BIP
tags: [bip]

---

# getfeerange BIP

## Why we need it?

Currently light client has no way to estimate the fee like 
a full node with the full mempool available.

So, like getutxo method https://github.com/bitcoin/bips/blob/master/bip-0064.mediawiki we should be able to query the fee for a node in a range.

https://github.com/bitcoin/bips/blob/master/bip-0064.mediawiki


## Applicability

This remove the needs of an fee endpoint in lite clients like nakamoto or neutrino. 


## Related work

There is a fee filter already in the following [BIP](https://github.com/bitcoin/bips/blob/master/bip-0133.mediawiki), but I think this is not what is needed to solve the current problem because we are missing the possibility to ask for a range of transactions.

### Open question

- How to verify the fee received?
- How to prefent spamming? (by accepting only a request by peer for a range? and if the peer keep asking the same range we disconned?)


### Alternative methods suggested

Base point

>For BIP157/158 the protection mechanism is supposed to be that you can ask multiple peers for the filter and if they diverge you get the block yourself and calculate filter to check who is right. You could also ask multiple peers for fee estimates but unless the response is some deterministic way to calculate it based only on blocks and not the mempool,


#### Block fetching

Request a few recent blocks and make a fee estimates based on those, maybe just on demand if the peer wants to bump fees. 

- Downside is how to estimate a fee in a range? like between 6 and 100 blocks?

#### Transaction fetching

If a peer wants you lower the feerate on the channel you can ask them to send you 3 tx with a feerate that is below that they requested which were confirmed in each of the last 5 blocks or so.

So we ask for a couple of transaction for each confirmation target and then we try to estimate the fee base on the transaction fee.

- Contrs: Each of the 5 blocks so it’s not easily exploitable by a single miner but it probably still has security issues with all the recent out-of-band payments to miners. 

- This have all the problemt that are listed in the getutxo? or there is another way to fetch the blocks?

### BIP implementation

TODO this is a working in progress.