Skip to content

types: read the deposit address a deposit carries - #142

Open
octobocto wants to merge 1 commit into
LayerTwo-Labs:masterfrom
octobocto:2026-08-31-deposit-address
Open

octobocto wants to merge 1 commit into
LayerTwo-Labs:masterfrom
octobocto:2026-08-31-deposit-address

Conversation

@octobocto

@octobocto octobocto commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

A deposit credited the all-zeros address on every network, because proto.rs passed the whole s{slot}_{base58}_{checksum} string to Address::from_str, which decodes base58 only. from_deposit_address strips the prefix, parses the address, and compares the whole string against format_for_deposit, so a wrong or short checksum fails. A bare address still parses, and every node must upgrade together.

@octobocto octobocto closed this Aug 31, 2026
@octobocto octobocto reopened this Aug 31, 2026
@octobocto
octobocto force-pushed the 2026-08-31-deposit-address branch from 98e12d4 to cdc6e5f Compare August 31, 2026 08:45
Coinelius pushed a commit to Coinelius/plain-bitassets that referenced this pull request Sep 1, 2026
The enforcer hands the node a deposit address as UTF-8 in the form
`s4_<address>_<checksum>`. proto.rs called `Address::from_str` on that whole
string, which base58 decodes it and fails, and the code then took
`Address::ALL_ZEROS` with only a warning — so every deposit credited
`11111111111111111111` and was unspendable.

The node could already write that format with `format_for_deposit` but could
never read it back. `from_deposit_address` reverses it, and the deposit path
still accepts a bare address. The silent ALL_ZEROS fallback stays, because
failing there could stop a node mid-sync.

Ported from LayerTwo-Labs/thunder-rust#142 by @octobocto, which fixes the same
bug in Thunder (slot 9), adapted to this crate's layout and
`AddressParseError`. Tests cover the round trip, a longer checksum, a wrong
checksum, a wrong sidechain number, and a bare address.

This changes which address a deposit credits, so every node on a chain must
run the same side of it. Do not mix patched and unpatched nodes on eCash
alphanet slot 4.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019i7HNfwdUXvoHEzp6MCmBE
@octobocto
octobocto force-pushed the 2026-08-31-deposit-address branch 2 times, most recently from f7b0bdd to 290f56d Compare September 5, 2026 06:21
@octobocto
octobocto force-pushed the 2026-08-31-deposit-address branch from 290f56d to 553db60 Compare September 27, 2026 13:59
@octobocto
octobocto force-pushed the 2026-08-31-deposit-address branch from 553db60 to 0d292a4 Compare September 27, 2026 14:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant