fix(thorchain): keep outbound memo references intact with passthrough

🔎 Visual review: building it for 87eff521; the link appears here.

Problem

When an inbound memo carries passthrough data (=:BTC.BTC:<addr>|d7), the outbound memo gets that data appended and is then cut to the chain's max memo length. UTXO chains allow 80 bytes, but OUT: plus an 88-character Solana tx ID is already 92. The cut removes the end of the ID, Bifrost cannot parse the memo, and the outbound is never signed. This has happened on mainnet with SOL → BTC swaps.

Change

New Chain.MaxOutboundMemoLength(); prepareTxOutItem uses it to limit only the passthrough part:

  • BTC, LTC, BCH, DOGE: 239 bytes in total (MaxMemoSizeUtxoExtended). Bifrost already encodes these memos with continuation outputs and decodes them, within the scanner's output limit.
  • ZEC: stays at 80. Its signer sizes the fee from the memo without passthrough, as one output, so longer memos would underpay ZIP-317 at 5,000 zats per action. Zebra 6.4.0+ charges 1,000 per action, so this is a margin for older fee policies.
  • The protocol memo is never cut. If the reference alone is over budget, the passthrough is dropped.
  • On UTXO chains, passthrough stops at the first non-printable byte or ^ (the continuation marker).
  • Other chains keep their limit; the cut no longer splits the reference or a UTF-8 character.

No Bifrost production changes, no migration.

Cost

A 239-byte BTC memo adds up to 8 dust continuation outputs (294 sats each, 2,352 in total) plus their fee. These are paid as protocol gas and can exceed the user's outbound fee.

Not in this MR

  • Repair of outbounds that are already stuck with a cut memo; that is handled separately.
  • Sizing the ZEC fee from the real outputs, which would let ZEC use 239 bytes too.

Testing

  • x/thorchain: TestOutboundMemoPassthrough, TestZECOutboundMemoPassthrough, TestPrepareTxOutExtendedMemo
  • bifrost/.../utxo: TestOutboundMemoContinuationRoundTrip, TestZECOutboundMemoBudgetFee (checks the real signed outputs against the ZIP-317 fee), plus a 95-byte memo case in the BTC TestSignTxHappyPathWithPrivateKey
  • Raising ZEC to 239 makes both ZEC tests fail.
  • TestAddOutTxItem with -tags=mainnet fails on develop too (112499 vs 112500); this MR doesn't change it.
Edited by Huginn Ai

Merge request reports

Loading
Loading