ADAByronAddress.legacyFromBip32 constructor

ADAByronAddress.legacyFromBip32({
  1. required CardanoByronLegacy bip32,
  2. required Bip32KeyIndex firstIndex,
  3. required Bip32KeyIndex secondIndex,
  4. ADANetwork network = ADANetwork.mainnet,
})

Factory constructor to create a legacy ADAByronAddress instance from a Bip32 structure.

Implementation

factory ADAByronAddress.legacyFromBip32(
    {required CardanoByronLegacy bip32,
    required Bip32KeyIndex firstIndex,
    required Bip32KeyIndex secondIndex,
    ADANetwork network = ADANetwork.mainnet}) {
  final publicKey =
      bip32.getPublicKey(firstIndex: firstIndex, secondIndex: secondIndex);
  final encode = AdaByronLegacyAddrEncoder()
      .encodeKeyWithInfo(publicKey.pubKey.compressed, {
    "net_tag": network,
    "chain_code": publicKey.chainCode.toBytes(),
    "hd_path": 'm/${firstIndex.toInt()}\'/${secondIndex.toInt()}\'',
    "hd_path_key": bip32.hdPathKey
  });
  return ADAByronAddress._(encode.encode(), encode, network);
}