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.Random

Description

An implementation of address discovery for the random address scheme as used by the legacy Cardano wallets.

Synopsis

State

data RndState (network :: NetworkDiscriminant ) Source #

HD random address discovery state and key material for AD.

Constructors

RndState

Fields

Instances

Instances details
Eq ( RndState network) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

Eq ( Prologue ( RndState n)) Source #
Instance details

Defined in Cardano.Wallet.Address.Book

Eq ( Discoveries ( RndState n)) Source #
Instance details

Defined in Cardano.Wallet.Address.Book

Show ( RndState network) Source #

There's no instance of Show for XPrv

Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

Generic ( RndState network) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

Associated Types

type Rep ( RndState network) :: Type -> Type Source #

NFData ( RndState network) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

Methods

rnf :: RndState network -> () Source #

Buildable ( RndState network) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

Buildable ( Prologue ( RndState n)) Source #
Instance details

Defined in Cardano.Wallet.Address.Book

MaybeLight ( RndState n) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

Methods

maybeDiscover :: Maybe (LightDiscoverTxs ( RndState n)) Source #

KnownAddresses ( RndState n) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

CompareDiscovery ( RndState n) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

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

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

Associated Types

type ArgGenChange ( RndState n) Source #

RndStateLike ( RndState n) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

AddressBookIso ( RndState n) Source #

Isomorphism for HD random address book.

Instance details

Defined in Cardano.Wallet.Address.Book

PersistAddressBook ( RndState n) Source #

Persisting RndState requires that the wallet root key has already been added to the database with putPrivateKey . Unlike sequential AD, random address discovery requires a root key to recognize addresses.

Instance details

Defined in Cardano.Wallet.DB.Store.Checkpoints

IsOwned ( RndState n) ByronKey Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

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

KnownDiscovery ( RndState network :: Type ) Source #
Instance details

Defined in Cardano.Wallet.Api.Types

type Rep ( RndState network) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

type ArgGenChange ( RndState n) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

data Prologue ( RndState n) Source #
Instance details

Defined in Cardano.Wallet.Address.Book

data Discoveries ( RndState n) Source #
Instance details

Defined in Cardano.Wallet.Address.Book

mkRndState :: ByronKey ' RootK XPrv -> Int -> RndState n Source #

Initialize the HD random address discovery state from a root key and RNG seed.

type DerivationPath = ( Index ' WholeDomain ' AccountK , Index ' WholeDomain ' AddressK ) Source #

Shortcut type alias for HD random address derivation path.

Low-level API

findUnusedPath :: StdGen -> Index ' Hardened ' AccountK -> Set DerivationPath -> ( DerivationPath , StdGen ) Source #

Randomly generates an address derivation path for a given account. If the path is already in the "blacklist", it will try generating another.

Note that performance of this function will degrade poorly as more of the account's address space is used up. We may have to improve it later.

unavailablePaths :: RndStateLike s => s -> Set DerivationPath Source #

Returns the set of derivation paths that should not be used for new address generation because they are already in use.

defaultAccountIndex :: RndStateLike s => s -> Index ' Hardened ' AccountK Source #

Default account used for generating new derivation paths.

withRNG :: RndStateLike s => s -> ( StdGen -> (a, StdGen )) -> (a, s) Source #

Default random number generator.

Benchmarking

newtype RndAnyState (network :: NetworkDiscriminant ) (p :: Nat ) Source #

An "unsound" alternative that can be used for benchmarking and stress testing. It re-uses the same underlying structure as the RndState but it discover addresses based on an arbitrary ratio instead of decrypting the derivation path.

The proportion is stored as a type-level parameter so that we don't have to alter the database schema to store it. It simply exists and depends on the caller creating the wallet to define it.

Constructors

RndAnyState

Fields

Instances

Instances details
Eq ( Prologue ( RndAnyState n p)) Source #
Instance details

Defined in Cardano.Wallet.Address.Book

Eq ( Discoveries ( RndAnyState n p)) Source #
Instance details

Defined in Cardano.Wallet.Address.Book

Show ( RndAnyState network p) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

Generic ( RndAnyState network p) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

Associated Types

type Rep ( RndAnyState network p) :: Type -> Type Source #

NFData ( RndAnyState n p) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

MaybeLight ( RndAnyState n p) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

Methods

maybeDiscover :: Maybe (LightDiscoverTxs ( RndAnyState n p)) Source #

KnownAddresses ( RndAnyState n p) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

CompareDiscovery ( RndAnyState n p) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

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 #

RndStateLike ( RndAnyState n p) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

AddressBookIso ( RndAnyState n p) Source #
Instance details

Defined in Cardano.Wallet.Address.Book

PersistAddressBook ( RndAnyState n p) Source #
Instance details

Defined in Cardano.Wallet.DB.Store.Checkpoints

KnownNat p => IsOwned ( RndAnyState n p) ByronKey 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

type Rep ( RndAnyState network p) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

type Rep ( RndAnyState network p) = D1 (' MetaData "RndAnyState" "Cardano.Wallet.Primitive.AddressDiscovery.Random" "cardano-wallet-core-2022.7.1-AGKhlyz9liLKN3QqZD1gj" ' True ) ( C1 (' MetaCons "RndAnyState" ' PrefixI ' True ) ( S1 (' MetaSel (' Just "innerState") ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 ( RndState network))))
type ArgGenChange ( RndAnyState n p) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Random

data Prologue ( RndAnyState n p) Source #
Instance details

Defined in Cardano.Wallet.Address.Book

data Discoveries ( RndAnyState n p) Source #
Instance details

Defined in Cardano.Wallet.Address.Book

mkRndAnyState :: forall (p :: Nat ) n. ByronKey ' RootK XPrv -> Int -> RndAnyState n p Source #

Initialize the HD random address discovery state from a root key and RNG seed.

The type parameter is expected to be a ratio of addresses we ought to simply recognize as ours. It is expressed in per-myriad, so "1" means 0.01%, "100" means 1% and 10000 means 100%.