Documentation ¶
Index ¶
- func NewMockConn(localPk, remotePk *secp256k1.PublicKey, localAddr, remoteAddr net.Addr, ...) (*MockPeer, *MockPeer)
- type ClientDB
- func (m *ClientDB) AckUpdate(id *wtdb.SessionID, seqNum, lastApplied uint16) error
- func (m *ClientDB) CommitUpdate(id *wtdb.SessionID, update *wtdb.CommittedUpdate) (uint16, error)
- func (m *ClientDB) CreateClientSession(session *wtdb.ClientSession) error
- func (m *ClientDB) CreateTower(lnAddr *lnwire.NetAddress) (*wtdb.Tower, error)
- func (m *ClientDB) FetchChanSummaries() (wtdb.ChannelSummaries, error)
- func (m *ClientDB) ListClientSessions(tower *wtdb.TowerID) (map[wtdb.SessionID]*wtdb.ClientSession, error)
- func (m *ClientDB) ListTowers() ([]*wtdb.Tower, error)
- func (m *ClientDB) LoadTower(pubKey *secp256k1.PublicKey) (*wtdb.Tower, error)
- func (m *ClientDB) LoadTowerByID(towerID wtdb.TowerID) (*wtdb.Tower, error)
- func (m *ClientDB) MarkBackupIneligible(chanID lnwire.ChannelID, commitHeight uint64) error
- func (m *ClientDB) NextSessionKeyIndex(towerID wtdb.TowerID, blobType blob.Type) (uint32, error)
- func (m *ClientDB) RegisterChannel(chanID lnwire.ChannelID, sweepPkScript []byte) error
- func (m *ClientDB) RemoveTower(pubKey *secp256k1.PublicKey, addr net.Addr) error
- type MockPeer
- func (p *MockPeer) Close() error
- func (p *MockPeer) LocalAddr() net.Addr
- func (p *MockPeer) Read(dst []byte) (int, error)
- func (p *MockPeer) ReadNextMessage() ([]byte, error)
- func (p *MockPeer) RemoteAddr() net.Addr
- func (p *MockPeer) RemotePub() *secp256k1.PublicKey
- func (p *MockPeer) SetDeadline(t time.Time) error
- func (p *MockPeer) SetReadDeadline(t time.Time) error
- func (p *MockPeer) SetWriteDeadline(t time.Time) error
- func (p *MockPeer) Write(b []byte) (n int, err error)
- type MockSigner
- func (s *MockSigner) AddPrivKey(privKey *secp256k1.PrivateKey) keychain.KeyLocator
- func (s *MockSigner) ComputeInputScript(tx *wire.MsgTx, signDesc *input.SignDescriptor) (*input.Script, error)
- func (s *MockSigner) SignOutputRaw(tx *wire.MsgTx, signDesc *input.SignDescriptor) (input.Signature, error)
- type SecretKeyRing
- type TowerDB
- func (db *TowerDB) DeleteSession(target wtdb.SessionID) error
- func (db *TowerDB) GetLookoutTip() (*chainntnfs.BlockEpoch, error)
- func (db *TowerDB) GetSessionInfo(id *wtdb.SessionID) (*wtdb.SessionInfo, error)
- func (db *TowerDB) InsertSessionInfo(info *wtdb.SessionInfo) error
- func (db *TowerDB) InsertStateUpdate(update *wtdb.SessionStateUpdate) (uint16, error)
- func (db *TowerDB) QueryMatches(breachHints []blob.BreachHint) ([]wtdb.Match, error)
- func (db *TowerDB) SetLookoutTip(epoch *chainntnfs.BlockEpoch) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ClientDB ¶
type ClientDB struct {
// contains filtered or unexported fields
}
ClientDB is a mock, in-memory database or testing the watchtower client behavior.
func (*ClientDB) AckUpdate ¶
AckUpdate persists an acknowledgment for a given (session, seqnum) pair. This removes the update from the set of committed updates, and validates the lastApplied value returned from the tower.
func (*ClientDB) CommitUpdate ¶
CommitUpdate persists the CommittedUpdate provided in the slot for (session, seqNum). This allows the client to retransmit this update on startup.
func (*ClientDB) CreateClientSession ¶
func (m *ClientDB) CreateClientSession(session *wtdb.ClientSession) error
CreateClientSession records a newly negotiated client session in the set of active sessions. The session can be identified by its SessionID.
func (*ClientDB) CreateTower ¶
CreateTower initialize an address record used to communicate with a watchtower. Each Tower is assigned a unique ID, that is used to amortize storage costs of the public key when used by multiple sessions. If the tower already exists, the address is appended to the list of all addresses used to that tower previously and its corresponding sessions are marked as active.
func (*ClientDB) FetchChanSummaries ¶
func (m *ClientDB) FetchChanSummaries() (wtdb.ChannelSummaries, error)
FetchChanSummaries loads a mapping from all registered channels to their channel summaries.
func (*ClientDB) ListClientSessions ¶
func (m *ClientDB) ListClientSessions( tower *wtdb.TowerID) (map[wtdb.SessionID]*wtdb.ClientSession, error)
ListClientSessions returns the set of all client sessions known to the db. An optional tower ID can be used to filter out any client sessions in the response that do not correspond to this tower.
func (*ClientDB) ListTowers ¶
ListTowers retrieves the list of towers available within the database.
func (*ClientDB) LoadTowerByID ¶
LoadTowerByID retrieves a tower by its tower ID.
func (*ClientDB) MarkBackupIneligible ¶
MarkBackupIneligible records that particular commit height is ineligible for backup. This allows the client to track which updates it should not attempt to retry after startup.
func (*ClientDB) NextSessionKeyIndex ¶
NextSessionKeyIndex reserves a new session key derivation index for a particular tower id. The index is reserved for that tower until CreateClientSession is invoked for that tower and index, at which point a new index for that tower can be reserved. Multiple calls to this method before CreateClientSession is invoked should return the same index.
func (*ClientDB) RegisterChannel ¶
RegisterChannel registers a channel for use within the client database. For now, all that is stored in the channel summary is the sweep pkscript that we'd like any tower sweeps to pay into. In the future, this will be extended to contain more info to allow the client efficiently request historical states to be backed up under the client's active policy.
func (*ClientDB) RemoveTower ¶
RemoveTower modifies a tower's record within the database. If an address is provided, then _only_ the address record should be removed from the tower's persisted state. Otherwise, we'll attempt to mark the tower as inactive by marking all of its sessions inactive. If any of its sessions has unacked updates, then ErrTowerUnackedUpdates is returned. If the tower doesn't have any sessions at all, it'll be completely removed from the database.
NOTE: An error is not returned if the tower doesn't exist.
type MockPeer ¶
type MockPeer struct { IncomingMsgs chan []byte OutgoingMsgs chan []byte RemoteQuit chan struct{} Quit chan struct{} // contains filtered or unexported fields }
MockPeer emulates a single endpoint of brontide transport.
func NewMockPeer ¶
NewMockPeer returns a fresh MockPeer.
func (*MockPeer) ReadNextMessage ¶
ReadNextMessage returns the raw bytes of the next full message read from the remote peer. The read will fail if either party closes the connection or the read deadline expires.
func (*MockPeer) RemoteAddr ¶
RemoteAddr returns the net address of the remote peer.
func (*MockPeer) RemotePub ¶
func (p *MockPeer) RemotePub() *secp256k1.PublicKey
RemotePub returns the public key of the remote peer.
func (*MockPeer) SetDeadline ¶
SetDeadline is not implemented.
func (*MockPeer) SetReadDeadline ¶
SetReadDeadline initializes a timer that will cause any pending reads to fail at time t. If t is zero, the deadline is infinite.
func (*MockPeer) SetWriteDeadline ¶
SetWriteDeadline initializes a timer that will cause any pending writes to fail at time t. If t is zero, the deadline is infinite.
type MockSigner ¶
type MockSigner struct {
// contains filtered or unexported fields
}
MockSigner is an input.Signer that allows one to add arbitrary private keys and sign messages by passing the assigned keychain.KeyLocator.
func (*MockSigner) AddPrivKey ¶
func (s *MockSigner) AddPrivKey(privKey *secp256k1.PrivateKey) keychain.KeyLocator
AddPrivKey records the passed privKey in the MockSigner's registry of keys it can sign with in the future. A unique key locator is returned, allowing the caller to sign with this key when presented via an input.SignDescriptor.
func (*MockSigner) ComputeInputScript ¶
func (s *MockSigner) ComputeInputScript(tx *wire.MsgTx, signDesc *input.SignDescriptor) (*input.Script, error)
ComputeInputScript is not implemented.
func (*MockSigner) SignOutputRaw ¶
func (s *MockSigner) SignOutputRaw(tx *wire.MsgTx, signDesc *input.SignDescriptor) (input.Signature, error)
SignOutputRaw signs an input on the passed transaction using the input index in the sign descriptor. The returned signature is the raw DER-encoded signature without the signhash flag.
type SecretKeyRing ¶
type SecretKeyRing struct {
// contains filtered or unexported fields
}
SecretKeyRing is a mock, in-memory implementation for deriving private keys.
func NewSecretKeyRing ¶
func NewSecretKeyRing() *SecretKeyRing
NewSecretKeyRing creates a new mock SecretKeyRing.
func (*SecretKeyRing) DeriveKey ¶ added in v0.3.0
func (m *SecretKeyRing) DeriveKey( keyLoc keychain.KeyLocator) (keychain.KeyDescriptor, error)
DeriveKey attempts to derive an arbitrary key specified by the passed KeyLocator. This may be used in several recovery scenarios, or when manually rotating something like our current default node key.
NOTE: This is part of the wtclient.ECDHKeyRing interface.
func (*SecretKeyRing) ECDH ¶ added in v0.3.0
func (m *SecretKeyRing) ECDH(keyDesc keychain.KeyDescriptor, pub *secp256k1.PublicKey) ([32]byte, error)
ECDH performs a scalar multiplication (ECDH-like operation) between the target key descriptor and remote public key. The output returned will be the sha256 of the resulting shared point serialized in compressed format. If k is our private key, and P is the public key, we perform the following operation:
sx := k*P s := sha256(sx.SerializeCompressed())
NOTE: This is part of the wtclient.ECDHKeyRing interface.
type TowerDB ¶
type TowerDB struct {
// contains filtered or unexported fields
}
TowerDB is a mock, in-memory implementation of a watchtower.DB.
func (*TowerDB) DeleteSession ¶
DeleteSession removes all data associated with a particular session id from the tower's database.
func (*TowerDB) GetLookoutTip ¶
func (db *TowerDB) GetLookoutTip() (*chainntnfs.BlockEpoch, error)
GetLookoutTip retrieves the current lookout tip block epoch from the tower database.
func (*TowerDB) GetSessionInfo ¶
GetSessionInfo retrieves the session for the passed session id. An error is returned if the session could not be found.
func (*TowerDB) InsertSessionInfo ¶
func (db *TowerDB) InsertSessionInfo(info *wtdb.SessionInfo) error
InsertSessionInfo records a negotiated session in the tower database. An error is returned if the session already exists.
func (*TowerDB) InsertStateUpdate ¶
func (db *TowerDB) InsertStateUpdate(update *wtdb.SessionStateUpdate) (uint16, error)
InsertStateUpdate stores an update sent by the client after validating that the update is well-formed in the context of other updates sent for the same session. This include verifying that the sequence number is incremented properly and the last applied values echoed by the client are sane.
func (*TowerDB) QueryMatches ¶
QueryMatches searches against all known state updates for any that match the passed breachHints. More than one Match will be returned for a given hint if they exist in the database.
func (*TowerDB) SetLookoutTip ¶
func (db *TowerDB) SetLookoutTip(epoch *chainntnfs.BlockEpoch) error
SetLookoutTip stores the provided epoch as the latest lookout tip epoch in the tower database.