NodeWithAddress.fromChainIndex constructor

NodeWithAddress.fromChainIndex({
  1. required BIP32 node,
  2. required String address,
  3. required int chainIndex,
  4. required String derivationPath,
  5. required Map<AddressType, String> addresses,
  6. HDWalletPurpose? walletPurpose,
})

Implementation

factory NodeWithAddress.fromChainIndex({
  required BIP32 node,
  required String address,
  required int chainIndex,
  required String derivationPath,
  required Map<AddressType, String> addresses,
  HDWalletPurpose? walletPurpose,
}) {
  if (chainIndex == EXTERNAL_CHAIN_INDEX) {
    return ReceiveNode(
      bip32Node: node,
      address: address,
      derivationPath: derivationPath,
      addresses: addresses,
      walletPurpose: walletPurpose,
      publicKey: node.publicKey.toHex,
    );
  }
  if (chainIndex == INTERNAL_CHAIN_INDEX) {
    return ChangeNode(
      bip32Node: node,
      address: address,
      derivationPath: derivationPath,
      addresses: addresses,
      walletPurpose: walletPurpose,
      publicKey: node.publicKey.toHex,
    );
  }
  throw UnsupportedError("unexpected chainIndex");
}