routerrpc: parse dest_features bits for manual SendPayment
This commit is contained in:
parent
457fda6095
commit
35dd5f354d
@ -633,6 +633,14 @@ func (r *RouterBackend) extractIntentFromSendRequest(
|
|||||||
|
|
||||||
// Payment hash.
|
// Payment hash.
|
||||||
copy(payIntent.PaymentHash[:], rpcPayReq.PaymentHash)
|
copy(payIntent.PaymentHash[:], rpcPayReq.PaymentHash)
|
||||||
|
|
||||||
|
// Parse destination feature bits.
|
||||||
|
features, err := UnmarshalFeatures(rpcPayReq.DestFeatures)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
payIntent.DestFeatures = features
|
||||||
}
|
}
|
||||||
|
|
||||||
// Currently, within the bootstrap phase of the network, we limit the
|
// Currently, within the bootstrap phase of the network, we limit the
|
||||||
@ -699,6 +707,21 @@ func unmarshallHopHint(rpcHint *lnrpc.HopHint) (zpay32.HopHint, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnmarshalFeatures converts a list of uint32's into a valid feature vector.
|
||||||
|
// This method checks that feature bit pairs aren't assigned toegether, and
|
||||||
|
// validates transitive depdencies.
|
||||||
|
func UnmarshalFeatures(rpcFeatures []lnrpc.FeatureBit) (*lnwire.FeatureVector, error) {
|
||||||
|
raw := lnwire.NewRawFeatureVector()
|
||||||
|
for _, bit := range rpcFeatures {
|
||||||
|
err := raw.SafeSet(lnwire.FeatureBit(bit))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return lnwire.NewFeatureVector(raw, lnwire.Features), nil
|
||||||
|
}
|
||||||
|
|
||||||
// ValidatePayReqExpiry checks if the passed payment request has expired. In
|
// ValidatePayReqExpiry checks if the passed payment request has expired. In
|
||||||
// the case it has expired, an error will be returned.
|
// the case it has expired, an error will be returned.
|
||||||
func ValidatePayReqExpiry(payReq *zpay32.Invoice) error {
|
func ValidatePayReqExpiry(payReq *zpay32.Invoice) error {
|
||||||
|
@ -3442,6 +3442,14 @@ func (r *rpcServer) extractPaymentIntent(rpcPayReq *rpcPaymentRequest) (rpcPayme
|
|||||||
copy(payIntent.rHash[:], rpcPayReq.PaymentHash)
|
copy(payIntent.rHash[:], rpcPayReq.PaymentHash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Unmarshal any custom destination features.
|
||||||
|
payIntent.destFeatures, err = routerrpc.UnmarshalFeatures(
|
||||||
|
rpcPayReq.DestFeatures,
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return payIntent, err
|
||||||
|
}
|
||||||
|
|
||||||
// Currently, within the bootstrap phase of the network, we limit the
|
// Currently, within the bootstrap phase of the network, we limit the
|
||||||
// largest payment size allotted to (2^32) - 1 mSAT or 4.29 million
|
// largest payment size allotted to (2^32) - 1 mSAT or 4.29 million
|
||||||
// satoshis.
|
// satoshis.
|
||||||
|
Loading…
Reference in New Issue
Block a user