Improve estimatefee API
This commit is contained in:
parent
92e8cff770
commit
3f69595fbd
@ -216,12 +216,16 @@ class Daemon(object):
|
|||||||
'''Update our record of the daemon's mempool hashes.'''
|
'''Update our record of the daemon's mempool hashes.'''
|
||||||
return await self._send_single('getrawmempool')
|
return await self._send_single('getrawmempool')
|
||||||
|
|
||||||
async def estimatefee(self, params):
|
async def estimatefee(self, block_count):
|
||||||
'''Return the fee estimate for the given parameters.'''
|
'''Return the fee estimate for the block count. Units are whole
|
||||||
|
currency units per KB, e.g. 0.00000995, or -1 if no estimate
|
||||||
|
is available.
|
||||||
|
'''
|
||||||
|
args = (block_count, )
|
||||||
if await self._is_rpc_available('estimatesmartfee'):
|
if await self._is_rpc_available('estimatesmartfee'):
|
||||||
estimate = await self._send_single('estimatesmartfee', params)
|
estimate = await self._send_single('estimatesmartfee', args)
|
||||||
return estimate.get('feerate', -1)
|
return estimate.get('feerate', -1)
|
||||||
return await self._send_single('estimatefee', params)
|
return await self._send_single('estimatefee', args)
|
||||||
|
|
||||||
async def getnetworkinfo(self):
|
async def getnetworkinfo(self):
|
||||||
'''Return the result of the 'getnetworkinfo' RPC call.'''
|
'''Return the result of the 'getnetworkinfo' RPC call.'''
|
||||||
@ -280,7 +284,7 @@ class FakeEstimateFeeDaemon(Daemon):
|
|||||||
'''Daemon that simulates estimatefee and relayfee RPC calls. Coin that
|
'''Daemon that simulates estimatefee and relayfee RPC calls. Coin that
|
||||||
wants to use this daemon must define ESTIMATE_FEE & RELAY_FEE'''
|
wants to use this daemon must define ESTIMATE_FEE & RELAY_FEE'''
|
||||||
|
|
||||||
async def estimatefee(self, params):
|
async def estimatefee(self, block_count):
|
||||||
'''Return the fee estimate for the given parameters.'''
|
'''Return the fee estimate for the given parameters.'''
|
||||||
return self.coin.ESTIMATE_FEE
|
return self.coin.ESTIMATE_FEE
|
||||||
|
|
||||||
|
|||||||
@ -1088,7 +1088,7 @@ class ElectrumX(SessionBase):
|
|||||||
number: the number of blocks
|
number: the number of blocks
|
||||||
'''
|
'''
|
||||||
number = non_negative_integer(number)
|
number = non_negative_integer(number)
|
||||||
return await self.daemon_request('estimatefee', [number])
|
return await self.daemon_request('estimatefee', number)
|
||||||
|
|
||||||
async def ping(self):
|
async def ping(self):
|
||||||
'''Serves as a connection keep-alive mechanism and for the client to
|
'''Serves as a connection keep-alive mechanism and for the client to
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user