Skip to content

Commit 8fbe65b

Browse files
committed
dataformat: use wire.NewOutPointFromString
1 parent ecfc83e commit 8fbe65b

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

dataformat/summary.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"strings"
99

1010
"github.com/btcsuite/btcd/btcec/v2"
11+
"github.com/btcsuite/btcd/wire"
1112
"github.com/lightningnetwork/lnd/keychain"
1213
)
1314

@@ -109,16 +110,10 @@ func ExtractSummaryFromDump(data string) ([]*SummaryEntry, error) {
109110
for _, match := range matches {
110111
if len(match) == 5 {
111112
chanPoint := strings.TrimSpace(match[1])
112-
chanPointParts := strings.Split(chanPoint, ":")
113-
if len(chanPointParts) != 2 {
114-
return nil, fmt.Errorf("invalid chanPoint: %s",
115-
chanPoint)
116-
}
117-
txid := chanPointParts[0]
118-
index, err := strconv.Atoi(chanPointParts[1])
113+
parsedOP, err := wire.NewOutPointFromString(chanPoint)
119114
if err != nil {
120115
return nil, fmt.Errorf("unable to parse "+
121-
"index: %w", err)
116+
"outpoint: %w", err)
122117
}
123118

124119
capacity, err := strconv.ParseFloat(match[3], 64)
@@ -130,8 +125,8 @@ func ExtractSummaryFromDump(data string) ([]*SummaryEntry, error) {
130125
results = append(results, &SummaryEntry{
131126
RemotePubkey: match[2],
132127
ChannelPoint: chanPoint,
133-
FundingTXID: txid,
134-
FundingTXIndex: uint32(index),
128+
FundingTXID: parsedOP.Hash.String(),
129+
FundingTXIndex: parsedOP.Index,
135130
Capacity: uint64(
136131
capacity * 1e8,
137132
),

0 commit comments

Comments
 (0)