mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-16 13:00:37 +02:00
Merge pull request #216 from bhandras/custom_records
lndclient: add optional custom records to SendPayment
This commit is contained in:
commit
2775ea5c22
1 changed files with 12 additions and 3 deletions
|
|
@ -117,6 +117,10 @@ type SendPaymentRequest struct {
|
|||
|
||||
// KeySend is set to true if the tlv payload will include the preimage.
|
||||
KeySend bool
|
||||
|
||||
// CustomRecords holds the custom TLV records that will be added to the
|
||||
// payment.
|
||||
CustomRecords map[uint64][]byte
|
||||
}
|
||||
|
||||
// routerClient is a wrapper around the generated routerrpc proxy.
|
||||
|
|
@ -154,6 +158,9 @@ func (r *routerClient) SendPayment(ctx context.Context,
|
|||
if request.LastHopPubkey != nil {
|
||||
rpcReq.LastHopPubkey = request.LastHopPubkey[:]
|
||||
}
|
||||
|
||||
rpcReq.DestCustomRecords = request.CustomRecords
|
||||
|
||||
if request.KeySend {
|
||||
if request.PaymentHash != nil {
|
||||
return nil, nil, fmt.Errorf(
|
||||
|
|
@ -165,10 +172,12 @@ func (r *routerClient) SendPayment(ctx context.Context,
|
|||
return nil, nil, err
|
||||
}
|
||||
|
||||
// Override the payment hash.
|
||||
rpcReq.DestCustomRecords = map[uint64][]byte{
|
||||
record.KeySendType: preimage[:],
|
||||
if rpcReq.DestCustomRecords == nil {
|
||||
rpcReq.DestCustomRecords = make(map[uint64][]byte)
|
||||
}
|
||||
|
||||
// Override the payment hash.
|
||||
rpcReq.DestCustomRecords[record.KeySendType] = preimage[:]
|
||||
hash := preimage.Hash()
|
||||
request.PaymentHash = &hash
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue