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

types: read the deposit address a deposit carries#142
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 credits the all-zeros address, so the coins are unspendable. The enforcer sends the address as s9_<address>_<checksum>, and proto.rs passed that whole string to Address::from_str, which fails.

from_deposit_address reads that format, so a deposit credits the address it carries. This changes which address a deposit credits, so 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 from cdc6e5f to f7b0bdd Compare September 5, 2026 06:10
@octobocto
octobocto force-pushed the 2026-08-31-deposit-address branch from f7b0bdd to 290f56d Compare September 5, 2026 06:21
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