XMR swaps, memoless swaps: check that memo address belongs to wallet
This commit is contained in:
parent
0a536e7f27
commit
168f5a7407
5 changed files with 18 additions and 3 deletions
|
|
@ -1 +1 @@
|
|||
17.1.0dev1
|
||||
17.1.0dev2
|
||||
|
|
|
|||
|
|
@ -89,6 +89,15 @@ class mainnet(CoinProtocol.RPC, CoinProtocol.DummyWIF, CoinProtocol.Base):
|
|||
def viewkey(self, viewkey_str):
|
||||
return MoneroViewKey.__new__(MoneroViewKey, viewkey_str)
|
||||
|
||||
def keyaddrlist_entry2addr(self, kal_entry, mmid):
|
||||
from .subaddress import get_subaddress
|
||||
return get_subaddress(
|
||||
proto = self,
|
||||
master_addr = kal_entry.addr,
|
||||
master_svk = bytes.fromhex(kal_entry.viewkey),
|
||||
acct_idx = mmid.acct_idx,
|
||||
addr_idx = mmid.addr_idx)
|
||||
|
||||
class testnet(mainnet): # use stagenet for testnet
|
||||
# testnet is {'35', '3f', '36'}
|
||||
addr_ver_info = {'18': 'monero', '24': 'monero_sub', '19': 'monero_integrated'}
|
||||
|
|
|
|||
|
|
@ -200,6 +200,9 @@ class CoinProtocol(MMGenObject):
|
|||
def viewkey(self, viewkey_str):
|
||||
raise NotImplementedError(f'{self.name} protocol does not support view keys')
|
||||
|
||||
def keyaddrlist_entry2addr(self, kal_entry, mmid):
|
||||
return kal_entry.addr
|
||||
|
||||
def base_proto_subclass(self, cls, modname, *, sub_clsname=None, is_token=False):
|
||||
"""
|
||||
magic module loading and class selection
|
||||
|
|
|
|||
|
|
@ -82,6 +82,9 @@ class Completed(Base):
|
|||
|
||||
def check_swap_memo(self):
|
||||
if memo_bytes := self.get_swap_memo_maybe():
|
||||
if self.is_refreq:
|
||||
memo_bytes = self.swap_proto_mod.reference_memo(
|
||||
reference_memo_str=memo_bytes.decode()).memo.encode()
|
||||
from ..swap.proto.thorchain import Memo
|
||||
if Memo.is_partial_memo(memo_bytes):
|
||||
from ..protocol import init_proto
|
||||
|
|
|
|||
|
|
@ -188,13 +188,13 @@ class TxKeys:
|
|||
if kal.al_id == mmid.al_id:
|
||||
for d in kal.data:
|
||||
if d.idx == mmid.idx:
|
||||
if d.addr == e.addr:
|
||||
if (addr := proto.keyaddrlist_entry2addr(d, mmid)) == e.addr:
|
||||
e.have_wif = True
|
||||
yield d
|
||||
else:
|
||||
die(3, fmt(f"""
|
||||
{gc.proj_name} -> {proto.coin} address mappings differ!
|
||||
{err_desc:<23} {mmid} -> {d.addr}
|
||||
{err_desc:<23} {mmid} -> {addr}
|
||||
{'tx file:':<23} {mmid} -> {e.addr}
|
||||
""").strip())
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue