TxKeys: set num_mkeys correctly; check_swap_memo(): cleanup
This commit is contained in:
parent
6b25d2992e
commit
b625d9ba55
2 changed files with 6 additions and 5 deletions
|
|
@ -100,15 +100,16 @@ class Completed(Base):
|
|||
r.coin,
|
||||
tokensym = r.tokensym,
|
||||
need_amt = True)
|
||||
|
||||
if mmid := getattr(self, 'swap_recv_addr_mmid', None):
|
||||
pass
|
||||
return self.Output(proto, addr=p.address, mmid=mmid, amt=proto.coin_amt('0'))
|
||||
elif not self.is_swap:
|
||||
pass
|
||||
elif self.cfg.allow_non_wallet_swap:
|
||||
ymsg('Warning: allowing swap to non-wallet address (--allow-non-wallet-swap)')
|
||||
return self.Output(proto, addr=p.address, mmid=None, amt=proto.coin_amt('0'))
|
||||
else:
|
||||
raise ValueError('Swap to non-wallet address forbidden (override with --allow-non-wallet-swap)')
|
||||
return self.Output(proto, addr=p.address, mmid=mmid, amt=proto.coin_amt('0'))
|
||||
|
||||
if self.is_swap and not self.is_memoless:
|
||||
raise ValueError('missing or invalid memo in swap transaction')
|
||||
|
|
|
|||
|
|
@ -215,12 +215,12 @@ class TxKeys:
|
|||
memo_output = self.tx.check_swap_memo() # do this for non-swap transactions too!
|
||||
okeys, mkeys = ([], [])
|
||||
num_okeys = len([e for e in self.tx.outputs if e.mmid and not e.have_wif])
|
||||
num_mkeys = 1
|
||||
num_mkeys = 1 if memo_output and memo_output.mmid else None
|
||||
|
||||
if self.keyaddrlist:
|
||||
ret += self.add_keys('inputs', self.tx.inputs, from_keyaddrlist=True)
|
||||
okeys += self.add_keys('outputs', self.tx.outputs, from_keyaddrlist=True)
|
||||
if memo_output:
|
||||
if num_mkeys:
|
||||
mkeys += self.add_keys('swap destination address', [memo_output], from_keyaddrlist=True)
|
||||
|
||||
ret += self.add_keys('inputs', self.tx.inputs)
|
||||
|
|
@ -229,7 +229,7 @@ class TxKeys:
|
|||
if len(okeys) != num_okeys:
|
||||
die('TxKeysError', 'Could not resolve all MMGen outputs')
|
||||
|
||||
if memo_output:
|
||||
if num_mkeys:
|
||||
mkeys += self.add_keys('swap destination address', [memo_output])
|
||||
if len(mkeys) != num_mkeys and not self.cfg.allow_non_wallet_swap:
|
||||
die('TxKeysError', 'Unable to resolve memo destination address')
|
||||
|
|
|
|||
Loading…
Reference in a new issue