Skip to content

Updated Swift docs for LDK 0.0.121 #253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2024
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
3 changes: 2 additions & 1 deletion docs/building-a-node-with-ldk/closing-a-channel.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ func handleEvent(event: Event) {
let outputs = event.getOutputs()
do {
let address = ldkManager!.bdkManager.getAddress(addressIndex: .new)!
let script = try Address(address: address).scriptPubkey().toBytes()
let network = ldkManager!.network == .Testnet ? BitcoinDevKit.Network.testnet : BitcoinDevKit.Network.regtest
let script = try Address(address: address, network: network).scriptPubkey().toBytes()
let res = ldkManager!.myKeysManager.spendSpendableOutputs(
descriptors: outputs,
outputs: [],
Expand Down
18 changes: 13 additions & 5 deletions docs/building-a-node-with-ldk/sending-payments.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,21 @@ let invoiceStr = // get an invoice from the payee
let parsedInvoice = Bolt11Invoice.fromStr(s: invoiceStr)

if let invoiceVal = parsedInvoice.getValue() {
let invoicePaymentResult = Bindings.payInvoice(
invoice: invoiceVal,
retryStrategy: Bindings.Retry.initWithTimeout(a: 15),
channelmanager: channelManager
let invoicePaymentResult = Bindings.paymentParametersFromInvoice(invoice: invoiceVal)
guard invoicePaymentResult.isOk() else {
return false
}
let (paymentHash, recipientOnion, routeParams) = Bindings.paymentParametersFromInvoice(invoice: invoiceVal).getValue()!
let paymentId = invoice.paymentHash()!
let res = channelManager.sendPayment(
paymentHash: paymentHash,
recipientOnion: recipientOnion,
paymentId: paymentId,
routeParams: routeParams,
retryStrategy: .initWithTimeout(a: 15)
)

if invoicePaymentResult.isOk() {
if res.isOk() {
// Payment Sent
}
}
Expand Down
20 changes: 11 additions & 9 deletions docs/building-a-node-with-ldk/setting-up-a-channel-manager.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,18 @@ val feeEstimator: FeeEstimator = FeeEstimator.new_impl(YourFeeEstimator)
<template v-slot:swift>

```Swift
class MyFeeEstimator: FeeEstimator {
class MyFeeEstimator: FeeEstimator {
override func getEstSatPer1000Weight(confirmationTarget: Bindings.ConfirmationTarget) -> UInt32 {
if confirmationTarget == .Background {
// Fetch Background Feerate
} else if confirmationTarget == .Normal {
// Fetch Normal Feerate (~6 blocks)
} else if confirmationTarget == .HighPriority {
// Fetch High Feerate
}
// Fetch Default Feerate
if confirmationTarget == .MinAllowedNonAnchorChannelRemoteFee {
return 253
} else if confirmationTarget == .ChannelCloseMinimum {
return 1000
} else if confirmationTarget == .NonAnchorChannelFee {
return 7500
} else if confirmationTarget == .OnChainSweep {
return 7500
}
return 7500
}
}

Expand Down