mirror of
https://github.com/luxfi/bridge.git
synced 2026-09-24 00:26:46 +00:00
Add internal/substrate package containing the minimal Polkadot wire
primitives the bridge needs to sign + broadcast balances.transfer_keep_alive
extrinsics:
- SCALE codec primitives (compact ints, fixed-width LE ints, byte slices
bare + length-prefixed) — enough to encode ExtrinsicPayloadV4 + a v4
signed extrinsic. Not a general reflection-driven encoder.
- AccountId32 derivation from a compressed secp256k1 pubkey via
blake2_256 — matches sp_io::hashing::blake2_256 on the runtime side.
- SS58 base58check encoder + decoder with single-byte network prefixes
(Polkadot=0, Kusama=2, generic=42). Verified against the canonical
Alice fixture in both Polkadot mainnet ("15oF4u...") and substrate
generic ("5Grwva...") forms.
- ExtrinsicPayloadV4 builder: SCALE(call) || era || nonce || tip ||
spec_version || tx_version || genesis_hash || block_hash, with the
>256-byte → blake2_256 hashing rule.
- v4 signed-extrinsic assembler: 0x84 version byte || MultiAddress::Id
signer (33B) || MultiSignature(scheme, sig) || era || nonce || tip ||
call, length-prefixed compact-style.
The substrate primitives are leaf code with no network I/O. Test vectors
are pinned against the Polkadot JS SDK and substrate runtime references.