routing: Route String() method
This commit is contained in:
parent
35003bd87c
commit
3db48dc53f
@ -3,6 +3,8 @@ package route
|
|||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcec"
|
"github.com/btcsuite/btcd/btcec"
|
||||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||||
@ -180,3 +182,20 @@ func (r *Route) ToSphinxPath() (*sphinx.PaymentPath, error) {
|
|||||||
|
|
||||||
return &path, nil
|
return &path, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// String returns a human readable representation of the route.
|
||||||
|
func (r *Route) String() string {
|
||||||
|
var b strings.Builder
|
||||||
|
|
||||||
|
for i, hop := range r.Hops {
|
||||||
|
if i > 0 {
|
||||||
|
b.WriteString(",")
|
||||||
|
}
|
||||||
|
b.WriteString(strconv.FormatUint(hop.ChannelID, 10))
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf("amt=%v, fees=%v, tl=%v, chans=%v",
|
||||||
|
r.TotalAmount-r.TotalFees(), r.TotalFees(), r.TotalTimeLock,
|
||||||
|
b.String(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user