Documentation
¶
Index ¶
- Constants
- func BigMystToFloat(input *big.Int) float64
- func FloatToBigMyst(input float64) *big.Int
- func GenerateChannelAddress(identity, hermes, registry, channelImplementation string) (address string, err error)
- func GenerateHermesAddress(operator string, registry string, hermesImplementation string) (address string, err error)
- func GenerateProviderChannelID(providerIdentity, hermesAddress string) (string, error)
- func GenerateProviderChannelIDForPayAndSettle(providerIdentity, hermesAddress string) (string, error)
- func GetProxyCode(destinationAddress string) ([]byte, error)
- func HexToBytes(str string) []byte
- func Pad(b []byte, size int) []byte
- func RecoverAddress(message []byte, signature []byte) (common.Address, error)
- func ReformatSignatureVForBC(signature []byte) error
- func ReformatSignatureVForRecovery(signature []byte) error
- type DecreaseProviderStakeRequest
- func (dpsr DecreaseProviderStakeRequest) CreateSignature(ks hashSigner, signer common.Address) ([]byte, error)
- func (dpsr DecreaseProviderStakeRequest) GetMessage() []byte
- func (dpsr DecreaseProviderStakeRequest) IsValid(expectedSigner common.Address) bool
- func (dpsr DecreaseProviderStakeRequest) RecoverSigner() (common.Address, error)
- func (dpsr *DecreaseProviderStakeRequest) Sign(ks *keystore.KeyStore, signer common.Address) error
- type ExchangeMessage
- func (m ExchangeMessage) CreateSignature(ks hashSigner, signer common.Address) ([]byte, error)
- func (m ExchangeMessage) GetAgreementTotal() *big.Int
- func (m ExchangeMessage) GetFee() *big.Int
- func (m ExchangeMessage) GetMessage() []byte
- func (m ExchangeMessage) GetMessageHash() []byte
- func (m ExchangeMessage) GetSignatureBytesRaw() []byte
- func (m ExchangeMessage) IsMessageValid(expectedSigner common.Address) bool
- func (m ExchangeMessage) RecoverConsumerIdentity() (common.Address, error)
- type ExitRequest
- type Invoice
- type PayAndSettleBeneficiaryPayload
- type Promise
- func CreatePromise(channelID string, chainID int64, amount *big.Int, fee *big.Int, ...) (*Promise, error)
- func NewPromise(chainID int64, channelID string, amount, fee *big.Int, preimage string, ...) (*Promise, error)
- func NewRawPromise(chainID int64, channelID string, amount, fee *big.Int, hashlock string, ...) (*Promise, error)
- func (p Promise) CreateSignature(ks hashSigner, signer common.Address) ([]byte, error)
- func (p Promise) GetHash() []byte
- func (p Promise) GetMessage() []byte
- func (p Promise) GetSignatureHexString() string
- func (p Promise) IsPromiseValid(expectedSigner common.Address) bool
- func (p Promise) RecoverSigner() (common.Address, error)
- func (p *Promise) Sign(ks *keystore.KeyStore, signer common.Address) error
- type ProviderChannelType
- type ReferralTokenRequest
- type SetBeneficiaryRequest
- type SignedIdentityRequest
Constants ¶
const ExitPrefix = "Exit request:"
const Myst uint64 = 1000_000_000_000_000_000
Myst represents a single myst ERC 777 token.
Variables ¶
This section is empty.
Functions ¶
func BigMystToFloat ¶ added in v0.2.0
BigMystToFloat takes in a big int and returns a float64 representation of the myst.
func FloatToBigMyst ¶ added in v0.2.0
FloatToBigMyst takes in a float converts it to a big int representation. For example, 1.5 becomes 1500_000_000_000_000_000.
func GenerateChannelAddress ¶
func GenerateChannelAddress(identity, hermes, registry, channelImplementation string) (address string, err error)
GenerateChannelAddress generate channel address from given identity hash
func GenerateHermesAddress ¶ added in v0.2.0
func GenerateHermesAddress(operator string, registry string, hermesImplementation string) (address string, err error)
GenerateHermesAddress generate hermes address from given hermes operator address
func GenerateProviderChannelID ¶
GenerateProviderChannelID generated channelID for provider channels from given identity hash
func GenerateProviderChannelIDForPayAndSettle ¶ added in v0.2.0
func GenerateProviderChannelIDForPayAndSettle(providerIdentity, hermesAddress string) (string, error)
GenerateProviderChannelIDForPayAndSettle generated channelID for provider channels from given identity hash
func GetProxyCode ¶
GetProxyCode generates bytecode of minimal proxy contract (EIP 1167)
func HexToBytes ¶ added in v0.2.0
func RecoverAddress ¶
RecoverAddress recovers the address from message and signature
func ReformatSignatureVForBC ¶
ReformatSignatureVForBC takes in the signature and modifies its last byte to correspond to the format required for SC
func ReformatSignatureVForRecovery ¶
ReformatSignatureVForRecovery takes in the signature and modifies its last byte to normalize V to either 0 or 1
Types ¶
type DecreaseProviderStakeRequest ¶ added in v0.2.0
type DecreaseProviderStakeRequest struct { ChannelID [32]byte HermesID common.Address Amount *big.Int TransactorFee *big.Int Nonce *big.Int ChainID int64 Signature []byte }
DecreaseProviderStakeRequest represents all the parameters required for decreasing provider stake.
func (DecreaseProviderStakeRequest) CreateSignature ¶ added in v0.2.0
func (dpsr DecreaseProviderStakeRequest) CreateSignature(ks hashSigner, signer common.Address) ([]byte, error)
CreateSignature signs promise using keystore
func (DecreaseProviderStakeRequest) GetMessage ¶ added in v0.2.0
func (dpsr DecreaseProviderStakeRequest) GetMessage() []byte
GetMessage gets a message representation of the DecreaseProviderStakeRequest.
func (DecreaseProviderStakeRequest) IsValid ¶ added in v0.2.0
func (dpsr DecreaseProviderStakeRequest) IsValid(expectedSigner common.Address) bool
IsValid checks if the current stake decrease request is valid or not.
func (DecreaseProviderStakeRequest) RecoverSigner ¶ added in v0.2.0
func (dpsr DecreaseProviderStakeRequest) RecoverSigner() (common.Address, error)
RecoverSigner recovers signer address out of request signature.
type ExchangeMessage ¶
type ExchangeMessage struct { Promise Promise AgreementID *big.Int AgreementTotal *big.Int Provider string Signature string HermesID string ChainID int64 }
ExchangeMessage represent a promise exchange message
func CreateExchangeMessage ¶
func CreateExchangeMessage(chainID int64, invoice Invoice, promiseAmount *big.Int, channelID, hermesID string, ks hashSigner, signer common.Address) (*ExchangeMessage, error)
CreateExchangeMessage creates new exchange message with it's promise
func CreateExchangeMessageWithPromise ¶ added in v0.2.0
func (ExchangeMessage) CreateSignature ¶
func (m ExchangeMessage) CreateSignature(ks hashSigner, signer common.Address) ([]byte, error)
CreateSignature signs promise using keystore
func (ExchangeMessage) GetAgreementTotal ¶
func (m ExchangeMessage) GetAgreementTotal() *big.Int
GetAgreementTotal returns a big int representation for the agreement total amount
func (ExchangeMessage) GetFee ¶
func (m ExchangeMessage) GetFee() *big.Int
GetFee returns the big int representation for the promise settling transaction fee
func (ExchangeMessage) GetMessage ¶
func (m ExchangeMessage) GetMessage() []byte
GetMessage forms the message of promise exchange request
func (ExchangeMessage) GetMessageHash ¶
func (m ExchangeMessage) GetMessageHash() []byte
GetMessageHash returns a keccak of exchange message params
func (ExchangeMessage) GetSignatureBytesRaw ¶
func (m ExchangeMessage) GetSignatureBytesRaw() []byte
GetSignatureBytesRaw returns the unadulterated bytes of the signature
func (ExchangeMessage) IsMessageValid ¶
func (m ExchangeMessage) IsMessageValid(expectedSigner common.Address) bool
IsMessageValid validates if given exchange message was signed by expected identity
func (ExchangeMessage) RecoverConsumerIdentity ¶
func (m ExchangeMessage) RecoverConsumerIdentity() (common.Address, error)
RecoverConsumerIdentity recovers the identity from the given request
type ExitRequest ¶ added in v0.2.0
type ExitRequest struct { ChannelID common.Address Beneficiary common.Address ValidUntil *big.Int Signature []byte }
func NewExitRequest ¶ added in v0.2.0
func NewExitRequest(channelID, beneficiary common.Address, validUntil *big.Int) *ExitRequest
func (ExitRequest) CreateSignature ¶ added in v0.2.0
func (er ExitRequest) CreateSignature(ks hashSigner, signer common.Address) ([]byte, error)
func (ExitRequest) GetMessage ¶ added in v0.2.0
func (er ExitRequest) GetMessage() []byte
func (ExitRequest) RecoverSigner ¶ added in v0.2.0
func (er ExitRequest) RecoverSigner() (common.Address, error)
type Invoice ¶
type Invoice struct { AgreementID *big.Int AgreementTotal *big.Int TransactorFee *big.Int Hashlock string Provider string ChainID int64 }
Invoice represent a payment request
type PayAndSettleBeneficiaryPayload ¶ added in v0.2.0
type PayAndSettleBeneficiaryPayload struct { Beneficiary common.Address Signature []byte ChainID int64 ProviderChannelIDForWithdrawal string Amount *big.Int R [32]byte }
func NewPayAndSettleBeneficiaryPayload ¶ added in v0.2.0
func (*PayAndSettleBeneficiaryPayload) RecoverSigner ¶ added in v0.2.0
func (pasp *PayAndSettleBeneficiaryPayload) RecoverSigner() (common.Address, error)
RecoverSigner recovers signer address out of promise signature
type Promise ¶
type Promise struct { ChannelID []byte ChainID int64 Amount *big.Int Fee *big.Int Hashlock []byte R []byte Signature []byte }
Promise is payment promise object
func CreatePromise ¶
func CreatePromise(channelID string, chainID int64, amount *big.Int, fee *big.Int, hashlock string, ks hashSigner, signer common.Address) (*Promise, error)
CreatePromise creates and signs new payment promise
func NewPromise ¶
func NewPromise(chainID int64, channelID string, amount, fee *big.Int, preimage string, signature string) (*Promise, error)
NewPromise will create new promise, signature can be empty and be created later using `Sign()` method.
func NewRawPromise ¶ added in v0.2.0
func NewRawPromise(chainID int64, channelID string, amount, fee *big.Int, hashlock string, signature string) (*Promise, error)
NewRawPromise creates a promise from given params. The promise has no R.
func (Promise) CreateSignature ¶
CreateSignature signs promise using keystore
func (Promise) GetMessage ¶
GetMessage forms the message of payment promise
func (Promise) GetSignatureHexString ¶
GetSignatureHexString returns signature in hex sting format
func (Promise) IsPromiseValid ¶
IsPromiseValid validates if given promise params are properly signed
func (Promise) RecoverSigner ¶
RecoverSigner recovers signer address out of promise signature
type ProviderChannelType ¶ added in v0.2.0
type ProviderChannelType string
const ( ProviderChannelTypeDefault ProviderChannelType = "" ProviderChannelTypePayAndSettle ProviderChannelType = "withdrawal" )
type ReferralTokenRequest ¶ added in v0.2.0
func CreateReferralTokenRequest ¶ added in v0.2.0
func CreateReferralTokenRequest(ks hashSigner, signer common.Address) (ReferralTokenRequest, error)
CreateSignature signs promise using keystore
func (ReferralTokenRequest) IsValid ¶ added in v0.2.0
func (rtr ReferralTokenRequest) IsValid() error
type SetBeneficiaryRequest ¶ added in v0.0.13
type SetBeneficiaryRequest struct { ChainID int64 `json:"chainID"` Registry string `json:"registry"` Identity string `json:"channelID"` Beneficiary string `json:"beneficiary"` Nonce *big.Int `json:"nonce"` Signature string `json:"signature"` }
SetBeneficiaryRequest represents a request for setting new beneficiary.
func CreateBeneficiaryRequest ¶ added in v0.0.13
func NewBeneficiaryRequest ¶ added in v0.0.13
func (SetBeneficiaryRequest) CreateSignature ¶ added in v0.0.13
func (r SetBeneficiaryRequest) CreateSignature(ks hashSigner, signer common.Address) ([]byte, error)
CreateSignature signs set beneficiary request using keystore
func (SetBeneficiaryRequest) GetMessage ¶ added in v0.0.13
func (r SetBeneficiaryRequest) GetMessage() []byte
GetMessage forms the message payload given the set beneficiary request.
func (SetBeneficiaryRequest) GetSignatureBytesRaw ¶ added in v0.0.13
func (r SetBeneficiaryRequest) GetSignatureBytesRaw() []byte
GetSignatureBytesRaw returns the unadulterated bytes of the signature.
func (SetBeneficiaryRequest) RecoverSigner ¶ added in v0.0.13
func (r SetBeneficiaryRequest) RecoverSigner() (common.Address, error)
RecoverSigner recovers the signer identity from the given request.
type SignedIdentityRequest ¶ added in v1.0.0
type SignedIdentityRequest struct { Identity common.Address `json:"identity,omitempty"` Signature string `json:"signature,omitempty"` }
func CreateSignedIdentityRequest ¶ added in v1.0.0
func CreateSignedIdentityRequest(ks hashSigner, identityToSign, signer common.Address) (SignedIdentityRequest, error)
func (SignedIdentityRequest) RecoverSigner ¶ added in v1.0.0
func (sir SignedIdentityRequest) RecoverSigner() (common.Address, error)