channeldb

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: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ActiveNetParams = &chaincfg.TestNet3Params
)
View Source
var (
	ErrNoExists = fmt.Errorf("channel db has not yet been created")
)

Functions

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.

func SetLogWriter

func SetLogWriter(w io.Writer, level string) error

SetLogWriter uses a specified io.Writer to output package logging info. This allows a caller to direct package logging output without needing a dependency on seelog. If the caller is also using btclog, UseLogger should be used instead.

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

Types

type ChannelDelta

type ChannelDelta struct {
}

ChannelDelta... TODO(roasbeef): binlog like entry?

type ChannelSnapshot

type ChannelSnapshot struct {
	OpenChannel
	// contains filtered or unexported fields
}

ChannelSnapshot.... TODO(roasbeef): methods to roll forwards/backwards in state etc

  • use botldb cursor?

type DB

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

DB...

func Open

func Open(dbPath string) (*DB, error)

Open opens an existing channeldb created under the passed namespace with sensitive data encrypted by the passed EncryptorDecryptor implementation. TODO(roasbeef): versioning?

func (*DB) Close

func (d *DB) Close() error

Close...

func (*DB) FetchOpenChannel

func (d *DB) FetchOpenChannel(nodeID [32]byte) (*OpenChannel, error)

FetchOpenChannel...

func (*DB) GetIdAdr

func (d *DB) GetIdAdr() (*btcutil.AddressPubKeyHash, error)

GetIdKey returns the hash160 of the public key used for out identity within the Lightning Network as a p2pkh bitcoin address.

func (*DB) PutIdKey

func (d *DB) PutIdKey(pkh []byte) error

PutIdKey saves the hash160 of the public key used for our identity within the Lightning Network.

func (*DB) RegisterCryptoSystem

func (d *DB) RegisterCryptoSystem(ed EncryptorDecryptor)

RegisterCryptoSystem...

func (*DB) Wipe

func (d *DB) Wipe() error

Wipe...

type EncryptorDecryptor

type EncryptorDecryptor interface {
	Encrypt(in []byte) ([]byte, error)
	Decrypt(in []byte) ([]byte, error)
	OverheadSize() uint32
}

EncryptorDecryptor... TODO(roasbeef): ability to rotate EncryptorDecryptor's across DB

type OpenChannel

type OpenChannel struct {
	// Hash? or Their current pubKey?
	TheirLNID [wire.HashSize]byte

	// The ID of a channel is the txid of the funding transaction.
	ChanID [wire.HashSize]byte

	MinFeePerKb btcutil.Amount

	// Keys for both sides to be used for the commitment transactions.
	OurCommitKey   *btcec.PrivateKey
	TheirCommitKey *btcec.PublicKey

	// Tracking total channel capacity, and the amount of funds allocated
	// to each side.
	Capacity     btcutil.Amount
	OurBalance   btcutil.Amount
	TheirBalance btcutil.Amount

	// Commitment transactions for both sides (they're asymmetric). Our
	// commitment transaction includes a valid sigScript, and is ready for
	// broadcast.
	TheirCommitTx *wire.MsgTx
	OurCommitTx   *wire.MsgTx

	// The final funding transaction. Kept for wallet-related records.
	FundingTx *wire.MsgTx

	MultiSigKey         *btcec.PrivateKey
	FundingRedeemScript []byte

	// In blocks
	LocalCsvDelay  uint32
	RemoteCsvDelay uint32

	// Current revocation for their commitment transaction. However, since
	// this is the hash, and not the pre-image, we can't yet verify that
	// it's actually in the chain.
	TheirCurrentRevocation [20]byte
	LocalElkrem            *elkrem.ElkremSender
	RemoteElkrem           *elkrem.ElkremReceiver

	// The pkScript for both sides to be used for final delivery in the case
	// of a cooperative close.
	OurDeliveryScript   []byte
	TheirDeliveryScript []byte

	NumUpdates            uint64
	TotalSatoshisSent     uint64
	TotalSatoshisReceived uint64
	TotalNetFees          uint64    // TODO(roasbeef): total fees paid too?
	CreationTime          time.Time // TODO(roasbeef): last update time?

	// TODO(roasbeef): eww
	Db *DB

	sync.RWMutex
	// contains filtered or unexported fields
}

OpenChannel... TODO(roasbeef): Copy/Clone method, so CoW on writes?

  • CoW method would allow for intelligent partial writes for updates

TODO(roasbeef): UpdateState(func (newChan *OpenChannel) error)

  • need mutex, invarient that all reads/writes grab the mutex
  • needs to also return two slices of added then removed HTLC's

func (*OpenChannel) FindPreviousState

func (c *OpenChannel) FindPreviousState(updateNum uint64) (*ChannelSnapshot, error)

FindPreviousState... TODO(roasbeef): method to retrieve both old commitment txns given update #

func (*OpenChannel) FullSync

func (c *OpenChannel) FullSync() error

FullSync serializes, and writes to disk the *full* channel state, using both the active channel bucket to store the prefixed column fields, and the remote node's ID to store the remainder of the channel state.

NOTE: This method requires an active EncryptorDecryptor to be registered in order to encrypt sensitive information.

func (OpenChannel) RecordChannelDelta

func (c OpenChannel) RecordChannelDelta(theirRevokedCommit *wire.MsgTx, updateNum uint64) error

RecordChannelDelta TODO(roasbeef): only need their commit?

  • or as internal helper func to UpdateState func?

func (*OpenChannel) Snapshot

func (c *OpenChannel) Snapshot() (*ChannelSnapshot, error)

Snapshot.... read-only snapshot

Jump to

Keyboard shortcuts

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