-
Notifications
You must be signed in to change notification settings - Fork 29
/
close_report.go
42 lines (37 loc) · 1.23 KB
/
close_report.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package frdrpcserver
import (
"context"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg/chainhash"
"github.com/lightninglabs/faraday/fees"
"github.com/lightninglabs/faraday/frdrpc"
"github.com/lightninglabs/faraday/resolutions"
"github.com/lightninglabs/lndclient"
)
func parseCloseReportRequest(ctx context.Context, cfg *Config) *resolutions.Config {
return &resolutions.Config{
ClosedChannels: func() ([]lndclient.ClosedChannel, error) {
return cfg.Lnd.Client.ClosedChannels(ctx)
},
GetTxDetail: cfg.BitcoinClient.GetTxDetail,
WalletTransactions: func() ([]lndclient.Transaction, error) {
return cfg.Lnd.Client.ListTransactions(ctx, 0, 0)
},
CalculateFees: func(hash *chainhash.Hash) (btcutil.Amount, error) {
return fees.CalculateFee(
cfg.BitcoinClient.GetTxDetail, hash,
)
},
}
}
func rpcCloseReportResponse(
report *resolutions.CloseReport) *frdrpc.CloseReportResponse {
return &frdrpc.CloseReportResponse{
ChannelPoint: report.ChannelPoint.String(),
ChannelInitiator: report.ChannelInitiator,
CloseType: report.CloseType.String(),
CloseTxid: report.CloseTxid,
OpenFee: report.OpenFee.String(),
CloseFee: report.CloseFee.String(),
}
}