Merge pull request #9338 from yyforyongyu/fix-invoice-htlcs-order
lnrpc: sort `Invoice.HTLCs` based on `HtlcIndex`
This commit is contained in:
2 files changed
+11
No files matched your search
@@ -90,6 +90,10 @@
|
|||||||
* [The `walletrpc.FundPsbt` method now has a new option to specify the maximum
|
* [The `walletrpc.FundPsbt` method now has a new option to specify the maximum
|
||||||
fee to output amounts ratio.](https://github.com/lightningnetwork/lnd/pull/8600)
|
fee to output amounts ratio.](https://github.com/lightningnetwork/lnd/pull/8600)
|
||||||
|
|
||||||
|
* When returning the response from list invoices RPC, the `lnrpc.Invoice.Htlcs`
|
||||||
|
are now [sorted](https://github.com/lightningnetwork/lnd/pull/9337) based on
|
||||||
|
the `InvoiceHTLC.HtlcIndex`.
|
||||||
|
|
||||||
## lncli Additions
|
## lncli Additions
|
||||||
|
|
||||||
* [A pre-generated macaroon root key can now be specified in `lncli create` and
|
* [A pre-generated macaroon root key can now be specified in `lncli create` and
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
package invoicesrpc
|
package invoicesrpc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"cmp"
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"slices"
|
||||||
|
|
||||||
"github.com/btcsuite/btcd/btcec/v2"
|
"github.com/btcsuite/btcd/btcec/v2"
|
||||||
"github.com/btcsuite/btcd/chaincfg"
|
"github.com/btcsuite/btcd/chaincfg"
|
||||||
@@ -160,6 +162,11 @@ func CreateRPCInvoice(invoice *invoices.Invoice,
|
|||||||
rpcHtlcs = append(rpcHtlcs, &rpcHtlc)
|
rpcHtlcs = append(rpcHtlcs, &rpcHtlc)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Perform an inplace sort of the HTLCs to ensure they are ordered.
|
||||||
|
slices.SortFunc(rpcHtlcs, func(i, j *lnrpc.InvoiceHTLC) int {
|
||||||
|
return cmp.Compare(i.HtlcIndex, j.HtlcIndex)
|
||||||
|
})
|
||||||
|
|
||||||
rpcInvoice := &lnrpc.Invoice{
|
rpcInvoice := &lnrpc.Invoice{
|
||||||
Memo: string(invoice.Memo),
|
Memo: string(invoice.Memo),
|
||||||
RHash: rHash,
|
RHash: rHash,
|
||||||
|
|||||||
Reference in new issue
Block a user