|
71 | 71 | from .plugin import run_hook, DeviceMgr, Plugins |
72 | 72 | from .version import ELECTRUM_VERSION |
73 | 73 | from .simple_config import SimpleConfig |
74 | | -from .fee_policy import FeePolicy |
| 74 | +from .fee_policy import FeePolicy, FEE_ETA_TARGETS, FEERATE_DEFAULT_RELAY |
75 | 75 | from . import GuiImportError |
76 | 76 | from . import crypto |
77 | 77 | from . import constants |
@@ -1577,6 +1577,27 @@ async def getfeerate(self): |
1577 | 1577 | 'tooltip': tooltip, |
1578 | 1578 | } |
1579 | 1579 |
|
| 1580 | + @command('n') |
| 1581 | + async def test_inject_fee_etas(self, fee_est): |
| 1582 | + """ |
| 1583 | + Inject fee estimates into the network object, as if they were coming from connected servers. |
| 1584 | + Useful on regtest. |
| 1585 | +
|
| 1586 | + arg:str:fee_est:dict of ETA-based fee estimates, encoded as str |
| 1587 | + """ |
| 1588 | + if not isinstance(fee_est, dict): |
| 1589 | + fee_est = ast.literal_eval(fee_est) |
| 1590 | + assert isinstance(fee_est, dict), f"unexpected type for fee_est. got {repr(fee_est)}" |
| 1591 | + # populate missing high-block-number estimates using default relay fee. |
| 1592 | + # e.g. {"25": 2222} -> {"25": 2222, "144": 1000, "1008": 1000} |
| 1593 | + furthest_estimate = max(fee_est.keys()) if fee_est else 0 |
| 1594 | + further_fee_est = { |
| 1595 | + eta_target: FEERATE_DEFAULT_RELAY for eta_target in FEE_ETA_TARGETS |
| 1596 | + if eta_target > furthest_estimate |
| 1597 | + } |
| 1598 | + fee_est.update(further_fee_est) |
| 1599 | + self.network.update_fee_estimates(fee_est=fee_est) |
| 1600 | + |
1580 | 1601 | @command('w') |
1581 | 1602 | async def removelocaltx(self, txid, wallet: Abstract_Wallet = None): |
1582 | 1603 | """Remove a 'local' transaction from the wallet, and its dependent |
|
0 commit comments