Bitcoin Forum
November 21, 2026, 03:51:25 AM *
News: Latest Bitcoin Core release: 32.1 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Thorchain technical discussion (Bitcoin-focused). Stop the UTXO set spam! And...  (Read 16 times)
This is a self-moderated topic. If you do not want to be moderated by the person who started this topic, create a new topic.
nullius (OP)
Copper Member
Hero Member
*****
Offline

Activity: 672
Merit: 2884


Privacy is necessary & sufficient for fungibility.


View Profile WWW
November 20, 2026, 11:55:54 PM
 #1

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 contents


I 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 glance

In 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...

Info

For 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:

  • Why does a Bitcoin address need to be “funded for refunds”?  (Protip:  It doesn’t.)  Will Thorchain fail a tx, with potential loss of funds, if the refund address is not “funded for refunds”?
      
  • I want to send a tx with no change, where all input funds are consumed by Thorchain + tx fee.  This is actually my own biggest use case for Thorchain, and the basis of my idea to build a project for Thorchain:  It will use a 1-in, 2-out Bitcoin tx (1 TxOut paying to Thorchain, 1 TxOut with OP_RETURN memo).  Will Thorchain fail to parse this?  With loss of funds?
      
  • If ThorChain requires three TxOuts in a specific order, is there any creative way to hack around it?  I don’t immediately see one, as I can’t send a change amount of 0—and anyway, Thorchain looks so hypersensitive that I’d fear it would choke on this.
    • Set Asgard vault as VOUT0: Send the transaction amount to the current Asgard vault address as the first output (VOUT0), obtainable from the Inbound Addresses endpoint.
    • Return change to VIN0: Direct all change back to the input address (VIN0) in a subsequent output, e.g., VOUT1, as THORChain identifies the user by VIN0 for refunds.
    • Include memo in OP_RETURN: Add the transaction memo as an OP_RETURN output, typically in VOUT2, to specify the user’s intent (e.g., swap, add liquidity). Refer to Memos for format details.
     
  • Not a question, but a comment:  This stuff about “VIN0”, and the limitations on inputs elsewhere in the documentation, are all bad design.  Thorchain should be changed; it shouldn’t care at all about deposit tx inputs, but only outputs.  Don’t even try to parse the inputs!  This is Bitcoin 101, a newbie-level (or Ethereum dev) learning issue.

    Bitcoin addresses are used to receive payments, but not to send them: there is no concept of a "from" address in Bitcoin.
     
  • Is any of this “IDs the user as the address in VIN0” stuff relevant at all, if I follow the instructions to specify a custom refund address?

    Custom Refund Address

    By default, in the case of a refund the protocol will return the inbound swap to the original sender. However, in the case of protocol <> protocol interactions, many times the original sender is a smart contract, and not the user's EOA. In these cases, a custom refund address can be defined in the memo, which will ensure the user will receive the refund and not the smart contract.

    Params:

    • refund_address: User's refund address. Needs to be a valid address for the inbound asset, otherwise refunds will be returned to the sender

    Memo format: =:BTC.BTC:<destination>/<refund_address>

    Quote example: https://gateway.liquify.com/chain/thorchain_api/thorchain/quote/swap?amount=100000000&from_asset=ETH.ETH&to_asset=BTC.BTC&destination=bc1qyl7wjm2ldfezgnjk2c78adqlk7dvtm8sd7gn0q&refund_address=0x3021c479f7f8c9f1d5c7d8523ba5e22c0bcb5430

    [This forum’s buggy BBcode can’t put a code block inside a quote block inside a list item.]
    [code]{
      ...
      "memo": "=:BTC.BTC:bc1qyl7wjm2ldfezgnjk2c78adqlk7dvtm8sd7gn0q/0x3021c479f7f8c9f1d5c7d8523ba5e22c0bcb5430",
      ...
    }
    [/code]



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 issues

The 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 Formats

Below are the list of supported Address Formats. Not using this risks loss of funds.

ChainSupported Address FormatNotes
BTCP2WSH /w Bech32 (preferred), P2WPKH /w Bech32, P2PKH, P2SH, P2TRDo 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?)

ChainSupported Address FormatNotes
XMRStandard (4…) and Subaddress (8…), Monero Base58Integrated 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

Code:
{
  "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 path

All 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.  Wink


⚠︎ 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).

▄▄████████████████████▄▄
▄███████▀▀██████▀▀███████▄
█████▀██████████████▀█████
████████▄▄██████▄▄████▀███
██████████████████████████
██▄▄██████████████▄▄██████
██▀▀██████████████████▄▄██
██████▀▀██████████████▀▀██
██████████████████████████
███▄████▀▀██████▀▀████████
█████▄██████████████▄█████
▀███████▄▄██████▄▄███████▀
▀▀████████████████████▀▀

 DΞX.fo 
▄▄██████
█████████
██████████
██████████
██████████
█████████
▀▀██████

▄███████
▄██████████
████████████
█████████████
█████████████
|███████▄███▄███▄███▄██
█████████▄▀█████▀▄████
███▄████████▀█▀████████▄
█████████▀███████▀██████
████████████████████████
█▄██▄▀▀▀▀▀██▄▀▄██▀▀▀▀▀▄▀
▄████▄▀▀▀██▀███▀██▀▀▀▄
████████████████████
▀███████████████████▄
█▀████████████████████▄▄
████████████████████████
████████████████████████
███▀███████████████████▀
|
nullius (OP)
Copper Member
Hero Member
*****
Offline

Activity: 672
Merit: 2884


Privacy is necessary & sufficient for fungibility.


View Profile WWW
November 20, 2026, 11:56:49 PM
 #2

Reserved for Github issue links, etc., when/as I file them.

▄▄████████████████████▄▄
▄███████▀▀██████▀▀███████▄
█████▀██████████████▀█████
████████▄▄██████▄▄████▀███
██████████████████████████
██▄▄██████████████▄▄██████
██▀▀██████████████████▄▄██
██████▀▀██████████████▀▀██
██████████████████████████
███▄████▀▀██████▀▀████████
█████▄██████████████▄█████
▀███████▄▄██████▄▄███████▀
▀▀████████████████████▀▀

 DΞX.fo 
▄▄██████
█████████
██████████
██████████
██████████
█████████
▀▀██████

▄███████
▄██████████
████████████
█████████████
█████████████
|███████▄███▄███▄███▄██
█████████▄▀█████▀▄████
███▄████████▀█▀████████▄
█████████▀███████▀██████
████████████████████████
█▄██▄▀▀▀▀▀██▄▀▄██▀▀▀▀▀▄▀
▄████▄▀▀▀██▀███▀██▀▀▀▄
████████████████████
▀███████████████████▄
█▀████████████████████▄▄
████████████████████████
████████████████████████
███▀███████████████████▀
|
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!