chanpay

package
v0.1.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelPayActionInstance

type ChannelPayActionInstance struct {
	// contains filtered or unexported fields
}

* * 单次支付行为操作 * 初始化调用: 0. SetUpstreamSide or ... 1. SetMustSignAddresses 2. StartOneSideMessageSubscription 3. InitCreateEmptyBillDocumentsByInitPayMsg *

func NewChannelPayActionInstance

func NewChannelPayActionInstance() *ChannelPayActionInstance

Newly created

func (*ChannelPayActionInstance) BroadcastMessage

func (c *ChannelPayActionInstance) BroadcastMessage(msg protocol.Message)

Broadcast message

func (*ChannelPayActionInstance) Destroy

func (c *ChannelPayActionInstance) Destroy()

Complete all, destroy all resources

func (*ChannelPayActionInstance) GetPayActionInstanceType

func (c *ChannelPayActionInstance) GetPayActionInstanceType() PayActionInstanceType

Judge my node type 1,2,3

func (*ChannelPayActionInstance) InitCreateEmptyBillDocumentsByInitPayMsg

func (c *ChannelPayActionInstance) InitCreateEmptyBillDocumentsByInitPayMsg(msg *protocol.MsgRequestInitiatePayment) error

Initializing the creation of transaction tickets through the message

func (*ChannelPayActionInstance) SetCollectCustomer

func (c *ChannelPayActionInstance) SetCollectCustomer(user *Customer)

func (*ChannelPayActionInstance) SetDownstreamSide

func (c *ChannelPayActionInstance) SetDownstreamSide(side *RelayPaySettleNoder)

func (*ChannelPayActionInstance) SetLocalServicerNode

func (c *ChannelPayActionInstance) SetLocalServicerNode(localnode *payroutes.PayRelayNode)

Set local service node

func (*ChannelPayActionInstance) SetMustSignAddresses

func (c *ChannelPayActionInstance) SetMustSignAddresses(addrs []fields.Address)

Set signature address

func (*ChannelPayActionInstance) SetPayCustomer

func (c *ChannelPayActionInstance) SetPayCustomer(user *Customer)

func (*ChannelPayActionInstance) SetSignatureMachine

func (c *ChannelPayActionInstance) SetSignatureMachine(machine DataSourceOfSignatureMachine)

Set signing machine

func (*ChannelPayActionInstance) SetSuccessedBackCall

func (c *ChannelPayActionInstance) SetSuccessedBackCall(fc func(newbill *channel.OffChainCrossNodeSimplePaymentReconciliationBill))

Callback of successful payment

func (*ChannelPayActionInstance) SetUpstreamSide

func (c *ChannelPayActionInstance) SetUpstreamSide(side *RelayPaySettleNoder)

Set connection parties

func (*ChannelPayActionInstance) StartOneSideMessageSubscription

func (c *ChannelPayActionInstance) StartOneSideMessageSubscription(upOrDownStream bool, side *ChannelSideConn)

Start a side message subscription

func (*ChannelPayActionInstance) SubscribeLogs

func (c *ChannelPayActionInstance) SubscribeLogs(logschan chan *PayActionLog)

Subscription log

type ChannelSideConn

type ChannelSideConn struct {

	// Ws long connection
	WsConn *websocket.Conn

	// data
	ChannelId   fields.ChannelId             // Channel Chain ID
	ChannelInfo *protocol.RpcDataChannelInfo // Channel current information

	OurAddress    fields.Address // Our address
	RemoteAddress fields.Address // Opposite address (customer address or opposite address of settlement channel)

	// Latest reconciliation bill
	LatestReconciliationBalanceBill channel.ReconciliationBalanceBill
	// contains filtered or unexported fields
}

Channel connector

func NewChannelSideByConn

func NewChannelSideByConn(conn *websocket.Conn) *ChannelSideConn

func NewChannelSideById

func NewChannelSideById(cid fields.ChannelId) *ChannelSideConn

func (*ChannelSideConn) ClearBusinessExclusive

func (c *ChannelSideConn) ClearBusinessExclusive()

Remove state exclusivity

func (*ChannelSideConn) ClearCloseAutoCollectionStatus

func (c *ChannelSideConn) ClearCloseAutoCollectionStatus()

Cancel closing automatic collection

func (*ChannelSideConn) GetAvailableAutoNumber

func (c *ChannelSideConn) GetAvailableAutoNumber() uint64

func (*ChannelSideConn) GetAvailableReuseVersion

func (c *ChannelSideConn) GetAvailableReuseVersion() uint32

Get channel data

func (*ChannelSideConn) GetChannelCapacityAmount

func (c *ChannelSideConn) GetChannelCapacityAmount(side string) fields.Amount

Get channel capacity side = our, remote

func (*ChannelSideConn) GetChannelCapacityAmountOfOur

func (c *ChannelSideConn) GetChannelCapacityAmountOfOur() fields.Amount

func (*ChannelSideConn) GetChannelCapacityAmountOfRemote

func (c *ChannelSideConn) GetChannelCapacityAmountOfRemote() fields.Amount

func (*ChannelSideConn) GetChannelCapacitySatoshi

func (c *ChannelSideConn) GetChannelCapacitySatoshi(side string) fields.Satoshi

Get channel capacity side = our, remote

func (*ChannelSideConn) GetChannelCapacitySatoshiOfOur

func (c *ChannelSideConn) GetChannelCapacitySatoshiOfOur() fields.Satoshi

func (*ChannelSideConn) GetChannelCapacitySatoshiOfRemote

func (c *ChannelSideConn) GetChannelCapacitySatoshiOfRemote() fields.Satoshi

func (*ChannelSideConn) GetChannelId

func (c *ChannelSideConn) GetChannelId() fields.ChannelId

func (*ChannelSideConn) GetChannelInfo

func (c *ChannelSideConn) GetChannelInfo() *protocol.RpcDataChannelInfo

func (*ChannelSideConn) GetLastestHeartbeatTime

func (c *ChannelSideConn) GetLastestHeartbeatTime() time.Time

func (*ChannelSideConn) GetOurAddress

func (c *ChannelSideConn) GetOurAddress() fields.Address

func (*ChannelSideConn) GetReconciliationBill

func (c *ChannelSideConn) GetReconciliationBill() channel.ReconciliationBalanceBill

func (*ChannelSideConn) GetRemoteAddress

func (c *ChannelSideConn) GetRemoteAddress() fields.Address

func (*ChannelSideConn) IsInBusinessExclusive

func (c *ChannelSideConn) IsInBusinessExclusive() bool

Check whether the collection channel is occupied

func (*ChannelSideConn) IsInCloseAutoCollectionStatus

func (c *ChannelSideConn) IsInCloseAutoCollectionStatus() bool

Check whether automatic collection is closed

func (*ChannelSideConn) RemoteAddressIsLeft

func (c *ChannelSideConn) RemoteAddressIsLeft() bool

judge

func (*ChannelSideConn) SetAddresses

func (c *ChannelSideConn) SetAddresses(our, remote fields.Address)

func (*ChannelSideConn) SetChannelId

func (c *ChannelSideConn) SetChannelId(id fields.ChannelId)

func (*ChannelSideConn) SetChannelInfo

func (c *ChannelSideConn) SetChannelInfo(info *protocol.RpcDataChannelInfo)

func (*ChannelSideConn) SetReconciliationBill

func (c *ChannelSideConn) SetReconciliationBill(bill channel.ReconciliationBalanceBill)

func (*ChannelSideConn) StartBusinessExclusive

func (c *ChannelSideConn) StartBusinessExclusive() bool

Enable state exclusive

func (*ChannelSideConn) StartCloseAutoCollectionStatus

func (c *ChannelSideConn) StartCloseAutoCollectionStatus() bool

启用关闭自动收款

func (*ChannelSideConn) StartMessageListen

func (c *ChannelSideConn) StartMessageListen()

Start message listening

func (*ChannelSideConn) SubscribeMessage

func (c *ChannelSideConn) SubscribeMessage(chanobj chan protocol.Message) event.Subscription

Subscription message processing

func (*ChannelSideConn) UncheckSignSaveBillByCompleteDocuments

func (c *ChannelSideConn) UncheckSignSaveBillByCompleteDocuments(bills *channel.ChannelPayCompleteDocuments) error

Directly save (do not check) payment reconciliation bills

type ChannelSideConnListByCollectCapacity

type ChannelSideConnListByCollectCapacity []ChannelSideConnWrap

Sort by channel capacity

func CreateChannelSideConnWrapForCustomer

func CreateChannelSideConnWrapForCustomer(list []*Customer) ChannelSideConnListByCollectCapacity

func CreateChannelSideConnWrapForRelayPayNodeConnect

func CreateChannelSideConnWrapForRelayPayNodeConnect(list []*RelayPaySettleNoder) ChannelSideConnListByCollectCapacity

func (ChannelSideConnListByCollectCapacity) Len

func (ChannelSideConnListByCollectCapacity) Less

func (ChannelSideConnListByCollectCapacity) Swap

type ChannelSideConnWrap

type ChannelSideConnWrap interface {
	GetChannelCapacityAmountForRemoteCollect() fields.Amount
}

type Customer

type Customer struct {
	RegisteredID uint64 // Whether the registration has been completed and a random number will be assigned when it is completed

	LanguageSet fields.StringMax255 // Language settings en_ US zh_ CN

	ChannelSide *ChannelSideConn
	// contains filtered or unexported fields
}

func NewCustomer

func NewCustomer(ws *websocket.Conn) *Customer

func (*Customer) ClearBusinessExclusive

func (c *Customer) ClearBusinessExclusive()

Remove state exclusivity

func (*Customer) CustomerAddressIsLeft

func (c *Customer) CustomerAddressIsLeft() bool

judge

func (*Customer) DoDisplacementOffline

func (c *Customer) DoDisplacementOffline(newcur *Customer)

Replaced offline

func (*Customer) DoRegister

func (c *Customer) DoRegister(channelId fields.ChannelId, address fields.Address)

Perform registration

func (*Customer) GetChannelCapacityAmountForRemoteCollect

func (c *Customer) GetChannelCapacityAmountForRemoteCollect() fields.Amount

func (*Customer) GetChannelCapacityAmountForRemotePay

func (c *Customer) GetChannelCapacityAmountForRemotePay() fields.Amount

func (*Customer) GetCustomerAddress

func (c *Customer) GetCustomerAddress() fields.Address

judge

func (*Customer) GetLastestHeartbeatTime

func (c *Customer) GetLastestHeartbeatTime() time.Time

func (*Customer) GetServicerAddress

func (c *Customer) GetServicerAddress() fields.Address

func (*Customer) IsInBusinessExclusive

func (c *Customer) IsInBusinessExclusive() bool

Check whether the collection channel is occupied

func (*Customer) StartBusinessExclusive

func (c *Customer) StartBusinessExclusive() bool

Where state exclusive

func (*Customer) UpdateLastestHeartbeatTime

func (c *Customer) UpdateLastestHeartbeatTime()

Update heartbeat time

type DataSourceOfBalanceBill

type DataSourceOfBalanceBill interface {
	Init() error // initialization
	// Save general reconciliation bills and check the validity of reconciliation documents
	UpdateStoreBalanceBill(channelId fields.ChannelId, bill channel.ReconciliationBalanceBill) error
	// Read latest ticket
	GetLastestBalanceBill(channelId fields.ChannelId) (channel.ReconciliationBalanceBill, error)
}

Balance bill data

type DataSourceOfServicerPayChannelSetup

type DataSourceOfServicerPayChannelSetup interface {
	Init() error // initialization
	// Set customer service channel
	SetupCustomerPayChannel(channelId fields.ChannelId) error
	// Query whether the customer service channel exists,
	CheckCustomerPayChannel(channelId fields.ChannelId) bool
	// Cancel customer service channel
	CancelCustomerPayChannel(channelId fields.ChannelId) error
}

Channel load data

type DataSourceOfSignatureMachine

type DataSourceOfSignatureMachine interface {
	Init() error // initialization
	// Temporary private key
	TemporaryStoragePrivateKeyForSign(privatekeyOrPassword string)
	RemovePrivateKey(address fields.Address) // Remove private key
	CleanAllPrivateKey()                     // Clear all private keys
	// Sign the statement and then check all signatures
	CheckReconciliationFillNeedSignature(bill *channel.OffChainFormPaymentChannelRealtimeReconciliation, checksign *fields.Sign) (*fields.Sign, error)
	// Send the channel transaction to the signer to verify the data, and automatically fill in the signature
	CheckPaydocumentAndFillNeedSignature(paydocs *channel.ChannelPayCompleteDocuments, mustaddrs []fields.Address) (*fields.SignListMax255, error)
}

Signature machine

type LocalDBImpOfDataSource

type LocalDBImpOfDataSource struct {
	// contains filtered or unexported fields
}

func NewLocalDBImpOfDataSource

func NewLocalDBImpOfDataSource(dbdir string) (*LocalDBImpOfDataSource, error)

func (*LocalDBImpOfDataSource) CancelCustomerPayChannel

func (l *LocalDBImpOfDataSource) CancelCustomerPayChannel(channelId fields.ChannelId) error

Cancel service channel

func (*LocalDBImpOfDataSource) CancelRelaySettlementPayChannel

func (l *LocalDBImpOfDataSource) CancelRelaySettlementPayChannel(channelId fields.ChannelId) error

Cancel the settlement channel of the service provider

func (*LocalDBImpOfDataSource) CheckCustomerPayChannel

func (l *LocalDBImpOfDataSource) CheckCustomerPayChannel(channelId fields.ChannelId) bool

Query service channel

func (*LocalDBImpOfDataSource) CheckPaydocumentAndFillNeedSignature

func (s *LocalDBImpOfDataSource) CheckPaydocumentAndFillNeedSignature(paydocs *channel.ChannelPayCompleteDocuments, mustaddrs []fields.Address) (*fields.SignListMax255, error)

Signed payment

func (*LocalDBImpOfDataSource) CheckReconciliationFillNeedSignature

func (s *LocalDBImpOfDataSource) CheckReconciliationFillNeedSignature(bill *channel.OffChainFormPaymentChannelRealtimeReconciliation, checksign *fields.Sign) (*fields.Sign, error)

Sign statement

func (*LocalDBImpOfDataSource) CheckRelaySettlementPayChannel

func (l *LocalDBImpOfDataSource) CheckRelaySettlementPayChannel(channelId fields.ChannelId) (bool, bool)

Query whether the settlement channel of the service provider exists. The previous bool indicates whether it exists, and the latter bool=weisrightside

func (*LocalDBImpOfDataSource) CleanAllPrivateKey

func (s *LocalDBImpOfDataSource) CleanAllPrivateKey()

Clear all private keys

func (*LocalDBImpOfDataSource) GetLastestBalanceBill

func (l *LocalDBImpOfDataSource) GetLastestBalanceBill(channelId fields.ChannelId) (channel.ReconciliationBalanceBill, error)

Read latest ticket

func (*LocalDBImpOfDataSource) Init

func (l *LocalDBImpOfDataSource) Init() error

func (*LocalDBImpOfDataSource) ReadPrivateKey

func (s *LocalDBImpOfDataSource) ReadPrivateKey(address fields.Address) *account.Account

Remove private key

func (*LocalDBImpOfDataSource) RemovePrivateKey

func (s *LocalDBImpOfDataSource) RemovePrivateKey(address fields.Address)

Remove private key

func (*LocalDBImpOfDataSource) SetupCustomerPayChannel

func (l *LocalDBImpOfDataSource) SetupCustomerPayChannel(channelId fields.ChannelId) error

Set service channel

func (*LocalDBImpOfDataSource) SetupRelaySettlementPayChannel

func (l *LocalDBImpOfDataSource) SetupRelaySettlementPayChannel(channelId fields.ChannelId, weAreRightSide bool) error

Set the settlement channel of the service provider. Is our address on the right

func (*LocalDBImpOfDataSource) TemporaryStoragePrivateKeyForSign

func (s *LocalDBImpOfDataSource) TemporaryStoragePrivateKeyForSign(privatekeyOrPassword string)

func (*LocalDBImpOfDataSource) UpdateStoreBalanceBill

func (l *LocalDBImpOfDataSource) UpdateStoreBalanceBill(channelId fields.ChannelId, bill channel.ReconciliationBalanceBill) error

Save general reconciliation bills and check the validity of reconciliation documents

type PayActionInstanceType

type PayActionInstanceType uint8

Instance type

const (
	PaySide     PayActionInstanceType = 1
	RelayNode   PayActionInstanceType = 2
	CollectSide PayActionInstanceType = 3
)

type PayActionLog

type PayActionLog struct {
	IsEnd     bool
	IsSuccess bool
	IsError   bool
	Content   string
}

journal

type RelayPaySettleNoder

type RelayPaySettleNoder struct {

	// Service name
	IdentificationName string
	ChannelId          fields.ChannelId
	OurAddressIsLeft   bool

	ChannelSide *ChannelSideConn
}

Relay payment connection channel

func NewRelayPayNodeConnect

func NewRelayPayNodeConnect(name string, cid fields.ChannelId, ourIsLeft bool, side *ChannelSideConn) *RelayPaySettleNoder

func (*RelayPaySettleNoder) ClearBusinessExclusive

func (c *RelayPaySettleNoder) ClearBusinessExclusive()

Remove state exclusivity

func (*RelayPaySettleNoder) GetChannelCapacityAmountForRemoteCollect

func (c *RelayPaySettleNoder) GetChannelCapacityAmountForRemoteCollect() fields.Amount

func (*RelayPaySettleNoder) IsInBusinessExclusive

func (c *RelayPaySettleNoder) IsInBusinessExclusive() bool

Check whether the collection channel is occupied

func (*RelayPaySettleNoder) StartBusinessExclusive

func (c *RelayPaySettleNoder) StartBusinessExclusive() bool

Where state exclusive

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL