Skip to content

[REST] add a rest endpoint for estimatesmartfee, docs, and test#11770

Closed
joemphilips wants to merge 1 commit intobitcoin:masterfrom
joemphilips:rest_fee
Closed

[REST] add a rest endpoint for estimatesmartfee, docs, and test#11770
joemphilips wants to merge 1 commit intobitcoin:masterfrom
joemphilips:rest_fee

Conversation

@joemphilips
Copy link
Contributor

This could be useful if other clients want to use the core's fee estimation logic via REST.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Instead of moving them to a separate file, you could add convenience wrappers to the test_node class? Thus, it would not be required to pass in host and port all the time.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@promag promag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Light concept ACK. Maybe too much for REST?

At least the the URI could be improved. This looks weird:

  • /rest/fee/economical/6.json
  • /rest/fee/unset/3.json

src/rest.cpp Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change, please revert.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

src/rest.cpp Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change, please revert.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done. I will make sure will not to include these kinds of changes from next time.

src/rest.cpp Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

src/rest.cpp Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

src/rest.cpp Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds weird to "redirect" to RPC handler (redo the mode parse etc). Maybe factor out what is needed from there?

Maybe just call ::feeEstimator.estimateSmartFee() here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove 2nd empty line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

src/rest.cpp Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing {}.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

src/rest.cpp Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing {}.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returns proper fee estimated by bitcoind, this is bitcoind. 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

@joemphilips
Copy link
Contributor Author

joemphilips commented Nov 27, 2017

Thanks for reviewing.
I will update according to the review soon.

Maybe too much for REST?

Rationale for this PR is that some light client(or other services) wants to use information about block or mempool for estimating fee. This is pretty close to the motivation of getutxo in terms of it places some trust on the full node. core's fee estimation logic is likely to update to a more sophisticated scheme in the near future so many clients may want to use core's logic directly.

At least the the URI could be improved. This looks weird:

You are right. Can I use &foo=bar style query parameter here? I didn't because other endpoint didn't. in that case, what about
/rest/fee.json?target=<TARGET>&mode=<MODE> and make mode optional? Though I'm not sure how easy this is to implement.

Otherwise all I can think is enabling to omit <MODE> . and query in the form like
/rest/fee/5.json

@promag
Copy link
Contributor

promag commented Nov 27, 2017

My vote goes to GET /rest/fee?target=<TARGET>&mode=<MODE>, with query parameters and without extension. IMO all endpoints should return JSON, unless Accept: headers requests other format.

src/rest.cpp Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's not worth passing through the RPC call estimatesmartfee.
Better directly use feeEstimator.estimateFee(nBlocks);.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean feeEstimator::estimateSmartFee ?

@jonasschnelli
Copy link
Contributor

Concept ACK.
Please no query string.
The in this PR proposed URL scheme seems correct and in align with other calls: https://github.com/bitcoin/bitcoin/blob/master/doc/REST-interface.md#query-utxo-set

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. why not:

"/rest/fee/unset/{}.json".format((i+1)//2)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@laanwj
Copy link
Member

laanwj commented Nov 28, 2017

Please no query string.
The in this PR proposed URL scheme seems correct and in align with other calls:

Yep, agree.
Concept ACK.

@joemphilips joemphilips force-pushed the rest_fee branch 2 times, most recently from 4737cc4 to f865a63 Compare November 30, 2017 11:40
Copy link
Contributor Author

@joemphilips joemphilips left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated according to review by @promag , @jb55 and @MarcoFalke . Ready for next review.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

src/rest.cpp Outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done. I will make sure will not to include these kinds of changes from next time.

src/rest.cpp Outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

src/rest.cpp Outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

src/rest.cpp Outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

src/rest.cpp Outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

src/rest.cpp Outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

src/rest.cpp Outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean feeEstimator::estimateSmartFee ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@promag
Copy link
Contributor

promag commented Feb 3, 2018

Needs rebase.

@joemphilips
Copy link
Contributor Author

rebased.

@joemphilips
Copy link
Contributor Author

umm... sorry, does "Needs rebase" imply needs for squashing? or just rebasing onto master?
I only did rebasing onto master but it needs squashing before merge.
(Sorry for silly question. Forgive me, this is my first PR.) @promag

@bitcoin bitcoin deleted a comment from WorkShop-Office Feb 15, 2018
@fanquake
Copy link
Member

@joemphilips You'll need to rebase onto master, as this currently has merge conflicts in test/functional/feature_fee_estimation.py.

At the same time, you can also squash your changes into a single commit. See Squashing Commits. Use a descriptive commit message i.e "rest: add an endpoint for estimatesmartfee".

@joemphilips joemphilips force-pushed the rest_fee branch 5 times, most recently from 3976774 to 5c548c1 Compare February 18, 2018 17:01
@joemphilips
Copy link
Contributor Author

rebased (and squashed)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http.client is already imported above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done.

Copy link
Contributor

@jgarzik jgarzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

concept ACK

@maflcko
Copy link
Member

maflcko commented Nov 9, 2018

Still needs rebase.

Could do something like this:

git checkout rest_fee
git fetch bitcoin
git merge bitcoin/master
git reset --soft bitcoin/master
git commit -m '[REST] add a rest endpoint for estimatesmartfee, docs, and test'
git push origin rest_fee -f

@joemphilips joemphilips force-pushed the rest_fee branch 7 times, most recently from a47b155 to 5ed237a Compare November 9, 2018 18:18
@joemphilips
Copy link
Contributor Author

rebased

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 9, 2018

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

No conflicts as of last run.

src/rest.cpp Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove e since unused :-)

src/rest.cpp Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: bool conservative = mode != FeeEstimateMode::ECONOMICAL; instead? :-)

src/rest.cpp Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop ; :-)

src/rest.cpp Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop ; :-)

src/rest.cpp Outdated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop ; :-)

* write REST interface for getting estimated fee
* update docs about REST interface for fee estimation
* add test
@practicalswift
Copy link
Contributor

This PR does not compile when rebased on master. Is it still active or should it be closed? :-)

@joemphilips
Copy link
Contributor Author

This PR does not compile when rebased on master. Is it still active or should it be closed? :-)

I will close. sorry for leaving it here for so long.

@joemphilips joemphilips closed this May 7, 2019
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants