BuxOrg / bux

Bitcoin UTXO & xPub Management Engine
https://getbux.io
Apache License 2.0
36 stars 6 forks source link

fix(BUX-461) fee quotes for both arc and mAPI with user defined fee quote #533

Closed chris-4chain closed 10 months ago

chris-4chain commented 10 months ago

Pull Request Checklist

The primary goal of this task was to calculate the lowest fee for ARC mode, similar to what is done with mAPI. Additionally, to allow users (e.g., bux-server) configure a fee unit (satoshis/bytes) when use_fee_quotes is disabled.

To accomplish this, I had to rewrite some parts of the chainstate package. This was mainly due to the chainstate.Client being tightly coupled with minercraft.

I moved the minercraft initialization functions to minercraft_init.go. Then, I created another file broadcast_client_init.go, which contains an algorithm to calculate the lowest fee based on the GetFeeQuote function from the broadcast-client.

For reviewers: The most interesting files to review are:

mergify[bot] commented 10 months ago

Welcome to our open-source project @chris-4chain! πŸ’˜

codecov[bot] commented 10 months ago

Codecov Report

Attention: 82 lines in your changes are missing coverage. Please review.

Comparison is base (7279b7a) 51.85% compared to head (2410e8e) 51.88%.

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/BuxOrg/bux/pull/533/graphs/tree.svg?width=650&height=150&src=pr&token=gh8XH5lven&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BuxOrg)](https://app.codecov.io/gh/BuxOrg/bux/pull/533?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BuxOrg) ```diff @@ Coverage Diff @@ ## master #533 +/- ## ========================================== + Coverage 51.85% 51.88% +0.03% ========================================== Files 107 109 +2 Lines 11191 11250 +59 ========================================== + Hits 5803 5837 +34 - Misses 4927 4946 +19 - Partials 461 467 +6 ``` | [Flag](https://app.codecov.io/gh/BuxOrg/bux/pull/533/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BuxOrg) | Coverage Ξ” | | |---|---|---| | [unittests](https://app.codecov.io/gh/BuxOrg/bux/pull/533/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BuxOrg) | `51.88% <67.46%> (+0.03%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BuxOrg#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files](https://app.codecov.io/gh/BuxOrg/bux/pull/533?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BuxOrg) | Coverage Ξ” | | |---|---|---| | [chainstate/broadcast\_providers.go](https://app.codecov.io/gh/BuxOrg/bux/pull/533?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BuxOrg#diff-Y2hhaW5zdGF0ZS9icm9hZGNhc3RfcHJvdmlkZXJzLmdv) | `60.71% <100.00%> (ΓΈ)` | | | [chainstate/minercraft\_default.go](https://app.codecov.io/gh/BuxOrg/bux/pull/533?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BuxOrg#diff-Y2hhaW5zdGF0ZS9taW5lcmNyYWZ0X2RlZmF1bHQuZ28=) | `100.00% <100.00%> (ΓΈ)` | | | [chainstate/mock\_minercraft.go](https://app.codecov.io/gh/BuxOrg/bux/pull/533?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BuxOrg#diff-Y2hhaW5zdGF0ZS9tb2NrX21pbmVyY3JhZnQuZ28=) | `16.41% <100.00%> (ΓΈ)` | | | [chainstate/transaction.go](https://app.codecov.io/gh/BuxOrg/bux/pull/533?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BuxOrg#diff-Y2hhaW5zdGF0ZS90cmFuc2FjdGlvbi5nbw==) | `83.17% <100.00%> (ΓΈ)` | | | [model\_draft\_transactions.go](https://app.codecov.io/gh/BuxOrg/bux/pull/533?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BuxOrg#diff-bW9kZWxfZHJhZnRfdHJhbnNhY3Rpb25zLmdv) | `73.53% <100.00%> (-0.21%)` | :arrow_down: | | [chainstate/client\_options.go](https://app.codecov.io/gh/BuxOrg/bux/pull/533?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BuxOrg#diff-Y2hhaW5zdGF0ZS9jbGllbnRfb3B0aW9ucy5nbw==) | `67.61% <71.42%> (-8.44%)` | :arrow_down: | | [utils/fees.go](https://app.codecov.io/gh/BuxOrg/bux/pull/533?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BuxOrg#diff-dXRpbHMvZmVlcy5nbw==) | `90.69% <84.61%> (-9.31%)` | :arrow_down: | | [client\_options.go](https://app.codecov.io/gh/BuxOrg/bux/pull/533?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BuxOrg#diff-Y2xpZW50X29wdGlvbnMuZ28=) | `75.71% <0.00%> (+1.06%)` | :arrow_up: | | [chainstate/client.go](https://app.codecov.io/gh/BuxOrg/bux/pull/533?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BuxOrg#diff-Y2hhaW5zdGF0ZS9jbGllbnQuZ28=) | `65.95% <64.70%> (-14.48%)` | :arrow_down: | | [chainstate/broadcast\_client\_init.go](https://app.codecov.io/gh/BuxOrg/bux/pull/533?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BuxOrg#diff-Y2hhaW5zdGF0ZS9icm9hZGNhc3RfY2xpZW50X2luaXQuZ28=) | `55.17% <55.17%> (ΓΈ)` | | | ... and [1 more](https://app.codecov.io/gh/BuxOrg/bux/pull/533?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BuxOrg) | | ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/BuxOrg/bux/pull/533?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BuxOrg). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BuxOrg) > `Ξ” = absolute (impact)`, `ΓΈ = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/BuxOrg/bux/pull/533?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BuxOrg). Last update [7279b7a...2410e8e](https://app.codecov.io/gh/BuxOrg/bux/pull/533?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BuxOrg). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=BuxOrg).