• 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

0.0
/chainreg/taproot_check.go
1
package chainreg
2

3
import (
4
        "encoding/json"
5

6
        "github.com/btcsuite/btcd/rpcclient"
7
)
8

9
// backendSupportsTaproot returns true if the backend understands the taproot
10
// soft fork.
UNCOV
11
func backendSupportsTaproot(rpc *rpcclient.Client) bool {
×
UNCOV
12
        // First, we'll try to access the normal getblockchaininfo call.
×
UNCOV
13
        chainInfo, err := rpc.GetBlockChainInfo()
×
UNCOV
14
        if err == nil {
×
UNCOV
15
                // If this call worked, then we'll check that the taproot
×
UNCOV
16
                // deployment is defined.
×
UNCOV
17
                switch {
×
18
                // Bitcoind versions before 0.19 and also btcd use the
19
                // SoftForks fields.
UNCOV
20
                case chainInfo.SoftForks != nil:
×
UNCOV
21
                        _, ok := chainInfo.SoftForks.Bip9SoftForks["taproot"]
×
UNCOV
22
                        if ok {
×
UNCOV
23
                                return ok
×
UNCOV
24
                        }
×
25

26
                // Bitcoind versions after 0.19 will use the UnifiedSoftForks
27
                // field that factors in the set of "buried" soft forks.
UNCOV
28
                case chainInfo.UnifiedSoftForks != nil:
×
UNCOV
29
                        _, ok := chainInfo.UnifiedSoftForks.SoftForks["taproot"]
×
UNCOV
30
                        if ok {
×
31
                                return ok
×
32
                        }
×
33
                }
34
        }
35

36
        // The user might be running a newer version of bitcoind that doesn't
37
        // implement the getblockchaininfo call any longer, so we'll fall back
38
        // here.
39
        //
40
        // Alternatively, the fork wasn't specified, but the user might be
41
        // running a newer version of bitcoind that still has the
42
        // getblockchaininfo call, but doesn't populate the data, so we'll hit
43
        // the new getdeploymentinfo call.
UNCOV
44
        resp, err := rpc.RawRequest("getdeploymentinfo", nil)
×
UNCOV
45
        if err != nil {
×
46
                log.Warnf("unable to make getdeploymentinfo request: %v", err)
×
47
                return false
×
48
        }
×
49

UNCOV
50
        info := struct {
×
UNCOV
51
                Deployments map[string]struct {
×
UNCOV
52
                        Type   string `json:"type"`
×
UNCOV
53
                        Active bool   `json:"active"`
×
UNCOV
54
                        Height int32  `json:"height"`
×
UNCOV
55
                } `json:"deployments"`
×
UNCOV
56
        }{}
×
UNCOV
57
        if err := json.Unmarshal(resp, &info); err != nil {
×
58
                log.Warnf("unable to decode getdeploymentinfo resp: %v", err)
×
59
                return false
×
60
        }
×
61

UNCOV
62
        _, ok := info.Deployments["taproot"]
×
UNCOV
63
        return ok
×
64
}
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