Commit graph

3,143 commits

Author SHA1 Message Date
ea9c2d296e
THORChain XMR swaps
See: ffe488ff, ff35b01c

Enabled for test suite only pending activation on THORChain mainnet.

Swapping to and from ETH and ERC20 tokens is currently untested.

Sample LTC-to-XMR swap workflow (assumes --autosign):

    # Create the registration transaction (pass 1) (amount is optional):
    $ mmgen-swaptxcreate --memoless LTC 5.4321 XMR

    # Autosign the registration transaction and send it:
    $ mmgen-txsend
    => TxID

    # Get the reference number from the THORChain network:
    $ mmgen-remote --coin=rune get_refnum TxID
    => REFNUM

    # Create the swap transaction (pass 2) (amount is optional):
    $ mmgen-swaptxcreate --refnum=REFNUM LTC 5.4321 XMR

    # Sign and send the swap transaction:
    $ mmgen-txsend

    # Monitor your XMR wallet for the funds:
    $ mmgen-tool --coin=xmr twview

Sample XMR-to-LTC swap workflow (assumes --autosign):

    # Create the registration transaction (pass 1) (amount is required):
    $ mmgen-swaptxcreate --memoless XMR 1.2345 LTC

    # Sign and send registration TX and get reference number as shown above

    # Create the swap transaction (pass 2) (amount is required):
    $ mmgen-swaptxcreate --refnum=REFNUM XMR 1.2345 LTC

    # Sign and send the swap transaction as shown above

    # Monitor your LTC wallet for the funds:
    $ mmgen-tool --coin=ltc twview

Testing/demo:

    $ test/cmdtest.py --coin=ltc -e xmrswap

For more information and examples, invoke `mmgen-swaptxcreate --help`

More complete documentation will be provided at a later date.
2026-10-20 17:38:48 +00:00
a5e3a1807c
minor fixes and cleanups 2026-10-20 17:38:48 +00:00
1304a3be55
proto.xmr.tx.completed.info: return TxInfo instance 2026-10-20 17:38:48 +00:00
33ff0a85a7
xmrwallet.ops.daemon: initialize coin daemon proto properly 2026-10-20 17:38:48 +00:00
919b1e504a
tx.info: new gen_swap_subhdr() method 2026-10-20 17:38:48 +00:00
e6cb2f9587
CoinProtocol.Base: new has_chg attr 2026-10-20 17:38:48 +00:00
fa905256af
proto.rune.tx.new: include memo in TxID for deposit transactions (bugfix)
Fixes a bug whereby all memoless registration transactions had the same MMGen
TxID.
2026-10-20 17:38:48 +00:00
29c5ea22db
various fixes and cleanups 2026-10-20 17:38:48 +00:00
d87e67406a
whitespace (hanging parentheses) 2026-10-20 17:38:43 +00:00
ff35b01c45
memoless swaps: set trade limit and destination address from registered memo
Revises ffe488ff (THORChain memoless swaps)

For memoless swaps, it is now forbidden to specify a trade limit or destination
address in the swap transaction invocation (second pass), as these are already
set in the reference memo registered on the THORChain network, so duplicating
them on the command line only leads to confusion.

If a trade limit was specified in the registration transaction, it’s up to the
user to ensure that the swap transaction spend amount is appropriate for the
trade limit.  Increasing the spend amount is possible, but any significant
increase effectively nullifies the protection the trade limit provides.
2026-10-19 09:06:13 +00:00
e93aec5a19
opts_data 'requires': support non-boolean a-value 2026-10-19 09:06:13 +00:00
74a147be63
tw.view: new obj_key_mappings attr 2026-10-19 09:06:13 +00:00
153a815b5b
XMR: support regtest for cmdtest.py 2026-10-19 09:06:13 +00:00
648664ed9f
various fixes, renames and cleanups 2026-10-19 09:06:07 +00:00
d9e2449429
tx: allow zero send amount for deposit transactions (bugfix)
Fixes a critical bug whereby the memoless registration transaction spent all the
RUNE in the account.

Note that memoless swaps are enabled in the test suite only, so the bug could
not have led to loss of user funds.

As an added safeguard, the patch also disables zero send amounts for non-deposit
transactions.
2026-10-15 09:35:53 +00:00
08376aba3f
mmgen-regtest: set --bdb-wallet according to coin 2026-10-15 09:35:53 +00:00
e3b02b7098
test/cmdtest.py xmr_autosign: alice -> user 2026-10-15 09:35:53 +00:00
c7980fb553
minor changes, fixes and cleanups 2026-10-15 09:35:52 +00:00
f7e6904d6d
help, tool, tx.base_swap: remove swap-proto-dependent code 2026-10-15 09:35:52 +00:00
c29fd6a828
tx.info: improve header display for memoless swap transactions 2026-10-15 09:35:47 +00:00
ffe488ffbd
THORChain memoless swaps
Memoless swaps permit coins with long addresses and/or restricted memo space,
such as Monero, for example, to be swapped on THORChain.  They introduce added
complexity, along with certain privacy and security tradeoffs, so should only
be used for assets that cannot be swapped the usual way.

A reference request transaction (a.k.a. registration transaction) containing
the memo is sent to the THORChain network, which assigns it a number.  This
number is then encoded in the send amount of the swap transaction in lieu of
a memo.

See https://dev.thorchain.org/swap-guide/memoless-swaps.html for technical
details.

While this patch fully implements the feature in MMGen Wallet, it’s disabled
on mainnet for the time being.  Mainnet will be enabled after memoless swaps
are unhalted on THORChain mainnet and the feature can undergo live testing.

The following example is provided for purposes of illustration only. Normally
we would swap LTC to BCH the standard way.

Sample LTC-to-BCH memoless swap workflow (assumes --autosign):

    # Create the reference request transaction (pass 1):
    $ mmgen-swaptxcreate --memoless LTC 1.2345 BCH

    # Autosign the reference request transaction and send it:
    $ mmgen-txsend
    => TxID

    # Get the reference number from the THORChain network:
    $ mmgen-remote --coin=rune get_refnum TxID
    => REFNUM

    # Create the swap transaction (pass 2):
    $ mmgen-swaptxcreate --refnum=REFNUM LTC 1.2345 BCH

    # Sign and send the swap transaction:
    $ mmgen-txsend

    # Monitor your BCH wallet for the funds:
    $ mmgen-tool --coin=bch twview

Testing/demo:

    $ test/cmdtest.py -e swap.memoless

Note that the real send amount is the amount specified in the second invocation
of ‘mmgen-swaptxcreate’ (i.e. the swap transaction or second pass).  If you
omit the --trade-limit option, the amounts in the two invocations can differ,
otherwise amount and trade limit must be identical for both invocations.

Before sending, the software checks that the provided reference number is valid
and points to an address in the user’s tracking wallet.  Thus funds cannot be
sent to the wrong destination as a result of user error.

References remain valid for approximately six hours.  Before sending, the
software checks that the reference is valid, but not whether it is close to
expiration.  If the reference later expires before the swap transaction is
confirmed, there’s a danger of funds loss.  Therefore, it’s recommended to
create and broadcast the swap transaction without delay.  If necessary, the
transaction can be bumped to ensure timely confirmation.

In order to create and send the reference request transaction, the user must
have some RUNE in their wallet.  The current cost per transaction is 0.2 RUNE.

Also be aware of the privacy implications.  Swaps can easily be correlated if
their registration transactions spend from the same RUNE address, or from RUNE
addresses that can be linked via chain analysis.

More complete documentation will be provided at a later date.
2026-10-12 10:04:48 +00:00
9ad34f5001
various changes and cleanups 2026-10-12 10:04:48 +00:00
5d3ac1d99d
new BaseSwapMethods class 2026-10-12 10:04:48 +00:00
fcb5924fe8
SwapAsset: new sanitize_input param 2026-10-12 10:04:48 +00:00
226995cfc7
tx.new_swap, tx.base, ThornodeRPCServer: minor fixes and cleanups 2026-10-12 10:04:48 +00:00
8da39e9c9e
tx.new: convert amount to CoinAmt after parsing 2026-10-12 10:04:48 +00:00
00781a3554
Thornode -> ThornodeQuote 2026-10-12 10:04:47 +00:00
048e2e7505
main_txcreate: cleanups 2026-10-12 10:04:42 +00:00
13623ed9e5
mmgen-swaptxcreate: add --quote option
Display a swap quote and exit without creating a transaction.

All data is from the remote endpoint — no running daemons are required.
2026-10-08 13:12:03 +00:00
da989ccf8b
NewSwap: new display_quote() method 2026-10-08 13:12:03 +00:00
cef8ed21e1
Thornode: new trade_limit property 2026-10-08 13:12:03 +00:00
549751e59c
NewSwap: minor fixes, cleanups, renames 2026-10-08 13:11:58 +00:00
4fa8e32400
mmgen-remote: new quote command 2026-10-07 16:40:39 +00:00
8e75f9f23d
Thornode.get_quote(): get data via remote RPC interface 2026-10-07 16:40:39 +00:00
3b1839c734
rpc: new get_remote_rpc() function 2026-10-07 16:40:39 +00:00
2c4f96e6a4
cfg, opt: improve parsing of regtest opts 2026-10-07 16:40:39 +00:00
f558e4ec21
minor fixes, cleanups, renames 2026-10-07 16:40:39 +00:00
0dd511bafc
whitespace 2026-10-07 16:40:39 +00:00
1356325bf4
init_proto(): remove testnet and regtest params 2026-10-07 16:40:39 +00:00
99b9081640
mmgen-swaptxcreate: check network before creating and sending TX 2026-10-07 16:40:39 +00:00
235c91bf7c
ThornodeServer: new setvar method 2026-10-07 16:40:38 +00:00
d5b4e94676
cmdtest.py remote: add mimir test 2026-10-07 16:40:38 +00:00
dba333306d
whitespace, variable renames 2026-10-07 16:40:33 +00:00
abcb40a74f
remove shebangs and exec perms from mods where applicable (392 files) 2026-10-05 14:30:06 +00:00
1057012524
remove empty __init__ mods 2026-10-05 14:30:06 +00:00
00407d0b5b
extended Monero MMGenID: use / as initial separator 2026-10-05 14:30:05 +00:00
3d8fbca67e
TwAddresses.get_change_address(): support full-list matching 2026-10-05 14:30:05 +00:00
527fedd7d5
TwAddresses: clean up bisect func, move to algo mod, add key-getting funcs 2026-10-05 14:30:05 +00:00
1422e89eaf
TwAddresses.get_change_address(): remove one indentation level 2026-10-05 14:30:05 +00:00
c61d120d94
tw.addresses: add autochg_ignore_labels attr 2026-10-05 14:30:05 +00:00