swaptxcreate.py 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. #!/usr/bin/env python3
  2. #
  3. # MMGen Wallet, a terminal-based cryptocurrency wallet
  4. # Copyright (C)2013-2025 The MMGen Project <mmgen@tuta.io>
  5. # Licensed under the GNU General Public License, Version 3:
  6. # https://www.gnu.org/licenses
  7. # Public project repositories:
  8. # https://github.com/mmgen/mmgen-wallet
  9. # https://gitlab.com/mmgen/mmgen-wallet
  10. """
  11. help.swaptxcreate: swaptxcreate and swaptxdo help notes for the MMGen Wallet suite
  12. """
  13. def help(proto, cfg):
  14. return """
  15. This script is similar in operation to ‘mmgen-txcreate’, only with additional
  16. steps. Users are advised to first familiarize themselves with the use of that
  17. script before attempting to perform a swap with this one.
  18. The tracking wallets of both the send and receive coins must be available when
  19. the script is invoked. If the two coin daemons are running on different hosts
  20. than the script, or with non-standard ports, coin-specific RPC options may be
  21. required (see EXAMPLES below).
  22. The swap protocol’s quote server on the Internet must be reachable either
  23. directly or via the SOCKS5 proxy specified with the --proxy option. To improve
  24. privacy, it’s recommended to proxy requests to the quote server via Tor or
  25. some other anonymity network.
  26. The resulting transaction file is saved, signed, sent, and optionally bumped,
  27. exactly the same way as one created with ‘mmgen-txcreate’. Autosign with
  28. automount is likewise supported via the --autosign option.
  29. The command line must contain at minimum a send coin (COIN1) and receive coin
  30. (COIN2) symbol. Currently supported coins are BTC, LTC, BCH and ETH. All
  31. other arguments are optional. If AMT is specified, the specified value of
  32. send coin will be swapped and the rest returned to a change address in the
  33. originating tracking wallet. Otherwise, the entire value of the interactively
  34. selected inputs will be swapped.
  35. By default, the change (if applicable) and destination addresses are chosen
  36. automatically by finding the lowest-indexed unused addresses of the preferred
  37. address types in the send and receive tracking wallets. For Bitcoin and
  38. forks, types ‘B’, ‘S’ and ‘C’ (see ADDRESS TYPES below) are searched in that
  39. order for unused addresses. Note that sending to an unused address may be
  40. undesirable for Ethereum, where address (i.e. account) reuse is the norm. In
  41. that case, the user should specify a destination address on the command line.
  42. If the wallet contains eligible unused addresses with multiple Seed IDs, the
  43. user will be presented with a list of the lowest-indexed addresses of
  44. preferred type for each Seed ID and prompted to choose from among them.
  45. Change and destination addresses may also be specified manually with the
  46. CHG_ADDR and ADDR arguments. These may be given as full MMGen IDs or in the
  47. form ADDRTYPE_CODE or SEED_ID:ADDRTYPE_CODE (see EXAMPLES below and the
  48. ‘mmgen-txcreate’ help screen for details). For Ethereum, the CHG_ADDR
  49. argument is not supported.
  50. While discouraged, sending change or swapping to non-wallet addresses is also
  51. supported, in which case the signing script (‘mmgen-txsign’ or ‘mmgen-
  52. autosign’, as applicable) must be invoked with the --allow-non-wallet-swap
  53. option.
  54. Rather than specifying a transaction fee on the command line, it’s advisable
  55. to start with the fee suggested by the swap protocol quote server (the script
  56. does this automatically) and then adjust the fee interactively if desired.
  57. When choosing a fee, bear in mind that the longer the transaction remains
  58. unconfirmed, the greater the risk that the vault address will expire, leading
  59. to loss of funds. It’s therefore recommended to learn how to create, sign and
  60. send replacement transactions with ‘mmgen-txbump’ before performing a swap
  61. with this script. When bumping a stuck swap transaction, the safest option
  62. is to create a replacement transaction with one output that returns funds back
  63. to the originating tracking wallet, thus aborting the swap, rather than one
  64. that merely increases the fee (see EXAMPLES below).
  65. Before broadcasting the transaction, it’s a good idea to double-check the
  66. vault address on a block explorer such as thorchain.net or runescan.io.
  67. The MMGen Node Tools suite contains two useful tools to help with fine-tuning
  68. transaction fees, ‘mmnode-feeview’ and ‘mmnode-blocks-info’, in addition to
  69. ‘mmnode-ticker’, which can be used to calculate the current cross-rate between
  70. the asset pair of a swap, as well as the total receive value in terms of send
  71. value.
  72. TRADE LIMIT
  73. A target value for the swap may be set, known as the “trade limit”. If
  74. this target cannot be met, the network will refund the user’s coins, minus
  75. transaction fees (note that the refund goes to the address associated with the
  76. transaction’s first input, leading to coin reuse). Since under certain
  77. circumstances large amounts of slippage can occur, resulting in significant
  78. losses, setting a trade limit is highly recommended.
  79. The target may be given as either an absolute coin amount or percentage value.
  80. In the latter case, it’s interpreted as the percentage below the “expected
  81. amount out” returned by the swap quote server. Zero or negative percentage
  82. values are also accepted, but are likely to result in your coins being
  83. refunded.
  84. The trade limit is rounded to four digits of precision in order to reduce
  85. transaction size.
  86. """