bitcoin-payment-channel-0.6.0.1: Library for working with Bitcoin payment channels

Copyright(c) Rune K. Svendsen 2016
LicensePublicDomain
Maintainerrunesvend@gmail.com
Safe HaskellNone
LanguageHaskell2010

Data.Bitcoin.PaymentChannel.Types

Contents

Description

Types used with the interface provided by Data.Bitcoin.PaymentChannel.

Synopsis

Interface

class PaymentChannel a where Source #

Get various information about an open payment channel.

Minimal complete definition

valueToMe, getChannelState

Methods

valueToMe :: a -> BitcoinAmount Source #

Get amount received by receiver/left for sender

getChannelState :: a -> PaymentChannelState Source #

Retrieve internal state object

getChannelFunding :: a -> OutPoint Source #

getExpirationDate :: a -> BitcoinLockTime Source #

getSenderPubKey :: a -> SendPubKey Source #

getFundingAmount :: a -> BitcoinAmount Source #

getPaymentCount :: a -> Word64 Source #

fundingAddress :: a -> Address Source #

getNewestPayment :: a -> Payment Source #

getNewestSig :: a -> Signature Source #

expiresBefore :: BitcoinLockTime -> a -> Bool Source #

Return True if channel expires earlier than given expiration date

_setChannelState :: a -> PaymentChannelState -> a Source #

For internal use

channelValueLeft :: a -> BitcoinAmount Source #

senderChangeValue :: a -> BitcoinAmount Source #

channelIsExhausted :: a -> Bool Source #

Returns True if all available channel value has been transferred, False otherwise

Instances

PaymentChannel ReceiverPaymentChannel Source # 
PaymentChannel SenderPaymentChannel Source # 

class PaymentChannel a => PayChan a Source #

Short-hand

State

type ReceiverPaymentChannel = ReceiverPaymentChannelI () Source #

ReceiverPaymentChannel without public key metadata

data ReceiverPaymentChannelI pkInfo Source #

State object for the value receiver. pkInfo holds optional, extra data associated with the receiver public key

Instances

Show ReceiverPaymentChannelX Source # 
Show ReceiverPaymentChannel Source # 
PaymentChannel ReceiverPaymentChannel Source # 
Eq pkInfo => Eq (ReceiverPaymentChannelI pkInfo) Source # 

type ReceiverPaymentChannelX = ReceiverPaymentChannelI XPubKey Source #

ReceiverPaymentChannel with BIP32 , "extended" public key metadata

Config

data Config Source #

Miscellaneous configuration options

Constructors

Config 

Fields

  • cDustLimit :: BitcoinAmount

    Refuse to accept/produce payments with a client change value less than this amount.

  • cSettlementPeriod :: Hour

    This many hours before the channel expiration date, consider the channel closed. This gives the receiver time to publish the settlement transaction, before the refund transaction becomes valid.

Instances

data FundingTxInfo Source #

Holds information about the Bitcoin transaction used to fund the channel

Constructors

CFundingTxInfo 

Fields

Payment

data Payment Source #

Contains the bare minimum of information to transfer value from sender to receiver.

Instances

cpSignature :: Payment -> PaymentSignature Source #

Get payment signature from payment

data FullPayment Source #

Contains all information required to construct the payment transaction

Constructors

CFullPayment 

Fields

Error

data PayChanError Source #

Constructors

SigVerifyFailed

Signature verification failed

BadPaymentValue BitcoinAmount

Payment assigns less value to server than previous payment. Client change value is greater by the specified BitcoinAmount.

OutPointMismatch OutPoint

OutPoint in payment does not match the one in server's state

ChangeAddrMismatch Address

Client change Address in payment does not match the one in server's state

RedeemScriptMismatch Script

redeemScript in payment does not match the one in server's state

DustOutput BitcoinAmount

Client change value is less than dust limit (payment transaction would contain a dust output)

ClosingPaymentBadValue

The closing payment only changes the payment transaction change address. Sending value is not allowed.

ChannelExpired

Channel has expired or is too close to expiration date

Bitcoin

data BitcoinAmount Source #

Represents a bitcoin amount as number of satoshis. 1 satoshi = 1e-8 bitcoin. 1e8 satohis = 1 bitcoin. Only amounts >= 0 can be represented, and fromInteger caps to a Word64. It is thus not possible to eg. construct a negative BitcoinAmount which, when added to another BitcoinAmount, subtracts from its value. Adding two large amounts together will never overflow, nor will subtraction underflow.

Instances

Bounded BitcoinAmount Source # 
Enum BitcoinAmount Source # 
Eq BitcoinAmount Source # 
Integral BitcoinAmount Source # 
Num BitcoinAmount Source # 
Ord BitcoinAmount Source # 
Real BitcoinAmount Source # 
Show BitcoinAmount Source # 
Serialize BitcoinAmount Source # 
HasFee BitcoinAmount Source #

For compatibility

data BitcoinLockTime Source #

Data type representing a Bitcoin LockTime, which specifies a point in time. Derive a BitcoinLockTime from a UTCTime using fromDate.

Constructors

LockTimeBlockHeight Word32

A value of "n" represents the point in time at which Bitcoin block number "n" appears

LockTimeDate UTCTime

Specifies a point in time using a timestamp with 1-second accuracy

class HasFee a where Source #

Objects from which a Bitcoin fee can be calculated, given a transaction (yeah you need to create a tx twice).

Minimal complete definition

absoluteFee

newtype SatoshisPerByte Source #

Specify a fee as satoshis per byte

Constructors

SatoshisPerByte BitcoinAmount

Fee in satoshis per byte

Instances

Enum SatoshisPerByte Source # 
Eq SatoshisPerByte Source # 
Integral SatoshisPerByte Source # 
Num SatoshisPerByte Source # 
Ord SatoshisPerByte Source # 
Real SatoshisPerByte Source # 
Show SatoshisPerByte Source # 
Serialize SatoshisPerByte Source # 
HasFee SatoshisPerByte Source # 

Crypto

class Serialize a => IsPubKey a where Source #

Types which contain a pubkey

Minimal complete definition

getPubKey

Methods

getPubKey :: a -> PubKeyC Source #

Util