Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core-dart/.dart_tool/package_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
],
"generator": "pub",
"generatorVersion": "3.9.2",
"flutterRoot": "file:///C:/Users/TCE%20HUB/fvm/versions/3.35.7",
"flutterRoot": "file:///C:/Users/TCE%20HUB/fvm/default",
"flutterVersion": "3.35.7",
"pubCache": "file:///C:/Users/TCE%20HUB/AppData/Local/Pub/Cache"
}
Binary file not shown.
8 changes: 4 additions & 4 deletions packages/core-dart/lib/src/address/stellar_address.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:meta/meta.dart';
import '../address/codes.dart';
import '../muxed/decode.dart';
import '../address/detect.dart';
import '../exceptions.dart';
import 'codes.dart';
import 'detect.dart';

/// An immutable representation of a Stellar Address.
@immutable
Expand Down Expand Up @@ -65,8 +65,8 @@ class StellarAddress {
return StellarAddress._(
kind: AddressKind.m,
raw: address,
baseG: decoded['baseG'] as String?,
muxedId: decoded['id'] as BigInt?,
baseG: decoded.baseG,
muxedId: decoded.id,
);
} catch (error) {
throw StellarAddressException(
Expand Down
10 changes: 10 additions & 0 deletions packages/core-dart/lib/src/muxed/decode.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
import 'dart:typed_data';
import '../util/strkey.dart';
import 'decoded_muxed_address.dart';
import '../exceptions.dart';

class MuxedDecoder {
static DecodedMuxedAddress decodeMuxedString(String mAddress) {
final decoded = StrKeyUtil.decodeBase32(mAddress);

if (decoded.length != 43) {
throw const StellarAddressException('Invalid muxed address length');
}

if (decoded[0] != 0x60) {
throw const StellarAddressException('Invalid muxed address prefix');
}

// Payload starts at index 1 (skip version byte 0x60)
// 32 bytes pubkey + 8 bytes ID = 40 bytes
final pubkey = decoded.sublist(1, 33);
Expand Down
4 changes: 2 additions & 2 deletions packages/core-dart/lib/src/routing/extract.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ RoutingResult extractRouting(RoutingInput input) {
if (parsed.kind == AddressKind.m) {
final warnings = List<Warning>.from(parsed.warnings);
final decoded = MuxedDecoder.decodeMuxedString(parsed.address);
final baseG = decoded['baseG'] as String;
final muxedId = (decoded['id'] as BigInt).toString();
final baseG = decoded.baseG;
final muxedId = decoded.id.toString();

if (input.memoType == 'none') {
return RoutingResult(
Expand Down
12 changes: 12 additions & 0 deletions packages/core-dart/test/debug_decode.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:stellar_address_kit/stellar_address_kit.dart';

void main() {
const baseG = 'GAYCUYT553C5LHVE2XPW5GMEJT4BXGM7AHMJWLAPZP53KJO7EIQADRSI';
try {
print('Testing decode on G address...');
final result = MuxedAddress.decode(baseG);
print('Result: $result');
} catch (e) {
print('Caught expected error: $e');
}
}
10 changes: 5 additions & 5 deletions packages/core-dart/test/muxed_round_trip_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ BigInt _randomUint64(Random rng) {
// Build 64 random bits from two 32-bit values.
final hi = BigInt.from(rng.nextInt(1 << 32));
final lo = BigInt.from(rng.nextInt(1 << 32));
return (hi << 32) | lo;
return (hi << 32) + lo;
}

void main() {
Expand All @@ -20,7 +20,7 @@ void main() {
// Feature: muxed-decode-typed-dto, Property 1: Construction preserves field values
// For any baseG string and BigInt id, DecodedMuxedAddress(baseG, id).baseG == baseG and .id == id
group('Property 1: Construction preserves field values', () {
test('field values are preserved across $\_iterations random instances', () {
test('field values are preserved across $_iterations random instances', () {
for (var i = 0; i < _iterations; i++) {
final id = _randomUint64(rng);
final dto = DecodedMuxedAddress(baseG: _baseG, id: id);
Expand All @@ -43,7 +43,7 @@ void main() {
// Feature: muxed-decode-typed-dto, Property 2: Equality and hashCode consistency
// For any two DecodedMuxedAddress instances, == and hashCode are consistent with field equality
group('Property 2: Equality and hashCode consistency', () {
test('equal instances have equal hashCode across $\_iterations pairs', () {
test('equal instances have equal hashCode across $_iterations pairs', () {
for (var i = 0; i < _iterations; i++) {
final id = _randomUint64(rng);
final a = DecodedMuxedAddress(baseG: _baseG, id: id);
Expand All @@ -68,7 +68,7 @@ void main() {
// Feature: muxed-decode-typed-dto, Property 3: toString contains both fields
// For any DecodedMuxedAddress, toString() contains baseG and id
group('Property 3: toString contains both fields', () {
test('toString contains baseG and id across $\_iterations instances', () {
test('toString contains baseG and id across $_iterations instances', () {
for (var i = 0; i < _iterations; i++) {
final id = _randomUint64(rng);
final dto = DecodedMuxedAddress(baseG: _baseG, id: id);
Expand All @@ -84,7 +84,7 @@ void main() {
// Feature: muxed-decode-typed-dto, Property 4: Round-trip encode → decode → encode
// For any valid baseG and uint64 id, encode then decode then re-encode is identity
group('Property 4: Round-trip encode → decode → encode', () {
test('round-trip preserves baseG and id across $\_iterations random ids',
test('round-trip preserves baseG and id across $_iterations random ids',
() {
for (var i = 0; i < _iterations; i++) {
final id = _randomUint64(rng);
Expand Down
Loading