channel

package
v0.0.0-...-425d0f2 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 5 Imported by: 6

Documentation

Index

Constants

View Source
const (
	ChannelTransferDirectionLeftToRight uint8 = 1
	ChannelTransferDirectionRightToLeft uint8 = 2
)
View Source
const (
	BillTypeCodeSimplePay      uint8 = 1 // Ordinary payment
	BillTypeCodeReconciliation uint8 = 2 // Reconciliation
)

*

支付票据类型

Variables

This section is empty.

Functions

func CleanSortMustSignAddresses

func CleanSortMustSignAddresses(addrs []fields.Address) (fields.VarUint1, []fields.Address)

De duplication and sorting address list

func SerializeReconciliationBalanceBillWithPrefixTypeCode

func SerializeReconciliationBalanceBillWithPrefixTypeCode(bill ReconciliationBalanceBill) ([]byte, error)

serialize

Types

type ChannelChainTransferProveBodyInfo

type ChannelChainTransferProveBodyInfo struct {
	ChannelId fields.ChannelId // Channel ID

	ReuseVersion   fields.VarUint4 // Channel reuse sequence number
	BillAutoNumber fields.VarUint8 // Serial number of channel bill

	PayDirection fields.VarUint1         // Capital flow direction: HAC 1 Left = > right; 2. right = > left BTC 3 Left = > right; 4. right = > left
	PayAmount    fields.Amount           // Payment amount cannot be negative
	PaySatoshi   fields.SatoshiVariation // Pay bitcoin sat amount

	LeftBalance  fields.Amount // Real time amount on the left
	RightBalance fields.Amount // Right real time amount

	LeftSatoshi  fields.SatoshiVariation // Number of bitcoin sat on the left
	RightSatoshi fields.SatoshiVariation // Number of bitcoin sat on the right

	LeftAddress  fields.Address // Left address
	RightAddress fields.Address // Right address
}

Channel transfer, data body

func (*ChannelChainTransferProveBodyInfo) CheckAddressAndSign

func (elm *ChannelChainTransferProveBodyInfo) CheckAddressAndSign(leftAddress, rightAddress fields.Address) error

Check signature

func (*ChannelChainTransferProveBodyInfo) GetAutoNumber

func (e *ChannelChainTransferProveBodyInfo) GetAutoNumber() uint64

func (*ChannelChainTransferProveBodyInfo) GetChannelId

interface

func (*ChannelChainTransferProveBodyInfo) GetLeftAddress

func (e *ChannelChainTransferProveBodyInfo) GetLeftAddress() fields.Address

func (*ChannelChainTransferProveBodyInfo) GetLeftBalance

func (e *ChannelChainTransferProveBodyInfo) GetLeftBalance() fields.Amount

func (*ChannelChainTransferProveBodyInfo) GetLeftSatoshi

func (e *ChannelChainTransferProveBodyInfo) GetLeftSatoshi() fields.Satoshi

func (*ChannelChainTransferProveBodyInfo) GetReuseVersion

func (e *ChannelChainTransferProveBodyInfo) GetReuseVersion() uint32

func (*ChannelChainTransferProveBodyInfo) GetRightAddress

func (e *ChannelChainTransferProveBodyInfo) GetRightAddress() fields.Address

func (*ChannelChainTransferProveBodyInfo) GetRightBalance

func (e *ChannelChainTransferProveBodyInfo) GetRightBalance() fields.Amount

func (*ChannelChainTransferProveBodyInfo) GetRightSatoshi

func (e *ChannelChainTransferProveBodyInfo) GetRightSatoshi() fields.Satoshi

func (*ChannelChainTransferProveBodyInfo) GetSignStuff

func (elm *ChannelChainTransferProveBodyInfo) GetSignStuff() []byte

func (*ChannelChainTransferProveBodyInfo) GetSignStuffHashHalfChecker

func (elm *ChannelChainTransferProveBodyInfo) GetSignStuffHashHalfChecker() fields.HashHalfChecker

func (*ChannelChainTransferProveBodyInfo) Parse

func (elm *ChannelChainTransferProveBodyInfo) Parse(buf []byte, seek uint32) (uint32, error)

func (*ChannelChainTransferProveBodyInfo) Serialize

func (elm *ChannelChainTransferProveBodyInfo) Serialize() ([]byte, error)

func (*ChannelChainTransferProveBodyInfo) Size

type ChannelPayCompleteDocuments

type ChannelPayCompleteDocuments struct {
	// Reconciliation bill table
	ProveBodys *ChannelPayProveBodyList
	// Payment of signed bills
	ChainPayment *OffChainFormPaymentChannelTransfer
}

Channel chain payment bill

func (*ChannelPayCompleteDocuments) Parse

func (c *ChannelPayCompleteDocuments) Parse(buf []byte, seek uint32) (uint32, error)

func (ChannelPayCompleteDocuments) Serialize

func (c ChannelPayCompleteDocuments) Serialize() ([]byte, error)

func (ChannelPayCompleteDocuments) Size

type ChannelPayProveBodyList

type ChannelPayProveBodyList struct {
	Count      fields.VarUint1
	ProveBodys []*ChannelChainTransferProveBodyInfo
}

func (*ChannelPayProveBodyList) Parse

func (c *ChannelPayProveBodyList) Parse(buf []byte, seek uint32) (uint32, error)

func (ChannelPayProveBodyList) Serialize

func (c ChannelPayProveBodyList) Serialize() ([]byte, error)

func (ChannelPayProveBodyList) Size

type OffChainCrossNodeSimplePaymentReconciliationBill

type OffChainCrossNodeSimplePaymentReconciliationBill struct {

	// Statement of this channel
	ChannelChainTransferTargetProveBody ChannelChainTransferProveBodyInfo

	// Channel chain payment data
	ChannelChainTransferData OffChainFormPaymentChannelTransfer
}

func (OffChainCrossNodeSimplePaymentReconciliationBill) CheckValidity

Check data availability

func (OffChainCrossNodeSimplePaymentReconciliationBill) ConvertToRealtimeReconciliation

*

  • 转换支付票据为实时对账单

func (OffChainCrossNodeSimplePaymentReconciliationBill) GetAutoNumber

func (OffChainCrossNodeSimplePaymentReconciliationBill) GetChannelId

func (OffChainCrossNodeSimplePaymentReconciliationBill) GetLeftAddress

func (OffChainCrossNodeSimplePaymentReconciliationBill) GetLeftBalance

func (OffChainCrossNodeSimplePaymentReconciliationBill) GetLeftSatoshi

func (OffChainCrossNodeSimplePaymentReconciliationBill) GetReuseVersion

func (OffChainCrossNodeSimplePaymentReconciliationBill) GetReuseVersionAndAutoNumber

func (c OffChainCrossNodeSimplePaymentReconciliationBill) GetReuseVersionAndAutoNumber() (uint32, uint64)

func (OffChainCrossNodeSimplePaymentReconciliationBill) GetRightAddress

func (OffChainCrossNodeSimplePaymentReconciliationBill) GetRightBalance

func (OffChainCrossNodeSimplePaymentReconciliationBill) GetRightSatoshi

func (OffChainCrossNodeSimplePaymentReconciliationBill) GetTimestamp

func (*OffChainCrossNodeSimplePaymentReconciliationBill) Parse

func (OffChainCrossNodeSimplePaymentReconciliationBill) Serialize

func (OffChainCrossNodeSimplePaymentReconciliationBill) SerializeWithTypeCode

func (c OffChainCrossNodeSimplePaymentReconciliationBill) SerializeWithTypeCode() ([]byte, error)

func (OffChainCrossNodeSimplePaymentReconciliationBill) Size

func (OffChainCrossNodeSimplePaymentReconciliationBill) TypeCode

func (OffChainCrossNodeSimplePaymentReconciliationBill) VerifySignature

Verify signature on ticket

type OffChainFormPaymentChannelRealtimeReconciliation

type OffChainFormPaymentChannelRealtimeReconciliation struct {
	// Signature hash calculation data part
	ChannelId fields.ChannelId // Channel ID

	ReuseVersion   fields.VarUint4 // Channel reuse sequence number
	BillAutoNumber fields.VarUint8 // Serial number of channel bill

	LeftBalance  fields.Amount // Real time amount on the left
	RightBalance fields.Amount // Right real time amount

	LeftSatoshi  fields.SatoshiVariation // Number of bitcoin sat on the left
	RightSatoshi fields.SatoshiVariation // Number of bitcoin sat on the right

	// Unsigned hash calculation data part
	LeftAddress  fields.Address // Left address
	RightAddress fields.Address // Right address

	Timestamp fields.BlockTxTimestamp // Reconciliation timestamp

	// Signature on both sides
	LeftSign  fields.Sign // Left address reconciliation signature
	RightSign fields.Sign // Right address reconciliation signature
}

*

  • 通道实时对账(链下签署)

func (*OffChainFormPaymentChannelRealtimeReconciliation) CheckAddressAndSign

func (elm *OffChainFormPaymentChannelRealtimeReconciliation) CheckAddressAndSign() error

Check signature

func (*OffChainFormPaymentChannelRealtimeReconciliation) CheckValidity

Check data availability

func (OffChainFormPaymentChannelRealtimeReconciliation) ConvertToOnChain

*

  • 转换链下实时对账单为链上仲裁单据

func (*OffChainFormPaymentChannelRealtimeReconciliation) FillTargetSignature

填充一方签名

func (*OffChainFormPaymentChannelRealtimeReconciliation) GetAutoNumber

func (*OffChainFormPaymentChannelRealtimeReconciliation) GetChannelId

func (*OffChainFormPaymentChannelRealtimeReconciliation) GetLeftAddress

func (*OffChainFormPaymentChannelRealtimeReconciliation) GetLeftBalance

func (*OffChainFormPaymentChannelRealtimeReconciliation) GetLeftSatoshi

func (*OffChainFormPaymentChannelRealtimeReconciliation) GetReuseVersion

func (*OffChainFormPaymentChannelRealtimeReconciliation) GetReuseVersionAndAutoNumber

func (e *OffChainFormPaymentChannelRealtimeReconciliation) GetReuseVersionAndAutoNumber() (uint32, uint64)

func (*OffChainFormPaymentChannelRealtimeReconciliation) GetRightAddress

func (*OffChainFormPaymentChannelRealtimeReconciliation) GetRightBalance

func (*OffChainFormPaymentChannelRealtimeReconciliation) GetRightSatoshi

func (*OffChainFormPaymentChannelRealtimeReconciliation) GetTimestamp

func (*OffChainFormPaymentChannelRealtimeReconciliation) Parse

func (*OffChainFormPaymentChannelRealtimeReconciliation) Serialize

func (*OffChainFormPaymentChannelRealtimeReconciliation) SerializeForSign

func (elm *OffChainFormPaymentChannelRealtimeReconciliation) SerializeForSign() ([]byte, error)

func (*OffChainFormPaymentChannelRealtimeReconciliation) SerializeWithTypeCode

func (e *OffChainFormPaymentChannelRealtimeReconciliation) SerializeWithTypeCode() ([]byte, error)

serialize

func (*OffChainFormPaymentChannelRealtimeReconciliation) SignStuffHash

func (*OffChainFormPaymentChannelRealtimeReconciliation) Size

func (*OffChainFormPaymentChannelRealtimeReconciliation) TypeCode

interface type

func (*OffChainFormPaymentChannelRealtimeReconciliation) VerifySignature

Verify signature on ticket

type OffChainFormPaymentChannelTransfer

type OffChainFormPaymentChannelTransfer struct {
	Timestamp                fields.BlockTxTimestamp // time stamp
	OrderNoteHashHalfChecker fields.HashHalfChecker  // Order detail data hash len = 16

	MustSignCount     fields.VarUint1  // Number of addresses that must be signed, max. 200
	MustSignAddresses []fields.Address // 顺序打乱/随机的通道必须签名的地址

	ChannelCount                         fields.VarUint1          // Number of access channels, max. 200
	ChannelTransferProveHashHalfCheckers []fields.HashHalfChecker // Hash of channel transfer certificate, from payment to final collection, hash len = 16

	MustSigns []fields.Sign // 顺序打乱/随机的签名,顺序与地址相同
}

Channel chain transfer transactions (signed off the chain) can be arbitrated on the chain Adopt zero knowledge proof mode

func (*OffChainFormPaymentChannelTransfer) CheckMustAddressAndSigns

func (elm *OffChainFormPaymentChannelTransfer) CheckMustAddressAndSigns() error

Check all signatures

func (*OffChainFormPaymentChannelTransfer) CheckOneAddressSign

func (elm *OffChainFormPaymentChannelTransfer) CheckOneAddressSign(addr fields.Address) error

Check whether an address is signed

func (*OffChainFormPaymentChannelTransfer) CheckValidity

func (elm *OffChainFormPaymentChannelTransfer) CheckValidity() error

Check data availability

func (*OffChainFormPaymentChannelTransfer) DoSignFillPosition

func (elm *OffChainFormPaymentChannelTransfer) DoSignFillPosition(acc *account.Account) (*fields.Sign, error)

Sign and fill to the specified location

func (*OffChainFormPaymentChannelTransfer) FillSignByPosition

func (elm *OffChainFormPaymentChannelTransfer) FillSignByPosition(sign fields.Sign) error

Populate signatures by location

func (*OffChainFormPaymentChannelTransfer) GetSignStuffHash

func (elm *OffChainFormPaymentChannelTransfer) GetSignStuffHash() fields.Hash

func (*OffChainFormPaymentChannelTransfer) Parse

func (elm *OffChainFormPaymentChannelTransfer) Parse(buf []byte, seek uint32) (uint32, error)

func (*OffChainFormPaymentChannelTransfer) Serialize

func (elm *OffChainFormPaymentChannelTransfer) Serialize() ([]byte, error)

func (*OffChainFormPaymentChannelTransfer) SerializeForPrefixSignStuff

func (elm *OffChainFormPaymentChannelTransfer) SerializeForPrefixSignStuff() ([]byte, error)

func (*OffChainFormPaymentChannelTransfer) SerializeNoSign

func (elm *OffChainFormPaymentChannelTransfer) SerializeNoSign() ([]byte, error)

func (*OffChainFormPaymentChannelTransfer) Size

func (*OffChainFormPaymentChannelTransfer) VerifySignature

func (elm *OffChainFormPaymentChannelTransfer) VerifySignature() error

Verify signature on ticket

type OnChainArbitrationBasisReconciliation

type OnChainArbitrationBasisReconciliation struct {
	// Signature hash calculation data part
	ChannelId fields.ChannelId // Channel ID

	ReuseVersion   fields.VarUint4 // Channel reuse sequence number
	BillAutoNumber fields.VarUint8 // Serial number of channel bill

	LeftBalance  fields.Amount // Real time amount on the left
	RightBalance fields.Amount // Right real time amount

	LeftSatoshi  fields.SatoshiVariation // Number of bitcoin sat on the left
	RightSatoshi fields.SatoshiVariation // Number of bitcoin sat on the right

	// Signature on both sides
	LeftSign  fields.Sign // Left address reconciliation signature
	RightSign fields.Sign // Right address reconciliation signature
}

func (*OnChainArbitrationBasisReconciliation) CheckAddressAndSign

func (elm *OnChainArbitrationBasisReconciliation) CheckAddressAndSign(laddr, raddr fields.Address) error

Check signature

func (*OnChainArbitrationBasisReconciliation) FillSigns

func (elm *OnChainArbitrationBasisReconciliation) FillSigns(lacc, racc *account.Account) error

Fill in signature

func (*OnChainArbitrationBasisReconciliation) GetAutoNumber

func (e *OnChainArbitrationBasisReconciliation) GetAutoNumber() uint64

func (*OnChainArbitrationBasisReconciliation) GetChannelId

func (*OnChainArbitrationBasisReconciliation) GetLeftBalance

func (*OnChainArbitrationBasisReconciliation) GetLeftSatoshi

func (*OnChainArbitrationBasisReconciliation) GetReuseVersion

func (e *OnChainArbitrationBasisReconciliation) GetReuseVersion() uint32

func (*OnChainArbitrationBasisReconciliation) GetRightBalance

func (*OnChainArbitrationBasisReconciliation) GetRightSatoshi

func (*OnChainArbitrationBasisReconciliation) Parse

func (elm *OnChainArbitrationBasisReconciliation) Parse(buf []byte, seek uint32) (uint32, error)

func (*OnChainArbitrationBasisReconciliation) Serialize

func (elm *OnChainArbitrationBasisReconciliation) Serialize() ([]byte, error)

func (*OnChainArbitrationBasisReconciliation) SerializeForSign

func (elm *OnChainArbitrationBasisReconciliation) SerializeForSign() ([]byte, error)

func (*OnChainArbitrationBasisReconciliation) SignStuffHash

func (elm *OnChainArbitrationBasisReconciliation) SignStuffHash() fields.Hash

func (*OnChainArbitrationBasisReconciliation) Size

type OnChainChannelPaymentArbitrationReconciliationBasis

type OnChainChannelPaymentArbitrationReconciliationBasis interface {
	GetChannelId() fields.ChannelId
	GetLeftBalance() fields.Amount   // Left HAC amount
	GetRightBalance() fields.Amount  // Right HAC amount
	GetLeftSatoshi() fields.Satoshi  // BTC sat amount allocated on the left
	GetRightSatoshi() fields.Satoshi // BTC sat amount allocated on the right
	GetReuseVersion() uint32         // Channel reuse sequence number
	GetAutoNumber() uint64
	// Check address and signature
	CheckAddressAndSign(laddr, raddr fields.Address) error
}

Online arbitration reconciliation basis

type ReconciliationBalanceBill

type ReconciliationBalanceBill interface {
	Size() uint32
	Parse(buf []byte, seek uint32) (uint32, error) // Deserialization
	Serialize() ([]byte, error)                    // serialize
	SerializeWithTypeCode() ([]byte, error)        // serialize
	TypeCode() uint8                               // type

	GetChannelId() fields.ChannelId

	GetLeftSatoshi() fields.Satoshi
	GetRightSatoshi() fields.Satoshi

	GetLeftBalance() fields.Amount
	GetRightBalance() fields.Amount

	GetLeftAddress() fields.Address
	GetRightAddress() fields.Address

	GetTimestamp() uint64 // Reconciliation timestamp, seconds

	// Channel reuse serial number channel bill serial number
	GetReuseVersionAndAutoNumber() (uint32, uint64)
	GetReuseVersion() uint32
	GetAutoNumber() uint64

	CheckValidity() error   // Check data availability
	VerifySignature() error // Verify signature on ticket

}

General reconciliation bill interface

func ParseReconciliationBalanceBillByPrefixTypeCode

func ParseReconciliationBalanceBillByPrefixTypeCode(buf []byte, seek uint32) (ReconciliationBalanceBill, uint32, error)

Deserialization

type SortAddresses

type SortAddresses []fields.Address

Sorting unit

func (SortAddresses) Len

func (n SortAddresses) Len() int

func (SortAddresses) Less

func (n SortAddresses) Less(i, j int) bool

func (SortAddresses) Swap

func (n SortAddresses) Swap(i, j int)

Jump to

Keyboard shortcuts

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