cardano-wallet-core-2022.7.1: The Wallet Backend for a Cardano node.
Copyright © 2018-2020 IOHK
License Apache-2.0
Safe Haskell None
Language Haskell2010

Cardano.Wallet.Primitive.AddressDiscovery

Description

This module contains types for address discovery. The two address discovery schemes implemented are:

Synopsis

Abstractions

class IsOurs s entity where Source #

Checks whether or not a given entity belongs to us.

This abstraction exists to give us the ability to keep the wallet business logic agnostic to the address derivation and discovery mechanisms.

This is needed because two different address schemes lives on Cardano:

  • A hierarchical random scheme: rather custom made, with several flaws; this is the original and now legacy address scheme.
  • A hierarchical sequential scheme: a new scheme based on the BIP-0044 specification, which is better suited for our present needs.

In practice, we will need a wallet that can support both, even if not at the same time, and this little abstraction can buy us this without introducing too much overhead.

Methods

isOurs Source #

Arguments

:: entity
-> s
-> ( Maybe ( NonEmpty DerivationIndex ), s)

Returns derivation path if the entity is ours, otherwise Nothing.

Instances

Instances details
IsOurs ( RndState n) RewardAccount Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

IsOurs ( RndState n) Address Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

IsOurs ( RndAnyState n p) RewardAccount Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

KnownNat p => IsOurs ( RndAnyState n p) Address Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

SupportsDiscovery n k => IsOurs ( SeqState n k) Address Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Sequential

IsOurs ( SeqState n ShelleyKey ) RewardAccount Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDerivation.Shelley

IsOurs ( SeqState n IcarusKey ) RewardAccount Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDerivation.Icarus

IsOurs ( SharedState n k) RewardAccount Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

SupportsDiscovery n k => IsOurs ( SharedState n k) Address Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

IsOurs ( SeqAnyState n k p) RewardAccount Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Sequential

KnownNat p => IsOurs ( SeqAnyState n k p) Address Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Sequential

class IsOurs s Address => IsOwned s key where Source #

More powerful than isOurs , this abstractions offer the underlying state the ability to find / compute the address private key corresponding to a given known address.

Requiring IsOwned as a constraint supposed that there is a way to recover the root private key of a particular wallet. This isn't true for externally owned wallet which would delegate its key management to a third party (like a hardware Ledger or Trezor).

Methods

isOwned Source #

Arguments

:: s
-> (key ' RootK XPrv , Passphrase "encryption")
-> Address
-> Maybe (key ' AddressK XPrv , Passphrase "encryption")

Derive the private key corresponding to an address. Careful, this operation can be costly. Note that the state is discarded from this function as we do not intend to discover any addresses from this operation; This is merely a lookup from known addresses.

class GenChange s where Source #

Abstracting over change address generation. In theory, this is only needed for sending transactions on a wallet following a particular scheme. This abstractions allows for defining an heuristic to pick new change address. For instance, in BIP-44, change addresses belong to a particular change chain (also called "Internal Chain").

Associated Types

type ArgGenChange s :: Type Source #

Methods

genChange Source #

Arguments

:: ArgGenChange s
-> s
-> ( Address , s)

Generate a new change address for the given scheme. The rules for generating a new change address depends on the underlying scheme.

Instances

Instances details
PaymentAddress n ByronKey => GenChange ( RndState n) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

Associated Types

type ArgGenChange ( RndState n) Source #

PaymentAddress n ByronKey => GenChange ( RndAnyState n p) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

Associated Types

type ArgGenChange ( RndAnyState n p) Source #

SoftDerivation k => GenChange ( SeqState n k) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Sequential

Associated Types

type ArgGenChange ( SeqState n k) Source #

GenChange ( SharedState n k) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

Associated Types

type ArgGenChange ( SharedState n k) Source #

SoftDerivation k => GenChange ( SeqAnyState n k p) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Sequential

Associated Types

type ArgGenChange ( SeqAnyState n k p) Source #

class CompareDiscovery s where Source #

Ordering addresses by discovery date.

If a1 has been discovered before a2 , then the following equation holds:

compareDiscovery s a1 a2 == LT

If a1 has been discovered after a2 , then the following equation holds:

compareDiscovery s a1 a2 == GT

Note that, if an address isn't known it is considered not discovered and therefore, is always _greater than_ any known address.

class KnownAddresses s where Source #

Extract the list of all known addresses.

NOTE: Change addresses aren't considered "known" until they've been used. The rationale is that, we don't want users or consumers of the wallet to be using change addresses prematurely.

coinTypeAda :: Index ' Hardened ' CoinTypeK Source #

One master node (seed) can be used for unlimited number of independent cryptocoins such as Bitcoin, Litecoin or Namecoin. However, sharing the same space for various cryptocoins has some disadvantages.

This level creates a separate subtree for every cryptocoin, avoiding reusing addresses across cryptocoins and improving privacy issues.

Coin type is a constant, set for each cryptocoin. For Cardano this constant is set to 1815' (or 0x80000717). 1815 is the birthyear of our beloved Ada Lovelace.

Hardened derivation is used at this level.

class MaybeLight s where Source #

Checks whether the address discovery state s works in light-mode and returns a procedure for discovering addresses if that is indeed the case.

Methods

maybeDiscover :: Maybe (LightDiscoverTxs s) Source #

newtype DiscoverTxs addr txs s Source #

Function that discovers transactions based on an address.

Constructors

DiscoverTxs

Fields

emptyPendingIxs :: PendingIxs k Source #

An empty pending set of change indexes.

NOTE: We do not define a Monoid instance here because there's no rational of combining two pending sets.

pendingIxsFromList :: [ Index ' Soft k] -> PendingIxs k Source #

Construct a PendingIxs from a list, ensuring that it is a set of indexes in descending order.

nextChangeIndex :: forall (key :: Depth -> Type -> Type ) k. Pool ( KeyFingerprint "payment" key) ( Index ' Soft k) -> PendingIxs k -> ( Index ' Soft k, PendingIxs k) Source #

Get the next change index; If every available indexes have already been taken, we'll rotate the pending set and re-use already provided indexes.

updatePendingIxs :: Index ' Soft k -> PendingIxs k -> PendingIxs k Source #

Update the set of pending indexes by discarding every indexes _below_ the given index.

Why is that?

Because we really do care about the higher index that was last used in order to know from where we can generate new indexes.