Skip to content

Commit 0e048cb

Browse files
committed
lndclient: add optional custom records to SendPayment
1 parent ce39d76 commit 0e048cb

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lndclient/router_client.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ type SendPaymentRequest struct {
117117

118118
// KeySend is set to true if the tlv payload will include the preimage.
119119
KeySend bool
120+
121+
// CustomRecords holds the custom TLV records that will be added to the
122+
// payment.
123+
CustomRecords map[uint64][]byte
120124
}
121125

122126
// routerClient is a wrapper around the generated routerrpc proxy.
@@ -154,6 +158,9 @@ func (r *routerClient) SendPayment(ctx context.Context,
154158
if request.LastHopPubkey != nil {
155159
rpcReq.LastHopPubkey = request.LastHopPubkey[:]
156160
}
161+
162+
rpcReq.DestCustomRecords = request.CustomRecords
163+
157164
if request.KeySend {
158165
if request.PaymentHash != nil {
159166
return nil, nil, fmt.Errorf(
@@ -165,10 +172,12 @@ func (r *routerClient) SendPayment(ctx context.Context,
165172
return nil, nil, err
166173
}
167174

168-
// Override the payment hash.
169-
rpcReq.DestCustomRecords = map[uint64][]byte{
170-
record.KeySendType: preimage[:],
175+
if rpcReq.DestCustomRecords == nil {
176+
rpcReq.DestCustomRecords = make(map[uint64][]byte)
171177
}
178+
179+
// Override the payment hash.
180+
rpcReq.DestCustomRecords[record.KeySendType] = preimage[:]
172181
hash := preimage.Hash()
173182
request.PaymentHash = &hash
174183
}

0 commit comments

Comments
 (0)