zpay32: move HopHint and DefaultFinalCLTVDelta

This commit is contained in:
Joost Jager
2019-02-19 09:09:01 +01:00
parent 652ebb1652
commit 2be1051fb6
11 changed files with 70 additions and 66 deletions

View File

@@ -13,7 +13,6 @@ import (
"github.com/btcsuite/btcutil"
"github.com/btcsuite/btcutil/bech32"
"github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing"
)
const (
@@ -146,7 +145,7 @@ type Invoice struct {
// represent private routes.
//
// NOTE: This is optional.
RouteHints [][]routing.HopHint
RouteHints [][]HopHint
}
// Amount is a functional option that allows callers of NewInvoice to set the
@@ -214,7 +213,7 @@ func FallbackAddr(fallbackAddr btcutil.Address) func(*Invoice) {
// RouteHint is a functional option that allows callers of NewInvoice to add
// one or more hop hints that represent a private route to the destination.
func RouteHint(routeHint []routing.HopHint) func(*Invoice) {
func RouteHint(routeHint []HopHint) func(*Invoice) {
return func(i *Invoice) {
i.RouteHints = append(i.RouteHints, routeHint)
}
@@ -476,7 +475,7 @@ func (invoice *Invoice) MinFinalCLTVExpiry() uint64 {
return *invoice.minFinalCLTVExpiry
}
return routing.DefaultFinalCLTVDelta
return DefaultFinalCLTVDelta
}
// validateInvoice does a sanity check of the provided Invoice, making sure it
@@ -843,7 +842,7 @@ func parseFallbackAddr(data []byte, net *chaincfg.Params) (btcutil.Address, erro
// parseRouteHint converts the data (encoded in base32) into an array containing
// one or more routing hop hints that represent a single route hint.
func parseRouteHint(data []byte) ([]routing.HopHint, error) {
func parseRouteHint(data []byte) ([]HopHint, error) {
base256Data, err := bech32.ConvertBits(data, 5, 8, false)
if err != nil {
return nil, err
@@ -854,10 +853,10 @@ func parseRouteHint(data []byte) ([]routing.HopHint, error) {
"got %d", hopHintLen, len(base256Data))
}
var routeHint []routing.HopHint
var routeHint []HopHint
for len(base256Data) > 0 {
hopHint := routing.HopHint{}
hopHint := HopHint{}
hopHint.NodeID, err = btcec.ParsePubKey(base256Data[:33], btcec.S256())
if err != nil {
return nil, err