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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
128,700 | lightningnetwork/lnd | chainntnfs/bitcoindnotify/bitcoind.go | handleBlockConnected | func (b *BitcoindNotifier) handleBlockConnected(block chainntnfs.BlockEpoch) error {
// First, we'll fetch the raw block as we'll need to gather all the
// transactions to determine whether any are relevant to our registered
// clients.
rawBlock, err := b.chainConn.GetBlock(block.Hash)
if err != nil {
return fmt... | go | func (b *BitcoindNotifier) handleBlockConnected(block chainntnfs.BlockEpoch) error {
// First, we'll fetch the raw block as we'll need to gather all the
// transactions to determine whether any are relevant to our registered
// clients.
rawBlock, err := b.chainConn.GetBlock(block.Hash)
if err != nil {
return fmt... | [
"func",
"(",
"b",
"*",
"BitcoindNotifier",
")",
"handleBlockConnected",
"(",
"block",
"chainntnfs",
".",
"BlockEpoch",
")",
"error",
"{",
"// First, we'll fetch the raw block as we'll need to gather all the",
"// transactions to determine whether any are relevant to our registered",
... | // handleBlockConnected applies a chain update for a new block. Any watched
// transactions included this block will processed to either send notifications
// now or after numConfirmations confs. | [
"handleBlockConnected",
"applies",
"a",
"chain",
"update",
"for",
"a",
"new",
"block",
".",
"Any",
"watched",
"transactions",
"included",
"this",
"block",
"will",
"processed",
"to",
"either",
"send",
"notifications",
"now",
"or",
"after",
"numConfirmations",
"conf... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chainntnfs/bitcoindnotify/bitcoind.go#L640-L670 |
128,701 | lightningnetwork/lnd | autopilot/graph.go | randChanID | func randChanID() lnwire.ShortChannelID {
id := atomic.AddUint64(&chanIDCounter, 1)
return lnwire.NewShortChanIDFromInt(id)
} | go | func randChanID() lnwire.ShortChannelID {
id := atomic.AddUint64(&chanIDCounter, 1)
return lnwire.NewShortChanIDFromInt(id)
} | [
"func",
"randChanID",
"(",
")",
"lnwire",
".",
"ShortChannelID",
"{",
"id",
":=",
"atomic",
".",
"AddUint64",
"(",
"&",
"chanIDCounter",
",",
"1",
")",
"\n",
"return",
"lnwire",
".",
"NewShortChanIDFromInt",
"(",
"id",
")",
"\n",
"}"
] | // randChanID generates a new random channel ID. | [
"randChanID",
"generates",
"a",
"new",
"random",
"channel",
"ID",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/autopilot/graph.go#L336-L339 |
128,702 | lightningnetwork/lnd | autopilot/graph.go | randKey | func randKey() (*btcec.PublicKey, error) {
priv, err := btcec.NewPrivateKey(btcec.S256())
if err != nil {
return nil, err
}
return priv.PubKey(), nil
} | go | func randKey() (*btcec.PublicKey, error) {
priv, err := btcec.NewPrivateKey(btcec.S256())
if err != nil {
return nil, err
}
return priv.PubKey(), nil
} | [
"func",
"randKey",
"(",
")",
"(",
"*",
"btcec",
".",
"PublicKey",
",",
"error",
")",
"{",
"priv",
",",
"err",
":=",
"btcec",
".",
"NewPrivateKey",
"(",
"btcec",
".",
"S256",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
","... | // randKey returns a random public key. | [
"randKey",
"returns",
"a",
"random",
"public",
"key",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/autopilot/graph.go#L342-L349 |
128,703 | lightningnetwork/lnd | autopilot/graph.go | Median | func Median(vals []btcutil.Amount) btcutil.Amount {
sort.Slice(vals, func(i, j int) bool {
return vals[i] < vals[j]
})
num := len(vals)
switch {
case num == 0:
return 0
case num%2 == 0:
return (vals[num/2-1] + vals[num/2]) / 2
default:
return vals[num/2]
}
} | go | func Median(vals []btcutil.Amount) btcutil.Amount {
sort.Slice(vals, func(i, j int) bool {
return vals[i] < vals[j]
})
num := len(vals)
switch {
case num == 0:
return 0
case num%2 == 0:
return (vals[num/2-1] + vals[num/2]) / 2
default:
return vals[num/2]
}
} | [
"func",
"Median",
"(",
"vals",
"[",
"]",
"btcutil",
".",
"Amount",
")",
"btcutil",
".",
"Amount",
"{",
"sort",
".",
"Slice",
"(",
"vals",
",",
"func",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"return",
"vals",
"[",
"i",
"]",
"<",
"vals",
"[... | // Median returns the median value in the slice of Amounts. | [
"Median",
"returns",
"the",
"median",
"value",
"in",
"the",
"slice",
"of",
"Amounts",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/autopilot/graph.go#L507-L523 |
128,704 | lightningnetwork/lnd | input/witnessgen.go | String | func (wt WitnessType) String() string {
switch wt {
case CommitmentTimeLock:
return "CommitmentTimeLock"
case CommitmentNoDelay:
return "CommitmentNoDelay"
case CommitmentRevoke:
return "CommitmentRevoke"
case HtlcOfferedRevoke:
return "HtlcOfferedRevoke"
case HtlcAcceptedRevoke:
return "HtlcAccepte... | go | func (wt WitnessType) String() string {
switch wt {
case CommitmentTimeLock:
return "CommitmentTimeLock"
case CommitmentNoDelay:
return "CommitmentNoDelay"
case CommitmentRevoke:
return "CommitmentRevoke"
case HtlcOfferedRevoke:
return "HtlcOfferedRevoke"
case HtlcAcceptedRevoke:
return "HtlcAccepte... | [
"func",
"(",
"wt",
"WitnessType",
")",
"String",
"(",
")",
"string",
"{",
"switch",
"wt",
"{",
"case",
"CommitmentTimeLock",
":",
"return",
"\"",
"\"",
"\n\n",
"case",
"CommitmentNoDelay",
":",
"return",
"\"",
"\"",
"\n\n",
"case",
"CommitmentRevoke",
":",
... | // Stirng returns a human readable version of the target WitnessType. | [
"Stirng",
"returns",
"a",
"human",
"readable",
"version",
"of",
"the",
"target",
"WitnessType",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/input/witnessgen.go#L85-L120 |
128,705 | lightningnetwork/lnd | input/witnessgen.go | GenWitnessFunc | func (wt WitnessType) GenWitnessFunc(signer Signer,
descriptor *SignDescriptor) WitnessGenerator {
return func(tx *wire.MsgTx, hc *txscript.TxSigHashes,
inputIndex int) (*Script, error) {
desc := descriptor
desc.SigHashes = hc
desc.InputIndex = inputIndex
switch wt {
case CommitmentTimeLock:
witness... | go | func (wt WitnessType) GenWitnessFunc(signer Signer,
descriptor *SignDescriptor) WitnessGenerator {
return func(tx *wire.MsgTx, hc *txscript.TxSigHashes,
inputIndex int) (*Script, error) {
desc := descriptor
desc.SigHashes = hc
desc.InputIndex = inputIndex
switch wt {
case CommitmentTimeLock:
witness... | [
"func",
"(",
"wt",
"WitnessType",
")",
"GenWitnessFunc",
"(",
"signer",
"Signer",
",",
"descriptor",
"*",
"SignDescriptor",
")",
"WitnessGenerator",
"{",
"return",
"func",
"(",
"tx",
"*",
"wire",
".",
"MsgTx",
",",
"hc",
"*",
"txscript",
".",
"TxSigHashes",
... | // GenWitnessFunc will return a WitnessGenerator function that an output uses
// to generate the witness and optionally the sigScript for a sweep
// transaction. The sigScript will be generated if the witness type warrants
// one for spending, such as the NestedWitnessKeyHash witness type. | [
"GenWitnessFunc",
"will",
"return",
"a",
"WitnessGenerator",
"function",
"that",
"an",
"output",
"uses",
"to",
"generate",
"the",
"witness",
"and",
"optionally",
"the",
"sigScript",
"for",
"a",
"sweep",
"transaction",
".",
"The",
"sigScript",
"will",
"be",
"gene... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/input/witnessgen.go#L134-L248 |
128,706 | lightningnetwork/lnd | chainntnfs/btcdnotify/btcd.go | New | func New(config *rpcclient.ConnConfig, chainParams *chaincfg.Params,
spendHintCache chainntnfs.SpendHintCache,
confirmHintCache chainntnfs.ConfirmHintCache) (*BtcdNotifier, error) {
notifier := &BtcdNotifier{
chainParams: chainParams,
notificationCancels: make(chan interface{}),
notificationRegistry: make(c... | go | func New(config *rpcclient.ConnConfig, chainParams *chaincfg.Params,
spendHintCache chainntnfs.SpendHintCache,
confirmHintCache chainntnfs.ConfirmHintCache) (*BtcdNotifier, error) {
notifier := &BtcdNotifier{
chainParams: chainParams,
notificationCancels: make(chan interface{}),
notificationRegistry: make(c... | [
"func",
"New",
"(",
"config",
"*",
"rpcclient",
".",
"ConnConfig",
",",
"chainParams",
"*",
"chaincfg",
".",
"Params",
",",
"spendHintCache",
"chainntnfs",
".",
"SpendHintCache",
",",
"confirmHintCache",
"chainntnfs",
".",
"ConfirmHintCache",
")",
"(",
"*",
"Btc... | // New returns a new BtcdNotifier instance. This function assumes the btcd node
// detailed in the passed configuration is already running, and willing to
// accept new websockets clients. | [
"New",
"returns",
"a",
"new",
"BtcdNotifier",
"instance",
".",
"This",
"function",
"assumes",
"the",
"btcd",
"node",
"detailed",
"in",
"the",
"passed",
"configuration",
"is",
"already",
"running",
"and",
"willing",
"to",
"accept",
"new",
"websockets",
"clients",... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chainntnfs/btcdnotify/btcd.go#L98-L136 |
128,707 | lightningnetwork/lnd | chainntnfs/btcdnotify/btcd.go | Start | func (b *BtcdNotifier) Start() error {
// Already started?
if atomic.AddInt32(&b.started, 1) != 1 {
return nil
}
// Connect to btcd, and register for notifications on connected, and
// disconnected blocks.
if err := b.chainConn.Connect(20); err != nil {
return err
}
if err := b.chainConn.NotifyBlocks(); er... | go | func (b *BtcdNotifier) Start() error {
// Already started?
if atomic.AddInt32(&b.started, 1) != 1 {
return nil
}
// Connect to btcd, and register for notifications on connected, and
// disconnected blocks.
if err := b.chainConn.Connect(20); err != nil {
return err
}
if err := b.chainConn.NotifyBlocks(); er... | [
"func",
"(",
"b",
"*",
"BtcdNotifier",
")",
"Start",
"(",
")",
"error",
"{",
"// Already started?",
"if",
"atomic",
".",
"AddInt32",
"(",
"&",
"b",
".",
"started",
",",
"1",
")",
"!=",
"1",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// Connect to btcd, ... | // Start connects to the running btcd node over websockets, registers for block
// notifications, and finally launches all related helper goroutines. | [
"Start",
"connects",
"to",
"the",
"running",
"btcd",
"node",
"over",
"websockets",
"registers",
"for",
"block",
"notifications",
"and",
"finally",
"launches",
"all",
"related",
"helper",
"goroutines",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chainntnfs/btcdnotify/btcd.go#L140-L177 |
128,708 | lightningnetwork/lnd | chainntnfs/btcdnotify/btcd.go | Stop | func (b *BtcdNotifier) Stop() error {
// Already shutting down?
if atomic.AddInt32(&b.stopped, 1) != 1 {
return nil
}
// Shutdown the rpc client, this gracefully disconnects from btcd, and
// cleans up all related resources.
b.chainConn.Shutdown()
close(b.quit)
b.wg.Wait()
b.chainUpdates.Stop()
b.txUpdat... | go | func (b *BtcdNotifier) Stop() error {
// Already shutting down?
if atomic.AddInt32(&b.stopped, 1) != 1 {
return nil
}
// Shutdown the rpc client, this gracefully disconnects from btcd, and
// cleans up all related resources.
b.chainConn.Shutdown()
close(b.quit)
b.wg.Wait()
b.chainUpdates.Stop()
b.txUpdat... | [
"func",
"(",
"b",
"*",
"BtcdNotifier",
")",
"Stop",
"(",
")",
"error",
"{",
"// Already shutting down?",
"if",
"atomic",
".",
"AddInt32",
"(",
"&",
"b",
".",
"stopped",
",",
"1",
")",
"!=",
"1",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// Shutdown the... | // Stop shutsdown the BtcdNotifier. | [
"Stop",
"shutsdown",
"the",
"BtcdNotifier",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chainntnfs/btcdnotify/btcd.go#L180-L207 |
128,709 | lightningnetwork/lnd | chainntnfs/btcdnotify/btcd.go | onBlockConnected | func (b *BtcdNotifier) onBlockConnected(hash *chainhash.Hash, height int32, t time.Time) {
// Append this new chain update to the end of the queue of new chain
// updates.
b.chainUpdates.ChanIn() <- &chainUpdate{
blockHash: hash,
blockHeight: height,
connect: true,
}
} | go | func (b *BtcdNotifier) onBlockConnected(hash *chainhash.Hash, height int32, t time.Time) {
// Append this new chain update to the end of the queue of new chain
// updates.
b.chainUpdates.ChanIn() <- &chainUpdate{
blockHash: hash,
blockHeight: height,
connect: true,
}
} | [
"func",
"(",
"b",
"*",
"BtcdNotifier",
")",
"onBlockConnected",
"(",
"hash",
"*",
"chainhash",
".",
"Hash",
",",
"height",
"int32",
",",
"t",
"time",
".",
"Time",
")",
"{",
"// Append this new chain update to the end of the queue of new chain",
"// updates.",
"b",
... | // onBlockConnected implements on OnBlockConnected callback for rpcclient.
// Ingesting a block updates the wallet's internal utxo state based on the
// outputs created and destroyed within each block. | [
"onBlockConnected",
"implements",
"on",
"OnBlockConnected",
"callback",
"for",
"rpcclient",
".",
"Ingesting",
"a",
"block",
"updates",
"the",
"wallet",
"s",
"internal",
"utxo",
"state",
"based",
"on",
"the",
"outputs",
"created",
"and",
"destroyed",
"within",
"eac... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chainntnfs/btcdnotify/btcd.go#L212-L220 |
128,710 | lightningnetwork/lnd | chainntnfs/btcdnotify/btcd.go | onRedeemingTx | func (b *BtcdNotifier) onRedeemingTx(tx *btcutil.Tx, details *btcjson.BlockDetails) {
// Append this new transaction update to the end of the queue of new
// chain updates.
b.txUpdates.ChanIn() <- &txUpdate{tx, details}
} | go | func (b *BtcdNotifier) onRedeemingTx(tx *btcutil.Tx, details *btcjson.BlockDetails) {
// Append this new transaction update to the end of the queue of new
// chain updates.
b.txUpdates.ChanIn() <- &txUpdate{tx, details}
} | [
"func",
"(",
"b",
"*",
"BtcdNotifier",
")",
"onRedeemingTx",
"(",
"tx",
"*",
"btcutil",
".",
"Tx",
",",
"details",
"*",
"btcjson",
".",
"BlockDetails",
")",
"{",
"// Append this new transaction update to the end of the queue of new",
"// chain updates.",
"b",
".",
"... | // onRedeemingTx implements on OnRedeemingTx callback for rpcclient. | [
"onRedeemingTx",
"implements",
"on",
"OnRedeemingTx",
"callback",
"for",
"rpcclient",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chainntnfs/btcdnotify/btcd.go#L251-L255 |
128,711 | lightningnetwork/lnd | chainntnfs/btcdnotify/btcd.go | notifyBlockEpochClient | func (b *BtcdNotifier) notifyBlockEpochClient(epochClient *blockEpochRegistration,
height int32, sha *chainhash.Hash) {
epoch := &chainntnfs.BlockEpoch{
Height: height,
Hash: sha,
}
select {
case epochClient.epochQueue.ChanIn() <- epoch:
case <-epochClient.cancelChan:
case <-b.quit:
}
} | go | func (b *BtcdNotifier) notifyBlockEpochClient(epochClient *blockEpochRegistration,
height int32, sha *chainhash.Hash) {
epoch := &chainntnfs.BlockEpoch{
Height: height,
Hash: sha,
}
select {
case epochClient.epochQueue.ChanIn() <- epoch:
case <-epochClient.cancelChan:
case <-b.quit:
}
} | [
"func",
"(",
"b",
"*",
"BtcdNotifier",
")",
"notifyBlockEpochClient",
"(",
"epochClient",
"*",
"blockEpochRegistration",
",",
"height",
"int32",
",",
"sha",
"*",
"chainhash",
".",
"Hash",
")",
"{",
"epoch",
":=",
"&",
"chainntnfs",
".",
"BlockEpoch",
"{",
"H... | // notifyBlockEpochClient sends a registered block epoch client a notification
// about a specific block. | [
"notifyBlockEpochClient",
"sends",
"a",
"registered",
"block",
"epoch",
"client",
"a",
"notification",
"about",
"a",
"specific",
"block",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chainntnfs/btcdnotify/btcd.go#L718-L731 |
128,712 | lightningnetwork/lnd | lnwire/funding_locked.go | NewFundingLocked | func NewFundingLocked(cid ChannelID, npcp *btcec.PublicKey) *FundingLocked {
return &FundingLocked{
ChanID: cid,
NextPerCommitmentPoint: npcp,
}
} | go | func NewFundingLocked(cid ChannelID, npcp *btcec.PublicKey) *FundingLocked {
return &FundingLocked{
ChanID: cid,
NextPerCommitmentPoint: npcp,
}
} | [
"func",
"NewFundingLocked",
"(",
"cid",
"ChannelID",
",",
"npcp",
"*",
"btcec",
".",
"PublicKey",
")",
"*",
"FundingLocked",
"{",
"return",
"&",
"FundingLocked",
"{",
"ChanID",
":",
"cid",
",",
"NextPerCommitmentPoint",
":",
"npcp",
",",
"}",
"\n",
"}"
] | // NewFundingLocked creates a new FundingLocked message, populating it with the
// necessary IDs and revocation secret. | [
"NewFundingLocked",
"creates",
"a",
"new",
"FundingLocked",
"message",
"populating",
"it",
"with",
"the",
"necessary",
"IDs",
"and",
"revocation",
"secret",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/funding_locked.go#L26-L31 |
128,713 | lightningnetwork/lnd | lnwire/funding_locked.go | Decode | func (c *FundingLocked) Decode(r io.Reader, pver uint32) error {
return ReadElements(r,
&c.ChanID,
&c.NextPerCommitmentPoint)
} | go | func (c *FundingLocked) Decode(r io.Reader, pver uint32) error {
return ReadElements(r,
&c.ChanID,
&c.NextPerCommitmentPoint)
} | [
"func",
"(",
"c",
"*",
"FundingLocked",
")",
"Decode",
"(",
"r",
"io",
".",
"Reader",
",",
"pver",
"uint32",
")",
"error",
"{",
"return",
"ReadElements",
"(",
"r",
",",
"&",
"c",
".",
"ChanID",
",",
"&",
"c",
".",
"NextPerCommitmentPoint",
")",
"\n",... | // Decode deserializes the serialized FundingLocked message stored in the
// passed io.Reader into the target FundingLocked using the deserialization
// rules defined by the passed protocol version.
//
// This is part of the lnwire.Message interface. | [
"Decode",
"deserializes",
"the",
"serialized",
"FundingLocked",
"message",
"stored",
"in",
"the",
"passed",
"io",
".",
"Reader",
"into",
"the",
"target",
"FundingLocked",
"using",
"the",
"deserialization",
"rules",
"defined",
"by",
"the",
"passed",
"protocol",
"ve... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/funding_locked.go#L42-L46 |
128,714 | lightningnetwork/lnd | lnwire/funding_locked.go | Encode | func (c *FundingLocked) Encode(w io.Writer, pver uint32) error {
return WriteElements(w,
c.ChanID,
c.NextPerCommitmentPoint)
} | go | func (c *FundingLocked) Encode(w io.Writer, pver uint32) error {
return WriteElements(w,
c.ChanID,
c.NextPerCommitmentPoint)
} | [
"func",
"(",
"c",
"*",
"FundingLocked",
")",
"Encode",
"(",
"w",
"io",
".",
"Writer",
",",
"pver",
"uint32",
")",
"error",
"{",
"return",
"WriteElements",
"(",
"w",
",",
"c",
".",
"ChanID",
",",
"c",
".",
"NextPerCommitmentPoint",
")",
"\n",
"}"
] | // Encode serializes the target FundingLocked message 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",
"FundingLocked",
"message",
"into",
"the",
"passed",
"io",
".",
"Writer",
"implementation",
".",
"Serialization",
"will",
"observe",
"the",
"rules",
"defined",
"by",
"the",
"passed",
"protocol",
"version",
".",
"This",
"i... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/funding_locked.go#L53-L57 |
128,715 | lightningnetwork/lnd | lnwire/funding_locked.go | MaxPayloadLength | func (c *FundingLocked) MaxPayloadLength(uint32) uint32 {
var length uint32
// ChanID - 32 bytes
length += 32
// NextPerCommitmentPoint - 33 bytes
length += 33
// 65 bytes
return length
} | go | func (c *FundingLocked) MaxPayloadLength(uint32) uint32 {
var length uint32
// ChanID - 32 bytes
length += 32
// NextPerCommitmentPoint - 33 bytes
length += 33
// 65 bytes
return length
} | [
"func",
"(",
"c",
"*",
"FundingLocked",
")",
"MaxPayloadLength",
"(",
"uint32",
")",
"uint32",
"{",
"var",
"length",
"uint32",
"\n\n",
"// ChanID - 32 bytes",
"length",
"+=",
"32",
"\n\n",
"// NextPerCommitmentPoint - 33 bytes",
"length",
"+=",
"33",
"\n\n",
"// 6... | // MaxPayloadLength returns the maximum allowed payload length for a
// FundingLocked message. This is calculated by summing the max length of all
// the fields within a FundingLocked message.
//
// This is part of the lnwire.Message interface. | [
"MaxPayloadLength",
"returns",
"the",
"maximum",
"allowed",
"payload",
"length",
"for",
"a",
"FundingLocked",
"message",
".",
"This",
"is",
"calculated",
"by",
"summing",
"the",
"max",
"length",
"of",
"all",
"the",
"fields",
"within",
"a",
"FundingLocked",
"mess... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/funding_locked.go#L72-L83 |
128,716 | lightningnetwork/lnd | htlcswitch/control_tower.go | NewPaymentControl | func NewPaymentControl(strict bool, db *channeldb.DB) ControlTower {
return &paymentControl{
strict: strict,
db: db,
}
} | go | func NewPaymentControl(strict bool, db *channeldb.DB) ControlTower {
return &paymentControl{
strict: strict,
db: db,
}
} | [
"func",
"NewPaymentControl",
"(",
"strict",
"bool",
",",
"db",
"*",
"channeldb",
".",
"DB",
")",
"ControlTower",
"{",
"return",
"&",
"paymentControl",
"{",
"strict",
":",
"strict",
",",
"db",
":",
"db",
",",
"}",
"\n",
"}"
] | // NewPaymentControl creates a new instance of the paymentControl. The strict
// flag indicates whether the controller should require "strict" state
// transitions, which would be otherwise intolerant to older databases that may
// already have duplicate payments to the same payment hash. It should be
// enabled only a... | [
"NewPaymentControl",
"creates",
"a",
"new",
"instance",
"of",
"the",
"paymentControl",
".",
"The",
"strict",
"flag",
"indicates",
"whether",
"the",
"controller",
"should",
"require",
"strict",
"state",
"transitions",
"which",
"would",
"be",
"otherwise",
"intolerant"... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/control_tower.go#L73-L78 |
128,717 | lightningnetwork/lnd | htlcswitch/control_tower.go | ClearForTakeoff | func (p *paymentControl) ClearForTakeoff(htlc *lnwire.UpdateAddHTLC) error {
var takeoffErr error
err := p.db.Batch(func(tx *bbolt.Tx) error {
// Retrieve current status of payment from local database.
paymentStatus, err := channeldb.FetchPaymentStatusTx(
tx, htlc.PaymentHash,
)
if err != nil {
return e... | go | func (p *paymentControl) ClearForTakeoff(htlc *lnwire.UpdateAddHTLC) error {
var takeoffErr error
err := p.db.Batch(func(tx *bbolt.Tx) error {
// Retrieve current status of payment from local database.
paymentStatus, err := channeldb.FetchPaymentStatusTx(
tx, htlc.PaymentHash,
)
if err != nil {
return e... | [
"func",
"(",
"p",
"*",
"paymentControl",
")",
"ClearForTakeoff",
"(",
"htlc",
"*",
"lnwire",
".",
"UpdateAddHTLC",
")",
"error",
"{",
"var",
"takeoffErr",
"error",
"\n",
"err",
":=",
"p",
".",
"db",
".",
"Batch",
"(",
"func",
"(",
"tx",
"*",
"bbolt",
... | // ClearForTakeoff checks that we don't already have an InFlight or Completed
// payment identified by the same payment hash. | [
"ClearForTakeoff",
"checks",
"that",
"we",
"don",
"t",
"already",
"have",
"an",
"InFlight",
"or",
"Completed",
"payment",
"identified",
"by",
"the",
"same",
"payment",
"hash",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/control_tower.go#L82-L129 |
128,718 | lightningnetwork/lnd | htlcswitch/control_tower.go | Success | func (p *paymentControl) Success(paymentHash [32]byte) error {
var updateErr error
err := p.db.Batch(func(tx *bbolt.Tx) error {
paymentStatus, err := channeldb.FetchPaymentStatusTx(
tx, paymentHash,
)
if err != nil {
return err
}
// Reset the update error, to avoid carrying over an error
// from a ... | go | func (p *paymentControl) Success(paymentHash [32]byte) error {
var updateErr error
err := p.db.Batch(func(tx *bbolt.Tx) error {
paymentStatus, err := channeldb.FetchPaymentStatusTx(
tx, paymentHash,
)
if err != nil {
return err
}
// Reset the update error, to avoid carrying over an error
// from a ... | [
"func",
"(",
"p",
"*",
"paymentControl",
")",
"Success",
"(",
"paymentHash",
"[",
"32",
"]",
"byte",
")",
"error",
"{",
"var",
"updateErr",
"error",
"\n",
"err",
":=",
"p",
".",
"db",
".",
"Batch",
"(",
"func",
"(",
"tx",
"*",
"bbolt",
".",
"Tx",
... | // Success transitions an InFlight payment to Completed, otherwise it returns an
// error. After calling Success, ClearForTakeoff should prevent any further
// attempts for the same payment hash. | [
"Success",
"transitions",
"an",
"InFlight",
"payment",
"to",
"Completed",
"otherwise",
"it",
"returns",
"an",
"error",
".",
"After",
"calling",
"Success",
"ClearForTakeoff",
"should",
"prevent",
"any",
"further",
"attempts",
"for",
"the",
"same",
"payment",
"hash"... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/htlcswitch/control_tower.go#L134-L186 |
128,719 | lightningnetwork/lnd | channeldb/nodes.go | NewLinkNode | func (db *DB) NewLinkNode(bitNet wire.BitcoinNet, pub *btcec.PublicKey,
addrs ...net.Addr) *LinkNode {
return &LinkNode{
Network: bitNet,
IdentityPub: pub,
LastSeen: time.Now(),
Addresses: addrs,
db: db,
}
} | go | func (db *DB) NewLinkNode(bitNet wire.BitcoinNet, pub *btcec.PublicKey,
addrs ...net.Addr) *LinkNode {
return &LinkNode{
Network: bitNet,
IdentityPub: pub,
LastSeen: time.Now(),
Addresses: addrs,
db: db,
}
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"NewLinkNode",
"(",
"bitNet",
"wire",
".",
"BitcoinNet",
",",
"pub",
"*",
"btcec",
".",
"PublicKey",
",",
"addrs",
"...",
"net",
".",
"Addr",
")",
"*",
"LinkNode",
"{",
"return",
"&",
"LinkNode",
"{",
"Network",
":"... | // NewLinkNode creates a new LinkNode from the provided parameters, which is
// backed by an instance of channeldb. | [
"NewLinkNode",
"creates",
"a",
"new",
"LinkNode",
"from",
"the",
"provided",
"parameters",
"which",
"is",
"backed",
"by",
"an",
"instance",
"of",
"channeldb",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/nodes.go#L64-L74 |
128,720 | lightningnetwork/lnd | channeldb/nodes.go | UpdateLastSeen | func (l *LinkNode) UpdateLastSeen(lastSeen time.Time) error {
l.LastSeen = lastSeen
return l.Sync()
} | go | func (l *LinkNode) UpdateLastSeen(lastSeen time.Time) error {
l.LastSeen = lastSeen
return l.Sync()
} | [
"func",
"(",
"l",
"*",
"LinkNode",
")",
"UpdateLastSeen",
"(",
"lastSeen",
"time",
".",
"Time",
")",
"error",
"{",
"l",
".",
"LastSeen",
"=",
"lastSeen",
"\n\n",
"return",
"l",
".",
"Sync",
"(",
")",
"\n",
"}"
] | // UpdateLastSeen updates the last time this node was directly encountered on
// the Lightning Network. | [
"UpdateLastSeen",
"updates",
"the",
"last",
"time",
"this",
"node",
"was",
"directly",
"encountered",
"on",
"the",
"Lightning",
"Network",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/nodes.go#L78-L82 |
128,721 | lightningnetwork/lnd | channeldb/nodes.go | Sync | func (l *LinkNode) Sync() error {
// Finally update the database by storing the link node and updating
// any relevant indexes.
return l.db.Update(func(tx *bbolt.Tx) error {
nodeMetaBucket := tx.Bucket(nodeInfoBucket)
if nodeMetaBucket == nil {
return ErrLinkNodesNotFound
}
return putLinkNode(nodeMetaBu... | go | func (l *LinkNode) Sync() error {
// Finally update the database by storing the link node and updating
// any relevant indexes.
return l.db.Update(func(tx *bbolt.Tx) error {
nodeMetaBucket := tx.Bucket(nodeInfoBucket)
if nodeMetaBucket == nil {
return ErrLinkNodesNotFound
}
return putLinkNode(nodeMetaBu... | [
"func",
"(",
"l",
"*",
"LinkNode",
")",
"Sync",
"(",
")",
"error",
"{",
"// Finally update the database by storing the link node and updating",
"// any relevant indexes.",
"return",
"l",
".",
"db",
".",
"Update",
"(",
"func",
"(",
"tx",
"*",
"bbolt",
".",
"Tx",
... | // Sync performs a full database sync which writes the current up-to-date data
// within the struct to the database. | [
"Sync",
"performs",
"a",
"full",
"database",
"sync",
"which",
"writes",
"the",
"current",
"up",
"-",
"to",
"-",
"date",
"data",
"within",
"the",
"struct",
"to",
"the",
"database",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/nodes.go#L100-L112 |
128,722 | lightningnetwork/lnd | channeldb/nodes.go | putLinkNode | func putLinkNode(nodeMetaBucket *bbolt.Bucket, l *LinkNode) error {
// First serialize the LinkNode into its raw-bytes encoding.
var b bytes.Buffer
if err := serializeLinkNode(&b, l); err != nil {
return err
}
// Finally insert the link-node into the node metadata bucket keyed
// according to the its pubkey se... | go | func putLinkNode(nodeMetaBucket *bbolt.Bucket, l *LinkNode) error {
// First serialize the LinkNode into its raw-bytes encoding.
var b bytes.Buffer
if err := serializeLinkNode(&b, l); err != nil {
return err
}
// Finally insert the link-node into the node metadata bucket keyed
// according to the its pubkey se... | [
"func",
"putLinkNode",
"(",
"nodeMetaBucket",
"*",
"bbolt",
".",
"Bucket",
",",
"l",
"*",
"LinkNode",
")",
"error",
"{",
"// First serialize the LinkNode into its raw-bytes encoding.",
"var",
"b",
"bytes",
".",
"Buffer",
"\n",
"if",
"err",
":=",
"serializeLinkNode",... | // putLinkNode serializes then writes the encoded version of the passed link
// node into the nodeMetaBucket. This function is provided in order to allow
// the ability to re-use a database transaction across many operations. | [
"putLinkNode",
"serializes",
"then",
"writes",
"the",
"encoded",
"version",
"of",
"the",
"passed",
"link",
"node",
"into",
"the",
"nodeMetaBucket",
".",
"This",
"function",
"is",
"provided",
"in",
"order",
"to",
"allow",
"the",
"ability",
"to",
"re",
"-",
"u... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/nodes.go#L117-L128 |
128,723 | lightningnetwork/lnd | channeldb/nodes.go | DeleteLinkNode | func (db *DB) DeleteLinkNode(identity *btcec.PublicKey) error {
return db.Update(func(tx *bbolt.Tx) error {
return db.deleteLinkNode(tx, identity)
})
} | go | func (db *DB) DeleteLinkNode(identity *btcec.PublicKey) error {
return db.Update(func(tx *bbolt.Tx) error {
return db.deleteLinkNode(tx, identity)
})
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"DeleteLinkNode",
"(",
"identity",
"*",
"btcec",
".",
"PublicKey",
")",
"error",
"{",
"return",
"db",
".",
"Update",
"(",
"func",
"(",
"tx",
"*",
"bbolt",
".",
"Tx",
")",
"error",
"{",
"return",
"db",
".",
"delete... | // DeleteLinkNode removes the link node with the given identity from the
// database. | [
"DeleteLinkNode",
"removes",
"the",
"link",
"node",
"with",
"the",
"given",
"identity",
"from",
"the",
"database",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/nodes.go#L132-L136 |
128,724 | lightningnetwork/lnd | channeldb/nodes.go | FetchLinkNode | func (db *DB) FetchLinkNode(identity *btcec.PublicKey) (*LinkNode, error) {
var linkNode *LinkNode
err := db.View(func(tx *bbolt.Tx) error {
node, err := fetchLinkNode(tx, identity)
if err != nil {
return err
}
linkNode = node
return nil
})
return linkNode, err
} | go | func (db *DB) FetchLinkNode(identity *btcec.PublicKey) (*LinkNode, error) {
var linkNode *LinkNode
err := db.View(func(tx *bbolt.Tx) error {
node, err := fetchLinkNode(tx, identity)
if err != nil {
return err
}
linkNode = node
return nil
})
return linkNode, err
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"FetchLinkNode",
"(",
"identity",
"*",
"btcec",
".",
"PublicKey",
")",
"(",
"*",
"LinkNode",
",",
"error",
")",
"{",
"var",
"linkNode",
"*",
"LinkNode",
"\n",
"err",
":=",
"db",
".",
"View",
"(",
"func",
"(",
"tx"... | // FetchLinkNode attempts to lookup the data for a LinkNode based on a target
// identity public key. If a particular LinkNode for the passed identity public
// key cannot be found, then ErrNodeNotFound if returned. | [
"FetchLinkNode",
"attempts",
"to",
"lookup",
"the",
"data",
"for",
"a",
"LinkNode",
"based",
"on",
"a",
"target",
"identity",
"public",
"key",
".",
"If",
"a",
"particular",
"LinkNode",
"for",
"the",
"passed",
"identity",
"public",
"key",
"cannot",
"be",
"fou... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/nodes.go#L151-L164 |
128,725 | lightningnetwork/lnd | channeldb/nodes.go | fetchAllLinkNodes | func (db *DB) fetchAllLinkNodes(tx *bbolt.Tx) ([]*LinkNode, error) {
nodeMetaBucket := tx.Bucket(nodeInfoBucket)
if nodeMetaBucket == nil {
return nil, ErrLinkNodesNotFound
}
var linkNodes []*LinkNode
err := nodeMetaBucket.ForEach(func(k, v []byte) error {
if v == nil {
return nil
}
nodeReader := byte... | go | func (db *DB) fetchAllLinkNodes(tx *bbolt.Tx) ([]*LinkNode, error) {
nodeMetaBucket := tx.Bucket(nodeInfoBucket)
if nodeMetaBucket == nil {
return nil, ErrLinkNodesNotFound
}
var linkNodes []*LinkNode
err := nodeMetaBucket.ForEach(func(k, v []byte) error {
if v == nil {
return nil
}
nodeReader := byte... | [
"func",
"(",
"db",
"*",
"DB",
")",
"fetchAllLinkNodes",
"(",
"tx",
"*",
"bbolt",
".",
"Tx",
")",
"(",
"[",
"]",
"*",
"LinkNode",
",",
"error",
")",
"{",
"nodeMetaBucket",
":=",
"tx",
".",
"Bucket",
"(",
"nodeInfoBucket",
")",
"\n",
"if",
"nodeMetaBuc... | // fetchAllLinkNodes uses an existing database transaction to fetch all nodes
// with whom we have active channels with. | [
"fetchAllLinkNodes",
"uses",
"an",
"existing",
"database",
"transaction",
"to",
"fetch",
"all",
"nodes",
"with",
"whom",
"we",
"have",
"active",
"channels",
"with",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/nodes.go#L212-L238 |
128,726 | lightningnetwork/lnd | lnwire/funding_signed.go | Encode | func (f *FundingSigned) Encode(w io.Writer, pver uint32) error {
return WriteElements(w, f.ChanID, f.CommitSig)
} | go | func (f *FundingSigned) Encode(w io.Writer, pver uint32) error {
return WriteElements(w, f.ChanID, f.CommitSig)
} | [
"func",
"(",
"f",
"*",
"FundingSigned",
")",
"Encode",
"(",
"w",
"io",
".",
"Writer",
",",
"pver",
"uint32",
")",
"error",
"{",
"return",
"WriteElements",
"(",
"w",
",",
"f",
".",
"ChanID",
",",
"f",
".",
"CommitSig",
")",
"\n",
"}"
] | // Encode serializes the target FundingSigned 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",
"FundingSigned",
"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_signed.go#L27-L29 |
128,727 | lightningnetwork/lnd | lnwire/funding_signed.go | Decode | func (f *FundingSigned) Decode(r io.Reader, pver uint32) error {
return ReadElements(r, &f.ChanID, &f.CommitSig)
} | go | func (f *FundingSigned) Decode(r io.Reader, pver uint32) error {
return ReadElements(r, &f.ChanID, &f.CommitSig)
} | [
"func",
"(",
"f",
"*",
"FundingSigned",
")",
"Decode",
"(",
"r",
"io",
".",
"Reader",
",",
"pver",
"uint32",
")",
"error",
"{",
"return",
"ReadElements",
"(",
"r",
",",
"&",
"f",
".",
"ChanID",
",",
"&",
"f",
".",
"CommitSig",
")",
"\n",
"}"
] | // Decode deserializes the serialized FundingSigned stored in the passed
// io.Reader into the target FundingSigned using the deserialization rules
// defined by the passed protocol version.
//
// This is part of the lnwire.Message interface. | [
"Decode",
"deserializes",
"the",
"serialized",
"FundingSigned",
"stored",
"in",
"the",
"passed",
"io",
".",
"Reader",
"into",
"the",
"target",
"FundingSigned",
"using",
"the",
"deserialization",
"rules",
"defined",
"by",
"the",
"passed",
"protocol",
"version",
"."... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwire/funding_signed.go#L36-L38 |
128,728 | lightningnetwork/lnd | build/version.go | normalizeVerString | func normalizeVerString(str string) string {
var result bytes.Buffer
for _, r := range str {
if strings.ContainsRune(semanticAlphabet, r) {
result.WriteRune(r)
}
}
return result.String()
} | go | func normalizeVerString(str string) string {
var result bytes.Buffer
for _, r := range str {
if strings.ContainsRune(semanticAlphabet, r) {
result.WriteRune(r)
}
}
return result.String()
} | [
"func",
"normalizeVerString",
"(",
"str",
"string",
")",
"string",
"{",
"var",
"result",
"bytes",
".",
"Buffer",
"\n",
"for",
"_",
",",
"r",
":=",
"range",
"str",
"{",
"if",
"strings",
".",
"ContainsRune",
"(",
"semanticAlphabet",
",",
"r",
")",
"{",
"... | // normalizeVerString returns the passed string stripped of all characters which
// are not valid according to the semantic versioning guidelines for pre-release
// version and build metadata strings. In particular they MUST only contain
// characters in semanticAlphabet. | [
"normalizeVerString",
"returns",
"the",
"passed",
"string",
"stripped",
"of",
"all",
"characters",
"which",
"are",
"not",
"valid",
"according",
"to",
"the",
"semantic",
"versioning",
"guidelines",
"for",
"pre",
"-",
"release",
"version",
"and",
"build",
"metadata"... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/build/version.go#L58-L66 |
128,729 | lightningnetwork/lnd | watchtower/wtclient/candidate_iterator.go | newTowerListIterator | func newTowerListIterator(candidates ...*wtdb.Tower) *towerListIterator {
iter := &towerListIterator{
candidates: list.New(),
}
for _, candidate := range candidates {
iter.candidates.PushBack(candidate)
}
iter.Reset()
return iter
} | go | func newTowerListIterator(candidates ...*wtdb.Tower) *towerListIterator {
iter := &towerListIterator{
candidates: list.New(),
}
for _, candidate := range candidates {
iter.candidates.PushBack(candidate)
}
iter.Reset()
return iter
} | [
"func",
"newTowerListIterator",
"(",
"candidates",
"...",
"*",
"wtdb",
".",
"Tower",
")",
"*",
"towerListIterator",
"{",
"iter",
":=",
"&",
"towerListIterator",
"{",
"candidates",
":",
"list",
".",
"New",
"(",
")",
",",
"}",
"\n\n",
"for",
"_",
",",
"can... | // newTowerListIterator initializes a new towerListIterator from a variadic list
// of lnwire.NetAddresses. | [
"newTowerListIterator",
"initializes",
"a",
"new",
"towerListIterator",
"from",
"a",
"variadic",
"list",
"of",
"lnwire",
".",
"NetAddresses",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/candidate_iterator.go#L36-L47 |
128,730 | lightningnetwork/lnd | watchtower/wtclient/candidate_iterator.go | Reset | func (t *towerListIterator) Reset() error {
t.mu.Lock()
defer t.mu.Unlock()
// Reset the next candidate to the front of the linked-list.
t.nextCandidate = t.candidates.Front()
return nil
} | go | func (t *towerListIterator) Reset() error {
t.mu.Lock()
defer t.mu.Unlock()
// Reset the next candidate to the front of the linked-list.
t.nextCandidate = t.candidates.Front()
return nil
} | [
"func",
"(",
"t",
"*",
"towerListIterator",
")",
"Reset",
"(",
")",
"error",
"{",
"t",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"t",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"// Reset the next candidate to the front of the linked-list.",
"t",
".... | // Reset clears the iterators state, and makes the address at the front of the
// list the next item to be returned.. | [
"Reset",
"clears",
"the",
"iterators",
"state",
"and",
"makes",
"the",
"address",
"at",
"the",
"front",
"of",
"the",
"list",
"the",
"next",
"item",
"to",
"be",
"returned",
".."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/candidate_iterator.go#L51-L59 |
128,731 | lightningnetwork/lnd | watchtower/wtclient/candidate_iterator.go | Next | func (t *towerListIterator) Next() (*wtdb.Tower, error) {
t.mu.Lock()
defer t.mu.Unlock()
// If the next candidate is nil, we've exhausted the list.
if t.nextCandidate == nil {
return nil, ErrTowerCandidatesExhausted
}
// Propose the tower at the front of the list.
tower := t.nextCandidate.Value.(*wtdb.Tower... | go | func (t *towerListIterator) Next() (*wtdb.Tower, error) {
t.mu.Lock()
defer t.mu.Unlock()
// If the next candidate is nil, we've exhausted the list.
if t.nextCandidate == nil {
return nil, ErrTowerCandidatesExhausted
}
// Propose the tower at the front of the list.
tower := t.nextCandidate.Value.(*wtdb.Tower... | [
"func",
"(",
"t",
"*",
"towerListIterator",
")",
"Next",
"(",
")",
"(",
"*",
"wtdb",
".",
"Tower",
",",
"error",
")",
"{",
"t",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"t",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"// If the next cand... | // Next returns the next candidate tower. This iterator will always return
// candidates in the order given when the iterator was instantiated. If no more
// candidates are available, ErrTowerCandidatesExhausted is returned. | [
"Next",
"returns",
"the",
"next",
"candidate",
"tower",
".",
"This",
"iterator",
"will",
"always",
"return",
"candidates",
"in",
"the",
"order",
"given",
"when",
"the",
"iterator",
"was",
"instantiated",
".",
"If",
"no",
"more",
"candidates",
"are",
"available... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/candidate_iterator.go#L64-L80 |
128,732 | lightningnetwork/lnd | chanbackup/single.go | NewSingle | func NewSingle(channel *channeldb.OpenChannel,
nodeAddrs []net.Addr) Single {
// TODO(roasbeef): update after we start to store the KeyLoc for
// shachain root
// We'll need to obtain the shachain root which is derived directly
// from a private key in our keychain.
var b bytes.Buffer
channel.RevocationProduce... | go | func NewSingle(channel *channeldb.OpenChannel,
nodeAddrs []net.Addr) Single {
// TODO(roasbeef): update after we start to store the KeyLoc for
// shachain root
// We'll need to obtain the shachain root which is derived directly
// from a private key in our keychain.
var b bytes.Buffer
channel.RevocationProduce... | [
"func",
"NewSingle",
"(",
"channel",
"*",
"channeldb",
".",
"OpenChannel",
",",
"nodeAddrs",
"[",
"]",
"net",
".",
"Addr",
")",
"Single",
"{",
"// TODO(roasbeef): update after we start to store the KeyLoc for",
"// shachain root",
"// We'll need to obtain the shachain root wh... | // NewSingle creates a new static channel backup based on an existing open
// channel. We also pass in the set of addresses that we used in the past to
// connect to the channel peer. | [
"NewSingle",
"creates",
"a",
"new",
"static",
"channel",
"backup",
"based",
"on",
"an",
"existing",
"open",
"channel",
".",
"We",
"also",
"pass",
"in",
"the",
"set",
"of",
"addresses",
"that",
"we",
"used",
"in",
"the",
"past",
"to",
"connect",
"to",
"th... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chanbackup/single.go#L107-L142 |
128,733 | lightningnetwork/lnd | chanbackup/single.go | Serialize | func (s *Single) Serialize(w io.Writer) error {
// Check to ensure that we'll only attempt to serialize a version that
// we're aware of.
switch s.Version {
case DefaultSingleVersion:
default:
return fmt.Errorf("unable to serialize w/ unknown "+
"version: %v", s.Version)
}
// If the sha chain root has spec... | go | func (s *Single) Serialize(w io.Writer) error {
// Check to ensure that we'll only attempt to serialize a version that
// we're aware of.
switch s.Version {
case DefaultSingleVersion:
default:
return fmt.Errorf("unable to serialize w/ unknown "+
"version: %v", s.Version)
}
// If the sha chain root has spec... | [
"func",
"(",
"s",
"*",
"Single",
")",
"Serialize",
"(",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"// Check to ensure that we'll only attempt to serialize a version that",
"// we're aware of.",
"switch",
"s",
".",
"Version",
"{",
"case",
"DefaultSingleVersion",
":"... | // Serialize attempts to write out the serialized version of the target
// StaticChannelBackup into the passed io.Writer. | [
"Serialize",
"attempts",
"to",
"write",
"out",
"the",
"serialized",
"version",
"of",
"the",
"target",
"StaticChannelBackup",
"into",
"the",
"passed",
"io",
".",
"Writer",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chanbackup/single.go#L146-L219 |
128,734 | lightningnetwork/lnd | chanbackup/single.go | PackToWriter | func (s *Single) PackToWriter(w io.Writer, keyRing keychain.KeyRing) error {
// First, we'll serialize the SCB (StaticChannelBackup) into a
// temporary buffer so we can store it in a temporary place before we
// go to encrypt the entire thing.
var rawBytes bytes.Buffer
if err := s.Serialize(&rawBytes); err != nil... | go | func (s *Single) PackToWriter(w io.Writer, keyRing keychain.KeyRing) error {
// First, we'll serialize the SCB (StaticChannelBackup) into a
// temporary buffer so we can store it in a temporary place before we
// go to encrypt the entire thing.
var rawBytes bytes.Buffer
if err := s.Serialize(&rawBytes); err != nil... | [
"func",
"(",
"s",
"*",
"Single",
")",
"PackToWriter",
"(",
"w",
"io",
".",
"Writer",
",",
"keyRing",
"keychain",
".",
"KeyRing",
")",
"error",
"{",
"// First, we'll serialize the SCB (StaticChannelBackup) into a",
"// temporary buffer so we can store it in a temporary place... | // PackToWriter is similar to the Serialize method, but takes the operation a
// step further by encryption the raw bytes of the static channel back up. For
// encryption we use the chacah20poly1305 AEAD cipher with a 24 byte nonce and
// 32-byte key size. We use a 24-byte nonce, as we can't ensure that we have a
// gl... | [
"PackToWriter",
"is",
"similar",
"to",
"the",
"Serialize",
"method",
"but",
"takes",
"the",
"operation",
"a",
"step",
"further",
"by",
"encryption",
"the",
"raw",
"bytes",
"of",
"the",
"static",
"channel",
"back",
"up",
".",
"For",
"encryption",
"we",
"use",... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chanbackup/single.go#L234-L247 |
128,735 | lightningnetwork/lnd | chanbackup/single.go | readLocalKeyDesc | func readLocalKeyDesc(r io.Reader) (keychain.KeyDescriptor, error) {
var keyDesc keychain.KeyDescriptor
var keyFam uint32
if err := lnwire.ReadElements(r, &keyFam); err != nil {
return keyDesc, err
}
keyDesc.Family = keychain.KeyFamily(keyFam)
if err := lnwire.ReadElements(r, &keyDesc.Index); err != nil {
r... | go | func readLocalKeyDesc(r io.Reader) (keychain.KeyDescriptor, error) {
var keyDesc keychain.KeyDescriptor
var keyFam uint32
if err := lnwire.ReadElements(r, &keyFam); err != nil {
return keyDesc, err
}
keyDesc.Family = keychain.KeyFamily(keyFam)
if err := lnwire.ReadElements(r, &keyDesc.Index); err != nil {
r... | [
"func",
"readLocalKeyDesc",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"keychain",
".",
"KeyDescriptor",
",",
"error",
")",
"{",
"var",
"keyDesc",
"keychain",
".",
"KeyDescriptor",
"\n\n",
"var",
"keyFam",
"uint32",
"\n",
"if",
"err",
":=",
"lnwire",
".",
... | // readLocalKeyDesc reads a KeyDescriptor encoded within an unpacked Single.
// For local KeyDescs, we only write out the KeyLocator information as we can
// re-derive the pubkey from it. | [
"readLocalKeyDesc",
"reads",
"a",
"KeyDescriptor",
"encoded",
"within",
"an",
"unpacked",
"Single",
".",
"For",
"local",
"KeyDescs",
"we",
"only",
"write",
"out",
"the",
"KeyLocator",
"information",
"as",
"we",
"can",
"re",
"-",
"derive",
"the",
"pubkey",
"fro... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chanbackup/single.go#L252-L266 |
128,736 | lightningnetwork/lnd | chanbackup/single.go | readRemoteKeyDesc | func readRemoteKeyDesc(r io.Reader) (keychain.KeyDescriptor, error) {
var (
keyDesc keychain.KeyDescriptor
pub [33]byte
)
_, err := io.ReadFull(r, pub[:])
if err != nil {
return keyDesc, nil
}
keyDesc.PubKey, err = btcec.ParsePubKey(pub[:], btcec.S256())
if err != nil {
return keyDesc, nil
}
key... | go | func readRemoteKeyDesc(r io.Reader) (keychain.KeyDescriptor, error) {
var (
keyDesc keychain.KeyDescriptor
pub [33]byte
)
_, err := io.ReadFull(r, pub[:])
if err != nil {
return keyDesc, nil
}
keyDesc.PubKey, err = btcec.ParsePubKey(pub[:], btcec.S256())
if err != nil {
return keyDesc, nil
}
key... | [
"func",
"readRemoteKeyDesc",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"keychain",
".",
"KeyDescriptor",
",",
"error",
")",
"{",
"var",
"(",
"keyDesc",
"keychain",
".",
"KeyDescriptor",
"\n",
"pub",
"[",
"33",
"]",
"byte",
"\n",
")",
"\n\n",
"_",
",",
... | // readRemoteKeyDesc reads a remote KeyDescriptor encoded within an unpacked
// Single. For remote KeyDescs, we write out only the PubKey since we don't
// actually have the KeyLocator data. | [
"readRemoteKeyDesc",
"reads",
"a",
"remote",
"KeyDescriptor",
"encoded",
"within",
"an",
"unpacked",
"Single",
".",
"For",
"remote",
"KeyDescs",
"we",
"write",
"out",
"only",
"the",
"PubKey",
"since",
"we",
"don",
"t",
"actually",
"have",
"the",
"KeyLocator",
... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chanbackup/single.go#L271-L290 |
128,737 | lightningnetwork/lnd | chanbackup/single.go | PackStaticChanBackups | func PackStaticChanBackups(backups []Single,
keyRing keychain.KeyRing) (map[wire.OutPoint][]byte, error) {
packedBackups := make(map[wire.OutPoint][]byte)
for _, chanBackup := range backups {
chanPoint := chanBackup.FundingOutpoint
var b bytes.Buffer
err := chanBackup.PackToWriter(&b, keyRing)
if err != ni... | go | func PackStaticChanBackups(backups []Single,
keyRing keychain.KeyRing) (map[wire.OutPoint][]byte, error) {
packedBackups := make(map[wire.OutPoint][]byte)
for _, chanBackup := range backups {
chanPoint := chanBackup.FundingOutpoint
var b bytes.Buffer
err := chanBackup.PackToWriter(&b, keyRing)
if err != ni... | [
"func",
"PackStaticChanBackups",
"(",
"backups",
"[",
"]",
"Single",
",",
"keyRing",
"keychain",
".",
"KeyRing",
")",
"(",
"map",
"[",
"wire",
".",
"OutPoint",
"]",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"packedBackups",
":=",
"make",
"(",
"map",
"[... | // PackStaticChanBackups accepts a set of existing open channels, and a
// keychain.KeyRing, and returns a map of outpoints to the serialized+encrypted
// static channel backups. The passed keyRing should be backed by the users
// root HD seed in order to ensure full determinism. | [
"PackStaticChanBackups",
"accepts",
"a",
"set",
"of",
"existing",
"open",
"channels",
"and",
"a",
"keychain",
".",
"KeyRing",
"and",
"returns",
"a",
"map",
"of",
"outpoints",
"to",
"the",
"serialized",
"+",
"encrypted",
"static",
"channel",
"backups",
".",
"Th... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chanbackup/single.go#L426-L444 |
128,738 | lightningnetwork/lnd | chanbackup/single.go | Unpack | func (p PackedSingles) Unpack(keyRing keychain.KeyRing) ([]Single, error) {
backups := make([]Single, len(p))
for i, encryptedBackup := range p {
var backup Single
backupReader := bytes.NewReader(encryptedBackup)
err := backup.UnpackFromReader(backupReader, keyRing)
if err != nil {
return nil, err
}
... | go | func (p PackedSingles) Unpack(keyRing keychain.KeyRing) ([]Single, error) {
backups := make([]Single, len(p))
for i, encryptedBackup := range p {
var backup Single
backupReader := bytes.NewReader(encryptedBackup)
err := backup.UnpackFromReader(backupReader, keyRing)
if err != nil {
return nil, err
}
... | [
"func",
"(",
"p",
"PackedSingles",
")",
"Unpack",
"(",
"keyRing",
"keychain",
".",
"KeyRing",
")",
"(",
"[",
"]",
"Single",
",",
"error",
")",
"{",
"backups",
":=",
"make",
"(",
"[",
"]",
"Single",
",",
"len",
"(",
"p",
")",
")",
"\n",
"for",
"i"... | // Unpack attempts to decrypt the passed set of encrypted SCBs and deserialize
// each one into a new SCB struct. The passed keyRing should be backed by the
// same HD seed as was used to encrypt the set of backups in the first place.
// If we're unable to decrypt any of the back ups, then we'll return an error. | [
"Unpack",
"attempts",
"to",
"decrypt",
"the",
"passed",
"set",
"of",
"encrypted",
"SCBs",
"and",
"deserialize",
"each",
"one",
"into",
"a",
"new",
"SCB",
"struct",
".",
"The",
"passed",
"keyRing",
"should",
"be",
"backed",
"by",
"the",
"same",
"HD",
"seed"... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/chanbackup/single.go#L455-L471 |
128,739 | lightningnetwork/lnd | pool/recycle.go | NewRecycle | func NewRecycle(newItem func() interface{}, returnQueueSize int,
gcInterval, expiryInterval time.Duration) *Recycle {
return &Recycle{
queue: queue.NewGCQueue(
newItem, returnQueueSize,
gcInterval, expiryInterval,
),
}
} | go | func NewRecycle(newItem func() interface{}, returnQueueSize int,
gcInterval, expiryInterval time.Duration) *Recycle {
return &Recycle{
queue: queue.NewGCQueue(
newItem, returnQueueSize,
gcInterval, expiryInterval,
),
}
} | [
"func",
"NewRecycle",
"(",
"newItem",
"func",
"(",
")",
"interface",
"{",
"}",
",",
"returnQueueSize",
"int",
",",
"gcInterval",
",",
"expiryInterval",
"time",
".",
"Duration",
")",
"*",
"Recycle",
"{",
"return",
"&",
"Recycle",
"{",
"queue",
":",
"queue",... | // NewRecycle initializes a fresh Recycle instance. | [
"NewRecycle",
"initializes",
"a",
"fresh",
"Recycle",
"instance",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/pool/recycle.go#L24-L33 |
128,740 | lightningnetwork/lnd | pool/recycle.go | Return | func (r *Recycle) Return(item Recycler) {
// Recycle the item to ensure that a dirty instance is never offered
// from Take. The call is done here so that the CPU cycles spent
// clearing the buffer are owned by the caller, and not by the queue
// itself. This makes the queue more likely to be available to deliver
... | go | func (r *Recycle) Return(item Recycler) {
// Recycle the item to ensure that a dirty instance is never offered
// from Take. The call is done here so that the CPU cycles spent
// clearing the buffer are owned by the caller, and not by the queue
// itself. This makes the queue more likely to be available to deliver
... | [
"func",
"(",
"r",
"*",
"Recycle",
")",
"Return",
"(",
"item",
"Recycler",
")",
"{",
"// Recycle the item to ensure that a dirty instance is never offered",
"// from Take. The call is done here so that the CPU cycles spent",
"// clearing the buffer are owned by the caller, and not by the ... | // Return returns an item implementing the Recycler interface to the pool. The
// Recycle method is invoked before returning the item to improve performance
// and utilization under load. | [
"Return",
"returns",
"an",
"item",
"implementing",
"the",
"Recycler",
"interface",
"to",
"the",
"pool",
".",
"The",
"Recycle",
"method",
"is",
"invoked",
"before",
"returning",
"the",
"item",
"to",
"improve",
"performance",
"and",
"utilization",
"under",
"load",... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/pool/recycle.go#L43-L52 |
128,741 | lightningnetwork/lnd | input/size.go | EstimateCommitTxWeight | func EstimateCommitTxWeight(count int, prediction bool) int64 {
// Make prediction about the size of commitment transaction with
// additional HTLC.
if prediction {
count++
}
htlcWeight := int64(count * HTLCWeight)
baseWeight := int64(BaseCommitmentTxWeight)
witnessWeight := int64(WitnessCommitmentTxWeight)
... | go | func EstimateCommitTxWeight(count int, prediction bool) int64 {
// Make prediction about the size of commitment transaction with
// additional HTLC.
if prediction {
count++
}
htlcWeight := int64(count * HTLCWeight)
baseWeight := int64(BaseCommitmentTxWeight)
witnessWeight := int64(WitnessCommitmentTxWeight)
... | [
"func",
"EstimateCommitTxWeight",
"(",
"count",
"int",
",",
"prediction",
"bool",
")",
"int64",
"{",
"// Make prediction about the size of commitment transaction with",
"// additional HTLC.",
"if",
"prediction",
"{",
"count",
"++",
"\n",
"}",
"\n\n",
"htlcWeight",
":=",
... | // EstimateCommitTxWeight estimate commitment transaction weight depending on
// the precalculated weight of base transaction, witness data, which is needed
// for paying for funding tx, and htlc weight multiplied by their count. | [
"EstimateCommitTxWeight",
"estimate",
"commitment",
"transaction",
"weight",
"depending",
"on",
"the",
"precalculated",
"weight",
"of",
"base",
"transaction",
"witness",
"data",
"which",
"is",
"needed",
"for",
"paying",
"for",
"funding",
"tx",
"and",
"htlc",
"weight... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/input/size.go#L365-L377 |
128,742 | lightningnetwork/lnd | input/size.go | AddP2PKHInput | func (twe *TxWeightEstimator) AddP2PKHInput() *TxWeightEstimator {
twe.inputSize += InputSize + P2PKHScriptSigSize
twe.inputWitnessSize++
twe.inputCount++
return twe
} | go | func (twe *TxWeightEstimator) AddP2PKHInput() *TxWeightEstimator {
twe.inputSize += InputSize + P2PKHScriptSigSize
twe.inputWitnessSize++
twe.inputCount++
return twe
} | [
"func",
"(",
"twe",
"*",
"TxWeightEstimator",
")",
"AddP2PKHInput",
"(",
")",
"*",
"TxWeightEstimator",
"{",
"twe",
".",
"inputSize",
"+=",
"InputSize",
"+",
"P2PKHScriptSigSize",
"\n",
"twe",
".",
"inputWitnessSize",
"++",
"\n",
"twe",
".",
"inputCount",
"++"... | // AddP2PKHInput updates the weight estimate to account for an additional input
// spending a P2PKH output. | [
"AddP2PKHInput",
"updates",
"the",
"weight",
"estimate",
"to",
"account",
"for",
"an",
"additional",
"input",
"spending",
"a",
"P2PKH",
"output",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/input/size.go#L395-L401 |
128,743 | lightningnetwork/lnd | input/size.go | AddWitnessInput | func (twe *TxWeightEstimator) AddWitnessInput(witnessSize int) *TxWeightEstimator {
twe.inputSize += InputSize
twe.inputWitnessSize += witnessSize
twe.inputCount++
twe.hasWitness = true
return twe
} | go | func (twe *TxWeightEstimator) AddWitnessInput(witnessSize int) *TxWeightEstimator {
twe.inputSize += InputSize
twe.inputWitnessSize += witnessSize
twe.inputCount++
twe.hasWitness = true
return twe
} | [
"func",
"(",
"twe",
"*",
"TxWeightEstimator",
")",
"AddWitnessInput",
"(",
"witnessSize",
"int",
")",
"*",
"TxWeightEstimator",
"{",
"twe",
".",
"inputSize",
"+=",
"InputSize",
"\n",
"twe",
".",
"inputWitnessSize",
"+=",
"witnessSize",
"\n",
"twe",
".",
"input... | // AddWitnessInput updates the weight estimate to account for an additional
// input spending a native pay-to-witness output. This accepts the total size
// of the witness as a parameter. | [
"AddWitnessInput",
"updates",
"the",
"weight",
"estimate",
"to",
"account",
"for",
"an",
"additional",
"input",
"spending",
"a",
"native",
"pay",
"-",
"to",
"-",
"witness",
"output",
".",
"This",
"accepts",
"the",
"total",
"size",
"of",
"the",
"witness",
"as... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/input/size.go#L414-L421 |
128,744 | lightningnetwork/lnd | input/size.go | AddNestedP2WKHInput | func (twe *TxWeightEstimator) AddNestedP2WKHInput() *TxWeightEstimator {
twe.inputSize += InputSize + P2WPKHSize
twe.inputWitnessSize += P2WKHWitnessSize
twe.inputSize++
twe.hasWitness = true
return twe
} | go | func (twe *TxWeightEstimator) AddNestedP2WKHInput() *TxWeightEstimator {
twe.inputSize += InputSize + P2WPKHSize
twe.inputWitnessSize += P2WKHWitnessSize
twe.inputSize++
twe.hasWitness = true
return twe
} | [
"func",
"(",
"twe",
"*",
"TxWeightEstimator",
")",
"AddNestedP2WKHInput",
"(",
")",
"*",
"TxWeightEstimator",
"{",
"twe",
".",
"inputSize",
"+=",
"InputSize",
"+",
"P2WPKHSize",
"\n",
"twe",
".",
"inputWitnessSize",
"+=",
"P2WKHWitnessSize",
"\n",
"twe",
".",
... | // AddNestedP2WKHInput updates the weight estimate to account for an additional
// input spending a P2SH output with a nested P2WKH redeem script. | [
"AddNestedP2WKHInput",
"updates",
"the",
"weight",
"estimate",
"to",
"account",
"for",
"an",
"additional",
"input",
"spending",
"a",
"P2SH",
"output",
"with",
"a",
"nested",
"P2WKH",
"redeem",
"script",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/input/size.go#L425-L432 |
128,745 | lightningnetwork/lnd | input/size.go | AddNestedP2WSHInput | func (twe *TxWeightEstimator) AddNestedP2WSHInput(witnessSize int) *TxWeightEstimator {
twe.inputSize += InputSize + P2WSHSize
twe.inputWitnessSize += witnessSize
twe.inputSize++
twe.hasWitness = true
return twe
} | go | func (twe *TxWeightEstimator) AddNestedP2WSHInput(witnessSize int) *TxWeightEstimator {
twe.inputSize += InputSize + P2WSHSize
twe.inputWitnessSize += witnessSize
twe.inputSize++
twe.hasWitness = true
return twe
} | [
"func",
"(",
"twe",
"*",
"TxWeightEstimator",
")",
"AddNestedP2WSHInput",
"(",
"witnessSize",
"int",
")",
"*",
"TxWeightEstimator",
"{",
"twe",
".",
"inputSize",
"+=",
"InputSize",
"+",
"P2WSHSize",
"\n",
"twe",
".",
"inputWitnessSize",
"+=",
"witnessSize",
"\n"... | // AddNestedP2WSHInput updates the weight estimate to account for an additional
// input spending a P2SH output with a nested P2WSH redeem script. | [
"AddNestedP2WSHInput",
"updates",
"the",
"weight",
"estimate",
"to",
"account",
"for",
"an",
"additional",
"input",
"spending",
"a",
"P2SH",
"output",
"with",
"a",
"nested",
"P2WSH",
"redeem",
"script",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/input/size.go#L436-L443 |
128,746 | lightningnetwork/lnd | input/size.go | AddP2PKHOutput | func (twe *TxWeightEstimator) AddP2PKHOutput() *TxWeightEstimator {
twe.outputSize += P2PKHOutputSize
twe.outputCount++
return twe
} | go | func (twe *TxWeightEstimator) AddP2PKHOutput() *TxWeightEstimator {
twe.outputSize += P2PKHOutputSize
twe.outputCount++
return twe
} | [
"func",
"(",
"twe",
"*",
"TxWeightEstimator",
")",
"AddP2PKHOutput",
"(",
")",
"*",
"TxWeightEstimator",
"{",
"twe",
".",
"outputSize",
"+=",
"P2PKHOutputSize",
"\n",
"twe",
".",
"outputCount",
"++",
"\n\n",
"return",
"twe",
"\n",
"}"
] | // AddP2PKHOutput updates the weight estimate to account for an additional P2PKH
// output. | [
"AddP2PKHOutput",
"updates",
"the",
"weight",
"estimate",
"to",
"account",
"for",
"an",
"additional",
"P2PKH",
"output",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/input/size.go#L447-L452 |
128,747 | lightningnetwork/lnd | input/size.go | AddP2WKHOutput | func (twe *TxWeightEstimator) AddP2WKHOutput() *TxWeightEstimator {
twe.outputSize += P2WKHOutputSize
twe.outputCount++
return twe
} | go | func (twe *TxWeightEstimator) AddP2WKHOutput() *TxWeightEstimator {
twe.outputSize += P2WKHOutputSize
twe.outputCount++
return twe
} | [
"func",
"(",
"twe",
"*",
"TxWeightEstimator",
")",
"AddP2WKHOutput",
"(",
")",
"*",
"TxWeightEstimator",
"{",
"twe",
".",
"outputSize",
"+=",
"P2WKHOutputSize",
"\n",
"twe",
".",
"outputCount",
"++",
"\n\n",
"return",
"twe",
"\n",
"}"
] | // AddP2WKHOutput updates the weight estimate to account for an additional
// native P2WKH output. | [
"AddP2WKHOutput",
"updates",
"the",
"weight",
"estimate",
"to",
"account",
"for",
"an",
"additional",
"native",
"P2WKH",
"output",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/input/size.go#L456-L461 |
128,748 | lightningnetwork/lnd | input/size.go | AddP2WSHOutput | func (twe *TxWeightEstimator) AddP2WSHOutput() *TxWeightEstimator {
twe.outputSize += P2WSHOutputSize
twe.outputCount++
return twe
} | go | func (twe *TxWeightEstimator) AddP2WSHOutput() *TxWeightEstimator {
twe.outputSize += P2WSHOutputSize
twe.outputCount++
return twe
} | [
"func",
"(",
"twe",
"*",
"TxWeightEstimator",
")",
"AddP2WSHOutput",
"(",
")",
"*",
"TxWeightEstimator",
"{",
"twe",
".",
"outputSize",
"+=",
"P2WSHOutputSize",
"\n",
"twe",
".",
"outputCount",
"++",
"\n\n",
"return",
"twe",
"\n",
"}"
] | // AddP2WSHOutput updates the weight estimate to account for an additional
// native P2WSH output. | [
"AddP2WSHOutput",
"updates",
"the",
"weight",
"estimate",
"to",
"account",
"for",
"an",
"additional",
"native",
"P2WSH",
"output",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/input/size.go#L465-L470 |
128,749 | lightningnetwork/lnd | input/size.go | AddP2SHOutput | func (twe *TxWeightEstimator) AddP2SHOutput() *TxWeightEstimator {
twe.outputSize += P2SHOutputSize
twe.outputCount++
return twe
} | go | func (twe *TxWeightEstimator) AddP2SHOutput() *TxWeightEstimator {
twe.outputSize += P2SHOutputSize
twe.outputCount++
return twe
} | [
"func",
"(",
"twe",
"*",
"TxWeightEstimator",
")",
"AddP2SHOutput",
"(",
")",
"*",
"TxWeightEstimator",
"{",
"twe",
".",
"outputSize",
"+=",
"P2SHOutputSize",
"\n",
"twe",
".",
"outputCount",
"++",
"\n\n",
"return",
"twe",
"\n",
"}"
] | // AddP2SHOutput updates the weight estimate to account for an additional P2SH
// output. | [
"AddP2SHOutput",
"updates",
"the",
"weight",
"estimate",
"to",
"account",
"for",
"an",
"additional",
"P2SH",
"output",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/input/size.go#L474-L479 |
128,750 | lightningnetwork/lnd | input/size.go | Weight | func (twe *TxWeightEstimator) Weight() int {
txSizeStripped := BaseTxSize +
wire.VarIntSerializeSize(uint64(twe.inputCount)) + twe.inputSize +
wire.VarIntSerializeSize(uint64(twe.outputCount)) + twe.outputSize
weight := txSizeStripped * witnessScaleFactor
if twe.hasWitness {
weight += WitnessHeaderSize + twe.i... | go | func (twe *TxWeightEstimator) Weight() int {
txSizeStripped := BaseTxSize +
wire.VarIntSerializeSize(uint64(twe.inputCount)) + twe.inputSize +
wire.VarIntSerializeSize(uint64(twe.outputCount)) + twe.outputSize
weight := txSizeStripped * witnessScaleFactor
if twe.hasWitness {
weight += WitnessHeaderSize + twe.i... | [
"func",
"(",
"twe",
"*",
"TxWeightEstimator",
")",
"Weight",
"(",
")",
"int",
"{",
"txSizeStripped",
":=",
"BaseTxSize",
"+",
"wire",
".",
"VarIntSerializeSize",
"(",
"uint64",
"(",
"twe",
".",
"inputCount",
")",
")",
"+",
"twe",
".",
"inputSize",
"+",
"... | // Weight gets the estimated weight of the transaction. | [
"Weight",
"gets",
"the",
"estimated",
"weight",
"of",
"the",
"transaction",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/input/size.go#L482-L491 |
128,751 | lightningnetwork/lnd | watchtower/wtserver/state_update.go | handleStateUpdates | func (s *Server) handleStateUpdates(peer Peer, id *wtdb.SessionID,
update *wtwire.StateUpdate) error {
// Set the current update to the first update read off the wire.
// Additional updates will be read if this value is set to nil after
// processing the first.
var curUpdate = update
for {
// If this is not th... | go | func (s *Server) handleStateUpdates(peer Peer, id *wtdb.SessionID,
update *wtwire.StateUpdate) error {
// Set the current update to the first update read off the wire.
// Additional updates will be read if this value is set to nil after
// processing the first.
var curUpdate = update
for {
// If this is not th... | [
"func",
"(",
"s",
"*",
"Server",
")",
"handleStateUpdates",
"(",
"peer",
"Peer",
",",
"id",
"*",
"wtdb",
".",
"SessionID",
",",
"update",
"*",
"wtwire",
".",
"StateUpdate",
")",
"error",
"{",
"// Set the current update to the first update read off the wire.",
"// ... | // handleStateUpdates processes a stream of StateUpdate requests from the
// client. The provided update should be the first such update read, subsequent
// updates will be consumed if the peer does not signal IsComplete on a
// particular update. | [
"handleStateUpdates",
"processes",
"a",
"stream",
"of",
"StateUpdate",
"requests",
"from",
"the",
"client",
".",
"The",
"provided",
"update",
"should",
"be",
"the",
"first",
"such",
"update",
"read",
"subsequent",
"updates",
"will",
"be",
"consumed",
"if",
"the"... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtserver/state_update.go#L14-L60 |
128,752 | lightningnetwork/lnd | watchtower/wtserver/state_update.go | handleStateUpdate | func (s *Server) handleStateUpdate(peer Peer, id *wtdb.SessionID,
update *wtwire.StateUpdate) error {
var (
lastApplied uint16
failCode wtwire.ErrorCode
err error
)
sessionUpdate := wtdb.SessionStateUpdate{
ID: *id,
Hint: update.Hint,
SeqNum: update.SeqNum,
Last... | go | func (s *Server) handleStateUpdate(peer Peer, id *wtdb.SessionID,
update *wtwire.StateUpdate) error {
var (
lastApplied uint16
failCode wtwire.ErrorCode
err error
)
sessionUpdate := wtdb.SessionStateUpdate{
ID: *id,
Hint: update.Hint,
SeqNum: update.SeqNum,
Last... | [
"func",
"(",
"s",
"*",
"Server",
")",
"handleStateUpdate",
"(",
"peer",
"Peer",
",",
"id",
"*",
"wtdb",
".",
"SessionID",
",",
"update",
"*",
"wtwire",
".",
"StateUpdate",
")",
"error",
"{",
"var",
"(",
"lastApplied",
"uint16",
"\n",
"failCode",
"wtwire"... | // handleStateUpdate processes a StateUpdate message request from a client. An
// attempt will be made to insert the update into the db, where it is validated
// against the client's session. The possible errors are then mapped back to
// StateUpdateCodes specified by the watchtower wire protocol, and sent back
// usin... | [
"handleStateUpdate",
"processes",
"a",
"StateUpdate",
"message",
"request",
"from",
"a",
"client",
".",
"An",
"attempt",
"will",
"be",
"made",
"to",
"insert",
"the",
"update",
"into",
"the",
"db",
"where",
"it",
"is",
"validated",
"against",
"the",
"client",
... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtserver/state_update.go#L67-L127 |
128,753 | lightningnetwork/lnd | watchtower/wtserver/state_update.go | replyStateUpdate | func (s *Server) replyStateUpdate(peer Peer, id *wtdb.SessionID,
code wtwire.StateUpdateCode, lastApplied uint16) error {
msg := &wtwire.StateUpdateReply{
Code: code,
LastApplied: lastApplied,
}
err := s.sendMessage(peer, msg)
if err != nil {
log.Errorf("unable to send StateUpdateReply to %s", id)
... | go | func (s *Server) replyStateUpdate(peer Peer, id *wtdb.SessionID,
code wtwire.StateUpdateCode, lastApplied uint16) error {
msg := &wtwire.StateUpdateReply{
Code: code,
LastApplied: lastApplied,
}
err := s.sendMessage(peer, msg)
if err != nil {
log.Errorf("unable to send StateUpdateReply to %s", id)
... | [
"func",
"(",
"s",
"*",
"Server",
")",
"replyStateUpdate",
"(",
"peer",
"Peer",
",",
"id",
"*",
"wtdb",
".",
"SessionID",
",",
"code",
"wtwire",
".",
"StateUpdateCode",
",",
"lastApplied",
"uint16",
")",
"error",
"{",
"msg",
":=",
"&",
"wtwire",
".",
"S... | // replyStateUpdate sends a response to a StateUpdate from a client. If the
// status code in the reply is OK, the error from the write will be bubbled up.
// Otherwise, this method returns a connection error to ensure we don't continue
// communication with the client. | [
"replyStateUpdate",
"sends",
"a",
"response",
"to",
"a",
"StateUpdate",
"from",
"a",
"client",
".",
"If",
"the",
"status",
"code",
"in",
"the",
"reply",
"is",
"OK",
"the",
"error",
"from",
"the",
"write",
"will",
"be",
"bubbled",
"up",
".",
"Otherwise",
... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtserver/state_update.go#L133-L157 |
128,754 | lightningnetwork/lnd | watchtower/wtclient/client.go | New | func New(config *Config) (*TowerClient, error) {
// Copy the config to prevent side-effects from modifying both the
// internal and external version of the Config.
cfg := new(Config)
*cfg = *config
// Set the read timeout to the default if none was provided.
if cfg.ReadTimeout <= 0 {
cfg.ReadTimeout = DefaultR... | go | func New(config *Config) (*TowerClient, error) {
// Copy the config to prevent side-effects from modifying both the
// internal and external version of the Config.
cfg := new(Config)
*cfg = *config
// Set the read timeout to the default if none was provided.
if cfg.ReadTimeout <= 0 {
cfg.ReadTimeout = DefaultR... | [
"func",
"New",
"(",
"config",
"*",
"Config",
")",
"(",
"*",
"TowerClient",
",",
"error",
")",
"{",
"// Copy the config to prevent side-effects from modifying both the",
"// internal and external version of the Config.",
"cfg",
":=",
"new",
"(",
"Config",
")",
"\n",
"*",... | // New initializes a new TowerClient from the provide Config. An error is
// returned if the client could not initialized. | [
"New",
"initializes",
"a",
"new",
"TowerClient",
"from",
"the",
"provide",
"Config",
".",
"An",
"error",
"is",
"returned",
"if",
"the",
"client",
"could",
"not",
"initialized",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/client.go#L169-L254 |
128,755 | lightningnetwork/lnd | watchtower/wtclient/client.go | Start | func (c *TowerClient) Start() error {
var err error
c.started.Do(func() {
log.Infof("Starting watchtower client")
// First, restart a session queue for any sessions that have
// committed but unacked state updates. This ensures that these
// sessions will be able to flush the committed updates after a
// r... | go | func (c *TowerClient) Start() error {
var err error
c.started.Do(func() {
log.Infof("Starting watchtower client")
// First, restart a session queue for any sessions that have
// committed but unacked state updates. This ensures that these
// sessions will be able to flush the committed updates after a
// r... | [
"func",
"(",
"c",
"*",
"TowerClient",
")",
"Start",
"(",
")",
"error",
"{",
"var",
"err",
"error",
"\n",
"c",
".",
"started",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n\n",
"// First, restart a session queue... | // Start initializes the watchtower client by loading or negotiating an active
// session and then begins processing backup tasks from the request pipeline. | [
"Start",
"initializes",
"the",
"watchtower",
"client",
"by",
"loading",
"or",
"negotiating",
"an",
"active",
"session",
"and",
"then",
"begins",
"processing",
"backup",
"tasks",
"from",
"the",
"request",
"pipeline",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/client.go#L258-L294 |
128,756 | lightningnetwork/lnd | watchtower/wtclient/client.go | Stop | func (c *TowerClient) Stop() error {
c.stopped.Do(func() {
log.Debugf("Stopping watchtower client")
// 1. Shutdown the backup queue, which will prevent any further
// updates from being accepted. In practice, the links should be
// shutdown before the client has been stopped, so all updates
// would have be... | go | func (c *TowerClient) Stop() error {
c.stopped.Do(func() {
log.Debugf("Stopping watchtower client")
// 1. Shutdown the backup queue, which will prevent any further
// updates from being accepted. In practice, the links should be
// shutdown before the client has been stopped, so all updates
// would have be... | [
"func",
"(",
"c",
"*",
"TowerClient",
")",
"Stop",
"(",
")",
"error",
"{",
"c",
".",
"stopped",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"log",
".",
"Debugf",
"(",
"\"",
"\"",
")",
"\n\n",
"// 1. Shutdown the backup queue, which will prevent any further",
"/... | // Stop idempotently initiates a graceful shutdown of the watchtower client. | [
"Stop",
"idempotently",
"initiates",
"a",
"graceful",
"shutdown",
"of",
"the",
"watchtower",
"client",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/client.go#L297-L351 |
128,757 | lightningnetwork/lnd | watchtower/wtclient/client.go | ForceQuit | func (c *TowerClient) ForceQuit() {
c.forced.Do(func() {
log.Infof("Force quitting watchtower client")
// 1. Shutdown the backup queue, which will prevent any further
// updates from being accepted. In practice, the links should be
// shutdown before the client has been stopped, so all updates
// would have... | go | func (c *TowerClient) ForceQuit() {
c.forced.Do(func() {
log.Infof("Force quitting watchtower client")
// 1. Shutdown the backup queue, which will prevent any further
// updates from being accepted. In practice, the links should be
// shutdown before the client has been stopped, so all updates
// would have... | [
"func",
"(",
"c",
"*",
"TowerClient",
")",
"ForceQuit",
"(",
")",
"{",
"c",
".",
"forced",
".",
"Do",
"(",
"func",
"(",
")",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n\n",
"// 1. Shutdown the backup queue, which will prevent any further",
"// update... | // ForceQuit idempotently initiates an unclean shutdown of the watchtower
// client. This should only be executed if Stop is unable to exit cleanly. | [
"ForceQuit",
"idempotently",
"initiates",
"an",
"unclean",
"shutdown",
"of",
"the",
"watchtower",
"client",
".",
"This",
"should",
"only",
"be",
"executed",
"if",
"Stop",
"is",
"unable",
"to",
"exit",
"cleanly",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/client.go#L355-L385 |
128,758 | lightningnetwork/lnd | watchtower/wtclient/client.go | RegisterChannel | func (c *TowerClient) RegisterChannel(chanID lnwire.ChannelID) error {
c.sweepPkScriptMu.Lock()
defer c.sweepPkScriptMu.Unlock()
// If a pkscript for this channel already exists, the channel has been
// previously registered.
if _, ok := c.sweepPkScripts[chanID]; ok {
return nil
}
// Otherwise, generate a ne... | go | func (c *TowerClient) RegisterChannel(chanID lnwire.ChannelID) error {
c.sweepPkScriptMu.Lock()
defer c.sweepPkScriptMu.Unlock()
// If a pkscript for this channel already exists, the channel has been
// previously registered.
if _, ok := c.sweepPkScripts[chanID]; ok {
return nil
}
// Otherwise, generate a ne... | [
"func",
"(",
"c",
"*",
"TowerClient",
")",
"RegisterChannel",
"(",
"chanID",
"lnwire",
".",
"ChannelID",
")",
"error",
"{",
"c",
".",
"sweepPkScriptMu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"sweepPkScriptMu",
".",
"Unlock",
"(",
")",
"\n\n",
... | // RegisterChannel persistently initializes any channel-dependent parameters
// within the client. This should be called during link startup to ensure that
// the client is able to support the link during operation. | [
"RegisterChannel",
"persistently",
"initializes",
"any",
"channel",
"-",
"dependent",
"parameters",
"within",
"the",
"client",
".",
"This",
"should",
"be",
"called",
"during",
"link",
"startup",
"to",
"ensure",
"that",
"the",
"client",
"is",
"able",
"to",
"suppo... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/client.go#L390-L419 |
128,759 | lightningnetwork/lnd | watchtower/wtclient/client.go | nextSessionQueue | func (c *TowerClient) nextSessionQueue() *sessionQueue {
// Select any candidate session at random, and remove it from the set of
// candidate sessions.
var candidateSession *wtdb.ClientSession
for id, sessionInfo := range c.candidateSessions {
delete(c.candidateSessions, id)
// Skip any sessions with policies... | go | func (c *TowerClient) nextSessionQueue() *sessionQueue {
// Select any candidate session at random, and remove it from the set of
// candidate sessions.
var candidateSession *wtdb.ClientSession
for id, sessionInfo := range c.candidateSessions {
delete(c.candidateSessions, id)
// Skip any sessions with policies... | [
"func",
"(",
"c",
"*",
"TowerClient",
")",
"nextSessionQueue",
"(",
")",
"*",
"sessionQueue",
"{",
"// Select any candidate session at random, and remove it from the set of",
"// candidate sessions.",
"var",
"candidateSession",
"*",
"wtdb",
".",
"ClientSession",
"\n",
"for"... | // nextSessionQueue attempts to fetch an active session from our set of
// candidate sessions. Candidate sessions with a differing policy from the
// active client's advertised policy will be ignored, but may be resumed if the
// client is restarted with a matching policy. If no candidates were found, nil
// is returne... | [
"nextSessionQueue",
"attempts",
"to",
"fetch",
"an",
"active",
"session",
"from",
"our",
"set",
"of",
"candidate",
"sessions",
".",
"Candidate",
"sessions",
"with",
"a",
"differing",
"policy",
"from",
"the",
"active",
"client",
"s",
"advertised",
"policy",
"will... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/client.go#L449-L477 |
128,760 | lightningnetwork/lnd | watchtower/wtclient/client.go | processTask | func (c *TowerClient) processTask(task *backupTask) {
status, accepted := c.sessionQueue.AcceptTask(task)
if accepted {
c.taskAccepted(task, status)
} else {
c.taskRejected(task, status)
}
} | go | func (c *TowerClient) processTask(task *backupTask) {
status, accepted := c.sessionQueue.AcceptTask(task)
if accepted {
c.taskAccepted(task, status)
} else {
c.taskRejected(task, status)
}
} | [
"func",
"(",
"c",
"*",
"TowerClient",
")",
"processTask",
"(",
"task",
"*",
"backupTask",
")",
"{",
"status",
",",
"accepted",
":=",
"c",
".",
"sessionQueue",
".",
"AcceptTask",
"(",
"task",
")",
"\n",
"if",
"accepted",
"{",
"c",
".",
"taskAccepted",
"... | // processTask attempts to schedule the given backupTask on the active
// sessionQueue. The task will either be accepted or rejected, afterwhich the
// appropriate modifications to the client's state machine will be made. After
// every invocation of processTask, the caller should ensure that the
// sessionQueue hasn't... | [
"processTask",
"attempts",
"to",
"schedule",
"the",
"given",
"backupTask",
"on",
"the",
"active",
"sessionQueue",
".",
"The",
"task",
"will",
"either",
"be",
"accepted",
"or",
"rejected",
"afterwhich",
"the",
"appropriate",
"modifications",
"to",
"the",
"client",
... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/client.go#L587-L594 |
128,761 | lightningnetwork/lnd | watchtower/wtclient/client.go | dial | func (c *TowerClient) dial(privKey *btcec.PrivateKey,
addr *lnwire.NetAddress) (wtserver.Peer, error) {
return c.cfg.AuthDial(privKey, addr, c.cfg.Dial)
} | go | func (c *TowerClient) dial(privKey *btcec.PrivateKey,
addr *lnwire.NetAddress) (wtserver.Peer, error) {
return c.cfg.AuthDial(privKey, addr, c.cfg.Dial)
} | [
"func",
"(",
"c",
"*",
"TowerClient",
")",
"dial",
"(",
"privKey",
"*",
"btcec",
".",
"PrivateKey",
",",
"addr",
"*",
"lnwire",
".",
"NetAddress",
")",
"(",
"wtserver",
".",
"Peer",
",",
"error",
")",
"{",
"return",
"c",
".",
"cfg",
".",
"AuthDial",
... | // dial connects the peer at addr using privKey as our secret key for the
// connection. The connection will use the configured Net's resolver to resolve
// the address for either Tor or clear net connections. | [
"dial",
"connects",
"the",
"peer",
"at",
"addr",
"using",
"privKey",
"as",
"our",
"secret",
"key",
"for",
"the",
"connection",
".",
"The",
"connection",
"will",
"use",
"the",
"configured",
"Net",
"s",
"resolver",
"to",
"resolve",
"the",
"address",
"for",
"... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/client.go#L687-L691 |
128,762 | lightningnetwork/lnd | watchtower/wtclient/client.go | newSessionQueue | func (c *TowerClient) newSessionQueue(s *wtdb.ClientSession) *sessionQueue {
return newSessionQueue(&sessionQueueConfig{
ClientSession: s,
ChainHash: c.cfg.ChainHash,
Dial: c.dial,
ReadMessage: c.readMessage,
SendMessage: c.sendMessage,
Signer: c.cfg.Signer,
DB: c.cfg.D... | go | func (c *TowerClient) newSessionQueue(s *wtdb.ClientSession) *sessionQueue {
return newSessionQueue(&sessionQueueConfig{
ClientSession: s,
ChainHash: c.cfg.ChainHash,
Dial: c.dial,
ReadMessage: c.readMessage,
SendMessage: c.sendMessage,
Signer: c.cfg.Signer,
DB: c.cfg.D... | [
"func",
"(",
"c",
"*",
"TowerClient",
")",
"newSessionQueue",
"(",
"s",
"*",
"wtdb",
".",
"ClientSession",
")",
"*",
"sessionQueue",
"{",
"return",
"newSessionQueue",
"(",
"&",
"sessionQueueConfig",
"{",
"ClientSession",
":",
"s",
",",
"ChainHash",
":",
"c",... | // newSessionQueue creates a sessionQueue from a ClientSession loaded from the
// database and supplying it with the resources needed by the client. | [
"newSessionQueue",
"creates",
"a",
"sessionQueue",
"from",
"a",
"ClientSession",
"loaded",
"from",
"the",
"database",
"and",
"supplying",
"it",
"with",
"the",
"resources",
"needed",
"by",
"the",
"client",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/client.go#L763-L775 |
128,763 | lightningnetwork/lnd | watchtower/wtclient/client.go | getOrInitActiveQueue | func (c *TowerClient) getOrInitActiveQueue(s *wtdb.ClientSession) *sessionQueue {
if sq, ok := c.activeSessions[s.ID]; ok {
return sq
}
return c.initActiveQueue(s)
} | go | func (c *TowerClient) getOrInitActiveQueue(s *wtdb.ClientSession) *sessionQueue {
if sq, ok := c.activeSessions[s.ID]; ok {
return sq
}
return c.initActiveQueue(s)
} | [
"func",
"(",
"c",
"*",
"TowerClient",
")",
"getOrInitActiveQueue",
"(",
"s",
"*",
"wtdb",
".",
"ClientSession",
")",
"*",
"sessionQueue",
"{",
"if",
"sq",
",",
"ok",
":=",
"c",
".",
"activeSessions",
"[",
"s",
".",
"ID",
"]",
";",
"ok",
"{",
"return"... | // getOrInitActiveQueue checks the activeSessions set for a sessionQueue for the
// passed ClientSession. If it exists, the active sessionQueue is returned.
// Otherwise a new sessionQueue is initialized and added to the set. | [
"getOrInitActiveQueue",
"checks",
"the",
"activeSessions",
"set",
"for",
"a",
"sessionQueue",
"for",
"the",
"passed",
"ClientSession",
".",
"If",
"it",
"exists",
"the",
"active",
"sessionQueue",
"is",
"returned",
".",
"Otherwise",
"a",
"new",
"sessionQueue",
"is",... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/client.go#L780-L786 |
128,764 | lightningnetwork/lnd | watchtower/wtclient/client.go | initActiveQueue | func (c *TowerClient) initActiveQueue(s *wtdb.ClientSession) *sessionQueue {
// Initialize the session queue, providing it with all of the resources
// it requires from the client instance.
sq := c.newSessionQueue(s)
// Add the session queue as an active session so that we remember to
// stop it on shutdown.
c.a... | go | func (c *TowerClient) initActiveQueue(s *wtdb.ClientSession) *sessionQueue {
// Initialize the session queue, providing it with all of the resources
// it requires from the client instance.
sq := c.newSessionQueue(s)
// Add the session queue as an active session so that we remember to
// stop it on shutdown.
c.a... | [
"func",
"(",
"c",
"*",
"TowerClient",
")",
"initActiveQueue",
"(",
"s",
"*",
"wtdb",
".",
"ClientSession",
")",
"*",
"sessionQueue",
"{",
"// Initialize the session queue, providing it with all of the resources",
"// it requires from the client instance.",
"sq",
":=",
"c",
... | // initActiveQueue creates a new sessionQueue from the passed ClientSession,
// adds the sessionQueue to the activeSessions set, and starts the sessionQueue
// so that it can deliver any committed updates or begin accepting newly
// assigned tasks. | [
"initActiveQueue",
"creates",
"a",
"new",
"sessionQueue",
"from",
"the",
"passed",
"ClientSession",
"adds",
"the",
"sessionQueue",
"to",
"the",
"activeSessions",
"set",
"and",
"starts",
"the",
"sessionQueue",
"so",
"that",
"it",
"can",
"deliver",
"any",
"committed... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/client.go#L792-L806 |
128,765 | lightningnetwork/lnd | watchtower/wtclient/client.go | logMessage | func logMessage(peer wtserver.Peer, msg wtwire.Message, read bool) {
var action = "Received"
var preposition = "from"
if !read {
action = "Sending"
preposition = "to"
}
summary := wtwire.MessageSummary(msg)
if len(summary) > 0 {
summary = "(" + summary + ")"
}
log.Debugf("%s %s%v %s %x@%s", action, msg.... | go | func logMessage(peer wtserver.Peer, msg wtwire.Message, read bool) {
var action = "Received"
var preposition = "from"
if !read {
action = "Sending"
preposition = "to"
}
summary := wtwire.MessageSummary(msg)
if len(summary) > 0 {
summary = "(" + summary + ")"
}
log.Debugf("%s %s%v %s %x@%s", action, msg.... | [
"func",
"logMessage",
"(",
"peer",
"wtserver",
".",
"Peer",
",",
"msg",
"wtwire",
".",
"Message",
",",
"read",
"bool",
")",
"{",
"var",
"action",
"=",
"\"",
"\"",
"\n",
"var",
"preposition",
"=",
"\"",
"\"",
"\n",
"if",
"!",
"read",
"{",
"action",
... | // logMessage writes information about a message received from a remote peer,
// using directional prepositions to signal whether the message was sent or
// received. | [
"logMessage",
"writes",
"information",
"about",
"a",
"message",
"received",
"from",
"a",
"remote",
"peer",
"using",
"directional",
"prepositions",
"to",
"signal",
"whether",
"the",
"message",
"was",
"sent",
"or",
"received",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtclient/client.go#L811-L827 |
128,766 | lightningnetwork/lnd | lnwallet/sigpool.go | NewSigPool | func NewSigPool(numWorkers int, signer input.Signer) *SigPool {
return &SigPool{
signer: signer,
numWorkers: numWorkers,
verifyJobs: make(chan VerifyJob, jobBuffer),
signJobs: make(chan SignJob, jobBuffer),
quit: make(chan struct{}),
}
} | go | func NewSigPool(numWorkers int, signer input.Signer) *SigPool {
return &SigPool{
signer: signer,
numWorkers: numWorkers,
verifyJobs: make(chan VerifyJob, jobBuffer),
signJobs: make(chan SignJob, jobBuffer),
quit: make(chan struct{}),
}
} | [
"func",
"NewSigPool",
"(",
"numWorkers",
"int",
",",
"signer",
"input",
".",
"Signer",
")",
"*",
"SigPool",
"{",
"return",
"&",
"SigPool",
"{",
"signer",
":",
"signer",
",",
"numWorkers",
":",
"numWorkers",
",",
"verifyJobs",
":",
"make",
"(",
"chan",
"V... | // NewSigPool creates a new signature pool with the specified number of
// workers. The recommended parameter for the number of works is the number of
// physical CPU cores available on the target machine. | [
"NewSigPool",
"creates",
"a",
"new",
"signature",
"pool",
"with",
"the",
"specified",
"number",
"of",
"workers",
".",
"The",
"recommended",
"parameter",
"for",
"the",
"number",
"of",
"works",
"is",
"the",
"number",
"of",
"physical",
"CPU",
"cores",
"available"... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/sigpool.go#L145-L153 |
128,767 | lightningnetwork/lnd | lnwallet/sigpool.go | Start | func (s *SigPool) Start() error {
if !atomic.CompareAndSwapUint32(&s.started, 0, 1) {
return nil
}
for i := 0; i < s.numWorkers; i++ {
s.wg.Add(1)
go s.poolWorker()
}
return nil
} | go | func (s *SigPool) Start() error {
if !atomic.CompareAndSwapUint32(&s.started, 0, 1) {
return nil
}
for i := 0; i < s.numWorkers; i++ {
s.wg.Add(1)
go s.poolWorker()
}
return nil
} | [
"func",
"(",
"s",
"*",
"SigPool",
")",
"Start",
"(",
")",
"error",
"{",
"if",
"!",
"atomic",
".",
"CompareAndSwapUint32",
"(",
"&",
"s",
".",
"started",
",",
"0",
",",
"1",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"for",
"i",
":=",
"0",
";... | // Start starts of all goroutines that the sigPool sig pool needs to
// carry out its duties. | [
"Start",
"starts",
"of",
"all",
"goroutines",
"that",
"the",
"sigPool",
"sig",
"pool",
"needs",
"to",
"carry",
"out",
"its",
"duties",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/sigpool.go#L157-L168 |
128,768 | lightningnetwork/lnd | lnwallet/sigpool.go | Stop | func (s *SigPool) Stop() error {
if !atomic.CompareAndSwapUint32(&s.stopped, 0, 1) {
return nil
}
close(s.quit)
s.wg.Wait()
return nil
} | go | func (s *SigPool) Stop() error {
if !atomic.CompareAndSwapUint32(&s.stopped, 0, 1) {
return nil
}
close(s.quit)
s.wg.Wait()
return nil
} | [
"func",
"(",
"s",
"*",
"SigPool",
")",
"Stop",
"(",
")",
"error",
"{",
"if",
"!",
"atomic",
".",
"CompareAndSwapUint32",
"(",
"&",
"s",
".",
"stopped",
",",
"0",
",",
"1",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"close",
"(",
"s",
".",
"q... | // Stop signals any active workers carrying out jobs to exit so the sigPool can
// gracefully shutdown. | [
"Stop",
"signals",
"any",
"active",
"workers",
"carrying",
"out",
"jobs",
"to",
"exit",
"so",
"the",
"sigPool",
"can",
"gracefully",
"shutdown",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/sigpool.go#L172-L181 |
128,769 | lightningnetwork/lnd | lnwallet/sigpool.go | poolWorker | func (s *SigPool) poolWorker() {
defer s.wg.Done()
for {
select {
// We've just received a new signature job. Given the items
// contained within the message, we'll craft a signature and
// send the result along with a possible error back to the
// caller.
case sigMsg := <-s.signJobs:
rawSig, err := ... | go | func (s *SigPool) poolWorker() {
defer s.wg.Done()
for {
select {
// We've just received a new signature job. Given the items
// contained within the message, we'll craft a signature and
// send the result along with a possible error back to the
// caller.
case sigMsg := <-s.signJobs:
rawSig, err := ... | [
"func",
"(",
"s",
"*",
"SigPool",
")",
"poolWorker",
"(",
")",
"{",
"defer",
"s",
".",
"wg",
".",
"Done",
"(",
")",
"\n\n",
"for",
"{",
"select",
"{",
"// We've just received a new signature job. Given the items",
"// contained within the message, we'll craft a signat... | // poolWorker is the main worker goroutine within the sigPool sig pool.
// Individual batches are distributed amongst each of the active workers. The
// workers then execute the task based on the type of job, and return the
// result back to caller. | [
"poolWorker",
"is",
"the",
"main",
"worker",
"goroutine",
"within",
"the",
"sigPool",
"sig",
"pool",
".",
"Individual",
"batches",
"are",
"distributed",
"amongst",
"each",
"of",
"the",
"active",
"workers",
".",
"The",
"workers",
"then",
"execute",
"the",
"task... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/sigpool.go#L187-L274 |
128,770 | lightningnetwork/lnd | lnwallet/sigpool.go | SubmitSignBatch | func (s *SigPool) SubmitSignBatch(signJobs []SignJob) {
for _, job := range signJobs {
select {
case s.signJobs <- job:
case <-job.Cancel:
// TODO(roasbeef): return error?
case <-s.quit:
return
}
}
} | go | func (s *SigPool) SubmitSignBatch(signJobs []SignJob) {
for _, job := range signJobs {
select {
case s.signJobs <- job:
case <-job.Cancel:
// TODO(roasbeef): return error?
case <-s.quit:
return
}
}
} | [
"func",
"(",
"s",
"*",
"SigPool",
")",
"SubmitSignBatch",
"(",
"signJobs",
"[",
"]",
"SignJob",
")",
"{",
"for",
"_",
",",
"job",
":=",
"range",
"signJobs",
"{",
"select",
"{",
"case",
"s",
".",
"signJobs",
"<-",
"job",
":",
"case",
"<-",
"job",
".... | // SubmitSignBatch submits a batch of signature jobs to the sigPool. The
// response and cancel channels for each of the SignJob's are expected to be
// fully populated, as the response for each job will be sent over the
// response channel within the job itself. | [
"SubmitSignBatch",
"submits",
"a",
"batch",
"of",
"signature",
"jobs",
"to",
"the",
"sigPool",
".",
"The",
"response",
"and",
"cancel",
"channels",
"for",
"each",
"of",
"the",
"SignJob",
"s",
"are",
"expected",
"to",
"be",
"fully",
"populated",
"as",
"the",
... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/sigpool.go#L280-L290 |
128,771 | lightningnetwork/lnd | lnwallet/sigpool.go | SubmitVerifyBatch | func (s *SigPool) SubmitVerifyBatch(verifyJobs []VerifyJob,
cancelChan chan struct{}) <-chan *HtlcIndexErr {
errChan := make(chan *HtlcIndexErr, len(verifyJobs))
for _, job := range verifyJobs {
job.Cancel = cancelChan
job.ErrResp = errChan
select {
case s.verifyJobs <- job:
case <-job.Cancel:
return... | go | func (s *SigPool) SubmitVerifyBatch(verifyJobs []VerifyJob,
cancelChan chan struct{}) <-chan *HtlcIndexErr {
errChan := make(chan *HtlcIndexErr, len(verifyJobs))
for _, job := range verifyJobs {
job.Cancel = cancelChan
job.ErrResp = errChan
select {
case s.verifyJobs <- job:
case <-job.Cancel:
return... | [
"func",
"(",
"s",
"*",
"SigPool",
")",
"SubmitVerifyBatch",
"(",
"verifyJobs",
"[",
"]",
"VerifyJob",
",",
"cancelChan",
"chan",
"struct",
"{",
"}",
")",
"<-",
"chan",
"*",
"HtlcIndexErr",
"{",
"errChan",
":=",
"make",
"(",
"chan",
"*",
"HtlcIndexErr",
"... | // SubmitVerifyBatch submits a batch of verification jobs to the sigPool. For
// each job submitted, an error will be passed into the returned channel
// denoting if signature verification was valid or not. The passed cancelChan
// allows the caller to cancel all pending jobs in the case that they wish to
// bail early... | [
"SubmitVerifyBatch",
"submits",
"a",
"batch",
"of",
"verification",
"jobs",
"to",
"the",
"sigPool",
".",
"For",
"each",
"job",
"submitted",
"an",
"error",
"will",
"be",
"passed",
"into",
"the",
"returned",
"channel",
"denoting",
"if",
"signature",
"verification"... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/lnwallet/sigpool.go#L297-L314 |
128,772 | lightningnetwork/lnd | watchtower/wtwire/message.go | String | func (m MessageType) String() string {
switch m {
case MsgInit:
return "Init"
case MsgCreateSession:
return "MsgCreateSession"
case MsgCreateSessionReply:
return "MsgCreateSessionReply"
case MsgStateUpdate:
return "MsgStateUpdate"
case MsgStateUpdateReply:
return "MsgStateUpdateReply"
case MsgDeleteSes... | go | func (m MessageType) String() string {
switch m {
case MsgInit:
return "Init"
case MsgCreateSession:
return "MsgCreateSession"
case MsgCreateSessionReply:
return "MsgCreateSessionReply"
case MsgStateUpdate:
return "MsgStateUpdate"
case MsgStateUpdateReply:
return "MsgStateUpdateReply"
case MsgDeleteSes... | [
"func",
"(",
"m",
"MessageType",
")",
"String",
"(",
")",
"string",
"{",
"switch",
"m",
"{",
"case",
"MsgInit",
":",
"return",
"\"",
"\"",
"\n",
"case",
"MsgCreateSession",
":",
"return",
"\"",
"\"",
"\n",
"case",
"MsgCreateSessionReply",
":",
"return",
... | // String returns a human readable description of the message type. | [
"String",
"returns",
"a",
"human",
"readable",
"description",
"of",
"the",
"message",
"type",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtwire/message.go#L53-L74 |
128,773 | lightningnetwork/lnd | watchtower/wtwire/message.go | WriteMessage | func WriteMessage(w io.Writer, msg Message, pver uint32) (int, error) {
totalBytes := 0
// Encode the message payload itself into a temporary buffer.
// TODO(roasbeef): create buffer pool
var bw bytes.Buffer
if err := msg.Encode(&bw, pver); err != nil {
return totalBytes, err
}
payload := bw.Bytes()
lenp := ... | go | func WriteMessage(w io.Writer, msg Message, pver uint32) (int, error) {
totalBytes := 0
// Encode the message payload itself into a temporary buffer.
// TODO(roasbeef): create buffer pool
var bw bytes.Buffer
if err := msg.Encode(&bw, pver); err != nil {
return totalBytes, err
}
payload := bw.Bytes()
lenp := ... | [
"func",
"WriteMessage",
"(",
"w",
"io",
".",
"Writer",
",",
"msg",
"Message",
",",
"pver",
"uint32",
")",
"(",
"int",
",",
"error",
")",
"{",
"totalBytes",
":=",
"0",
"\n\n",
"// Encode the message payload itself into a temporary buffer.",
"// TODO(roasbeef): create... | // WriteMessage writes a lightning Message to w including the necessary header
// information and returns the number of bytes written. | [
"WriteMessage",
"writes",
"a",
"lightning",
"Message",
"to",
"w",
"including",
"the",
"necessary",
"header",
"information",
"and",
"returns",
"the",
"number",
"of",
"bytes",
"written",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtwire/message.go#L126-L169 |
128,774 | lightningnetwork/lnd | watchtower/wtwire/message.go | ReadMessage | func ReadMessage(r io.Reader, pver uint32) (Message, error) {
// First, we'll read out the first two bytes of the message so we can
// create the proper empty message.
var mType [2]byte
if _, err := io.ReadFull(r, mType[:]); err != nil {
return nil, err
}
msgType := MessageType(binary.BigEndian.Uint16(mType[:]... | go | func ReadMessage(r io.Reader, pver uint32) (Message, error) {
// First, we'll read out the first two bytes of the message so we can
// create the proper empty message.
var mType [2]byte
if _, err := io.ReadFull(r, mType[:]); err != nil {
return nil, err
}
msgType := MessageType(binary.BigEndian.Uint16(mType[:]... | [
"func",
"ReadMessage",
"(",
"r",
"io",
".",
"Reader",
",",
"pver",
"uint32",
")",
"(",
"Message",
",",
"error",
")",
"{",
"// First, we'll read out the first two bytes of the message so we can",
"// create the proper empty message.",
"var",
"mType",
"[",
"2",
"]",
"by... | // ReadMessage reads, validates, and parses the next Watchtower message from r
// for the provided protocol version. | [
"ReadMessage",
"reads",
"validates",
"and",
"parses",
"the",
"next",
"Watchtower",
"message",
"from",
"r",
"for",
"the",
"provided",
"protocol",
"version",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/watchtower/wtwire/message.go#L173-L194 |
128,775 | lightningnetwork/lnd | channeldb/waitingproof.go | NewWaitingProofStore | func NewWaitingProofStore(db *DB) (*WaitingProofStore, error) {
s := &WaitingProofStore{
db: db,
cache: make(map[WaitingProofKey]struct{}),
}
if err := s.ForAll(func(proof *WaitingProof) error {
s.cache[proof.Key()] = struct{}{}
return nil
}); err != nil && err != ErrWaitingProofNotFound {
return nil,... | go | func NewWaitingProofStore(db *DB) (*WaitingProofStore, error) {
s := &WaitingProofStore{
db: db,
cache: make(map[WaitingProofKey]struct{}),
}
if err := s.ForAll(func(proof *WaitingProof) error {
s.cache[proof.Key()] = struct{}{}
return nil
}); err != nil && err != ErrWaitingProofNotFound {
return nil,... | [
"func",
"NewWaitingProofStore",
"(",
"db",
"*",
"DB",
")",
"(",
"*",
"WaitingProofStore",
",",
"error",
")",
"{",
"s",
":=",
"&",
"WaitingProofStore",
"{",
"db",
":",
"db",
",",
"cache",
":",
"make",
"(",
"map",
"[",
"WaitingProofKey",
"]",
"struct",
"... | // NewWaitingProofStore creates new instance of proofs storage. | [
"NewWaitingProofStore",
"creates",
"new",
"instance",
"of",
"proofs",
"storage",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/waitingproof.go#L43-L57 |
128,776 | lightningnetwork/lnd | channeldb/waitingproof.go | Add | func (s *WaitingProofStore) Add(proof *WaitingProof) error {
s.mu.Lock()
defer s.mu.Unlock()
err := s.db.Update(func(tx *bbolt.Tx) error {
var err error
var b bytes.Buffer
// Get or create the bucket.
bucket, err := tx.CreateBucketIfNotExists(waitingProofsBucketKey)
if err != nil {
return err
}
/... | go | func (s *WaitingProofStore) Add(proof *WaitingProof) error {
s.mu.Lock()
defer s.mu.Unlock()
err := s.db.Update(func(tx *bbolt.Tx) error {
var err error
var b bytes.Buffer
// Get or create the bucket.
bucket, err := tx.CreateBucketIfNotExists(waitingProofsBucketKey)
if err != nil {
return err
}
/... | [
"func",
"(",
"s",
"*",
"WaitingProofStore",
")",
"Add",
"(",
"proof",
"*",
"WaitingProof",
")",
"error",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"err",
":=",
"s",
".",
"db",
".... | // Add adds new waiting proof in the storage. | [
"Add",
"adds",
"new",
"waiting",
"proof",
"in",
"the",
"storage",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/waitingproof.go#L60-L92 |
128,777 | lightningnetwork/lnd | channeldb/waitingproof.go | Remove | func (s *WaitingProofStore) Remove(key WaitingProofKey) error {
s.mu.Lock()
defer s.mu.Unlock()
if _, ok := s.cache[key]; !ok {
return ErrWaitingProofNotFound
}
err := s.db.Update(func(tx *bbolt.Tx) error {
// Get or create the top bucket.
bucket := tx.Bucket(waitingProofsBucketKey)
if bucket == nil {
... | go | func (s *WaitingProofStore) Remove(key WaitingProofKey) error {
s.mu.Lock()
defer s.mu.Unlock()
if _, ok := s.cache[key]; !ok {
return ErrWaitingProofNotFound
}
err := s.db.Update(func(tx *bbolt.Tx) error {
// Get or create the top bucket.
bucket := tx.Bucket(waitingProofsBucketKey)
if bucket == nil {
... | [
"func",
"(",
"s",
"*",
"WaitingProofStore",
")",
"Remove",
"(",
"key",
"WaitingProofKey",
")",
"error",
"{",
"s",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"_",
",",
"ok",
":=",
"s",
... | // Remove removes the proof from storage by its key. | [
"Remove",
"removes",
"the",
"proof",
"from",
"storage",
"by",
"its",
"key",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/waitingproof.go#L95-L121 |
128,778 | lightningnetwork/lnd | channeldb/waitingproof.go | ForAll | func (s *WaitingProofStore) ForAll(cb func(*WaitingProof) error) error {
return s.db.View(func(tx *bbolt.Tx) error {
bucket := tx.Bucket(waitingProofsBucketKey)
if bucket == nil {
return ErrWaitingProofNotFound
}
// Iterate over objects buckets.
return bucket.ForEach(func(k, v []byte) error {
// Skip ... | go | func (s *WaitingProofStore) ForAll(cb func(*WaitingProof) error) error {
return s.db.View(func(tx *bbolt.Tx) error {
bucket := tx.Bucket(waitingProofsBucketKey)
if bucket == nil {
return ErrWaitingProofNotFound
}
// Iterate over objects buckets.
return bucket.ForEach(func(k, v []byte) error {
// Skip ... | [
"func",
"(",
"s",
"*",
"WaitingProofStore",
")",
"ForAll",
"(",
"cb",
"func",
"(",
"*",
"WaitingProof",
")",
"error",
")",
"error",
"{",
"return",
"s",
".",
"db",
".",
"View",
"(",
"func",
"(",
"tx",
"*",
"bbolt",
".",
"Tx",
")",
"error",
"{",
"b... | // ForAll iterates thought all waiting proofs and passing the waiting proof
// in the given callback. | [
"ForAll",
"iterates",
"thought",
"all",
"waiting",
"proofs",
"and",
"passing",
"the",
"waiting",
"proof",
"in",
"the",
"given",
"callback",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/waitingproof.go#L125-L148 |
128,779 | lightningnetwork/lnd | channeldb/waitingproof.go | Get | func (s *WaitingProofStore) Get(key WaitingProofKey) (*WaitingProof, error) {
proof := &WaitingProof{}
s.mu.RLock()
defer s.mu.RUnlock()
if _, ok := s.cache[key]; !ok {
return nil, ErrWaitingProofNotFound
}
err := s.db.View(func(tx *bbolt.Tx) error {
bucket := tx.Bucket(waitingProofsBucketKey)
if bucket ... | go | func (s *WaitingProofStore) Get(key WaitingProofKey) (*WaitingProof, error) {
proof := &WaitingProof{}
s.mu.RLock()
defer s.mu.RUnlock()
if _, ok := s.cache[key]; !ok {
return nil, ErrWaitingProofNotFound
}
err := s.db.View(func(tx *bbolt.Tx) error {
bucket := tx.Bucket(waitingProofsBucketKey)
if bucket ... | [
"func",
"(",
"s",
"*",
"WaitingProofStore",
")",
"Get",
"(",
"key",
"WaitingProofKey",
")",
"(",
"*",
"WaitingProof",
",",
"error",
")",
"{",
"proof",
":=",
"&",
"WaitingProof",
"{",
"}",
"\n\n",
"s",
".",
"mu",
".",
"RLock",
"(",
")",
"\n",
"defer",... | // Get returns the object which corresponds to the given index. | [
"Get",
"returns",
"the",
"object",
"which",
"corresponds",
"to",
"the",
"given",
"index",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/waitingproof.go#L151-L178 |
128,780 | lightningnetwork/lnd | channeldb/waitingproof.go | NewWaitingProof | func NewWaitingProof(isRemote bool, proof *lnwire.AnnounceSignatures) *WaitingProof {
return &WaitingProof{
AnnounceSignatures: proof,
isRemote: isRemote,
}
} | go | func NewWaitingProof(isRemote bool, proof *lnwire.AnnounceSignatures) *WaitingProof {
return &WaitingProof{
AnnounceSignatures: proof,
isRemote: isRemote,
}
} | [
"func",
"NewWaitingProof",
"(",
"isRemote",
"bool",
",",
"proof",
"*",
"lnwire",
".",
"AnnounceSignatures",
")",
"*",
"WaitingProof",
"{",
"return",
"&",
"WaitingProof",
"{",
"AnnounceSignatures",
":",
"proof",
",",
"isRemote",
":",
"isRemote",
",",
"}",
"\n",... | // NewWaitingProof constructs a new waiting prof instance. | [
"NewWaitingProof",
"constructs",
"a",
"new",
"waiting",
"prof",
"instance",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/waitingproof.go#L195-L200 |
128,781 | lightningnetwork/lnd | channeldb/waitingproof.go | OppositeKey | func (p *WaitingProof) OppositeKey() WaitingProofKey {
var key [9]byte
binary.BigEndian.PutUint64(key[:8], p.ShortChannelID.ToUint64())
if !p.isRemote {
key[8] = 1
}
return key
} | go | func (p *WaitingProof) OppositeKey() WaitingProofKey {
var key [9]byte
binary.BigEndian.PutUint64(key[:8], p.ShortChannelID.ToUint64())
if !p.isRemote {
key[8] = 1
}
return key
} | [
"func",
"(",
"p",
"*",
"WaitingProof",
")",
"OppositeKey",
"(",
")",
"WaitingProofKey",
"{",
"var",
"key",
"[",
"9",
"]",
"byte",
"\n",
"binary",
".",
"BigEndian",
".",
"PutUint64",
"(",
"key",
"[",
":",
"8",
"]",
",",
"p",
".",
"ShortChannelID",
"."... | // OppositeKey returns the key which uniquely identifies opposite waiting proof. | [
"OppositeKey",
"returns",
"the",
"key",
"which",
"uniquely",
"identifies",
"opposite",
"waiting",
"proof",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/waitingproof.go#L203-L211 |
128,782 | lightningnetwork/lnd | channeldb/waitingproof.go | Encode | func (p *WaitingProof) Encode(w io.Writer) error {
if err := binary.Write(w, byteOrder, p.isRemote); err != nil {
return err
}
if err := p.AnnounceSignatures.Encode(w, 0); err != nil {
return err
}
return nil
} | go | func (p *WaitingProof) Encode(w io.Writer) error {
if err := binary.Write(w, byteOrder, p.isRemote); err != nil {
return err
}
if err := p.AnnounceSignatures.Encode(w, 0); err != nil {
return err
}
return nil
} | [
"func",
"(",
"p",
"*",
"WaitingProof",
")",
"Encode",
"(",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"if",
"err",
":=",
"binary",
".",
"Write",
"(",
"w",
",",
"byteOrder",
",",
"p",
".",
"isRemote",
")",
";",
"err",
"!=",
"nil",
"{",
"return",... | // Encode writes the internal representation of waiting proof in byte stream. | [
"Encode",
"writes",
"the",
"internal",
"representation",
"of",
"waiting",
"proof",
"in",
"byte",
"stream",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/waitingproof.go#L225-L235 |
128,783 | lightningnetwork/lnd | channeldb/waitingproof.go | Decode | func (p *WaitingProof) Decode(r io.Reader) error {
if err := binary.Read(r, byteOrder, &p.isRemote); err != nil {
return err
}
msg := &lnwire.AnnounceSignatures{}
if err := msg.Decode(r, 0); err != nil {
return err
}
(*p).AnnounceSignatures = msg
return nil
} | go | func (p *WaitingProof) Decode(r io.Reader) error {
if err := binary.Read(r, byteOrder, &p.isRemote); err != nil {
return err
}
msg := &lnwire.AnnounceSignatures{}
if err := msg.Decode(r, 0); err != nil {
return err
}
(*p).AnnounceSignatures = msg
return nil
} | [
"func",
"(",
"p",
"*",
"WaitingProof",
")",
"Decode",
"(",
"r",
"io",
".",
"Reader",
")",
"error",
"{",
"if",
"err",
":=",
"binary",
".",
"Read",
"(",
"r",
",",
"byteOrder",
",",
"&",
"p",
".",
"isRemote",
")",
";",
"err",
"!=",
"nil",
"{",
"re... | // Decode reads the data from the byte stream and initializes the
// waiting proof object with it. | [
"Decode",
"reads",
"the",
"data",
"from",
"the",
"byte",
"stream",
"and",
"initializes",
"the",
"waiting",
"proof",
"object",
"with",
"it",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/channeldb/waitingproof.go#L239-L251 |
128,784 | lightningnetwork/lnd | routing/router.go | newRouteTuple | func newRouteTuple(amt lnwire.MilliSatoshi, dest []byte) routeTuple {
r := routeTuple{
amt: amt,
}
copy(r.dest[:], dest)
return r
} | go | func newRouteTuple(amt lnwire.MilliSatoshi, dest []byte) routeTuple {
r := routeTuple{
amt: amt,
}
copy(r.dest[:], dest)
return r
} | [
"func",
"newRouteTuple",
"(",
"amt",
"lnwire",
".",
"MilliSatoshi",
",",
"dest",
"[",
"]",
"byte",
")",
"routeTuple",
"{",
"r",
":=",
"routeTuple",
"{",
"amt",
":",
"amt",
",",
"}",
"\n",
"copy",
"(",
"r",
".",
"dest",
"[",
":",
"]",
",",
"dest",
... | // newRouteTuple creates a new route tuple from the target and amount. | [
"newRouteTuple",
"creates",
"a",
"new",
"route",
"tuple",
"from",
"the",
"target",
"and",
"amount",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/routing/router.go#L218-L225 |
128,785 | lightningnetwork/lnd | routing/router.go | newEdgeLocatorByPubkeys | func newEdgeLocatorByPubkeys(channelID uint64, fromNode, toNode *route.Vertex) *EdgeLocator {
// Determine direction based on lexicographical ordering of both
// pubkeys.
var direction uint8
if bytes.Compare(fromNode[:], toNode[:]) == 1 {
direction = 1
}
return &EdgeLocator{
ChannelID: channelID,
Direction... | go | func newEdgeLocatorByPubkeys(channelID uint64, fromNode, toNode *route.Vertex) *EdgeLocator {
// Determine direction based on lexicographical ordering of both
// pubkeys.
var direction uint8
if bytes.Compare(fromNode[:], toNode[:]) == 1 {
direction = 1
}
return &EdgeLocator{
ChannelID: channelID,
Direction... | [
"func",
"newEdgeLocatorByPubkeys",
"(",
"channelID",
"uint64",
",",
"fromNode",
",",
"toNode",
"*",
"route",
".",
"Vertex",
")",
"*",
"EdgeLocator",
"{",
"// Determine direction based on lexicographical ordering of both",
"// pubkeys.",
"var",
"direction",
"uint8",
"\n",
... | // newEdgeLocatorByPubkeys returns an edgeLocator based on its end point
// pubkeys. | [
"newEdgeLocatorByPubkeys",
"returns",
"an",
"edgeLocator",
"based",
"on",
"its",
"end",
"point",
"pubkeys",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/routing/router.go#L240-L252 |
128,786 | lightningnetwork/lnd | routing/router.go | newEdgeLocator | func newEdgeLocator(edge *channeldb.ChannelEdgePolicy) *EdgeLocator {
return &EdgeLocator{
ChannelID: edge.ChannelID,
Direction: uint8(edge.ChannelFlags & lnwire.ChanUpdateDirection),
}
} | go | func newEdgeLocator(edge *channeldb.ChannelEdgePolicy) *EdgeLocator {
return &EdgeLocator{
ChannelID: edge.ChannelID,
Direction: uint8(edge.ChannelFlags & lnwire.ChanUpdateDirection),
}
} | [
"func",
"newEdgeLocator",
"(",
"edge",
"*",
"channeldb",
".",
"ChannelEdgePolicy",
")",
"*",
"EdgeLocator",
"{",
"return",
"&",
"EdgeLocator",
"{",
"ChannelID",
":",
"edge",
".",
"ChannelID",
",",
"Direction",
":",
"uint8",
"(",
"edge",
".",
"ChannelFlags",
... | // newEdgeLocator extracts an edgeLocator based for a full edge policy
// structure. | [
"newEdgeLocator",
"extracts",
"an",
"edgeLocator",
"based",
"for",
"a",
"full",
"edge",
"policy",
"structure",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/routing/router.go#L256-L261 |
128,787 | lightningnetwork/lnd | routing/router.go | String | func (e *EdgeLocator) String() string {
return fmt.Sprintf("%v:%v", e.ChannelID, e.Direction)
} | go | func (e *EdgeLocator) String() string {
return fmt.Sprintf("%v:%v", e.ChannelID, e.Direction)
} | [
"func",
"(",
"e",
"*",
"EdgeLocator",
")",
"String",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"ChannelID",
",",
"e",
".",
"Direction",
")",
"\n",
"}"
] | // String returns a human readable version of the edgeLocator values. | [
"String",
"returns",
"a",
"human",
"readable",
"version",
"of",
"the",
"edgeLocator",
"values",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/routing/router.go#L264-L266 |
128,788 | lightningnetwork/lnd | routing/router.go | Start | func (r *ChannelRouter) Start() error {
if !atomic.CompareAndSwapUint32(&r.started, 0, 1) {
return nil
}
log.Tracef("Channel Router starting")
bestHash, bestHeight, err := r.cfg.Chain.GetBestBlock()
if err != nil {
return err
}
// If the graph has never been pruned, or hasn't fully been created yet,
// t... | go | func (r *ChannelRouter) Start() error {
if !atomic.CompareAndSwapUint32(&r.started, 0, 1) {
return nil
}
log.Tracef("Channel Router starting")
bestHash, bestHeight, err := r.cfg.Chain.GetBestBlock()
if err != nil {
return err
}
// If the graph has never been pruned, or hasn't fully been created yet,
// t... | [
"func",
"(",
"r",
"*",
"ChannelRouter",
")",
"Start",
"(",
")",
"error",
"{",
"if",
"!",
"atomic",
".",
"CompareAndSwapUint32",
"(",
"&",
"r",
".",
"started",
",",
"0",
",",
"1",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"log",
".",
"Tracef",
... | // Start launches all the goroutines the ChannelRouter requires to carry out
// its duties. If the router has already been started, then this method is a
// noop. | [
"Start",
"launches",
"all",
"the",
"goroutines",
"the",
"ChannelRouter",
"requires",
"to",
"carry",
"out",
"its",
"duties",
".",
"If",
"the",
"router",
"has",
"already",
"been",
"started",
"then",
"this",
"method",
"is",
"a",
"noop",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/routing/router.go#L377-L471 |
128,789 | lightningnetwork/lnd | routing/router.go | syncGraphWithChain | func (r *ChannelRouter) syncGraphWithChain() error {
// First, we'll need to check to see if we're already in sync with the
// latest state of the UTXO set.
bestHash, bestHeight, err := r.cfg.Chain.GetBestBlock()
if err != nil {
return err
}
r.bestHeight = uint32(bestHeight)
pruneHash, pruneHeight, err := r.c... | go | func (r *ChannelRouter) syncGraphWithChain() error {
// First, we'll need to check to see if we're already in sync with the
// latest state of the UTXO set.
bestHash, bestHeight, err := r.cfg.Chain.GetBestBlock()
if err != nil {
return err
}
r.bestHeight = uint32(bestHeight)
pruneHash, pruneHeight, err := r.c... | [
"func",
"(",
"r",
"*",
"ChannelRouter",
")",
"syncGraphWithChain",
"(",
")",
"error",
"{",
"// First, we'll need to check to see if we're already in sync with the",
"// latest state of the UTXO set.",
"bestHash",
",",
"bestHeight",
",",
"err",
":=",
"r",
".",
"cfg",
".",
... | // syncGraphWithChain attempts to synchronize the current channel graph with
// the latest UTXO set state. This process involves pruning from the channel
// graph any channels which have been closed by spending their funding output
// since we've been down. | [
"syncGraphWithChain",
"attempts",
"to",
"synchronize",
"the",
"current",
"channel",
"graph",
"with",
"the",
"latest",
"UTXO",
"set",
"state",
".",
"This",
"process",
"involves",
"pruning",
"from",
"the",
"channel",
"graph",
"any",
"channels",
"which",
"have",
"b... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/routing/router.go#L501-L629 |
128,790 | lightningnetwork/lnd | routing/router.go | assertNodeAnnFreshness | func (r *ChannelRouter) assertNodeAnnFreshness(node route.Vertex,
msgTimestamp time.Time) error {
// If we are not already aware of this node, it means that we don't
// know about any channel using this node. To avoid a DoS attack by
// node announcements, we will ignore such nodes. If we do know about
// this no... | go | func (r *ChannelRouter) assertNodeAnnFreshness(node route.Vertex,
msgTimestamp time.Time) error {
// If we are not already aware of this node, it means that we don't
// know about any channel using this node. To avoid a DoS attack by
// node announcements, we will ignore such nodes. If we do know about
// this no... | [
"func",
"(",
"r",
"*",
"ChannelRouter",
")",
"assertNodeAnnFreshness",
"(",
"node",
"route",
".",
"Vertex",
",",
"msgTimestamp",
"time",
".",
"Time",
")",
"error",
"{",
"// If we are not already aware of this node, it means that we don't",
"// know about any channel using t... | // assertNodeAnnFreshness returns a non-nil error if we have an announcement in
// the database for the passed node with a timestamp newer than the passed
// timestamp. ErrIgnored will be returned if we already have the node, and
// ErrOutdated will be returned if we have a timestamp that's after the new
// timestamp. | [
"assertNodeAnnFreshness",
"returns",
"a",
"non",
"-",
"nil",
"error",
"if",
"we",
"have",
"an",
"announcement",
"in",
"the",
"database",
"for",
"the",
"passed",
"node",
"with",
"a",
"timestamp",
"newer",
"than",
"the",
"passed",
"timestamp",
".",
"ErrIgnored",... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/routing/router.go#L977-L1006 |
128,791 | lightningnetwork/lnd | routing/router.go | pathsToFeeSortedRoutes | func pathsToFeeSortedRoutes(source route.Vertex, paths [][]*channeldb.ChannelEdgePolicy,
finalCLTVDelta uint16, amt lnwire.MilliSatoshi,
currentHeight uint32) ([]*route.Route, error) {
validRoutes := make([]*route.Route, 0, len(paths))
for _, path := range paths {
// Attempt to make the path into a route. We sni... | go | func pathsToFeeSortedRoutes(source route.Vertex, paths [][]*channeldb.ChannelEdgePolicy,
finalCLTVDelta uint16, amt lnwire.MilliSatoshi,
currentHeight uint32) ([]*route.Route, error) {
validRoutes := make([]*route.Route, 0, len(paths))
for _, path := range paths {
// Attempt to make the path into a route. We sni... | [
"func",
"pathsToFeeSortedRoutes",
"(",
"source",
"route",
".",
"Vertex",
",",
"paths",
"[",
"]",
"[",
"]",
"*",
"channeldb",
".",
"ChannelEdgePolicy",
",",
"finalCLTVDelta",
"uint16",
",",
"amt",
"lnwire",
".",
"MilliSatoshi",
",",
"currentHeight",
"uint32",
"... | // pathsToFeeSortedRoutes takes a set of paths, and returns a corresponding set
// of routes. A route differs from a path in that it has full time-lock and
// fee information attached. The set of routes returned may be less than the
// initial set of paths as it's possible we drop a route if it can't handle the
// tota... | [
"pathsToFeeSortedRoutes",
"takes",
"a",
"set",
"of",
"paths",
"and",
"returns",
"a",
"corresponding",
"set",
"of",
"routes",
".",
"A",
"route",
"differs",
"from",
"a",
"path",
"in",
"that",
"it",
"has",
"full",
"time",
"-",
"lock",
"and",
"fee",
"informati... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/routing/router.go#L1311-L1358 |
128,792 | lightningnetwork/lnd | routing/router.go | FindRoutes | func (r *ChannelRouter) FindRoutes(source, target route.Vertex,
amt lnwire.MilliSatoshi, restrictions *RestrictParams, numPaths uint32,
finalExpiry ...uint16) ([]*route.Route, error) {
var finalCLTVDelta uint16
if len(finalExpiry) == 0 {
finalCLTVDelta = zpay32.DefaultFinalCLTVDelta
} else {
finalCLTVDelta = ... | go | func (r *ChannelRouter) FindRoutes(source, target route.Vertex,
amt lnwire.MilliSatoshi, restrictions *RestrictParams, numPaths uint32,
finalExpiry ...uint16) ([]*route.Route, error) {
var finalCLTVDelta uint16
if len(finalExpiry) == 0 {
finalCLTVDelta = zpay32.DefaultFinalCLTVDelta
} else {
finalCLTVDelta = ... | [
"func",
"(",
"r",
"*",
"ChannelRouter",
")",
"FindRoutes",
"(",
"source",
",",
"target",
"route",
".",
"Vertex",
",",
"amt",
"lnwire",
".",
"MilliSatoshi",
",",
"restrictions",
"*",
"RestrictParams",
",",
"numPaths",
"uint32",
",",
"finalExpiry",
"...",
"uin... | // FindRoutes attempts to query the ChannelRouter for a bounded number
// available paths to a particular target destination which is able to send
// `amt` after factoring in channel capacities and cumulative fees along each
// route. To `numPaths eligible paths, we use a modified version of
// Yen's algorithm which i... | [
"FindRoutes",
"attempts",
"to",
"query",
"the",
"ChannelRouter",
"for",
"a",
"bounded",
"number",
"available",
"paths",
"to",
"a",
"particular",
"target",
"destination",
"which",
"is",
"able",
"to",
"send",
"amt",
"after",
"factoring",
"in",
"channel",
"capaciti... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/routing/router.go#L1369-L1454 |
128,793 | lightningnetwork/lnd | routing/router.go | generateSphinxPacket | func generateSphinxPacket(rt *route.Route, paymentHash []byte) ([]byte,
*sphinx.Circuit, error) {
// As a sanity check, we'll ensure that the set of hops has been
// properly filled in, otherwise, we won't actually be able to
// construct a route.
if len(rt.Hops) == 0 {
return nil, nil, route.ErrNoRouteHopsProv... | go | func generateSphinxPacket(rt *route.Route, paymentHash []byte) ([]byte,
*sphinx.Circuit, error) {
// As a sanity check, we'll ensure that the set of hops has been
// properly filled in, otherwise, we won't actually be able to
// construct a route.
if len(rt.Hops) == 0 {
return nil, nil, route.ErrNoRouteHopsProv... | [
"func",
"generateSphinxPacket",
"(",
"rt",
"*",
"route",
".",
"Route",
",",
"paymentHash",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"*",
"sphinx",
".",
"Circuit",
",",
"error",
")",
"{",
"// As a sanity check, we'll ensure that the set of hops has been... | // generateSphinxPacket generates then encodes a sphinx packet which encodes
// the onion route specified by the passed layer 3 route. The blob returned
// from this function can immediately be included within an HTLC add packet to
// be sent to the first hop within the route. | [
"generateSphinxPacket",
"generates",
"then",
"encodes",
"a",
"sphinx",
"packet",
"which",
"encodes",
"the",
"onion",
"route",
"specified",
"by",
"the",
"passed",
"layer",
"3",
"route",
".",
"The",
"blob",
"returned",
"from",
"this",
"function",
"can",
"immediate... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/routing/router.go#L1460-L1528 |
128,794 | lightningnetwork/lnd | routing/router.go | sendPaymentAttempt | func (r *ChannelRouter) sendPaymentAttempt(paySession *paymentSession,
route *route.Route, paymentHash [32]byte) ([32]byte, bool, error) {
log.Tracef("Attempting to send payment %x, using route: %v",
paymentHash, newLogClosure(func() string {
return spew.Sdump(route)
}),
)
preimage, err := r.sendToSwitch(r... | go | func (r *ChannelRouter) sendPaymentAttempt(paySession *paymentSession,
route *route.Route, paymentHash [32]byte) ([32]byte, bool, error) {
log.Tracef("Attempting to send payment %x, using route: %v",
paymentHash, newLogClosure(func() string {
return spew.Sdump(route)
}),
)
preimage, err := r.sendToSwitch(r... | [
"func",
"(",
"r",
"*",
"ChannelRouter",
")",
"sendPaymentAttempt",
"(",
"paySession",
"*",
"paymentSession",
",",
"route",
"*",
"route",
".",
"Route",
",",
"paymentHash",
"[",
"32",
"]",
"byte",
")",
"(",
"[",
"32",
"]",
"byte",
",",
"bool",
",",
"erro... | // sendPaymentAttempt tries to send the payment via the specified route. If
// successful, it returns the obtained preimage. If an error occurs, the last
// bool parameter indicates whether this is a final outcome or more attempts
// should be made. | [
"sendPaymentAttempt",
"tries",
"to",
"send",
"the",
"payment",
"via",
"the",
"specified",
"route",
".",
"If",
"successful",
"it",
"returns",
"the",
"obtained",
"preimage",
".",
"If",
"an",
"error",
"occurs",
"the",
"last",
"bool",
"parameter",
"indicates",
"wh... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/routing/router.go#L1722-L1742 |
128,795 | lightningnetwork/lnd | routing/router.go | sendToSwitch | func (r *ChannelRouter) sendToSwitch(route *route.Route, paymentHash [32]byte) (
[32]byte, error) {
// Generate the raw encoded sphinx packet to be included along
// with the htlcAdd message that we send directly to the
// switch.
onionBlob, circuit, err := generateSphinxPacket(
route, paymentHash[:],
)
if er... | go | func (r *ChannelRouter) sendToSwitch(route *route.Route, paymentHash [32]byte) (
[32]byte, error) {
// Generate the raw encoded sphinx packet to be included along
// with the htlcAdd message that we send directly to the
// switch.
onionBlob, circuit, err := generateSphinxPacket(
route, paymentHash[:],
)
if er... | [
"func",
"(",
"r",
"*",
"ChannelRouter",
")",
"sendToSwitch",
"(",
"route",
"*",
"route",
".",
"Route",
",",
"paymentHash",
"[",
"32",
"]",
"byte",
")",
"(",
"[",
"32",
"]",
"byte",
",",
"error",
")",
"{",
"// Generate the raw encoded sphinx packet to be incl... | // sendToSwitch sends a payment along the specified route and returns the
// obtained preimage. | [
"sendToSwitch",
"sends",
"a",
"payment",
"along",
"the",
"specified",
"route",
"and",
"returns",
"the",
"obtained",
"preimage",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/routing/router.go#L1746-L1778 |
128,796 | lightningnetwork/lnd | routing/router.go | getFailedEdge | func getFailedEdge(route *route.Route, errSource route.Vertex) (
*EdgeLocator, error) {
hopCount := len(route.Hops)
fromNode := route.SourcePubKey
for i, hop := range route.Hops {
toNode := hop.PubKeyBytes
// Determine if we have a failure from the final hop.
//
// TODO(joostjager): In this case, certain ... | go | func getFailedEdge(route *route.Route, errSource route.Vertex) (
*EdgeLocator, error) {
hopCount := len(route.Hops)
fromNode := route.SourcePubKey
for i, hop := range route.Hops {
toNode := hop.PubKeyBytes
// Determine if we have a failure from the final hop.
//
// TODO(joostjager): In this case, certain ... | [
"func",
"getFailedEdge",
"(",
"route",
"*",
"route",
".",
"Route",
",",
"errSource",
"route",
".",
"Vertex",
")",
"(",
"*",
"EdgeLocator",
",",
"error",
")",
"{",
"hopCount",
":=",
"len",
"(",
"route",
".",
"Hops",
")",
"\n",
"fromNode",
":=",
"route",... | // getFailedEdge tries to locate the failing channel given a route and the
// pubkey of the node that sent the error. It will assume that the error is
// associated with the outgoing channel of the error node. | [
"getFailedEdge",
"tries",
"to",
"locate",
"the",
"failing",
"channel",
"given",
"a",
"route",
"and",
"the",
"pubkey",
"of",
"the",
"node",
"that",
"sent",
"the",
"error",
".",
"It",
"will",
"assume",
"that",
"the",
"error",
"is",
"associated",
"with",
"the... | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/routing/router.go#L2011-L2045 |
128,797 | lightningnetwork/lnd | routing/router.go | applyChannelUpdate | func (r *ChannelRouter) applyChannelUpdate(msg *lnwire.ChannelUpdate,
pubKey *btcec.PublicKey) bool {
// If we get passed a nil channel update (as it's optional with some
// onion errors), then we'll exit early with a success result.
if msg == nil {
return true
}
ch, _, _, err := r.GetChannelByID(msg.ShortChan... | go | func (r *ChannelRouter) applyChannelUpdate(msg *lnwire.ChannelUpdate,
pubKey *btcec.PublicKey) bool {
// If we get passed a nil channel update (as it's optional with some
// onion errors), then we'll exit early with a success result.
if msg == nil {
return true
}
ch, _, _, err := r.GetChannelByID(msg.ShortChan... | [
"func",
"(",
"r",
"*",
"ChannelRouter",
")",
"applyChannelUpdate",
"(",
"msg",
"*",
"lnwire",
".",
"ChannelUpdate",
",",
"pubKey",
"*",
"btcec",
".",
"PublicKey",
")",
"bool",
"{",
"// If we get passed a nil channel update (as it's optional with some",
"// onion errors)... | // applyChannelUpdate validates a channel update and if valid, applies it to the
// database. It returns a bool indicating whether the updates was successful. | [
"applyChannelUpdate",
"validates",
"a",
"channel",
"update",
"and",
"if",
"valid",
"applies",
"it",
"to",
"the",
"database",
".",
"It",
"returns",
"a",
"bool",
"indicating",
"whether",
"the",
"updates",
"was",
"successful",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/routing/router.go#L2049-L2086 |
128,798 | lightningnetwork/lnd | contractcourt/briefcase.go | String | func (a ArbitratorState) String() string {
switch a {
case StateDefault:
return "StateDefault"
case StateBroadcastCommit:
return "StateBroadcastCommit"
case StateCommitmentBroadcasted:
return "StateCommitmentBroadcasted"
case StateContractClosed:
return "StateContractClosed"
case StateWaitingFullResol... | go | func (a ArbitratorState) String() string {
switch a {
case StateDefault:
return "StateDefault"
case StateBroadcastCommit:
return "StateBroadcastCommit"
case StateCommitmentBroadcasted:
return "StateCommitmentBroadcasted"
case StateContractClosed:
return "StateContractClosed"
case StateWaitingFullResol... | [
"func",
"(",
"a",
"ArbitratorState",
")",
"String",
"(",
")",
"string",
"{",
"switch",
"a",
"{",
"case",
"StateDefault",
":",
"return",
"\"",
"\"",
"\n\n",
"case",
"StateBroadcastCommit",
":",
"return",
"\"",
"\"",
"\n\n",
"case",
"StateCommitmentBroadcasted",... | // String returns a human readable string describing the ArbitratorState. | [
"String",
"returns",
"a",
"human",
"readable",
"string",
"describing",
"the",
"ArbitratorState",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/contractcourt/briefcase.go#L144-L170 |
128,799 | lightningnetwork/lnd | contractcourt/briefcase.go | newResolverID | func newResolverID(op wire.OutPoint) resolverID {
var r resolverID
copy(r[:], op.Hash[:])
endian.PutUint32(r[32:], op.Index)
return r
} | go | func newResolverID(op wire.OutPoint) resolverID {
var r resolverID
copy(r[:], op.Hash[:])
endian.PutUint32(r[32:], op.Index)
return r
} | [
"func",
"newResolverID",
"(",
"op",
"wire",
".",
"OutPoint",
")",
"resolverID",
"{",
"var",
"r",
"resolverID",
"\n\n",
"copy",
"(",
"r",
"[",
":",
"]",
",",
"op",
".",
"Hash",
"[",
":",
"]",
")",
"\n\n",
"endian",
".",
"PutUint32",
"(",
"r",
"[",
... | // newResolverID returns a resolverID given the outpoint of a contract. | [
"newResolverID",
"returns",
"a",
"resolverID",
"given",
"the",
"outpoint",
"of",
"a",
"contract",
"."
] | 1acd38e48c168b86c291524eb56b8fcdf04a910c | https://github.com/lightningnetwork/lnd/blob/1acd38e48c168b86c291524eb56b8fcdf04a910c/contractcourt/briefcase.go#L209-L217 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.