Documentation ¶
Index ¶
- func NewMockConn(localPk, remotePk *btcec.PublicKey, localAddr, remoteAddr net.Addr, ...) (*MockPeer, *MockPeer)
- func NewQueueDB[T any]() wtdb.Queue[T]
- type DiskQueueDB
- 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() *btcec.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 *btcec.PrivateKey) keychain.KeyLocator
- func (s *MockSigner) ComputeInputScript(tx *wire.MsgTx, signDesc *input.SignDescriptor) (*input.Script, error)
- func (s *MockSigner) MuSig2Cleanup(input.MuSig2SessionID) error
- func (s *MockSigner) MuSig2CombineSig(input.MuSig2SessionID, []*musig2.PartialSignature) (*schnorr.Signature, bool, error)
- func (s *MockSigner) MuSig2CreateSession(input.MuSig2Version, keychain.KeyLocator, []*btcec.PublicKey, ...) (*input.MuSig2SessionInfo, error)
- func (s *MockSigner) MuSig2RegisterNonces(input.MuSig2SessionID, [][musig2.PubNonceSize]byte) (bool, error)
- func (s *MockSigner) MuSig2Sign(input.MuSig2SessionID, [sha256.Size]byte, bool) (*musig2.PartialSignature, 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 DiskQueueDB ¶
type DiskQueueDB[T any] struct { // contains filtered or unexported fields }
DiskQueueDB is an in-memory implementation of the wtclient.Queue interface.
func (*DiskQueueDB[T]) Len ¶
func (d *DiskQueueDB[T]) Len() (uint64, error)
Len returns the number of tasks in the queue.
NOTE: This is part of the wtclient.Queue interface.
func (*DiskQueueDB[T]) PopUpTo ¶
func (d *DiskQueueDB[T]) PopUpTo(n int) ([]T, error)
PopUpTo attempts to pop up to n items from the queue. If the queue is empty, then ErrEmptyQueue is returned.
NOTE: This is part of the Queue interface.
func (*DiskQueueDB[T]) Push ¶
func (d *DiskQueueDB[T]) Push(items ...T) error
Push adds new T items to the tail of the queue.
NOTE: This is part of the wtclient.Queue interface.
func (*DiskQueueDB[T]) PushHead ¶
func (d *DiskQueueDB[T]) PushHead(items ...T) error
PushHead pushes new T items to the head of the queue.
NOTE: This is part of the wtclient.Queue interface.
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() *btcec.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 *btcec.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) MuSig2Cleanup ¶
func (s *MockSigner) MuSig2Cleanup(input.MuSig2SessionID) error
MuSig2Cleanup removes a session from memory to free up resources.
func (*MockSigner) MuSig2CombineSig ¶
func (s *MockSigner) MuSig2CombineSig(input.MuSig2SessionID, []*musig2.PartialSignature) (*schnorr.Signature, bool, error)
MuSig2CombineSig combines the given partial signature(s) with the local one, if it already exists. Once a partial signature of all participants is registered, the final signature will be combined and returned.
func (*MockSigner) MuSig2CreateSession ¶
func (s *MockSigner) MuSig2CreateSession(input.MuSig2Version, keychain.KeyLocator, []*btcec.PublicKey, *input.MuSig2Tweaks, [][musig2.PubNonceSize]byte, *musig2.Nonces) (*input.MuSig2SessionInfo, error)
MuSig2CreateSession creates a new MuSig2 signing session using the local key identified by the key locator. The complete list of all public keys of all signing parties must be provided, including the public key of the local signing key. If nonces of other parties are already known, they can be submitted as well to reduce the number of method calls necessary later on.
func (*MockSigner) MuSig2RegisterNonces ¶
func (s *MockSigner) MuSig2RegisterNonces(input.MuSig2SessionID, [][musig2.PubNonceSize]byte) (bool, error)
MuSig2RegisterNonces registers one or more public nonces of other signing participants for a session identified by its ID. This method returns true once we have all nonces for all other signing participants.
func (*MockSigner) MuSig2Sign ¶
func (s *MockSigner) MuSig2Sign(input.MuSig2SessionID, [sha256.Size]byte, bool) (*musig2.PartialSignature, error)
MuSig2Sign creates a partial signature using the local signing key that was specified when the session was created. This can only be called when all public nonces of all participants are known and have been registered with the session. If this node isn't responsible for combining all the partial signatures, then the cleanup parameter should be set, indicating that the session can be removed from memory once the signature was produced.
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 ¶
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 ¶
func (m *SecretKeyRing) ECDH(keyDesc keychain.KeyDescriptor, pub *btcec.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.