Skip to content

Commit

Permalink
Merge pull request #37 from LN-Zap/estimatemode
Browse files Browse the repository at this point in the history
Ability to set bitcoind fee estimation mode
  • Loading branch information
mrfelton authored Feb 13, 2024
2 parents 409b1c0 + 4465d06 commit a904215
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ Here are the available configuration options:
| `bitcoind.username` | The username to use for authenticating with the bitcoind instance | - | `BITCOIND_USERNAME` |
| `bitcoind.password` | The password to use for authenticating with the bitcoind instance | - | `BITCOIND_PASSWORD` |
| `bitcoind.confTargets` | The block targets to use for history-based fee estimates | `[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 144, 504, 1008]` | `BITCOIND_CONF_TARGETS` |
| `bitcoind.estimateMode` | The estimate mode to use for fee estimates (`ECONOMICAL` or `CONSERVATIVE`) | `ECONOMICAL` | `BITCOIND_ESTIMATE_MODE` |

## Development

Expand Down
3 changes: 2 additions & 1 deletion config/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"baseUrl": "BITCOIND_BASE_URL",
"username": "BITCOIND_USERNAME",
"password": "BITCOIND_PASSWORD",
"confTargets": "BITCOIND_CONF_TARGETS"
"confTargets": "BITCOIND_CONF_TARGETS",
"estimateMode": "BITCOIND_ESTIMATE_MODE"
},
"cache": {
"stdTTL": "CACHE_STD_TTL",
Expand Down
3 changes: 2 additions & 1 deletion config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"baseUrl": null,
"username": null,
"password": null,
"confTargets": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 144, 504, 1008]
"confTargets": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 144, 504, 1008],
"estimateMode": "ECONOMICAL"
},
"cache": {
"stdTTL": 15,
Expand Down
3 changes: 3 additions & 0 deletions src/custom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ interface EstimateSmartFeeResponse {
errors?: [string], // errors encountered during processing (if there are any)
blocks?: number // block number where estimate was found
};

// EstimateMode represents the mode for fee estimation.
type EstimateMode = 'ECONOMICAL' | 'CONSERVATIVE'; // estimate mode can be either 'ECONOMICAL' or 'CONSERVATIVE'
3 changes: 2 additions & 1 deletion src/server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const BITCOIND_BASE_URL = config.get<string>('bitcoind.baseUrl');
const BITCOIND_USERNAME = config.get<string>('bitcoind.username');
const BITCOIND_PASSWORD = config.get<number>('bitcoind.password');
const BITCOIND_CONF_TARGETS = config.get<number[]>('bitcoind.confTargets');
const BITCOIND_ESTIMATE_MODE = config.get<EstimateMode>('bitcoind.estimateMode');

const LOGLEVEL = config.get<string>('settings.loglevel');
const TIMEOUT = config.get<number>('settings.timeout');
Expand Down Expand Up @@ -252,7 +253,7 @@ async function fetchBitcoindData() : Promise<FeeByBlockTarget | null> {

function batchCall() {
targets.forEach(function (target) {
rpc.estimatesmartfee(target);
rpc.estimatesmartfee(target, BITCOIND_ESTIMATE_MODE);
});
}

Expand Down

0 comments on commit a904215

Please sign in to comment.