Example #1
0
class EthereumProtocol(DummyWIF, BitcoinProtocol):

    addr_width = 40
    mmtypes = ('E', )
    dfl_mmtype = 'E'
    name = 'ethereum'
    base_coin = 'ETH'
    pubkey_type = 'std'  # required by DummyWIF

    data_subdir = ''
    daemon_name = 'parity'
    daemon_family = 'parity'
    rpc_port = 8545
    mmcaps = ('key', 'addr', 'rpc')
    coin_amt = ETHAmt
    max_tx_fee = ETHAmt('0.005')
    chain_name = 'foundation'
    sign_mode = 'standalone'
    caps = ('token', )

    @classmethod
    def verify_addr(cls, addr, hex_width, return_dict=False):
        from mmgen.util import is_hex_str_lc
        if is_hex_str_lc(addr) and len(addr) == cls.addr_width:
            return {'hex': addr, 'format': 'ethereum'} if return_dict else True
        if g.debug: Msg("Invalid address '{}'".format(addr))
        return False

    @classmethod
    def pubhash2addr(cls, pubkey_hash, p2sh):
        assert len(
            pubkey_hash) == 40, '{}: invalid length for pubkey hash'.format(
                len(pubkey_hash))
        assert not p2sh, 'Ethereum has no P2SH address format'
        return pubkey_hash
Example #2
0
 async def do_transfer(rpc):
     for i in range(2):
         tk = await TokenResolve(
             self.proto, rpc,
             self.read_from_tmpfile(f'token_addr{i+1}').strip())
         imsg_r('\n' + await tk.info())
         imsg('dev token balance (pre-send): {}'.format(
             await tk.get_balance(dfl_addr)))
         imsg('Sending {} {} to address {} ({})'.format(
             amt, self.proto.dcoin, usr_addrs[i], usr_mmaddrs[i]))
         from mmgen.obj import ETHAmt
         txid = await tk.transfer(dfl_addr,
                                  usr_addrs[i],
                                  amt,
                                  dfl_privkey,
                                  start_gas=ETHAmt(60000, 'wei'),
                                  gasPrice=ETHAmt(8, 'Gwei'))
         assert (await self.get_exec_status(txid)
                 ) != 0, 'Transfer of token funds failed. Aborting'
Example #3
0
 def do_transfer():
     for i in range(2):
         tk = Token(
             self.read_from_tmpfile('token_addr{}'.format(i +
                                                          1)).strip())
         imsg_r('\n' + tk.info())
         imsg('dev token balance (pre-send): {}'.format(
             tk.balance(dfl_addr)))
         imsg('Sending {} {} to address {} ({})'.format(
             amt, g.coin, usr_addrs[i], usr_mmaddrs[i]))
         from mmgen.obj import ETHAmt
         txid = tk.transfer(dfl_addr,
                            usr_addrs[i],
                            amt,
                            dfl_privkey,
                            start_gas=ETHAmt(60000, 'wei'),
                            gasPrice=ETHAmt(8, 'Gwei'))
         assert etx.get_exec_status(
             txid,
             True) != 0, 'Transfer of token funds failed. Aborting'
Example #4
0
 def rpc_get_balance(self, addr):
     return ETHAmt(int(g.rpch.eth_getBalance('0x' + addr), 16), 'wei')
Example #5
0
 async def get_balance(self, acct_addr):
     return ETHAmt(await self.do_call('balanceOf(address)',
                                      acct_addr.rjust(64, '0'),
                                      toUnit=True))
Example #6
0
 def transferdata2amt(self, data):  # online
     return ETHAmt(int(parse_abi(data)[-1], 16) * self.base_unit)
Example #7
0
File: tw.py Project: dooglus/mmgen
 def get_unspent_data(self):
     super(type(self), self).get_unspent_data()
     for e in self.unspent:
         e.amt2 = ETHAmt(int(g.rpch.eth_getBalance('0x' + e.addr), 16),
                         'wei')
Example #8
0
	async def rpc_get_balance(self,addr):
		return ETHAmt(int(await self.rpc.call('eth_getBalance','0x'+addr),16),'wei')