This thread is for
technical discussion of Thorchain. My OP here is technical about Bitcoin; I think that
Development & Technical Discussion is the only board where most of the regulars have sufficient expertise for this, it will be elementary to many, and some know much more than I do. Moreover, the section about
Thorchain’s UTXO set spam should be of interest to all Bitcoin experts. Accordingly, I ask the moderators to keep this topic here; however, if they do not, I ask them only to move it somewhere that I will keep self-mod.
Background: I urgently need to make a no-KYC BTC→ZEC swap, and I can’t find any good options. The Thorchain swap web app
requires WASM, which I refuse to enable. Therefore, what with my being incorrigibly me, I got an idea for a project to build on Thorchain—and I dug into the Thorchain dev docs.
Whereupon I wound up with a jumble of notes, which I have roughly sectioned into this post. To avoid all the scary “loss of funds” warning issues, I hope to get some technical support from the Thorchain side; the project apparently has
at least two official forum accounts. Moreover, there are some issues here that need to be discussed with the Bitcoin technical community.
Table of contentsI want to like Thorchain. Actually, right now, I have an incentive to
need to like Thorchain. This post may come off as harsh, but it’s necessary. I want something that I and everyone else can use safely—and which
doesn’t spam the Bitcoin UTXO set with dust payments to fake addresses. My starting perusal of the docs finds a disturbing and pervasive lack of Bitcoin competence.
First list of questions, at a glanceIn the Thorchain developer documentation, the
Quickstart Guide looks easy. Superficially, it
looks like I could hack together my own Thorchain client in almost no time, and make an exchange today!
Then, I see the first issue: They don’t even know that Bitcoin’s
OP_RETURN is now unlimited. The docs are full of stuff like this...
InfoFor chains with limited memo space (like Bitcoin's 80-byte OP_RETURN), see the
Memoless Swaps Guide for reference memo registration and amount encoding.
...and their instructions say to spam the UTXO set with fake P2WPKH addresses, for overflow past the 80-byte
OP_RETURN limit. (More on this in a moment.)
Then, it gets worse. (Background colour is in the original.)
Sending Transactions
[...]
UTXO Chains
[...] Ensure the following steps are completed to avoid transaction failures or loss of funds. [...]
Warning
Do not use HD wallets that forward the change to a new address, because THORChain IDs the user as the address in VIN0. The user must keep their VIN0 address funded for refunds.
Danger
Override randomised VOUT ordering; THORChain requires specific output ordering. Funds using wrong ordering are very likely to be lost.
Questions:
Please stop the UTXO set spam!These instructions are
UTXO set spam, harmful to the Bitcoin network, and totally unnecessary in Bitcoin since the
OP_RETURN limit was removed:
Memo greater than 80 characters- Ensure the address type is supported
- Send the transaction with Asgard vault as VOUT0
- Pass all change back to the VIN0 address in a subsequent VOUT e.g. VOUT1
- Take the first 79 characters of the memo and append '^' and use that as an OP_RETURN in a subsequent VOUT e.g. VOUT2
- Add remaining characters encoded as p2wpkh address as subsequent VOUT
- encode remaining characters to hex representation
- split the resulting string into chunks of 40 characters each, append "00" to the last chunk until its length also matches 40 characters
- for each hex encoded chunk, create a VOUT sending the minimum allowed amount of sats for the specific chain to the script pub key: '0014' + <chunk>
- ...
Bug: This spamming of fake P2WPKH is a bug that needs to be fixed ASAP—not only in the documentation, but also in all existing Thorchain swap client software! In Bitcoin, use only
OP_RETURN.
Observation: As written, the above quote’s stuff about hex shows a lack of competence at programming for binary protocols.
Important practical question: Will Thorchain parse an
OP_RETURN >80 octets, or will it fail the transaction with potential loss of funds?
Note: The “Memoless Swaps” feature requires the RUNE token. This makes it useless to people who don’t have RUNE. It also makes it useless for any privacy application, where different swaps should not be linked to the same sender.
Phase 1: Register Reference Memo- Send Registration Transaction: Send RUNE to inbound address with memo:
Supported address format issuesThe documentation is full of warnings like this (highlighting is mine):
"notes": "First output should be to inbound_address, second output should be change back to self, third output should be OP_RETURN, limited to 80 bytes. Do not send below the dust threshold. Do not use exotic spend scripts, locks or address formats (P2WSH with Bech32 address format preferred).",
The documentation does include P2TR:
Supported Address FormatsBelow are the list of supported Address Formats. Not using this risks
loss of funds.
| Chain | Supported Address Format | Notes |
| BTC | P2WSH /w Bech32 (preferred), P2WPKH /w Bech32, P2PKH, P2SH, P2TR | Do not send below the dust threshold. Do not use exotic spend scripts, locks or address formats |
Question: Will a
BIP 352 Silent Payments output as VIN be recognized as P2TR? It
should, but I want to confirm this due to the scary “loss of funds” warning. Anyway, Thorchain
shouldn’t even care, insofar as this pertains to inputs.
Doc bug: Zcash is not listed under “supported address format”, even though
Thorchain supports Zcash. I
presume that they support (only) P2PKH on Zcash, but this should be documented by Thorchain developers. (Zcash transparent pool was originally codeforked from Bitcoin Core pre-Segwit, still has no Segwit, and AFAIK has some modifications by Zcash devs that I don’t think are relevant here.)
Once again: Bitcoin has no
from address, and
Thorchain shouldn’t pretend it does. The only “supported address” issues should pertain to (a) manually specified refund addresses for inbound Bitcoin, and (b) swaps
to Bitcoin from other currencies.
Oh, so you can cope with no from address? (Really?)| Chain | Supported Address Format | Notes |
| XMR | Standard (4…) and Subaddress (8…), Monero Base58 | Integrated addresses and payment IDs are not supported. A refund address is required in the swap memo — Monero hides the sender, so a failed swap without one cannot be refunded. |
Zcash question: Say someone wants to swap ZEC→BTC, and sends incoming ZEC in an unshielding tx. This is totally normal in Zcash. As with XMR, you can’t even guess a “from address”. Is this handled the same as with XMR?
Bitcoin question: Can I
really ignore the scary “loss of funds” warnings, ignore all the nonsense about “VIN0”, ignore all the restrictions on parent tx(es) in inputs, and simply provide a custom refund address?
I asked this already, but the “loss of funds” warnings scare me into asking twice!
Bitcoin block timing issues{
"inbound_address": "bc1qt9723ak9t7lu7a97lt9kelq4gnrlmyvk4yhzwr",
"inbound_confirmation_blocks": 1,
"inbound_confirmation_seconds": 600,
[...]
"expiry": 1722575316,
[...]
"recommended_gas_rate": "4",
"gas_rate_units": "satsperbyte",
[...]
[...]
For security reasons, your inbound transaction will be delayed by 600 seconds (1 BTC Block) and 1074 seconds (or 179 native THORChain blocks) for the outbound transaction, 2640 seconds all up*.
Questions and comments:- Upon exactly what condition does Thorchain decide if an inbound tx is timely versus expired? Observation within a majority of Thorchain nodes’ Bitcoin mempools? (Note plural “mempools”; there is no such thing as “the mempool”.) Observation in mempools and payment of whatever miner fee Thorchain thinks is sufficient? Confirmation? The docs are not clear to developers about how to predict what’ll happen, in all the various edge cases where a tx takes more blocks than expected to confirm.
- Does “gas rate units” of “satsperbyte” mean “satsperbyte”, or “satspervbyte”? There’s a huge difference! If Thorchain is looking at sats per byte, it’s a pretty severe bug; it’ll cause and require significant overpayment of fees. Ever since 2017, correct fee calculation is sats per vbyte.
- Bitcoin does NOT have a blocktime of 600 seconds. This is one of my pet peeve; see post history. 600 seconds is the targeted average of an exponential distribution. Only about 63% of Bitcoin blocks will occur within 600 seconds of the last block. Any security system that assumes “a Bitcoin block takes 600 seconds” is poorly designed.
Feature suggestion: Taproot recovery pathAll of these “loss of funds” doc warnings show a brittle design—and with modern Bitcoin, it’s so very unnecessary.
I suggest to the Thorchain developers that for inbound Bitcoin, they should use a P2TR address with an alternative script that allows the user to spend the funds after some moderate time—say, 36 blocks for
an average of six hours. Then, if tx is successful, the Thorchain network simply needs to spend the funds first; otherwise, the user has an emergency recovery method in case of any “warning, warning, Thorchain loss of funds” scenario.
This is what Taproot is for!
I’d send a merit to the first person who suggests details of correct, optimal Taproot use for this—but maybe, if you are generous, you want to let this big commercial project offer me a consulting fee to help them with it.

⚠︎ Notice: Any posts directing me to a Discord channel, and any replies to such posts, shall be censored as spam/low-value/off-topic. I absolutely never use Discord. Some years ago, I did attempt to create a Discord account. I used a third-party open-source Discord app, which did not include any of Discord’s surveillance and user-tracking garbage. Needless to say, I used Tor. I follow a good example, as according to theymos, Satoshi Nakamoto always used Tor; doesn’t everyone use Tor for everything all the time? Discord instantly autobanned my new account, even though I used a paid anonymous SMS for “phone verification”. And that’s that. Discord is permabanned in nullian cypherspace. DO NOT MENTION DISCORD IN THIS THREAD (unless you sincerely criticize Discord, or earnestly thank me for banning it).