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

Cardano.Wallet.Primitive.AddressDiscovery.Shared

Description

An implementation of shared script state using scheme specified in CIP-1854 Multi-signature Wallets.

Synopsis

Documentation

State

data SharedState (n :: NetworkDiscriminant ) k Source #

Shared wallet is a new kind of wallet owned by one or more co-signers. In this type of the wallet, addresses are defined by two monetary scripts (one for the ownership of assets and the other one for the ownership of stake). The two scripts can be the same, different, also the script for the ownership of stake can be absent.

The shared wallet can be in two states: pending or ready. In a pending state the wallet does not have account public keys for all co-signers, and hence discovery of script addresses co-shared with other co-signers is not possible. In a ready state the wallet has account public keys for all co-signers and co-shared script address discovery is possible.

The shared wallet is instantiated with an account public key, derivation path needed to recreate it for a holder of this shared wallet, ie., one of the co-signers. In order to construct correctly the wallet, ie., enable co-shared script addresses discovery the following is needed:

  • a way to determine what range of indices are checked on the ledger. Mechanism of address pool, also adopted for sequential wallets, is used. The idea is to track all indices starting from 0 and up to N. N is variable as addresses are discovered (and marked as Used in consequence). The pool of addresses is enlarged in such way that the number of consecutive Unused addresses equals to address pool gap of the address pool. Hence, the address pool gap needs to be specified.
  • script template for payment credential contains information about all collected account public keys for all parties engaged, here named co-signers. Also the skeleton determining script structure is provided. In this sense script is predetermined from the beginning and can variate only in verification key part that replaces co-signers in the script skeleton. The places where a specific cosigner is present is to be replaced with the derived verification key using the co-signer's account public key and the index that was chosen. This is the reason why we need complete set of account public keys for each co-signer to realize address discovery. The script template can be translated into a corresponding script, which hash is used in the address, only when account public keys for all cosigners specified in script are collected.The index for derivation is the same for each cosigner's derivation. The same index is used in both scripts that represent payment or delegation credential. Verification keys are derived using role=3 for payment credential.
  • optional script template for delegation credential contains all information as in case of the script template for payment credential. One difference is that the verification keys are derived using role=4 for delegation credential.

When both script are present, the base address (with both credentials) is expected to be discovered. When script template for delegation credential is missing then enterprise address (non-stakable) is expected.

Constructors

SharedState

Fields

Instances

Instances details
key ~ SharedKey => Eq ( Prologue ( SharedState n key)) Source #
Instance details

Defined in Cardano.Wallet.Address.Book

key ~ SharedKey => Eq ( Discoveries ( SharedState n key)) Source #
Instance details

Defined in Cardano.Wallet.Address.Book

key ~ SharedKey => Buildable ( Prologue ( SharedState n key)) Source #
Instance details

Defined in Cardano.Wallet.Address.Book

Eq (k ' AccountK XPub ) => Eq ( SharedState n k) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

Show (k ' AccountK XPub ) => Show ( SharedState n k) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

Generic ( SharedState n k) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

Associated Types

type Rep ( SharedState n k) :: Type -> Type Source #

NFData (k ' AccountK XPub ) => NFData ( SharedState n k) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

PersistPublicKey (k ' AccountK ) => Buildable ( SharedState n k) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

MaybeLight ( SharedState n k) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

Methods

maybeDiscover :: Maybe (LightDiscoverTxs ( SharedState n k)) Source #

Typeable n => KnownAddresses ( SharedState n k) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

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

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

GenChange ( SharedState n k) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

Associated Types

type ArgGenChange ( SharedState n k) Source #

key ~ SharedKey => AddressBookIso ( SharedState n key) Source #

Isomorphism for multi-sig address book.

Instance details

Defined in Cardano.Wallet.Address.Book

( PersistPublicKey (key ' AccountK ), SupportsDiscovery n key, WalletKey key, key ~ SharedKey ) => PersistAddressBook ( SharedState n key) Source #
Instance details

Defined in Cardano.Wallet.DB.Store.Checkpoints

GetAccount ( SharedState n k) k Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

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

type Rep ( SharedState n k) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

type ArgGenChange ( SharedState n k) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

data Prologue ( SharedState n key) Source #
Instance details

Defined in Cardano.Wallet.Address.Book

data Discoveries ( SharedState n key) Source #
Instance details

Defined in Cardano.Wallet.Address.Book

data Readiness a Source #

Readiness status of the shared state.

Constructors

Pending
Active !a

data SharedAddressPools (key :: Depth -> Type -> Type ) Source #

Instances

Instances details
Eq ( SharedAddressPools key) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

Show ( SharedAddressPools key) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

Generic ( SharedAddressPools key) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

NFData ( SharedAddressPools key) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

Buildable ( SharedAddressPools key) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

type Rep ( SharedAddressPools key) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

type Rep ( SharedAddressPools key) = D1 (' MetaData "SharedAddressPools" "Cardano.Wallet.Primitive.AddressDiscovery.Shared" "cardano-wallet-core-2022.7.1-AGKhlyz9liLKN3QqZD1gj" ' False ) ( C1 (' MetaCons "SharedAddressPools" ' PrefixI ' True ) ( S1 (' MetaSel (' Just "externalPool") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( SharedAddressPool ' UtxoExternal key)) :*: ( S1 (' MetaSel (' Just "internalPool") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( SharedAddressPool ' UtxoInternal key)) :*: S1 (' MetaSel (' Just "pendingChangeIxs") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( PendingIxs ' ScriptK )))))

newtype SharedAddressPool (c :: Role ) (key :: Depth -> Type -> Type ) Source #

An address pool which keeps track of shared addresses. To create a new pool, see newSharedAddressPool .

Instances

Instances details
Show ( SharedAddressPool c key) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

Generic ( SharedAddressPool c key) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

Associated Types

type Rep ( SharedAddressPool c key) :: Type -> Type Source #

NFData ( SharedAddressPool c k) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

Buildable ( SharedAddressPool c k) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

type Rep ( SharedAddressPool c key) Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

type Rep ( SharedAddressPool c key) = D1 (' MetaData "SharedAddressPool" "Cardano.Wallet.Primitive.AddressDiscovery.Shared" "cardano-wallet-core-2022.7.1-AGKhlyz9liLKN3QqZD1gj" ' True ) ( C1 (' MetaCons "SharedAddressPool" ' PrefixI ' True ) ( S1 (' MetaSel (' Just "getPool") ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 ( Pool ( KeyFingerprint "payment" key) ( Index ' Soft ' ScriptK )))))

newSharedAddressPool :: forall (n :: NetworkDiscriminant ) c key. (key ~ SharedKey , SupportsDiscovery n key, Typeable c) => AddressPoolGap -> ScriptTemplate -> Maybe ScriptTemplate -> SharedAddressPool c key Source #

Create a new shared address pool from complete script templates.

data ErrAddCosigner Source #

Possible errors from adding a co-signer key to the shared wallet state.

Constructors

NoDelegationTemplate

Adding key for a cosigner for a non-existent delegation template is not allowed.

NoSuchCosigner CredentialType Cosigner

Adding key for a cosigners for a given script is possible for the cosigner present in the script template.

KeyAlreadyPresent CredentialType

Adding the same key for different cosigners for a given script is not allowed.

WalletAlreadyActive

Adding is possible only to pending shared wallet.

CannotUpdateSharedWalletKey

Updating key is possible only for other cosigners, not cosigner belonging to the shared wallet.

addCosignerAccXPub :: ( SupportsDiscovery n k, WalletKey k, k ~ SharedKey ) => ( Cosigner , k ' AccountK XPub ) -> CredentialType -> SharedState n k -> Either ErrAddCosigner ( SharedState n k) Source #

The cosigner with his account public key is updated per template.

For each template the script is checked for presence of the cosigner: * If present, then the key is inserted into the state. * Otherwise, fail with NoSuchCosigner . If the key is already present it is going to be updated. For a given template all keys must be unique. If already present key is tried to be added, KeyAlreadyPresent error is produced. The updating works only with pending shared state,

When an active shared state is used WalletAlreadyActive error is triggered.

Updating the key for delegation script can be successful only if delegation script is present. Otherwise, NoDelegationTemplate error is triggered.

data CredentialType Source #

Instances

Instances details
Eq CredentialType Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

Show CredentialType Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

Generic CredentialType Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

NFData CredentialType Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

PersistFieldSql CredentialType Source #
Instance details

Defined in Cardano.Wallet.DB.Sqlite.Types

PersistField CredentialType Source #
Instance details

Defined in Cardano.Wallet.DB.Sqlite.Types

ToText CredentialType Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

FromText CredentialType Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

SymbolToField "cosignerKeyCredential" CosignerKey CredentialType Source #
Instance details

Defined in Cardano.Wallet.DB.Sqlite.Schema

type Rep CredentialType Source #
Instance details

Defined in Cardano.Wallet.Primitive.AddressDiscovery.Shared

type Rep CredentialType = D1 (' MetaData "CredentialType" "Cardano.Wallet.Primitive.AddressDiscovery.Shared" "cardano-wallet-core-2022.7.1-AGKhlyz9liLKN3QqZD1gj" ' False ) ( C1 (' MetaCons "Payment" ' PrefixI ' False ) ( U1 :: Type -> Type ) :+: C1 (' MetaCons "Delegation" ' PrefixI ' False ) ( U1 :: Type -> Type ))

Orphan instances