protocol.py: add 'base_proto' attribute; minor changes

This commit is contained in:
The MMGen Project 2019-03-27 18:49:41 +00:00
commit 00227b3d73
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
3 changed files with 9 additions and 7 deletions

View file

@ -86,6 +86,7 @@ class BitcoinProtocol(MMGenObject):
caps = ('rbf','segwit')
mmcaps = ('key','addr','rpc','tx')
base_coin = 'BTC'
base_proto = 'Bitcoin'
# From BIP173: witness version 'n' is stored as 'OP_n'. OP_0 is encoded as 0x00,
# but OP_1 through OP_16 are encoded as 0x51 though 0x60 (81 to 96 in decimal).
witness_vernum_hex = '00'
@ -316,6 +317,7 @@ class EthereumProtocol(DummyWIF,BitcoinProtocol):
chain_name = 'foundation'
sign_mode = 'standalone'
caps = ('token',)
base_proto = 'Ethereum'
@classmethod
def verify_addr(cls,addr,hex_width,return_dict=False):

View file

@ -343,7 +343,7 @@ class MMGenToolCmdCoin(MMGenToolCmdBase):
"""
cryptocoin key/address utilities
May require use of the '--coin' and '--type' options
May require use of the '--coin', '--type' and/or '--testnet' options
Examples:
mmgen-tool --coin=ltc --type=bech32 wif2addr <wif key>

View file

@ -230,7 +230,7 @@ class MMGenTxIO(MMGenListItem):
valid_attrs_extra = {'amt'}
# Setting self.amt is runtime-dependent, so make it a property
# Make underlying self._amt an MMGenImmutableAttr so that reassignment is prevented
# Make underlying self._amt an MMGenImmutableAttr to prevent reassignment
@property
def amt(self):
if type(self._amt) != g.proto.coin_amt:
@ -1426,18 +1426,18 @@ Selected non-{pnm} inputs: {{}}""".strip().format(pnm=g.proj_name,pnl=g.proj_nam
change_amt = self.get_inputs_from_user(tw)
# only after we have inputs
if opt.rbf: self.inputs[0].sequence = g.max_int - 2 # handles the locktime case too
elif locktime: self.inputs[0].sequence = g.max_int - 1
self.update_change_output(change_amt)
self.update_send_amt(change_amt)
if g.proto.base_proto == 'Bitcoin':
if opt.rbf: self.inputs[0].sequence = g.max_int - 2 # handles the locktime case too
elif locktime: self.inputs[0].sequence = g.max_int - 1
if not opt.yes:
self.add_comment() # edits an existing comment
self.create_raw() # creates self.hex, self.txid
if locktime:
if g.proto.base_proto == 'Bitcoin' and locktime:
msg('Setting nlocktime to {}!'.format(strfmt_locktime(locktime)))
self.set_hex_locktime(locktime)
self.update_txid()