id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
129,400
lightningnetwork/lnd
chancloser.go
rachetFee
func rachetFee(fee btcutil.Amount, up bool) btcutil.Amount { // If we need to rachet up, then we'll increase our fee by 10%. if up { return fee + ((fee * 1) / 10) } // Otherwise, we'll *decrease* our fee by 10%. return fee - ((fee * 1) / 10) }
go
func rachetFee(fee btcutil.Amount, up bool) btcutil.Amount { // If we need to rachet up, then we'll increase our fee by 10%. if up { return fee + ((fee * 1) / 10) } // Otherwise, we'll *decrease* our fee by 10%. return fee - ((fee * 1) / 10) }
[ "func", "rachetFee", "(", "fee", "btcutil", ".", "Amount", ",", "up", "bool", ")", "btcutil", ".", "Amount", "{", "// If we need to rachet up, then we'll increase our fee by 10%.", "if", "up", "{", "return", "fee", "+", "(", "(", "fee", "*", "1", ")", "/", "...
// rachetFee is our step function used to inch our fee closer to something that // both sides can agree on. If up is true, then we'll attempt to increase our // offered fee. Otherwise, if up is false, then we'll attempt to decrease our // offered fee.
[ "rachetFee", "is", "our", "step", "function", "used", "to", "inch", "our", "fee", "closer", "to", "something", "that", "both", "sides", "can", "agree", "on", ".", "If", "up", "is", "true", "then", "we", "ll", "attempt", "to", "increase", "our", "offered"...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chancloser.go#L539-L547
129,401
lightningnetwork/lnd
lnwire/channel_id.go
NewChanIDFromOutPoint
func NewChanIDFromOutPoint(op *wire.OutPoint) ChannelID { // First we'll copy the txid of the outpoint into our channel ID slice. var cid ChannelID copy(cid[:], op.Hash[:]) // With the txid copied over, we'll now XOR the lower 2-bytes of the // partial channelID with big-endian serialization of output index. xor...
go
func NewChanIDFromOutPoint(op *wire.OutPoint) ChannelID { // First we'll copy the txid of the outpoint into our channel ID slice. var cid ChannelID copy(cid[:], op.Hash[:]) // With the txid copied over, we'll now XOR the lower 2-bytes of the // partial channelID with big-endian serialization of output index. xor...
[ "func", "NewChanIDFromOutPoint", "(", "op", "*", "wire", ".", "OutPoint", ")", "ChannelID", "{", "// First we'll copy the txid of the outpoint into our channel ID slice.", "var", "cid", "ChannelID", "\n", "copy", "(", "cid", "[", ":", "]", ",", "op", ".", "Hash", ...
// NewChanIDFromOutPoint converts a target OutPoint into a ChannelID that is // usable within the network. In order to convert the OutPoint into a ChannelID, // we XOR the lower 2-bytes of the txid within the OutPoint with the big-endian // serialization of the Index of the OutPoint, truncated to 2-bytes.
[ "NewChanIDFromOutPoint", "converts", "a", "target", "OutPoint", "into", "a", "ChannelID", "that", "is", "usable", "within", "the", "network", ".", "In", "order", "to", "convert", "the", "OutPoint", "into", "a", "ChannelID", "we", "XOR", "the", "lower", "2", ...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/channel_id.go#L43-L53
129,402
lightningnetwork/lnd
lnwire/channel_id.go
xorTxid
func xorTxid(cid *ChannelID, outputIndex uint16) { var buf [32]byte binary.BigEndian.PutUint16(buf[30:], outputIndex) cid[30] = cid[30] ^ buf[30] cid[31] = cid[31] ^ buf[31] }
go
func xorTxid(cid *ChannelID, outputIndex uint16) { var buf [32]byte binary.BigEndian.PutUint16(buf[30:], outputIndex) cid[30] = cid[30] ^ buf[30] cid[31] = cid[31] ^ buf[31] }
[ "func", "xorTxid", "(", "cid", "*", "ChannelID", ",", "outputIndex", "uint16", ")", "{", "var", "buf", "[", "32", "]", "byte", "\n", "binary", ".", "BigEndian", ".", "PutUint16", "(", "buf", "[", "30", ":", "]", ",", "outputIndex", ")", "\n\n", "cid"...
// xorTxid performs the transformation needed to transform an OutPoint into a // ChannelID. To do this, we expect the cid parameter to contain the txid // unaltered and the outputIndex to be the output index
[ "xorTxid", "performs", "the", "transformation", "needed", "to", "transform", "an", "OutPoint", "into", "a", "ChannelID", ".", "To", "do", "this", "we", "expect", "the", "cid", "parameter", "to", "contain", "the", "txid", "unaltered", "and", "the", "outputIndex...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/channel_id.go#L58-L64
129,403
lightningnetwork/lnd
lnwire/channel_id.go
GenPossibleOutPoints
func (c *ChannelID) GenPossibleOutPoints() [MaxFundingTxOutputs]wire.OutPoint { var possiblePoints [MaxFundingTxOutputs]wire.OutPoint for i := uint32(0); i < MaxFundingTxOutputs; i++ { cidCopy := *c xorTxid(&cidCopy, uint16(i)) possiblePoints[i] = wire.OutPoint{ Hash: chainhash.Hash(cidCopy), Index: i, ...
go
func (c *ChannelID) GenPossibleOutPoints() [MaxFundingTxOutputs]wire.OutPoint { var possiblePoints [MaxFundingTxOutputs]wire.OutPoint for i := uint32(0); i < MaxFundingTxOutputs; i++ { cidCopy := *c xorTxid(&cidCopy, uint16(i)) possiblePoints[i] = wire.OutPoint{ Hash: chainhash.Hash(cidCopy), Index: i, ...
[ "func", "(", "c", "*", "ChannelID", ")", "GenPossibleOutPoints", "(", ")", "[", "MaxFundingTxOutputs", "]", "wire", ".", "OutPoint", "{", "var", "possiblePoints", "[", "MaxFundingTxOutputs", "]", "wire", ".", "OutPoint", "\n", "for", "i", ":=", "uint32", "("...
// GenPossibleOutPoints generates all the possible outputs given a channel ID. // In order to generate these possible outpoints, we perform a brute-force // search through the candidate output index space, performing a reverse // mapping from channelID back to OutPoint.
[ "GenPossibleOutPoints", "generates", "all", "the", "possible", "outputs", "given", "a", "channel", "ID", ".", "In", "order", "to", "generate", "these", "possible", "outpoints", "we", "perform", "a", "brute", "-", "force", "search", "through", "the", "candidate",...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/channel_id.go#L70-L83
129,404
lightningnetwork/lnd
lnwire/channel_id.go
IsChanPoint
func (c ChannelID) IsChanPoint(op *wire.OutPoint) bool { candidateCid := NewChanIDFromOutPoint(op) return candidateCid == c }
go
func (c ChannelID) IsChanPoint(op *wire.OutPoint) bool { candidateCid := NewChanIDFromOutPoint(op) return candidateCid == c }
[ "func", "(", "c", "ChannelID", ")", "IsChanPoint", "(", "op", "*", "wire", ".", "OutPoint", ")", "bool", "{", "candidateCid", ":=", "NewChanIDFromOutPoint", "(", "op", ")", "\n\n", "return", "candidateCid", "==", "c", "\n", "}" ]
// IsChanPoint returns true if the OutPoint passed corresponds to the target // ChannelID.
[ "IsChanPoint", "returns", "true", "if", "the", "OutPoint", "passed", "corresponds", "to", "the", "target", "ChannelID", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/channel_id.go#L87-L91
129,405
lightningnetwork/lnd
build/log_default.go
Write
func (w *LogWriter) Write(b []byte) (int, error) { os.Stdout.Write(b) if w.RotatorPipe != nil { w.RotatorPipe.Write(b) } return len(b), nil }
go
func (w *LogWriter) Write(b []byte) (int, error) { os.Stdout.Write(b) if w.RotatorPipe != nil { w.RotatorPipe.Write(b) } return len(b), nil }
[ "func", "(", "w", "*", "LogWriter", ")", "Write", "(", "b", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "os", ".", "Stdout", ".", "Write", "(", "b", ")", "\n", "if", "w", ".", "RotatorPipe", "!=", "nil", "{", "w", ".", "Rotator...
// Write writes the byte slice to both stdout and the log rotator, if present.
[ "Write", "writes", "the", "byte", "slice", "to", "both", "stdout", "and", "the", "log", "rotator", "if", "present", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/build/log_default.go#L12-L18
129,406
lightningnetwork/lnd
peer.go
newPeer
func newPeer(conn net.Conn, connReq *connmgr.ConnReq, server *server, addr *lnwire.NetAddress, inbound bool, localFeatures *lnwire.RawFeatureVector, chanActiveTimeout time.Duration, finalCltvRejectDelta, outgoingCltvRejectDelta uint32) ( *peer, error) { nodePub := addr.IdentityKey p := &peer{ conn: conn, a...
go
func newPeer(conn net.Conn, connReq *connmgr.ConnReq, server *server, addr *lnwire.NetAddress, inbound bool, localFeatures *lnwire.RawFeatureVector, chanActiveTimeout time.Duration, finalCltvRejectDelta, outgoingCltvRejectDelta uint32) ( *peer, error) { nodePub := addr.IdentityKey p := &peer{ conn: conn, a...
[ "func", "newPeer", "(", "conn", "net", ".", "Conn", ",", "connReq", "*", "connmgr", ".", "ConnReq", ",", "server", "*", "server", ",", "addr", "*", "lnwire", ".", "NetAddress", ",", "inbound", "bool", ",", "localFeatures", "*", "lnwire", ".", "RawFeature...
// newPeer creates a new peer from an establish connection object, and a // pointer to the main server.
[ "newPeer", "creates", "a", "new", "peer", "from", "an", "establish", "connection", "object", "and", "a", "pointer", "to", "the", "main", "server", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L241-L288
129,407
lightningnetwork/lnd
peer.go
Start
func (p *peer) Start() error { if atomic.AddInt32(&p.started, 1) != 1 { return nil } peerLog.Tracef("Peer %v starting", p) // Exchange local and global features, the init message should be very // first between two nodes. if err := p.sendInitMsg(); err != nil { return fmt.Errorf("unable to send init msg: %v...
go
func (p *peer) Start() error { if atomic.AddInt32(&p.started, 1) != 1 { return nil } peerLog.Tracef("Peer %v starting", p) // Exchange local and global features, the init message should be very // first between two nodes. if err := p.sendInitMsg(); err != nil { return fmt.Errorf("unable to send init msg: %v...
[ "func", "(", "p", "*", "peer", ")", "Start", "(", ")", "error", "{", "if", "atomic", ".", "AddInt32", "(", "&", "p", ".", "started", ",", "1", ")", "!=", "1", "{", "return", "nil", "\n", "}", "\n\n", "peerLog", ".", "Tracef", "(", "\"", "\"", ...
// Start starts all helper goroutines the peer needs for normal operations. In // the case this peer has already been started, then this function is a loop.
[ "Start", "starts", "all", "helper", "goroutines", "the", "peer", "needs", "for", "normal", "operations", ".", "In", "the", "case", "this", "peer", "has", "already", "been", "started", "then", "this", "function", "is", "a", "loop", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L292-L381
129,408
lightningnetwork/lnd
peer.go
initGossipSync
func (p *peer) initGossipSync() { switch { // If the remote peer knows of the new gossip queries feature, then // we'll create a new gossipSyncer in the AuthenticatedGossiper for it. case p.remoteLocalFeatures.HasFeature(lnwire.GossipQueriesOptional): srvrLog.Infof("Negotiated chan series queries with %x", p....
go
func (p *peer) initGossipSync() { switch { // If the remote peer knows of the new gossip queries feature, then // we'll create a new gossipSyncer in the AuthenticatedGossiper for it. case p.remoteLocalFeatures.HasFeature(lnwire.GossipQueriesOptional): srvrLog.Infof("Negotiated chan series queries with %x", p....
[ "func", "(", "p", "*", "peer", ")", "initGossipSync", "(", ")", "{", "switch", "{", "// If the remote peer knows of the new gossip queries feature, then", "// we'll create a new gossipSyncer in the AuthenticatedGossiper for it.", "case", "p", ".", "remoteLocalFeatures", ".", "H...
// initGossipSync initializes either a gossip syncer or an initial routing // dump, depending on the negotiated synchronization method.
[ "initGossipSync", "initializes", "either", "a", "gossip", "syncer", "or", "an", "initial", "routing", "dump", "depending", "on", "the", "negotiated", "synchronization", "method", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L385-L415
129,409
lightningnetwork/lnd
peer.go
loadActiveChannels
func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) error { for _, dbChan := range chans { lnChan, err := lnwallet.NewLightningChannel( p.server.cc.signer, p.server.witnessBeacon, dbChan, p.server.sigPool, ) if err != nil { return err } chanPoint := &dbChan.FundingOutpoint chanID :...
go
func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) error { for _, dbChan := range chans { lnChan, err := lnwallet.NewLightningChannel( p.server.cc.signer, p.server.witnessBeacon, dbChan, p.server.sigPool, ) if err != nil { return err } chanPoint := &dbChan.FundingOutpoint chanID :...
[ "func", "(", "p", "*", "peer", ")", "loadActiveChannels", "(", "chans", "[", "]", "*", "channeldb", ".", "OpenChannel", ")", "error", "{", "for", "_", ",", "dbChan", ":=", "range", "chans", "{", "lnChan", ",", "err", ":=", "lnwallet", ".", "NewLightnin...
// loadActiveChannels creates indexes within the peer for tracking all active // channels returned by the database.
[ "loadActiveChannels", "creates", "indexes", "within", "the", "peer", "for", "tracking", "all", "active", "channels", "returned", "by", "the", "database", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L429-L545
129,410
lightningnetwork/lnd
peer.go
addLink
func (p *peer) addLink(chanPoint *wire.OutPoint, lnChan *lnwallet.LightningChannel, forwardingPolicy *htlcswitch.ForwardingPolicy, chainEvents *contractcourt.ChainEventSubscription, currentHeight int32, syncStates bool) error { // onChannelFailure will be called by the link in case the channel // fails for some ...
go
func (p *peer) addLink(chanPoint *wire.OutPoint, lnChan *lnwallet.LightningChannel, forwardingPolicy *htlcswitch.ForwardingPolicy, chainEvents *contractcourt.ChainEventSubscription, currentHeight int32, syncStates bool) error { // onChannelFailure will be called by the link in case the channel // fails for some ...
[ "func", "(", "p", "*", "peer", ")", "addLink", "(", "chanPoint", "*", "wire", ".", "OutPoint", ",", "lnChan", "*", "lnwallet", ".", "LightningChannel", ",", "forwardingPolicy", "*", "htlcswitch", ".", "ForwardingPolicy", ",", "chainEvents", "*", "contractcourt...
// addLink creates and adds a new link from the specified channel.
[ "addLink", "creates", "and", "adds", "a", "new", "link", "from", "the", "specified", "channel", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L548-L618
129,411
lightningnetwork/lnd
peer.go
WaitForDisconnect
func (p *peer) WaitForDisconnect(ready chan struct{}) { select { case <-ready: case <-p.quit: } p.wg.Wait() }
go
func (p *peer) WaitForDisconnect(ready chan struct{}) { select { case <-ready: case <-p.quit: } p.wg.Wait() }
[ "func", "(", "p", "*", "peer", ")", "WaitForDisconnect", "(", "ready", "chan", "struct", "{", "}", ")", "{", "select", "{", "case", "<-", "ready", ":", "case", "<-", "p", ".", "quit", ":", "}", "\n\n", "p", ".", "wg", ".", "Wait", "(", ")", "\n...
// WaitForDisconnect waits until the peer has disconnected. A peer may be // disconnected if the local or remote side terminating the connection, or an // irrecoverable protocol error has been encountered. This method will only // begin watching the peer's waitgroup after the ready channel or the peer's // quit channel...
[ "WaitForDisconnect", "waits", "until", "the", "peer", "has", "disconnected", ".", "A", "peer", "may", "be", "disconnected", "if", "the", "local", "or", "remote", "side", "terminating", "the", "connection", "or", "an", "irrecoverable", "protocol", "error", "has",...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L628-L635
129,412
lightningnetwork/lnd
peer.go
Disconnect
func (p *peer) Disconnect(reason error) { if !atomic.CompareAndSwapInt32(&p.disconnect, 0, 1) { return } peerLog.Infof("Disconnecting %s, reason: %v", p, reason) // Ensure that the TCP connection is properly closed before continuing. p.conn.Close() close(p.quit) }
go
func (p *peer) Disconnect(reason error) { if !atomic.CompareAndSwapInt32(&p.disconnect, 0, 1) { return } peerLog.Infof("Disconnecting %s, reason: %v", p, reason) // Ensure that the TCP connection is properly closed before continuing. p.conn.Close() close(p.quit) }
[ "func", "(", "p", "*", "peer", ")", "Disconnect", "(", "reason", "error", ")", "{", "if", "!", "atomic", ".", "CompareAndSwapInt32", "(", "&", "p", ".", "disconnect", ",", "0", ",", "1", ")", "{", "return", "\n", "}", "\n\n", "peerLog", ".", "Infof...
// Disconnect terminates the connection with the remote peer. Additionally, a // signal is sent to the server and htlcSwitch indicating the resources // allocated to the peer can now be cleaned up.
[ "Disconnect", "terminates", "the", "connection", "with", "the", "remote", "peer", ".", "Additionally", "a", "signal", "is", "sent", "to", "the", "server", "and", "htlcSwitch", "indicating", "the", "resources", "allocated", "to", "the", "peer", "can", "now", "b...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L640-L651
129,413
lightningnetwork/lnd
peer.go
String
func (p *peer) String() string { return fmt.Sprintf("%x@%s", p.pubKeyBytes, p.conn.RemoteAddr()) }
go
func (p *peer) String() string { return fmt.Sprintf("%x@%s", p.pubKeyBytes, p.conn.RemoteAddr()) }
[ "func", "(", "p", "*", "peer", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "p", ".", "pubKeyBytes", ",", "p", ".", "conn", ".", "RemoteAddr", "(", ")", ")", "\n", "}" ]
// String returns the string representation of this peer.
[ "String", "returns", "the", "string", "representation", "of", "this", "peer", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L654-L656
129,414
lightningnetwork/lnd
peer.go
readNextMessage
func (p *peer) readNextMessage() (lnwire.Message, error) { noiseConn, ok := p.conn.(*brontide.Conn) if !ok { return nil, fmt.Errorf("brontide.Conn required to read messages") } err := noiseConn.SetReadDeadline(time.Time{}) if err != nil { return nil, err } pktLen, err := noiseConn.ReadNextHeader() if err ...
go
func (p *peer) readNextMessage() (lnwire.Message, error) { noiseConn, ok := p.conn.(*brontide.Conn) if !ok { return nil, fmt.Errorf("brontide.Conn required to read messages") } err := noiseConn.SetReadDeadline(time.Time{}) if err != nil { return nil, err } pktLen, err := noiseConn.ReadNextHeader() if err ...
[ "func", "(", "p", "*", "peer", ")", "readNextMessage", "(", ")", "(", "lnwire", ".", "Message", ",", "error", ")", "{", "noiseConn", ",", "ok", ":=", "p", ".", "conn", ".", "(", "*", "brontide", ".", "Conn", ")", "\n", "if", "!", "ok", "{", "re...
// readNextMessage reads, and returns the next message on the wire along with // any additional raw payload.
[ "readNextMessage", "reads", "and", "returns", "the", "next", "message", "on", "the", "wire", "along", "with", "any", "additional", "raw", "payload", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L660-L713
129,415
lightningnetwork/lnd
peer.go
newMsgStream
func newMsgStream(p *peer, startMsg, stopMsg string, bufSize uint32, apply func(lnwire.Message)) *msgStream { stream := &msgStream{ peer: p, apply: apply, startMsg: startMsg, stopMsg: stopMsg, producerSema: make(chan struct{}, bufSize), quit: make(chan struct{}), } strea...
go
func newMsgStream(p *peer, startMsg, stopMsg string, bufSize uint32, apply func(lnwire.Message)) *msgStream { stream := &msgStream{ peer: p, apply: apply, startMsg: startMsg, stopMsg: stopMsg, producerSema: make(chan struct{}, bufSize), quit: make(chan struct{}), } strea...
[ "func", "newMsgStream", "(", "p", "*", "peer", ",", "startMsg", ",", "stopMsg", "string", ",", "bufSize", "uint32", ",", "apply", "func", "(", "lnwire", ".", "Message", ")", ")", "*", "msgStream", "{", "stream", ":=", "&", "msgStream", "{", "peer", ":"...
// newMsgStream creates a new instance of a chanMsgStream for a particular // channel identified by its channel ID. bufSize is the max number of messages // that should be buffered in the internal queue. Callers should set this to a // sane value that avoids blocking unnecessarily, but doesn't allow an // unbounded amo...
[ "newMsgStream", "creates", "a", "new", "instance", "of", "a", "chanMsgStream", "for", "a", "particular", "channel", "identified", "by", "its", "channel", "ID", ".", "bufSize", "is", "the", "max", "number", "of", "messages", "that", "should", "be", "buffered", ...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L747-L769
129,416
lightningnetwork/lnd
peer.go
Stop
func (ms *msgStream) Stop() { // TODO(roasbeef): signal too? close(ms.quit) // Now that we've closed the channel, we'll repeatedly signal the msg // consumer until we've detected that it has exited. for atomic.LoadInt32(&ms.streamShutdown) == 0 { ms.msgCond.Signal() time.Sleep(time.Millisecond * 100) } ms...
go
func (ms *msgStream) Stop() { // TODO(roasbeef): signal too? close(ms.quit) // Now that we've closed the channel, we'll repeatedly signal the msg // consumer until we've detected that it has exited. for atomic.LoadInt32(&ms.streamShutdown) == 0 { ms.msgCond.Signal() time.Sleep(time.Millisecond * 100) } ms...
[ "func", "(", "ms", "*", "msgStream", ")", "Stop", "(", ")", "{", "// TODO(roasbeef): signal too?", "close", "(", "ms", ".", "quit", ")", "\n\n", "// Now that we've closed the channel, we'll repeatedly signal the msg", "// consumer until we've detected that it has exited.", "f...
// Stop stops the chanMsgStream.
[ "Stop", "stops", "the", "chanMsgStream", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L778-L791
129,417
lightningnetwork/lnd
peer.go
msgConsumer
func (ms *msgStream) msgConsumer() { defer ms.wg.Done() defer peerLog.Tracef(ms.stopMsg) defer atomic.StoreInt32(&ms.streamShutdown, 1) peerLog.Tracef(ms.startMsg) for { // First, we'll check our condition. If the queue of messages // is empty, then we'll wait until a new item is added. ms.msgCond.L.Lock()...
go
func (ms *msgStream) msgConsumer() { defer ms.wg.Done() defer peerLog.Tracef(ms.stopMsg) defer atomic.StoreInt32(&ms.streamShutdown, 1) peerLog.Tracef(ms.startMsg) for { // First, we'll check our condition. If the queue of messages // is empty, then we'll wait until a new item is added. ms.msgCond.L.Lock()...
[ "func", "(", "ms", "*", "msgStream", ")", "msgConsumer", "(", ")", "{", "defer", "ms", ".", "wg", ".", "Done", "(", ")", "\n", "defer", "peerLog", ".", "Tracef", "(", "ms", ".", "stopMsg", ")", "\n", "defer", "atomic", ".", "StoreInt32", "(", "&", ...
// msgConsumer is the main goroutine that streams messages from the peer's // readHandler directly to the target channel.
[ "msgConsumer", "is", "the", "main", "goroutine", "that", "streams", "messages", "from", "the", "peer", "s", "readHandler", "directly", "to", "the", "target", "channel", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L795-L846
129,418
lightningnetwork/lnd
peer.go
AddMsg
func (ms *msgStream) AddMsg(msg lnwire.Message) { // First, we'll attempt to receive from the producerSema struct. This // acts as a sempahore to prevent us from indefinitely buffering // incoming items from the wire. Either the msg queue isn't full, and // we'll not block, or the queue is full, and we'll block unt...
go
func (ms *msgStream) AddMsg(msg lnwire.Message) { // First, we'll attempt to receive from the producerSema struct. This // acts as a sempahore to prevent us from indefinitely buffering // incoming items from the wire. Either the msg queue isn't full, and // we'll not block, or the queue is full, and we'll block unt...
[ "func", "(", "ms", "*", "msgStream", ")", "AddMsg", "(", "msg", "lnwire", ".", "Message", ")", "{", "// First, we'll attempt to receive from the producerSema struct. This", "// acts as a sempahore to prevent us from indefinitely buffering", "// incoming items from the wire. Either th...
// AddMsg adds a new message to the msgStream. This function is safe for // concurrent access.
[ "AddMsg", "adds", "a", "new", "message", "to", "the", "msgStream", ".", "This", "function", "is", "safe", "for", "concurrent", "access", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L850-L873
129,419
lightningnetwork/lnd
peer.go
newChanMsgStream
func newChanMsgStream(p *peer, cid lnwire.ChannelID) *msgStream { var chanLink htlcswitch.ChannelLink return newMsgStream(p, fmt.Sprintf("Update stream for ChannelID(%x) created", cid[:]), fmt.Sprintf("Update stream for ChannelID(%x) exiting", cid[:]), 1000, func(msg lnwire.Message) { _, isChanSyncMsg :=...
go
func newChanMsgStream(p *peer, cid lnwire.ChannelID) *msgStream { var chanLink htlcswitch.ChannelLink return newMsgStream(p, fmt.Sprintf("Update stream for ChannelID(%x) created", cid[:]), fmt.Sprintf("Update stream for ChannelID(%x) exiting", cid[:]), 1000, func(msg lnwire.Message) { _, isChanSyncMsg :=...
[ "func", "newChanMsgStream", "(", "p", "*", "peer", ",", "cid", "lnwire", ".", "ChannelID", ")", "*", "msgStream", "{", "var", "chanLink", "htlcswitch", ".", "ChannelLink", "\n\n", "return", "newMsgStream", "(", "p", ",", "fmt", ".", "Sprintf", "(", "\"", ...
// newChanMsgStream is used to create a msgStream between the peer and // particular channel link in the htlcswitch. We utilize additional // synchronization with the fundingManager to ensure we don't attempt to // dispatch a message to a channel before it is fully active. A reference to the // channel this stream for...
[ "newChanMsgStream", "is", "used", "to", "create", "a", "msgStream", "between", "the", "peer", "and", "particular", "channel", "link", "in", "the", "htlcswitch", ".", "We", "utilize", "additional", "synchronization", "with", "the", "fundingManager", "to", "ensure",...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L881-L975
129,420
lightningnetwork/lnd
peer.go
newDiscMsgStream
func newDiscMsgStream(p *peer) *msgStream { return newMsgStream(p, "Update stream for gossiper created", "Update stream for gossiper exited", 1000, func(msg lnwire.Message) { p.server.authGossiper.ProcessRemoteAnnouncement(msg, p) }, ) }
go
func newDiscMsgStream(p *peer) *msgStream { return newMsgStream(p, "Update stream for gossiper created", "Update stream for gossiper exited", 1000, func(msg lnwire.Message) { p.server.authGossiper.ProcessRemoteAnnouncement(msg, p) }, ) }
[ "func", "newDiscMsgStream", "(", "p", "*", "peer", ")", "*", "msgStream", "{", "return", "newMsgStream", "(", "p", ",", "\"", "\"", ",", "\"", "\"", ",", "1000", ",", "func", "(", "msg", "lnwire", ".", "Message", ")", "{", "p", ".", "server", ".", ...
// newDiscMsgStream is used to setup a msgStream between the peer and the // authenticated gossiper. This stream should be used to forward all remote // channel announcements.
[ "newDiscMsgStream", "is", "used", "to", "setup", "a", "msgStream", "between", "the", "peer", "and", "the", "authenticated", "gossiper", ".", "This", "stream", "should", "be", "used", "to", "forward", "all", "remote", "channel", "announcements", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L980-L989
129,421
lightningnetwork/lnd
peer.go
logWireMessage
func (p *peer) logWireMessage(msg lnwire.Message, read bool) { summaryPrefix := "Received" if !read { summaryPrefix = "Sending" } peerLog.Debugf("%v", newLogClosure(func() string { // Debug summary of message. summary := messageSummary(msg) if len(summary) > 0 { summary = "(" + summary + ")" } prep...
go
func (p *peer) logWireMessage(msg lnwire.Message, read bool) { summaryPrefix := "Received" if !read { summaryPrefix = "Sending" } peerLog.Debugf("%v", newLogClosure(func() string { // Debug summary of message. summary := messageSummary(msg) if len(summary) > 0 { summary = "(" + summary + ")" } prep...
[ "func", "(", "p", "*", "peer", ")", "logWireMessage", "(", "msg", "lnwire", ".", "Message", ",", "read", "bool", ")", "{", "summaryPrefix", ":=", "\"", "\"", "\n", "if", "!", "read", "{", "summaryPrefix", "=", "\"", "\"", "\n", "}", "\n\n", "peerLog"...
// logWireMessage logs the receipt or sending of particular wire message. This // function is used rather than just logging the message in order to produce // less spammy log messages in trace mode by setting the 'Curve" parameter to // nil. Doing this avoids printing out each of the field elements in the curve // para...
[ "logWireMessage", "logs", "the", "receipt", "or", "sending", "of", "particular", "wire", "message", ".", "This", "function", "is", "used", "rather", "than", "just", "logging", "the", "message", "in", "order", "to", "produce", "less", "spammy", "log", "messages...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L1346-L1401
129,422
lightningnetwork/lnd
peer.go
writeMessage
func (p *peer) writeMessage(msg lnwire.Message) error { // Simply exit if we're shutting down. if atomic.LoadInt32(&p.disconnect) != 0 { return lnpeer.ErrPeerExiting } // Only log the message on the first attempt. if msg != nil { p.logWireMessage(msg, false) } noiseConn, ok := p.conn.(*brontide.Conn) if !...
go
func (p *peer) writeMessage(msg lnwire.Message) error { // Simply exit if we're shutting down. if atomic.LoadInt32(&p.disconnect) != 0 { return lnpeer.ErrPeerExiting } // Only log the message on the first attempt. if msg != nil { p.logWireMessage(msg, false) } noiseConn, ok := p.conn.(*brontide.Conn) if !...
[ "func", "(", "p", "*", "peer", ")", "writeMessage", "(", "msg", "lnwire", ".", "Message", ")", "error", "{", "// Simply exit if we're shutting down.", "if", "atomic", ".", "LoadInt32", "(", "&", "p", ".", "disconnect", ")", "!=", "0", "{", "return", "lnpee...
// writeMessage writes and flushes the target lnwire.Message to the remote peer. // If the passed message is nil, this method will only try to flush an existing // message buffered on the connection. It is safe to recall this method with a // nil message iff a timeout error is returned. This will continue to flush the ...
[ "writeMessage", "writes", "and", "flushes", "the", "target", "lnwire", ".", "Message", "to", "the", "remote", "peer", ".", "If", "the", "passed", "message", "is", "nil", "this", "method", "will", "only", "try", "to", "flush", "an", "existing", "message", "...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L1408-L1474
129,423
lightningnetwork/lnd
peer.go
queueMsg
func (p *peer) queueMsg(msg lnwire.Message, errChan chan error) { p.queue(true, msg, errChan) }
go
func (p *peer) queueMsg(msg lnwire.Message, errChan chan error) { p.queue(true, msg, errChan) }
[ "func", "(", "p", "*", "peer", ")", "queueMsg", "(", "msg", "lnwire", ".", "Message", ",", "errChan", "chan", "error", ")", "{", "p", ".", "queue", "(", "true", ",", "msg", ",", "errChan", ")", "\n", "}" ]
// queueMsg adds the lnwire.Message to the back of the high priority send queue. // If the errChan is non-nil, an error is sent back if the msg failed to queue // or failed to write, and nil otherwise.
[ "queueMsg", "adds", "the", "lnwire", ".", "Message", "to", "the", "back", "of", "the", "high", "priority", "send", "queue", ".", "If", "the", "errChan", "is", "non", "-", "nil", "an", "error", "is", "sent", "back", "if", "the", "msg", "failed", "to", ...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L1671-L1673
129,424
lightningnetwork/lnd
peer.go
queueMsgLazy
func (p *peer) queueMsgLazy(msg lnwire.Message, errChan chan error) { p.queue(false, msg, errChan) }
go
func (p *peer) queueMsgLazy(msg lnwire.Message, errChan chan error) { p.queue(false, msg, errChan) }
[ "func", "(", "p", "*", "peer", ")", "queueMsgLazy", "(", "msg", "lnwire", ".", "Message", ",", "errChan", "chan", "error", ")", "{", "p", ".", "queue", "(", "false", ",", "msg", ",", "errChan", ")", "\n", "}" ]
// queueMsgLazy adds the lnwire.Message to the back of the low priority send // queue. If the errChan is non-nil, an error is sent back if the msg failed to // queue or failed to write, and nil otherwise.
[ "queueMsgLazy", "adds", "the", "lnwire", ".", "Message", "to", "the", "back", "of", "the", "low", "priority", "send", "queue", ".", "If", "the", "errChan", "is", "non", "-", "nil", "an", "error", "is", "sent", "back", "if", "the", "msg", "failed", "to"...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L1678-L1680
129,425
lightningnetwork/lnd
peer.go
queue
func (p *peer) queue(priority bool, msg lnwire.Message, errChan chan error) { select { case p.outgoingQueue <- outgoingMsg{priority, msg, errChan}: case <-p.quit: peerLog.Tracef("Peer shutting down, could not enqueue msg.") if errChan != nil { errChan <- lnpeer.ErrPeerExiting } } }
go
func (p *peer) queue(priority bool, msg lnwire.Message, errChan chan error) { select { case p.outgoingQueue <- outgoingMsg{priority, msg, errChan}: case <-p.quit: peerLog.Tracef("Peer shutting down, could not enqueue msg.") if errChan != nil { errChan <- lnpeer.ErrPeerExiting } } }
[ "func", "(", "p", "*", "peer", ")", "queue", "(", "priority", "bool", ",", "msg", "lnwire", ".", "Message", ",", "errChan", "chan", "error", ")", "{", "select", "{", "case", "p", ".", "outgoingQueue", "<-", "outgoingMsg", "{", "priority", ",", "msg", ...
// queue sends a given message to the queueHandler using the passed priority. If // the errChan is non-nil, an error is sent back if the msg failed to queue or // failed to write, and nil otherwise.
[ "queue", "sends", "a", "given", "message", "to", "the", "queueHandler", "using", "the", "passed", "priority", ".", "If", "the", "errChan", "is", "non", "-", "nil", "an", "error", "is", "sent", "back", "if", "the", "msg", "failed", "to", "queue", "or", ...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L1685-L1694
129,426
lightningnetwork/lnd
peer.go
ChannelSnapshots
func (p *peer) ChannelSnapshots() []*channeldb.ChannelSnapshot { p.activeChanMtx.RLock() defer p.activeChanMtx.RUnlock() snapshots := make([]*channeldb.ChannelSnapshot, 0, len(p.activeChannels)) for _, activeChan := range p.activeChannels { // We'll only return a snapshot for channels that are // *immedately* ...
go
func (p *peer) ChannelSnapshots() []*channeldb.ChannelSnapshot { p.activeChanMtx.RLock() defer p.activeChanMtx.RUnlock() snapshots := make([]*channeldb.ChannelSnapshot, 0, len(p.activeChannels)) for _, activeChan := range p.activeChannels { // We'll only return a snapshot for channels that are // *immedately* ...
[ "func", "(", "p", "*", "peer", ")", "ChannelSnapshots", "(", ")", "[", "]", "*", "channeldb", ".", "ChannelSnapshot", "{", "p", ".", "activeChanMtx", ".", "RLock", "(", ")", "\n", "defer", "p", ".", "activeChanMtx", ".", "RUnlock", "(", ")", "\n\n", ...
// ChannelSnapshots returns a slice of channel snapshots detailing all // currently active channels maintained with the remote peer.
[ "ChannelSnapshots", "returns", "a", "slice", "of", "channel", "snapshots", "detailing", "all", "currently", "active", "channels", "maintained", "with", "the", "remote", "peer", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L1698-L1715
129,427
lightningnetwork/lnd
peer.go
genDeliveryScript
func (p *peer) genDeliveryScript() ([]byte, error) { deliveryAddr, err := p.server.cc.wallet.NewAddress( lnwallet.WitnessPubKey, false, ) if err != nil { return nil, err } peerLog.Infof("Delivery addr for channel close: %v", deliveryAddr) return txscript.PayToAddrScript(deliveryAddr) }
go
func (p *peer) genDeliveryScript() ([]byte, error) { deliveryAddr, err := p.server.cc.wallet.NewAddress( lnwallet.WitnessPubKey, false, ) if err != nil { return nil, err } peerLog.Infof("Delivery addr for channel close: %v", deliveryAddr) return txscript.PayToAddrScript(deliveryAddr) }
[ "func", "(", "p", "*", "peer", ")", "genDeliveryScript", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "deliveryAddr", ",", "err", ":=", "p", ".", "server", ".", "cc", ".", "wallet", ".", "NewAddress", "(", "lnwallet", ".", "WitnessPubKey"...
// genDeliveryScript returns a new script to be used to send our funds to in // the case of a cooperative channel close negotiation.
[ "genDeliveryScript", "returns", "a", "new", "script", "to", "be", "used", "to", "send", "our", "funds", "to", "in", "the", "case", "of", "a", "cooperative", "channel", "close", "negotiation", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L1719-L1730
129,428
lightningnetwork/lnd
peer.go
reenableActiveChannels
func (p *peer) reenableActiveChannels() { // First, filter all known channels with this peer for ones that are // both public and not pending. var activePublicChans []wire.OutPoint p.activeChanMtx.RLock() for chanID, lnChan := range p.activeChannels { dbChan := lnChan.State() isPublic := dbChan.ChannelFlags&ln...
go
func (p *peer) reenableActiveChannels() { // First, filter all known channels with this peer for ones that are // both public and not pending. var activePublicChans []wire.OutPoint p.activeChanMtx.RLock() for chanID, lnChan := range p.activeChannels { dbChan := lnChan.State() isPublic := dbChan.ChannelFlags&ln...
[ "func", "(", "p", "*", "peer", ")", "reenableActiveChannels", "(", ")", "{", "// First, filter all known channels with this peer for ones that are", "// both public and not pending.", "var", "activePublicChans", "[", "]", "wire", ".", "OutPoint", "\n", "p", ".", "activeCh...
// reenableActiveChannels searches the index of channels maintained with this // peer, and reenables each public, non-pending channel. This is done at the // gossip level by broadcasting a new ChannelUpdate with the disabled bit unset. // No message will be sent if the channel is already enabled.
[ "reenableActiveChannels", "searches", "the", "index", "of", "channels", "maintained", "with", "this", "peer", "and", "reenables", "each", "public", "non", "-", "pending", "channel", ".", "This", "is", "done", "at", "the", "gossip", "level", "by", "broadcasting",...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L1988-L2025
129,429
lightningnetwork/lnd
peer.go
fetchActiveChanCloser
func (p *peer) fetchActiveChanCloser(chanID lnwire.ChannelID) (*channelCloser, error) { // First, we'll ensure that we actually know of the target channel. If // not, we'll ignore this message. p.activeChanMtx.RLock() channel, ok := p.activeChannels[chanID] p.activeChanMtx.RUnlock() if !ok { return nil, ErrChan...
go
func (p *peer) fetchActiveChanCloser(chanID lnwire.ChannelID) (*channelCloser, error) { // First, we'll ensure that we actually know of the target channel. If // not, we'll ignore this message. p.activeChanMtx.RLock() channel, ok := p.activeChannels[chanID] p.activeChanMtx.RUnlock() if !ok { return nil, ErrChan...
[ "func", "(", "p", "*", "peer", ")", "fetchActiveChanCloser", "(", "chanID", "lnwire", ".", "ChannelID", ")", "(", "*", "channelCloser", ",", "error", ")", "{", "// First, we'll ensure that we actually know of the target channel. If", "// not, we'll ignore this message.", ...
// fetchActiveChanCloser attempts to fetch the active chan closer state machine // for the target channel ID. If the channel isn't active an error is returned. // Otherwise, either an existing state machine will be returned, or a new one // will be created.
[ "fetchActiveChanCloser", "attempts", "to", "fetch", "the", "active", "chan", "closer", "state", "machine", "for", "the", "target", "channel", "ID", ".", "If", "the", "channel", "isn", "t", "active", "an", "error", "is", "returned", ".", "Otherwise", "either", ...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L2031-L2096
129,430
lightningnetwork/lnd
peer.go
handleLocalCloseReq
func (p *peer) handleLocalCloseReq(req *htlcswitch.ChanClose) { chanID := lnwire.NewChanIDFromOutPoint(req.ChanPoint) p.activeChanMtx.RLock() channel, ok := p.activeChannels[chanID] p.activeChanMtx.RUnlock() if !ok { err := fmt.Errorf("unable to close channel, ChannelID(%v) is "+ "unknown", chanID) peerLog...
go
func (p *peer) handleLocalCloseReq(req *htlcswitch.ChanClose) { chanID := lnwire.NewChanIDFromOutPoint(req.ChanPoint) p.activeChanMtx.RLock() channel, ok := p.activeChannels[chanID] p.activeChanMtx.RUnlock() if !ok { err := fmt.Errorf("unable to close channel, ChannelID(%v) is "+ "unknown", chanID) peerLog...
[ "func", "(", "p", "*", "peer", ")", "handleLocalCloseReq", "(", "req", "*", "htlcswitch", ".", "ChanClose", ")", "{", "chanID", ":=", "lnwire", ".", "NewChanIDFromOutPoint", "(", "req", ".", "ChanPoint", ")", "\n\n", "p", ".", "activeChanMtx", ".", "RLock"...
// handleLocalCloseReq kicks-off the workflow to execute a cooperative or // forced unilateral closure of the channel initiated by a local subsystem.
[ "handleLocalCloseReq", "kicks", "-", "off", "the", "workflow", "to", "execute", "a", "cooperative", "or", "forced", "unilateral", "closure", "of", "the", "channel", "initiated", "by", "a", "local", "subsystem", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L2100-L2185
129,431
lightningnetwork/lnd
peer.go
handleLinkFailure
func (p *peer) handleLinkFailure(failure linkFailureReport) { // We begin by wiping the link, which will remove it from the switch, // such that it won't be attempted used for any more updates. // // TODO(halseth): should introduce a way to atomically stop/pause the // link and cancel back any adds in its mailboxe...
go
func (p *peer) handleLinkFailure(failure linkFailureReport) { // We begin by wiping the link, which will remove it from the switch, // such that it won't be attempted used for any more updates. // // TODO(halseth): should introduce a way to atomically stop/pause the // link and cancel back any adds in its mailboxe...
[ "func", "(", "p", "*", "peer", ")", "handleLinkFailure", "(", "failure", "linkFailureReport", ")", "{", "// We begin by wiping the link, which will remove it from the switch,", "// such that it won't be attempted used for any more updates.", "//", "// TODO(halseth): should introduce a ...
// handleLinkFailure processes a link failure report when a link in the switch // fails. It handles facilitates removal of all channel state within the peer, // force closing the channel depending on severity, and sending the error // message back to the remote party.
[ "handleLinkFailure", "processes", "a", "link", "failure", "report", "when", "a", "link", "in", "the", "switch", "fails", ".", "It", "handles", "facilitates", "removal", "of", "all", "channel", "state", "within", "the", "peer", "force", "closing", "the", "chann...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L2202-L2254
129,432
lightningnetwork/lnd
peer.go
finalizeChanClosure
func (p *peer) finalizeChanClosure(chanCloser *channelCloser) { closeReq := chanCloser.CloseRequest() // First, we'll clear all indexes related to the channel in question. chanPoint := chanCloser.cfg.channel.ChannelPoint() if err := p.WipeChannel(chanPoint); err != nil { if closeReq != nil { closeReq.Err <- e...
go
func (p *peer) finalizeChanClosure(chanCloser *channelCloser) { closeReq := chanCloser.CloseRequest() // First, we'll clear all indexes related to the channel in question. chanPoint := chanCloser.cfg.channel.ChannelPoint() if err := p.WipeChannel(chanPoint); err != nil { if closeReq != nil { closeReq.Err <- e...
[ "func", "(", "p", "*", "peer", ")", "finalizeChanClosure", "(", "chanCloser", "*", "channelCloser", ")", "{", "closeReq", ":=", "chanCloser", ".", "CloseRequest", "(", ")", "\n\n", "// First, we'll clear all indexes related to the channel in question.", "chanPoint", ":=...
// finalizeChanClosure performs the final clean up steps once the cooperative // closure transaction has been fully broadcast. The finalized closing state // machine should be passed in. Once the transaction has been sufficiently // confirmed, the channel will be marked as fully closed within the database, // and any c...
[ "finalizeChanClosure", "performs", "the", "final", "clean", "up", "steps", "once", "the", "cooperative", "closure", "transaction", "has", "been", "fully", "broadcast", ".", "The", "finalized", "closing", "state", "machine", "should", "be", "passed", "in", ".", "...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L2261-L2315
129,433
lightningnetwork/lnd
peer.go
WipeChannel
func (p *peer) WipeChannel(chanPoint *wire.OutPoint) error { chanID := lnwire.NewChanIDFromOutPoint(chanPoint) p.activeChanMtx.Lock() delete(p.activeChannels, chanID) p.activeChanMtx.Unlock() // Instruct the HtlcSwitch to close this link as the channel is no // longer active. p.server.htlcSwitch.RemoveLink(cha...
go
func (p *peer) WipeChannel(chanPoint *wire.OutPoint) error { chanID := lnwire.NewChanIDFromOutPoint(chanPoint) p.activeChanMtx.Lock() delete(p.activeChannels, chanID) p.activeChanMtx.Unlock() // Instruct the HtlcSwitch to close this link as the channel is no // longer active. p.server.htlcSwitch.RemoveLink(cha...
[ "func", "(", "p", "*", "peer", ")", "WipeChannel", "(", "chanPoint", "*", "wire", ".", "OutPoint", ")", "error", "{", "chanID", ":=", "lnwire", ".", "NewChanIDFromOutPoint", "(", "chanPoint", ")", "\n\n", "p", ".", "activeChanMtx", ".", "Lock", "(", ")",...
// WipeChannel removes the passed channel point from all indexes associated with // the peer, and the switch.
[ "WipeChannel", "removes", "the", "passed", "channel", "point", "from", "all", "indexes", "associated", "with", "the", "peer", "and", "the", "switch", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L2360-L2372
129,434
lightningnetwork/lnd
peer.go
handleInitMsg
func (p *peer) handleInitMsg(msg *lnwire.Init) error { p.remoteLocalFeatures = lnwire.NewFeatureVector( msg.LocalFeatures, lnwire.LocalFeatures, ) p.remoteGlobalFeatures = lnwire.NewFeatureVector( msg.GlobalFeatures, lnwire.GlobalFeatures, ) // Now that we have their features loaded, we'll ensure that they /...
go
func (p *peer) handleInitMsg(msg *lnwire.Init) error { p.remoteLocalFeatures = lnwire.NewFeatureVector( msg.LocalFeatures, lnwire.LocalFeatures, ) p.remoteGlobalFeatures = lnwire.NewFeatureVector( msg.GlobalFeatures, lnwire.GlobalFeatures, ) // Now that we have their features loaded, we'll ensure that they /...
[ "func", "(", "p", "*", "peer", ")", "handleInitMsg", "(", "msg", "*", "lnwire", ".", "Init", ")", "error", "{", "p", ".", "remoteLocalFeatures", "=", "lnwire", ".", "NewFeatureVector", "(", "msg", ".", "LocalFeatures", ",", "lnwire", ".", "LocalFeatures", ...
// handleInitMsg handles the incoming init message which contains global and // local features vectors. If feature vectors are incompatible then disconnect.
[ "handleInitMsg", "handles", "the", "incoming", "init", "message", "which", "contains", "global", "and", "local", "features", "vectors", ".", "If", "feature", "vectors", "are", "incompatible", "then", "disconnect", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L2376-L2407
129,435
lightningnetwork/lnd
peer.go
sendInitMsg
func (p *peer) sendInitMsg() error { msg := lnwire.NewInitMessage( p.server.globalFeatures.RawFeatureVector, p.localFeatures, ) return p.writeMessage(msg) }
go
func (p *peer) sendInitMsg() error { msg := lnwire.NewInitMessage( p.server.globalFeatures.RawFeatureVector, p.localFeatures, ) return p.writeMessage(msg) }
[ "func", "(", "p", "*", "peer", ")", "sendInitMsg", "(", ")", "error", "{", "msg", ":=", "lnwire", ".", "NewInitMessage", "(", "p", ".", "server", ".", "globalFeatures", ".", "RawFeatureVector", ",", "p", ".", "localFeatures", ",", ")", "\n\n", "return", ...
// sendInitMsg sends init message to remote peer which contains our currently // supported local and global features.
[ "sendInitMsg", "sends", "init", "message", "to", "remote", "peer", "which", "contains", "our", "currently", "supported", "local", "and", "global", "features", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L2411-L2418
129,436
lightningnetwork/lnd
peer.go
resendChanSyncMsg
func (p *peer) resendChanSyncMsg(cid lnwire.ChannelID) error { // Check if we have any channel sync messages stored for this channel. c, err := p.server.chanDB.FetchClosedChannelForID(cid) if err != nil { return fmt.Errorf("unable to fetch channel sync messages for "+ "peer %v: %v", p, err) } if c.LastChanSy...
go
func (p *peer) resendChanSyncMsg(cid lnwire.ChannelID) error { // Check if we have any channel sync messages stored for this channel. c, err := p.server.chanDB.FetchClosedChannelForID(cid) if err != nil { return fmt.Errorf("unable to fetch channel sync messages for "+ "peer %v: %v", p, err) } if c.LastChanSy...
[ "func", "(", "p", "*", "peer", ")", "resendChanSyncMsg", "(", "cid", "lnwire", ".", "ChannelID", ")", "error", "{", "// Check if we have any channel sync messages stored for this channel.", "c", ",", "err", ":=", "p", ".", "server", ".", "chanDB", ".", "FetchClose...
// resendChanSyncMsg will attempt to find a channel sync message for the closed // channel and resend it to our peer.
[ "resendChanSyncMsg", "will", "attempt", "to", "find", "a", "channel", "sync", "message", "for", "the", "closed", "channel", "and", "resend", "it", "to", "our", "peer", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L2422-L2447
129,437
lightningnetwork/lnd
peer.go
sendMessage
func (p *peer) sendMessage(sync, priority bool, msgs ...lnwire.Message) error { // Add all incoming messages to the outgoing queue. A list of error // chans is populated for each message if the caller requested a sync // send. var errChans []chan error if sync { errChans = make([]chan error, 0, len(msgs)) } fo...
go
func (p *peer) sendMessage(sync, priority bool, msgs ...lnwire.Message) error { // Add all incoming messages to the outgoing queue. A list of error // chans is populated for each message if the caller requested a sync // send. var errChans []chan error if sync { errChans = make([]chan error, 0, len(msgs)) } fo...
[ "func", "(", "p", "*", "peer", ")", "sendMessage", "(", "sync", ",", "priority", "bool", ",", "msgs", "...", "lnwire", ".", "Message", ")", "error", "{", "// Add all incoming messages to the outgoing queue. A list of error", "// chans is populated for each message if the ...
// sendMessage queues a variadic number of messages using the passed priority // to the remote peer. If sync is true, this method will block until the // messages have been sent to the remote peer or an error is returned, otherwise // it returns immediately after queueing.
[ "sendMessage", "queues", "a", "variadic", "number", "of", "messages", "using", "the", "passed", "priority", "to", "the", "remote", "peer", ".", "If", "sync", "is", "true", "this", "method", "will", "block", "until", "the", "messages", "have", "been", "sent",...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/peer.go#L2473-L2509
129,438
lightningnetwork/lnd
tor/tor.go
Dial
func Dial(address, socksAddr string, streamIsolation bool) (net.Conn, error) { conn, err := dial(address, socksAddr, streamIsolation) if err != nil { return nil, err } // Now that the connection is established, we'll create our internal // proxyConn that will serve in populating the correct remote address // o...
go
func Dial(address, socksAddr string, streamIsolation bool) (net.Conn, error) { conn, err := dial(address, socksAddr, streamIsolation) if err != nil { return nil, err } // Now that the connection is established, we'll create our internal // proxyConn that will serve in populating the correct remote address // o...
[ "func", "Dial", "(", "address", ",", "socksAddr", "string", ",", "streamIsolation", "bool", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "conn", ",", "err", ":=", "dial", "(", "address", ",", "socksAddr", ",", "streamIsolation", ")", "\n", "if...
// Dial is a wrapper over the non-exported dial function that returns a wrapper // around net.Conn in order to expose the actual remote address we're dialing, // rather than the proxy's address.
[ "Dial", "is", "a", "wrapper", "over", "the", "non", "-", "exported", "dial", "function", "that", "returns", "a", "wrapper", "around", "net", ".", "Conn", "in", "order", "to", "expose", "the", "actual", "remote", "address", "we", "re", "dialing", "rather", ...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/tor/tor.go#L57-L75
129,439
lightningnetwork/lnd
tor/tor.go
dial
func dial(address, socksAddr string, streamIsolation bool) (net.Conn, error) { // If we were requested to force stream isolation for this connection, // we'll populate the authentication credentials with random data as // Tor will create a new circuit for each set of credentials. var auth *proxy.Auth if streamIsol...
go
func dial(address, socksAddr string, streamIsolation bool) (net.Conn, error) { // If we were requested to force stream isolation for this connection, // we'll populate the authentication credentials with random data as // Tor will create a new circuit for each set of credentials. var auth *proxy.Auth if streamIsol...
[ "func", "dial", "(", "address", ",", "socksAddr", "string", ",", "streamIsolation", "bool", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "// If we were requested to force stream isolation for this connection,", "// we'll populate the authentication credentials with r...
// dial establishes a connection to the address via Tor's SOCKS proxy. Only TCP // is supported over Tor. The final argument determines if we should force // stream isolation for this new connection. If we do, then this means this new // connection will use a fresh circuit, rather than possibly re-using an // existing ...
[ "dial", "establishes", "a", "connection", "to", "the", "address", "via", "Tor", "s", "SOCKS", "proxy", ".", "Only", "TCP", "is", "supported", "over", "Tor", ".", "The", "final", "argument", "determines", "if", "we", "should", "force", "stream", "isolation", ...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/tor/tor.go#L82-L106
129,440
lightningnetwork/lnd
tor/tor.go
LookupHost
func LookupHost(host, socksAddr string) ([]string, error) { ip, err := connmgr.TorLookupIP(host, socksAddr) if err != nil { return nil, err } // Only one IPv4 address is returned by the TorLookupIP function. return []string{ip[0].String()}, nil }
go
func LookupHost(host, socksAddr string) ([]string, error) { ip, err := connmgr.TorLookupIP(host, socksAddr) if err != nil { return nil, err } // Only one IPv4 address is returned by the TorLookupIP function. return []string{ip[0].String()}, nil }
[ "func", "LookupHost", "(", "host", ",", "socksAddr", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "ip", ",", "err", ":=", "connmgr", ".", "TorLookupIP", "(", "host", ",", "socksAddr", ")", "\n", "if", "err", "!=", "nil", "{", "re...
// LookupHost performs DNS resolution on a given host via Tor's native resolver. // Only IPv4 addresses are returned.
[ "LookupHost", "performs", "DNS", "resolution", "on", "a", "given", "host", "via", "Tor", "s", "native", "resolver", ".", "Only", "IPv4", "addresses", "are", "returned", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/tor/tor.go#L110-L118
129,441
lightningnetwork/lnd
tor/tor.go
LookupSRV
func LookupSRV(service, proto, name, socksAddr, dnsServer string, streamIsolation bool) (string, []*net.SRV, error) { // Connect to the DNS server we'll be using to query SRV records. conn, err := dial(dnsServer, socksAddr, streamIsolation) if err != nil { return "", nil, err } dnsConn := &dns.Conn{Conn: conn...
go
func LookupSRV(service, proto, name, socksAddr, dnsServer string, streamIsolation bool) (string, []*net.SRV, error) { // Connect to the DNS server we'll be using to query SRV records. conn, err := dial(dnsServer, socksAddr, streamIsolation) if err != nil { return "", nil, err } dnsConn := &dns.Conn{Conn: conn...
[ "func", "LookupSRV", "(", "service", ",", "proto", ",", "name", ",", "socksAddr", ",", "dnsServer", "string", ",", "streamIsolation", "bool", ")", "(", "string", ",", "[", "]", "*", "net", ".", "SRV", ",", "error", ")", "{", "// Connect to the DNS server w...
// LookupSRV uses Tor's SOCKS proxy to route DNS SRV queries. Tor does not // natively support SRV queries so we must route all SRV queries through the // proxy by connecting directly to a DNS server and querying it. The DNS server // must have TCP resolution enabled for the given port.
[ "LookupSRV", "uses", "Tor", "s", "SOCKS", "proxy", "to", "route", "DNS", "SRV", "queries", ".", "Tor", "does", "not", "natively", "support", "SRV", "queries", "so", "we", "must", "route", "all", "SRV", "queries", "through", "the", "proxy", "by", "connectin...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/tor/tor.go#L124-L169
129,442
lightningnetwork/lnd
tor/tor.go
ResolveTCPAddr
func ResolveTCPAddr(address, socksAddr string) (*net.TCPAddr, error) { // Split host:port since the lookup function does not take a port. host, port, err := net.SplitHostPort(address) if err != nil { return nil, err } ip, err := LookupHost(host, socksAddr) if err != nil { return nil, err } p, err := strco...
go
func ResolveTCPAddr(address, socksAddr string) (*net.TCPAddr, error) { // Split host:port since the lookup function does not take a port. host, port, err := net.SplitHostPort(address) if err != nil { return nil, err } ip, err := LookupHost(host, socksAddr) if err != nil { return nil, err } p, err := strco...
[ "func", "ResolveTCPAddr", "(", "address", ",", "socksAddr", "string", ")", "(", "*", "net", ".", "TCPAddr", ",", "error", ")", "{", "// Split host:port since the lookup function does not take a port.", "host", ",", "port", ",", "err", ":=", "net", ".", "SplitHostP...
// ResolveTCPAddr uses Tor's proxy to resolve TCP addresses instead of the // standard system resolver provided in the `net` package.
[ "ResolveTCPAddr", "uses", "Tor", "s", "proxy", "to", "resolve", "TCP", "addresses", "instead", "of", "the", "standard", "system", "resolver", "provided", "in", "the", "net", "package", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/tor/tor.go#L173-L194
129,443
lightningnetwork/lnd
tor/tor.go
ParseAddr
func ParseAddr(address, socksAddr string) (net.Addr, error) { host, portStr, err := net.SplitHostPort(address) if err != nil { return nil, err } port, err := strconv.Atoi(portStr) if err != nil { return nil, err } if IsOnionHost(host) { return &OnionAddr{OnionService: host, Port: port}, nil } return R...
go
func ParseAddr(address, socksAddr string) (net.Addr, error) { host, portStr, err := net.SplitHostPort(address) if err != nil { return nil, err } port, err := strconv.Atoi(portStr) if err != nil { return nil, err } if IsOnionHost(host) { return &OnionAddr{OnionService: host, Port: port}, nil } return R...
[ "func", "ParseAddr", "(", "address", ",", "socksAddr", "string", ")", "(", "net", ".", "Addr", ",", "error", ")", "{", "host", ",", "portStr", ",", "err", ":=", "net", ".", "SplitHostPort", "(", "address", ")", "\n", "if", "err", "!=", "nil", "{", ...
// ParseAddr parses an address from its string format to a net.Addr.
[ "ParseAddr", "parses", "an", "address", "from", "its", "string", "format", "to", "a", "net", ".", "Addr", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/tor/tor.go#L197-L213
129,444
lightningnetwork/lnd
tor/tor.go
IsOnionHost
func IsOnionHost(host string) bool { // Note the starting index of the onion suffix in the host depending // on its length. var suffixIndex int switch len(host) { case V2Len: suffixIndex = V2Len - OnionSuffixLen case V3Len: suffixIndex = V3Len - OnionSuffixLen default: return false } // Make sure the ho...
go
func IsOnionHost(host string) bool { // Note the starting index of the onion suffix in the host depending // on its length. var suffixIndex int switch len(host) { case V2Len: suffixIndex = V2Len - OnionSuffixLen case V3Len: suffixIndex = V3Len - OnionSuffixLen default: return false } // Make sure the ho...
[ "func", "IsOnionHost", "(", "host", "string", ")", "bool", "{", "// Note the starting index of the onion suffix in the host depending", "// on its length.", "var", "suffixIndex", "int", "\n", "switch", "len", "(", "host", ")", "{", "case", "V2Len", ":", "suffixIndex", ...
// IsOnionHost determines whether a host is part of an onion address.
[ "IsOnionHost", "determines", "whether", "a", "host", "is", "part", "of", "an", "onion", "address", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/tor/tor.go#L216-L243
129,445
lightningnetwork/lnd
routing/chainview/btcd.go
NewBtcdFilteredChainView
func NewBtcdFilteredChainView(config rpcclient.ConnConfig) (*BtcdFilteredChainView, error) { chainView := &BtcdFilteredChainView{ chainFilter: make(map[wire.OutPoint]struct{}), filterUpdates: make(chan filterUpdate), filterBlockReqs: make(chan *filterBlockReq), quit: make(chan struct{}), } ...
go
func NewBtcdFilteredChainView(config rpcclient.ConnConfig) (*BtcdFilteredChainView, error) { chainView := &BtcdFilteredChainView{ chainFilter: make(map[wire.OutPoint]struct{}), filterUpdates: make(chan filterUpdate), filterBlockReqs: make(chan *filterBlockReq), quit: make(chan struct{}), } ...
[ "func", "NewBtcdFilteredChainView", "(", "config", "rpcclient", ".", "ConnConfig", ")", "(", "*", "BtcdFilteredChainView", ",", "error", ")", "{", "chainView", ":=", "&", "BtcdFilteredChainView", "{", "chainFilter", ":", "make", "(", "map", "[", "wire", ".", "...
// NewBtcdFilteredChainView creates a new instance of a FilteredChainView from // RPC credentials for an active btcd instance.
[ "NewBtcdFilteredChainView", "creates", "a", "new", "instance", "of", "a", "FilteredChainView", "from", "RPC", "credentials", "for", "an", "active", "btcd", "instance", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/routing/chainview/btcd.go#L61-L87
129,446
lightningnetwork/lnd
lnwire/msat.go
ToSatoshis
func (m MilliSatoshi) ToSatoshis() btcutil.Amount { return btcutil.Amount(uint64(m) / mSatScale) }
go
func (m MilliSatoshi) ToSatoshis() btcutil.Amount { return btcutil.Amount(uint64(m) / mSatScale) }
[ "func", "(", "m", "MilliSatoshi", ")", "ToSatoshis", "(", ")", "btcutil", ".", "Amount", "{", "return", "btcutil", ".", "Amount", "(", "uint64", "(", "m", ")", "/", "mSatScale", ")", "\n", "}" ]
// ToSatoshis converts the target MilliSatoshi amount to satoshis. Simply, this // sheds a factor of 1000 from the mSAT amount in order to convert it to SAT.
[ "ToSatoshis", "converts", "the", "target", "MilliSatoshi", "amount", "to", "satoshis", ".", "Simply", "this", "sheds", "a", "factor", "of", "1000", "from", "the", "mSAT", "amount", "in", "order", "to", "convert", "it", "to", "SAT", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/msat.go#L36-L38
129,447
lightningnetwork/lnd
tor/controller.go
Start
func (c *Controller) Start() error { if !atomic.CompareAndSwapInt32(&c.started, 0, 1) { return nil } conn, err := textproto.Dial("tcp", c.controlAddr) if err != nil { return fmt.Errorf("unable to connect to Tor server: %v", err) } c.conn = conn return c.authenticate() }
go
func (c *Controller) Start() error { if !atomic.CompareAndSwapInt32(&c.started, 0, 1) { return nil } conn, err := textproto.Dial("tcp", c.controlAddr) if err != nil { return fmt.Errorf("unable to connect to Tor server: %v", err) } c.conn = conn return c.authenticate() }
[ "func", "(", "c", "*", "Controller", ")", "Start", "(", ")", "error", "{", "if", "!", "atomic", ".", "CompareAndSwapInt32", "(", "&", "c", ".", "started", ",", "0", ",", "1", ")", "{", "return", "nil", "\n", "}", "\n\n", "conn", ",", "err", ":=",...
// Start establishes and authenticates the connection between the controller and // a Tor server. Once done, the controller will be able to send commands and // expect responses.
[ "Start", "establishes", "and", "authenticates", "the", "connection", "between", "the", "controller", "and", "a", "Tor", "server", ".", "Once", "done", "the", "controller", "will", "be", "able", "to", "send", "commands", "and", "expect", "responses", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/tor/controller.go#L95-L108
129,448
lightningnetwork/lnd
tor/controller.go
Stop
func (c *Controller) Stop() error { if !atomic.CompareAndSwapInt32(&c.stopped, 0, 1) { return nil } return c.conn.Close() }
go
func (c *Controller) Stop() error { if !atomic.CompareAndSwapInt32(&c.stopped, 0, 1) { return nil } return c.conn.Close() }
[ "func", "(", "c", "*", "Controller", ")", "Stop", "(", ")", "error", "{", "if", "!", "atomic", ".", "CompareAndSwapInt32", "(", "&", "c", ".", "stopped", ",", "0", ",", "1", ")", "{", "return", "nil", "\n", "}", "\n\n", "return", "c", ".", "conn"...
// Stop closes the connection between the controller and the Tor server.
[ "Stop", "closes", "the", "connection", "between", "the", "controller", "and", "the", "Tor", "server", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/tor/controller.go#L111-L117
129,449
lightningnetwork/lnd
tor/controller.go
sendCommand
func (c *Controller) sendCommand(command string) (int, string, error) { if err := c.conn.Writer.PrintfLine(command); err != nil { return 0, "", err } // We'll use ReadResponse as it has built-in support for multi-line // text protocol responses. code, reply, err := c.conn.Reader.ReadResponse(success) if err !=...
go
func (c *Controller) sendCommand(command string) (int, string, error) { if err := c.conn.Writer.PrintfLine(command); err != nil { return 0, "", err } // We'll use ReadResponse as it has built-in support for multi-line // text protocol responses. code, reply, err := c.conn.Reader.ReadResponse(success) if err !=...
[ "func", "(", "c", "*", "Controller", ")", "sendCommand", "(", "command", "string", ")", "(", "int", ",", "string", ",", "error", ")", "{", "if", "err", ":=", "c", ".", "conn", ".", "Writer", ".", "PrintfLine", "(", "command", ")", ";", "err", "!=",...
// sendCommand sends a command to the Tor server and returns its response, as a // single space-delimited string, and code.
[ "sendCommand", "sends", "a", "command", "to", "the", "Tor", "server", "and", "returns", "its", "response", "as", "a", "single", "space", "-", "delimited", "string", "and", "code", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/tor/controller.go#L121-L134
129,450
lightningnetwork/lnd
tor/controller.go
parseTorReply
func parseTorReply(reply string) map[string]string { params := make(map[string]string) // Replies can either span single or multiple lines, so we'll default // to stripping whitespace and newlines in order to retrieve the // individual contents of it. The -1 indicates that we want this to span // across all insta...
go
func parseTorReply(reply string) map[string]string { params := make(map[string]string) // Replies can either span single or multiple lines, so we'll default // to stripping whitespace and newlines in order to retrieve the // individual contents of it. The -1 indicates that we want this to span // across all insta...
[ "func", "parseTorReply", "(", "reply", "string", ")", "map", "[", "string", "]", "string", "{", "params", ":=", "make", "(", "map", "[", "string", "]", "string", ")", "\n\n", "// Replies can either span single or multiple lines, so we'll default", "// to stripping whi...
// parseTorReply parses the reply from the Tor server after receiving a command // from a controller. This will parse the relevant reply parameters into a map // of keys and values.
[ "parseTorReply", "parses", "the", "reply", "from", "the", "Tor", "server", "after", "receiving", "a", "command", "from", "a", "controller", ".", "This", "will", "parse", "the", "relevant", "reply", "parameters", "into", "a", "map", "of", "keys", "and", "valu...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/tor/controller.go#L139-L163
129,451
lightningnetwork/lnd
tor/controller.go
authenticate
func (c *Controller) authenticate() error { // Before proceeding to authenticate the connection, we'll retrieve // the authentication cookie of the Tor server. This will be used // throughout the authentication routine. We do this before as once the // authentication routine has begun, it is not possible to retriev...
go
func (c *Controller) authenticate() error { // Before proceeding to authenticate the connection, we'll retrieve // the authentication cookie of the Tor server. This will be used // throughout the authentication routine. We do this before as once the // authentication routine has begun, it is not possible to retriev...
[ "func", "(", "c", "*", "Controller", ")", "authenticate", "(", ")", "error", "{", "// Before proceeding to authenticate the connection, we'll retrieve", "// the authentication cookie of the Tor server. This will be used", "// throughout the authentication routine. We do this before as once...
// authenticate authenticates the connection between the controller and the // Tor server using the SAFECOOKIE or NULL authentication method.
[ "authenticate", "authenticates", "the", "connection", "between", "the", "controller", "and", "the", "Tor", "server", "using", "the", "SAFECOOKIE", "or", "NULL", "authentication", "method", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/tor/controller.go#L167-L267
129,452
lightningnetwork/lnd
tor/controller.go
getAuthCookie
func (c *Controller) getAuthCookie() ([]byte, error) { // Retrieve the authentication methods currently supported by the Tor // server. authMethods, cookieFilePath, version, err := c.ProtocolInfo() if err != nil { return nil, err } // With the version retrieved, we'll cache it now in case it needs to be // us...
go
func (c *Controller) getAuthCookie() ([]byte, error) { // Retrieve the authentication methods currently supported by the Tor // server. authMethods, cookieFilePath, version, err := c.ProtocolInfo() if err != nil { return nil, err } // With the version retrieved, we'll cache it now in case it needs to be // us...
[ "func", "(", "c", "*", "Controller", ")", "getAuthCookie", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// Retrieve the authentication methods currently supported by the Tor", "// server.", "authMethods", ",", "cookieFilePath", ",", "version", ",", "err...
// getAuthCookie retrieves the authentication cookie in bytes from the Tor // server. Cookie authentication must be enabled for this to work. The boolean
[ "getAuthCookie", "retrieves", "the", "authentication", "cookie", "in", "bytes", "from", "the", "Tor", "server", ".", "Cookie", "authentication", "must", "be", "enabled", "for", "this", "to", "work", ".", "The", "boolean" ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/tor/controller.go#L271-L312
129,453
lightningnetwork/lnd
tor/controller.go
computeHMAC256
func computeHMAC256(key, message []byte) []byte { mac := hmac.New(sha256.New, key) mac.Write(message) return mac.Sum(nil) }
go
func computeHMAC256(key, message []byte) []byte { mac := hmac.New(sha256.New, key) mac.Write(message) return mac.Sum(nil) }
[ "func", "computeHMAC256", "(", "key", ",", "message", "[", "]", "byte", ")", "[", "]", "byte", "{", "mac", ":=", "hmac", ".", "New", "(", "sha256", ".", "New", ",", "key", ")", "\n", "mac", ".", "Write", "(", "message", ")", "\n", "return", "mac"...
// computeHMAC256 computes the HMAC-SHA256 of a key and message.
[ "computeHMAC256", "computes", "the", "HMAC", "-", "SHA256", "of", "a", "key", "and", "message", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/tor/controller.go#L315-L319
129,454
lightningnetwork/lnd
tor/controller.go
ProtocolInfo
func (c *Controller) ProtocolInfo() ([]string, string, string, error) { // We'll start off by sending the "PROTOCOLINFO" command to the Tor // server. We should receive a reply of the following format: // // METHODS=COOKIE,SAFECOOKIE // COOKIEFILE="/home/user/.tor/control_auth_cookie" // VERSION Tor="0.3.2.10" /...
go
func (c *Controller) ProtocolInfo() ([]string, string, string, error) { // We'll start off by sending the "PROTOCOLINFO" command to the Tor // server. We should receive a reply of the following format: // // METHODS=COOKIE,SAFECOOKIE // COOKIEFILE="/home/user/.tor/control_auth_cookie" // VERSION Tor="0.3.2.10" /...
[ "func", "(", "c", "*", "Controller", ")", "ProtocolInfo", "(", ")", "(", "[", "]", "string", ",", "string", ",", "string", ",", "error", ")", "{", "// We'll start off by sending the \"PROTOCOLINFO\" command to the Tor", "// server. We should receive a reply of the followi...
// ProtocolInfo returns the different authentication methods supported by the // Tor server and the version of the Tor server.
[ "ProtocolInfo", "returns", "the", "different", "authentication", "methods", "supported", "by", "the", "Tor", "server", "and", "the", "version", "of", "the", "Tor", "server", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/tor/controller.go#L364-L404
129,455
lightningnetwork/lnd
tor/controller.go
AddOnion
func (c *Controller) AddOnion(cfg AddOnionConfig) (*OnionAddr, error) { // Before sending the request to create an onion service to the Tor // server, we'll make sure that it supports V3 onion services if that // was the type requested. if cfg.Type == V3 { if err := supportsV3(c.version); err != nil { return n...
go
func (c *Controller) AddOnion(cfg AddOnionConfig) (*OnionAddr, error) { // Before sending the request to create an onion service to the Tor // server, we'll make sure that it supports V3 onion services if that // was the type requested. if cfg.Type == V3 { if err := supportsV3(c.version); err != nil { return n...
[ "func", "(", "c", "*", "Controller", ")", "AddOnion", "(", "cfg", "AddOnionConfig", ")", "(", "*", "OnionAddr", ",", "error", ")", "{", "// Before sending the request to create an onion service to the Tor", "// server, we'll make sure that it supports V3 onion services if that"...
// AddOnion creates an onion service and returns its onion address. Once // created, the new onion service will remain active until the connection // between the controller and the Tor server is closed.
[ "AddOnion", "creates", "an", "onion", "service", "and", "returns", "its", "onion", "address", ".", "Once", "created", "the", "new", "onion", "service", "will", "remain", "active", "until", "the", "connection", "between", "the", "controller", "and", "the", "Tor...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/tor/controller.go#L442-L534
129,456
lightningnetwork/lnd
channeldb/db.go
Open
func Open(dbPath string, modifiers ...OptionModifier) (*DB, error) { path := filepath.Join(dbPath, dbName) if !fileExists(path) { if err := createChannelDB(dbPath); err != nil { return nil, err } } opts := DefaultOptions() for _, modifier := range modifiers { modifier(&opts) } bdb, err := bbolt.Open(...
go
func Open(dbPath string, modifiers ...OptionModifier) (*DB, error) { path := filepath.Join(dbPath, dbName) if !fileExists(path) { if err := createChannelDB(dbPath); err != nil { return nil, err } } opts := DefaultOptions() for _, modifier := range modifiers { modifier(&opts) } bdb, err := bbolt.Open(...
[ "func", "Open", "(", "dbPath", "string", ",", "modifiers", "...", "OptionModifier", ")", "(", "*", "DB", ",", "error", ")", "{", "path", ":=", "filepath", ".", "Join", "(", "dbPath", ",", "dbName", ")", "\n\n", "if", "!", "fileExists", "(", "path", "...
// Open opens an existing channeldb. Any necessary schemas migrations due to // updates will take place as necessary.
[ "Open", "opens", "an", "existing", "channeldb", ".", "Any", "necessary", "schemas", "migrations", "due", "to", "updates", "will", "take", "place", "as", "necessary", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/db.go#L117-L151
129,457
lightningnetwork/lnd
channeldb/db.go
Wipe
func (d *DB) Wipe() error { return d.Update(func(tx *bbolt.Tx) error { err := tx.DeleteBucket(openChannelBucket) if err != nil && err != bbolt.ErrBucketNotFound { return err } err = tx.DeleteBucket(closedChannelBucket) if err != nil && err != bbolt.ErrBucketNotFound { return err } err = tx.Delete...
go
func (d *DB) Wipe() error { return d.Update(func(tx *bbolt.Tx) error { err := tx.DeleteBucket(openChannelBucket) if err != nil && err != bbolt.ErrBucketNotFound { return err } err = tx.DeleteBucket(closedChannelBucket) if err != nil && err != bbolt.ErrBucketNotFound { return err } err = tx.Delete...
[ "func", "(", "d", "*", "DB", ")", "Wipe", "(", ")", "error", "{", "return", "d", ".", "Update", "(", "func", "(", "tx", "*", "bbolt", ".", "Tx", ")", "error", "{", "err", ":=", "tx", ".", "DeleteBucket", "(", "openChannelBucket", ")", "\n", "if",...
// Wipe completely deletes all saved state within all used buckets within the // database. The deletion is done in a single transaction, therefore this // operation is fully atomic.
[ "Wipe", "completely", "deletes", "all", "saved", "state", "within", "all", "used", "buckets", "within", "the", "database", ".", "The", "deletion", "is", "done", "in", "a", "single", "transaction", "therefore", "this", "operation", "is", "fully", "atomic", "." ...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/db.go#L161-L202
129,458
lightningnetwork/lnd
channeldb/db.go
fetchNodeChannels
func (d *DB) fetchNodeChannels(chainBucket *bbolt.Bucket) ([]*OpenChannel, error) { var channels []*OpenChannel // A node may have channels on several chains, so for each known chain, // we'll extract all the channels. err := chainBucket.ForEach(func(chanPoint, v []byte) error { // If there's a value, it's not ...
go
func (d *DB) fetchNodeChannels(chainBucket *bbolt.Bucket) ([]*OpenChannel, error) { var channels []*OpenChannel // A node may have channels on several chains, so for each known chain, // we'll extract all the channels. err := chainBucket.ForEach(func(chanPoint, v []byte) error { // If there's a value, it's not ...
[ "func", "(", "d", "*", "DB", ")", "fetchNodeChannels", "(", "chainBucket", "*", "bbolt", ".", "Bucket", ")", "(", "[", "]", "*", "OpenChannel", ",", "error", ")", "{", "var", "channels", "[", "]", "*", "OpenChannel", "\n\n", "// A node may have channels on...
// fetchNodeChannels retrieves all active channels from the target chainBucket // which is under a node's dedicated channel bucket. This function is typically // used to fetch all the active channels related to a particular node.
[ "fetchNodeChannels", "retrieves", "all", "active", "channels", "from", "the", "target", "chainBucket", "which", "is", "under", "a", "node", "s", "dedicated", "channel", "bucket", ".", "This", "function", "is", "typically", "used", "to", "fetch", "all", "the", ...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/db.go#L387-L424
129,459
lightningnetwork/lnd
channeldb/db.go
FetchChannel
func (d *DB) FetchChannel(chanPoint wire.OutPoint) (*OpenChannel, error) { var ( targetChan *OpenChannel targetChanPoint bytes.Buffer ) if err := writeOutpoint(&targetChanPoint, &chanPoint); err != nil { return nil, err } // chanScan will traverse the following bucket structure: // * nodePub => chai...
go
func (d *DB) FetchChannel(chanPoint wire.OutPoint) (*OpenChannel, error) { var ( targetChan *OpenChannel targetChanPoint bytes.Buffer ) if err := writeOutpoint(&targetChanPoint, &chanPoint); err != nil { return nil, err } // chanScan will traverse the following bucket structure: // * nodePub => chai...
[ "func", "(", "d", "*", "DB", ")", "FetchChannel", "(", "chanPoint", "wire", ".", "OutPoint", ")", "(", "*", "OpenChannel", ",", "error", ")", "{", "var", "(", "targetChan", "*", "OpenChannel", "\n", "targetChanPoint", "bytes", ".", "Buffer", "\n", ")", ...
// FetchChannel attempts to locate a channel specified by the passed channel // point. If the channel cannot be found, then an error will be returned.
[ "FetchChannel", "attempts", "to", "locate", "a", "channel", "specified", "by", "the", "passed", "channel", "point", ".", "If", "the", "channel", "cannot", "be", "found", "then", "an", "error", "will", "be", "returned", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/db.go#L428-L520
129,460
lightningnetwork/lnd
channeldb/db.go
FetchAllChannels
func (d *DB) FetchAllChannels() ([]*OpenChannel, error) { var channels []*OpenChannel // TODO(halseth): fetch all in one db tx. openChannels, err := d.FetchAllOpenChannels() if err != nil { return nil, err } channels = append(channels, openChannels...) pendingChannels, err := d.FetchPendingChannels() if err...
go
func (d *DB) FetchAllChannels() ([]*OpenChannel, error) { var channels []*OpenChannel // TODO(halseth): fetch all in one db tx. openChannels, err := d.FetchAllOpenChannels() if err != nil { return nil, err } channels = append(channels, openChannels...) pendingChannels, err := d.FetchPendingChannels() if err...
[ "func", "(", "d", "*", "DB", ")", "FetchAllChannels", "(", ")", "(", "[", "]", "*", "OpenChannel", ",", "error", ")", "{", "var", "channels", "[", "]", "*", "OpenChannel", "\n\n", "// TODO(halseth): fetch all in one db tx.", "openChannels", ",", "err", ":=",...
// FetchAllChannels attempts to retrieve all open channels currently stored // within the database, including pending open, fully open and channels waiting // for a closing transaction to confirm.
[ "FetchAllChannels", "attempts", "to", "retrieve", "all", "open", "channels", "currently", "stored", "within", "the", "database", "including", "pending", "open", "fully", "open", "and", "channels", "waiting", "for", "a", "closing", "transaction", "to", "confirm", "...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/db.go#L525-L548
129,461
lightningnetwork/lnd
channeldb/db.go
fetchChannels
func fetchChannels(d *DB, pending, waitingClose bool) ([]*OpenChannel, error) { var channels []*OpenChannel err := d.View(func(tx *bbolt.Tx) error { // Get the bucket dedicated to storing the metadata for open // channels. openChanBucket := tx.Bucket(openChannelBucket) if openChanBucket == nil { return Er...
go
func fetchChannels(d *DB, pending, waitingClose bool) ([]*OpenChannel, error) { var channels []*OpenChannel err := d.View(func(tx *bbolt.Tx) error { // Get the bucket dedicated to storing the metadata for open // channels. openChanBucket := tx.Bucket(openChannelBucket) if openChanBucket == nil { return Er...
[ "func", "fetchChannels", "(", "d", "*", "DB", ",", "pending", ",", "waitingClose", "bool", ")", "(", "[", "]", "*", "OpenChannel", ",", "error", ")", "{", "var", "channels", "[", "]", "*", "OpenChannel", "\n\n", "err", ":=", "d", ".", "View", "(", ...
// fetchChannels attempts to retrieve channels currently stored in the // database. The pending parameter determines whether only pending channels // will be returned, or only open channels will be returned. The waitingClose // parameter determines whether only channels waiting for a closing transaction // to be confir...
[ "fetchChannels", "attempts", "to", "retrieve", "channels", "currently", "stored", "in", "the", "database", ".", "The", "pending", "parameter", "determines", "whether", "only", "pending", "channels", "will", "be", "returned", "or", "only", "open", "channels", "will...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/db.go#L587-L666
129,462
lightningnetwork/lnd
channeldb/db.go
FetchClosedChannel
func (d *DB) FetchClosedChannel(chanID *wire.OutPoint) (*ChannelCloseSummary, error) { var chanSummary *ChannelCloseSummary if err := d.View(func(tx *bbolt.Tx) error { closeBucket := tx.Bucket(closedChannelBucket) if closeBucket == nil { return ErrClosedChannelNotFound } var b bytes.Buffer var err error...
go
func (d *DB) FetchClosedChannel(chanID *wire.OutPoint) (*ChannelCloseSummary, error) { var chanSummary *ChannelCloseSummary if err := d.View(func(tx *bbolt.Tx) error { closeBucket := tx.Bucket(closedChannelBucket) if closeBucket == nil { return ErrClosedChannelNotFound } var b bytes.Buffer var err error...
[ "func", "(", "d", "*", "DB", ")", "FetchClosedChannel", "(", "chanID", "*", "wire", ".", "OutPoint", ")", "(", "*", "ChannelCloseSummary", ",", "error", ")", "{", "var", "chanSummary", "*", "ChannelCloseSummary", "\n", "if", "err", ":=", "d", ".", "View"...
// FetchClosedChannel queries for a channel close summary using the channel // point of the channel in question.
[ "FetchClosedChannel", "queries", "for", "a", "channel", "close", "summary", "using", "the", "channel", "point", "of", "the", "channel", "in", "question", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/db.go#L713-L741
129,463
lightningnetwork/lnd
channeldb/db.go
FetchClosedChannelForID
func (d *DB) FetchClosedChannelForID(cid lnwire.ChannelID) ( *ChannelCloseSummary, error) { var chanSummary *ChannelCloseSummary if err := d.View(func(tx *bbolt.Tx) error { closeBucket := tx.Bucket(closedChannelBucket) if closeBucket == nil { return ErrClosedChannelNotFound } // The first 30 bytes of th...
go
func (d *DB) FetchClosedChannelForID(cid lnwire.ChannelID) ( *ChannelCloseSummary, error) { var chanSummary *ChannelCloseSummary if err := d.View(func(tx *bbolt.Tx) error { closeBucket := tx.Bucket(closedChannelBucket) if closeBucket == nil { return ErrClosedChannelNotFound } // The first 30 bytes of th...
[ "func", "(", "d", "*", "DB", ")", "FetchClosedChannelForID", "(", "cid", "lnwire", ".", "ChannelID", ")", "(", "*", "ChannelCloseSummary", ",", "error", ")", "{", "var", "chanSummary", "*", "ChannelCloseSummary", "\n", "if", "err", ":=", "d", ".", "View", ...
// FetchClosedChannelForID queries for a channel close summary using the // channel ID of the channel in question.
[ "FetchClosedChannelForID", "queries", "for", "a", "channel", "close", "summary", "using", "the", "channel", "ID", "of", "the", "channel", "in", "question", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/db.go#L745-L789
129,464
lightningnetwork/lnd
channeldb/db.go
MarkChanFullyClosed
func (d *DB) MarkChanFullyClosed(chanPoint *wire.OutPoint) error { return d.Update(func(tx *bbolt.Tx) error { var b bytes.Buffer if err := writeOutpoint(&b, chanPoint); err != nil { return err } chanID := b.Bytes() closedChanBucket, err := tx.CreateBucketIfNotExists( closedChannelBucket, ) if err...
go
func (d *DB) MarkChanFullyClosed(chanPoint *wire.OutPoint) error { return d.Update(func(tx *bbolt.Tx) error { var b bytes.Buffer if err := writeOutpoint(&b, chanPoint); err != nil { return err } chanID := b.Bytes() closedChanBucket, err := tx.CreateBucketIfNotExists( closedChannelBucket, ) if err...
[ "func", "(", "d", "*", "DB", ")", "MarkChanFullyClosed", "(", "chanPoint", "*", "wire", ".", "OutPoint", ")", "error", "{", "return", "d", ".", "Update", "(", "func", "(", "tx", "*", "bbolt", ".", "Tx", ")", "error", "{", "var", "b", "bytes", ".", ...
// MarkChanFullyClosed marks a channel as fully closed within the database. A // channel should be marked as fully closed if the channel was initially // cooperatively closed and it's reached a single confirmation, or after all // the pending funds in a channel that has been forcibly closed have been // swept.
[ "MarkChanFullyClosed", "marks", "a", "channel", "as", "fully", "closed", "within", "the", "database", ".", "A", "channel", "should", "be", "marked", "as", "fully", "closed", "if", "the", "channel", "was", "initially", "cooperatively", "closed", "and", "it", "s...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/db.go#L796-L845
129,465
lightningnetwork/lnd
channeldb/db.go
pruneLinkNode
func (d *DB) pruneLinkNode(tx *bbolt.Tx, remotePub *btcec.PublicKey) error { openChannels, err := d.fetchOpenChannels(tx, remotePub) if err != nil { return fmt.Errorf("unable to fetch open channels for peer %x: "+ "%v", remotePub.SerializeCompressed(), err) } if len(openChannels) > 0 { return nil } log.I...
go
func (d *DB) pruneLinkNode(tx *bbolt.Tx, remotePub *btcec.PublicKey) error { openChannels, err := d.fetchOpenChannels(tx, remotePub) if err != nil { return fmt.Errorf("unable to fetch open channels for peer %x: "+ "%v", remotePub.SerializeCompressed(), err) } if len(openChannels) > 0 { return nil } log.I...
[ "func", "(", "d", "*", "DB", ")", "pruneLinkNode", "(", "tx", "*", "bbolt", ".", "Tx", ",", "remotePub", "*", "btcec", ".", "PublicKey", ")", "error", "{", "openChannels", ",", "err", ":=", "d", ".", "fetchOpenChannels", "(", "tx", ",", "remotePub", ...
// pruneLinkNode determines whether we should garbage collect a link node from // the database due to no longer having any open channels with it. If there are // any left, then this acts as a no-op.
[ "pruneLinkNode", "determines", "whether", "we", "should", "garbage", "collect", "a", "link", "node", "from", "the", "database", "due", "to", "no", "longer", "having", "any", "open", "channels", "with", "it", ".", "If", "there", "are", "any", "left", "then", ...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/db.go#L850-L865
129,466
lightningnetwork/lnd
channeldb/db.go
PruneLinkNodes
func (d *DB) PruneLinkNodes() error { return d.Update(func(tx *bbolt.Tx) error { linkNodes, err := d.fetchAllLinkNodes(tx) if err != nil { return err } for _, linkNode := range linkNodes { err := d.pruneLinkNode(tx, linkNode.IdentityPub) if err != nil { return err } } return nil }) }
go
func (d *DB) PruneLinkNodes() error { return d.Update(func(tx *bbolt.Tx) error { linkNodes, err := d.fetchAllLinkNodes(tx) if err != nil { return err } for _, linkNode := range linkNodes { err := d.pruneLinkNode(tx, linkNode.IdentityPub) if err != nil { return err } } return nil }) }
[ "func", "(", "d", "*", "DB", ")", "PruneLinkNodes", "(", ")", "error", "{", "return", "d", ".", "Update", "(", "func", "(", "tx", "*", "bbolt", ".", "Tx", ")", "error", "{", "linkNodes", ",", "err", ":=", "d", ".", "fetchAllLinkNodes", "(", "tx", ...
// PruneLinkNodes attempts to prune all link nodes found within the databse with // whom we no longer have any open channels with.
[ "PruneLinkNodes", "attempts", "to", "prune", "all", "link", "nodes", "found", "within", "the", "databse", "with", "whom", "we", "no", "longer", "have", "any", "open", "channels", "with", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/db.go#L869-L885
129,467
lightningnetwork/lnd
channeldb/db.go
RestoreChannelShells
func (d *DB) RestoreChannelShells(channelShells ...*ChannelShell) error { chanGraph := d.ChannelGraph() // TODO(conner): find way to do this w/o accessing internal members? chanGraph.cacheMu.Lock() defer chanGraph.cacheMu.Unlock() var chansRestored []uint64 err := d.Update(func(tx *bbolt.Tx) error { for _, ch...
go
func (d *DB) RestoreChannelShells(channelShells ...*ChannelShell) error { chanGraph := d.ChannelGraph() // TODO(conner): find way to do this w/o accessing internal members? chanGraph.cacheMu.Lock() defer chanGraph.cacheMu.Unlock() var chansRestored []uint64 err := d.Update(func(tx *bbolt.Tx) error { for _, ch...
[ "func", "(", "d", "*", "DB", ")", "RestoreChannelShells", "(", "channelShells", "...", "*", "ChannelShell", ")", "error", "{", "chanGraph", ":=", "d", ".", "ChannelGraph", "(", ")", "\n\n", "// TODO(conner): find way to do this w/o accessing internal members?", "chanG...
// RestoreChannelShells is a method that allows the caller to reconstruct the // state of an OpenChannel from the ChannelShell. We'll attempt to write the // new channel to disk, create a LinkNode instance with the passed node // addresses, and finally create an edge within the graph for the channel as // well. This me...
[ "RestoreChannelShells", "is", "a", "method", "that", "allows", "the", "caller", "to", "reconstruct", "the", "state", "of", "an", "OpenChannel", "from", "the", "ChannelShell", ".", "We", "ll", "attempt", "to", "write", "the", "new", "channel", "to", "disk", "...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/db.go#L906-L1015
129,468
lightningnetwork/lnd
channeldb/db.go
AddrsForNode
func (d *DB) AddrsForNode(nodePub *btcec.PublicKey) ([]net.Addr, error) { var ( linkNode *LinkNode graphNode LightningNode ) dbErr := d.View(func(tx *bbolt.Tx) error { var err error linkNode, err = fetchLinkNode(tx, nodePub) if err != nil { return err } // We'll also query the graph for this pee...
go
func (d *DB) AddrsForNode(nodePub *btcec.PublicKey) ([]net.Addr, error) { var ( linkNode *LinkNode graphNode LightningNode ) dbErr := d.View(func(tx *bbolt.Tx) error { var err error linkNode, err = fetchLinkNode(tx, nodePub) if err != nil { return err } // We'll also query the graph for this pee...
[ "func", "(", "d", "*", "DB", ")", "AddrsForNode", "(", "nodePub", "*", "btcec", ".", "PublicKey", ")", "(", "[", "]", "net", ".", "Addr", ",", "error", ")", "{", "var", "(", "linkNode", "*", "LinkNode", "\n", "graphNode", "LightningNode", "\n", ")", ...
// AddrsForNode consults the graph and channel database for all addresses known // to the passed node public key.
[ "AddrsForNode", "consults", "the", "graph", "and", "channel", "database", "for", "all", "addresses", "known", "to", "the", "passed", "node", "public", "key", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/db.go#L1019-L1070
129,469
lightningnetwork/lnd
channeldb/db.go
getMigrationsToApply
func getMigrationsToApply(versions []version, version uint32) ([]migration, []uint32) { migrations := make([]migration, 0, len(versions)) migrationVersions := make([]uint32, 0, len(versions)) for _, v := range versions { if v.number > version { migrations = append(migrations, v.migration) migrationVersions ...
go
func getMigrationsToApply(versions []version, version uint32) ([]migration, []uint32) { migrations := make([]migration, 0, len(versions)) migrationVersions := make([]uint32, 0, len(versions)) for _, v := range versions { if v.number > version { migrations = append(migrations, v.migration) migrationVersions ...
[ "func", "getMigrationsToApply", "(", "versions", "[", "]", "version", ",", "version", "uint32", ")", "(", "[", "]", "migration", ",", "[", "]", "uint32", ")", "{", "migrations", ":=", "make", "(", "[", "]", "migration", ",", "0", ",", "len", "(", "ve...
// getMigrationsToApply retrieves the migration function that should be // applied to the database.
[ "getMigrationsToApply", "retrieves", "the", "migration", "function", "that", "should", "be", "applied", "to", "the", "database", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/db.go#L1145-L1157
129,470
lightningnetwork/lnd
sweep/sweeper.go
New
func New(cfg *UtxoSweeperConfig) *UtxoSweeper { return &UtxoSweeper{ cfg: cfg, newInputs: make(chan *sweepInputMessage), spendChan: make(chan *chainntnfs.SpendDetail), quit: make(chan struct{}), pendingInputs: make(map[wire.OutPoint]*pendingInput), } }
go
func New(cfg *UtxoSweeperConfig) *UtxoSweeper { return &UtxoSweeper{ cfg: cfg, newInputs: make(chan *sweepInputMessage), spendChan: make(chan *chainntnfs.SpendDetail), quit: make(chan struct{}), pendingInputs: make(map[wire.OutPoint]*pendingInput), } }
[ "func", "New", "(", "cfg", "*", "UtxoSweeperConfig", ")", "*", "UtxoSweeper", "{", "return", "&", "UtxoSweeper", "{", "cfg", ":", "cfg", ",", "newInputs", ":", "make", "(", "chan", "*", "sweepInputMessage", ")", ",", "spendChan", ":", "make", "(", "chan"...
// New returns a new Sweeper instance.
[ "New", "returns", "a", "new", "Sweeper", "instance", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/sweep/sweeper.go#L157-L166
129,471
lightningnetwork/lnd
sweep/sweeper.go
Start
func (s *UtxoSweeper) Start() error { if !atomic.CompareAndSwapUint32(&s.started, 0, 1) { return nil } log.Tracef("Sweeper starting") // Retrieve last published tx from database. lastTx, err := s.cfg.Store.GetLastPublishedTx() if err != nil { return fmt.Errorf("get last published tx: %v", err) } // Repub...
go
func (s *UtxoSweeper) Start() error { if !atomic.CompareAndSwapUint32(&s.started, 0, 1) { return nil } log.Tracef("Sweeper starting") // Retrieve last published tx from database. lastTx, err := s.cfg.Store.GetLastPublishedTx() if err != nil { return fmt.Errorf("get last published tx: %v", err) } // Repub...
[ "func", "(", "s", "*", "UtxoSweeper", ")", "Start", "(", ")", "error", "{", "if", "!", "atomic", ".", "CompareAndSwapUint32", "(", "&", "s", ".", "started", ",", "0", ",", "1", ")", "{", "return", "nil", "\n", "}", "\n\n", "log", ".", "Tracef", "...
// Start starts the process of constructing and publish sweep txes.
[ "Start", "starts", "the", "process", "of", "constructing", "and", "publish", "sweep", "txes", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/sweep/sweeper.go#L169-L235
129,472
lightningnetwork/lnd
sweep/sweeper.go
Stop
func (s *UtxoSweeper) Stop() error { if !atomic.CompareAndSwapUint32(&s.stopped, 0, 1) { return nil } log.Debugf("Sweeper shutting down") close(s.quit) s.wg.Wait() log.Debugf("Sweeper shut down") return nil }
go
func (s *UtxoSweeper) Stop() error { if !atomic.CompareAndSwapUint32(&s.stopped, 0, 1) { return nil } log.Debugf("Sweeper shutting down") close(s.quit) s.wg.Wait() log.Debugf("Sweeper shut down") return nil }
[ "func", "(", "s", "*", "UtxoSweeper", ")", "Stop", "(", ")", "error", "{", "if", "!", "atomic", ".", "CompareAndSwapUint32", "(", "&", "s", ".", "stopped", ",", "0", ",", "1", ")", "{", "return", "nil", "\n", "}", "\n\n", "log", ".", "Debugf", "(...
// Stop stops sweeper from listening to block epochs and constructing sweep // txes.
[ "Stop", "stops", "sweeper", "from", "listening", "to", "block", "epochs", "and", "constructing", "sweep", "txes", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/sweep/sweeper.go#L239-L252
129,473
lightningnetwork/lnd
sweep/sweeper.go
scheduleSweep
func (s *UtxoSweeper) scheduleSweep(currentHeight int32) error { // The timer is already ticking, no action needed for the sweep to // happen. if s.timer != nil { log.Debugf("Timer still ticking") return nil } // Retrieve fee estimate for input filtering and final tx fee // calculation. satPerKW, err := s.c...
go
func (s *UtxoSweeper) scheduleSweep(currentHeight int32) error { // The timer is already ticking, no action needed for the sweep to // happen. if s.timer != nil { log.Debugf("Timer still ticking") return nil } // Retrieve fee estimate for input filtering and final tx fee // calculation. satPerKW, err := s.c...
[ "func", "(", "s", "*", "UtxoSweeper", ")", "scheduleSweep", "(", "currentHeight", "int32", ")", "error", "{", "// The timer is already ticking, no action needed for the sweep to", "// happen.", "if", "s", ".", "timer", "!=", "nil", "{", "log", ".", "Debugf", "(", ...
// scheduleSweep starts the sweep timer to create an opportunity for more inputs // to be added.
[ "scheduleSweep", "starts", "the", "sweep", "timer", "to", "create", "an", "opportunity", "for", "more", "inputs", "to", "be", "added", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/sweep/sweeper.go#L459-L498
129,474
lightningnetwork/lnd
sweep/sweeper.go
signalAndRemove
func (s *UtxoSweeper) signalAndRemove(outpoint *wire.OutPoint, result Result) { pendInput := s.pendingInputs[*outpoint] listeners := pendInput.listeners if result.Err == nil { log.Debugf("Dispatching sweep success for %v to %v listeners", outpoint, len(listeners), ) } else { log.Debugf("Dispatching sweep ...
go
func (s *UtxoSweeper) signalAndRemove(outpoint *wire.OutPoint, result Result) { pendInput := s.pendingInputs[*outpoint] listeners := pendInput.listeners if result.Err == nil { log.Debugf("Dispatching sweep success for %v to %v listeners", outpoint, len(listeners), ) } else { log.Debugf("Dispatching sweep ...
[ "func", "(", "s", "*", "UtxoSweeper", ")", "signalAndRemove", "(", "outpoint", "*", "wire", ".", "OutPoint", ",", "result", "Result", ")", "{", "pendInput", ":=", "s", ".", "pendingInputs", "[", "*", "outpoint", "]", "\n", "listeners", ":=", "pendInput", ...
// signalAndRemove notifies the listeners of the final result of the input // sweep. It cancels any pending spend notification and removes the input from // the list of pending inputs. When this function returns, the sweeper has // completely forgotten about the input.
[ "signalAndRemove", "notifies", "the", "listeners", "of", "the", "final", "result", "of", "the", "input", "sweep", ".", "It", "cancels", "any", "pending", "spend", "notification", "and", "removes", "the", "input", "from", "the", "list", "of", "pending", "inputs...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/sweep/sweeper.go#L504-L534
129,475
lightningnetwork/lnd
sweep/sweeper.go
getInputLists
func (s *UtxoSweeper) getInputLists(currentHeight int32, satPerKW lnwallet.SatPerKWeight) ([]inputSet, error) { // Filter for inputs that need to be swept. Create two lists: all // sweepable inputs and a list containing only the new, never tried // inputs. // // We want to create as large a tx as possible, so we...
go
func (s *UtxoSweeper) getInputLists(currentHeight int32, satPerKW lnwallet.SatPerKWeight) ([]inputSet, error) { // Filter for inputs that need to be swept. Create two lists: all // sweepable inputs and a list containing only the new, never tried // inputs. // // We want to create as large a tx as possible, so we...
[ "func", "(", "s", "*", "UtxoSweeper", ")", "getInputLists", "(", "currentHeight", "int32", ",", "satPerKW", "lnwallet", ".", "SatPerKWeight", ")", "(", "[", "]", "inputSet", ",", "error", ")", "{", "// Filter for inputs that need to be swept. Create two lists: all", ...
// getInputLists goes through all pending inputs and constructs sweep lists, // each up to the configured maximum number of inputs. Negative yield inputs are // skipped. Transactions with an output below the dust limit are not published. // Those inputs remain pending and will be bundled with future inputs if // possib...
[ "getInputLists", "goes", "through", "all", "pending", "inputs", "and", "constructs", "sweep", "lists", "each", "up", "to", "the", "configured", "maximum", "number", "of", "inputs", ".", "Negative", "yield", "inputs", "are", "skipped", ".", "Transactions", "with"...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/sweep/sweeper.go#L541-L601
129,476
lightningnetwork/lnd
sweep/sweeper.go
sweep
func (s *UtxoSweeper) sweep(inputs inputSet, satPerKW lnwallet.SatPerKWeight, currentHeight int32) error { var err error // Generate output script if no unused script available. if s.currentOutputScript == nil { s.currentOutputScript, err = s.cfg.GenSweepScript() if err != nil { return fmt.Errorf("gen swee...
go
func (s *UtxoSweeper) sweep(inputs inputSet, satPerKW lnwallet.SatPerKWeight, currentHeight int32) error { var err error // Generate output script if no unused script available. if s.currentOutputScript == nil { s.currentOutputScript, err = s.cfg.GenSweepScript() if err != nil { return fmt.Errorf("gen swee...
[ "func", "(", "s", "*", "UtxoSweeper", ")", "sweep", "(", "inputs", "inputSet", ",", "satPerKW", "lnwallet", ".", "SatPerKWeight", ",", "currentHeight", "int32", ")", "error", "{", "var", "err", "error", "\n\n", "// Generate output script if no unused script availabl...
// sweep takes a set of preselected inputs, creates a sweep tx and publishes the // tx. The output address is only marked as used if the publish succeeds.
[ "sweep", "takes", "a", "set", "of", "preselected", "inputs", "creates", "a", "sweep", "tx", "and", "publishes", "the", "tx", ".", "The", "output", "address", "is", "only", "marked", "as", "used", "if", "the", "publish", "succeeds", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/sweep/sweeper.go#L605-L696
129,477
lightningnetwork/lnd
sweep/sweeper.go
waitForSpend
func (s *UtxoSweeper) waitForSpend(outpoint wire.OutPoint, script []byte, heightHint uint32) (func(), error) { log.Debugf("Wait for spend of %v", outpoint) spendEvent, err := s.cfg.Notifier.RegisterSpendNtfn( &outpoint, script, heightHint, ) if err != nil { return nil, fmt.Errorf("register spend ntfn: %v", e...
go
func (s *UtxoSweeper) waitForSpend(outpoint wire.OutPoint, script []byte, heightHint uint32) (func(), error) { log.Debugf("Wait for spend of %v", outpoint) spendEvent, err := s.cfg.Notifier.RegisterSpendNtfn( &outpoint, script, heightHint, ) if err != nil { return nil, fmt.Errorf("register spend ntfn: %v", e...
[ "func", "(", "s", "*", "UtxoSweeper", ")", "waitForSpend", "(", "outpoint", "wire", ".", "OutPoint", ",", "script", "[", "]", "byte", ",", "heightHint", "uint32", ")", "(", "func", "(", ")", ",", "error", ")", "{", "log", ".", "Debugf", "(", "\"", ...
// waitForSpend registers a spend notification with the chain notifier. It // returns a cancel function that can be used to cancel the registration.
[ "waitForSpend", "registers", "a", "spend", "notification", "with", "the", "chain", "notifier", ".", "It", "returns", "a", "cancel", "function", "that", "can", "be", "used", "to", "cancel", "the", "registration", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/sweep/sweeper.go#L700-L737
129,478
lightningnetwork/lnd
htlcswitch/sequencer.go
NewPersistentSequencer
func NewPersistentSequencer(db *channeldb.DB) (Sequencer, error) { g := &persistentSequencer{ db: db, } // Ensure the database bucket is created before any updates are // performed. if err := g.initDB(); err != nil { return nil, err } return g, nil }
go
func NewPersistentSequencer(db *channeldb.DB) (Sequencer, error) { g := &persistentSequencer{ db: db, } // Ensure the database bucket is created before any updates are // performed. if err := g.initDB(); err != nil { return nil, err } return g, nil }
[ "func", "NewPersistentSequencer", "(", "db", "*", "channeldb", ".", "DB", ")", "(", "Sequencer", ",", "error", ")", "{", "g", ":=", "&", "persistentSequencer", "{", "db", ":", "db", ",", "}", "\n\n", "// Ensure the database bucket is created before any updates are...
// NewPersistentSequencer initializes a new sequencer using a channeldb backend.
[ "NewPersistentSequencer", "initializes", "a", "new", "sequencer", "using", "a", "channeldb", "backend", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/sequencer.go#L46-L58
129,479
lightningnetwork/lnd
htlcswitch/sequencer.go
NextID
func (s *persistentSequencer) NextID() (uint64, error) { // nextID will be the unique sequence number returned if no errors are // encountered. var nextID uint64 // If our sequence batch has not been exhausted, we can allocate the // next identifier in the range. s.mu.Lock() defer s.mu.Unlock() if s.nextID <...
go
func (s *persistentSequencer) NextID() (uint64, error) { // nextID will be the unique sequence number returned if no errors are // encountered. var nextID uint64 // If our sequence batch has not been exhausted, we can allocate the // next identifier in the range. s.mu.Lock() defer s.mu.Unlock() if s.nextID <...
[ "func", "(", "s", "*", "persistentSequencer", ")", "NextID", "(", ")", "(", "uint64", ",", "error", ")", "{", "// nextID will be the unique sequence number returned if no errors are", "// encountered.", "var", "nextID", "uint64", "\n\n", "// If our sequence batch has not be...
// NextID returns a unique sequence number for every invocation, persisting the // assignment to avoid reuse.
[ "NextID", "returns", "a", "unique", "sequence", "number", "for", "every", "invocation", "persisting", "the", "assignment", "to", "avoid", "reuse", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/sequencer.go#L62-L120
129,480
lightningnetwork/lnd
htlcswitch/sequencer.go
initDB
func (s *persistentSequencer) initDB() error { return s.db.Update(func(tx *bbolt.Tx) error { _, err := tx.CreateBucketIfNotExists(nextPaymentIDKey) return err }) }
go
func (s *persistentSequencer) initDB() error { return s.db.Update(func(tx *bbolt.Tx) error { _, err := tx.CreateBucketIfNotExists(nextPaymentIDKey) return err }) }
[ "func", "(", "s", "*", "persistentSequencer", ")", "initDB", "(", ")", "error", "{", "return", "s", ".", "db", ".", "Update", "(", "func", "(", "tx", "*", "bbolt", ".", "Tx", ")", "error", "{", "_", ",", "err", ":=", "tx", ".", "CreateBucketIfNotEx...
// initDB populates the bucket used to generate payment sequence numbers.
[ "initDB", "populates", "the", "bucket", "used", "to", "generate", "payment", "sequence", "numbers", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/sequencer.go#L123-L128
129,481
lightningnetwork/lnd
sweep/txgenerator.go
generateInputPartitionings
func generateInputPartitionings(sweepableInputs []input.Input, relayFeePerKW, feePerKW lnwallet.SatPerKWeight, maxInputsPerTx int) ([]inputSet, error) { // Calculate dust limit based on the P2WPKH output script of the sweep // txes. dustLimit := txrules.GetDustThreshold( input.P2WPKHSize, btcutil.Amount(relay...
go
func generateInputPartitionings(sweepableInputs []input.Input, relayFeePerKW, feePerKW lnwallet.SatPerKWeight, maxInputsPerTx int) ([]inputSet, error) { // Calculate dust limit based on the P2WPKH output script of the sweep // txes. dustLimit := txrules.GetDustThreshold( input.P2WPKHSize, btcutil.Amount(relay...
[ "func", "generateInputPartitionings", "(", "sweepableInputs", "[", "]", "input", ".", "Input", ",", "relayFeePerKW", ",", "feePerKW", "lnwallet", ".", "SatPerKWeight", ",", "maxInputsPerTx", "int", ")", "(", "[", "]", "inputSet", ",", "error", ")", "{", "// Ca...
// generateInputPartitionings goes through all given inputs and constructs sets // of inputs that can be used to generate a sensible transaction. Each set // contains up to the configured maximum number of inputs. Negative yield // inputs are skipped. No input sets with a total value after fees below the // dust limit ...
[ "generateInputPartitionings", "goes", "through", "all", "given", "inputs", "and", "constructs", "sets", "of", "inputs", "that", "can", "be", "used", "to", "generate", "a", "sensible", "transaction", ".", "Each", "set", "contains", "up", "to", "the", "configured"...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/sweep/txgenerator.go#L32-L107
129,482
lightningnetwork/lnd
sweep/txgenerator.go
createSweepTx
func createSweepTx(inputs []input.Input, outputPkScript []byte, currentBlockHeight uint32, feePerKw lnwallet.SatPerKWeight, signer input.Signer) (*wire.MsgTx, error) { inputs, txWeight, csvCount, cltvCount := getWeightEstimate(inputs) log.Infof("Creating sweep transaction for %v inputs (%v CSV, %v CLTV) "+ "usi...
go
func createSweepTx(inputs []input.Input, outputPkScript []byte, currentBlockHeight uint32, feePerKw lnwallet.SatPerKWeight, signer input.Signer) (*wire.MsgTx, error) { inputs, txWeight, csvCount, cltvCount := getWeightEstimate(inputs) log.Infof("Creating sweep transaction for %v inputs (%v CSV, %v CLTV) "+ "usi...
[ "func", "createSweepTx", "(", "inputs", "[", "]", "input", ".", "Input", ",", "outputPkScript", "[", "]", "byte", ",", "currentBlockHeight", "uint32", ",", "feePerKw", "lnwallet", ".", "SatPerKWeight", ",", "signer", "input", ".", "Signer", ")", "(", "*", ...
// createSweepTx builds a signed tx spending the inputs to a the output script.
[ "createSweepTx", "builds", "a", "signed", "tx", "spending", "the", "inputs", "to", "a", "the", "output", "script", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/sweep/txgenerator.go#L170-L252
129,483
lightningnetwork/lnd
sweep/txgenerator.go
getInputWitnessSizeUpperBound
func getInputWitnessSizeUpperBound(inp input.Input) (int, bool, error) { switch inp.WitnessType() { // Outputs on a remote commitment transaction that pay directly to us. case input.WitnessKeyHash: fallthrough case input.CommitmentNoDelay: return input.P2WKHWitnessSize, false, nil // Outputs on a past commit...
go
func getInputWitnessSizeUpperBound(inp input.Input) (int, bool, error) { switch inp.WitnessType() { // Outputs on a remote commitment transaction that pay directly to us. case input.WitnessKeyHash: fallthrough case input.CommitmentNoDelay: return input.P2WKHWitnessSize, false, nil // Outputs on a past commit...
[ "func", "getInputWitnessSizeUpperBound", "(", "inp", "input", ".", "Input", ")", "(", "int", ",", "bool", ",", "error", ")", "{", "switch", "inp", ".", "WitnessType", "(", ")", "{", "// Outputs on a remote commitment transaction that pay directly to us.", "case", "i...
// getInputWitnessSizeUpperBound returns the maximum length of the witness for // the given input if it would be included in a tx. We also return if the // output itself is a nested p2sh output, if so then we need to take into // account the extra sigScript data size.
[ "getInputWitnessSizeUpperBound", "returns", "the", "maximum", "length", "of", "the", "witness", "for", "the", "given", "input", "if", "it", "would", "be", "included", "in", "a", "tx", ".", "We", "also", "return", "if", "the", "output", "itself", "is", "a", ...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/sweep/txgenerator.go#L258-L303
129,484
lightningnetwork/lnd
sweep/txgenerator.go
getWeightEstimate
func getWeightEstimate(inputs []input.Input) ([]input.Input, int64, int, int) { // We initialize a weight estimator so we can accurately asses the // amount of fees we need to pay for this sweep transaction. // // TODO(roasbeef): can be more intelligent about buffering outputs to // be more efficient on-chain. va...
go
func getWeightEstimate(inputs []input.Input) ([]input.Input, int64, int, int) { // We initialize a weight estimator so we can accurately asses the // amount of fees we need to pay for this sweep transaction. // // TODO(roasbeef): can be more intelligent about buffering outputs to // be more efficient on-chain. va...
[ "func", "getWeightEstimate", "(", "inputs", "[", "]", "input", ".", "Input", ")", "(", "[", "]", "input", ".", "Input", ",", "int64", ",", "int", ",", "int", ")", "{", "// We initialize a weight estimator so we can accurately asses the", "// amount of fees we need t...
// getWeightEstimate returns a weight estimate for the given inputs. // Additionally, it returns counts for the number of csv and cltv inputs.
[ "getWeightEstimate", "returns", "a", "weight", "estimate", "for", "the", "given", "inputs", ".", "Additionally", "it", "returns", "counts", "for", "the", "number", "of", "csv", "and", "cltv", "inputs", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/sweep/txgenerator.go#L307-L363
129,485
lightningnetwork/lnd
lnwire/funding_created.go
Encode
func (f *FundingCreated) Encode(w io.Writer, pver uint32) error { return WriteElements(w, f.PendingChannelID[:], f.FundingPoint, f.CommitSig) }
go
func (f *FundingCreated) Encode(w io.Writer, pver uint32) error { return WriteElements(w, f.PendingChannelID[:], f.FundingPoint, f.CommitSig) }
[ "func", "(", "f", "*", "FundingCreated", ")", "Encode", "(", "w", "io", ".", "Writer", ",", "pver", "uint32", ")", "error", "{", "return", "WriteElements", "(", "w", ",", "f", ".", "PendingChannelID", "[", ":", "]", ",", "f", ".", "FundingPoint", ","...
// Encode serializes the target FundingCreated into the passed io.Writer // implementation. Serialization will observe the rules defined by the passed // protocol version. // // This is part of the lnwire.Message interface.
[ "Encode", "serializes", "the", "target", "FundingCreated", "into", "the", "passed", "io", ".", "Writer", "implementation", ".", "Serialization", "will", "observe", "the", "rules", "defined", "by", "the", "passed", "protocol", "version", ".", "This", "is", "part"...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/funding_created.go#L38-L40
129,486
lightningnetwork/lnd
lnwire/funding_created.go
Decode
func (f *FundingCreated) Decode(r io.Reader, pver uint32) error { return ReadElements(r, f.PendingChannelID[:], &f.FundingPoint, &f.CommitSig) }
go
func (f *FundingCreated) Decode(r io.Reader, pver uint32) error { return ReadElements(r, f.PendingChannelID[:], &f.FundingPoint, &f.CommitSig) }
[ "func", "(", "f", "*", "FundingCreated", ")", "Decode", "(", "r", "io", ".", "Reader", ",", "pver", "uint32", ")", "error", "{", "return", "ReadElements", "(", "r", ",", "f", ".", "PendingChannelID", "[", ":", "]", ",", "&", "f", ".", "FundingPoint",...
// Decode deserializes the serialized FundingCreated stored in the passed // io.Reader into the target FundingCreated using the deserialization rules // defined by the passed protocol version. // // This is part of the lnwire.Message interface.
[ "Decode", "deserializes", "the", "serialized", "FundingCreated", "stored", "in", "the", "passed", "io", ".", "Reader", "into", "the", "target", "FundingCreated", "using", "the", "deserialization", "rules", "defined", "by", "the", "passed", "protocol", "version", "...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/funding_created.go#L47-L49
129,487
lightningnetwork/lnd
channeldb/witness_cache.go
toDBKey
func (w WitnessType) toDBKey() ([]byte, error) { switch w { case Sha256HashWitness: return []byte{byte(w)}, nil default: return nil, ErrUnknownWitnessType } }
go
func (w WitnessType) toDBKey() ([]byte, error) { switch w { case Sha256HashWitness: return []byte{byte(w)}, nil default: return nil, ErrUnknownWitnessType } }
[ "func", "(", "w", "WitnessType", ")", "toDBKey", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "switch", "w", "{", "case", "Sha256HashWitness", ":", "return", "[", "]", "byte", "{", "byte", "(", "w", ")", "}", ",", "nil", "\n\n", "defa...
// toDBKey is a helper method that maps a witness type to the key that we'll // use to store it within the database.
[ "toDBKey", "is", "a", "helper", "method", "that", "maps", "a", "witness", "type", "to", "the", "key", "that", "we", "ll", "use", "to", "store", "it", "within", "the", "database", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/witness_cache.go#L33-L42
129,488
lightningnetwork/lnd
channeldb/witness_cache.go
AddSha256Witnesses
func (w *WitnessCache) AddSha256Witnesses(preimages ...lntypes.Preimage) error { // Optimistically compute the preimages' hashes before attempting to // start the db transaction. entries := make([]witnessEntry, 0, len(preimages)) for i := range preimages { hash := preimages[i].Hash() entries = append(entries, w...
go
func (w *WitnessCache) AddSha256Witnesses(preimages ...lntypes.Preimage) error { // Optimistically compute the preimages' hashes before attempting to // start the db transaction. entries := make([]witnessEntry, 0, len(preimages)) for i := range preimages { hash := preimages[i].Hash() entries = append(entries, w...
[ "func", "(", "w", "*", "WitnessCache", ")", "AddSha256Witnesses", "(", "preimages", "...", "lntypes", ".", "Preimage", ")", "error", "{", "// Optimistically compute the preimages' hashes before attempting to", "// start the db transaction.", "entries", ":=", "make", "(", ...
// AddSha256Witnesses adds a batch of new sha256 preimages into the witness // cache. This is an alias for AddWitnesses that uses Sha256HashWitness as the // preimages' witness type.
[ "AddSha256Witnesses", "adds", "a", "batch", "of", "new", "sha256", "preimages", "into", "the", "witness", "cache", ".", "This", "is", "an", "alias", "for", "AddWitnesses", "that", "uses", "Sha256HashWitness", "as", "the", "preimages", "witness", "type", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/witness_cache.go#L83-L96
129,489
lightningnetwork/lnd
channeldb/witness_cache.go
addWitnessEntries
func (w *WitnessCache) addWitnessEntries(wType WitnessType, entries []witnessEntry) error { // Exit early if there are no witnesses to add. if len(entries) == 0 { return nil } return w.db.Batch(func(tx *bbolt.Tx) error { witnessBucket, err := tx.CreateBucketIfNotExists(witnessBucketKey) if err != nil { ...
go
func (w *WitnessCache) addWitnessEntries(wType WitnessType, entries []witnessEntry) error { // Exit early if there are no witnesses to add. if len(entries) == 0 { return nil } return w.db.Batch(func(tx *bbolt.Tx) error { witnessBucket, err := tx.CreateBucketIfNotExists(witnessBucketKey) if err != nil { ...
[ "func", "(", "w", "*", "WitnessCache", ")", "addWitnessEntries", "(", "wType", "WitnessType", ",", "entries", "[", "]", "witnessEntry", ")", "error", "{", "// Exit early if there are no witnesses to add.", "if", "len", "(", "entries", ")", "==", "0", "{", "retur...
// addWitnessEntries inserts the witnessEntry key-value pairs into the cache, // using the appropriate witness type to segment the namespace of possible // witness types.
[ "addWitnessEntries", "inserts", "the", "witnessEntry", "key", "-", "value", "pairs", "into", "the", "cache", "using", "the", "appropriate", "witness", "type", "to", "segment", "the", "namespace", "of", "possible", "witness", "types", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/witness_cache.go#L101-L135
129,490
lightningnetwork/lnd
channeldb/witness_cache.go
LookupSha256Witness
func (w *WitnessCache) LookupSha256Witness(hash lntypes.Hash) (lntypes.Preimage, error) { witness, err := w.lookupWitness(Sha256HashWitness, hash[:]) if err != nil { return lntypes.Preimage{}, err } return lntypes.MakePreimage(witness) }
go
func (w *WitnessCache) LookupSha256Witness(hash lntypes.Hash) (lntypes.Preimage, error) { witness, err := w.lookupWitness(Sha256HashWitness, hash[:]) if err != nil { return lntypes.Preimage{}, err } return lntypes.MakePreimage(witness) }
[ "func", "(", "w", "*", "WitnessCache", ")", "LookupSha256Witness", "(", "hash", "lntypes", ".", "Hash", ")", "(", "lntypes", ".", "Preimage", ",", "error", ")", "{", "witness", ",", "err", ":=", "w", ".", "lookupWitness", "(", "Sha256HashWitness", ",", "...
// LookupSha256Witness attempts to lookup the preimage for a sha256 hash. If // the witness isn't found, ErrNoWitnesses will be returned.
[ "LookupSha256Witness", "attempts", "to", "lookup", "the", "preimage", "for", "a", "sha256", "hash", ".", "If", "the", "witness", "isn", "t", "found", "ErrNoWitnesses", "will", "be", "returned", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/witness_cache.go#L139-L146
129,491
lightningnetwork/lnd
channeldb/witness_cache.go
lookupWitness
func (w *WitnessCache) lookupWitness(wType WitnessType, witnessKey []byte) ([]byte, error) { var witness []byte err := w.db.View(func(tx *bbolt.Tx) error { witnessBucket := tx.Bucket(witnessBucketKey) if witnessBucket == nil { return ErrNoWitnesses } witnessTypeBucketKey, err := wType.toDBKey() if err !...
go
func (w *WitnessCache) lookupWitness(wType WitnessType, witnessKey []byte) ([]byte, error) { var witness []byte err := w.db.View(func(tx *bbolt.Tx) error { witnessBucket := tx.Bucket(witnessBucketKey) if witnessBucket == nil { return ErrNoWitnesses } witnessTypeBucketKey, err := wType.toDBKey() if err !...
[ "func", "(", "w", "*", "WitnessCache", ")", "lookupWitness", "(", "wType", "WitnessType", ",", "witnessKey", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "witness", "[", "]", "byte", "\n", "err", ":=", "w", ".", "db"...
// lookupWitness attempts to lookup a witness according to its type and also // its witness key. In the case that the witness isn't found, ErrNoWitnesses // will be returned.
[ "lookupWitness", "attempts", "to", "lookup", "a", "witness", "according", "to", "its", "type", "and", "also", "its", "witness", "key", ".", "In", "the", "case", "that", "the", "witness", "isn", "t", "found", "ErrNoWitnesses", "will", "be", "returned", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/witness_cache.go#L151-L183
129,492
lightningnetwork/lnd
channeldb/witness_cache.go
DeleteSha256Witness
func (w *WitnessCache) DeleteSha256Witness(hash lntypes.Hash) error { return w.deleteWitness(Sha256HashWitness, hash[:]) }
go
func (w *WitnessCache) DeleteSha256Witness(hash lntypes.Hash) error { return w.deleteWitness(Sha256HashWitness, hash[:]) }
[ "func", "(", "w", "*", "WitnessCache", ")", "DeleteSha256Witness", "(", "hash", "lntypes", ".", "Hash", ")", "error", "{", "return", "w", ".", "deleteWitness", "(", "Sha256HashWitness", ",", "hash", "[", ":", "]", ")", "\n", "}" ]
// DeleteSha256Witness attempts to delete a sha256 preimage identified by hash.
[ "DeleteSha256Witness", "attempts", "to", "delete", "a", "sha256", "preimage", "identified", "by", "hash", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/witness_cache.go#L186-L188
129,493
lightningnetwork/lnd
channeldb/witness_cache.go
deleteWitness
func (w *WitnessCache) deleteWitness(wType WitnessType, witnessKey []byte) error { return w.db.Batch(func(tx *bbolt.Tx) error { witnessBucket, err := tx.CreateBucketIfNotExists(witnessBucketKey) if err != nil { return err } witnessTypeBucketKey, err := wType.toDBKey() if err != nil { return err } ...
go
func (w *WitnessCache) deleteWitness(wType WitnessType, witnessKey []byte) error { return w.db.Batch(func(tx *bbolt.Tx) error { witnessBucket, err := tx.CreateBucketIfNotExists(witnessBucketKey) if err != nil { return err } witnessTypeBucketKey, err := wType.toDBKey() if err != nil { return err } ...
[ "func", "(", "w", "*", "WitnessCache", ")", "deleteWitness", "(", "wType", "WitnessType", ",", "witnessKey", "[", "]", "byte", ")", "error", "{", "return", "w", ".", "db", ".", "Batch", "(", "func", "(", "tx", "*", "bbolt", ".", "Tx", ")", "error", ...
// deleteWitness attempts to delete a particular witness from the database.
[ "deleteWitness", "attempts", "to", "delete", "a", "particular", "witness", "from", "the", "database", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/witness_cache.go#L191-L211
129,494
lightningnetwork/lnd
lnrpc/routerrpc/driver.go
createNewSubServer
func createNewSubServer(configRegistry lnrpc.SubServerConfigDispatcher) ( lnrpc.SubServer, lnrpc.MacaroonPerms, error) { // We'll attempt to look up the config that we expect, according to our // subServerName name. If we can't find this, then we'll exit with an // error, as we're unable to properly initialize our...
go
func createNewSubServer(configRegistry lnrpc.SubServerConfigDispatcher) ( lnrpc.SubServer, lnrpc.MacaroonPerms, error) { // We'll attempt to look up the config that we expect, according to our // subServerName name. If we can't find this, then we'll exit with an // error, as we're unable to properly initialize our...
[ "func", "createNewSubServer", "(", "configRegistry", "lnrpc", ".", "SubServerConfigDispatcher", ")", "(", "lnrpc", ".", "SubServer", ",", "lnrpc", ".", "MacaroonPerms", ",", "error", ")", "{", "// We'll attempt to look up the config that we expect, according to our", "// su...
// createNewSubServer is a helper method that will create the new router sub // server given the main config dispatcher method. If we're unable to find the // config that is meant for us in the config dispatcher, then we'll exit with // an error.
[ "createNewSubServer", "is", "a", "helper", "method", "that", "will", "create", "the", "new", "router", "sub", "server", "given", "the", "main", "config", "dispatcher", "method", ".", "If", "we", "re", "unable", "to", "find", "the", "config", "that", "is", ...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnrpc/routerrpc/driver.go#L15-L46
129,495
lightningnetwork/lnd
lnrpc/invoicesrpc/invoices_server.go
New
func New(cfg *Config) (*Server, lnrpc.MacaroonPerms, error) { // If the path of the invoices macaroon wasn't specified, then we'll // assume that it's found at the default network directory. macFilePath := filepath.Join( cfg.NetworkDir, DefaultInvoicesMacFilename, ) // Now that we know the full path of the invo...
go
func New(cfg *Config) (*Server, lnrpc.MacaroonPerms, error) { // If the path of the invoices macaroon wasn't specified, then we'll // assume that it's found at the default network directory. macFilePath := filepath.Join( cfg.NetworkDir, DefaultInvoicesMacFilename, ) // Now that we know the full path of the invo...
[ "func", "New", "(", "cfg", "*", "Config", ")", "(", "*", "Server", ",", "lnrpc", ".", "MacaroonPerms", ",", "error", ")", "{", "// If the path of the invoices macaroon wasn't specified, then we'll", "// assume that it's found at the default network directory.", "macFilePath",...
// New returns a new instance of the invoicesrpc Invoices sub-server. We also // return the set of permissions for the macaroons that we may create within // this method. If the macaroons we need aren't found in the filepath, then // we'll create them on start up. If we're unable to locate, or create the // macaroons w...
[ "New", "returns", "a", "new", "instance", "of", "the", "invoicesrpc", "Invoices", "sub", "-", "server", ".", "We", "also", "return", "the", "set", "of", "permissions", "for", "the", "macaroons", "that", "we", "may", "create", "within", "this", "method", "....
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnrpc/invoicesrpc/invoices_server.go#L89-L129
129,496
lightningnetwork/lnd
lnrpc/invoicesrpc/invoices_server.go
SettleInvoice
func (s *Server) SettleInvoice(ctx context.Context, in *SettleInvoiceMsg) (*SettleInvoiceResp, error) { preimage, err := lntypes.MakePreimage(in.Preimage) if err != nil { return nil, err } err = s.cfg.InvoiceRegistry.SettleHodlInvoice(preimage) if err != nil && err != channeldb.ErrInvoiceAlreadySettled { re...
go
func (s *Server) SettleInvoice(ctx context.Context, in *SettleInvoiceMsg) (*SettleInvoiceResp, error) { preimage, err := lntypes.MakePreimage(in.Preimage) if err != nil { return nil, err } err = s.cfg.InvoiceRegistry.SettleHodlInvoice(preimage) if err != nil && err != channeldb.ErrInvoiceAlreadySettled { re...
[ "func", "(", "s", "*", "Server", ")", "SettleInvoice", "(", "ctx", "context", ".", "Context", ",", "in", "*", "SettleInvoiceMsg", ")", "(", "*", "SettleInvoiceResp", ",", "error", ")", "{", "preimage", ",", "err", ":=", "lntypes", ".", "MakePreimage", "(...
// SettleInvoice settles an accepted invoice. If the invoice is already settled, // this call will succeed.
[ "SettleInvoice", "settles", "an", "accepted", "invoice", ".", "If", "the", "invoice", "is", "already", "settled", "this", "call", "will", "succeed", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnrpc/invoicesrpc/invoices_server.go#L206-L220
129,497
lightningnetwork/lnd
lnrpc/invoicesrpc/invoices_server.go
CancelInvoice
func (s *Server) CancelInvoice(ctx context.Context, in *CancelInvoiceMsg) (*CancelInvoiceResp, error) { paymentHash, err := lntypes.MakeHash(in.PaymentHash) if err != nil { return nil, err } err = s.cfg.InvoiceRegistry.CancelInvoice(paymentHash) if err != nil { return nil, err } log.Infof("Canceled invoi...
go
func (s *Server) CancelInvoice(ctx context.Context, in *CancelInvoiceMsg) (*CancelInvoiceResp, error) { paymentHash, err := lntypes.MakeHash(in.PaymentHash) if err != nil { return nil, err } err = s.cfg.InvoiceRegistry.CancelInvoice(paymentHash) if err != nil { return nil, err } log.Infof("Canceled invoi...
[ "func", "(", "s", "*", "Server", ")", "CancelInvoice", "(", "ctx", "context", ".", "Context", ",", "in", "*", "CancelInvoiceMsg", ")", "(", "*", "CancelInvoiceResp", ",", "error", ")", "{", "paymentHash", ",", "err", ":=", "lntypes", ".", "MakeHash", "("...
// CancelInvoice cancels a currently open invoice. If the invoice is already // canceled, this call will succeed. If the invoice is already settled, it will // fail.
[ "CancelInvoice", "cancels", "a", "currently", "open", "invoice", ".", "If", "the", "invoice", "is", "already", "canceled", "this", "call", "will", "succeed", ".", "If", "the", "invoice", "is", "already", "settled", "it", "will", "fail", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnrpc/invoicesrpc/invoices_server.go#L225-L241
129,498
lightningnetwork/lnd
lnwire/onion_error.go
String
func (c FailCode) String() string { switch c { case CodeInvalidRealm: return "InvalidRealm" case CodeTemporaryNodeFailure: return "TemporaryNodeFailure" case CodePermanentNodeFailure: return "PermanentNodeFailure" case CodeRequiredNodeFeatureMissing: return "RequiredNodeFeatureMissing" case CodeInvali...
go
func (c FailCode) String() string { switch c { case CodeInvalidRealm: return "InvalidRealm" case CodeTemporaryNodeFailure: return "TemporaryNodeFailure" case CodePermanentNodeFailure: return "PermanentNodeFailure" case CodeRequiredNodeFeatureMissing: return "RequiredNodeFeatureMissing" case CodeInvali...
[ "func", "(", "c", "FailCode", ")", "String", "(", ")", "string", "{", "switch", "c", "{", "case", "CodeInvalidRealm", ":", "return", "\"", "\"", "\n\n", "case", "CodeTemporaryNodeFailure", ":", "return", "\"", "\"", "\n\n", "case", "CodePermanentNodeFailure", ...
// String returns the string representation of the failure code.
[ "String", "returns", "the", "string", "representation", "of", "the", "failure", "code", "." ]
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/onion_error.go#L84-L155
129,499
lightningnetwork/lnd
lnwire/onion_error.go
parseChannelUpdateCompatabilityMode
func parseChannelUpdateCompatabilityMode(r *bufio.Reader, chanUpdate *ChannelUpdate, pver uint32) error { // We'll peek out two bytes from the buffer without advancing the // buffer so we can decide how to parse the remainder of it. maybeTypeBytes, err := r.Peek(2) if err != nil { return err } // Some nodes ...
go
func parseChannelUpdateCompatabilityMode(r *bufio.Reader, chanUpdate *ChannelUpdate, pver uint32) error { // We'll peek out two bytes from the buffer without advancing the // buffer so we can decide how to parse the remainder of it. maybeTypeBytes, err := r.Peek(2) if err != nil { return err } // Some nodes ...
[ "func", "parseChannelUpdateCompatabilityMode", "(", "r", "*", "bufio", ".", "Reader", ",", "chanUpdate", "*", "ChannelUpdate", ",", "pver", "uint32", ")", "error", "{", "// We'll peek out two bytes from the buffer without advancing the", "// buffer so we can decide how to parse...
// parseChannelUpdateCompatabilityMode will attempt to parse a channel updated // encoded into an onion error payload in two ways. First, we'll try the // compatibility oriented version wherein we'll _skip_ the length prefixing on // the channel update message. Older versions of c-lighting do this so we'll // attempt t...
[ "parseChannelUpdateCompatabilityMode", "will", "attempt", "to", "parse", "a", "channel", "updated", "encoded", "into", "an", "onion", "error", "payload", "in", "two", "ways", ".", "First", "we", "ll", "try", "the", "compatibility", "oriented", "version", "wherein"...
1acd38e48c168b86c291524eb56b8fcdf04a910c
https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/onion_error.go#L548-L577