• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lightningnetwork / lnd / 12343072627

15 Dec 2024 11:09PM UTC coverage: 57.504% (-1.1%) from 58.636%
12343072627

Pull #9315

github

yyforyongyu
contractcourt: offer outgoing htlc one block earlier before its expiry

We need to offer the outgoing htlc one block earlier to make sure when
the expiry height hits, the sweeper will not miss sweeping it in the
same block. This also means the outgoing contest resolver now only does
one thing - watch for preimage spend till height expiry-1, which can
easily be moved into the timeout resolver instead in the future.
Pull Request #9315: Implement `blockbeat`

1445 of 2007 new or added lines in 26 files covered. (72.0%)

19246 existing lines in 249 files now uncovered.

102342 of 177975 relevant lines covered (57.5%)

24772.24 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

61.9
/netann/node_signer.go
1
package netann
2

3
import (
4
        "fmt"
5

6
        "github.com/btcsuite/btcd/btcec/v2/ecdsa"
7
        "github.com/lightningnetwork/lnd/keychain"
8
        "github.com/lightningnetwork/lnd/lnwallet"
9
)
10

11
// NodeSigner is an implementation of the MessageSigner interface backed by the
12
// identity private key of running lnd node.
13
type NodeSigner struct {
14
        keySigner keychain.SingleKeyMessageSigner
15
}
16

17
// NewNodeSigner creates a new instance of the NodeSigner backed by the target
18
// private key.
19
func NewNodeSigner(keySigner keychain.SingleKeyMessageSigner) *NodeSigner {
42✔
20
        return &NodeSigner{
42✔
21
                keySigner: keySigner,
42✔
22
        }
42✔
23
}
42✔
24

25
// SignMessage signs a double-sha256 digest of the passed msg under the
26
// resident node's private key described in the key locator. If the target key
27
// locator is _not_ the node's private key, then an error will be returned.
28
func (n *NodeSigner) SignMessage(keyLoc keychain.KeyLocator,
29
        msg []byte, doubleHash bool) (*ecdsa.Signature, error) {
100✔
30

100✔
31
        // If this isn't our identity public key, then we'll exit early with an
100✔
32
        // error as we can't sign with this key.
100✔
33
        if keyLoc != n.keySigner.KeyLocator() {
100✔
34
                return nil, fmt.Errorf("unknown public key locator")
×
35
        }
×
36

37
        // Otherwise, we'll sign the double-sha256 of the target message.
38
        sig, err := n.keySigner.SignMessage(msg, doubleHash)
100✔
39
        if err != nil {
100✔
40
                return nil, fmt.Errorf("can't sign the message: %w", err)
×
41
        }
×
42

43
        return sig, nil
100✔
44
}
45

46
// SignMessageCompact signs a single or double sha256 digest of the msg
47
// parameter under the resident node's private key. The returned signature is a
48
// pubkey-recoverable signature.
49
func (n *NodeSigner) SignMessageCompact(msg []byte, doubleHash bool) ([]byte,
UNCOV
50
        error) {
×
UNCOV
51

×
UNCOV
52
        return n.keySigner.SignMessageCompact(msg, doubleHash)
×
UNCOV
53
}
×
54

55
// A compile time check to ensure that NodeSigner implements the MessageSigner
56
// interface.
57
var _ lnwallet.MessageSigner = (*NodeSigner)(nil)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc