hydra-node-0.19.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 (PParams Conway)

A means to query some pparams.

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

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_ :: (EraCrypto era ~ StandardCrypto, EraPlutusContext era, AlonzoEraTx era, ScriptsNeeded era ~ AlonzoScriptsNeeded era, EraUTxO era, BabbageEraTxBody era) => PParams era -> SystemStart -> EpochInfo (Either Text) -> Map TxIn (TxOut era) -> Map TxIn (TxOut era) -> Tx era -> Either ErrCoverFee (Tx era) 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

findLargestUTxO :: EraTxOut era => Map TxIn (TxOut era) -> Maybe (TxIn, TxOut era) Source #

estimateScriptsCost Source #

Arguments

:: forall era. (AlonzoEraTx era, EraPlutusContext era, ScriptsNeeded era ~ AlonzoScriptsNeeded era, EraCrypto era ~ StandardCrypto, EraUTxO era) 
=> PParams era

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 era)

A UTXO needed to resolve inputs

-> Tx era

The pre-constructed transaction

-> Either ErrCoverFee (Map (PlutusPurpose AsIx era) 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.19.0-6Z4E5vp1s1XJuLOmmEVMTw" '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)))))