mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-04 12:31:39 +02:00
rpcserver: return an encoded payment request in AddInvoice
This commit modifies the generated response to an “AddInvoice” RPC by including an encoded payment request in the response. This change gives callers a new atomic piece of information that they can present to the payee, to allow completion of the payment in a seamless manner.
This commit is contained in:
16
rpcserver.go
16
rpcserver.go
@ -965,13 +965,21 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally generate the payment hash itself from the pre-image. This
|
// Next, generate the payment hash itself from the pre-image. This will
|
||||||
// will be used by clients to query for the state of a particular
|
// be used by clients to query for the state of a particular invoice.
|
||||||
// invoice.
|
|
||||||
rHash := fastsha256.Sum256(paymentPreimage[:])
|
rHash := fastsha256.Sum256(paymentPreimage[:])
|
||||||
|
|
||||||
|
// Finally we also create an encoded payment request which allows the
|
||||||
|
// caller to comactly send the invoice to the payer.
|
||||||
|
payReqString := zpay32.Encode(&zpay32.PaymentRequest{
|
||||||
|
Destination: r.server.identityPriv.PubKey(),
|
||||||
|
PaymentHash: rHash,
|
||||||
|
Amount: btcutil.Amount(invoice.Value),
|
||||||
|
})
|
||||||
|
|
||||||
return &lnrpc.AddInvoiceResponse{
|
return &lnrpc.AddInvoiceResponse{
|
||||||
RHash: rHash[:],
|
RHash: rHash[:],
|
||||||
|
PaymentRequest: payReqString,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user