diff --git a/lib/src/bip/bip32/address_encoders/bitcoin/bitcoin_p2wpkh_address_encoder.dart b/lib/src/bip/bip32/address_encoders/bitcoin/bitcoin_p2wpkh_address_encoder.dart index 4258bb05..4bd3f7c4 100644 --- a/lib/src/bip/bip32/address_encoders/bitcoin/bitcoin_p2wpkh_address_encoder.dart +++ b/lib/src/bip/bip32/address_encoders/bitcoin/bitcoin_p2wpkh_address_encoder.dart @@ -26,6 +26,6 @@ class BitcoinP2WPKHAddressEncoder extends ABlockchainAddressEncoder String encodePublicKey(Secp256k1PublicKey publicKey) { Uint8List publicKeyFingerprint = Sha256().convert(publicKey.compressed).byteList; Uint8List publicKeyHash = Ripemd160().process(publicKeyFingerprint); - - return Bech32Codec.encode(Bech32Pair(hrp: hrp, data: publicKeyHash)); + Bech32 bech32 = Bech32(hrp, publicKeyHash); + return Bech32Encoder().encode(bech32); } } diff --git a/lib/src/transactions/cosmos/cosmos_acc_address.dart b/lib/src/transactions/cosmos/cosmos_acc_address.dart index 7eef3291..0742ea56 100644 --- a/lib/src/transactions/cosmos/cosmos_acc_address.dart +++ b/lib/src/transactions/cosmos/cosmos_acc_address.dart @@ -9,27 +9,29 @@ class CosmosAccAddress extends AProtobufField { final String hrp; /// The bytes of the address - final Uint8List bytes; + final Uint8List uint8List; /// Creates [CosmosAccountAddress] from a Bech32 encoded address. factory CosmosAccAddress(String address) { - Bech32Pair decodedBech32 = Bech32Codec.decode(address); - return CosmosAccAddress._(decodedBech32.hrp, decodedBech32.data); + Bech32 decodedBech32 = Bech32Decoder().decode(address); + return CosmosAccAddress._(decodedBech32.hrp, decodedBech32.uint8List); } /// Private constructor used by the factory to initialize the hrp and bytes. - const CosmosAccAddress._(this.hrp, this.bytes); + const CosmosAccAddress._(this.hrp, this.uint8List); @override List encode(int fieldNumber) { - return ProtobufBytes(bytes).encode(fieldNumber); + return ProtobufBytes(uint8List).encode(fieldNumber); } /// Returns the Bech32 encoded address as a string. - String get value => Bech32Codec.encode(Bech32Pair(hrp: hrp, data: bytes)); + String get value { + return Bech32Encoder().encode(Bech32(hrp, uint8List)); + } @override - List get props => [hrp, bytes]; + List get props => [hrp, uint8List]; @override String toString() => value; diff --git a/pubspec.yaml b/pubspec.yaml index 872874e1..2b937bd1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: cryptography_utils description: "Dart package containing utility methods for common cryptographic and blockchain-specific operations" publish_to: none -version: 0.0.24 +version: 0.0.25 environment: sdk: ">=3.2.6"