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

lightningnetwork / lnd / 11388202384

17 Oct 2024 03:31PM UTC coverage: 58.81% (-0.07%) from 58.884%
11388202384

push

github

web-flow
Merge pull request #9196 from lightningnetwork/fn-context-guard

fn: add ContextGuard from tapd repo

131011 of 222771 relevant lines covered (58.81%)

28214.75 hits per line

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

62.86
/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.
11
func backendSupportsTaproot(rpc *rpcclient.Client) bool {
2✔
12
        // First, we'll try to access the normal getblockchaininfo call.
2✔
13
        chainInfo, err := rpc.GetBlockChainInfo()
2✔
14
        if err == nil {
4✔
15
                // If this call worked, then we'll check that the taproot
2✔
16
                // deployment is defined.
2✔
17
                switch {
2✔
18
                // Bitcoind versions before 0.19 and also btcd use the
19
                // SoftForks fields.
20
                case chainInfo.SoftForks != nil:
×
21
                        _, ok := chainInfo.SoftForks.Bip9SoftForks["taproot"]
×
22
                        if ok {
×
23
                                return ok
×
24
                        }
×
25

26
                // Bitcoind versions after 0.19 will use the UnifiedSoftForks
27
                // field that factors in the set of "buried" soft forks.
28
                case chainInfo.UnifiedSoftForks != nil:
2✔
29
                        _, ok := chainInfo.UnifiedSoftForks.SoftForks["taproot"]
2✔
30
                        if ok {
2✔
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.
44
        resp, err := rpc.RawRequest("getdeploymentinfo", nil)
2✔
45
        if err != nil {
2✔
46
                log.Warnf("unable to make getdeploymentinfo request: %v", err)
×
47
                return false
×
48
        }
×
49

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

62
        _, ok := info.Deployments["taproot"]
2✔
63
        return ok
2✔
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