minor addition and cleanups
This commit is contained in:
parent
1fcac76363
commit
e223a776d8
3 changed files with 15 additions and 11 deletions
|
|
@ -239,12 +239,12 @@ class Base(TxBase.Base):
|
|||
wsize = get_witness_size()
|
||||
|
||||
# TODO: compute real varInt sizes instead of assuming 1 byte
|
||||
# old serialization: [nVersion] [vInt][txins][vInt][txouts] [nLockTime]
|
||||
old_size = 4 + 1 + isize + 1 + osize + 4
|
||||
# marker = 0x00, flag = 0x01
|
||||
# new serialization: [nVersion][marker][flag][vInt][txins][vInt][txouts][witness][nLockTime]
|
||||
new_size = 4 + 1 + 1 + 1 + isize + 1 + osize + wsize + 4 \
|
||||
if wsize else old_size
|
||||
# Serialization:
|
||||
# old: [nVersion] [vInt][txins][vInt][txouts] [nLockTime]
|
||||
old_size = 4 + 1 + isize + 1 + osize + 4
|
||||
# marker = 0x00, flag = 0x01
|
||||
# new: [nVersion][marker][flag][vInt][txins][vInt][txouts][witness][nLockTime]
|
||||
new_size = 4 + 1 + 1 + 1 + isize + 1 + osize + wsize + 4 if wsize else old_size
|
||||
|
||||
ret = (old_size * 3 + new_size) // 4
|
||||
|
||||
|
|
|
|||
|
|
@ -100,12 +100,11 @@ class CoinProtocol(MMGenObject):
|
|||
|
||||
if need_amt:
|
||||
import mmgen.amt
|
||||
setattr( self, 'coin_amt', getattr(mmgen.amt,self.coin_amt) )
|
||||
fee = getattr(self,'max_tx_fee',None)
|
||||
setattr( self, 'max_tx_fee', (self.coin_amt(fee) if fee else None) )
|
||||
self.coin_amt = getattr(mmgen.amt,self.coin_amt)
|
||||
self.max_tx_fee = self.coin_amt(self.max_tx_fee) if hasattr(self,'max_tx_fee') else None
|
||||
else:
|
||||
setattr( self, 'coin_amt', None )
|
||||
setattr( self, 'max_tx_fee', None )
|
||||
self.coin_amt = None
|
||||
self.max_tx_fee = None
|
||||
|
||||
@property
|
||||
def dcoin(self):
|
||||
|
|
|
|||
|
|
@ -289,6 +289,11 @@ def is_int(s):
|
|||
except:
|
||||
return False
|
||||
|
||||
def check_int_between(val,imin,imax,desc):
|
||||
if not imin <= int(val) <= imax:
|
||||
die(1,f'{val}: invalid value for {desc} (must be between {imin} and {imax})')
|
||||
return int(val)
|
||||
|
||||
def is_hex_str(s):
|
||||
return set(s) <= set(hexdigits)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue