channeldb+routing: expose HTLCs in payment subscriptions

This commit modifies the FetchPayment method to return MPPayment structs
converted from the legacy on-disk format. This allows us to attach the
HTLCs to the events given to clients subscribing to the outcome of an
HTLC.

This commit also bubbles up to the routerrpc/router_server, by
populating HTLCAttempts in the response and extracting the legacy route
field from the HTLCAttempts.
This commit is contained in:
Conner Fromknecht
2019-11-08 03:39:51 -08:00
parent 68916eb4b7
commit 063f24f2ed
6 changed files with 143 additions and 86 deletions

View File

@@ -337,7 +337,7 @@ func (db *DB) FetchPayments() ([]*MPPayment, error) {
return err
}
payments = append(payments, p.ToMPPayment())
payments = append(payments, p)
// For older versions of lnd, duplicate payments to a
// payment has was possible. These will be found in a
@@ -362,7 +362,7 @@ func (db *DB) FetchPayments() ([]*MPPayment, error) {
return err
}
payments = append(payments, p.ToMPPayment())
payments = append(payments, p)
return nil
})
})
@@ -379,7 +379,7 @@ func (db *DB) FetchPayments() ([]*MPPayment, error) {
return payments, nil
}
func fetchPayment(bucket *bbolt.Bucket) (*Payment, error) {
func fetchPayment(bucket *bbolt.Bucket) (*MPPayment, error) {
var (
err error
p = &Payment{}
@@ -434,7 +434,7 @@ func fetchPayment(bucket *bbolt.Bucket) (*Payment, error) {
p.Failure = &reason
}
return p, nil
return p.ToMPPayment(), nil
}
// DeletePayments deletes all completed and failed payments from the DB.