bitcoin-payment-channel-1.2.0.0: Instant, two-party Bitcoin payments

Safe HaskellNone
LanguageHaskell2010

Bitcoin.Signature

Contents

Synopsis

Interfaces to fill out

class Show c => SpendCondition c where Source #

Script that defines a condition to spend

Minimal complete definition

conditionScript

Methods

conditionScript :: c -> Script Source #

The script will, depending on transaction type, be placed either in output, input or witness of transaction

class HasSigner newSigData rdmScr => TransformSigData newSigData oldSigData rdmScr | newSigData oldSigData -> rdmScr where Source #

Defines how to transform old signature data type into a new one (by adding signatures)

Minimal complete definition

mkSigData

Methods

mkSigData :: oldSigData -> BtcSig -> Tagged rdmScr newSigData Source #

class SpendCondition r => HasSigner newSigData r where Source #

Identifies a signer whose signature produces newSigData

Minimal complete definition

signerPubKey

Methods

signerPubKey :: r -> Tagged newSigData PubKeyC Source #

Provided functions: sign tx, verify tx

signTx :: forall t r newSigData oldSd signKey. (TransformSigData newSigData oldSd r, HasSigningKey signKey r) => BtcTx t r oldSd -> SignM signKey (Either BtcError (BtcTx t r newSigData)) Source #

signChangeTx :: forall txLike t r newSd oldSd signKey coi. (SignatureScript r newSd t, TransformSigData newSd oldSd r, HasSigningKey signKey r, DeriveChangeOut (txLike t r oldSd) coi signKey r, IsTxLike txLike t r oldSd) => txLike t r oldSd -> coi -> SignM signKey (Either BtcError (BtcTx t r newSd)) Source #

Create SigSingle tx with added change output

data ChangeOut Source #

Instances

Eq ChangeOut Source # 
Show ChangeOut Source # 
Generic ChangeOut Source # 

Associated Types

type Rep ChangeOut :: * -> * #

ToJSON ChangeOut Source # 
FromJSON ChangeOut Source # 
Serialize ChangeOut Source # 
NFData ChangeOut Source # 

Methods

rnf :: ChangeOut -> () #

(SpendCondition r, IsTxLike tx t r sd) => DeriveChangeOut (tx t r sd) ChangeOut PrvKeyC r Source # 

Methods

createChangeOut :: tx t r sd -> PrvKeyC -> ChangeOut -> ChangeOut Source #

type Rep ChangeOut Source # 
type Rep ChangeOut = D1 (MetaData "ChangeOut" "Bitcoin.Types.Tx" "bitcoin-payment-channel-1.2.0.0-7YwDEKAOCp2BNoMt0JxEOM" False) (C1 (MetaCons "ChangeOut" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "btcChangeAddr") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Address)) ((:*:) (S1 (MetaSel (Just Symbol "btcTxFee") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 TxFee)) (S1 (MetaSel (Just Symbol "btcDustPolicy") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 DustPolicy)))))

Runners

runSimple :: PrvKeyC -> SignSimpleM a -> a Source #

Run SignM using a PrvKeyC private key

runExtDet :: RootPrv -> SignDerivM a -> a Source #

Run using a BIP-32 extended root private key as source key, with determinisitic key derivation.

runDummy :: SignDummyM a -> a Source #

TEST: Run using dummy private key. Used e.g. for producing transactions to test serialization length, for calculating tx fees relative to tx size.

data SignM key a Source #

Generic signing monad. Run with e.g. runSimple

Instances

Monad (SignM key) Source # 

Methods

(>>=) :: SignM key a -> (a -> SignM key b) -> SignM key b #

(>>) :: SignM key a -> SignM key b -> SignM key b #

return :: a -> SignM key a #

fail :: String -> SignM key a #

Functor (SignM key) Source # 

Methods

fmap :: (a -> b) -> SignM key a -> SignM key b #

(<$) :: a -> SignM key b -> SignM key a #

Applicative (SignM key) Source # 

Methods

pure :: a -> SignM key a #

(<*>) :: SignM key (a -> b) -> SignM key a -> SignM key b #

(*>) :: SignM key a -> SignM key b -> SignM key b #

(<*) :: SignM key a -> SignM key b -> SignM key a #

class HasSigningKey key rdmScr Source #

Minimal complete definition

getSignKey

Instances

HasSigningKey () r Source # 

Methods

getSignKey :: InputG t r oldSigData -> () -> PrvKeyC

HasSigningKey PrvKeyC r Source # 

Methods

getSignKey :: InputG t r oldSigData -> PrvKeyC -> PrvKeyC

DerivationSeed r => HasSigningKey RootPrv r Source # 

Methods

getSignKey :: InputG t r oldSigData -> RootPrv -> PrvKeyC

class HasSigningKey signKey rdmScr => DeriveChangeOut tx coi signKey rdmScr | tx -> rdmScr where Source #

Automatically derive a ChangeOut when using runExtDet and runDummy (not used in case of runSimple)

Minimal complete definition

createChangeOut

Methods

createChangeOut :: tx -> signKey -> coi -> ChangeOut Source #

Instances

(SpendCondition r, IsTxLike tx t r sd) => DeriveChangeOut (tx t r sd) ChangeOut PrvKeyC r Source # 

Methods

createChangeOut :: tx t r sd -> PrvKeyC -> ChangeOut -> ChangeOut Source #

(SpendCondition r, IsTxLike tx t r sd) => DeriveChangeOut (tx t r sd) (TxFee, DustPolicy) () r Source # 

Methods

createChangeOut :: tx t r sd -> () -> (TxFee, DustPolicy) -> ChangeOut Source #

DerivationSeed r => DeriveChangeOut (SigSinglePair t r sd) (TxFee, DustPolicy) RootPrv r Source # 

Methods

createChangeOut :: SigSinglePair t r sd -> RootPrv -> (TxFee, DustPolicy) -> ChangeOut Source #

Re-exports

data BtcSig Source #

ECDSA signature plus sig hash flag

Instances

Eq BtcSig Source # 

Methods

(==) :: BtcSig -> BtcSig -> Bool #

(/=) :: BtcSig -> BtcSig -> Bool #

Show BtcSig Source # 
Show ClientPayChan # 

Methods

showsPrec :: Int -> ClientPayChan -> ShowS #

show :: ClientPayChan -> String #

showList :: [ClientPayChan] -> ShowS #

Generic BtcSig Source # 

Associated Types

type Rep BtcSig :: * -> * #

Methods

from :: BtcSig -> Rep BtcSig x #

to :: Rep BtcSig x -> BtcSig #

ToJSON BtcSig Source # 
FromJSON BtcSig Source # 
Serialize BtcSig Source # 
NFData BtcSig Source # 

Methods

rnf :: BtcSig -> () #

HasSharedSecret ClientPayChan Source # 

Methods

getSecret :: ClientPayChan -> SharedSecret Source #

PaymentChannel ClientPayChan Source # 

Methods

valueToMe :: ClientPayChan -> BtcAmount Source #

channelValueLeft :: ClientPayChan -> BtcAmount Source #

getStatePayment :: ClientPayChan -> SignedPayment Source #

Eq (IgnoreSigData BtcSig) Source # 

Methods

(==) :: IgnoreSigData BtcSig -> IgnoreSigData BtcSig -> Bool #

(/=) :: IgnoreSigData BtcSig -> IgnoreSigData BtcSig -> Bool #

Eq rdmScr => Eq (IgnoreSigData (BtcTx inType rdmScr BtcSig)) Source # 

Methods

(==) :: IgnoreSigData (BtcTx inType rdmScr BtcSig) -> IgnoreSigData (BtcTx inType rdmScr BtcSig) -> Bool #

(/=) :: IgnoreSigData (BtcTx inType rdmScr BtcSig) -> IgnoreSigData (BtcTx inType rdmScr BtcSig) -> Bool #

ToJSON d => ToJSON (ServerPayChanI d) # 

Methods

toJSON :: ServerPayChanI d -> Value #

toEncoding :: ServerPayChanI d -> Encoding #

toJSONList :: [ServerPayChanI d] -> Value #

toEncodingList :: [ServerPayChanI d] -> Encoding #

FromJSON d => FromJSON (ServerPayChanI d) # 

Methods

parseJSON :: Value -> Parser (ServerPayChanI d) #

parseJSONList :: Value -> Parser [ServerPayChanI d] #

PaymentChannelRecv (ServerPayChanI (MetadataI a)) Source # 

Methods

clientTotalValueSent :: ServerPayChanI (MetadataI a) -> BtcAmount Source #

PaymentChannel (ServerPayChanI s) Source # 

Methods

valueToMe :: ServerPayChanI s -> BtcAmount Source #

channelValueLeft :: ServerPayChanI s -> BtcAmount Source #

getStatePayment :: ServerPayChanI s -> SignedPayment Source #

Eq r => Ord (SigSinglePair t r BtcSig) Source # 

Methods

compare :: SigSinglePair t r BtcSig -> SigSinglePair t r BtcSig -> Ordering #

(<) :: SigSinglePair t r BtcSig -> SigSinglePair t r BtcSig -> Bool #

(<=) :: SigSinglePair t r BtcSig -> SigSinglePair t r BtcSig -> Bool #

(>) :: SigSinglePair t r BtcSig -> SigSinglePair t r BtcSig -> Bool #

(>=) :: SigSinglePair t r BtcSig -> SigSinglePair t r BtcSig -> Bool #

max :: SigSinglePair t r BtcSig -> SigSinglePair t r BtcSig -> SigSinglePair t r BtcSig #

min :: SigSinglePair t r BtcSig -> SigSinglePair t r BtcSig -> SigSinglePair t r BtcSig #

type Rep BtcSig Source # 
type Rep BtcSig = D1 (MetaData "BtcSig" "Bitcoin.Types.Tx" "bitcoin-payment-channel-1.2.0.0-7YwDEKAOCp2BNoMt0JxEOM" False) (C1 (MetaCons "BtcSig" PrefixI True) ((:*:) (S1 (MetaSel (Just Symbol "bsSig") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 Signature)) (S1 (MetaSel (Just Symbol "bsSigFlag") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 SigHash))))

type PubKeyC = PubKeyI Compressed #

data BtcError Source #

Instances

Eq BtcError Source # 
Show BtcError Source # 
Generic BtcError Source # 

Associated Types

type Rep BtcError :: * -> * #

Methods

from :: BtcError -> Rep BtcError x #

to :: Rep BtcError x -> BtcError #

ToJSON BtcError Source # 
FromJSON BtcError Source # 
Exception BtcError Source # 
Serialize BtcError Source # 
NFData BtcError Source # 

Methods

rnf :: BtcError -> () #

type Rep BtcError Source # 
type Rep BtcError = D1 (MetaData "BtcError" "Bitcoin.Error" "bitcoin-payment-channel-1.2.0.0-7YwDEKAOCp2BNoMt0JxEOM" False) ((:+:) (C1 (MetaCons "InsufficientFunds" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 BtcAmount))) ((:+:) (C1 (MetaCons "DustOutput" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 BtcAmount))) (C1 (MetaCons "WrongSigningKey" PrefixI False) (S1 (MetaSel (Nothing Symbol) NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 [SignKeyError])))))