multi: return route role from HopPayload

We need to know what role we're playing to be able to handle errors
correctly, but the information that we need for this is held by our
iterator:
- Whether we had a blinding point in update add (blinding kit)
- Whether we had a blinding point in payload

As we're now going to use the route role return value even when our
err!=nil, we rename the error to signal that we're using less
canonical golang here.

An alternative to this approach is to attach a RouteRole to our
ErrInvalidPayload. The downside of that approach is:
- Propagate context through parsing (whether we had updateAddHtlc)
- Clumsy handling for errors that are not of type ErrInvalidPayload
This commit is contained in:
Carla Kirk-Cohen
2024-04-25 09:46:31 -04:00
parent b81a6f3d2f
commit 776c889267
6 changed files with 110 additions and 24 deletions

View File

@@ -330,10 +330,10 @@ func newMockHopIterator(hops ...*hop.Payload) hop.Iterator {
return &mockHopIterator{hops: hops}
}
func (r *mockHopIterator) HopPayload() (*hop.Payload, error) {
func (r *mockHopIterator) HopPayload() (*hop.Payload, hop.RouteRole, error) {
h := r.hops[0]
r.hops = r.hops[1:]
return h, nil
return h, hop.RouteRoleCleartext, nil
}
func (r *mockHopIterator) ExtraOnionBlob() []byte {