lnstate

package
v0.0.0-...-1e35018 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2016 License: MIT Imports: 7 Imported by: 0

README

I'm using this as a temporary repo for the state machine.

All hooks into real stuff isn't used right now.

Will merge into lnwallet/channel.go later?

Documentation

Index

Constants

View Source
const (
	MAX_STAGED_HTLCS                 = 1000
	MAX_UNREVOKED_COMMITMENTS        = 16
	MAX_UPDATED_HTLCS_PER_COMMITMENT = 1000
)
View Source
const (
	//HTLC Add
	ADD_PRESTAGE             = 1000
	ADD_STAGED               = 1100
	ADD_SIGNING_AND_REVOKING = 1200
	ADD_COMPLETE             = 1300 //Most HTLCs should be this
	ADD_REJECTED             = 1999 //Staging request rejected

	//HTLC Timeout
	TIMEOUT_PRESTAGE             = 2000
	TIMEOUT_STAGED               = 2100
	TIMEOUT_SIGNING_AND_REVOKING = 2200
	TIMEOUT_COMPLETE             = 2300

	//HTLC Settle
	SETTLE_PRESTAGE             = 3000
	SETTLE_STAGED               = 3100
	SETTLE_SIGNING_AND_REVOKING = 3200
	SETTLE_COMPLETE             = 3300
)

PaymentDescriptor states PRESTAGE: We're not sure if the other guy wants to follow through STAGED: Both parties informally agree to add to their commitments SIGNING_AND_REVOKING: In the process of activating the HTLC

Only one state is allowed at a time. timeout/settle can only begin on an ADD_COMPLETE state. If it times out before it hits completion, channel closes out uncooperatively.

NOTE: Current design assumes if value%1000 == 200 as partially signed/revoked, this means that the code is reliant upon this as knowing when to force close out channels, etc.

Variables

This section is empty.

Functions

This section is empty.

Types

type LNChannel

type LNChannel struct {
	sync.RWMutex

	//HTLCs
	//Even/odd numbering in effect
	//Will just take the next number
	HTLCs map[lnwire.HTLCKey]*PaymentDescriptor
	// contains filtered or unexported fields
}

func (*LNChannel) CreateHTLC

func (l *LNChannel) CreateHTLC(h *PaymentDescriptor) error

type PaymentDescriptor

type PaymentDescriptor struct {
	RHashes       []*[20]byte
	Timeout       uint32
	CreditsAmount lnwire.CreditsAmount
	Revocation    []*[20]byte
	Blob          []byte //next hop data
	PayToUs       bool

	State uint32 //Current state

	Index uint32 //Position in txout
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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