Copyright | (c) Rune K. Svendsen 2016 |
---|---|
License | PublicDomain |
Maintainer | runesvend@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
Types used with the interface provided by Data.Bitcoin.PaymentChannel.
- class PaymentChannel a where
- class PaymentChannel a => PayChan a
- data SenderPaymentChannel = CSenderPaymentChannel {}
- type SendPayChan = SenderPaymentChannel
- type ReceiverPaymentChannel = ReceiverPaymentChannelI ()
- data ReceiverPaymentChannelI pkInfo
- type RecvPayChan = ReceiverPaymentChannel
- type ReceiverPaymentChannelX = ReceiverPaymentChannelI XPubKey
- type RecvPayChanX = ReceiverPaymentChannelX
- data Config = Config {}
- defaultConfig :: Config
- data FundingTxInfo = CFundingTxInfo {}
- data ChannelParameters = CChannelParameters {}
- type ChanParams = ChannelParameters
- data Payment
- cpSignature :: Payment -> PaymentSignature
- data FullPayment = CFullPayment {}
- data PayChanError
- data BitcoinAmount
- data BitcoinLockTime
- class HasFee a where
- data Constant = Constant BitcoinAmount
- type TxByteSize = Word
- newtype SatoshisPerByte = SatoshisPerByte BitcoinAmount
- newtype SendPubKey = MkSendPubKey {}
- newtype RecvPubKey = MkRecvPubKey {}
- class Serialize a => IsPubKey a where
- mkExtendedKeyRPC :: ReceiverPaymentChannel -> XPubKey -> Maybe ReceiverPaymentChannelX
- rpcGetXPub :: ReceiverPaymentChannelI pkInfo -> pkInfo
- fromDate :: UTCTime -> BitcoinLockTime
- usesBlockHeight :: BitcoinLockTime -> Bool
Interface
class PaymentChannel a where Source #
Get various information about an open payment channel.
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 #
class PaymentChannel a => PayChan a Source #
Short-hand
State
data SenderPaymentChannel Source #
State object for the value sender
CSenderPaymentChannel | |
|
type SendPayChan = SenderPaymentChannel Source #
Short-hand
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
type RecvPayChan = ReceiverPaymentChannel Source #
Short-hand
type ReceiverPaymentChannelX = ReceiverPaymentChannelI XPubKey Source #
ReceiverPaymentChannel with BIP32 , "extended" public key metadata
type RecvPayChanX = ReceiverPaymentChannelX Source #
Short-hand
Config
Miscellaneous configuration options
Config | |
|
data FundingTxInfo Source #
Holds information about the Bitcoin transaction used to fund the channel
CFundingTxInfo | |
|
data ChannelParameters Source #
Defines channel: sender, receiver, and expiration date
CChannelParameters | |
|
type ChanParams = ChannelParameters Source #
Payment
Contains the bare minimum of information to transfer value from sender to receiver.
cpSignature :: Payment -> PaymentSignature Source #
Get payment signature from payment
data FullPayment Source #
Contains all information required to construct the payment transaction
CFullPayment | |
|
Error
data PayChanError Source #
SigVerifyFailed | Signature verification failed |
BadPaymentValue BitcoinAmount | Payment assigns less value to server than previous payment. Client change value is greater by the specified |
OutPointMismatch OutPoint |
|
ChangeAddrMismatch Address | Client change |
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.
data BitcoinLockTime Source #
Data type representing a Bitcoin LockTime, which specifies a point in time.
Derive a BitcoinLockTime
from a UTCTime
using fromDate
.
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 |
Objects from which a Bitcoin fee can be calculated, given a transaction (yeah you need to create a tx twice).
absoluteFee :: TxByteSize -> a -> BitcoinAmount Source #
type TxByteSize = Word Source #
newtype SatoshisPerByte Source #
Specify a fee as satoshis per byte
SatoshisPerByte BitcoinAmount | Fee in satoshis per byte |
Crypto
newtype SendPubKey Source #
Wrapper for value sender's public key
newtype RecvPubKey Source #
Wrapper for value receiver's public key
Util
mkExtendedKeyRPC :: ReceiverPaymentChannel -> XPubKey -> Maybe ReceiverPaymentChannelX Source #
Create a ReceiverPaymentChannelX
, which has an associated XPubKey, from a
ReceiverPaymentChannel
rpcGetXPub :: ReceiverPaymentChannelI pkInfo -> pkInfo Source #
fromDate :: UTCTime -> BitcoinLockTime Source #
Convert a UTCTime
to a BitcoinLockTime