mirror of
https://github.com/getAlby/hub.git
synced 2026-08-13 12:33:39 +02:00
feat: add minCltvExpiryDelta for LDK (#2181)
fixes #2065 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Improvements** * Hold invoices now support an optional minimum CLTV expiry delta with validation to ensure values stay within protocol limits, allowing finer control over confirmation timeout behavior. * **Chores** * Updated a direct library dependency to a newer version. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
commit
da5b68da84
3 changed files with 23 additions and 8 deletions
2
go.mod
2
go.mod
|
|
@ -7,7 +7,7 @@ require (
|
|||
github.com/btcsuite/btcd v0.24.3-0.20250318170759-4f4ea81776d6
|
||||
github.com/btcsuite/btcd/btcutil v1.1.6
|
||||
github.com/elnosh/gonuts v0.4.2
|
||||
github.com/getAlby/ldk-node-go v0.0.0-20260210094439-f4fc56578330
|
||||
github.com/getAlby/ldk-node-go v0.0.0-20260325180303-fbe7fe6a114d
|
||||
github.com/go-gormigrate/gormigrate/v2 v2.1.5
|
||||
github.com/labstack/echo/v4 v4.15.1
|
||||
github.com/mattn/go-sqlite3 v1.14.38
|
||||
|
|
|
|||
4
go.sum
4
go.sum
|
|
@ -187,8 +187,8 @@ github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S
|
|||
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
|
||||
github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E=
|
||||
github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ=
|
||||
github.com/getAlby/ldk-node-go v0.0.0-20260210094439-f4fc56578330 h1:JxzUYE5wn4MA0fF08jra+/hcZ+1uvVvy9luiXimd/tA=
|
||||
github.com/getAlby/ldk-node-go v0.0.0-20260210094439-f4fc56578330/go.mod h1:8BRjtKcz8E0RyYTPEbMS8VIdgredcGSLne8vHDtcRLg=
|
||||
github.com/getAlby/ldk-node-go v0.0.0-20260325180303-fbe7fe6a114d h1:u7m25pstQSZiDIViKGrIpxnQBu01asJIl25EbzljVtE=
|
||||
github.com/getAlby/ldk-node-go v0.0.0-20260325180303-fbe7fe6a114d/go.mod h1:8BRjtKcz8E0RyYTPEbMS8VIdgredcGSLne8vHDtcRLg=
|
||||
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
||||
github.com/go-gormigrate/gormigrate/v2 v2.1.5 h1:1OyorA5LtdQw12cyJDEHuTrEV3GiXiIhS4/QTTa/SM8=
|
||||
github.com/go-gormigrate/gormigrate/v2 v2.1.5/go.mod h1:mj9ekk/7CPF3VjopaFvWKN2v7fN3D9d3eEOAXRhi/+M=
|
||||
|
|
|
|||
|
|
@ -2283,7 +2283,6 @@ func (ls *LDKService) ExecuteCustomNodeCommand(ctx context.Context, command *lnc
|
|||
}
|
||||
|
||||
func (ls *LDKService) MakeHoldInvoice(ctx context.Context, amount int64, description string, descriptionHash string, expiry int64, paymentHash string, minCltvExpiryDelta *uint64) (*lnclient.Transaction, error) {
|
||||
// TODO: Support minCltvExpiryDelta
|
||||
if time.Duration(expiry)*time.Second > maxInvoiceExpiry {
|
||||
return nil, errors.New("expiry is too long")
|
||||
}
|
||||
|
|
@ -2326,10 +2325,26 @@ func (ls *LDKService) MakeHoldInvoice(ctx context.Context, amount int64, descrip
|
|||
|
||||
ldkPaymentHash := ldk_node.PaymentHash(hex.EncodeToString(paymentHash32[:]))
|
||||
|
||||
invoiceObj, err := ls.node.Bolt11Payment().ReceiveForHash(uint64(amount),
|
||||
descriptionType,
|
||||
uint32(expiry),
|
||||
ldkPaymentHash)
|
||||
var invoiceObj *ldk_node.Bolt11Invoice
|
||||
if minCltvExpiryDelta != nil {
|
||||
if *minCltvExpiryDelta > uint64(65535) {
|
||||
return nil, errors.New("min_cltv_expiry_delta must be <= 65535")
|
||||
}
|
||||
invoiceObj, err = ls.node.Bolt11Payment().ReceiveForHashWithMinCltvExpiryDelta(
|
||||
uint64(amount),
|
||||
descriptionType,
|
||||
uint32(expiry),
|
||||
ldkPaymentHash,
|
||||
uint16(*minCltvExpiryDelta),
|
||||
)
|
||||
} else {
|
||||
invoiceObj, err = ls.node.Bolt11Payment().ReceiveForHash(
|
||||
uint64(amount),
|
||||
descriptionType,
|
||||
uint32(expiry),
|
||||
ldkPaymentHash,
|
||||
)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
logger.Logger.WithError(err).Error("MakeHoldInvoice failed")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue