findSaplingAddressFrom method

SaplingDerivedAddress? findSaplingAddressFrom(
  1. DiversifierIndex from
)

Finds the first Sapling-derived address starting from the given diversifier index.

Implementation

SaplingDerivedAddress? findSaplingAddressFrom(DiversifierIndex from) {
  final sapling = getSapling();
  final addr = sapling.findAddress(from);
  if (addr == null) return null;
  final addressBytes = addr.$1.toBytes();
  final addrString = ZCashAddrEncoder().encodeKey(
    addressBytes,
    addrType: ZCashAddressType.sapling,
    network: config.network,
  );
  return SaplingDerivedAddress(
    address: addrString,
    paymentAddress: SaplingPaymentAddress.fromBytes(addressBytes),
    index: addr.$2,
    receiver: ReceiverSapling(
      data: addressBytes,
      mode: UnifiedReceiverMode.address,
    ),
  );
}