py3port: Parity: support 'eth_chainId' RPC call
This commit is contained in:
parent
489d637719
commit
61b4f5a07a
6 changed files with 14 additions and 5 deletions
|
|
@ -105,7 +105,8 @@ class Token(MMGenObject): # ERC20
|
|||
|
||||
def txsign(self,tx_in,key,from_addr,chain_id=None):
|
||||
if chain_id is None:
|
||||
chain_id = int(g.rpch.parity_chainId(),16)
|
||||
chain_id_method = ('parity_chainId','eth_chainId')['eth_chainId' in g.rpch.caps]
|
||||
chain_id = int(g.rpch.request(chain_id_method),16)
|
||||
tx = Transaction(**tx_in).sign(key,chain_id)
|
||||
hex_tx = hexlify(rlp.encode(tx))
|
||||
coin_txid = CoinTxID(hexlify(tx.hash))
|
||||
|
|
|
|||
|
|
@ -130,6 +130,7 @@ class EthereumMMGenTX(MMGenTX):
|
|||
return ETHNonce(int(g.rpch.parity_nextNonce('0x'+self.inputs[0].addr),16))
|
||||
|
||||
def make_txobj(self): # create_raw
|
||||
chain_id_method = ('parity_chainId','eth_chainId')['eth_chainId' in g.rpch.caps]
|
||||
self.txobj = {
|
||||
'from': self.inputs[0].addr,
|
||||
'to': self.outputs[0].addr if self.outputs else Str(''),
|
||||
|
|
@ -137,7 +138,7 @@ class EthereumMMGenTX(MMGenTX):
|
|||
'gasPrice': self.usr_rel_fee or self.fee_abs2rel(self.fee,to_unit='eth'),
|
||||
'startGas': self.start_gas,
|
||||
'nonce': self.get_nonce(),
|
||||
'chainId': Int(g.rpch.parity_chainId(),16),
|
||||
'chainId': Int(g.rpch.request(chain_id_method),16),
|
||||
'data': self.data,
|
||||
}
|
||||
|
||||
|
|
|
|||
0
mmgen/bech32.py
Normal file → Executable file
0
mmgen/bech32.py
Normal file → Executable file
0
mmgen/ed25519ll_djbec.py
Normal file → Executable file
0
mmgen/ed25519ll_djbec.py
Normal file → Executable file
|
|
@ -218,6 +218,9 @@ class EthereumRPCConnection(CoinDaemonRPCConnection):
|
|||
'eth_accounts',
|
||||
'eth_blockNumber',
|
||||
'eth_call',
|
||||
# Returns the EIP155 chain ID used for transaction signing at the current best block.
|
||||
# Null is returned if not available.
|
||||
'eth_chainId',
|
||||
'eth_gasPrice',
|
||||
'eth_getBalance',
|
||||
'eth_getBlockByHash',
|
||||
|
|
@ -233,9 +236,7 @@ class EthereumRPCConnection(CoinDaemonRPCConnection):
|
|||
'net_peerCount',
|
||||
'net_version',
|
||||
'parity_chain',
|
||||
# Returns the EIP155 chain ID used for transaction signing at the current best block.
|
||||
# Null is returned if not available.
|
||||
'parity_chainId',
|
||||
'parity_chainId', # superseded by eth_chainId
|
||||
'parity_chainStatus',
|
||||
'parity_composeTransaction',
|
||||
'parity_gasCeilTarget',
|
||||
|
|
|
|||
|
|
@ -857,6 +857,12 @@ def rpc_init_parity():
|
|||
(g.token,g.dcoin) = resolve_token_arg(g.token)
|
||||
|
||||
g.rpch.caps = ()
|
||||
try:
|
||||
g.rpch.request('eth_chainId')
|
||||
g.rpch.caps += ('eth_chainId',)
|
||||
except RPCFailure:
|
||||
pass
|
||||
|
||||
return g.rpch
|
||||
|
||||
def rpc_init_bitcoind():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue