Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ldk-node"
version = "0.6.0-rc.3"
version = "0.6.0-rc.4"
authors = ["Elias Rohrer <dev@tnull.de>"]
homepage = "https://lightningdevkit.org/"
license = "MIT OR Apache-2.0"
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

import PackageDescription

let tag = "v0.6.0-rc.3"
let checksum = "02345d7a9f39c6cdb161976bb00ac1053507aab61845d9e09cafd430368a57f1"
let tag = "v0.6.0-rc.4"
let checksum = "dd0856b962ad886b96839b63de1a24bb3c75fe15c22ce1265b46e1d23697e70d"
let url = "https://github.com/synonymdev/ldk-node/releases/download/\(tag)/LDKNodeFFI.xcframework.zip"

let package = Package(
Expand Down
4 changes: 2 additions & 2 deletions bindings/kotlin/ldk-node-android/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ Publishing new version guide.
- add dependency in `libs.versions.toml`:
```toml
# by tag
ldk-node-android = { module = "com.github.ovitrif:ldk-node", version = "v0.6.0-rc.1"
ldk-node-android = { module = "com.github.synonymdev:ldk-node", version = "v0.6.0-rc.4"

# or by branch
ldk-node-android = { module = "com.github.ovitrif:ldk-node", version = "main-SNAPSHOT"
ldk-node-android = { module = "com.github.synonymdev:ldk-node", version = "main-SNAPSHOT"
```
- Run `Sync project with gradle files` action in android studio
2 changes: 1 addition & 1 deletion bindings/kotlin/ldk-node-android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
android.enableJetifier=true
kotlin.code.style=official
libraryVersion=v0.6.0-rc.3
libraryVersion=v0.6.0-rc.4
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,8 @@ internal open class UniffiVTableCallbackInterfaceVssHeaderProvider(








Expand Down Expand Up @@ -1293,6 +1295,8 @@ internal interface UniffiLib : Library {
): RustBuffer.ByValue
fun uniffi_ldk_node_fn_method_onchainpayment_bump_fee_by_rbf(`ptr`: Pointer,`txid`: RustBuffer.ByValue,`feeRate`: Pointer,uniffi_out_err: UniffiRustCallStatus,
): RustBuffer.ByValue
fun uniffi_ldk_node_fn_method_onchainpayment_calculate_cpfp_fee_rate(`ptr`: Pointer,`parentTxid`: RustBuffer.ByValue,`urgent`: Byte,uniffi_out_err: UniffiRustCallStatus,
): Pointer
fun uniffi_ldk_node_fn_method_onchainpayment_list_spendable_outputs(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus,
): RustBuffer.ByValue
fun uniffi_ldk_node_fn_method_onchainpayment_new_address(`ptr`: Pointer,uniffi_out_err: UniffiRustCallStatus,
Expand Down Expand Up @@ -1657,6 +1661,8 @@ internal interface UniffiLib : Library {
): Short
fun uniffi_ldk_node_checksum_method_onchainpayment_bump_fee_by_rbf(
): Short
fun uniffi_ldk_node_checksum_method_onchainpayment_calculate_cpfp_fee_rate(
): Short
fun uniffi_ldk_node_checksum_method_onchainpayment_list_spendable_outputs(
): Short
fun uniffi_ldk_node_checksum_method_onchainpayment_new_address(
Expand Down Expand Up @@ -2027,6 +2033,9 @@ private fun uniffiCheckApiChecksums(lib: UniffiLib) {
if (lib.uniffi_ldk_node_checksum_method_onchainpayment_bump_fee_by_rbf() != 53877.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_ldk_node_checksum_method_onchainpayment_calculate_cpfp_fee_rate() != 32879.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_ldk_node_checksum_method_onchainpayment_list_spendable_outputs() != 19144.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
Expand Down Expand Up @@ -6024,6 +6033,8 @@ public interface OnchainPaymentInterface {

fun `bumpFeeByRbf`(`txid`: Txid, `feeRate`: FeeRate): Txid

fun `calculateCpfpFeeRate`(`parentTxid`: Txid, `urgent`: kotlin.Boolean): FeeRate

fun `listSpendableOutputs`(): List<SpendableUtxo>

fun `newAddress`(): Address
Expand Down Expand Up @@ -6145,6 +6156,19 @@ open class OnchainPayment: Disposable, AutoCloseable, OnchainPaymentInterface {



@Throws(NodeException::class)override fun `calculateCpfpFeeRate`(`parentTxid`: Txid, `urgent`: kotlin.Boolean): FeeRate {
return FfiConverterTypeFeeRate.lift(
callWithPointer {
uniffiRustCallWithError(NodeException) { _status ->
UniffiLib.INSTANCE.uniffi_ldk_node_fn_method_onchainpayment_calculate_cpfp_fee_rate(
it, FfiConverterTypeTxid.lower(`parentTxid`),FfiConverterBoolean.lower(`urgent`),_status)
}
}
)
}



@Throws(NodeException::class)override fun `listSpendableOutputs`(): List<SpendableUtxo> {
return FfiConverterSequenceTypeSpendableUtxo.lift(
callWithPointer {
Expand Down
2 changes: 2 additions & 0 deletions bindings/ldk_node.udl
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ interface OnchainPayment {
Txid bump_fee_by_rbf([ByRef]Txid txid, FeeRate fee_rate);
[Throws=NodeError]
Txid accelerate_by_cpfp([ByRef]Txid txid, FeeRate? fee_rate, Address? destination_address);
[Throws=NodeError]
FeeRate calculate_cpfp_fee_rate([ByRef]Txid parent_txid, boolean urgent);
};

enum CoinSelectionAlgorithm {
Expand Down
14 changes: 14 additions & 0 deletions bindings/swift/Sources/LDKNode/LDKNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2475,6 +2475,8 @@ public protocol OnchainPaymentProtocol : AnyObject {

func bumpFeeByRbf(txid: Txid, feeRate: FeeRate) throws -> Txid

func calculateCpfpFeeRate(parentTxid: Txid, urgent: Bool) throws -> FeeRate

func listSpendableOutputs() throws -> [SpendableUtxo]

func newAddress() throws -> Address
Expand Down Expand Up @@ -2547,6 +2549,15 @@ open func bumpFeeByRbf(txid: Txid, feeRate: FeeRate)throws -> Txid {
})
}

open func calculateCpfpFeeRate(parentTxid: Txid, urgent: Bool)throws -> FeeRate {
return try FfiConverterTypeFeeRate.lift(try rustCallWithError(FfiConverterTypeNodeError.lift) {
uniffi_ldk_node_fn_method_onchainpayment_calculate_cpfp_fee_rate(self.uniffiClonePointer(),
FfiConverterTypeTxid.lower(parentTxid),
FfiConverterBool.lower(urgent),$0
)
})
}

open func listSpendableOutputs()throws -> [SpendableUtxo] {
return try FfiConverterSequenceTypeSpendableUtxo.lift(try rustCallWithError(FfiConverterTypeNodeError.lift) {
uniffi_ldk_node_fn_method_onchainpayment_list_spendable_outputs(self.uniffiClonePointer(),$0
Expand Down Expand Up @@ -10015,6 +10026,9 @@ private var initializationResult: InitializationResult {
if (uniffi_ldk_node_checksum_method_onchainpayment_bump_fee_by_rbf() != 53877) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_ldk_node_checksum_method_onchainpayment_calculate_cpfp_fee_rate() != 32879) {
return InitializationResult.apiChecksumMismatch
}
if (uniffi_ldk_node_checksum_method_onchainpayment_list_spendable_outputs() != 19144) {
return InitializationResult.apiChecksumMismatch
}
Expand Down
40 changes: 40 additions & 0 deletions src/payment/onchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,4 +302,44 @@ impl OnchainPayment {
// Pass through to the wallet implementation
self.wallet.accelerate_by_cpfp(txid, fee_rate_param, destination_address)
}

/// Calculates an appropriate fee rate for a CPFP transaction to ensure
/// the parent transaction gets confirmed within the target number of blocks.
///
/// This method analyzes the parent transaction's current fee rate and calculates
/// how much the child transaction needs to pay to bring the combined package
/// fee rate up to the target level.
///
/// # Arguments
///
/// * `parent_txid` - The transaction ID of the parent transaction to accelerate
/// * `urgent` - If true, uses a more aggressive fee rate for faster confirmation
///
/// # Returns
///
/// The fee rate that should be used for the child transaction.
///
/// # Errors
///
/// * [`Error::NotRunning`] - If the node is not running
/// * [`Error::TransactionNotFound`] - If the parent transaction can't be found
/// * [`Error::TransactionAlreadyConfirmed`] - If the parent transaction is already confirmed
/// * [`Error::WalletOperationFailed`] - If fee calculation fails
pub fn calculate_cpfp_fee_rate(&self, parent_txid: &Txid, urgent: bool) -> Result<FeeRate, Error> {
let rt_lock = self.runtime.read().unwrap();
if rt_lock.is_none() {
return Err(Error::NotRunning);
}

let fee_rate = self.wallet.calculate_cpfp_fee_rate(parent_txid, urgent)?;

#[cfg(not(feature = "uniffi"))]
{
Ok(fee_rate)
}
#[cfg(feature = "uniffi")]
{
Ok(Arc::new(fee_rate))
}
}
}
2 changes: 1 addition & 1 deletion src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ where
// Get current mempool fee rates from fee estimator based on urgency
let target = if urgent {
ConfirmationTarget::Lightning(
lightning::chain::chaininterface::ConfirmationTarget::UrgentOnChainSweep,
lightning::chain::chaininterface::ConfirmationTarget::MaximumFeeEstimate,
)
} else {
ConfirmationTarget::OnchainPayment
Expand Down