Improve daemon API for broadcasting a tx
This commit is contained in:
parent
61711fcfd7
commit
92e8cff770
@ -249,9 +249,9 @@ class Daemon(object):
|
||||
# Convert hex strings to bytes
|
||||
return [hex_to_bytes(tx) if tx else None for tx in txs]
|
||||
|
||||
async def sendrawtransaction(self, params):
|
||||
async def broadcast_transaction(self, raw_tx):
|
||||
'''Broadcast a transaction to the network.'''
|
||||
return await self._send_single('sendrawtransaction', params)
|
||||
return await self._send_single('sendrawtransaction', (raw_tx, ))
|
||||
|
||||
async def height(self):
|
||||
'''Query the daemon for its current height.'''
|
||||
|
||||
@ -535,7 +535,7 @@ class SessionManager(object):
|
||||
return electrum_header
|
||||
|
||||
async def broadcast_transaction(self, raw_tx):
|
||||
hex_hash = await self.daemon.sendrawtransaction([raw_tx])
|
||||
hex_hash = await self.daemon.broadcast_transaction(raw_tx)
|
||||
self.txs_sent += 1
|
||||
return hex_hash
|
||||
|
||||
@ -1144,7 +1144,7 @@ class ElectrumX(SessionBase):
|
||||
except DaemonError as e:
|
||||
error, = e.args
|
||||
message = error['message']
|
||||
self.logger.info(f'sendrawtransaction: {message}')
|
||||
self.logger.info(f'error sending transaction: {message}')
|
||||
raise RPCError(BAD_REQUEST, 'the transaction was rejected by '
|
||||
f'network rules.\n\n{message}\n[{raw_tx}]')
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user