buildWalletFromHdWallet method

  1. @SquadronMethod.new()
  2. @walletMarshaler
Future<CardanoWallet> buildWalletFromHdWallet(
  1. @hdWalletMarshaler HdWallet hdWallet,
  2. @networkIdMarshaler NetworkId networkId
)

Implementation

@SquadronMethod()
@walletMarshaler
Future<CardanoWallet> buildWalletFromHdWallet(
  @hdWalletMarshaler HdWallet hdWallet,
  @networkIdMarshaler NetworkId networkId,
) async {
  final firstAddressKeyPair = hdWallet.deriveAddressKeys(role: Bip32KeyRole.payment, index: 0);
  final firstAddress = hdWallet.toBaseAddress(spendVerifyKey: firstAddressKeyPair.verifyKey, networkId: networkId);

  final stakeAddress = hdWallet.toRewardAddress(networkId: networkId);

  return CardanoWalletImpl(
    firstAddress: firstAddress,
    stakeAddress: stakeAddress,
    hdWallet: hdWallet,
    accountIndex: hdWallet.accountIndex,
  );
}