hydra-node-0.17.0: The Hydra node
Safe HaskellSafe-Inferred
LanguageGHC2021

Hydra.Chain.Direct.Wallet

Description

Companion tiny-wallet for the direct chain component. This module provide some useful utilities to tracking the wallet's UTXO, and accessing it

Synopsis

Documentation

type Address = Addr StandardCrypto Source #

type TxIn = TxIn StandardCrypto Source #

type TxOut = TxOut LedgerEra Source #

data TinyWallet m Source #

A TinyWallet is a small abstraction of a wallet with basic UTXO management. The wallet is assumed to have only one address, and only one UTXO at that address. It can sign transactions and keeps track of its UTXO behind the scene.

The wallet is connecting to the node initially and when asked to $sel:reset:TinyWallet. Otherwise it can be fed blocks via $sel:update:TinyWallet as the chain rolls forward.

Constructors

TinyWallet 

Fields

  • getUTxO :: STM m (Map TxIn TxOut)

    Return all known UTxO addressed to this wallet.

  • getSeedInput :: STM m (Maybe TxIn)

    Returns the seed input This is the special input needed by Direct chain component to initialise a head

  • sign :: Tx -> Tx
     
  • coverFee :: UTxO -> Tx -> m (Either ErrCoverFee Tx)
     
  • reset :: m ()

    Re-initializ wallet against the latest tip of the node and start to ignore $sel:update:TinyWallet calls until reaching that tip.

  • update :: BlockHeader -> [Tx] -> m ()

    Update the wallet state given a block and list of txs. May be ignored if wallet is still initializing.

data WalletInfoOnChain Source #

Constructors

WalletInfoOnChain 

Fields

type ChainQuery m = QueryPoint -> Address ShelleyAddr -> m WalletInfoOnChain Source #

newTinyWallet Source #

Arguments

:: Tracer IO TinyWalletLog

A tracer for logging

-> NetworkId

Network identifier to generate our address.

-> (VerificationKey PaymentKey, SigningKey PaymentKey)

Credentials of the wallet.

-> ChainQuery IO

A function to query UTxO, pparams, system start and epoch info from the node. Initially and on demand later.

-> IO (EpochInfo (Either Text)) 
-> IO (TinyWallet IO) 

Create a new tiny wallet handle.

applyTxs :: [Tx] -> (Address -> Bool) -> Map TxIn TxOut -> Map TxIn TxOut Source #

Apply a block to our wallet. Does nothing if the transaction does not modify the UTXO set, or else, remove consumed utxos and add produced ones.

To determine whether a produced output is ours, we apply the given function checking the output's address.

getTxId :: (HashAlgorithm (HASH crypto), HashAnnotated (TxBody (era crypto)) EraIndependentTxBody crypto) => AlonzoTx (era crypto) -> TxId crypto Source #

data ErrCoverFee Source #

This are all the error that can happen during coverFee.

Constructors

ErrNotEnoughFunds ChangeError 
ErrNoFuelUTxOFound 
ErrUnknownInput 

Fields

ErrScriptExecutionFailed 

Fields

  • scriptFailure :: (PlutusPurpose AsIndex LedgerEra, TransactionScriptFailure LedgerEra)
     
ErrTranslationError (ContextError LedgerEra) 

Instances

Instances details
Show ErrCoverFee Source # 
Instance details

Defined in Hydra.Chain.Direct.Wallet

data ChangeError Source #

Constructors

ChangeError 

Fields

Instances

Instances details
Show ChangeError Source # 
Instance details

Defined in Hydra.Chain.Direct.Wallet

coverFee_ :: PParams LedgerEra -> SystemStart -> EpochInfo (Either Text) -> Map TxIn TxOut -> Map TxIn TxOut -> AlonzoTx LedgerEra -> Either ErrCoverFee (AlonzoTx LedgerEra) Source #

Cover fee for a transaction body using the given UTXO set. This calculate necessary fees and augments inputs outputs collateral accordingly to cover for the transaction cost and get the change back.

XXX: All call sites of this function use cardano-api types

estimateScriptsCost Source #

Arguments

:: PParams LedgerEra

Protocol parameters

-> SystemStart

Start of the blockchain, for converting slots to UTC times

-> EpochInfo (Either Text)

Information about epoch sizes, for converting slots to UTC times

-> Map TxIn TxOut

A UTXO needed to resolve inputs

-> AlonzoTx LedgerEra

The pre-constructed transaction

-> Either ErrCoverFee (Map (PlutusPurpose AsIndex LedgerEra) ExUnits) 

Estimate cost of script executions on the transaction. This is only an estimates because the transaction isn't sealed at this point and adding new elements to it like change outputs or script integrity hash may increase that cost a little.

data TinyWalletLog Source #

Constructors

BeginInitialize 
EndInitialize 

Fields

BeginUpdate 

Fields

EndUpdate 

Fields

SkipUpdate 

Fields

Instances

Instances details
Arbitrary TinyWalletLog Source # 
Instance details

Defined in Hydra.Chain.Direct.Wallet

FromJSON TinyWalletLog Source # 
Instance details

Defined in Hydra.Chain.Direct.Wallet

Methods

parseJSON :: Value -> Parser TinyWalletLog

parseJSONList :: Value -> Parser [TinyWalletLog]

omittedField :: Maybe TinyWalletLog

ToJSON TinyWalletLog Source # 
Instance details

Defined in Hydra.Chain.Direct.Wallet

Generic TinyWalletLog Source # 
Instance details

Defined in Hydra.Chain.Direct.Wallet

Associated Types

type Rep TinyWalletLog :: Type -> Type Source #

Show TinyWalletLog Source # 
Instance details

Defined in Hydra.Chain.Direct.Wallet

Eq TinyWalletLog Source # 
Instance details

Defined in Hydra.Chain.Direct.Wallet

type Rep TinyWalletLog Source # 
Instance details

Defined in Hydra.Chain.Direct.Wallet

type Rep TinyWalletLog = D1 ('MetaData "TinyWalletLog" "Hydra.Chain.Direct.Wallet" "hydra-node-0.17.0-LAQRO9wCTJb3PlLjnCHOjA" 'False) ((C1 ('MetaCons "BeginInitialize" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "EndInitialize" 'PrefixI 'True) (S1 ('MetaSel ('Just "initialUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UTxO) :*: S1 ('MetaSel ('Just "tip") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ChainPoint))) :+: (C1 ('MetaCons "BeginUpdate" 'PrefixI 'True) (S1 ('MetaSel ('Just "point") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ChainPoint)) :+: (C1 ('MetaCons "EndUpdate" 'PrefixI 'True) (S1 ('MetaSel ('Just "newUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UTxO)) :+: C1 ('MetaCons "SkipUpdate" 'PrefixI 'True) (S1 ('MetaSel ('Just "point") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ChainPoint)))))