├── .editorconfig ├── .github ├── actions │ ├── archive-framework │ │ └── action.yml │ ├── build-for-testing │ │ └── action.yml │ ├── generate-xcframework │ │ └── action.yml │ ├── install-dependencies │ │ └── action.yml │ ├── test-without-building │ │ └── action.yml │ └── upload-xcframework-artifact │ │ └── action.yml └── workflows │ ├── build-xcframework-parallel-archives.yml │ ├── build-xcframework-parallel-libldk.yml │ ├── build-xcframework-sequential.yml │ ├── direct-bindings-app-tests.yml │ ├── release-framework.yml │ ├── swift.yml │ └── test-artifacts.yml ├── .gitignore ├── .swift-format ├── Package.swift ├── README.md ├── ci ├── Dockerfile ├── LDKSwift │ ├── .gitignore │ ├── Libraries │ │ └── arm64 │ │ │ └── README.md │ ├── Package.resolved │ ├── Package.swift │ ├── Sources │ │ └── LDKSwift │ │ │ ├── batteries │ │ │ └── ChannelManagerConstructor.swift │ │ │ └── bindings │ └── Tests │ │ └── LDKSwiftTests │ │ ├── HumanObjectPeerTestInstance.swift │ │ ├── LDKSwiftTests.swift │ │ ├── LDKTestFixtures.swift │ │ ├── TestBroadcasterInterface.swift │ │ ├── TestChannelManagerPersister.swift │ │ ├── TestFeeEstimator.swift │ │ ├── TestFilter.swift │ │ ├── TestLogger.swift │ │ ├── TestPersister.swift │ │ ├── WrappedSignerProviderTests.swift │ │ └── bitcoin │ │ ├── BTCBlock.swift │ │ ├── BTCHashing.swift │ │ ├── BTCTransaction.swift │ │ ├── BTCVarInt.swift │ │ └── BitcoinTests.swift ├── build_frameworks.sh ├── build_libldk.sh ├── docker-compose.yml ├── docker_setup.sh ├── docker_shell.sh ├── fix_header_includes.py ├── fix_swift_imports.py ├── run_tests.sh ├── toggle_address_sanitation_library.py └── walker.py ├── docs └── setup.md ├── out ├── Bindings.swift ├── VersionDescriptor.swift ├── enums │ ├── complex │ │ ├── APIError.swift │ │ ├── Amount.swift │ │ ├── AsyncPaymentsMessage.swift │ │ ├── Balance.swift │ │ ├── Bech32Error.swift │ │ ├── Bolt11ParseError.swift │ │ ├── Bolt12PaymentError.swift │ │ ├── BumpTransactionEvent.swift │ │ ├── CandidateRouteHop.swift │ │ ├── ClosureReason.swift │ │ ├── DecodeError.swift │ │ ├── Destination.swift │ │ ├── EffectiveCapacity.swift │ │ ├── ErrorAction.swift │ │ ├── Event.swift │ │ ├── FailureCode.swift │ │ ├── Fallback.swift │ │ ├── FundingInfo.swift │ │ ├── GossipSync.swift │ │ ├── GraphSyncError.swift │ │ ├── HTLCDestination.swift │ │ ├── IntroductionNode.swift │ │ ├── MaxDustHTLCExposure.swift │ │ ├── MessageContext.swift │ │ ├── MessageSendEvent.swift │ │ ├── MessageSendInstructions.swift │ │ ├── MonitorEvent.swift │ │ ├── NetworkUpdate.swift │ │ ├── NextMessageHop.swift │ │ ├── NodeAnnouncementInfo.swift │ │ ├── OffersContext.swift │ │ ├── OffersMessage.swift │ │ ├── OutputSpendStatus.swift │ │ ├── ParseOrSemanticError.swift │ │ ├── ParsedOnionMessageContents.swift │ │ ├── PathFailure.swift │ │ ├── Payee.swift │ │ ├── PaymentContext.swift │ │ ├── PaymentPurpose.swift │ │ ├── PaymentSendFailure.swift │ │ ├── PeeledOnion.swift │ │ ├── PendingHTLCRouting.swift │ │ ├── ProbeSendFailure.swift │ │ ├── Quantity.swift │ │ ├── RecentPaymentDetails.swift │ │ ├── Retry.swift │ │ ├── SendError.swift │ │ ├── SendSuccess.swift │ │ ├── SignError.swift │ │ ├── SignOrCreationError.swift │ │ ├── SocketAddress.swift │ │ ├── SpendableOutputDescriptor.swift │ │ ├── SpendingDelay.swift │ │ ├── UnsignedGossipMessage.swift │ │ └── UtxoResult.swift │ └── primitive │ │ ├── BalanceSource.swift │ │ ├── BlindedFailure.swift │ │ ├── Bolt11SemanticError.swift │ │ ├── Bolt12SemanticError.swift │ │ ├── ChannelMonitorUpdateStatus.swift │ │ ├── ChannelShutdownState.swift │ │ ├── ConfirmationTarget.swift │ │ ├── CreationError.swift │ │ ├── Currency.swift │ │ ├── Direction.swift │ │ ├── HTLCClaim.swift │ │ ├── IOError.swift │ │ ├── InboundHTLCStateDetails.swift │ │ ├── Level.swift │ │ ├── Network.swift │ │ ├── Option_NoneZ.swift │ │ ├── OutboundHTLCStateDetails.swift │ │ ├── PaymentFailureReason.swift │ │ ├── Recipient.swift │ │ ├── RetryableSendFailure.swift │ │ ├── Secp256k1Error.swift │ │ ├── ShortChannelIdError.swift │ │ ├── SiPrefix.swift │ │ ├── SocketAddressParseError.swift │ │ └── UtxoLookupError.swift ├── options │ ├── Option_APIErrorZ.swift │ ├── Option_AmountZ.swift │ ├── Option_BigEndianScalarZ.swift │ ├── Option_C2Tuple_OffersMessageResponseInstructionZZ.swift │ ├── Option_C2Tuple_OnionMessageContentsResponseInstructionZZ.swift │ ├── Option_C2Tuple_ReleaseHeldHtlcResponseInstructionZZ.swift │ ├── Option_C2Tuple_ThirtyTwoU16sThirtyTwoU16sZZ.swift │ ├── Option_C2Tuple_u64u16ZZ.swift │ ├── Option_C2Tuple_u64u64ZZ.swift │ ├── Option_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ.swift │ ├── Option_CVec_SocketAddressZZ.swift │ ├── Option_CVec_ThirtyTwoBytesZZ.swift │ ├── Option_CVec_u8ZZ.swift │ ├── Option_ChannelShutdownStateZ.swift │ ├── Option_ClosureReasonZ.swift │ ├── Option_ECDSASignatureZ.swift │ ├── Option_EventZ.swift │ ├── Option_FilterZ.swift │ ├── Option_HTLCClaimZ.swift │ ├── Option_HTLCDestinationZ.swift │ ├── Option_InboundHTLCStateDetailsZ.swift │ ├── Option_MaxDustHTLCExposureZ.swift │ ├── Option_MessageContextZ.swift │ ├── Option_MonitorEventZ.swift │ ├── Option_NetworkUpdateZ.swift │ ├── Option_NodeAnnouncementInfoZ.swift │ ├── Option_OffersContextZ.swift │ ├── Option_OnionMessageContentsZ.swift │ ├── Option_OutboundHTLCStateDetailsZ.swift │ ├── Option_PathFailureZ.swift │ ├── Option_PaymentContextZ.swift │ ├── Option_PaymentFailureReasonZ.swift │ ├── Option_QuantityZ.swift │ ├── Option_SocketAddressZ.swift │ ├── Option_StrZ.swift │ ├── Option_ThirtyTwoBytesZ.swift │ ├── Option_TxOutZ.swift │ ├── Option_TypeZ.swift │ ├── Option_U128Z.swift │ ├── Option_UtxoLookupZ.swift │ ├── Option_WriteableScoreZ.swift │ ├── Option_boolZ.swift │ ├── Option_f64Z.swift │ ├── Option_i64Z.swift │ ├── Option_u16Z.swift │ ├── Option_u32Z.swift │ ├── Option_u64Z.swift │ └── Option_usizeZ.swift ├── results │ ├── Result_AcceptChannelDecodeErrorZ.swift │ ├── Result_AcceptChannelV2DecodeErrorZ.swift │ ├── Result_AnnouncementSignaturesDecodeErrorZ.swift │ ├── Result_AsyncPaymentsMessageDecodeErrorZ.swift │ ├── Result_BestBlockDecodeErrorZ.swift │ ├── Result_BigSizeDecodeErrorZ.swift │ ├── Result_BlindedFailureDecodeErrorZ.swift │ ├── Result_BlindedForwardDecodeErrorZ.swift │ ├── Result_BlindedHopDecodeErrorZ.swift │ ├── Result_BlindedHopFeaturesDecodeErrorZ.swift │ ├── Result_BlindedMessagePathDecodeErrorZ.swift │ ├── Result_BlindedMessagePathNoneZ.swift │ ├── Result_BlindedPayInfoDecodeErrorZ.swift │ ├── Result_BlindedPaymentPathNoneZ.swift │ ├── Result_BlindedTailDecodeErrorZ.swift │ ├── Result_Bolt11InvoiceBolt11SemanticErrorZ.swift │ ├── Result_Bolt11InvoiceFeaturesDecodeErrorZ.swift │ ├── Result_Bolt11InvoiceParseOrSemanticErrorZ.swift │ ├── Result_Bolt11InvoiceSignOrCreationErrorZ.swift │ ├── Result_Bolt12InvoiceBolt12SemanticErrorZ.swift │ ├── Result_Bolt12InvoiceDecodeErrorZ.swift │ ├── Result_Bolt12InvoiceFeaturesDecodeErrorZ.swift │ ├── Result_Bolt12OfferContextDecodeErrorZ.swift │ ├── Result_Bolt12RefundContextDecodeErrorZ.swift │ ├── Result_BuiltCommitmentTransactionDecodeErrorZ.swift │ ├── Result_C2Tuple_BestBlockOutputSweeperZDecodeErrorZ.swift │ ├── Result_C2Tuple_CVec_u8Zu64ZNoneZ.swift │ ├── Result_C2Tuple_ECDSASignatureCVec_ECDSASignatureZZNoneZ.swift │ ├── Result_C2Tuple_ThirtyTwoBytesChannelManagerZDecodeErrorZ.swift │ ├── Result_C2Tuple_ThirtyTwoBytesChannelMonitorZDecodeErrorZ.swift │ ├── Result_C2Tuple_ThirtyTwoBytesChannelMonitorZIOErrorZ.swift │ ├── Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZNoneZ.swift │ ├── Result_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZPaymentSendFailureZ.swift │ ├── Result_C3Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZSendErrorZ.swift │ ├── Result_C3Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZNoneZ.swift │ ├── Result_COption_APIErrorZDecodeErrorZ.swift │ ├── Result_COption_ClosureReasonZDecodeErrorZ.swift │ ├── Result_COption_EventZDecodeErrorZ.swift │ ├── Result_COption_HTLCDestinationZDecodeErrorZ.swift │ ├── Result_COption_InboundHTLCStateDetailsZDecodeErrorZ.swift │ ├── Result_COption_MonitorEventZDecodeErrorZ.swift │ ├── Result_COption_NetworkUpdateZDecodeErrorZ.swift │ ├── Result_COption_OnionMessageContentsZDecodeErrorZ.swift │ ├── Result_COption_OutboundHTLCStateDetailsZDecodeErrorZ.swift │ ├── Result_COption_PathFailureZDecodeErrorZ.swift │ ├── Result_COption_PaymentFailureReasonZDecodeErrorZ.swift │ ├── Result_COption_TypeZDecodeErrorZ.swift │ ├── Result_CVec_BlindedMessagePathZNoneZ.swift │ ├── Result_CVec_BlindedPaymentPathZNoneZ.swift │ ├── Result_CVec_C2Tuple_ThirtyTwoBytesChannelMonitorZZIOErrorZ.swift │ ├── Result_CVec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZProbeSendFailureZ.swift │ ├── Result_CVec_ECDSASignatureZNoneZ.swift │ ├── Result_CVec_StrZIOErrorZ.swift │ ├── Result_CVec_UtxoZNoneZ.swift │ ├── Result_CVec_u8ZIOErrorZ.swift │ ├── Result_CVec_u8ZNoneZ.swift │ ├── Result_CVec_u8ZPeerHandleErrorZ.swift │ ├── Result_ChannelAnnouncementDecodeErrorZ.swift │ ├── Result_ChannelConfigDecodeErrorZ.swift │ ├── Result_ChannelCounterpartyDecodeErrorZ.swift │ ├── Result_ChannelDerivationParametersDecodeErrorZ.swift │ ├── Result_ChannelDetailsDecodeErrorZ.swift │ ├── Result_ChannelFeaturesDecodeErrorZ.swift │ ├── Result_ChannelIdAPIErrorZ.swift │ ├── Result_ChannelIdDecodeErrorZ.swift │ ├── Result_ChannelInfoDecodeErrorZ.swift │ ├── Result_ChannelMonitorUpdateDecodeErrorZ.swift │ ├── Result_ChannelMonitorUpdateStatusNoneZ.swift │ ├── Result_ChannelPublicKeysDecodeErrorZ.swift │ ├── Result_ChannelReadyDecodeErrorZ.swift │ ├── Result_ChannelReestablishDecodeErrorZ.swift │ ├── Result_ChannelShutdownStateDecodeErrorZ.swift │ ├── Result_ChannelTransactionParametersDecodeErrorZ.swift │ ├── Result_ChannelTypeFeaturesDecodeErrorZ.swift │ ├── Result_ChannelUpdateDecodeErrorZ.swift │ ├── Result_ChannelUpdateInfoDecodeErrorZ.swift │ ├── Result_ClaimedHTLCDecodeErrorZ.swift │ ├── Result_ClosingSignedDecodeErrorZ.swift │ ├── Result_ClosingSignedFeeRangeDecodeErrorZ.swift │ ├── Result_CoinSelectionNoneZ.swift │ ├── Result_CommitmentSignedBatchDecodeErrorZ.swift │ ├── Result_CommitmentSignedDecodeErrorZ.swift │ ├── Result_CommitmentTransactionDecodeErrorZ.swift │ ├── Result_CounterpartyChannelTransactionParametersDecodeErrorZ.swift │ ├── Result_CounterpartyCommitmentSecretsDecodeErrorZ.swift │ ├── Result_CounterpartyForwardingInfoDecodeErrorZ.swift │ ├── Result_DelayedPaymentBasepointDecodeErrorZ.swift │ ├── Result_DelayedPaymentKeyDecodeErrorZ.swift │ ├── Result_DelayedPaymentOutputDescriptorDecodeErrorZ.swift │ ├── Result_DescriptionCreationErrorZ.swift │ ├── Result_ECDSASignatureNoneZ.swift │ ├── Result_EcdsaChannelSignerDecodeErrorZ.swift │ ├── Result_ErrorMessageDecodeErrorZ.swift │ ├── Result_FinalOnionHopDataDecodeErrorZ.swift │ ├── Result_FixedPenaltyScorerDecodeErrorZ.swift │ ├── Result_FundingCreatedDecodeErrorZ.swift │ ├── Result_FundingInfoDecodeErrorZ.swift │ ├── Result_FundingSignedDecodeErrorZ.swift │ ├── Result_GossipTimestampFilterDecodeErrorZ.swift │ ├── Result_HTLCDescriptorDecodeErrorZ.swift │ ├── Result_HTLCOutputInCommitmentDecodeErrorZ.swift │ ├── Result_HTLCUpdateDecodeErrorZ.swift │ ├── Result_HeldHtlcAvailableDecodeErrorZ.swift │ ├── Result_HolderCommitmentTransactionDecodeErrorZ.swift │ ├── Result_HostnameDecodeErrorZ.swift │ ├── Result_HtlcBasepointDecodeErrorZ.swift │ ├── Result_HtlcKeyDecodeErrorZ.swift │ ├── Result_InFlightHtlcsDecodeErrorZ.swift │ ├── Result_InMemorySignerDecodeErrorZ.swift │ ├── Result_InboundHTLCDetailsDecodeErrorZ.swift │ ├── Result_InitDecodeErrorZ.swift │ ├── Result_InitFeaturesDecodeErrorZ.swift │ ├── Result_InvoiceErrorDecodeErrorZ.swift │ ├── Result_InvoiceRequestBolt12SemanticErrorZ.swift │ ├── Result_InvoiceRequestFieldsDecodeErrorZ.swift │ ├── Result_InvoiceRequestWithDerivedPayerIdBuilderBolt12SemanticErrorZ.swift │ ├── Result_InvoiceRequestWithExplicitPayerIdBuilderBolt12SemanticErrorZ.swift │ ├── Result_InvoiceWithDerivedSigningPubkeyBuilderBolt12SemanticErrorZ.swift │ ├── Result_InvoiceWithExplicitSigningPubkeyBuilderBolt12SemanticErrorZ.swift │ ├── Result_LockedChannelMonitorNoneZ.swift │ ├── Result_MaxDustHTLCExposureDecodeErrorZ.swift │ ├── Result_MessageContextDecodeErrorZ.swift │ ├── Result_NetworkGraphDecodeErrorZ.swift │ ├── Result_NodeAliasDecodeErrorZ.swift │ ├── Result_NodeAnnouncementDecodeErrorZ.swift │ ├── Result_NodeAnnouncementInfoDecodeErrorZ.swift │ ├── Result_NodeFeaturesDecodeErrorZ.swift │ ├── Result_NodeIdDecodeErrorZ.swift │ ├── Result_NodeInfoDecodeErrorZ.swift │ ├── Result_NonceDecodeErrorZ.swift │ ├── Result_NoneAPIErrorZ.swift │ ├── Result_NoneBolt11SemanticErrorZ.swift │ ├── Result_NoneBolt12SemanticErrorZ.swift │ ├── Result_NoneIOErrorZ.swift │ ├── Result_NoneLightningErrorZ.swift │ ├── Result_NoneNoneZ.swift │ ├── Result_NonePaymentSendFailureZ.swift │ ├── Result_NonePeerHandleErrorZ.swift │ ├── Result_NoneReplayEventZ.swift │ ├── Result_NoneRetryableSendFailureZ.swift │ ├── Result_NoneSendErrorZ.swift │ ├── Result_OfferBolt12ParseErrorZ.swift │ ├── Result_OfferBolt12SemanticErrorZ.swift │ ├── Result_OfferDecodeErrorZ.swift │ ├── Result_OfferIdDecodeErrorZ.swift │ ├── Result_OfferWithDerivedMetadataBuilderBolt12SemanticErrorZ.swift │ ├── Result_OffersContextDecodeErrorZ.swift │ ├── Result_OffersMessageDecodeErrorZ.swift │ ├── Result_OnionMessageDecodeErrorZ.swift │ ├── Result_OnionMessagePathNoneZ.swift │ ├── Result_OnionPacketDecodeErrorZ.swift │ ├── Result_OpenChannelDecodeErrorZ.swift │ ├── Result_OpenChannelV2DecodeErrorZ.swift │ ├── Result_OutPointDecodeErrorZ.swift │ ├── Result_OutboundHTLCDetailsDecodeErrorZ.swift │ ├── Result_OutputSpendStatusDecodeErrorZ.swift │ ├── Result_OutputSweeperDecodeErrorZ.swift │ ├── Result_PayeePubKeySecp256k1ErrorZ.swift │ ├── Result_PaymentConstraintsDecodeErrorZ.swift │ ├── Result_PaymentContextDecodeErrorZ.swift │ ├── Result_PaymentParametersDecodeErrorZ.swift │ ├── Result_PaymentPurposeDecodeErrorZ.swift │ ├── Result_PaymentRelayDecodeErrorZ.swift │ ├── Result_PeeledOnionNoneZ.swift │ ├── Result_PendingHTLCInfoDecodeErrorZ.swift │ ├── Result_PendingHTLCInfoInboundHTLCErrZ.swift │ ├── Result_PendingHTLCRoutingDecodeErrorZ.swift │ ├── Result_PhantomRouteHintsDecodeErrorZ.swift │ ├── Result_PingDecodeErrorZ.swift │ ├── Result_PongDecodeErrorZ.swift │ ├── Result_PositiveTimestampCreationErrorZ.swift │ ├── Result_PrivateRouteCreationErrorZ.swift │ ├── Result_ProbabilisticScorerDecodeErrorZ.swift │ ├── Result_PublicKeyNoneZ.swift │ ├── Result_PublicKeySecp256k1ErrorZ.swift │ ├── Result_QueryChannelRangeDecodeErrorZ.swift │ ├── Result_QueryShortChannelIdsDecodeErrorZ.swift │ ├── Result_RecipientOnionFieldsDecodeErrorZ.swift │ ├── Result_RecipientOnionFieldsNoneZ.swift │ ├── Result_RecoverableSignatureNoneZ.swift │ ├── Result_RefundBolt12ParseErrorZ.swift │ ├── Result_RefundBolt12SemanticErrorZ.swift │ ├── Result_RefundDecodeErrorZ.swift │ ├── Result_RefundMaybeWithDerivedMetadataBuilderBolt12SemanticErrorZ.swift │ ├── Result_ReleaseHeldHtlcDecodeErrorZ.swift │ ├── Result_ReplyChannelRangeDecodeErrorZ.swift │ ├── Result_ReplyShortChannelIdsEndDecodeErrorZ.swift │ ├── Result_ResponderDecodeErrorZ.swift │ ├── Result_RetryDecodeErrorZ.swift │ ├── Result_RevocationBasepointDecodeErrorZ.swift │ ├── Result_RevocationKeyDecodeErrorZ.swift │ ├── Result_RevokeAndACKDecodeErrorZ.swift │ ├── Result_RouteDecodeErrorZ.swift │ ├── Result_RouteHintDecodeErrorZ.swift │ ├── Result_RouteHintHopDecodeErrorZ.swift │ ├── Result_RouteHopDecodeErrorZ.swift │ ├── Result_RouteLightningErrorZ.swift │ ├── Result_RouteParametersDecodeErrorZ.swift │ ├── Result_RoutingFeesDecodeErrorZ.swift │ ├── Result_SchnorrSignatureNoneZ.swift │ ├── Result_SendSuccessSendErrorZ.swift │ ├── Result_ShutdownDecodeErrorZ.swift │ ├── Result_ShutdownScriptDecodeErrorZ.swift │ ├── Result_ShutdownScriptInvalidShutdownScriptZ.swift │ ├── Result_ShutdownScriptNoneZ.swift │ ├── Result_SiPrefixBolt11ParseErrorZ.swift │ ├── Result_SignedRawBolt11InvoiceBolt11ParseErrorZ.swift │ ├── Result_SocketAddressDecodeErrorZ.swift │ ├── Result_SocketAddressSocketAddressParseErrorZ.swift │ ├── Result_SpendableOutputDescriptorDecodeErrorZ.swift │ ├── Result_SpliceAckDecodeErrorZ.swift │ ├── Result_SpliceInitDecodeErrorZ.swift │ ├── Result_SpliceLockedDecodeErrorZ.swift │ ├── Result_StaticPaymentOutputDescriptorDecodeErrorZ.swift │ ├── Result_StfuDecodeErrorZ.swift │ ├── Result_ThirtyTwoBytesAPIErrorZ.swift │ ├── Result_ThirtyTwoBytesNoneZ.swift │ ├── Result_ThirtyTwoBytesPaymentSendFailureZ.swift │ ├── Result_ThirtyTwoBytesRetryableSendFailureZ.swift │ ├── Result_TrackedSpendableOutputDecodeErrorZ.swift │ ├── Result_TransactionNoneZ.swift │ ├── Result_TransactionU16LenLimitedDecodeErrorZ.swift │ ├── Result_TransactionU16LenLimitedNoneZ.swift │ ├── Result_TrustedClosingTransactionNoneZ.swift │ ├── Result_TrustedCommitmentTransactionNoneZ.swift │ ├── Result_TxAbortDecodeErrorZ.swift │ ├── Result_TxAckRbfDecodeErrorZ.swift │ ├── Result_TxAddInputDecodeErrorZ.swift │ ├── Result_TxAddOutputDecodeErrorZ.swift │ ├── Result_TxCompleteDecodeErrorZ.swift │ ├── Result_TxCreationKeysDecodeErrorZ.swift │ ├── Result_TxInitRbfDecodeErrorZ.swift │ ├── Result_TxOutUtxoLookupErrorZ.swift │ ├── Result_TxRemoveInputDecodeErrorZ.swift │ ├── Result_TxRemoveOutputDecodeErrorZ.swift │ ├── Result_TxSignaturesDecodeErrorZ.swift │ ├── Result_UnknownPaymentContextDecodeErrorZ.swift │ ├── Result_UnsignedBolt12InvoiceBolt12SemanticErrorZ.swift │ ├── Result_UnsignedChannelAnnouncementDecodeErrorZ.swift │ ├── Result_UnsignedChannelUpdateDecodeErrorZ.swift │ ├── Result_UnsignedInvoiceRequestBolt12SemanticErrorZ.swift │ ├── Result_UnsignedNodeAnnouncementDecodeErrorZ.swift │ ├── Result_UntrustedStringDecodeErrorZ.swift │ ├── Result_UpdateAddHTLCDecodeErrorZ.swift │ ├── Result_UpdateFailHTLCDecodeErrorZ.swift │ ├── Result_UpdateFailMalformedHTLCDecodeErrorZ.swift │ ├── Result_UpdateFeeDecodeErrorZ.swift │ ├── Result_UpdateFulfillHTLCDecodeErrorZ.swift │ ├── Result_VerifiedInvoiceRequestNoneZ.swift │ ├── Result_WarningMessageDecodeErrorZ.swift │ ├── Result_WitnessNoneZ.swift │ ├── Result__u832NoneZ.swift │ ├── Result_boolLightningErrorZ.swift │ ├── Result_boolPeerHandleErrorZ.swift │ ├── Result_u32GraphSyncErrorZ.swift │ └── Result_u64ShortChannelIdErrorZ.swift ├── structs │ ├── AcceptChannel.swift │ ├── AcceptChannelV2.swift │ ├── AnchorDescriptor.swift │ ├── AnnouncementSignatures.swift │ ├── BackgroundProcessor.swift │ ├── BestBlock.swift │ ├── BigSize.swift │ ├── BindingsError.swift │ ├── BindingsInit.swift │ ├── BlindedForward.swift │ ├── BlindedHop.swift │ ├── BlindedHopFeatures.swift │ ├── BlindedMessagePath.swift │ ├── BlindedPathCandidate.swift │ ├── BlindedPayInfo.swift │ ├── BlindedPaymentPath.swift │ ├── BlindedTail.swift │ ├── Bolt11Invoice.swift │ ├── Bolt11InvoiceFeatures.swift │ ├── Bolt11InvoiceSignature.swift │ ├── Bolt12Invoice.swift │ ├── Bolt12InvoiceFeatures.swift │ ├── Bolt12OfferContext.swift │ ├── Bolt12ParseError.swift │ ├── Bolt12RefundContext.swift │ ├── BuiltCommitmentTransaction.swift │ ├── BumpTransactionEventHandler.swift │ ├── ChainMonitor.swift │ ├── ChainParameters.swift │ ├── ChannelAnnouncement.swift │ ├── ChannelConfig.swift │ ├── ChannelConfigUpdate.swift │ ├── ChannelCounterparty.swift │ ├── ChannelDerivationParameters.swift │ ├── ChannelDetails.swift │ ├── ChannelFeatures.swift │ ├── ChannelHandshakeConfig.swift │ ├── ChannelHandshakeLimits.swift │ ├── ChannelId.swift │ ├── ChannelInfo.swift │ ├── ChannelManager.swift │ ├── ChannelManagerReadArgs.swift │ ├── ChannelMonitor.swift │ ├── ChannelMonitorUpdate.swift │ ├── ChannelParameters.swift │ ├── ChannelPublicKeys.swift │ ├── ChannelReady.swift │ ├── ChannelReestablish.swift │ ├── ChannelTransactionParameters.swift │ ├── ChannelTypeFeatures.swift │ ├── ChannelUpdate.swift │ ├── ChannelUpdateInfo.swift │ ├── ChannelUsage.swift │ ├── ClaimedHTLC.swift │ ├── ClosingSigned.swift │ ├── ClosingSignedFeeRange.swift │ ├── ClosingTransaction.swift │ ├── CoinSelection.swift │ ├── CommitmentSigned.swift │ ├── CommitmentSignedBatch.swift │ ├── CommitmentTransaction.swift │ ├── CommitmentUpdate.swift │ ├── CommonAcceptChannelFields.swift │ ├── CommonOpenChannelFields.swift │ ├── CounterpartyChannelTransactionParameters.swift │ ├── CounterpartyCommitmentSecrets.swift │ ├── CounterpartyForwardingInfo.swift │ ├── DefaultMessageRouter.swift │ ├── DefaultRouter.swift │ ├── DelayedPaymentBasepoint.swift │ ├── DelayedPaymentKey.swift │ ├── DelayedPaymentOutputDescriptor.swift │ ├── Description.swift │ ├── DirectedChannelInfo.swift │ ├── DirectedChannelTransactionParameters.swift │ ├── EmptyNodeIdLookUp.swift │ ├── ErroneousField.swift │ ├── ErrorMessage.swift │ ├── ErroringMessageHandler.swift │ ├── ExpandedKey.swift │ ├── ExpiryTime.swift │ ├── FilesystemStore.swift │ ├── FinalOnionHopData.swift │ ├── FirstHopCandidate.swift │ ├── FixedPenaltyScorer.swift │ ├── ForwardTlvs.swift │ ├── FundingCreated.swift │ ├── FundingSigned.swift │ ├── Future.swift │ ├── GossipTimestampFilter.swift │ ├── HTLCDescriptor.swift │ ├── HTLCOutputInCommitment.swift │ ├── HTLCUpdate.swift │ ├── HeldHtlcAvailable.swift │ ├── HolderCommitmentTransaction.swift │ ├── Hostname.swift │ ├── HtlcBasepoint.swift │ ├── HtlcKey.swift │ ├── IgnoringMessageHandler.swift │ ├── InFlightHtlcs.swift │ ├── InMemorySigner.swift │ ├── InboundHTLCDetails.swift │ ├── InboundHTLCErr.swift │ ├── InitFeatures.swift │ ├── Input.swift │ ├── InvalidShutdownScript.swift │ ├── InvoiceError.swift │ ├── InvoiceRequest.swift │ ├── InvoiceRequestFeatures.swift │ ├── InvoiceRequestFields.swift │ ├── InvoiceRequestWithDerivedPayerIdBuilder.swift │ ├── InvoiceRequestWithExplicitPayerIdBuilder.swift │ ├── InvoiceWithDerivedSigningPubkeyBuilder.swift │ ├── InvoiceWithExplicitSigningPubkeyBuilder.swift │ ├── KeysManager.swift │ ├── LightningError.swift │ ├── LockedChannelMonitor.swift │ ├── MessageForwardNode.swift │ ├── MessageHandler.swift │ ├── MinFinalCltvExpiryDelta.swift │ ├── MonitorUpdatingPersister.swift │ ├── MultiThreadedLockableScore.swift │ ├── MultiThreadedScoreLockRead.swift │ ├── MultiThreadedScoreLockWrite.swift │ ├── NetworkGraph.swift │ ├── NodeAlias.swift │ ├── NodeAnnouncement.swift │ ├── NodeAnnouncementDetails.swift │ ├── NodeFeatures.swift │ ├── NodeId.swift │ ├── NodeInfo.swift │ ├── Nonce.swift │ ├── Offer.swift │ ├── OfferFeatures.swift │ ├── OfferId.swift │ ├── OfferWithDerivedMetadataBuilder.swift │ ├── OfferWithExplicitMetadataBuilder.swift │ ├── OneHopBlindedPathCandidate.swift │ ├── OnionMessage.swift │ ├── OnionMessagePath.swift │ ├── OnionMessenger.swift │ ├── OnionPacket.swift │ ├── OpenChannel.swift │ ├── OpenChannelV2.swift │ ├── OutPoint.swift │ ├── OutboundHTLCDetails.swift │ ├── OutputSweeper.swift │ ├── P2PGossipSync.swift │ ├── Packet.swift │ ├── Path.swift │ ├── PayeePubKey.swift │ ├── PaymentConstraints.swift │ ├── PaymentForwardNode.swift │ ├── PaymentParameters.swift │ ├── PaymentRelay.swift │ ├── PeerDetails.swift │ ├── PeerHandleError.swift │ ├── PeerManager.swift │ ├── PendingHTLCInfo.swift │ ├── PhantomKeysManager.swift │ ├── PhantomRouteHints.swift │ ├── Ping.swift │ ├── Pong.swift │ ├── PositiveTimestamp.swift │ ├── PrintableString.swift │ ├── PrivateHopCandidate.swift │ ├── PrivateRoute.swift │ ├── ProbabilisticScorer.swift │ ├── ProbabilisticScoringDecayParameters.swift │ ├── ProbabilisticScoringFeeParameters.swift │ ├── PublicHopCandidate.swift │ ├── QueryChannelRange.swift │ ├── QueryShortChannelIds.swift │ ├── RandomBytes.swift │ ├── RapidGossipSync.swift │ ├── RawBolt11Invoice.swift │ ├── RawDataPart.swift │ ├── ReadOnlyNetworkGraph.swift │ ├── ReceiveTlvs.swift │ ├── RecipientOnionFields.swift │ ├── Record.swift │ ├── Refund.swift │ ├── RefundMaybeWithDerivedMetadataBuilder.swift │ ├── ReleaseHeldHtlc.swift │ ├── ReplayEvent.swift │ ├── ReplyChannelRange.swift │ ├── ReplyShortChannelIdsEnd.swift │ ├── Responder.swift │ ├── ResponseInstruction.swift │ ├── RevocationBasepoint.swift │ ├── RevocationKey.swift │ ├── RevokeAndACK.swift │ ├── Route.swift │ ├── RouteHint.swift │ ├── RouteHintHop.swift │ ├── RouteHop.swift │ ├── RouteParameters.swift │ ├── RoutingFees.swift │ ├── ScorerAccountingForInFlightHtlcs.swift │ ├── Sha256.swift │ ├── Shutdown.swift │ ├── ShutdownScript.swift │ ├── SignedRawBolt11Invoice.swift │ ├── Sleeper.swift │ ├── SpliceAck.swift │ ├── SpliceInit.swift │ ├── SpliceLocked.swift │ ├── StaticPaymentOutputDescriptor.swift │ ├── Stfu.swift │ ├── TaggedHash.swift │ ├── TrackedSpendableOutput.swift │ ├── TrampolineOnionPacket.swift │ ├── TransactionU16LenLimited.swift │ ├── TrustedClosingTransaction.swift │ ├── TrustedCommitmentTransaction.swift │ ├── TxAbort.swift │ ├── TxAckRbf.swift │ ├── TxAddInput.swift │ ├── TxAddOutput.swift │ ├── TxComplete.swift │ ├── TxCreationKeys.swift │ ├── TxIn.swift │ ├── TxInitRbf.swift │ ├── TxOut.swift │ ├── TxRemoveInput.swift │ ├── TxRemoveOutput.swift │ ├── TxSignatures.swift │ ├── UnknownPaymentContext.swift │ ├── UnsignedBolt12Invoice.swift │ ├── UnsignedChannelAnnouncement.swift │ ├── UnsignedChannelUpdate.swift │ ├── UnsignedInvoiceRequest.swift │ ├── UnsignedNodeAnnouncement.swift │ ├── UntrustedString.swift │ ├── UpdateAddHTLC.swift │ ├── UpdateFailHTLC.swift │ ├── UpdateFailMalformedHTLC.swift │ ├── UpdateFee.swift │ ├── UpdateFulfillHTLC.swift │ ├── UserConfig.swift │ ├── Utxo.swift │ ├── UtxoFuture.swift │ ├── VerifiedInvoiceRequest.swift │ ├── Wallet.swift │ ├── WarningMessage.swift │ ├── WatchedOutput.swift │ └── WitnessProgram.swift ├── traits │ ├── AsyncPaymentsMessageHandler.swift │ ├── BindingsType.swift │ ├── BroadcasterInterface.swift │ ├── ChangeDestinationSource.swift │ ├── ChannelMessageHandler.swift │ ├── ChannelSigner.swift │ ├── CoinSelectionSource.swift │ ├── Confirm.swift │ ├── CustomMessageHandler.swift │ ├── CustomMessageReader.swift │ ├── CustomOnionMessageHandler.swift │ ├── EcdsaChannelSigner.swift │ ├── EntropySource.swift │ ├── EventHandler.swift │ ├── EventsProvider.swift │ ├── FeeEstimator.swift │ ├── Filter.swift │ ├── FutureCallback.swift │ ├── KVStore.swift │ ├── Listen.swift │ ├── LockableScore.swift │ ├── Logger.swift │ ├── MessageRouter.swift │ ├── MessageSendEventsProvider.swift │ ├── NodeIdLookUp.swift │ ├── NodeSigner.swift │ ├── OffersMessageHandler.swift │ ├── OnionMessageContents.swift │ ├── OnionMessageHandler.swift │ ├── OutputSpender.swift │ ├── Persist.swift │ ├── Persister.swift │ ├── Router.swift │ ├── RoutingMessageHandler.swift │ ├── Score.swift │ ├── ScoreLookUp.swift │ ├── ScoreUpdate.swift │ ├── SignBolt12InvoiceFn.swift │ ├── SignInvoiceRequestFn.swift │ ├── SignerProvider.swift │ ├── SocketDescriptor.swift │ ├── UtxoLookup.swift │ ├── WalletSource.swift │ ├── Watch.swift │ └── WriteableScore.swift ├── tuples │ ├── Tuple_AsyncPaymentsMessageMessageSendInstructionsZ.swift │ ├── Tuple_BestBlockOutputSweeperZ.swift │ ├── Tuple_CVec_u8Zu64Z.swift │ ├── Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ.swift │ ├── Tuple_ChannelIdPublicKeyZ.swift │ ├── Tuple_ECDSASignatureCVec_ECDSASignatureZZ.swift │ ├── Tuple_OffersMessageMessageSendInstructionsZ.swift │ ├── Tuple_OffersMessageResponseInstructionZ.swift │ ├── Tuple_OnionMessageContentsMessageSendInstructionsZ.swift │ ├── Tuple_OnionMessageContentsResponseInstructionZ.swift │ ├── Tuple_OutPointCVec_u64ZZ.swift │ ├── Tuple_OutPointCVec_u8ZZ.swift │ ├── Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZ.swift │ ├── Tuple_OutPointChannelIdZ.swift │ ├── Tuple_PublicKeyOnionMessageCOption_CVec_SocketAddressZZZ.swift │ ├── Tuple_PublicKeyTypeZ.swift │ ├── Tuple_RawBolt11Invoice_u832Bolt11InvoiceSignatureZ.swift │ ├── Tuple_ReleaseHeldHtlcResponseInstructionZ.swift │ ├── Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZ.swift │ ├── Tuple_ThirtyTwoBytesCVec_C2Tuple_u32TxOutZZZ.swift │ ├── Tuple_ThirtyTwoBytesChannelManagerZ.swift │ ├── Tuple_ThirtyTwoBytesChannelMonitorZ.swift │ ├── Tuple_ThirtyTwoBytesRecipientOnionFieldsRouteParametersZ.swift │ ├── Tuple_ThirtyTwoBytesThirtyTwoBytesZ.swift │ ├── Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZ.swift │ ├── Tuple_Z.swift │ ├── Tuple__u1632_u1632Z.swift │ ├── Tuple__u832u16Z.swift │ ├── Tuple_u32CVec_u8ZZ.swift │ ├── Tuple_u32TxOutZ.swift │ ├── Tuple_u64CVec_u8ZZ.swift │ ├── Tuple_u64u16Z.swift │ ├── Tuple_u64u64Z.swift │ └── Tuple_usizeTransactionZ.swift ├── vectors │ ├── Vec_APIErrorZ.swift │ ├── Vec_BalanceZ.swift │ ├── Vec_BlindedHopZ.swift │ ├── Vec_BlindedMessagePathZ.swift │ ├── Vec_BlindedPaymentPathZ.swift │ ├── Vec_C2Tuple_AsyncPaymentsMessageMessageSendInstructionsZZ.swift │ ├── Vec_C2Tuple_ChannelIdPublicKeyZZ.swift │ ├── Vec_C2Tuple_OffersMessageMessageSendInstructionsZZ.swift │ ├── Vec_C2Tuple_OnionMessageContentsMessageSendInstructionsZZ.swift │ ├── Vec_C2Tuple_OutPointCVec_u64ZZZ.swift │ ├── Vec_C2Tuple_OutPointChannelIdZZ.swift │ ├── Vec_C2Tuple_PublicKeyTypeZZ.swift │ ├── Vec_C2Tuple_ThirtyTwoBytesCVec_C2Tuple_u32CVec_u8ZZZZZ.swift │ ├── Vec_C2Tuple_ThirtyTwoBytesChannelMonitorZZ.swift │ ├── Vec_C2Tuple_ThirtyTwoBytesThirtyTwoBytesZZ.swift │ ├── Vec_C2Tuple_u32CVec_u8ZZZ.swift │ ├── Vec_C2Tuple_u32TxOutZZ.swift │ ├── Vec_C2Tuple_u64CVec_u8ZZZ.swift │ ├── Vec_C2Tuple_usizeTransactionZZ.swift │ ├── Vec_C3Tuple_ThirtyTwoBytesu32COption_ThirtyTwoBytesZZZ.swift │ ├── Vec_C4Tuple_OutPointChannelIdCVec_MonitorEventZPublicKeyZZ.swift │ ├── Vec_CResult_NoneAPIErrorZZ.swift │ ├── Vec_ChannelDetailsZ.swift │ ├── Vec_ChannelIdZ.swift │ ├── Vec_ChannelMonitorZ.swift │ ├── Vec_ClaimedHTLCZ.swift │ ├── Vec_CommitmentTransactionZ.swift │ ├── Vec_ECDSASignatureZ.swift │ ├── Vec_FutureZ.swift │ ├── Vec_HTLCDescriptorZ.swift │ ├── Vec_HTLCOutputInCommitmentZ.swift │ ├── Vec_InboundHTLCDetailsZ.swift │ ├── Vec_InputZ.swift │ ├── Vec_MessageForwardNodeZ.swift │ ├── Vec_MessageSendEventZ.swift │ ├── Vec_MonitorEventZ.swift │ ├── Vec_NodeIdZ.swift │ ├── Vec_OutboundHTLCDetailsZ.swift │ ├── Vec_PathZ.swift │ ├── Vec_PaymentForwardNodeZ.swift │ ├── Vec_PeerDetailsZ.swift │ ├── Vec_PhantomRouteHintsZ.swift │ ├── Vec_PrivateRouteZ.swift │ ├── Vec_PublicKeyZ.swift │ ├── Vec_RecentPaymentDetailsZ.swift │ ├── Vec_RouteHintHopZ.swift │ ├── Vec_RouteHintZ.swift │ ├── Vec_RouteHopZ.swift │ ├── Vec_SocketAddressZ.swift │ ├── Vec_SpendableOutputDescriptorZ.swift │ ├── Vec_StrZ.swift │ ├── Vec_ThirtyTwoBytesZ.swift │ ├── Vec_TrackedSpendableOutputZ.swift │ ├── Vec_TransactionOutputsZ.swift │ ├── Vec_TransactionZ.swift │ ├── Vec_TxOutZ.swift │ ├── Vec_UpdateAddHTLCZ.swift │ ├── Vec_UpdateFailHTLCZ.swift │ ├── Vec_UpdateFailMalformedHTLCZ.swift │ ├── Vec_UpdateFulfillHTLCZ.swift │ ├── Vec_UtxoZ.swift │ ├── Vec_WitnessZ.swift │ ├── Vec_u64Z.swift │ └── Vec_u8Z.swift └── wrappers │ ├── BigEndianScalar.swift │ ├── ECDSASignature.swift │ ├── FourBytes.swift │ ├── PublicKey.swift │ ├── RecoverableSignature.swift │ ├── SchnorrSignature.swift │ ├── SecretKey.swift │ ├── SixteenBytes.swift │ ├── Str.swift │ ├── ThirtyTwoBytes.swift │ ├── ThirtyTwoU16s.swift │ ├── ThreeBytes.swift │ ├── Transaction.swift │ ├── TweakedPublicKey.swift │ ├── TwelveBytes.swift │ ├── TwentyBytes.swift │ ├── U128.swift │ ├── Witness.swift │ ├── WitnessVersion.swift │ └── u8slice.swift ├── package.json ├── scripts ├── __init__.py ├── build_bulk_libldks.py ├── build_individual_libldk.py ├── copy_c_files.py ├── generate_xcframework.py ├── prepare_xcode_project.py ├── script_config.py ├── symlink_resolver.py └── update_swift_package_checksum.py ├── src ├── config.mts ├── generation │ ├── base_type_generator.mts │ ├── bindings_file_generator.mts │ ├── complex_enum_generator.mts │ ├── index.mts │ ├── nullable_option_generator.mts │ ├── primitive_enum_generator.mts │ ├── primitive_wrapper_generator.mts │ ├── result_generator.mts │ ├── struct_generator.mts │ ├── trait_generator.mts │ ├── tuple_generator.mts │ └── vector_generator.mts ├── index.mts ├── parser.mts └── rust_types.mts ├── test ├── fixtures │ ├── generation │ │ ├── chain_monitor_test_01.h │ │ ├── enum_test_01.h │ │ ├── option_u32_test.h │ │ ├── vec_u8_test.h │ │ └── vec_vec_route_hop_test.h │ ├── lightning_01.h │ ├── lightning_02.h │ └── parsing │ │ ├── array_wrapper_test_01.h │ │ ├── binary_option_test_01.h │ │ ├── result_test_01.h │ │ ├── tagged_value_enum_test_01.h │ │ ├── tagged_value_enum_test_02.h │ │ ├── trait_test_01.h │ │ ├── trait_test_02.h │ │ ├── trait_test_03.h │ │ ├── tuple_test_01.h │ │ ├── vector_test_01.h │ │ ├── vector_test_02.h │ │ ├── vector_test_03.h │ │ └── vector_test_04.h ├── generator_tests.ts └── parser_tests.ts ├── tsconfig.json └── xcode ├── LDKFramework ├── DirectlyLinkedBindingsApp │ ├── Assets.xcassets │ │ ├── AccentColor.colorset │ │ │ └── Contents.json │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── Contents.json │ ├── ContentView.swift │ ├── DirectlyLinkedBindingsAppApp.swift │ ├── PolarConnectionExperiment.swift │ ├── Preview Content │ │ └── Preview Assets.xcassets │ │ │ └── Contents.json │ └── app-batteries │ │ ├── BlockchainObserver.swift │ │ ├── CombineUtils.swift │ │ ├── LNSyncHandler.swift │ │ ├── PolarIntegrationSample.swift │ │ ├── RegtestBlockchainManager.swift │ │ ├── RegtestBlockchainObserverOld.swift │ │ ├── RegtestBroadcasterInterface.swift │ │ ├── RegtestChannelManagerPersister.swift │ │ ├── SwiftSocketEchoHandler.swift │ │ └── SwiftSocketPeerHandler.swift ├── DirectlyLinkedBindingsAppTests │ ├── DirectlyLinkedBindingsAppTests.swift │ └── polar │ │ ├── BlockchainObserver.swift │ │ ├── CombineUtils.swift │ │ ├── PolarIntegrationSample.swift │ │ └── RegtestBlockchainManager.swift ├── Framework │ ├── Framework.h │ ├── FrameworkTests-Bridging-Header.h │ ├── Info.plist │ └── LDKExampleClass.swift ├── FrameworkTests │ ├── FrameworkTests.swift │ └── Info.plist ├── LDK.xcodeproj │ ├── project.pbxproj │ └── xcshareddata │ │ └── xcschemes │ │ └── DirectlyLinkedBindingsApp.xcscheme └── LightningDevKit.modulemap ├── MISSING_STEPS.md └── build_framework.sh /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | indent_size = 4 6 | insert_final_newline = true 7 | trim_trailing_whitespace = true 8 | 9 | [Makefile] 10 | 11 | -------------------------------------------------------------------------------- /.github/actions/archive-framework/action.yml: -------------------------------------------------------------------------------- 1 | name: Archive Framework 2 | inputs: 3 | destination: 4 | description: Destination platform/architecture details. Typically looks like "generic/platform=iOS" or "platform=macOS,variant=Mac Catalyst,arch=x86_64" 5 | required: true 6 | human_readable_platform: 7 | description: Human-readable platform name, used for directory naming 8 | required: true 9 | description: Framework archivation description. 10 | runs: 11 | using: composite 12 | steps: 13 | - shell: bash 14 | working-directory: . 15 | run: | 16 | cd xcode 17 | 18 | LDK_C_BINDINGS_BINARY_DIRECTORY="" \ 19 | xcodebuild archive \ 20 | -project 'LDKFramework/LDK.xcodeproj' \ 21 | -scheme 'LightningDevKit' \ 22 | -destination 'generic/platform=${{ inputs.destination }}' \ 23 | -archivePath "/Users/runner/work/ldk-swift/ldk-swift/bindings/bin/release/${{ inputs.human_readable_platform }}/${{ inputs.human_readable_platform }}" \ 24 | ENABLE_BITCODE=NO \ 25 | EXCLUDED_ARCHS="i386 armv7" \ 26 | SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES \ 27 | LDK_C_BINDINGS_BASE="${LDK_C_BINDINGS_BASE}" \ 28 | LDK_C_BINDINGS_BINARY_DIRECTORY="" \ 29 | LDK_C_BINDINGS_BINARY_FORCED_REBUILD_OUTPUT_DIRECTORY="${LDK_C_BINDINGS_BINARY_DIRECTORY}" 30 | -------------------------------------------------------------------------------- /.github/actions/build-for-testing/action.yml: -------------------------------------------------------------------------------- 1 | name: Build For Testing 2 | inputs: 3 | scheme: 4 | description: Scheme 5 | required: true 6 | destination: 7 | description: Destination 8 | required: true 9 | project: 10 | description: Project directory, relative to the xcode folder 11 | required: true 12 | description: Build for testing. 13 | runs: 14 | using: composite 15 | steps: 16 | - shell: bash 17 | working-directory: . 18 | run: | 19 | cd xcode 20 | 21 | LDK_C_BINDINGS_BINARY_DIRECTORY="" \ 22 | xcodebuild clean build-for-testing \ 23 | -allowProvisioningUpdates \ 24 | -allowProvisioningDeviceRegistration \ 25 | -project '${{ inputs.project }}' \ 26 | -scheme '${{ inputs.scheme }}' \ 27 | -destination '${{ inputs.destination }}' \ 28 | -resultBundlePath BuildResults.xcresult \ 29 | CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO \ 30 | LDK_C_BINDINGS_BASE="${LDK_C_BINDINGS_BASE}" \ 31 | LDK_C_BINDINGS_BINARY_DIRECTORY="" \ 32 | LDK_C_BINDINGS_BINARY_FORCED_REBUILD_OUTPUT_DIRECTORY="${LDK_C_BINDINGS_BINARY_DIRECTORY}" 33 | -------------------------------------------------------------------------------- /.github/actions/generate-xcframework/action.yml: -------------------------------------------------------------------------------- 1 | name: Generate XCFramework 2 | description: Build xcarchives and combine them into an xcframework using Python scripts.. 3 | runs: 4 | using: composite 5 | steps: 6 | - name: Build binaries 7 | shell: bash 8 | run: 9 | python3 ./scripts/build_bulk_libldks.py 10 | - name: Generate xcframework 11 | shell: bash 12 | run: 13 | python3 ./scripts/generate_xcframework.py 14 | -------------------------------------------------------------------------------- /.github/actions/install-dependencies/action.yml: -------------------------------------------------------------------------------- 1 | name: Install Dependencies 2 | description: Install dependencies 3 | inputs: 4 | destination: 5 | description: Location to check out rust-lightning and ldk-c-bindings repositories 6 | default: '.' 7 | required: true 8 | configureRustNightly: 9 | description: Flag whether or not to install rust, which is not necessary on Ubuntu machines 10 | default: 'true' 11 | required: false 12 | runs: 13 | using: composite 14 | steps: 15 | - name: Install Homebrew Dependencies 16 | shell: bash 17 | if: ${{ runner.os == 'macOS' }} 18 | run: | 19 | brew install gnu-sed 20 | mkdir -p /tmp/gnu-bin 21 | ln -s "$(command -v gsed)" /tmp/gnu-bin/sed 22 | - name: Checkout Rust-Lightning and LDK-C-Bindings git 23 | shell: bash 24 | run: | 25 | echo `pwd` 26 | mkdir -p ${{ inputs.destination }}/bin 27 | git clone --branch 0.0.125-bindings https://github.com/lightningdevkit/rust-lightning ${{ inputs.destination }}/rust-lightning 28 | git clone --branch 0.0.125 https://github.com/lightningdevkit/ldk-c-bindings ${{ inputs.destination }}/ldk-c-bindings 29 | - name: Configure default Rust toolchain 30 | shell: bash 31 | run: | 32 | rustup install 1.73.0 33 | rustup default 1.73.0 34 | - name: Install Rust, required targets 35 | if: ${{ inputs.configureRustNightly == 'true' }} 36 | shell: bash 37 | run: | 38 | rustup toolchain install nightly-2022-06-24 39 | rustup target add aarch64-apple-darwin aarch64-apple-ios x86_64-apple-ios 40 | rustup component add rust-src --toolchain nightly-2022-06-24-aarch64-apple-darwin 41 | - name: Load Cache 42 | if: ${{ inputs.configureRustNightly == 'true' }} 43 | uses: actions/cache@v3 44 | with: 45 | path: | 46 | ~/.cargo/bin/ 47 | ~/.cargo/registry/index/ 48 | ~/.cargo/registry/cache/ 49 | ~/.cargo/git/db/ 50 | target/ 51 | key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} 52 | - name: Pin cbindgen v24 53 | shell: bash 54 | run: | 55 | echo "DEVELOPER_DIR:" 56 | echo $DEVELOPER_DIR 57 | cargo install --force --version 0.24.5 cbindgen 58 | - name: Generate C Bindings 59 | shell: bash 60 | run: | 61 | # Alias sed as gsed, if applicable 62 | export PATH="/tmp/gnu-bin:$PATH" 63 | 64 | pushd ${{ inputs.destination }}/ldk-c-bindings 65 | if [ "$RUNNER_OS" == "macOS" ]; then 66 | ./genbindings.sh ../rust-lightning true skip-tests 67 | else 68 | ./genbindings.sh ../rust-lightning true 69 | fi 70 | cd ./lightning-c-bindings 71 | cargo update -p cc --precise "1.0.69" --verbose 72 | cd ../ 73 | popd 74 | -------------------------------------------------------------------------------- /.github/actions/test-without-building/action.yml: -------------------------------------------------------------------------------- 1 | name: Test Without Building 2 | inputs: 3 | scheme: 4 | description: Scheme 5 | required: true 6 | destination: 7 | description: Destination 8 | required: true 9 | test-plan: 10 | description: Test Plan 11 | required: false 12 | artifact-prefix: 13 | description: The prefix for the filename of the uploaded xcresults file 14 | required: true 15 | check-name: 16 | description: The check name 17 | required: true 18 | project: 19 | description: Project directory, relative to the xcode folder 20 | required: true 21 | runs: 22 | using: composite 23 | steps: 24 | - shell: bash 25 | id: vars 26 | run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" 27 | - shell: bash 28 | working-directory: . 29 | run: | 30 | cd xcode 31 | 32 | xcodebuild test-without-building \ 33 | -project '${{ inputs.project }}' \ 34 | -scheme '${{ inputs.scheme }}' \ 35 | -destination '${{ inputs.destination }}' \ 36 | -resultBundlePath "${{ inputs.artifact-prefix }}-${{ steps.vars.outputs.sha_short }}.xcresult" 37 | - uses: kishikawakatsumi/xcresulttool@v1 38 | if: always() 39 | with: 40 | path: ./xcode/${{ inputs.artifact-prefix }}-${{ steps.vars.outputs.sha_short }}.xcresult 41 | title: ${{ inputs.check-name }} 42 | show-passed-tests: false 43 | -------------------------------------------------------------------------------- /.github/actions/upload-xcframework-artifact/action.yml: -------------------------------------------------------------------------------- 1 | name: Upload XCFramework 2 | description: Create artifact containing a zipped xcframework. 3 | runs: 4 | using: composite 5 | steps: 6 | - name: Zip Xcframework 7 | shell: bash 8 | run: | 9 | ditto -c -k --sequesterRsrc --keepParent /Users/runner/work/ldk-swift/ldk-swift/bindings/bin/release/LightningDevKit.xcframework LightningDevKit.xcframework.zip 10 | - name: Create desymlinked xcframework variant 11 | shell: bash 12 | run: | 13 | cp -r /Users/runner/work/ldk-swift/ldk-swift/bindings/bin/release/LightningDevKit.xcframework /Users/runner/work/ldk-swift/ldk-swift/bindings/bin/release/LightningDevKit-no-symlinks.xcframework 14 | python3 ./scripts/symlink_resolver.py /Users/runner/work/ldk-swift/ldk-swift/bindings/bin/release/LightningDevKit-no-symlinks.xcframework 15 | ditto -c -k --sequesterRsrc --keepParent /Users/runner/work/ldk-swift/ldk-swift/bindings/bin/release/LightningDevKit-no-symlinks.xcframework LightningDevKit-no-symlinks.xcframework.zip 16 | - name: Upload Framework Artifact 17 | uses: actions/upload-artifact@v4 18 | with: 19 | name: LightningDevKit 20 | path: | 21 | LightningDevKit.xcframework.zip 22 | LightningDevKit-no-symlinks.xcframework.zip 23 | -------------------------------------------------------------------------------- /.github/workflows/build-xcframework-sequential.yml: -------------------------------------------------------------------------------- 1 | name: XCFramework from sequential Python script 2 | permissions: 3 | contents: read 4 | statuses: read 5 | pull-requests: read 6 | actions: read 7 | checks: write 8 | on: 9 | push: 10 | branches: 11 | - main 12 | pull_request: 13 | branches: 14 | - "*" 15 | 16 | concurrency: 17 | group: ${{ github.workflow }}-${{ github.ref }} 18 | cancel-in-progress: true 19 | 20 | jobs: 21 | generate-sequential: 22 | name: Build libldks, build xcarchives, and combine into xcframework 23 | runs-on: macos-latest 24 | env: 25 | DEVELOPER_DIR: /Applications/Xcode_15.4.0.app/Contents/Developer 26 | LDK_C_BINDINGS_BASE: ${{ github.workspace }}/bindings/artifacts/ldk-c-bindings 27 | steps: 28 | - name: Configure Xcode 29 | uses: maxim-lobanov/setup-xcode@v1 30 | with: 31 | xcode-version: 15.4.0 32 | - name: Print Xcode SDK availability 33 | shell: bash 34 | run: | 35 | xcodebuild -showsdks 36 | ls /Applications/ 37 | - name: Checkout 38 | uses: actions/checkout@v3 39 | - name: Install Dependencies 40 | uses: ./.github/actions/install-dependencies 41 | with: 42 | destination: ./bindings/artifacts 43 | - name: Generate XCFramework 44 | uses: ./.github/actions/generate-xcframework 45 | - name: Create XCFramework artifact 46 | uses: ./.github/actions/upload-xcframework-artifact 47 | -------------------------------------------------------------------------------- /.github/workflows/direct-bindings-app-tests.yml: -------------------------------------------------------------------------------- 1 | name: DirectBindingsApp 2 | permissions: 3 | contents: read 4 | statuses: read 5 | pull-requests: read 6 | actions: read 7 | checks: write 8 | on: 9 | push: 10 | branches: 11 | - main 12 | pull_request: 13 | branches: 14 | - "*" 15 | 16 | concurrency: 17 | group: ${{ github.workflow }}-${{ github.ref }} 18 | cancel-in-progress: true 19 | 20 | jobs: 21 | build: 22 | name: Build (${{ matrix.configuration['scheme'] }} - ${{ matrix.configuration['platform'] }}) 23 | runs-on: macos-latest 24 | continue-on-error: true 25 | strategy: 26 | fail-fast: false 27 | matrix: 28 | configuration: 29 | - scheme: DirectBindingsApp 30 | destination: platform=iOS Simulator,OS=15.4,name=iPhone 13 Pro 31 | platform: iOS Simulator 32 | project: DirectBindingsApp/DirectBindingsApp.xcodeproj 33 | - scheme: DirectBindingsAppTests 34 | destination: platform=iOS Simulator,OS=15.4,name=iPhone 13 Pro 35 | platform: iOS Simulator 36 | project: DirectBindingsApp/DirectBindingsApp.xcodeproj 37 | xcode-unit-test: DirectBindingsAppTests 38 | env: 39 | DEVELOPER_DIR: /Applications/Xcode_13.3.1.app/Contents/Developer 40 | steps: 41 | - name: Configure Xcode 42 | uses: maxim-lobanov/setup-xcode@v1 43 | with: 44 | xcode-version: 15.4.0 45 | - name: Checkout 46 | uses: actions/checkout@v2 47 | - name: Install Dependencies 48 | uses: ./.github/actions/install-dependencies 49 | - name: Build 50 | id: build 51 | uses: ./.github/actions/build-for-testing 52 | with: 53 | project: ${{ matrix.configuration['project'] }} 54 | scheme: ${{ matrix.configuration['scheme'] }} 55 | destination: ${{ matrix.configuration['destination'] }} 56 | - name: Xcode Unit Test 57 | if: ${{ matrix.configuration['xcode-unit-test'] != '' }} 58 | continue-on-error: true 59 | uses: ./.github/actions/test-without-building 60 | with: 61 | project: ${{ matrix.configuration['project'] }} 62 | scheme: ${{ matrix.configuration['scheme'] }} 63 | destination: ${{ matrix.configuration['destination'] }} 64 | test-plan: ${{ matrix.configuration['xcode-unit-test'] }} 65 | artifact-prefix: unit-tests-${{ matrix.configuration['sdk-name'] }} 66 | check-name: Xcode Unit Tests (${{ matrix.configuration['platform'] }}) 67 | -------------------------------------------------------------------------------- /.github/workflows/release-framework.yml: -------------------------------------------------------------------------------- 1 | name: Release Framework 2 | permissions: 3 | contents: write 4 | statuses: read 5 | pull-requests: read 6 | actions: read 7 | checks: write 8 | on: 9 | workflow_dispatch: 10 | inputs: 11 | tag: 12 | description: 'Tag for next release' 13 | required: true 14 | type: string 15 | 16 | jobs: 17 | generate-xcframework: 18 | name: Generate XCFramework 19 | runs-on: macos-latest 20 | env: 21 | DEVELOPER_DIR: /Applications/Xcode_15.4.0.app/Contents/Developer 22 | LDK_C_BINDINGS_BASE: ${{ github.workspace }}/bindings/artifacts/ldk-c-bindings 23 | steps: 24 | - name: Configure Xcode 25 | uses: maxim-lobanov/setup-xcode@v1 26 | with: 27 | xcode-version: 15.4.0 28 | - name: Checkout 29 | uses: actions/checkout@v3 30 | - name: Update Package.swift tag to ${{ github.event.inputs.tag }} 31 | if: ${{ github.event.inputs.tag != null && github.event.inputs.tag != '' }} 32 | run: | 33 | python3 ./scripts/update_swift_package_checksum.py --tag ${{ github.event.inputs.tag }} 34 | - name: Install Dependencies 35 | uses: ./.github/actions/install-dependencies 36 | with: 37 | destination: ./bindings/artifacts 38 | - name: Generate XCFramework 39 | uses: ./.github/actions/generate-xcframework 40 | - name: Create XCFramework artifact 41 | uses: ./.github/actions/upload-xcframework-artifact 42 | - name: Update Package.swift checksum 43 | if: ${{ github.event.inputs.tag != null && github.event.inputs.tag != '' }} 44 | run: | 45 | CHECKSUM=`swift package compute-checksum LightningDevKit.xcframework.zip` 46 | python3 ./scripts/update_swift_package_checksum.py --checksum "${CHECKSUM}" 47 | git commit -m "Update Package.swift for ${{ github.event.inputs.tag }} release." ./Package.swift 48 | - name: Push and tag commit 49 | if: ${{ github.event.inputs.tag != null && github.event.inputs.tag != '' }} 50 | run: | 51 | git tag ${{ github.event.inputs.tag }} 52 | git push -u origin HEAD:release-${{ github.event.inputs.tag }} 53 | git push --tags 54 | 55 | release: 56 | name: Publish Release 57 | runs-on: ubuntu-latest 58 | needs: [ generate-xcframework ] 59 | steps: 60 | - name: Download Framework Artifact 61 | uses: actions/download-artifact@v4 62 | with: 63 | name: LightningDevKit 64 | - name: Create Release 65 | uses: ncipollo/release-action@v1 66 | if: ${{ github.event.inputs.tag != null && github.event.inputs.tag != '' }} 67 | with: 68 | tag: ${{ github.event.inputs.tag }} 69 | artifacts: LightningDevKit.xcframework.zip,LightningDevKit-no-symlinks.xcframework.zip 70 | -------------------------------------------------------------------------------- /.github/workflows/test-artifacts.yml: -------------------------------------------------------------------------------- 1 | name: Test Artifacts 2 | permissions: 3 | contents: read 4 | statuses: read 5 | pull-requests: read 6 | actions: read 7 | checks: write 8 | on: 9 | workflow_dispatch: 10 | 11 | jobs: 12 | create-artifact: 13 | name: Add ${{ matrix.configuration['human_readable_platform'] }} to artifact 14 | runs-on: macos-latest 15 | strategy: 16 | fail-fast: false 17 | matrix: 18 | configuration: 19 | - destination: generic/platform=iOS 20 | human_readable_platform: 'iphoneos' 21 | - destination: platform=iOS Simulator,OS=15.2,name=iPhone 13 Pro 22 | human_readable_platform: 'iphonesimulator' 23 | - destination: generic/platform=OS X 24 | human_readable_platform: 'macosx' 25 | - destination: platform=macOS,variant=Mac Catalyst,arch=x86_64 26 | human_readable_platform: 'catalyst' 27 | steps: 28 | - name: Checkout 29 | uses: actions/checkout@v3 30 | - name: Xcarchive emulation 31 | run: | 32 | mkdir -p ./bindings/bin/release/${{ matrix.configuration['human_readable_platform'] }} 33 | touch ./bindings/bin/release/${{ matrix.configuration['human_readable_platform'] }}/${{ matrix.configuration['human_readable_platform'] }}.xcarchive 34 | - name: Upload emulated xcarchive 35 | uses: actions/upload-artifact@v4 36 | with: 37 | name: uploaded-artifact-name 38 | path: ./bindings/**/bin/release/${{ matrix.configuration['human_readable_platform'] }}/${{ matrix.configuration['human_readable_platform'] }}.xcarchive 39 | 40 | download-artifact: 41 | name: Download artifact 42 | runs-on: macos-latest 43 | needs: [ create-artifact ] 44 | steps: 45 | - name: Checkout 46 | uses: actions/checkout@v3 47 | - name: Download emulated xcarchives 48 | uses: actions/download-artifact@v3 49 | with: 50 | path: ./downloaded-artifact-name 51 | - name: Preview download result 52 | run: | 53 | ls -ll -R 54 | 55 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .build 3 | /node_modules 4 | 5 | /out/production 6 | /out/test 7 | 8 | /src/lab/* 9 | /src/**/*.mjs 10 | /src/**/*.mjs.map 11 | /test/**/*.js 12 | /test/**/*.js.map 13 | 14 | /ci/LDKSwift/Sources/LDKHeaders 15 | 16 | /xcode/*/Build/ 17 | /xcode/*/*.xcodeproj/project.xcworkspace/ 18 | /xcode/*/*.xcodeproj/xcuserdata/ 19 | /xcode/*/binary/* 20 | /xcode/*/headers/* 21 | /xcode/**/xcuserdata/* 22 | /xcode/build 23 | /xcuserdata/ 24 | *.log 25 | 26 | 27 | 28 | poetry.lock 29 | pyproject.toml 30 | 31 | ## User settings 32 | xcode/build 33 | xcuserdata/ 34 | /bindings/artifacts 35 | 36 | # VSCode 37 | .vscode/* 38 | 39 | -------------------------------------------------------------------------------- /.swift-format: -------------------------------------------------------------------------------- 1 | { 2 | "fileScopedDeclarationPrivacy" : { 3 | "accessLevel" : "private" 4 | }, 5 | "indentation" : { 6 | "tabs" : 1 7 | }, 8 | "indentConditionalCompilationBlocks" : true, 9 | "indentSwitchCaseLabels" : true, 10 | "lineBreakAroundMultilineExpressionChainComponents" : true, 11 | "lineBreakBeforeControlFlowKeywords" : false, 12 | "lineBreakBeforeEachArgument" : false, 13 | "lineBreakBeforeEachGenericRequirement" : false, 14 | "lineLength" : 120, 15 | "maximumBlankLines" : 2, 16 | "prioritizeKeepingFunctionOutputTogether" : false, 17 | "respectsExistingLineBreaks" : true, 18 | "rules" : { 19 | "AllPublicDeclarationsHaveDocumentation" : false, 20 | "AlwaysUseLowerCamelCase" : true, 21 | "AmbiguousTrailingClosureOverload" : true, 22 | "BeginDocumentationCommentWithOneLineSummary" : false, 23 | "DoNotUseSemicolons" : true, 24 | "DontRepeatTypeInStaticProperties" : true, 25 | "FileScopedDeclarationPrivacy" : true, 26 | "FullyIndirectEnum" : true, 27 | "GroupNumericLiterals" : true, 28 | "IdentifiersMustBeASCII" : true, 29 | "NeverForceUnwrap" : false, 30 | "NeverUseForceTry" : false, 31 | "NeverUseImplicitlyUnwrappedOptionals" : false, 32 | "NoAccessLevelOnExtensionDeclaration" : true, 33 | "NoAssignmentInExpressions" : true, 34 | "NoBlockComments" : false, 35 | "NoCasesWithOnlyFallthrough" : true, 36 | "NoEmptyTrailingClosureParentheses" : true, 37 | "NoLabelsInCasePatterns" : true, 38 | "NoLeadingUnderscores" : false, 39 | "NoParensAroundConditions" : true, 40 | "NoVoidReturnOnFunctionSignature" : true, 41 | "OneCasePerLine" : true, 42 | "OneVariableDeclarationPerLine" : true, 43 | "OnlyOneTrailingClosureArgument" : true, 44 | "OrderedImports" : true, 45 | "ReturnVoidInsteadOfEmptyTuple" : true, 46 | "UseEarlyExits" : false, 47 | "UseLetInEveryBoundCaseVariable" : true, 48 | "UseShorthandTypeNames" : true, 49 | "UseSingleLinePropertyGetter" : true, 50 | "UseSynthesizedInitializer" : true, 51 | "UseTripleSlashForDocumentationComments" : true, 52 | "UseWhereClausesInForLoops" : false, 53 | "ValidateDocumentationComments" : false 54 | }, 55 | "spacesAroundRangeFormationOperators" : false, 56 | "tabWidth" : 4, 57 | "version" : 1 58 | } 59 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.3 2 | import PackageDescription 3 | 4 | let tag = "0.0.125" 5 | let checksum = "d2829bf1c02409a658d3237de3637e0eb4bcbbb255a604bbf534a520f4bf722c" 6 | let url = "https://github.com/lightningdevkit/ldk-swift/releases/download/\(tag)/LightningDevKit.xcframework.zip" 7 | 8 | let package = Package( 9 | name: "LightningDevKit", 10 | platforms: [ 11 | .iOS(.v13), 12 | .macOS(.v10_12) 13 | ], 14 | products: [ 15 | .library( 16 | name: "LightningDevKit", 17 | targets: ["LightningDevKit"] 18 | ) 19 | ], 20 | targets: [ 21 | .binaryTarget( 22 | name: "LightningDevKit", 23 | url: url, 24 | checksum: checksum 25 | ) 26 | ] 27 | ) 28 | -------------------------------------------------------------------------------- /ci/Dockerfile: -------------------------------------------------------------------------------- 1 | #FROM ubuntu:20.04 2 | FROM swift:5.6-focal 3 | 4 | RUN apt-get -y update 5 | RUN apt-get -y dist-upgrade 6 | RUN apt-get install -y bash curl git make unzip build-essential python3 7 | # RUN apt-get install -y cargo 8 | 9 | # install RUST 10 | RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y 11 | ENV PATH="/root/.cargo/bin:${PATH}" 12 | 13 | # install llvm/clang 11 14 | RUN curl -SL https://github.com/llvm/llvm-project/releases/download/llvmorg-11.0.0/clang+llvm-11.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz | tar -xJC . 15 | 16 | #RUN apt-get install -y valgrind 17 | # RUN apt-get install -y python3 18 | # RUN apt-get install -y lld 19 | #RUN apt-get install -y git 20 | #RUN apt-get install -y g++ 21 | # RUN apt-get install -y clang 22 | # RUN apt-get install -y libxml2 23 | 24 | COPY ci/LDKSwift ./ci/LDKSwift 25 | COPY ci/fix_header_includes.py ./ci/ 26 | COPY ci/fix_swift_imports.py ./ci/ 27 | COPY ci/run_tests.sh ./ci/ 28 | COPY src ./src 29 | COPY templates ./templates 30 | COPY __main__.py ./ 31 | 32 | RUN rm -rf ci/LDKSwift/Sources/LDKHeaders 33 | RUN rm -rf ci/LDKSwift/Sources/LDKSwift 34 | RUN chmod +x ci/run_tests.sh 35 | 36 | COPY bindings/batteries ci/LDKSwift/Sources/LDKSwift/batteries 37 | # COPY bindings/LDK/. ci/LDKSwift/Sources/LDKSwift 38 | 39 | # RUN ln -s /lib/x86_64-linux-gnu/libtinfo.so.5 /lib/x86_64-linux-gnu/libtinfo.so.6 40 | 41 | ENV LDK_C_BINDINGS_BASE="/ldk-c-bindings" 42 | ENV LDK_SWIFT_GENERATOR_INPUT_HEADER_PATH="/ldk-c-bindings/lightning-c-bindings/include/lightning.h" 43 | ENV LDK_SWIFT_GENERATOR_OUTPUT_DIRECTORY_PATH="/ci/LDKSwift/Sources/LDKSwift" 44 | ENV LLVM_CLANG_ASAN_PATH="/clang+llvm-11.0.0-x86_64-linux-gnu-ubuntu-20.04/lib/clang/11.0.0/lib/linux/libclang_rt.asan-x86_64.a" 45 | ENV ASAN_SYMBOLIZER_PATH="/clang+llvm-11.0.0-x86_64-linux-gnu-ubuntu-20.04/bin/llvm-symbolizer" 46 | ENV PATH="/clang+llvm-11.0.0-x86_64-linux-gnu-ubuntu-20.04/bin:${PATH}" 47 | ENV RUST_BACKTRACE=1 48 | ENV RUSTFLAGS="--cfg=c_bindings" 49 | ENV SHELL=/bin/bash 50 | -------------------------------------------------------------------------------- /ci/LDKSwift/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /.build 3 | /Packages 4 | /*.xcodeproj 5 | xcuserdata/ 6 | DerivedData/ 7 | .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata 8 | -------------------------------------------------------------------------------- /ci/LDKSwift/Libraries/arm64/README.md: -------------------------------------------------------------------------------- 1 | # Dynamic Compilation Instructions 2 | 3 | // todo -------------------------------------------------------------------------------- /ci/LDKSwift/Package.resolved: -------------------------------------------------------------------------------- 1 | { 2 | "object": { 3 | "pins": [ 4 | { 5 | "package": "swift-crypto", 6 | "repositoryURL": "https://github.com/apple/swift-crypto.git", 7 | "state": { 8 | "branch": null, 9 | "revision": "067254c79435de759aeef4a6a03e43d087d61312", 10 | "version": "2.0.5" 11 | } 12 | } 13 | ] 14 | }, 15 | "version": 1 16 | } 17 | -------------------------------------------------------------------------------- /ci/LDKSwift/Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.3 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | import PackageDescription 5 | import Foundation 6 | 7 | var cBindingsBase = "../../../ldk-c-bindings" 8 | if let bindingsBase = getenv("LDK_C_BINDINGS_BASE") { 9 | cBindingsBase = String(utf8String: bindingsBase)! 10 | } 11 | 12 | var bindingsDirectory = "\(cBindingsBase)/lightning-c-bindings/target/debug" 13 | if let ldkBinaryDirectory = getenv("LDK_C_BINDINGS_BINARY_DIRECTORY") { 14 | bindingsDirectory = String(utf8String: ldkBinaryDirectory)! 15 | } 16 | 17 | var bindingsLibraryPath = "\(bindingsDirectory)/libldk.a" 18 | 19 | var linkerSettings: [PackageDescription.LinkerSetting] = [ 20 | .linkedLibrary(bindingsLibraryPath) 21 | ] 22 | 23 | #if os(Linux) 24 | if let addressSanitizerBinaryPath = getenv("LLVM_CLANG_ASAN_PATH") { 25 | linkerSettings.append(.linkedLibrary(String(utf8String: addressSanitizerBinaryPath)!, .when(platforms: [.linux]))) 26 | } 27 | #else 28 | linkerSettings = [ 29 | .unsafeFlags(["-L\(bindingsDirectory)"]), 30 | .linkedLibrary("ldk") 31 | ] 32 | #endif 33 | 34 | let package = Package( 35 | name: "LDKSwift", 36 | // platforms: [ 37 | // // .macOS(.v11), 38 | // // .macCatalyst(.v13), 39 | // .iOS(.v14), 40 | // ], 41 | products: [ 42 | .library( 43 | name: "LDKSwift", 44 | type: .dynamic, 45 | targets: ["LDKSwift"]), 46 | ], 47 | dependencies: [ 48 | .package(url: "https://github.com/apple/swift-crypto.git", "1.0.0"..<"3.0.0") 49 | ], 50 | targets: [ 51 | // Targets are the basic building blocks of a package. A target can define a module or a test suite. 52 | // Targets can depend on other targets in this package, and on products in packages this package depends on. 53 | .target(name: "LDKHeaders"), 54 | .target( 55 | name: "LDKSwift", 56 | dependencies: [ 57 | "LDKHeaders" 58 | ], 59 | path: nil, 60 | exclude: [], 61 | sources: nil, 62 | resources: nil, 63 | publicHeadersPath: "include", 64 | cSettings: nil, 65 | cxxSettings: nil, 66 | swiftSettings: nil, 67 | linkerSettings: linkerSettings 68 | ), 69 | .testTarget( 70 | name: "LDKSwiftTests", 71 | dependencies: [ 72 | "LDKSwift", 73 | "LDKHeaders", 74 | .product(name: "Crypto", package: "swift-crypto") 75 | ], 76 | path: nil, 77 | exclude: [], 78 | sources: nil, 79 | cSettings: nil, cxxSettings: nil, swiftSettings: nil, 80 | linkerSettings: nil) 81 | ] 82 | ) 83 | -------------------------------------------------------------------------------- /ci/LDKSwift/Sources/LDKSwift/bindings: -------------------------------------------------------------------------------- 1 | ../../../../out -------------------------------------------------------------------------------- /ci/LDKSwift/Tests/LDKSwiftTests/TestBroadcasterInterface.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MyBroadcasterInterface.swift 3 | // LDKSwiftARC 4 | // 5 | // Created by Arik Sosman on 5/17/21. 6 | // 7 | 8 | #if SWIFT_PACKAGE 9 | import LDKSwift 10 | import LDKHeaders 11 | #endif 12 | 13 | class TestBroadcasterInterface: BroadcasterInterface { 14 | 15 | override func broadcastTransactions(txs: [[UInt8]]) { 16 | // insert code to broadcast transaction 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /ci/LDKSwift/Tests/LDKSwiftTests/TestChannelManagerPersister.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MyChannelManagerPersister.swift 3 | // LDKSwiftARC 4 | // 5 | // Created by Arik Sosman on 5/27/21. 6 | // 7 | 8 | #if SWIFT_PACKAGE 9 | import LDKSwift 10 | import LDKHeaders 11 | #endif 12 | 13 | class TestChannelManagerPersister: Persister, ExtendedChannelManagerPersister { 14 | 15 | private let channelManager: ChannelManager? 16 | 17 | init(channelManager: ChannelManager? = nil) { 18 | self.channelManager = channelManager 19 | super.init() 20 | } 21 | 22 | func handleEvent(event: Event) -> Result_NoneReplayEventZ { 23 | .initWithOk() 24 | } 25 | 26 | override func persistScorer(scorer: Bindings.WriteableScore) -> Bindings.Result_NoneIOErrorZ { 27 | .initWithOk() 28 | } 29 | 30 | override func persistGraph(networkGraph: Bindings.NetworkGraph) -> Bindings.Result_NoneIOErrorZ { 31 | .initWithOk() 32 | } 33 | 34 | override func persistManager(channelManager: Bindings.ChannelManager) -> Bindings.Result_NoneIOErrorZ { 35 | .initWithOk() 36 | } 37 | } 38 | 39 | class FloatingChannelManagerPersister: Persister { 40 | 41 | private let channelManager: ChannelManager? 42 | 43 | init(channelManager: ChannelManager? = nil) { 44 | self.channelManager = channelManager 45 | super.init() 46 | } 47 | /* 48 | func handle_event(event: Event) { 49 | // privateHandleEvent(event: event) 50 | } 51 | 52 | override func persist_manager(channel_manager: ChannelManager) -> Result_NoneErrorZ { 53 | return Result_NoneErrorZ() 54 | } 55 | */ 56 | } 57 | -------------------------------------------------------------------------------- /ci/LDKSwift/Tests/LDKSwiftTests/TestFeeEstimator.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MyFeeEstimator.swift 3 | // LDKSwiftARC 4 | // 5 | // Created by Arik Sosman on 5/17/21. 6 | // 7 | 8 | #if SWIFT_PACKAGE 9 | import LDKSwift 10 | import LDKHeaders 11 | #endif 12 | 13 | class TestFeeEstimator: FeeEstimator { 14 | 15 | override func getEstSatPer1000Weight(confirmationTarget: Bindings.ConfirmationTarget) -> UInt32 { 16 | return 253 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /ci/LDKSwift/Tests/LDKSwiftTests/TestFilter.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MyFilter.swift 3 | // LDKSwiftARC 4 | // 5 | // Created by Arik Sosman on 5/17/21. 6 | // 7 | 8 | #if SWIFT_PACKAGE 9 | import LDKSwift 10 | import LDKHeaders 11 | #endif 12 | 13 | class TestFilter: Filter { 14 | 15 | override func registerTx(txid: [UInt8]?, scriptPubkey: [UInt8]) { 16 | // watch this transaction on-chain 17 | } 18 | 19 | override func registerOutput(output: Bindings.WatchedOutput) { 20 | let scriptPubkeyBytes = output.getScriptPubkey() 21 | let outpoint = output.getOutpoint() 22 | let txid = outpoint.getTxid() 23 | let outputIndex = outpoint.getIndex() 24 | 25 | // watch for any transactions that spend this output on-chain 26 | 27 | let blockHashBytes = output.getBlockHash() 28 | // if block hash bytes are not null, return any transaction spending the output that is found in the corresponding block along with its index 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /ci/LDKSwift/Tests/LDKSwiftTests/TestLogger.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MyLogger.swift 3 | // LDKSwiftARC 4 | // 5 | // Created by Arik Sosman on 5/17/21. 6 | // 7 | 8 | #if SWIFT_PACKAGE 9 | import LDKSwift 10 | import LDKHeaders 11 | #endif 12 | 13 | class TestLogger: Logger { 14 | 15 | override func log(record: Record) { 16 | print( 17 | "\nRLTestLogger (\(record.getLevel())): \(record.getFile()):\(record.getLine()):\n> \(record.getArgs())\n") 18 | } 19 | 20 | } 21 | 22 | class MuteLogger: Logger { 23 | 24 | override func log(record: Record) { 25 | // do nothing 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /ci/LDKSwift/Tests/LDKSwiftTests/TestPersister.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MyPersister.swift 3 | // LDKSwiftARC 4 | // 5 | // Created by Arik Sosman on 5/17/21. 6 | // 7 | 8 | #if SWIFT_PACKAGE 9 | import LDKSwift 10 | import LDKHeaders 11 | #endif 12 | 13 | class TestPersister: Persist { 14 | 15 | override func persistNewChannel(channelFundingOutpoint: Bindings.OutPoint, monitor: Bindings.ChannelMonitor) 16 | -> Bindings.ChannelMonitorUpdateStatus 17 | { 18 | .Completed 19 | } 20 | 21 | override func updatePersistedChannel( 22 | channelFundingOutpoint: Bindings.OutPoint, monitorUpdate: Bindings.ChannelMonitorUpdate, 23 | monitor: Bindings.ChannelMonitor 24 | ) -> Bindings.ChannelMonitorUpdateStatus { 25 | .Completed 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /ci/LDKSwift/Tests/LDKSwiftTests/bitcoin/BTCHashing.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BTCHashing.swift 3 | // DirectBindingsAppTests 4 | // 5 | // Created by Arik Sosman on 3/29/22. 6 | // 7 | 8 | import Crypto 9 | 10 | #if SWIFT_PACKAGE 11 | import LDKSwift 12 | import LDKHeaders 13 | #endif 14 | 15 | class BTCHashing { 16 | 17 | public static let SHA_ZERO_HASH = [UInt8](repeating: 0, count: 32) 18 | public static let RIPEMD_ZERO_HASH = [UInt8](repeating: 0, count: 20) 19 | 20 | private static func sha256(_ input: [UInt8]) -> [UInt8] { 21 | let hash = Crypto.SHA256.hash(data: input) 22 | let bytes = Array(hash) 23 | assert(bytes.count == 32) 24 | return bytes 25 | } 26 | 27 | static func doubleSha256(_ input: [UInt8]) -> [UInt8] { 28 | return sha256(sha256(input)) 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /ci/LDKSwift/Tests/LDKSwiftTests/bitcoin/BTCVarInt.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BTCVarInt.swift 3 | // DirectBindingsApp 4 | // 5 | // Created by Arik Sosman on 3/29/22. 6 | // 7 | 8 | #if SWIFT_PACKAGE 9 | import LDKSwift 10 | import LDKHeaders 11 | #endif 12 | 13 | public class BTCVarInt { 14 | 15 | private let value: UInt64 16 | 17 | public init(_ value: UInt64) { 18 | self.value = value 19 | } 20 | 21 | public func serialize() -> [UInt8] { 22 | var varInt = [UInt8]() 23 | var valueBytes: [UInt8] 24 | 25 | if self.value < 0xfd { 26 | return [UInt8(self.value)] 27 | } else if self.value <= 0xffff { 28 | varInt.append(0xfd) 29 | valueBytes = withUnsafeBytes(of: UInt16(self.value).littleEndian) { bytes in 30 | Array(bytes) 31 | } 32 | } else if self.value <= 0xffff_ffff { 33 | varInt.append(0xfe) 34 | valueBytes = withUnsafeBytes(of: UInt32(self.value).littleEndian) { bytes in 35 | Array(bytes) 36 | } 37 | } else { 38 | varInt.append(0xff) 39 | valueBytes = withUnsafeBytes(of: self.value.littleEndian) { bytes in 40 | Array(bytes) 41 | } 42 | } 43 | varInt.append(contentsOf: valueBytes) 44 | return varInt 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /ci/build_frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | # https://stackoverflow.com/a/4774063/299711 6 | BASEDIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" 7 | BUILD_PRODUCTS_DIR="${BASEDIR}/../bindings/bin" # directory to copy the shared library and headers into 8 | BUILD_LOG_PATH="${BASEDIR}/build_frameworks.log" 9 | 10 | # initialize the build log 11 | echo -n "" > $BUILD_LOG_PATH 12 | 13 | # force xcode 13.2.1 for the tuple fix for macabi 14 | sudo xcode-select -s /Applications/Xcode\ 13.2.1.app/Contents/Developer/ 15 | 16 | if [[ $CONFIGURATION = "Debug" ]]; then 17 | RUST_CONFIGURATION="debug" 18 | RUST_CONFIGURATION_FLAG="" 19 | else 20 | RUST_CONFIGURATION="release" 21 | RUST_CONFIGURATION_FLAG="--release" 22 | fi 23 | 24 | XCFRAMEWORK_INPUT_FLAGS="" 25 | 26 | declare -a destinationNames=( "iOS Simulator" "iOS" "OS X" "macOS,variant=Mac Catalyst" ) 27 | declare -a lipoDirectoryNames=( "iphonesimulator" "iphoneos" "macosx" "catalyst" ) 28 | 29 | declare archiveCount=${#lipoDirectoryNames[@]} 30 | for (( i=0; i<$archiveCount; i++ )); 31 | do 32 | CURRENT_DESTINATION_NAME=${destinationNames[$i]} 33 | CURRENT_LIPO_DIRECTORY_NAME_INFIX=${lipoDirectoryNames[$i]} 34 | CURRENT_ARCHIVE_DIRECTORY="${BASEDIR}/../bindings/bin/${RUST_CONFIGURATION}/${CURRENT_LIPO_DIRECTORY_NAME_INFIX}/xcarchive" 35 | CURRENT_DERIVED_DATA_DIRECTORY="${BASEDIR}/../bindings/bin/${RUST_CONFIGURATION}/${CURRENT_LIPO_DIRECTORY_NAME_INFIX}/DerivedData" 36 | CURRENT_ARCHIVE_PATH="${CURRENT_ARCHIVE_DIRECTORY}/${CURRENT_LIPO_DIRECTORY_NAME_INFIX}" 37 | 38 | CURRENT_LIPO_DIRECTORY_PATH="${BUILD_PRODUCTS_DIR}/${RUST_CONFIGURATION}/${CURRENT_LIPO_DIRECTORY_NAME_INFIX}/lipo" 39 | export LDK_C_BINDINGS_BINARY_DIRECTORY="${CURRENT_LIPO_DIRECTORY_PATH}" 40 | 41 | echo "Building xcarchive for ${CURRENT_DESTINATION_NAME}" >> $BUILD_LOG_PATH 42 | echo "Current lipo input directory: ${CURRENT_LIPO_DIRECTORY_PATH}" >> $BUILD_LOG_PATH 43 | echo "Current derived data directory: ${CURRENT_DERIVED_DATA_DIRECTORY}" >> $BUILD_LOG_PATH 44 | echo "Current xcarchive output directory: ${CURRENT_ARCHIVE_PATH}" >> $BUILD_LOG_PATH 45 | 46 | mkdir -p "${CURRENT_ARCHIVE_DIRECTORY}" 47 | mkdir -p "${CURRENT_DERIVED_DATA_DIRECTORY}" 48 | find "${CURRENT_ARCHIVE_DIRECTORY}" -mindepth 1 -delete 49 | find "${CURRENT_DERIVED_DATA_DIRECTORY}" -mindepth 1 -delete 50 | 51 | pushd "${BASEDIR}/LDKSwift" 52 | xcodebuild archive -scheme LDKSwift -destination "generic/platform=${CURRENT_DESTINATION_NAME}" -derivedDataPath "${CURRENT_DERIVED_DATA_DIRECTORY}" -archivePath "${CURRENT_ARCHIVE_PATH}" ENABLE_BITCODE=NO EXCLUDED_ARCHS="i386 armv7" SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES 53 | # xcodebuild -scheme LDKSwift -destination "generic/platform=${CURRENT_DESTINATION_NAME}" ENABLE_BITCODE=NO SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES 54 | popd 55 | 56 | # XCFRAMEWORK_INPUT_FLAGS="${XCFRAMEWORK_INPUT_FLAGS}-framework ${CURRENT_ARCHIVE_PATH}.xcarchive/Products/Library/Frameworks/LDKSwift.framework " 57 | XCFRAMEWORK_INPUT_FLAGS="${XCFRAMEWORK_INPUT_FLAGS}-framework ${CURRENT_ARCHIVE_PATH}.xcarchive/Products/usr/local/lib/LDKSwift.framework " 58 | echo "Current xcframework flags: ${XCFRAMEWORK_INPUT_FLAGS}" >> $BUILD_LOG_PATH 59 | echo "" >> $BUILD_LOG_PATH 60 | done 61 | 62 | XCODEBUILD_COMMAND="xcodebuild -create-xcframework ${XCFRAMEWORK_INPUT_FLAGS} -output ${BUILD_PRODUCTS_DIR}/LDKFramework.xcframework" 63 | echo "Xcode build command: ${XCODEBUILD_COMMAND}" >> $BUILD_LOG_PATH 64 | eval "${XCODEBUILD_COMMAND}" 65 | -------------------------------------------------------------------------------- /ci/docker-compose.yml: -------------------------------------------------------------------------------- 1 | services: 2 | swift-generation-ci: 3 | build: 4 | context: ../ 5 | dockerfile: ./Dockerfile 6 | -------------------------------------------------------------------------------- /ci/docker_setup.sh: -------------------------------------------------------------------------------- 1 | pushd ../ 2 | docker build -t swift-generation-ci -f ci/Dockerfile . 3 | -------------------------------------------------------------------------------- /ci/docker_shell.sh: -------------------------------------------------------------------------------- 1 | pushd ../ 2 | PROJECT_DIRECTORY=`pwd` 3 | LDK_DIRECTORY=$1 4 | MOUNT_CI_FOLDER=$2 5 | LDK_SUBDIRECTORY="$LDK_DIRECTORY/lightning-c-bindings" 6 | 7 | [[ "${LDK_DIRECTORY}" = "" || "${MOUNT_CI_FOLDER}" = "" ]] && echo "Usage: ./docker_shell.sh /path/to/ldk-c-bindings true/false" && exit 1; 8 | [ ! -d "${LDK_DIRECTORY}" ] && echo "Provided directory does not exist" && exit 1; 9 | [ ! -d "${LDK_SUBDIRECTORY}" ] && echo "Provided directory does not contain lightning-c-bindings directory." && exit 1; 10 | 11 | if [[ "${MOUNT_CI_FOLDER}" = "true" ]]; then 12 | # use for direct ci folder access 13 | # cp -R bindings/batteries ci/LDKSwift/Sources/LDKSwift 14 | # docker run --name "swift-generator-shell" -e MOUNTED_CI_FOLDER=true -i -v $PROJECT_DIRECTORY/ci:/ci -v $LDK_DIRECTORY:/ldk-c-bindings --rm -t swift-generation-ci /bin/bash 15 | docker run --name "swift-generator-shell" -e MOUNTED_CI_FOLDER=true -i -v $PROJECT_DIRECTORY/ci:/ci -v $LDK_DIRECTORY:/ldk-c-bindings -v $PROJECT_DIRECTORY/src:/src --rm -t swift-generation-ci /bin/bash 16 | elif [ "${MOUNT_CI_FOLDER}" = "false" ]; then 17 | docker run --name "swift-generator-shell" -e MOUNTED_CI_FOLDER=false -i -v $LDK_DIRECTORY:/ldk-c-bindings --rm -t swift-generation-ci /bin/bash 18 | else 19 | echo "Usage: ./docker_shell.sh /path/to/ldk-c-bindings true/false" && exit 1; 20 | fi 21 | -------------------------------------------------------------------------------- /ci/fix_header_includes.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | directory_path = os.path.dirname(os.path.realpath(__file__)) 5 | default_header_directory = f'{directory_path}/LDKSwift/Sources/LDKHeaders' 6 | header_directory = sys.argv[1] if len(sys.argv) >= 2 else default_header_directory 7 | # header_directory = f'{directory_path}/../xcode/LDKFramework' 8 | 9 | if not os.path.exists(header_directory): 10 | sys.exit(f'Directory "{header_directory}" does not exist') 11 | 12 | header_files = [] 13 | 14 | # Create a collection of local header (or C) files 15 | for current_directory, current_subdirectories, current_files in os.walk(header_directory): 16 | for current_header_file in current_files: 17 | current_file_path = os.path.join(current_directory, current_header_file) 18 | if not os.path.isfile(current_file_path): 19 | continue 20 | 21 | if not current_header_file.endswith('.h') and not current_header_file.endswith('.c'): 22 | continue 23 | 24 | header_files.append({'name': current_header_file, 'path': current_file_path}) 25 | 26 | for current_header_file in header_files: 27 | file_name = current_header_file['name'] 28 | path = current_header_file['path'] 29 | 30 | file_in = open(path, 'rt', encoding='utf-8') 31 | original_contents = file_in.read() 32 | file_in.close() 33 | 34 | fixed_contents = original_contents 35 | for other_header_file in header_files: 36 | other_file_name = other_header_file['name'] 37 | if other_file_name == file_name: 38 | continue 39 | 40 | if not other_file_name.endswith('.h'): 41 | # Only header files are ever imported, even though imports can happen in either header or C files 42 | continue 43 | 44 | # TODO: use regex to detect multi-space or other whitespace-altered includes and fix them correctly, too 45 | # Fix each local file's import by replacing angular brackets with quotes 46 | fixed_contents = fixed_contents.replace(f'#include <{other_file_name}>', f'#include "{other_file_name}"') 47 | if fixed_contents != original_contents: 48 | # Only save updated file if a change occurred 49 | file_out = open(path, 'wt', encoding='utf-8') 50 | file_out.write(fixed_contents) 51 | file_out.close() 52 | print(f'Fixed .h/.c file: {path}') 53 | 54 | -------------------------------------------------------------------------------- /ci/fix_swift_imports.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | directory_path = os.path.dirname(os.path.realpath(__file__)) 4 | header_directory = f'{directory_path}/LDKSwift/Sources/LDKSwift' 5 | 6 | swift_files = [] 7 | 8 | print("Should no longer be necessary due to #if SWIFT_PACKAGE checks") 9 | exit(0) 10 | 11 | # Create a collection of local header (or C) files 12 | for current_directory, current_subdirectories, current_files in os.walk(header_directory): 13 | for current_file in current_files: 14 | if not current_file.endswith('.swift'): 15 | continue 16 | swift_files.append({'name': current_file, 'path': os.path.join(current_directory, current_file)}) 17 | 18 | for current_swift_file in swift_files: 19 | file_name = current_swift_file['name'] 20 | path = current_swift_file['path'] 21 | 22 | file_in = open(path, 'rt', encoding='utf-8') 23 | original_contents = file_in.read() 24 | file_in.close() 25 | 26 | fixed_contents = original_contents 27 | 28 | if 'import LDKHeaders' not in original_contents: 29 | if 'import Foundation' in original_contents: 30 | fixed_contents = original_contents.replace('import Foundation', 'import Foundation\nimport LDKHeaders') 31 | else: 32 | fixed_contents = f'import LDKHeaders\n\n{original_contents}' 33 | 34 | if fixed_contents != original_contents: 35 | # Only save updated file if a change occurred 36 | file_out = open(path, 'wt', encoding='utf-8') 37 | file_out.write(fixed_contents) 38 | file_out.close() 39 | print(f'Fixed Swift file: {path}') 40 | 41 | -------------------------------------------------------------------------------- /ci/run_tests.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | set -x 3 | 4 | # find all directories and files within LDKSwift sources, exclude batteries. 5 | # If at least one result (xargs -r), remove recursively (rm -r) 6 | 7 | # remove everything except the batteries folder from the sources 8 | find ./LDKSwift/Sources/LDKSwift/* -maxdepth 0 -not -name 'batteries' | xargs -r rm -r 9 | 10 | # build the bindings 11 | pushd /ldk-c-bindings/lightning-c-bindings 12 | export RUSTFLAGS="--cfg=c_bindings" 13 | cargo build --features "std" 14 | popd 15 | 16 | pushd ../ 17 | # working within / 18 | 19 | python3 ./ 20 | 21 | mkdir -p /ci/LDKSwift/Sources/LDKHeaders/include/ 22 | cp /ldk-c-bindings/lightning-c-bindings/include/*.h /ci/LDKSwift/Sources/LDKHeaders/include/ 23 | cp /ldk-c-bindings/ldk-net/ldk_net.h /ci/LDKSwift/Sources/LDKHeaders/include/ 24 | cp /ldk-c-bindings/ldk-net/ldk_net.c /ci/LDKSwift/Sources/LDKHeaders/ 25 | 26 | popd 27 | # working within /ci 28 | 29 | python3 ./fix_header_includes.py 30 | python3 ./fix_swift_imports.py 31 | 32 | pushd LDKSwift/ 33 | #swift test 34 | swift test -Xswiftc -suppress-warnings 35 | #swift test --filter 'testInvoiceSerialization' -Xswiftc -suppress-warnings 36 | #swift test --filter 'testMainnetGraphSync' -Xswiftc -suppress-warnings 37 | -------------------------------------------------------------------------------- /ci/toggle_address_sanitation_library.py: -------------------------------------------------------------------------------- 1 | import re 2 | import os 3 | import sys 4 | 5 | directory_path = os.path.dirname(os.path.realpath(__file__)) 6 | file_path = f'{directory_path}/LDKSwift/Package.swift' 7 | if len(sys.argv) != 2: 8 | sys.exit('Usage: python3 toggle_address_sanitation_library.py [on/off]') 9 | 10 | if not os.path.isfile(file_path): 11 | sys.exit(f'Package.swift file is missing') 12 | 13 | should_enable_string = sys.argv[1] 14 | if not should_enable_string.lower() in ['on', 'off']: 15 | sys.exit(f'{should_enable_string} is not a valid on/off value') 16 | 17 | should_enable = True if should_enable_string.lower() == 'on' else False 18 | 19 | file_in = open(file_path, 'rt', encoding='utf-8') 20 | original_contents = file_in.read() 21 | file_in.close() 22 | 23 | regex = re.compile("(\/\/)?([^\S\r\n]*)(\.linkedLibrary\(String\(utf8String: getenv\(\"LLVM_CLANG_ASAN_PATH\"\)!\)!\))", re.MULTILINE) 24 | matches = regex.search(original_contents) 25 | 26 | comment_prefix = '' 27 | if not should_enable: 28 | comment_prefix = '//' 29 | 30 | toggle_result = regex.sub(f'\g<2>{comment_prefix}\g<3>', original_contents) 31 | 32 | file_out = open(file_path, 'wt', encoding='utf-8') 33 | file_out.write(toggle_result) 34 | file_out.close() 35 | -------------------------------------------------------------------------------- /ci/walker.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | walk_directory = sys.argv[1] if len(sys.argv) > 1 else os.path.dirname(os.path.realpath(__file__)) 5 | 6 | # Create a collection of local header (or C) files 7 | for current_directory, current_subdirectories, current_files in os.walk(walk_directory): 8 | for current_file in current_files: 9 | print(os.path.realpath(os.path.join(current_directory, current_file))) 10 | -------------------------------------------------------------------------------- /out/VersionDescriptor.swift: -------------------------------------------------------------------------------- 1 | #if SWIFT_PACKAGE 2 | import LDKHeaders 3 | #endif 4 | 5 | extension Bindings { 6 | public class func getLDKSwiftBindingsSerializationHash() -> String { 7 | return "79076e354f009c6232a3c95bfacfc59f4b4ca4a3cc6b6133ee8f58ee856fac31" 8 | } 9 | public class func getLDKSwiftBindingsVersion() -> String { 10 | return "0.0.124-2-g591c5860-dirty" 11 | } 12 | public class func getLDKSwiftBindingsCommitHash() -> String { 13 | return "591c58608bdf1a3e1c22902c42b4f00530b1dd9d" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /out/enums/primitive/BalanceSource.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// Indicates whether the balance is derived from a cooperative close, a force-close 9 | /// (for holder or counterparty), or whether it is for an HTLC. 10 | public typealias BalanceSource = Bindings.BalanceSource 11 | 12 | extension Bindings { 13 | 14 | /// Indicates whether the balance is derived from a cooperative close, a force-close 15 | /// (for holder or counterparty), or whether it is for an HTLC. 16 | public enum BalanceSource { 17 | 18 | 19 | /// The channel was force closed by the holder. 20 | case HolderForceClosed 21 | 22 | /// The channel was force closed by the counterparty. 23 | case CounterpartyForceClosed 24 | 25 | /// The channel was cooperatively closed. 26 | case CoopClose 27 | 28 | /// This balance is the result of an HTLC. 29 | case Htlc 30 | 31 | 32 | internal init(value: LDKBalanceSource) { 33 | switch value { 34 | 35 | case LDKBalanceSource_HolderForceClosed: 36 | self = .HolderForceClosed 37 | 38 | case LDKBalanceSource_CounterpartyForceClosed: 39 | self = .CounterpartyForceClosed 40 | 41 | case LDKBalanceSource_CoopClose: 42 | self = .CoopClose 43 | 44 | case LDKBalanceSource_Htlc: 45 | self = .Htlc 46 | 47 | default: 48 | Bindings.print("Error: Invalid value type for BalanceSource! Aborting.", severity: .ERROR) 49 | abort() 50 | 51 | } 52 | } 53 | 54 | internal func getCValue() -> LDKBalanceSource { 55 | switch self { 56 | 57 | case .HolderForceClosed: 58 | return LDKBalanceSource_HolderForceClosed 59 | 60 | case .CounterpartyForceClosed: 61 | return LDKBalanceSource_CounterpartyForceClosed 62 | 63 | case .CoopClose: 64 | return LDKBalanceSource_CoopClose 65 | 66 | case .Htlc: 67 | return LDKBalanceSource_Htlc 68 | 69 | } 70 | } 71 | 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /out/enums/primitive/BlindedFailure.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// Whether this blinded HTLC is being failed backwards by the introduction node or a blinded node, 9 | /// which determines the failure message that should be used. 10 | public typealias BlindedFailure = Bindings.BlindedFailure 11 | 12 | extension Bindings { 13 | 14 | /// Whether this blinded HTLC is being failed backwards by the introduction node or a blinded node, 15 | /// which determines the failure message that should be used. 16 | public enum BlindedFailure { 17 | 18 | 19 | /// This HTLC is being failed backwards by the introduction node, and thus should be failed with 20 | /// [`msgs::UpdateFailHTLC`] and error code `0x8000|0x4000|24`. 21 | case FromIntroductionNode 22 | 23 | /// This HTLC is being failed backwards by a blinded node within the path, and thus should be 24 | /// failed with [`msgs::UpdateFailMalformedHTLC`] and error code `0x8000|0x4000|24`. 25 | case FromBlindedNode 26 | 27 | 28 | internal init(value: LDKBlindedFailure) { 29 | switch value { 30 | 31 | case LDKBlindedFailure_FromIntroductionNode: 32 | self = .FromIntroductionNode 33 | 34 | case LDKBlindedFailure_FromBlindedNode: 35 | self = .FromBlindedNode 36 | 37 | default: 38 | Bindings.print("Error: Invalid value type for BlindedFailure! Aborting.", severity: .ERROR) 39 | abort() 40 | 41 | } 42 | } 43 | 44 | internal func getCValue() -> LDKBlindedFailure { 45 | switch self { 46 | 47 | case .FromIntroductionNode: 48 | return LDKBlindedFailure_FromIntroductionNode 49 | 50 | case .FromBlindedNode: 51 | return LDKBlindedFailure_FromBlindedNode 52 | 53 | } 54 | } 55 | 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /out/enums/primitive/Bolt11SemanticError.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// Errors that may occur when converting a [`RawBolt11Invoice`] to a [`Bolt11Invoice`]. They relate to 9 | /// the requirements sections in BOLT #11 10 | public typealias Bolt11SemanticError = Bindings.Bolt11SemanticError 11 | 12 | extension Bindings { 13 | 14 | /// Errors that may occur when converting a [`RawBolt11Invoice`] to a [`Bolt11Invoice`]. They relate to 15 | /// the requirements sections in BOLT #11 16 | public enum Bolt11SemanticError { 17 | 18 | 19 | /// The invoice is missing the mandatory payment hash 20 | case NoPaymentHash 21 | 22 | /// The invoice has multiple payment hashes which isn't allowed 23 | case MultiplePaymentHashes 24 | 25 | /// No description or description hash are part of the invoice 26 | case NoDescription 27 | 28 | /// The invoice contains multiple descriptions and/or description hashes which isn't allowed 29 | case MultipleDescriptions 30 | 31 | /// The invoice is missing the mandatory payment secret, which all modern lightning nodes 32 | /// should provide. 33 | case NoPaymentSecret 34 | 35 | /// The invoice contains multiple payment secrets 36 | case MultiplePaymentSecrets 37 | 38 | /// The invoice's features are invalid 39 | case InvalidFeatures 40 | 41 | /// The recovery id doesn't fit the signature/pub key 42 | case InvalidRecoveryId 43 | 44 | /// The invoice's signature is invalid 45 | case InvalidSignature 46 | 47 | /// The invoice's amount was not a whole number of millisatoshis 48 | case ImpreciseAmount 49 | 50 | 51 | internal init(value: LDKBolt11SemanticError) { 52 | switch value { 53 | 54 | case LDKBolt11SemanticError_NoPaymentHash: 55 | self = .NoPaymentHash 56 | 57 | case LDKBolt11SemanticError_MultiplePaymentHashes: 58 | self = .MultiplePaymentHashes 59 | 60 | case LDKBolt11SemanticError_NoDescription: 61 | self = .NoDescription 62 | 63 | case LDKBolt11SemanticError_MultipleDescriptions: 64 | self = .MultipleDescriptions 65 | 66 | case LDKBolt11SemanticError_NoPaymentSecret: 67 | self = .NoPaymentSecret 68 | 69 | case LDKBolt11SemanticError_MultiplePaymentSecrets: 70 | self = .MultiplePaymentSecrets 71 | 72 | case LDKBolt11SemanticError_InvalidFeatures: 73 | self = .InvalidFeatures 74 | 75 | case LDKBolt11SemanticError_InvalidRecoveryId: 76 | self = .InvalidRecoveryId 77 | 78 | case LDKBolt11SemanticError_InvalidSignature: 79 | self = .InvalidSignature 80 | 81 | case LDKBolt11SemanticError_ImpreciseAmount: 82 | self = .ImpreciseAmount 83 | 84 | default: 85 | Bindings.print("Error: Invalid value type for Bolt11SemanticError! Aborting.", severity: .ERROR) 86 | abort() 87 | 88 | } 89 | } 90 | 91 | internal func getCValue() -> LDKBolt11SemanticError { 92 | switch self { 93 | 94 | case .NoPaymentHash: 95 | return LDKBolt11SemanticError_NoPaymentHash 96 | 97 | case .MultiplePaymentHashes: 98 | return LDKBolt11SemanticError_MultiplePaymentHashes 99 | 100 | case .NoDescription: 101 | return LDKBolt11SemanticError_NoDescription 102 | 103 | case .MultipleDescriptions: 104 | return LDKBolt11SemanticError_MultipleDescriptions 105 | 106 | case .NoPaymentSecret: 107 | return LDKBolt11SemanticError_NoPaymentSecret 108 | 109 | case .MultiplePaymentSecrets: 110 | return LDKBolt11SemanticError_MultiplePaymentSecrets 111 | 112 | case .InvalidFeatures: 113 | return LDKBolt11SemanticError_InvalidFeatures 114 | 115 | case .InvalidRecoveryId: 116 | return LDKBolt11SemanticError_InvalidRecoveryId 117 | 118 | case .InvalidSignature: 119 | return LDKBolt11SemanticError_InvalidSignature 120 | 121 | case .ImpreciseAmount: 122 | return LDKBolt11SemanticError_ImpreciseAmount 123 | 124 | } 125 | } 126 | 127 | } 128 | 129 | } 130 | -------------------------------------------------------------------------------- /out/enums/primitive/ChannelShutdownState.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// Further information on the details of the channel shutdown. 9 | /// Upon channels being forced closed (i.e. commitment transaction confirmation detected 10 | /// by `ChainMonitor`), ChannelShutdownState will be set to `ShutdownComplete` or 11 | /// the channel will be removed shortly. 12 | /// Also note, that in normal operation, peers could disconnect at any of these states 13 | /// and require peer re-connection before making progress onto other states 14 | public typealias ChannelShutdownState = Bindings.ChannelShutdownState 15 | 16 | extension Bindings { 17 | 18 | /// Further information on the details of the channel shutdown. 19 | /// Upon channels being forced closed (i.e. commitment transaction confirmation detected 20 | /// by `ChainMonitor`), ChannelShutdownState will be set to `ShutdownComplete` or 21 | /// the channel will be removed shortly. 22 | /// Also note, that in normal operation, peers could disconnect at any of these states 23 | /// and require peer re-connection before making progress onto other states 24 | public enum ChannelShutdownState { 25 | 26 | 27 | /// Channel has not sent or received a shutdown message. 28 | case NotShuttingDown 29 | 30 | /// Local node has sent a shutdown message for this channel. 31 | case ShutdownInitiated 32 | 33 | /// Shutdown message exchanges have concluded and the channels are in the midst of 34 | /// resolving all existing open HTLCs before closing can continue. 35 | case ResolvingHTLCs 36 | 37 | /// All HTLCs have been resolved, nodes are currently negotiating channel close onchain fee rates. 38 | case NegotiatingClosingFee 39 | 40 | /// We've successfully negotiated a closing_signed dance. At this point `ChannelManager` is about 41 | /// to drop the channel. 42 | case ShutdownComplete 43 | 44 | 45 | internal init(value: LDKChannelShutdownState) { 46 | switch value { 47 | 48 | case LDKChannelShutdownState_NotShuttingDown: 49 | self = .NotShuttingDown 50 | 51 | case LDKChannelShutdownState_ShutdownInitiated: 52 | self = .ShutdownInitiated 53 | 54 | case LDKChannelShutdownState_ResolvingHTLCs: 55 | self = .ResolvingHTLCs 56 | 57 | case LDKChannelShutdownState_NegotiatingClosingFee: 58 | self = .NegotiatingClosingFee 59 | 60 | case LDKChannelShutdownState_ShutdownComplete: 61 | self = .ShutdownComplete 62 | 63 | default: 64 | Bindings.print("Error: Invalid value type for ChannelShutdownState! Aborting.", severity: .ERROR) 65 | abort() 66 | 67 | } 68 | } 69 | 70 | internal func getCValue() -> LDKChannelShutdownState { 71 | switch self { 72 | 73 | case .NotShuttingDown: 74 | return LDKChannelShutdownState_NotShuttingDown 75 | 76 | case .ShutdownInitiated: 77 | return LDKChannelShutdownState_ShutdownInitiated 78 | 79 | case .ResolvingHTLCs: 80 | return LDKChannelShutdownState_ResolvingHTLCs 81 | 82 | case .NegotiatingClosingFee: 83 | return LDKChannelShutdownState_NegotiatingClosingFee 84 | 85 | case .ShutdownComplete: 86 | return LDKChannelShutdownState_ShutdownComplete 87 | 88 | } 89 | } 90 | 91 | } 92 | 93 | } 94 | -------------------------------------------------------------------------------- /out/enums/primitive/CreationError.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// Errors that may occur when constructing a new [`RawBolt11Invoice`] or [`Bolt11Invoice`] 9 | public typealias CreationError = Bindings.CreationError 10 | 11 | extension Bindings { 12 | 13 | /// Errors that may occur when constructing a new [`RawBolt11Invoice`] or [`Bolt11Invoice`] 14 | public enum CreationError { 15 | 16 | 17 | /// The supplied description string was longer than 639 __bytes__ (see [`Description::new`]) 18 | case DescriptionTooLong 19 | 20 | /// The specified route has too many hops and can't be encoded 21 | case RouteTooLong 22 | 23 | /// The Unix timestamp of the supplied date is less than zero or greater than 35-bits 24 | case TimestampOutOfBounds 25 | 26 | /// The supplied millisatoshi amount was greater than the total bitcoin supply. 27 | case InvalidAmount 28 | 29 | /// Route hints were required for this invoice and were missing. 30 | case MissingRouteHints 31 | 32 | /// The provided `min_final_cltv_expiry_delta` was less than rust-lightning's minimum. 33 | case MinFinalCltvExpiryDeltaTooShort 34 | 35 | 36 | internal init(value: LDKCreationError) { 37 | switch value { 38 | 39 | case LDKCreationError_DescriptionTooLong: 40 | self = .DescriptionTooLong 41 | 42 | case LDKCreationError_RouteTooLong: 43 | self = .RouteTooLong 44 | 45 | case LDKCreationError_TimestampOutOfBounds: 46 | self = .TimestampOutOfBounds 47 | 48 | case LDKCreationError_InvalidAmount: 49 | self = .InvalidAmount 50 | 51 | case LDKCreationError_MissingRouteHints: 52 | self = .MissingRouteHints 53 | 54 | case LDKCreationError_MinFinalCltvExpiryDeltaTooShort: 55 | self = .MinFinalCltvExpiryDeltaTooShort 56 | 57 | default: 58 | Bindings.print("Error: Invalid value type for CreationError! Aborting.", severity: .ERROR) 59 | abort() 60 | 61 | } 62 | } 63 | 64 | internal func getCValue() -> LDKCreationError { 65 | switch self { 66 | 67 | case .DescriptionTooLong: 68 | return LDKCreationError_DescriptionTooLong 69 | 70 | case .RouteTooLong: 71 | return LDKCreationError_RouteTooLong 72 | 73 | case .TimestampOutOfBounds: 74 | return LDKCreationError_TimestampOutOfBounds 75 | 76 | case .InvalidAmount: 77 | return LDKCreationError_InvalidAmount 78 | 79 | case .MissingRouteHints: 80 | return LDKCreationError_MissingRouteHints 81 | 82 | case .MinFinalCltvExpiryDeltaTooShort: 83 | return LDKCreationError_MinFinalCltvExpiryDeltaTooShort 84 | 85 | } 86 | } 87 | 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /out/enums/primitive/Currency.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// Enum representing the crypto currencies (or networks) supported by this library 9 | public typealias Currency = Bindings.Currency 10 | 11 | extension Bindings { 12 | 13 | /// Enum representing the crypto currencies (or networks) supported by this library 14 | public enum Currency { 15 | 16 | 17 | /// Bitcoin mainnet 18 | case Bitcoin 19 | 20 | /// Bitcoin testnet 21 | case BitcoinTestnet 22 | 23 | /// Bitcoin regtest 24 | case Regtest 25 | 26 | /// Bitcoin simnet 27 | case Simnet 28 | 29 | /// Bitcoin signet 30 | case Signet 31 | 32 | 33 | internal init(value: LDKCurrency) { 34 | switch value { 35 | 36 | case LDKCurrency_Bitcoin: 37 | self = .Bitcoin 38 | 39 | case LDKCurrency_BitcoinTestnet: 40 | self = .BitcoinTestnet 41 | 42 | case LDKCurrency_Regtest: 43 | self = .Regtest 44 | 45 | case LDKCurrency_Simnet: 46 | self = .Simnet 47 | 48 | case LDKCurrency_Signet: 49 | self = .Signet 50 | 51 | default: 52 | Bindings.print("Error: Invalid value type for Currency! Aborting.", severity: .ERROR) 53 | abort() 54 | 55 | } 56 | } 57 | 58 | internal func getCValue() -> LDKCurrency { 59 | switch self { 60 | 61 | case .Bitcoin: 62 | return LDKCurrency_Bitcoin 63 | 64 | case .BitcoinTestnet: 65 | return LDKCurrency_BitcoinTestnet 66 | 67 | case .Regtest: 68 | return LDKCurrency_Regtest 69 | 70 | case .Simnet: 71 | return LDKCurrency_Simnet 72 | 73 | case .Signet: 74 | return LDKCurrency_Signet 75 | 76 | } 77 | } 78 | 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /out/enums/primitive/Direction.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// The side of a channel that is the [`IntroductionNode`] in a blinded path. [BOLT 7] defines which 9 | /// nodes is which in the [`ChannelAnnouncement`] message. 10 | /// 11 | /// [BOLT 7]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message 12 | /// [`ChannelAnnouncement`]: crate::ln::msgs::ChannelAnnouncement 13 | public typealias Direction = Bindings.Direction 14 | 15 | extension Bindings { 16 | 17 | /// The side of a channel that is the [`IntroductionNode`] in a blinded path. [BOLT 7] defines which 18 | /// nodes is which in the [`ChannelAnnouncement`] message. 19 | /// 20 | /// [BOLT 7]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-channel_announcement-message 21 | /// [`ChannelAnnouncement`]: crate::ln::msgs::ChannelAnnouncement 22 | public enum Direction { 23 | 24 | 25 | /// The lesser node id when compared lexicographically in ascending order. 26 | case NodeOne 27 | 28 | /// The greater node id when compared lexicographically in ascending order. 29 | case NodeTwo 30 | 31 | 32 | internal init(value: LDKDirection) { 33 | switch value { 34 | 35 | case LDKDirection_NodeOne: 36 | self = .NodeOne 37 | 38 | case LDKDirection_NodeTwo: 39 | self = .NodeTwo 40 | 41 | default: 42 | Bindings.print("Error: Invalid value type for Direction! Aborting.", severity: .ERROR) 43 | abort() 44 | 45 | } 46 | } 47 | 48 | internal func getCValue() -> LDKDirection { 49 | switch self { 50 | 51 | case .NodeOne: 52 | return LDKDirection_NodeOne 53 | 54 | case .NodeTwo: 55 | return LDKDirection_NodeTwo 56 | 57 | } 58 | } 59 | 60 | } 61 | 62 | } 63 | -------------------------------------------------------------------------------- /out/enums/primitive/HTLCClaim.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// Describes the type of HTLC claim as determined by analyzing the witness. 9 | public typealias HTLCClaim = Bindings.HTLCClaim 10 | 11 | extension Bindings { 12 | 13 | /// Describes the type of HTLC claim as determined by analyzing the witness. 14 | public enum HTLCClaim { 15 | 16 | 17 | /// Claims an offered output on a commitment transaction through the timeout path. 18 | case OfferedTimeout 19 | 20 | /// Claims an offered output on a commitment transaction through the success path. 21 | case OfferedPreimage 22 | 23 | /// Claims an accepted output on a commitment transaction through the timeout path. 24 | case AcceptedTimeout 25 | 26 | /// Claims an accepted output on a commitment transaction through the success path. 27 | case AcceptedPreimage 28 | 29 | /// Claims an offered/accepted output on a commitment transaction through the revocation path. 30 | case Revocation 31 | 32 | 33 | internal init(value: LDKHTLCClaim) { 34 | switch value { 35 | 36 | case LDKHTLCClaim_OfferedTimeout: 37 | self = .OfferedTimeout 38 | 39 | case LDKHTLCClaim_OfferedPreimage: 40 | self = .OfferedPreimage 41 | 42 | case LDKHTLCClaim_AcceptedTimeout: 43 | self = .AcceptedTimeout 44 | 45 | case LDKHTLCClaim_AcceptedPreimage: 46 | self = .AcceptedPreimage 47 | 48 | case LDKHTLCClaim_Revocation: 49 | self = .Revocation 50 | 51 | default: 52 | Bindings.print("Error: Invalid value type for HTLCClaim! Aborting.", severity: .ERROR) 53 | abort() 54 | 55 | } 56 | } 57 | 58 | internal func getCValue() -> LDKHTLCClaim { 59 | switch self { 60 | 61 | case .OfferedTimeout: 62 | return LDKHTLCClaim_OfferedTimeout 63 | 64 | case .OfferedPreimage: 65 | return LDKHTLCClaim_OfferedPreimage 66 | 67 | case .AcceptedTimeout: 68 | return LDKHTLCClaim_AcceptedTimeout 69 | 70 | case .AcceptedPreimage: 71 | return LDKHTLCClaim_AcceptedPreimage 72 | 73 | case .Revocation: 74 | return LDKHTLCClaim_Revocation 75 | 76 | } 77 | } 78 | 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /out/enums/primitive/Level.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// An enum representing the available verbosity levels of the logger. 9 | public typealias Level = Bindings.Level 10 | 11 | extension Bindings { 12 | 13 | /// An enum representing the available verbosity levels of the logger. 14 | public enum Level { 15 | 16 | 17 | /// Designates extremely verbose information, including gossip-induced messages 18 | case Gossip 19 | 20 | /// Designates very low priority, often extremely verbose, information 21 | case Trace 22 | 23 | /// Designates lower priority information 24 | case Debug 25 | 26 | /// Designates useful information 27 | case Info 28 | 29 | /// Designates hazardous situations 30 | case Warn 31 | 32 | /// Designates very serious errors 33 | case Error 34 | 35 | 36 | internal init(value: LDKLevel) { 37 | switch value { 38 | 39 | case LDKLevel_Gossip: 40 | self = .Gossip 41 | 42 | case LDKLevel_Trace: 43 | self = .Trace 44 | 45 | case LDKLevel_Debug: 46 | self = .Debug 47 | 48 | case LDKLevel_Info: 49 | self = .Info 50 | 51 | case LDKLevel_Warn: 52 | self = .Warn 53 | 54 | case LDKLevel_Error: 55 | self = .Error 56 | 57 | default: 58 | Bindings.print("Error: Invalid value type for Level! Aborting.", severity: .ERROR) 59 | abort() 60 | 61 | } 62 | } 63 | 64 | internal func getCValue() -> LDKLevel { 65 | switch self { 66 | 67 | case .Gossip: 68 | return LDKLevel_Gossip 69 | 70 | case .Trace: 71 | return LDKLevel_Trace 72 | 73 | case .Debug: 74 | return LDKLevel_Debug 75 | 76 | case .Info: 77 | return LDKLevel_Info 78 | 79 | case .Warn: 80 | return LDKLevel_Warn 81 | 82 | case .Error: 83 | return LDKLevel_Error 84 | 85 | } 86 | } 87 | 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /out/enums/primitive/Network.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// An enum representing the possible Bitcoin or test networks which we can run on 9 | public typealias Network = Bindings.Network 10 | 11 | extension Bindings { 12 | 13 | /// An enum representing the possible Bitcoin or test networks which we can run on 14 | public enum Network { 15 | 16 | 17 | /// The main Bitcoin blockchain. 18 | case Bitcoin 19 | 20 | /// The testnet3 blockchain. 21 | case Testnet 22 | 23 | /// A local test blockchain. 24 | case Regtest 25 | 26 | /// A blockchain on which blocks are signed instead of mined. 27 | case Signet 28 | 29 | 30 | internal init(value: LDKNetwork) { 31 | switch value { 32 | 33 | case LDKNetwork_Bitcoin: 34 | self = .Bitcoin 35 | 36 | case LDKNetwork_Testnet: 37 | self = .Testnet 38 | 39 | case LDKNetwork_Regtest: 40 | self = .Regtest 41 | 42 | case LDKNetwork_Signet: 43 | self = .Signet 44 | 45 | default: 46 | Bindings.print("Error: Invalid value type for Network! Aborting.", severity: .ERROR) 47 | abort() 48 | 49 | } 50 | } 51 | 52 | internal func getCValue() -> LDKNetwork { 53 | switch self { 54 | 55 | case .Bitcoin: 56 | return LDKNetwork_Bitcoin 57 | 58 | case .Testnet: 59 | return LDKNetwork_Testnet 60 | 61 | case .Regtest: 62 | return LDKNetwork_Regtest 63 | 64 | case .Signet: 65 | return LDKNetwork_Signet 66 | 67 | } 68 | } 69 | 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /out/enums/primitive/Option_NoneZ.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// An enum which can either contain a or not 9 | public typealias Option_NoneZ = Bindings.Option_NoneZ 10 | 11 | extension Bindings { 12 | 13 | /// An enum which can either contain a or not 14 | public enum Option_NoneZ { 15 | 16 | 17 | /// When we're in this state, this COption_NoneZ contains a 18 | case Some 19 | 20 | /// When we're in this state, this COption_NoneZ contains nothing 21 | case None 22 | 23 | 24 | internal init(value: LDKCOption_NoneZ) { 25 | switch value { 26 | 27 | case LDKCOption_NoneZ_Some: 28 | self = .Some 29 | 30 | case LDKCOption_NoneZ_None: 31 | self = .None 32 | 33 | default: 34 | Bindings.print("Error: Invalid value type for Option_NoneZ! Aborting.", severity: .ERROR) 35 | abort() 36 | 37 | } 38 | } 39 | 40 | internal func getCValue() -> LDKCOption_NoneZ { 41 | switch self { 42 | 43 | case .Some: 44 | return LDKCOption_NoneZ_Some 45 | 46 | case .None: 47 | return LDKCOption_NoneZ_None 48 | 49 | } 50 | } 51 | 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /out/enums/primitive/Recipient.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// Specifies the recipient of an invoice. 9 | /// 10 | /// This indicates to [`NodeSigner::sign_invoice`] what node secret key should be used to sign 11 | /// the invoice. 12 | public typealias Recipient = Bindings.Recipient 13 | 14 | extension Bindings { 15 | 16 | /// Specifies the recipient of an invoice. 17 | /// 18 | /// This indicates to [`NodeSigner::sign_invoice`] what node secret key should be used to sign 19 | /// the invoice. 20 | public enum Recipient { 21 | 22 | 23 | /// The invoice should be signed with the local node secret key. 24 | case Node 25 | 26 | /// The invoice should be signed with the phantom node secret key. This secret key must be the 27 | /// same for all nodes participating in the [phantom node payment]. 28 | /// 29 | /// [phantom node payment]: PhantomKeysManager 30 | case PhantomNode 31 | 32 | 33 | internal init(value: LDKRecipient) { 34 | switch value { 35 | 36 | case LDKRecipient_Node: 37 | self = .Node 38 | 39 | case LDKRecipient_PhantomNode: 40 | self = .PhantomNode 41 | 42 | default: 43 | Bindings.print("Error: Invalid value type for Recipient! Aborting.", severity: .ERROR) 44 | abort() 45 | 46 | } 47 | } 48 | 49 | internal func getCValue() -> LDKRecipient { 50 | switch self { 51 | 52 | case .Node: 53 | return LDKRecipient_Node 54 | 55 | case .PhantomNode: 56 | return LDKRecipient_PhantomNode 57 | 58 | } 59 | } 60 | 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /out/enums/primitive/RetryableSendFailure.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// Indicates an immediate error on [`ChannelManager::send_payment`]. Further errors may be 9 | /// surfaced later via [`Event::PaymentPathFailed`] and [`Event::PaymentFailed`]. 10 | /// 11 | /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment 12 | /// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed 13 | /// [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed 14 | public typealias RetryableSendFailure = Bindings.RetryableSendFailure 15 | 16 | extension Bindings { 17 | 18 | /// Indicates an immediate error on [`ChannelManager::send_payment`]. Further errors may be 19 | /// surfaced later via [`Event::PaymentPathFailed`] and [`Event::PaymentFailed`]. 20 | /// 21 | /// [`ChannelManager::send_payment`]: crate::ln::channelmanager::ChannelManager::send_payment 22 | /// [`Event::PaymentPathFailed`]: crate::events::Event::PaymentPathFailed 23 | /// [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed 24 | public enum RetryableSendFailure { 25 | 26 | 27 | /// The provided [`PaymentParameters::expiry_time`] indicated that the payment has expired. Note 28 | /// that this error is *not* caused by [`Retry::Timeout`]. 29 | /// 30 | /// [`PaymentParameters::expiry_time`]: crate::routing::router::PaymentParameters::expiry_time 31 | case PaymentExpired 32 | 33 | /// We were unable to find a route to the destination. 34 | case RouteNotFound 35 | 36 | /// Indicates that a payment for the provided [`PaymentId`] is already in-flight and has not 37 | /// yet completed (i.e. generated an [`Event::PaymentSent`] or [`Event::PaymentFailed`]). 38 | /// 39 | /// [`PaymentId`]: crate::ln::channelmanager::PaymentId 40 | /// [`Event::PaymentSent`]: crate::events::Event::PaymentSent 41 | /// [`Event::PaymentFailed`]: crate::events::Event::PaymentFailed 42 | case DuplicatePayment 43 | 44 | /// The [`RecipientOnionFields::payment_metadata`], [`RecipientOnionFields::custom_tlvs`], or 45 | /// [`BlindedPaymentPath`]s provided are too large and caused us to exceed the maximum onion 46 | /// packet size of 1300 bytes. 47 | /// 48 | /// [`BlindedPaymentPath`]: crate::blinded_path::payment::BlindedPaymentPath 49 | case OnionPacketSizeExceeded 50 | 51 | 52 | internal init(value: LDKRetryableSendFailure) { 53 | switch value { 54 | 55 | case LDKRetryableSendFailure_PaymentExpired: 56 | self = .PaymentExpired 57 | 58 | case LDKRetryableSendFailure_RouteNotFound: 59 | self = .RouteNotFound 60 | 61 | case LDKRetryableSendFailure_DuplicatePayment: 62 | self = .DuplicatePayment 63 | 64 | case LDKRetryableSendFailure_OnionPacketSizeExceeded: 65 | self = .OnionPacketSizeExceeded 66 | 67 | default: 68 | Bindings.print("Error: Invalid value type for RetryableSendFailure! Aborting.", severity: .ERROR) 69 | abort() 70 | 71 | } 72 | } 73 | 74 | internal func getCValue() -> LDKRetryableSendFailure { 75 | switch self { 76 | 77 | case .PaymentExpired: 78 | return LDKRetryableSendFailure_PaymentExpired 79 | 80 | case .RouteNotFound: 81 | return LDKRetryableSendFailure_RouteNotFound 82 | 83 | case .DuplicatePayment: 84 | return LDKRetryableSendFailure_DuplicatePayment 85 | 86 | case .OnionPacketSizeExceeded: 87 | return LDKRetryableSendFailure_OnionPacketSizeExceeded 88 | 89 | } 90 | } 91 | 92 | } 93 | 94 | } 95 | -------------------------------------------------------------------------------- /out/enums/primitive/Secp256k1Error.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// Represents an error returned from libsecp256k1 during validation of some secp256k1 data 9 | public typealias Secp256k1Error = Bindings.Secp256k1Error 10 | 11 | extension Bindings { 12 | 13 | /// Represents an error returned from libsecp256k1 during validation of some secp256k1 data 14 | public enum Secp256k1Error { 15 | 16 | 17 | /// Signature failed verification 18 | case IncorrectSignature 19 | 20 | /// Badly sized message ("messages" are actually fixed-sized digests; see the MESSAGE_SIZE constant) 21 | case InvalidMessage 22 | 23 | /// Bad public key 24 | case InvalidPublicKey 25 | 26 | /// Bad signature 27 | case InvalidSignature 28 | 29 | /// Bad secret key 30 | case InvalidSecretKey 31 | 32 | /// Bad shared secret. 33 | case InvalidSharedSecret 34 | 35 | /// Bad recovery id 36 | case InvalidRecoveryId 37 | 38 | /// Invalid tweak for add_assign or mul_assign 39 | case InvalidTweak 40 | 41 | /// Didn't pass enough memory to context creation with preallocated memory 42 | case NotEnoughMemory 43 | 44 | /// Bad set of public keys. 45 | case InvalidPublicKeySum 46 | 47 | /// The only valid parity values are 0 or 1. 48 | case InvalidParityValue 49 | 50 | /// Invalid Elligator Swift Value 51 | case InvalidEllSwift 52 | 53 | 54 | internal init(value: LDKSecp256k1Error) { 55 | switch value { 56 | 57 | case LDKSecp256k1Error_IncorrectSignature: 58 | self = .IncorrectSignature 59 | 60 | case LDKSecp256k1Error_InvalidMessage: 61 | self = .InvalidMessage 62 | 63 | case LDKSecp256k1Error_InvalidPublicKey: 64 | self = .InvalidPublicKey 65 | 66 | case LDKSecp256k1Error_InvalidSignature: 67 | self = .InvalidSignature 68 | 69 | case LDKSecp256k1Error_InvalidSecretKey: 70 | self = .InvalidSecretKey 71 | 72 | case LDKSecp256k1Error_InvalidSharedSecret: 73 | self = .InvalidSharedSecret 74 | 75 | case LDKSecp256k1Error_InvalidRecoveryId: 76 | self = .InvalidRecoveryId 77 | 78 | case LDKSecp256k1Error_InvalidTweak: 79 | self = .InvalidTweak 80 | 81 | case LDKSecp256k1Error_NotEnoughMemory: 82 | self = .NotEnoughMemory 83 | 84 | case LDKSecp256k1Error_InvalidPublicKeySum: 85 | self = .InvalidPublicKeySum 86 | 87 | case LDKSecp256k1Error_InvalidParityValue: 88 | self = .InvalidParityValue 89 | 90 | case LDKSecp256k1Error_InvalidEllSwift: 91 | self = .InvalidEllSwift 92 | 93 | default: 94 | Bindings.print("Error: Invalid value type for Secp256k1Error! Aborting.", severity: .ERROR) 95 | abort() 96 | 97 | } 98 | } 99 | 100 | internal func getCValue() -> LDKSecp256k1Error { 101 | switch self { 102 | 103 | case .IncorrectSignature: 104 | return LDKSecp256k1Error_IncorrectSignature 105 | 106 | case .InvalidMessage: 107 | return LDKSecp256k1Error_InvalidMessage 108 | 109 | case .InvalidPublicKey: 110 | return LDKSecp256k1Error_InvalidPublicKey 111 | 112 | case .InvalidSignature: 113 | return LDKSecp256k1Error_InvalidSignature 114 | 115 | case .InvalidSecretKey: 116 | return LDKSecp256k1Error_InvalidSecretKey 117 | 118 | case .InvalidSharedSecret: 119 | return LDKSecp256k1Error_InvalidSharedSecret 120 | 121 | case .InvalidRecoveryId: 122 | return LDKSecp256k1Error_InvalidRecoveryId 123 | 124 | case .InvalidTweak: 125 | return LDKSecp256k1Error_InvalidTweak 126 | 127 | case .NotEnoughMemory: 128 | return LDKSecp256k1Error_NotEnoughMemory 129 | 130 | case .InvalidPublicKeySum: 131 | return LDKSecp256k1Error_InvalidPublicKeySum 132 | 133 | case .InvalidParityValue: 134 | return LDKSecp256k1Error_InvalidParityValue 135 | 136 | case .InvalidEllSwift: 137 | return LDKSecp256k1Error_InvalidEllSwift 138 | 139 | } 140 | } 141 | 142 | } 143 | 144 | } 145 | -------------------------------------------------------------------------------- /out/enums/primitive/ShortChannelIdError.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// A `short_channel_id` construction error 9 | public typealias ShortChannelIdError = Bindings.ShortChannelIdError 10 | 11 | extension Bindings { 12 | 13 | /// A `short_channel_id` construction error 14 | public enum ShortChannelIdError { 15 | 16 | 17 | /// Block height too high 18 | case BlockOverflow 19 | 20 | /// Tx index too high 21 | case TxIndexOverflow 22 | 23 | /// Vout index too high 24 | case VoutIndexOverflow 25 | 26 | 27 | internal init(value: LDKShortChannelIdError) { 28 | switch value { 29 | 30 | case LDKShortChannelIdError_BlockOverflow: 31 | self = .BlockOverflow 32 | 33 | case LDKShortChannelIdError_TxIndexOverflow: 34 | self = .TxIndexOverflow 35 | 36 | case LDKShortChannelIdError_VoutIndexOverflow: 37 | self = .VoutIndexOverflow 38 | 39 | default: 40 | Bindings.print("Error: Invalid value type for ShortChannelIdError! Aborting.", severity: .ERROR) 41 | abort() 42 | 43 | } 44 | } 45 | 46 | internal func getCValue() -> LDKShortChannelIdError { 47 | switch self { 48 | 49 | case .BlockOverflow: 50 | return LDKShortChannelIdError_BlockOverflow 51 | 52 | case .TxIndexOverflow: 53 | return LDKShortChannelIdError_TxIndexOverflow 54 | 55 | case .VoutIndexOverflow: 56 | return LDKShortChannelIdError_VoutIndexOverflow 57 | 58 | } 59 | } 60 | 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /out/enums/primitive/SiPrefix.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// SI prefixes for the human readable part 9 | public typealias SiPrefix = Bindings.SiPrefix 10 | 11 | extension Bindings { 12 | 13 | /// SI prefixes for the human readable part 14 | public enum SiPrefix { 15 | 16 | 17 | /// 10^-3 18 | case Milli 19 | 20 | /// 10^-6 21 | case Micro 22 | 23 | /// 10^-9 24 | case Nano 25 | 26 | /// 10^-12 27 | case Pico 28 | 29 | 30 | internal init(value: LDKSiPrefix) { 31 | switch value { 32 | 33 | case LDKSiPrefix_Milli: 34 | self = .Milli 35 | 36 | case LDKSiPrefix_Micro: 37 | self = .Micro 38 | 39 | case LDKSiPrefix_Nano: 40 | self = .Nano 41 | 42 | case LDKSiPrefix_Pico: 43 | self = .Pico 44 | 45 | default: 46 | Bindings.print("Error: Invalid value type for SiPrefix! Aborting.", severity: .ERROR) 47 | abort() 48 | 49 | } 50 | } 51 | 52 | internal func getCValue() -> LDKSiPrefix { 53 | switch self { 54 | 55 | case .Milli: 56 | return LDKSiPrefix_Milli 57 | 58 | case .Micro: 59 | return LDKSiPrefix_Micro 60 | 61 | case .Nano: 62 | return LDKSiPrefix_Nano 63 | 64 | case .Pico: 65 | return LDKSiPrefix_Pico 66 | 67 | } 68 | } 69 | 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /out/enums/primitive/SocketAddressParseError.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// [`SocketAddress`] error variants 9 | public typealias SocketAddressParseError = Bindings.SocketAddressParseError 10 | 11 | extension Bindings { 12 | 13 | /// [`SocketAddress`] error variants 14 | public enum SocketAddressParseError { 15 | 16 | 17 | /// Socket address (IPv4/IPv6) parsing error 18 | case SocketAddrParse 19 | 20 | /// Invalid input format 21 | case InvalidInput 22 | 23 | /// Invalid port 24 | case InvalidPort 25 | 26 | /// Invalid onion v3 address 27 | case InvalidOnionV3 28 | 29 | 30 | internal init(value: LDKSocketAddressParseError) { 31 | switch value { 32 | 33 | case LDKSocketAddressParseError_SocketAddrParse: 34 | self = .SocketAddrParse 35 | 36 | case LDKSocketAddressParseError_InvalidInput: 37 | self = .InvalidInput 38 | 39 | case LDKSocketAddressParseError_InvalidPort: 40 | self = .InvalidPort 41 | 42 | case LDKSocketAddressParseError_InvalidOnionV3: 43 | self = .InvalidOnionV3 44 | 45 | default: 46 | Bindings.print("Error: Invalid value type for SocketAddressParseError! Aborting.", severity: .ERROR) 47 | abort() 48 | 49 | } 50 | } 51 | 52 | internal func getCValue() -> LDKSocketAddressParseError { 53 | switch self { 54 | 55 | case .SocketAddrParse: 56 | return LDKSocketAddressParseError_SocketAddrParse 57 | 58 | case .InvalidInput: 59 | return LDKSocketAddressParseError_InvalidInput 60 | 61 | case .InvalidPort: 62 | return LDKSocketAddressParseError_InvalidPort 63 | 64 | case .InvalidOnionV3: 65 | return LDKSocketAddressParseError_InvalidOnionV3 66 | 67 | } 68 | } 69 | 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /out/enums/primitive/UtxoLookupError.swift: -------------------------------------------------------------------------------- 1 | import Foundation 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// An error when accessing the chain via [`UtxoLookup`]. 9 | public typealias UtxoLookupError = Bindings.UtxoLookupError 10 | 11 | extension Bindings { 12 | 13 | /// An error when accessing the chain via [`UtxoLookup`]. 14 | public enum UtxoLookupError { 15 | 16 | 17 | /// The requested chain is unknown. 18 | case UnknownChain 19 | 20 | /// The requested transaction doesn't exist or hasn't confirmed. 21 | case UnknownTx 22 | 23 | 24 | internal init(value: LDKUtxoLookupError) { 25 | switch value { 26 | 27 | case LDKUtxoLookupError_UnknownChain: 28 | self = .UnknownChain 29 | 30 | case LDKUtxoLookupError_UnknownTx: 31 | self = .UnknownTx 32 | 33 | default: 34 | Bindings.print("Error: Invalid value type for UtxoLookupError! Aborting.", severity: .ERROR) 35 | abort() 36 | 37 | } 38 | } 39 | 40 | internal func getCValue() -> LDKUtxoLookupError { 41 | switch self { 42 | 43 | case .UnknownChain: 44 | return LDKUtxoLookupError_UnknownChain 45 | 46 | case .UnknownTx: 47 | return LDKUtxoLookupError_UnknownTx 48 | 49 | } 50 | } 51 | 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /out/options/Option_HTLCClaimZ.swift: -------------------------------------------------------------------------------- 1 | #if SWIFT_PACKAGE 2 | import LDKHeaders 3 | #endif 4 | 5 | /// 6 | internal typealias Option_HTLCClaimZ = Bindings.Option_HTLCClaimZ 7 | 8 | extension Bindings { 9 | 10 | /// An enum which can either contain a crate::lightning::ln::chan_utils::HTLCClaim or not 11 | internal class Option_HTLCClaimZ: NativeTypeWrapper { 12 | 13 | 14 | /// Set to false to suppress an individual type's deinit log statements. 15 | /// Only applicable when log threshold is set to `.Debug`. 16 | public static var enableDeinitLogging = true 17 | 18 | /// Set to true to suspend the freeing of this type's associated Rust memory. 19 | /// Should only ever be used for debugging purposes, and will likely be 20 | /// deprecated soon. 21 | public static var suspendFreedom = false 22 | 23 | private static var instanceCounter: UInt = 0 24 | internal let instanceNumber: UInt 25 | 26 | internal var cType: LDKCOption_HTLCClaimZ? 27 | 28 | internal init(cType: LDKCOption_HTLCClaimZ, instantiationContext: String) { 29 | Self.instanceCounter += 1 30 | self.instanceNumber = Self.instanceCounter 31 | self.cType = cType 32 | 33 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 34 | } 35 | 36 | internal init(cType: LDKCOption_HTLCClaimZ, instantiationContext: String, anchor: NativeTypeWrapper) { 37 | Self.instanceCounter += 1 38 | self.instanceNumber = Self.instanceCounter 39 | self.cType = cType 40 | 41 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 42 | self.dangling = true 43 | try! self.addAnchor(anchor: anchor) 44 | } 45 | 46 | internal init( 47 | cType: LDKCOption_HTLCClaimZ, instantiationContext: String, anchor: NativeTypeWrapper, dangle: Bool = false 48 | ) { 49 | Self.instanceCounter += 1 50 | self.instanceNumber = Self.instanceCounter 51 | self.cType = cType 52 | 53 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 54 | self.dangling = dangle 55 | try! self.addAnchor(anchor: anchor) 56 | } 57 | 58 | 59 | internal init(some: HTLCClaim?, instantiationContext: String) { 60 | Self.instanceCounter += 1 61 | self.instanceNumber = Self.instanceCounter 62 | 63 | if let some = some { 64 | 65 | self.cType = COption_HTLCClaimZ_some(some.getCValue()) 66 | } else { 67 | self.cType = COption_HTLCClaimZ_none() 68 | } 69 | 70 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 71 | } 72 | 73 | 74 | /// Frees any resources associated with the crate::lightning::ln::chan_utils::HTLCClaim, if we are in the Some state 75 | internal func free() { 76 | // native call variable prep 77 | 78 | 79 | // native method call 80 | let nativeCallResult = COption_HTLCClaimZ_free(self.cType!) 81 | 82 | // cleanup 83 | 84 | 85 | // return value (do some wrapping) 86 | let returnValue = nativeCallResult 87 | 88 | 89 | return returnValue 90 | } 91 | 92 | 93 | public func getValue() -> HTLCClaim? { 94 | if self.cType!.tag == LDKCOption_HTLCClaimZ_None { 95 | return nil 96 | } 97 | if self.cType!.tag == LDKCOption_HTLCClaimZ_Some { 98 | return HTLCClaim(value: self.cType!.some) 99 | } 100 | assert(false, "invalid option enum value") 101 | return nil 102 | } 103 | 104 | 105 | deinit { 106 | if Bindings.suspendFreedom || Self.suspendFreedom { 107 | return 108 | } 109 | 110 | if !self.dangling { 111 | if Self.enableDeinitLogging { 112 | Bindings.print( 113 | "Freeing Option_HTLCClaimZ \(self.instanceNumber). (Origin: \(self.instantiationContext))") 114 | } 115 | 116 | self.free() 117 | } else if Self.enableDeinitLogging { 118 | Bindings.print( 119 | "Not freeing Option_HTLCClaimZ \(self.instanceNumber) due to dangle. (Origin: \(self.instantiationContext))" 120 | ) 121 | } 122 | } 123 | 124 | 125 | } 126 | 127 | } 128 | -------------------------------------------------------------------------------- /out/structs/BindingsError.swift: -------------------------------------------------------------------------------- 1 | #if SWIFT_PACKAGE 2 | import LDKHeaders 3 | #endif 4 | 5 | /// Sub-errors which don't have specific information in them use this type. 6 | public typealias BindingsError = Bindings.BindingsError 7 | 8 | extension Bindings { 9 | 10 | 11 | /// Sub-errors which don't have specific information in them use this type. 12 | public class BindingsError: NativeTypeWrapper { 13 | 14 | 15 | /// Set to false to suppress an individual type's deinit log statements. 16 | /// Only applicable when log threshold is set to `.Debug`. 17 | public static var enableDeinitLogging = true 18 | 19 | /// Set to true to suspend the freeing of this type's associated Rust memory. 20 | /// Should only ever be used for debugging purposes, and will likely be 21 | /// deprecated soon. 22 | public static var suspendFreedom = false 23 | 24 | private static var instanceCounter: UInt = 0 25 | internal let instanceNumber: UInt 26 | 27 | internal var cType: LDKError? 28 | 29 | internal init(cType: LDKError, instantiationContext: String) { 30 | Self.instanceCounter += 1 31 | self.instanceNumber = Self.instanceCounter 32 | self.cType = cType 33 | 34 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 35 | } 36 | 37 | internal init(cType: LDKError, instantiationContext: String, anchor: NativeTypeWrapper) { 38 | Self.instanceCounter += 1 39 | self.instanceNumber = Self.instanceCounter 40 | self.cType = cType 41 | 42 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 43 | self.dangling = true 44 | try! self.addAnchor(anchor: anchor) 45 | } 46 | 47 | internal init(cType: LDKError, instantiationContext: String, anchor: NativeTypeWrapper, dangle: Bool = false) { 48 | Self.instanceCounter += 1 49 | self.instanceNumber = Self.instanceCounter 50 | self.cType = cType 51 | 52 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 53 | self.dangling = dangle 54 | try! self.addAnchor(anchor: anchor) 55 | } 56 | 57 | 58 | /// Zero-Sized_types aren't consistent across Rust/C/C++, so we add some size here 59 | public func getDummy() -> UInt8 { 60 | // return value (do some wrapping) 61 | let returnValue = self.cType!._dummy 62 | 63 | return returnValue 64 | } 65 | 66 | 67 | } 68 | 69 | 70 | } 71 | 72 | -------------------------------------------------------------------------------- /out/vectors/Vec_u8Z.swift: -------------------------------------------------------------------------------- 1 | #if SWIFT_PACKAGE 2 | import LDKHeaders 3 | #endif 4 | 5 | /// A dynamically-allocated array of u8s of arbitrary size. 6 | /// This corresponds to std::vector in C++ 7 | internal typealias Vec_u8Z = Bindings.Vec_u8Z 8 | 9 | extension Bindings { 10 | 11 | /// A dynamically-allocated array of u8s of arbitrary size. 12 | /// This corresponds to std::vector in C++ 13 | internal class Vec_u8Z: NativeTypeWrapper { 14 | 15 | 16 | /// Set to false to suppress an individual type's deinit log statements. 17 | /// Only applicable when log threshold is set to `.Debug`. 18 | public static var enableDeinitLogging = true 19 | 20 | /// Set to true to suspend the freeing of this type's associated Rust memory. 21 | /// Should only ever be used for debugging purposes, and will likely be 22 | /// deprecated soon. 23 | public static var suspendFreedom = false 24 | 25 | private static var instanceCounter: UInt = 0 26 | internal let instanceNumber: UInt 27 | 28 | internal var cType: LDKCVec_u8Z? 29 | 30 | internal init(cType: LDKCVec_u8Z, instantiationContext: String) { 31 | Self.instanceCounter += 1 32 | self.instanceNumber = Self.instanceCounter 33 | self.cType = cType 34 | 35 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 36 | } 37 | 38 | internal init(cType: LDKCVec_u8Z, instantiationContext: String, anchor: NativeTypeWrapper) { 39 | Self.instanceCounter += 1 40 | self.instanceNumber = Self.instanceCounter 41 | self.cType = cType 42 | 43 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 44 | self.dangling = true 45 | try! self.addAnchor(anchor: anchor) 46 | } 47 | 48 | internal init(cType: LDKCVec_u8Z, instantiationContext: String, anchor: NativeTypeWrapper, dangle: Bool = false) 49 | { 50 | Self.instanceCounter += 1 51 | self.instanceNumber = Self.instanceCounter 52 | self.cType = cType 53 | 54 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 55 | self.dangling = dangle 56 | try! self.addAnchor(anchor: anchor) 57 | } 58 | 59 | 60 | internal init(array: [UInt8], instantiationContext: String) { 61 | Self.instanceCounter += 1 62 | self.instanceNumber = Self.instanceCounter 63 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 64 | 65 | 66 | let dataContainer = UnsafeMutablePointer.allocate(capacity: array.count) 67 | dataContainer.initialize(from: array, count: array.count) 68 | 69 | let vector = LDKCVec_u8Z(data: dataContainer, datalen: UInt(array.count)) 70 | self.cType = vector 71 | } 72 | 73 | public func getValue() -> [UInt8] { 74 | 75 | var array = [UInt8]() 76 | 77 | 78 | for index1 in 0.. [UInt8] { 73 | return Bindings.UInt8Tuple64ToArray(tuple: self.cType!.compact_form) 74 | } 75 | 76 | 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /out/wrappers/FourBytes.swift: -------------------------------------------------------------------------------- 1 | import Foundation // necessary for Data for Strings 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// A 4-byte byte array. 9 | internal typealias FourBytes = Bindings.FourBytes 10 | 11 | extension Bindings { 12 | 13 | /// A 4-byte byte array. 14 | internal class FourBytes: NativeTypeWrapper { 15 | 16 | 17 | /// Set to false to suppress an individual type's deinit log statements. 18 | /// Only applicable when log threshold is set to `.Debug`. 19 | public static var enableDeinitLogging = true 20 | 21 | /// Set to true to suspend the freeing of this type's associated Rust memory. 22 | /// Should only ever be used for debugging purposes, and will likely be 23 | /// deprecated soon. 24 | public static var suspendFreedom = false 25 | 26 | private static var instanceCounter: UInt = 0 27 | internal let instanceNumber: UInt 28 | 29 | internal var cType: LDKFourBytes? 30 | 31 | internal init(cType: LDKFourBytes, instantiationContext: String) { 32 | Self.instanceCounter += 1 33 | self.instanceNumber = Self.instanceCounter 34 | self.cType = cType 35 | 36 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 37 | } 38 | 39 | internal init(cType: LDKFourBytes, instantiationContext: String, anchor: NativeTypeWrapper) { 40 | Self.instanceCounter += 1 41 | self.instanceNumber = Self.instanceCounter 42 | self.cType = cType 43 | 44 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 45 | self.dangling = true 46 | try! self.addAnchor(anchor: anchor) 47 | } 48 | 49 | internal init( 50 | cType: LDKFourBytes, instantiationContext: String, anchor: NativeTypeWrapper, dangle: Bool = false 51 | ) { 52 | Self.instanceCounter += 1 53 | self.instanceNumber = Self.instanceCounter 54 | self.cType = cType 55 | 56 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 57 | self.dangling = dangle 58 | try! self.addAnchor(anchor: anchor) 59 | } 60 | 61 | 62 | internal init(value: [UInt8], instantiationContext: String) { 63 | Self.instanceCounter += 1 64 | self.instanceNumber = Self.instanceCounter 65 | 66 | self.cType = LDKFourBytes(data: Bindings.arrayToUInt8Tuple4(array: value)) 67 | 68 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 69 | } 70 | 71 | 72 | public func getValue() -> [UInt8] { 73 | return Bindings.UInt8Tuple4ToArray(tuple: self.cType!.data) 74 | } 75 | 76 | 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /out/wrappers/PublicKey.swift: -------------------------------------------------------------------------------- 1 | import Foundation // necessary for Data for Strings 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// Represents a valid secp256k1 public key serialized in "compressed form" as a 33 byte array. 9 | internal typealias PublicKey = Bindings.PublicKey 10 | 11 | extension Bindings { 12 | 13 | /// Represents a valid secp256k1 public key serialized in "compressed form" as a 33 byte array. 14 | internal class PublicKey: NativeTypeWrapper { 15 | 16 | 17 | /// Set to false to suppress an individual type's deinit log statements. 18 | /// Only applicable when log threshold is set to `.Debug`. 19 | public static var enableDeinitLogging = true 20 | 21 | /// Set to true to suspend the freeing of this type's associated Rust memory. 22 | /// Should only ever be used for debugging purposes, and will likely be 23 | /// deprecated soon. 24 | public static var suspendFreedom = false 25 | 26 | private static var instanceCounter: UInt = 0 27 | internal let instanceNumber: UInt 28 | 29 | internal var cType: LDKPublicKey? 30 | 31 | internal init(cType: LDKPublicKey, instantiationContext: String) { 32 | Self.instanceCounter += 1 33 | self.instanceNumber = Self.instanceCounter 34 | self.cType = cType 35 | 36 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 37 | } 38 | 39 | internal init(cType: LDKPublicKey, instantiationContext: String, anchor: NativeTypeWrapper) { 40 | Self.instanceCounter += 1 41 | self.instanceNumber = Self.instanceCounter 42 | self.cType = cType 43 | 44 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 45 | self.dangling = true 46 | try! self.addAnchor(anchor: anchor) 47 | } 48 | 49 | internal init( 50 | cType: LDKPublicKey, instantiationContext: String, anchor: NativeTypeWrapper, dangle: Bool = false 51 | ) { 52 | Self.instanceCounter += 1 53 | self.instanceNumber = Self.instanceCounter 54 | self.cType = cType 55 | 56 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 57 | self.dangling = dangle 58 | try! self.addAnchor(anchor: anchor) 59 | } 60 | 61 | 62 | internal init(value: [UInt8], instantiationContext: String) { 63 | Self.instanceCounter += 1 64 | self.instanceNumber = Self.instanceCounter 65 | 66 | self.cType = LDKPublicKey(compressed_form: Bindings.arrayToUInt8Tuple33(array: value)) 67 | 68 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 69 | } 70 | 71 | 72 | public func getValue() -> [UInt8] { 73 | return Bindings.UInt8Tuple33ToArray(tuple: self.cType!.compressed_form) 74 | } 75 | 76 | 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /out/wrappers/RecoverableSignature.swift: -------------------------------------------------------------------------------- 1 | import Foundation // necessary for Data for Strings 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// Represents a secp256k1 signature serialized as two 32-byte numbers as well as a tag which 9 | /// allows recovering the exact public key which created the signature given the message. 10 | internal typealias RecoverableSignature = Bindings.RecoverableSignature 11 | 12 | extension Bindings { 13 | 14 | /// Represents a secp256k1 signature serialized as two 32-byte numbers as well as a tag which 15 | /// allows recovering the exact public key which created the signature given the message. 16 | internal class RecoverableSignature: NativeTypeWrapper { 17 | 18 | 19 | /// Set to false to suppress an individual type's deinit log statements. 20 | /// Only applicable when log threshold is set to `.Debug`. 21 | public static var enableDeinitLogging = true 22 | 23 | /// Set to true to suspend the freeing of this type's associated Rust memory. 24 | /// Should only ever be used for debugging purposes, and will likely be 25 | /// deprecated soon. 26 | public static var suspendFreedom = false 27 | 28 | private static var instanceCounter: UInt = 0 29 | internal let instanceNumber: UInt 30 | 31 | internal var cType: LDKRecoverableSignature? 32 | 33 | internal init(cType: LDKRecoverableSignature, instantiationContext: String) { 34 | Self.instanceCounter += 1 35 | self.instanceNumber = Self.instanceCounter 36 | self.cType = cType 37 | 38 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 39 | } 40 | 41 | internal init(cType: LDKRecoverableSignature, instantiationContext: String, anchor: NativeTypeWrapper) { 42 | Self.instanceCounter += 1 43 | self.instanceNumber = Self.instanceCounter 44 | self.cType = cType 45 | 46 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 47 | self.dangling = true 48 | try! self.addAnchor(anchor: anchor) 49 | } 50 | 51 | internal init( 52 | cType: LDKRecoverableSignature, instantiationContext: String, anchor: NativeTypeWrapper, 53 | dangle: Bool = false 54 | ) { 55 | Self.instanceCounter += 1 56 | self.instanceNumber = Self.instanceCounter 57 | self.cType = cType 58 | 59 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 60 | self.dangling = dangle 61 | try! self.addAnchor(anchor: anchor) 62 | } 63 | 64 | 65 | internal init(value: [UInt8], instantiationContext: String) { 66 | Self.instanceCounter += 1 67 | self.instanceNumber = Self.instanceCounter 68 | 69 | self.cType = LDKRecoverableSignature(serialized_form: Bindings.arrayToUInt8Tuple68(array: value)) 70 | 71 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 72 | } 73 | 74 | 75 | public func getValue() -> [UInt8] { 76 | return Bindings.UInt8Tuple68ToArray(tuple: self.cType!.serialized_form) 77 | } 78 | 79 | 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /out/wrappers/SchnorrSignature.swift: -------------------------------------------------------------------------------- 1 | import Foundation // necessary for Data for Strings 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// Represents a secp256k1 Schnorr signature serialized as two 32-byte numbers 9 | internal typealias SchnorrSignature = Bindings.SchnorrSignature 10 | 11 | extension Bindings { 12 | 13 | /// Represents a secp256k1 Schnorr signature serialized as two 32-byte numbers 14 | internal class SchnorrSignature: NativeTypeWrapper { 15 | 16 | 17 | /// Set to false to suppress an individual type's deinit log statements. 18 | /// Only applicable when log threshold is set to `.Debug`. 19 | public static var enableDeinitLogging = true 20 | 21 | /// Set to true to suspend the freeing of this type's associated Rust memory. 22 | /// Should only ever be used for debugging purposes, and will likely be 23 | /// deprecated soon. 24 | public static var suspendFreedom = false 25 | 26 | private static var instanceCounter: UInt = 0 27 | internal let instanceNumber: UInt 28 | 29 | internal var cType: LDKSchnorrSignature? 30 | 31 | internal init(cType: LDKSchnorrSignature, instantiationContext: String) { 32 | Self.instanceCounter += 1 33 | self.instanceNumber = Self.instanceCounter 34 | self.cType = cType 35 | 36 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 37 | } 38 | 39 | internal init(cType: LDKSchnorrSignature, instantiationContext: String, anchor: NativeTypeWrapper) { 40 | Self.instanceCounter += 1 41 | self.instanceNumber = Self.instanceCounter 42 | self.cType = cType 43 | 44 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 45 | self.dangling = true 46 | try! self.addAnchor(anchor: anchor) 47 | } 48 | 49 | internal init( 50 | cType: LDKSchnorrSignature, instantiationContext: String, anchor: NativeTypeWrapper, dangle: Bool = false 51 | ) { 52 | Self.instanceCounter += 1 53 | self.instanceNumber = Self.instanceCounter 54 | self.cType = cType 55 | 56 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 57 | self.dangling = dangle 58 | try! self.addAnchor(anchor: anchor) 59 | } 60 | 61 | 62 | internal init(value: [UInt8], instantiationContext: String) { 63 | Self.instanceCounter += 1 64 | self.instanceNumber = Self.instanceCounter 65 | 66 | self.cType = LDKSchnorrSignature(compact_form: Bindings.arrayToUInt8Tuple64(array: value)) 67 | 68 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 69 | } 70 | 71 | 72 | public func getValue() -> [UInt8] { 73 | return Bindings.UInt8Tuple64ToArray(tuple: self.cType!.compact_form) 74 | } 75 | 76 | 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /out/wrappers/SecretKey.swift: -------------------------------------------------------------------------------- 1 | import Foundation // necessary for Data for Strings 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// Represents a valid secp256k1 secret key serialized as a 32 byte array. 9 | internal typealias SecretKey = Bindings.SecretKey 10 | 11 | extension Bindings { 12 | 13 | /// Represents a valid secp256k1 secret key serialized as a 32 byte array. 14 | internal class SecretKey: NativeTypeWrapper { 15 | 16 | 17 | /// Set to false to suppress an individual type's deinit log statements. 18 | /// Only applicable when log threshold is set to `.Debug`. 19 | public static var enableDeinitLogging = true 20 | 21 | /// Set to true to suspend the freeing of this type's associated Rust memory. 22 | /// Should only ever be used for debugging purposes, and will likely be 23 | /// deprecated soon. 24 | public static var suspendFreedom = false 25 | 26 | private static var instanceCounter: UInt = 0 27 | internal let instanceNumber: UInt 28 | 29 | internal var cType: LDKSecretKey? 30 | 31 | internal init(cType: LDKSecretKey, instantiationContext: String) { 32 | Self.instanceCounter += 1 33 | self.instanceNumber = Self.instanceCounter 34 | self.cType = cType 35 | 36 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 37 | } 38 | 39 | internal init(cType: LDKSecretKey, instantiationContext: String, anchor: NativeTypeWrapper) { 40 | Self.instanceCounter += 1 41 | self.instanceNumber = Self.instanceCounter 42 | self.cType = cType 43 | 44 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 45 | self.dangling = true 46 | try! self.addAnchor(anchor: anchor) 47 | } 48 | 49 | internal init( 50 | cType: LDKSecretKey, instantiationContext: String, anchor: NativeTypeWrapper, dangle: Bool = false 51 | ) { 52 | Self.instanceCounter += 1 53 | self.instanceNumber = Self.instanceCounter 54 | self.cType = cType 55 | 56 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 57 | self.dangling = dangle 58 | try! self.addAnchor(anchor: anchor) 59 | } 60 | 61 | 62 | internal init(value: [UInt8], instantiationContext: String) { 63 | Self.instanceCounter += 1 64 | self.instanceNumber = Self.instanceCounter 65 | 66 | self.cType = LDKSecretKey(bytes: Bindings.arrayToUInt8Tuple32(array: value)) 67 | 68 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 69 | } 70 | 71 | 72 | public func getValue() -> [UInt8] { 73 | return Bindings.UInt8Tuple32ToArray(tuple: self.cType!.bytes) 74 | } 75 | 76 | 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /out/wrappers/SixteenBytes.swift: -------------------------------------------------------------------------------- 1 | import Foundation // necessary for Data for Strings 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// A 16-byte byte array. 9 | internal typealias SixteenBytes = Bindings.SixteenBytes 10 | 11 | extension Bindings { 12 | 13 | /// A 16-byte byte array. 14 | internal class SixteenBytes: NativeTypeWrapper { 15 | 16 | 17 | /// Set to false to suppress an individual type's deinit log statements. 18 | /// Only applicable when log threshold is set to `.Debug`. 19 | public static var enableDeinitLogging = true 20 | 21 | /// Set to true to suspend the freeing of this type's associated Rust memory. 22 | /// Should only ever be used for debugging purposes, and will likely be 23 | /// deprecated soon. 24 | public static var suspendFreedom = false 25 | 26 | private static var instanceCounter: UInt = 0 27 | internal let instanceNumber: UInt 28 | 29 | internal var cType: LDKSixteenBytes? 30 | 31 | internal init(cType: LDKSixteenBytes, instantiationContext: String) { 32 | Self.instanceCounter += 1 33 | self.instanceNumber = Self.instanceCounter 34 | self.cType = cType 35 | 36 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 37 | } 38 | 39 | internal init(cType: LDKSixteenBytes, instantiationContext: String, anchor: NativeTypeWrapper) { 40 | Self.instanceCounter += 1 41 | self.instanceNumber = Self.instanceCounter 42 | self.cType = cType 43 | 44 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 45 | self.dangling = true 46 | try! self.addAnchor(anchor: anchor) 47 | } 48 | 49 | internal init( 50 | cType: LDKSixteenBytes, instantiationContext: String, anchor: NativeTypeWrapper, dangle: Bool = false 51 | ) { 52 | Self.instanceCounter += 1 53 | self.instanceNumber = Self.instanceCounter 54 | self.cType = cType 55 | 56 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 57 | self.dangling = dangle 58 | try! self.addAnchor(anchor: anchor) 59 | } 60 | 61 | 62 | internal init(value: [UInt8], instantiationContext: String) { 63 | Self.instanceCounter += 1 64 | self.instanceNumber = Self.instanceCounter 65 | 66 | self.cType = LDKSixteenBytes(data: Bindings.arrayToUInt8Tuple16(array: value)) 67 | 68 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 69 | } 70 | 71 | 72 | public func getValue() -> [UInt8] { 73 | return Bindings.UInt8Tuple16ToArray(tuple: self.cType!.data) 74 | } 75 | 76 | 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /out/wrappers/ThirtyTwoBytes.swift: -------------------------------------------------------------------------------- 1 | import Foundation // necessary for Data for Strings 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// Arbitrary 32 bytes, which could represent one of a few different things. You probably want to 9 | /// look up the corresponding function in rust-lightning's docs. 10 | internal typealias ThirtyTwoBytes = Bindings.ThirtyTwoBytes 11 | 12 | extension Bindings { 13 | 14 | /// Arbitrary 32 bytes, which could represent one of a few different things. You probably want to 15 | /// look up the corresponding function in rust-lightning's docs. 16 | internal class ThirtyTwoBytes: NativeTypeWrapper { 17 | 18 | 19 | /// Set to false to suppress an individual type's deinit log statements. 20 | /// Only applicable when log threshold is set to `.Debug`. 21 | public static var enableDeinitLogging = true 22 | 23 | /// Set to true to suspend the freeing of this type's associated Rust memory. 24 | /// Should only ever be used for debugging purposes, and will likely be 25 | /// deprecated soon. 26 | public static var suspendFreedom = false 27 | 28 | private static var instanceCounter: UInt = 0 29 | internal let instanceNumber: UInt 30 | 31 | internal var cType: LDKThirtyTwoBytes? 32 | 33 | internal init(cType: LDKThirtyTwoBytes, instantiationContext: String) { 34 | Self.instanceCounter += 1 35 | self.instanceNumber = Self.instanceCounter 36 | self.cType = cType 37 | 38 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 39 | } 40 | 41 | internal init(cType: LDKThirtyTwoBytes, instantiationContext: String, anchor: NativeTypeWrapper) { 42 | Self.instanceCounter += 1 43 | self.instanceNumber = Self.instanceCounter 44 | self.cType = cType 45 | 46 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 47 | self.dangling = true 48 | try! self.addAnchor(anchor: anchor) 49 | } 50 | 51 | internal init( 52 | cType: LDKThirtyTwoBytes, instantiationContext: String, anchor: NativeTypeWrapper, dangle: Bool = false 53 | ) { 54 | Self.instanceCounter += 1 55 | self.instanceNumber = Self.instanceCounter 56 | self.cType = cType 57 | 58 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 59 | self.dangling = dangle 60 | try! self.addAnchor(anchor: anchor) 61 | } 62 | 63 | 64 | internal init(value: [UInt8], instantiationContext: String) { 65 | Self.instanceCounter += 1 66 | self.instanceNumber = Self.instanceCounter 67 | 68 | self.cType = LDKThirtyTwoBytes(data: Bindings.arrayToUInt8Tuple32(array: value)) 69 | 70 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 71 | } 72 | 73 | 74 | public func getValue() -> [UInt8] { 75 | return Bindings.UInt8Tuple32ToArray(tuple: self.cType!.data) 76 | } 77 | 78 | 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /out/wrappers/ThirtyTwoU16s.swift: -------------------------------------------------------------------------------- 1 | import Foundation // necessary for Data for Strings 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// 32 u16s 9 | internal typealias ThirtyTwoU16s = Bindings.ThirtyTwoU16s 10 | 11 | extension Bindings { 12 | 13 | /// 32 u16s 14 | internal class ThirtyTwoU16s: NativeTypeWrapper { 15 | 16 | 17 | /// Set to false to suppress an individual type's deinit log statements. 18 | /// Only applicable when log threshold is set to `.Debug`. 19 | public static var enableDeinitLogging = true 20 | 21 | /// Set to true to suspend the freeing of this type's associated Rust memory. 22 | /// Should only ever be used for debugging purposes, and will likely be 23 | /// deprecated soon. 24 | public static var suspendFreedom = false 25 | 26 | private static var instanceCounter: UInt = 0 27 | internal let instanceNumber: UInt 28 | 29 | internal var cType: LDKThirtyTwoU16s? 30 | 31 | internal init(cType: LDKThirtyTwoU16s, instantiationContext: String) { 32 | Self.instanceCounter += 1 33 | self.instanceNumber = Self.instanceCounter 34 | self.cType = cType 35 | 36 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 37 | } 38 | 39 | internal init(cType: LDKThirtyTwoU16s, instantiationContext: String, anchor: NativeTypeWrapper) { 40 | Self.instanceCounter += 1 41 | self.instanceNumber = Self.instanceCounter 42 | self.cType = cType 43 | 44 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 45 | self.dangling = true 46 | try! self.addAnchor(anchor: anchor) 47 | } 48 | 49 | internal init( 50 | cType: LDKThirtyTwoU16s, instantiationContext: String, anchor: NativeTypeWrapper, dangle: Bool = false 51 | ) { 52 | Self.instanceCounter += 1 53 | self.instanceNumber = Self.instanceCounter 54 | self.cType = cType 55 | 56 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 57 | self.dangling = dangle 58 | try! self.addAnchor(anchor: anchor) 59 | } 60 | 61 | 62 | internal init(value: [UInt16], instantiationContext: String) { 63 | Self.instanceCounter += 1 64 | self.instanceNumber = Self.instanceCounter 65 | 66 | self.cType = LDKThirtyTwoU16s(data: Bindings.arrayToUInt16Tuple32(array: value)) 67 | 68 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 69 | } 70 | 71 | 72 | public func getValue() -> [UInt16] { 73 | return Bindings.UInt16Tuple32ToArray(tuple: self.cType!.data) 74 | } 75 | 76 | 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /out/wrappers/ThreeBytes.swift: -------------------------------------------------------------------------------- 1 | import Foundation // necessary for Data for Strings 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// A 3-byte byte array. 9 | internal typealias ThreeBytes = Bindings.ThreeBytes 10 | 11 | extension Bindings { 12 | 13 | /// A 3-byte byte array. 14 | internal class ThreeBytes: NativeTypeWrapper { 15 | 16 | 17 | /// Set to false to suppress an individual type's deinit log statements. 18 | /// Only applicable when log threshold is set to `.Debug`. 19 | public static var enableDeinitLogging = true 20 | 21 | /// Set to true to suspend the freeing of this type's associated Rust memory. 22 | /// Should only ever be used for debugging purposes, and will likely be 23 | /// deprecated soon. 24 | public static var suspendFreedom = false 25 | 26 | private static var instanceCounter: UInt = 0 27 | internal let instanceNumber: UInt 28 | 29 | internal var cType: LDKThreeBytes? 30 | 31 | internal init(cType: LDKThreeBytes, instantiationContext: String) { 32 | Self.instanceCounter += 1 33 | self.instanceNumber = Self.instanceCounter 34 | self.cType = cType 35 | 36 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 37 | } 38 | 39 | internal init(cType: LDKThreeBytes, instantiationContext: String, anchor: NativeTypeWrapper) { 40 | Self.instanceCounter += 1 41 | self.instanceNumber = Self.instanceCounter 42 | self.cType = cType 43 | 44 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 45 | self.dangling = true 46 | try! self.addAnchor(anchor: anchor) 47 | } 48 | 49 | internal init( 50 | cType: LDKThreeBytes, instantiationContext: String, anchor: NativeTypeWrapper, dangle: Bool = false 51 | ) { 52 | Self.instanceCounter += 1 53 | self.instanceNumber = Self.instanceCounter 54 | self.cType = cType 55 | 56 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 57 | self.dangling = dangle 58 | try! self.addAnchor(anchor: anchor) 59 | } 60 | 61 | 62 | internal init(value: [UInt8], instantiationContext: String) { 63 | Self.instanceCounter += 1 64 | self.instanceNumber = Self.instanceCounter 65 | 66 | self.cType = LDKThreeBytes(data: Bindings.arrayToUInt8Tuple3(array: value)) 67 | 68 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 69 | } 70 | 71 | 72 | public func getValue() -> [UInt8] { 73 | return Bindings.UInt8Tuple3ToArray(tuple: self.cType!.data) 74 | } 75 | 76 | 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /out/wrappers/TweakedPublicKey.swift: -------------------------------------------------------------------------------- 1 | import Foundation // necessary for Data for Strings 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// Represents a tweaked X-only public key as required for BIP 340 (Taproot). 9 | internal typealias TweakedPublicKey = Bindings.TweakedPublicKey 10 | 11 | extension Bindings { 12 | 13 | /// Represents a tweaked X-only public key as required for BIP 340 (Taproot). 14 | internal class TweakedPublicKey: NativeTypeWrapper { 15 | 16 | 17 | /// Set to false to suppress an individual type's deinit log statements. 18 | /// Only applicable when log threshold is set to `.Debug`. 19 | public static var enableDeinitLogging = true 20 | 21 | /// Set to true to suspend the freeing of this type's associated Rust memory. 22 | /// Should only ever be used for debugging purposes, and will likely be 23 | /// deprecated soon. 24 | public static var suspendFreedom = false 25 | 26 | private static var instanceCounter: UInt = 0 27 | internal let instanceNumber: UInt 28 | 29 | internal var cType: LDKTweakedPublicKey? 30 | 31 | internal init(cType: LDKTweakedPublicKey, instantiationContext: String) { 32 | Self.instanceCounter += 1 33 | self.instanceNumber = Self.instanceCounter 34 | self.cType = cType 35 | 36 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 37 | } 38 | 39 | internal init(cType: LDKTweakedPublicKey, instantiationContext: String, anchor: NativeTypeWrapper) { 40 | Self.instanceCounter += 1 41 | self.instanceNumber = Self.instanceCounter 42 | self.cType = cType 43 | 44 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 45 | self.dangling = true 46 | try! self.addAnchor(anchor: anchor) 47 | } 48 | 49 | internal init( 50 | cType: LDKTweakedPublicKey, instantiationContext: String, anchor: NativeTypeWrapper, dangle: Bool = false 51 | ) { 52 | Self.instanceCounter += 1 53 | self.instanceNumber = Self.instanceCounter 54 | self.cType = cType 55 | 56 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 57 | self.dangling = dangle 58 | try! self.addAnchor(anchor: anchor) 59 | } 60 | 61 | 62 | internal init(value: [UInt8], instantiationContext: String) { 63 | Self.instanceCounter += 1 64 | self.instanceNumber = Self.instanceCounter 65 | 66 | self.cType = LDKTweakedPublicKey(x_coordinate: Bindings.arrayToUInt8Tuple32(array: value)) 67 | 68 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 69 | } 70 | 71 | 72 | public func getValue() -> [UInt8] { 73 | return Bindings.UInt8Tuple32ToArray(tuple: self.cType!.x_coordinate) 74 | } 75 | 76 | 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /out/wrappers/TwelveBytes.swift: -------------------------------------------------------------------------------- 1 | import Foundation // necessary for Data for Strings 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// A 12-byte byte array. 9 | internal typealias TwelveBytes = Bindings.TwelveBytes 10 | 11 | extension Bindings { 12 | 13 | /// A 12-byte byte array. 14 | internal class TwelveBytes: NativeTypeWrapper { 15 | 16 | 17 | /// Set to false to suppress an individual type's deinit log statements. 18 | /// Only applicable when log threshold is set to `.Debug`. 19 | public static var enableDeinitLogging = true 20 | 21 | /// Set to true to suspend the freeing of this type's associated Rust memory. 22 | /// Should only ever be used for debugging purposes, and will likely be 23 | /// deprecated soon. 24 | public static var suspendFreedom = false 25 | 26 | private static var instanceCounter: UInt = 0 27 | internal let instanceNumber: UInt 28 | 29 | internal var cType: LDKTwelveBytes? 30 | 31 | internal init(cType: LDKTwelveBytes, instantiationContext: String) { 32 | Self.instanceCounter += 1 33 | self.instanceNumber = Self.instanceCounter 34 | self.cType = cType 35 | 36 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 37 | } 38 | 39 | internal init(cType: LDKTwelveBytes, instantiationContext: String, anchor: NativeTypeWrapper) { 40 | Self.instanceCounter += 1 41 | self.instanceNumber = Self.instanceCounter 42 | self.cType = cType 43 | 44 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 45 | self.dangling = true 46 | try! self.addAnchor(anchor: anchor) 47 | } 48 | 49 | internal init( 50 | cType: LDKTwelveBytes, instantiationContext: String, anchor: NativeTypeWrapper, dangle: Bool = false 51 | ) { 52 | Self.instanceCounter += 1 53 | self.instanceNumber = Self.instanceCounter 54 | self.cType = cType 55 | 56 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 57 | self.dangling = dangle 58 | try! self.addAnchor(anchor: anchor) 59 | } 60 | 61 | 62 | internal init(value: [UInt8], instantiationContext: String) { 63 | Self.instanceCounter += 1 64 | self.instanceNumber = Self.instanceCounter 65 | 66 | self.cType = LDKTwelveBytes(data: Bindings.arrayToUInt8Tuple12(array: value)) 67 | 68 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 69 | } 70 | 71 | 72 | public func getValue() -> [UInt8] { 73 | return Bindings.UInt8Tuple12ToArray(tuple: self.cType!.data) 74 | } 75 | 76 | 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /out/wrappers/TwentyBytes.swift: -------------------------------------------------------------------------------- 1 | import Foundation // necessary for Data for Strings 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// A 20-byte byte array. 9 | internal typealias TwentyBytes = Bindings.TwentyBytes 10 | 11 | extension Bindings { 12 | 13 | /// A 20-byte byte array. 14 | internal class TwentyBytes: NativeTypeWrapper { 15 | 16 | 17 | /// Set to false to suppress an individual type's deinit log statements. 18 | /// Only applicable when log threshold is set to `.Debug`. 19 | public static var enableDeinitLogging = true 20 | 21 | /// Set to true to suspend the freeing of this type's associated Rust memory. 22 | /// Should only ever be used for debugging purposes, and will likely be 23 | /// deprecated soon. 24 | public static var suspendFreedom = false 25 | 26 | private static var instanceCounter: UInt = 0 27 | internal let instanceNumber: UInt 28 | 29 | internal var cType: LDKTwentyBytes? 30 | 31 | internal init(cType: LDKTwentyBytes, instantiationContext: String) { 32 | Self.instanceCounter += 1 33 | self.instanceNumber = Self.instanceCounter 34 | self.cType = cType 35 | 36 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 37 | } 38 | 39 | internal init(cType: LDKTwentyBytes, instantiationContext: String, anchor: NativeTypeWrapper) { 40 | Self.instanceCounter += 1 41 | self.instanceNumber = Self.instanceCounter 42 | self.cType = cType 43 | 44 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 45 | self.dangling = true 46 | try! self.addAnchor(anchor: anchor) 47 | } 48 | 49 | internal init( 50 | cType: LDKTwentyBytes, instantiationContext: String, anchor: NativeTypeWrapper, dangle: Bool = false 51 | ) { 52 | Self.instanceCounter += 1 53 | self.instanceNumber = Self.instanceCounter 54 | self.cType = cType 55 | 56 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 57 | self.dangling = dangle 58 | try! self.addAnchor(anchor: anchor) 59 | } 60 | 61 | 62 | internal init(value: [UInt8], instantiationContext: String) { 63 | Self.instanceCounter += 1 64 | self.instanceNumber = Self.instanceCounter 65 | 66 | self.cType = LDKTwentyBytes(data: Bindings.arrayToUInt8Tuple20(array: value)) 67 | 68 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 69 | } 70 | 71 | 72 | public func getValue() -> [UInt8] { 73 | return Bindings.UInt8Tuple20ToArray(tuple: self.cType!.data) 74 | } 75 | 76 | 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /out/wrappers/WitnessVersion.swift: -------------------------------------------------------------------------------- 1 | import Foundation // necessary for Data for Strings 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// Integer in the range `0..=16` 9 | internal typealias WitnessVersion = Bindings.WitnessVersion 10 | 11 | extension Bindings { 12 | 13 | /// Integer in the range `0..=16` 14 | internal class WitnessVersion: NativeTypeWrapper { 15 | 16 | 17 | /// Set to false to suppress an individual type's deinit log statements. 18 | /// Only applicable when log threshold is set to `.Debug`. 19 | public static var enableDeinitLogging = true 20 | 21 | /// Set to true to suspend the freeing of this type's associated Rust memory. 22 | /// Should only ever be used for debugging purposes, and will likely be 23 | /// deprecated soon. 24 | public static var suspendFreedom = false 25 | 26 | private static var instanceCounter: UInt = 0 27 | internal let instanceNumber: UInt 28 | 29 | internal var cType: LDKWitnessVersion? 30 | 31 | internal init(cType: LDKWitnessVersion, instantiationContext: String) { 32 | Self.instanceCounter += 1 33 | self.instanceNumber = Self.instanceCounter 34 | self.cType = cType 35 | 36 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 37 | } 38 | 39 | internal init(cType: LDKWitnessVersion, instantiationContext: String, anchor: NativeTypeWrapper) { 40 | Self.instanceCounter += 1 41 | self.instanceNumber = Self.instanceCounter 42 | self.cType = cType 43 | 44 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 45 | self.dangling = true 46 | try! self.addAnchor(anchor: anchor) 47 | } 48 | 49 | internal init( 50 | cType: LDKWitnessVersion, instantiationContext: String, anchor: NativeTypeWrapper, dangle: Bool = false 51 | ) { 52 | Self.instanceCounter += 1 53 | self.instanceNumber = Self.instanceCounter 54 | self.cType = cType 55 | 56 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 57 | self.dangling = dangle 58 | try! self.addAnchor(anchor: anchor) 59 | } 60 | 61 | 62 | internal init(value: UInt8, instantiationContext: String) { 63 | Self.instanceCounter += 1 64 | self.instanceNumber = Self.instanceCounter 65 | 66 | self.cType = LDKWitnessVersion(_0: value) 67 | 68 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 69 | } 70 | 71 | 72 | public func getValue() -> UInt8 { 73 | return self.cType!._0 74 | } 75 | 76 | 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /out/wrappers/u8slice.swift: -------------------------------------------------------------------------------- 1 | import Foundation // necessary for Data for Strings 2 | 3 | #if SWIFT_PACKAGE 4 | import LDKHeaders 5 | #endif 6 | 7 | 8 | /// A "slice" referencing some byte array. This is simply a length-tagged pointer which does not 9 | /// own the memory pointed to by data. 10 | internal typealias u8slice = Bindings.u8slice 11 | 12 | extension Bindings { 13 | 14 | /// A "slice" referencing some byte array. This is simply a length-tagged pointer which does not 15 | /// own the memory pointed to by data. 16 | internal class u8slice: NativeTypeWrapper { 17 | 18 | 19 | /// Set to false to suppress an individual type's deinit log statements. 20 | /// Only applicable when log threshold is set to `.Debug`. 21 | public static var enableDeinitLogging = true 22 | 23 | /// Set to true to suspend the freeing of this type's associated Rust memory. 24 | /// Should only ever be used for debugging purposes, and will likely be 25 | /// deprecated soon. 26 | public static var suspendFreedom = false 27 | 28 | private static var instanceCounter: UInt = 0 29 | internal let instanceNumber: UInt 30 | 31 | internal var cType: LDKu8slice? 32 | 33 | internal init(cType: LDKu8slice, instantiationContext: String) { 34 | Self.instanceCounter += 1 35 | self.instanceNumber = Self.instanceCounter 36 | self.cType = cType 37 | 38 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 39 | } 40 | 41 | internal init(cType: LDKu8slice, instantiationContext: String, anchor: NativeTypeWrapper) { 42 | Self.instanceCounter += 1 43 | self.instanceNumber = Self.instanceCounter 44 | self.cType = cType 45 | 46 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 47 | self.dangling = true 48 | try! self.addAnchor(anchor: anchor) 49 | } 50 | 51 | internal init(cType: LDKu8slice, instantiationContext: String, anchor: NativeTypeWrapper, dangle: Bool = false) 52 | { 53 | Self.instanceCounter += 1 54 | self.instanceNumber = Self.instanceCounter 55 | self.cType = cType 56 | 57 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 58 | self.dangling = dangle 59 | try! self.addAnchor(anchor: anchor) 60 | } 61 | 62 | 63 | internal init(value: [UInt8], instantiationContext: String) { 64 | Self.instanceCounter += 1 65 | self.instanceNumber = Self.instanceCounter 66 | 67 | 68 | let dataContainer = UnsafeMutablePointer.allocate(capacity: value.count) 69 | dataContainer.initialize(from: value, count: value.count) 70 | self.cType = LDKu8slice(data: dataContainer, datalen: UInt(value.count)) 71 | 72 | 73 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 74 | } 75 | 76 | 77 | public func getValue() -> [UInt8] { 78 | 79 | var array = [UInt8]() 80 | for index in 0.. ScriptConfig: 12 | config = ScriptConfig.parse( 13 | allow_ldk_argument=True, 14 | parse_configuration=(not CALL_INDIVIDUAL_BUILD_METHOD_VIA_SHELL) 15 | ) 16 | 17 | individual_configurations: [BuildConfig] = [ 18 | BuildConfig('iphoneos', '', ['arm64']), 19 | BuildConfig('iphonesimulator', '-simulator', ['arm64', 'x86_64']), 20 | BuildConfig('macosx', '', ['arm64', 'x86_64']), 21 | BuildConfig('macosx', '-macabi', ['arm64', 'x86_64']) 22 | ] 23 | config.LIBLDK_BUILD_CONFIGURATIONS = individual_configurations 24 | 25 | return config 26 | 27 | 28 | def run(config: ScriptConfig): 29 | child_environment = dict(os.environ) 30 | child_environment['LDK_C_BINDINGS_BASE'] = config.LDK_C_BINDINGS_BASE 31 | child_environment['LDK_C_BINDINGS_DIRECTORY'] = config.LDK_C_BINDINGS_DIRECTORY 32 | individual_libldk_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'build_individual_libldk.py') 33 | 34 | libldk_build_configurations = config.LIBLDK_BUILD_CONFIGURATIONS 35 | for current_build_config in libldk_build_configurations: 36 | current_platform: str = current_build_config.platform 37 | current_llvm_target_triple_suffix: str = current_build_config.llvm_target_triple_suffix 38 | current_architectures: [str] = current_build_config.architectures 39 | 40 | if CALL_INDIVIDUAL_BUILD_METHOD_VIA_SHELL: 41 | child_environment['PLATFORM'] = current_platform 42 | child_environment['LLVM_TARGET_TRIPLE_SUFFIX'] = current_llvm_target_triple_suffix 43 | child_environment['ARCHS'] = ' '.join(current_architectures) 44 | 45 | subprocess.check_call([sys.executable, individual_libldk_file], env=child_environment) 46 | else: 47 | current_config_clone = config 48 | current_config_clone.LIBLDK_BUILD_CONFIGURATIONS = [current_build_config] 49 | build_individual_libldk.run(config=current_config_clone) 50 | 51 | 52 | if __name__ == '__main__': 53 | run(config=parse_config()) 54 | -------------------------------------------------------------------------------- /scripts/copy_c_files.py: -------------------------------------------------------------------------------- 1 | import os.path 2 | import subprocess 3 | 4 | from script_config import ScriptConfig 5 | 6 | 7 | def run(config: ScriptConfig): 8 | header_directories = [ 9 | os.path.join(config.LDK_C_BINDINGS_DIRECTORY, 'include'), 10 | os.path.join(config.LDK_C_BINDINGS_BASE, 'ldk-net'), 11 | ] 12 | 13 | c_file_destination_directory = config.C_FILE_OUTPUT_DIRECTORY 14 | header_destination_directory = config.H_FILE_OUTPUT_DIRECTORY 15 | os.makedirs(c_file_destination_directory, exist_ok=True) 16 | os.makedirs(header_destination_directory, exist_ok=True) 17 | 18 | if c_file_destination_directory != header_destination_directory: 19 | print('Copying C files to', c_file_destination_directory) 20 | print('Copying headers to', header_destination_directory) 21 | 22 | for current_directory in header_directories: 23 | for current_file in os.listdir(current_directory): 24 | 25 | is_header_file = current_file.endswith('.h') 26 | is_c_file = current_file.endswith('.c') 27 | 28 | is_relevant_file = is_header_file or is_c_file 29 | if not is_relevant_file: 30 | continue 31 | 32 | current_path = os.path.join(current_directory, current_file) 33 | if not os.path.isfile(current_path): 34 | continue 35 | 36 | current_destination_directory = header_destination_directory 37 | if is_c_file: 38 | current_destination_directory = c_file_destination_directory 39 | 40 | print('Copying', current_path) 41 | subprocess.check_call(['cp', current_path, current_destination_directory]) 42 | 43 | 44 | if __name__ == '__main__': 45 | script_config = ScriptConfig.parse(allow_ldk_argument=True, parse_as_xcode_invocation=True) 46 | run(script_config) 47 | -------------------------------------------------------------------------------- /scripts/prepare_xcode_project.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | from script_config import ScriptConfig 5 | import copy_c_files 6 | import build_individual_libldk 7 | 8 | 9 | 10 | def run(config: ScriptConfig): 11 | print('Preparing Xcode project…') 12 | project_directory = os.getenv('PROJECT_DIR') 13 | 14 | bindings_binary_directory = os.getenv('LDK_C_BINDINGS_BINARY_DIRECTORY') 15 | forced_rebuild_override_directory = os.getenv('LDK_C_BINDINGS_BINARY_FORCED_REBUILD_OUTPUT_DIRECTORY') 16 | 17 | print('PROJECT_DIR:', project_directory) 18 | print('LDK_C_BINDINGS_BINARY_DIRECTORY:', bindings_binary_directory) 19 | print('LDK_C_BINDINGS_BINARY_FORCED_REBUILD_OUTPUT_DIRECTORY:', forced_rebuild_override_directory) 20 | 21 | # step 1: copy C files, *.h and *.c 22 | copy_c_files.run(config) 23 | 24 | if bindings_binary_directory and forced_rebuild_override_directory: 25 | print('LDK_C_BINDINGS_BINARY_DIRECTORY and LDK_C_BINDINGS_BINARY_FORCED_REBUILD_OUTPUT_DIRECTORY may not both be set at the same time!', file=sys.stderr) 26 | sys.exit(1) 27 | 28 | if not bindings_binary_directory and not forced_rebuild_override_directory: 29 | print('One of LDK_C_BINDINGS_BINARY_DIRECTORY and LDK_C_BINDINGS_BINARY_FORCED_REBUILD_OUTPUT_DIRECTORY must be set!', file=sys.stderr) 30 | sys.exit(1) 31 | 32 | if not forced_rebuild_override_directory: 33 | print('LDK_C_BINDINGS_BINARY_FORCED_REBUILD_OUTPUT_DIRECTORY not set: binary rebuild not necessary.') 34 | return 35 | 36 | # if and only if and if only LDK_C_BINDINGS_BINARY_FORCED_REBUILD_OUTPUT_DIRECTORY is set, we build the individual libldk 37 | config.LIPO_BINARY_OUTPUT_DIRECTORY = forced_rebuild_override_directory 38 | # TODO: detect if there's already a libldk.a in that directory and then not do the build 39 | build_individual_libldk.run(config) 40 | 41 | 42 | if __name__ == '__main__': 43 | script_config = ScriptConfig.parse( 44 | allow_ldk_argument=False, 45 | parse_configuration=True, 46 | parse_lipo_output_directory=True, 47 | parse_as_xcode_invocation=True 48 | ) 49 | run(script_config) 50 | -------------------------------------------------------------------------------- /scripts/symlink_resolver.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import os 3 | import shutil 4 | import subprocess 5 | import sys 6 | from os import path 7 | 8 | 9 | def run(xcframework_path: str): 10 | if not xcframework_path.endswith('.xcframework'): 11 | print('XCFramework path must end in *.xcframework', file=sys.stderr) 12 | sys.exit(1) 13 | if not path.exists(xcframework_path): 14 | print(f'Path {xcframework_path} does not exist', file=sys.stderr) 15 | sys.exit(1) 16 | if not path.isdir(xcframework_path): 17 | print('XCFramework must be a directory', file=sys.stderr) 18 | sys.exit(1) 19 | 20 | walked_paths = set() 21 | 22 | for current_root, current_subdirectories, current_files in os.walk(xcframework_path): 23 | 24 | if current_root in walked_paths: 25 | print('Skipping', current_root) 26 | 27 | for current_subdirectory in current_subdirectories: 28 | current_directory = path.join(current_root, current_subdirectory) 29 | is_symlink = path.islink(current_directory) 30 | if not is_symlink: 31 | continue 32 | 33 | walked_paths.add(current_directory) 34 | 35 | target = path.realpath(current_directory) 36 | print('Directory:', current_directory, '>', target) 37 | # remove current subdirectory 38 | print('Removing', current_directory) 39 | os.unlink(current_directory) 40 | # copy target into current directory 41 | target_contents = os.path.join(target, '.') 42 | print('Copying', target_contents, 'to', current_directory) 43 | subprocess.check_call(['cp', '-r', target_contents, current_directory]) 44 | 45 | for current_file in current_files: 46 | current_file_absolute = os.path.join(current_root, current_file) 47 | is_symlink = os.path.islink(current_file_absolute) 48 | if not is_symlink: 49 | continue 50 | target = path.realpath(current_file_absolute) 51 | print('File:', current_file_absolute, '>', target) 52 | # remove current file 53 | print('Removing', current_file_absolute) 54 | os.unlink(current_file_absolute) 55 | # copy target into current directory 56 | print('Copying', target, 'to', current_root) 57 | subprocess.check_call(['cp', target, current_root]) 58 | 59 | pass 60 | 61 | if __name__ == '__main__': 62 | parser = argparse.ArgumentParser(description='Resolve and replace symlinks in an xcframework') 63 | parser.add_argument('path', type=str, help='new checksum of LightningDevKit.xcframework.zip', default=None) 64 | args = parser.parse_args() 65 | run(xcframework_path=args.path) 66 | -------------------------------------------------------------------------------- /scripts/update_swift_package_checksum.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import json 3 | import os 4 | import re 5 | import sys 6 | 7 | 8 | def run(new_checksum: str = None, new_tag: str = None): 9 | if new_checksum is None and new_tag is None: 10 | print('At least one of --checksum or --tag arguments must be provided.', file=sys.stderr) 11 | sys.exit(1) 12 | 13 | if new_checksum is not None: 14 | if not new_checksum.isalnum(): 15 | print('Checksum must be alphanumeric.', file=sys.stderr) 16 | sys.exit(1) 17 | 18 | if not new_checksum.islower(): 19 | print('Checksum must be lowercase.', file=sys.stderr) 20 | sys.exit(1) 21 | 22 | try: 23 | int(new_checksum, 16) 24 | except: 25 | print('Checksum must be hexadecimal.', file=sys.stderr) 26 | sys.exit(1) 27 | 28 | if new_tag is not None: 29 | if new_tag.strip() != new_tag: 30 | print('Tag must not contain any whitespace.', file=sys.stderr) 31 | 32 | tag_regex = re.compile("^\d+[.]\d+[.]\d+$") 33 | tag_match = tag_regex.match(new_tag) 34 | if tag_match is None: 35 | print('Tag must adhere to x.x.x major/minor/patch format.', file=sys.stderr) 36 | 37 | settings = [ 38 | {'variable_name': 'checksum', 'value': new_checksum}, 39 | {'variable_name': 'tag', 'value': new_tag}, 40 | ] 41 | 42 | package_file_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '../Package.swift')) 43 | print(package_file_path) 44 | 45 | 46 | 47 | original_package_file = None 48 | try: 49 | with open(package_file_path, 'r') as package_file_handle: 50 | original_package_file = package_file_handle.read() 51 | except: 52 | print('Failed to read Package.swift file.', file=sys.stderr) 53 | sys.exit(1) 54 | 55 | package_file = original_package_file 56 | for current_setting in settings: 57 | current_variable_name = current_setting['variable_name'] 58 | new_value = current_setting['value'] 59 | if new_value is None: 60 | continue 61 | 62 | print(f'setting {current_variable_name} (JSON-serialization):') 63 | print(json.dumps(new_value)) 64 | 65 | regex = re.compile(f'(let[\s]+{current_variable_name}[\s]*=[\s]*)(.*)') 66 | 67 | previous_value = regex.search(package_file).group(2) 68 | # new_package_file = checksum_regex.sub(f'\g<1>"{new_checksum}"', package_file) 69 | package_file = package_file.replace(previous_value, f'"{new_value}"') 70 | 71 | with open(package_file_path, "w") as f: 72 | f.write(package_file) 73 | 74 | 75 | 76 | if __name__ == '__main__': 77 | parser = argparse.ArgumentParser(description='Process some integers.') 78 | parser.add_argument('--checksum', type=str, help='new checksum of LightningDevKit.xcframework.zip', required=False, default=None) 79 | parser.add_argument('--tag', type=str, help='new release tag', required=False, default=None) 80 | args = parser.parse_args() 81 | run(new_checksum=args.checksum, new_tag=args.tag) 82 | -------------------------------------------------------------------------------- /src/config.mts: -------------------------------------------------------------------------------- 1 | import {default as debugModule} from 'debug'; 2 | import url from 'url'; 3 | import child_process from 'child_process'; 4 | 5 | const debug = debugModule('ldk-parser:config'); 6 | 7 | export default class Config { 8 | 9 | getHeaderPath(): string { 10 | if (typeof process.env['LDK_SWIFT_GENERATOR_INPUT_HEADER_PATH'] === 'string' && process.env['LDK_SWIFT_GENERATOR_INPUT_HEADER_PATH'].length > 0) { 11 | debug('Header path: $LDK_SWIFT_GENERATOR_INPUT_HEADER_PATH = "%s"', process.env['LDK_SWIFT_GENERATOR_INPUT_HEADER_PATH']); 12 | return process.env['LDK_SWIFT_GENERATOR_INPUT_HEADER_PATH']; 13 | } 14 | 15 | const __dirname = url.fileURLToPath(new URL('.', import.meta.url)); 16 | const headerPath = `${__dirname}/../../ldk-c-bindings/lightning-c-bindings/include/lightning.h`; 17 | debug('Header path: "%s"', headerPath); 18 | return headerPath; 19 | } 20 | 21 | getOutputBaseDirectoryPath(): string { 22 | if (typeof process.env['LDK_SWIFT_GENERATOR_OUTPUT_DIRECTORY_PATH'] === 'string' && process.env['LDK_SWIFT_GENERATOR_OUTPUT_DIRECTORY_PATH'].length > 0) { 23 | debug('Output directory path: $LDK_SWIFT_GENERATOR_OUTPUT_DIRECTORY_PATH = "%s"', process.env['LDK_SWIFT_GENERATOR_OUTPUT_DIRECTORY_PATH']); 24 | return process.env['LDK_SWIFT_GENERATOR_OUTPUT_DIRECTORY_PATH']; 25 | } 26 | 27 | const __dirname = url.fileURLToPath(new URL('.', import.meta.url)); 28 | const outputDirectoryPath = `${__dirname}/../out`; 29 | debug('Output directory path: "%s"', outputDirectoryPath); 30 | return outputDirectoryPath; 31 | } 32 | 33 | getBatteryDirectoryPaths(): string[] { 34 | const __dirname = url.fileURLToPath(new URL('.', import.meta.url)); 35 | const ciProjectPath = `${__dirname}/../ci/LDKSwift`; 36 | const xcodeProjectPath = `${__dirname}/../xcode/LDKFramework`; 37 | return [ 38 | `${ciProjectPath}/Sources/LDKSwift/batteries/`, 39 | `${ciProjectPath}/Tests/LDKSwiftTests/`, 40 | `${xcodeProjectPath}/DirectlyLinkedBindingsApp/`, 41 | `${xcodeProjectPath}/DirectlyLinkedBindingsAppTests/`, 42 | ]; 43 | } 44 | 45 | getSwiftFormatterBinaryPath(): string | null { 46 | let swiftformatPath = process.env['SWIFT_FORMAT_PATH']; 47 | if (!swiftformatPath) { 48 | debug('SWIFT_FORMAT_PATH not defined, looking up PATH'); 49 | try { 50 | swiftformatPath = child_process.execSync('which swift-format').toString('utf-8').trim(); 51 | } catch (e) { 52 | debug('swift-format not found in PATH! See https://github.com/apple/swift-format#getting-swift-format for installation instructions.'); 53 | return null; 54 | } 55 | } 56 | 57 | return swiftformatPath; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/generation/nullable_option_generator.mts: -------------------------------------------------------------------------------- 1 | import {BaseTypeGenerator} from './base_type_generator.mjs'; 2 | import {RustFunction, RustNullableOption, RustPrimitiveEnum, RustType} from '../rust_types.mjs'; 3 | import Generator from './index.mjs'; 4 | 5 | export default class NullableOptionGenerator extends BaseTypeGenerator { 6 | generateFileContents(type: RustNullableOption): string { 7 | const swiftTypeName = this.swiftTypeName(type); 8 | 9 | let generatedMethods = ''; 10 | 11 | let someTag = ''; 12 | let noneTag = ''; 13 | 14 | let someInitializerMethod: RustFunction; 15 | let noneInitializerMethod: RustFunction; 16 | 17 | const tagEnumType = type.variantTag!.type as RustPrimitiveEnum; 18 | for (const currentTag of tagEnumType.variants) { 19 | if (currentTag.name.endsWith('_Some')) { 20 | someTag = currentTag.name; 21 | } else if (currentTag.name.endsWith('_None')) { 22 | noneTag = currentTag.name; 23 | } else { 24 | throw new Error('Unexpected nullable option tag enum variant name: ' + currentTag.name); 25 | } 26 | } 27 | 28 | for (const currentMethod of type.methods) { 29 | const standaloneMethodName = this.standaloneMethodName(currentMethod, type); 30 | if (standaloneMethodName === 'some') { 31 | someInitializerMethod = currentMethod; 32 | continue; 33 | } 34 | if (standaloneMethodName === 'none') { 35 | noneInitializerMethod = currentMethod; 36 | continue; 37 | } 38 | generatedMethods += this.generateMethod(currentMethod, type); 39 | } 40 | 41 | const swiftReturnType = this.getPublicTypeSignature(type.someVariant.type); 42 | const preparedReturnValue = this.prepareRustReturnValueForSwift(type.someVariant, type); 43 | 44 | const valueArgumentName = Generator.snakeCaseToCamelCase(type.someVariant.contextualName); 45 | const preparedArgument = this.prepareSwiftArgumentForRust(type.someVariant) 46 | 47 | return ` 48 | #if SWIFT_PACKAGE 49 | import LDKHeaders 50 | #endif 51 | 52 | ${this.renderDocComment(type.documentation, 3)} 53 | internal typealias ${swiftTypeName} = Bindings.${swiftTypeName} 54 | 55 | extension Bindings { 56 | 57 | ${this.renderDocComment(type.variantTag!.type.documentation, 4)} 58 | internal class ${swiftTypeName}: NativeTypeWrapper { 59 | 60 | ${this.inheritedInits(type)} 61 | 62 | internal init(${valueArgumentName}: ${swiftReturnType}?, instantiationContext: String) { 63 | Self.instanceCounter += 1 64 | self.instanceNumber = Self.instanceCounter 65 | 66 | if let some = some { 67 | ${Generator.reindentCode(preparedArgument.conversion, 7)} 68 | self.cType = ${preparedArgument.methodCallWrapperPrefix}${someInitializerMethod!.name}(${preparedArgument.accessor})${preparedArgument.methodCallWrapperSuffix} 69 | } else { 70 | self.cType = ${noneInitializerMethod!.name}() 71 | } 72 | 73 | super.init(conflictAvoidingVariableName: 0, instantiationContext: instantiationContext) 74 | } 75 | 76 | ${generatedMethods} 77 | 78 | public func getValue() -> ${swiftReturnType}? { 79 | if self.cType!.tag == ${noneTag} { 80 | return nil 81 | } 82 | if self.cType!.tag == ${someTag} { 83 | return ${preparedReturnValue.wrapperPrefix}self.cType!.some${preparedReturnValue.wrapperSuffix} 84 | } 85 | assert(false, "invalid option enum value") 86 | return nil 87 | } 88 | 89 | ${this.renderDanglingCloneAndDeinitMethods(type)} 90 | 91 | } 92 | 93 | } 94 | `; 95 | } 96 | 97 | protected outputDirectorySuffix(): string { 98 | return 'options'; 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /src/generation/primitive_enum_generator.mts: -------------------------------------------------------------------------------- 1 | import {RustPrimitiveEnum} from '../rust_types.mjs'; 2 | import {BaseTypeGenerator} from './base_type_generator.mjs'; 3 | 4 | export default class PrimitiveEnumGenerator extends BaseTypeGenerator { 5 | 6 | generateFileContents(type: RustPrimitiveEnum): string { 7 | if (type.parentType) { 8 | throw new Error(`Only orphan primitive enums may be generated. ${type.name} belongs to ${type.parentType.typeDescription}`); 9 | } 10 | 11 | const swiftTypeName = this.swiftTypeName(type); 12 | 13 | let enumVariants = ''; 14 | let rustValueAccessor = ''; 15 | let swiftValueInitializer = ''; 16 | 17 | // no reason in particular we're picking the last one and not any other 18 | // picking the first one would merely require an additional check inside the loop 19 | let lastSwiftVariantName = ''; 20 | 21 | for (const [index, currentVariant] of type.variants.entries()) { 22 | const currentVariantSwiftName = currentVariant.name.replace(type.name + '_', ''); 23 | const isLast = (index == type.variants.length - 1); 24 | 25 | enumVariants += ` 26 | ${this.renderDocComment(currentVariant.documentation, 5)} 27 | case ${currentVariantSwiftName} 28 | `; 29 | 30 | rustValueAccessor += ` 31 | case .${currentVariantSwiftName}: 32 | return ${currentVariant.name} 33 | `; 34 | 35 | swiftValueInitializer += ` 36 | case ${currentVariant.name}: 37 | self = .${currentVariantSwiftName} 38 | `; 39 | 40 | lastSwiftVariantName = currentVariantSwiftName; 41 | } 42 | 43 | swiftValueInitializer += ` 44 | default: 45 | Bindings.print("Error: Invalid value type for ${swiftTypeName}! Aborting.", severity: .ERROR) 46 | abort() 47 | `; 48 | 49 | return ` 50 | #if SWIFT_PACKAGE 51 | import LDKHeaders 52 | #endif 53 | 54 | import Foundation 55 | 56 | ${this.renderDocComment(type.documentation, 3)} 57 | public typealias ${swiftTypeName} = Bindings.${swiftTypeName} 58 | 59 | extension Bindings { 60 | 61 | ${this.renderDocComment(type.documentation, 4)} 62 | public enum ${swiftTypeName} { 63 | 64 | ${enumVariants} 65 | 66 | internal init (value: ${type.name}) { 67 | switch value { 68 | ${swiftValueInitializer} 69 | } 70 | } 71 | 72 | internal func getCValue() -> ${type.name} { 73 | switch self { 74 | ${rustValueAccessor} 75 | } 76 | } 77 | 78 | } 79 | 80 | } 81 | `; 82 | } 83 | 84 | outputDirectorySuffix(): string { 85 | return 'enums/primitive'; 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /src/generation/result_generator.mts: -------------------------------------------------------------------------------- 1 | import {RustPrimitive, RustResult, RustResultValueEnum} from '../rust_types.mjs'; 2 | import {BaseTypeGenerator} from './base_type_generator.mjs'; 3 | 4 | export default class ResultGenerator extends BaseTypeGenerator { 5 | 6 | generateFileContents(type: RustResult): string { 7 | const swiftTypeName = this.swiftTypeName(type); 8 | 9 | let generatedMethods = ''; 10 | 11 | const conflictingArgumentConstructors = this.collectConflictingConstructors(type); 12 | for (const currentMethod of type.methods) { 13 | const currentMethodName = this.swiftMethodName(currentMethod, type); 14 | if (currentMethodName === 'isOk') { 15 | // the native detour value checker is more circuitous 16 | continue; 17 | } 18 | 19 | const isConflictingConstructor = conflictingArgumentConstructors.has(currentMethod); 20 | generatedMethods += this.generateMethod(currentMethod, type, isConflictingConstructor); 21 | } 22 | 23 | const valueEnum = type.valueField.type as RustResultValueEnum; 24 | const preparedErrorReturnValue = this.prepareRustReturnValueForSwift(valueEnum.errorVariant, type); 25 | const preparedSuccessReturnValue = this.prepareRustReturnValueForSwift(valueEnum.resultVariant, type); 26 | 27 | let successTypeSignature = this.getPublicTypeSignature(valueEnum.resultVariant.type); 28 | let errorTypeSignature = this.getPublicTypeSignature(valueEnum.errorVariant.type); 29 | 30 | let successBlockCommentPrefix = ''; 31 | let successBlockCommentSuffix = ''; 32 | let failureBlockCommentPrefix = ''; 33 | let failureBlockCommentSuffix = ''; 34 | 35 | if(valueEnum.resultVariant.type instanceof RustPrimitive && valueEnum.resultVariant.type.swiftRawSignature === 'Void'){ 36 | successBlockCommentPrefix = '/*' 37 | successBlockCommentSuffix = '*/' 38 | } 39 | if(valueEnum.errorVariant.type instanceof RustPrimitive && valueEnum.errorVariant.type.swiftRawSignature === 'Void'){ 40 | failureBlockCommentPrefix = '/*' 41 | failureBlockCommentSuffix = '*/' 42 | } 43 | 44 | if (!successTypeSignature.endsWith('?')) { 45 | // it's always an optional 46 | successTypeSignature += '?'; 47 | } 48 | 49 | if (!errorTypeSignature.endsWith('?')) { 50 | // it's always an optional 51 | errorTypeSignature += '?'; 52 | } 53 | 54 | 55 | 56 | return ` 57 | #if SWIFT_PACKAGE 58 | import LDKHeaders 59 | #endif 60 | 61 | ${this.renderDocComment(type.documentation, 3)} 62 | public typealias ${swiftTypeName} = Bindings.${swiftTypeName} 63 | 64 | extension Bindings { 65 | 66 | ${this.renderDocComment(type.documentation, 4)} 67 | public class ${swiftTypeName}: NativeTypeWrapper { 68 | 69 | ${this.inheritedInits(type)} 70 | 71 | ${generatedMethods} 72 | 73 | public func isOk() -> Bool { 74 | return self.cType?.result_ok == true 75 | } 76 | 77 | ${failureBlockCommentPrefix} 78 | public func getError() -> ${errorTypeSignature} { 79 | if self.cType?.result_ok == false { 80 | return ${preparedErrorReturnValue.wrapperPrefix}self.cType!.contents.err${preparedErrorReturnValue.wrapperSuffix} 81 | } 82 | return nil 83 | } 84 | ${failureBlockCommentSuffix} 85 | 86 | ${successBlockCommentPrefix} 87 | public func getValue() -> ${successTypeSignature} { 88 | if self.cType?.result_ok == true { 89 | return ${preparedSuccessReturnValue.wrapperPrefix}self.cType!.contents.result${preparedSuccessReturnValue.wrapperSuffix} 90 | } 91 | return nil 92 | } 93 | ${successBlockCommentSuffix} 94 | 95 | ${this.renderDanglingCloneAndDeinitMethods(type)} 96 | 97 | } 98 | 99 | } 100 | `; 101 | } 102 | 103 | outputDirectorySuffix(): string { 104 | return 'results'; 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /src/generation/struct_generator.mts: -------------------------------------------------------------------------------- 1 | import {RustFunction, RustStruct, RustType} from '../rust_types.mjs'; 2 | import {BaseTypeGenerator} from './base_type_generator.mjs'; 3 | 4 | export default class StructGenerator extends BaseTypeGenerator { 5 | 6 | generateFileContents(type: RustStruct, containerType?: RustType): string { 7 | let swiftTypeName = this.swiftTypeName(type); 8 | 9 | let containerLessPrefix = ` 10 | #if SWIFT_PACKAGE 11 | import LDKHeaders 12 | #endif 13 | 14 | ${this.renderDocComment(type.documentation, 3)} 15 | public typealias ${swiftTypeName} = Bindings.${swiftTypeName} 16 | 17 | extension Bindings { 18 | `; 19 | let containerLessSuffix = ` 20 | } 21 | `; 22 | 23 | if (type.parentType && type.parentType !== containerType) { 24 | throw new Error(`Only orphan structs may be generated. ${type.name} belongs to ${type.parentType.typeDescription}`); 25 | } else if (type.parentType) { 26 | swiftTypeName = this.getPublicTypeSignature(type, containerType); 27 | containerLessPrefix = ` 28 | ${this.renderDocComment(type.documentation, 4)} 29 | internal typealias ${this.getPublicTypeSignature(type)} = ${swiftTypeName} 30 | `; 31 | containerLessSuffix = ''; 32 | } 33 | 34 | let fieldAccessors = ''; 35 | let generatedMethods = ''; 36 | 37 | let ownershipInfix = ''; 38 | let initialCFreeabilityInfix = ''; 39 | if (type.ownershipField) { 40 | // TODO: determine if setting this value to true by default is wise 41 | ownershipInfix = `, ${type.ownershipField.contextualName}: true`; 42 | initialCFreeabilityInfix = 'let initialCFreeability: Bool' 43 | } 44 | 45 | for (const [_, currentField] of Object.entries(type.fields)) { 46 | fieldAccessors += this.generateAccessor(currentField, type); 47 | } 48 | 49 | 50 | // THIS IS ALL CODE TO DETECT CONSTRUCTORS WITH DUPLICATE SIGNATURES 51 | const conflictingArgumentConstructors = this.collectConflictingConstructors(type); 52 | for (const currentMethod of type.methods) { 53 | const isConflictingConstructor = conflictingArgumentConstructors.has(currentMethod); 54 | generatedMethods += this.generateMethod(currentMethod, type, isConflictingConstructor); 55 | } 56 | 57 | 58 | 59 | return ` 60 | ${containerLessPrefix} 61 | 62 | ${this.renderDocComment(type.documentation, 4)} 63 | public class ${swiftTypeName}: NativeTypeWrapper { 64 | 65 | ${initialCFreeabilityInfix} 66 | 67 | ${this.inheritedInits(type)} 68 | 69 | ${generatedMethods} 70 | 71 | ${fieldAccessors} 72 | 73 | ${this.renderDanglingCloneAndDeinitMethods(type)} 74 | 75 | } 76 | 77 | ${containerLessSuffix} 78 | `; 79 | } 80 | 81 | outputDirectorySuffix(): string { 82 | return 'structs'; 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /src/generation/tuple_generator.mts: -------------------------------------------------------------------------------- 1 | import {RustTuple, RustType} from '../rust_types.mjs'; 2 | import {BaseTypeGenerator} from './base_type_generator.mjs'; 3 | import Generator from './index.mjs'; 4 | 5 | export default class TupleGenerator extends BaseTypeGenerator { 6 | 7 | generateFileContents(type: RustTuple, containerType?: RustType): string { 8 | const swiftTypeName = this.swiftTypeName(type); 9 | const swiftReturnType = this.getPublicTypeSignature(type); 10 | 11 | let fieldAccessors = ''; 12 | let generatedMethods = ''; 13 | 14 | for (const [_, currentField] of Object.entries(type.fields)) { 15 | fieldAccessors += this.generateAccessor(currentField, type); 16 | } 17 | 18 | for (const currentMethod of type.methods) { 19 | const standaloneMethodName = this.standaloneMethodName(currentMethod, type); 20 | 21 | if (!['free', 'clone', 'new'].includes(standaloneMethodName)) { 22 | let filteredTypeName = swiftTypeName.substring('Tuple_'.length, swiftTypeName.length - 'Z'.length); 23 | this.auxiliaryArtifacts.addMethod(currentMethod, standaloneMethodName + filteredTypeName); 24 | } 25 | 26 | generatedMethods += this.generateMethod(currentMethod, type); 27 | } 28 | 29 | let initializer = []; 30 | let valueAccessor = []; 31 | 32 | for (const [fieldIndex, currentField] of type.orderedFields.entries()) { 33 | let fieldAccessorName = Generator.snakeCaseToCamelCase(currentField.contextualName, true); 34 | initializer.push(`${currentField.contextualName}: tuple.${fieldIndex}`); 35 | valueAccessor.push(`self.get${fieldAccessorName}()`); 36 | } 37 | 38 | return ` 39 | #if SWIFT_PACKAGE 40 | import LDKHeaders 41 | #endif 42 | 43 | ${this.renderDocComment(type.documentation, 3)} 44 | internal typealias ${swiftTypeName} = Bindings.${swiftTypeName} 45 | 46 | extension Bindings { 47 | 48 | ${this.renderDocComment(type.documentation, 4)} 49 | internal class ${swiftTypeName}: NativeTypeWrapper { 50 | 51 | ${this.inheritedInits(type)} 52 | 53 | internal convenience init(tuple: ${swiftReturnType}, instantiationContext: String) { 54 | self.init(${initializer.join(', ')}, instantiationContext: instantiationContext) 55 | } 56 | 57 | ${generatedMethods} 58 | 59 | public func getValue() -> ${swiftReturnType} { 60 | return (${valueAccessor.join(', ')}) 61 | } 62 | 63 | ${fieldAccessors} 64 | 65 | ${this.renderDanglingCloneAndDeinitMethods(type)} 66 | 67 | } 68 | } 69 | `; 70 | } 71 | 72 | outputDirectorySuffix(): string { 73 | return 'tuples'; 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/index.mts: -------------------------------------------------------------------------------- 1 | import Parser from './parser.mjs'; 2 | import Config from './config.mjs'; 3 | import Generator from './generation/index.mjs'; 4 | 5 | (async () => { 6 | // add comments 7 | let config = new Config(); 8 | 9 | const parser = new Parser(config); 10 | parser.parse(); 11 | 12 | const generator = new Generator(parser); 13 | 14 | // optional, only if we wanna remove existing artifacts 15 | generator.initializeOutputDirectory(); 16 | 17 | const serializationHashTree = generator.calculateSerializationHash(); 18 | 19 | await generator.generateTypes(); 20 | await generator.generateFunctions(); 21 | await generator.runFormatter(true); 22 | })(); 23 | 24 | interface NullTest { 25 | someValue?: string 26 | } 27 | 28 | function nullInterpolationExample(someValue: NullTest){ 29 | console.log(`hello, ${someValue.someValue}`) 30 | } 31 | -------------------------------------------------------------------------------- /test/fixtures/generation/option_u32_test.h: -------------------------------------------------------------------------------- 1 | /** 2 | * An enum which can either contain a u32 or not 3 | */ 4 | typedef enum LDKCOption_u32Z_Tag { 5 | /** 6 | * When we're in this state, this COption_u32Z contains a u32 7 | */ 8 | LDKCOption_u32Z_Some, 9 | /** 10 | * When we're in this state, this COption_u32Z contains nothing 11 | */ 12 | LDKCOption_u32Z_None, 13 | /** 14 | * Must be last for serialization purposes 15 | */ 16 | LDKCOption_u32Z_Sentinel, 17 | } LDKCOption_u32Z_Tag; 18 | 19 | typedef struct LDKCOption_u32Z { 20 | LDKCOption_u32Z_Tag tag; 21 | union { 22 | struct { 23 | uint32_t some; 24 | }; 25 | }; 26 | } LDKCOption_u32Z; 27 | 28 | /** 29 | * Constructs a new COption_u32Z containing a u32 30 | */ 31 | struct LDKCOption_u32Z COption_u32Z_some(uint32_t o); 32 | 33 | /** 34 | * Constructs a new COption_u32Z containing nothing 35 | */ 36 | struct LDKCOption_u32Z COption_u32Z_none(void); 37 | 38 | /** 39 | * Frees any resources associated with the u32, if we are in the Some state 40 | */ 41 | void COption_u32Z_free(struct LDKCOption_u32Z _res); 42 | 43 | /** 44 | * Creates a new COption_u32Z which has the same data as `orig` 45 | * but with all dynamically-allocated buffers duplicated in new buffers. 46 | */ 47 | struct LDKCOption_u32Z COption_u32Z_clone(const struct LDKCOption_u32Z *NONNULL_PTR orig); -------------------------------------------------------------------------------- /test/fixtures/generation/vec_u8_test.h: -------------------------------------------------------------------------------- 1 | /** 2 | * A dynamically-allocated array of u8s of arbitrary size. 3 | * This corresponds to std::vector in C++ 4 | */ 5 | typedef struct LDKCVec_u8Z { 6 | /** 7 | * The elements in the array. 8 | * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). 9 | */ 10 | uint8_t *data; 11 | /** 12 | * The number of elements pointed to by `data`. 13 | */ 14 | uintptr_t datalen; 15 | } LDKCVec_u8Z; -------------------------------------------------------------------------------- /test/fixtures/generation/vec_vec_route_hop_test.h: -------------------------------------------------------------------------------- 1 | /** 2 | * A hop in a route 3 | */ 4 | typedef struct MUST_USE_STRUCT LDKRouteHop { 5 | /** 6 | * A pointer to the opaque Rust object. 7 | * Nearly everywhere, inner must be non-null, however in places where 8 | * the Rust equivalent takes an Option, it may be set to null to indicate None. 9 | */ 10 | LDKnativeRouteHop *inner; 11 | /** 12 | * Indicates that this is the only struct which contains the same pointer. 13 | * Rust functions which take ownership of an object provided via an argument require 14 | * this to be true and invalidate the object pointed to by inner. 15 | */ 16 | bool is_owned; 17 | } LDKRouteHop; 18 | 19 | /** 20 | * A dynamically-allocated array of crate::lightning::routing::router::RouteHops of arbitrary size. 21 | * This corresponds to std::vector in C++ 22 | */ 23 | typedef struct LDKCVec_RouteHopZ { 24 | /** 25 | * The elements in the array. 26 | * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). 27 | */ 28 | struct LDKRouteHop *data; 29 | /** 30 | * The number of elements pointed to by `data`. 31 | */ 32 | uintptr_t datalen; 33 | } LDKCVec_RouteHopZ; 34 | 35 | /** 36 | * A dynamically-allocated array of crate::c_types::derived::CVec_RouteHopZs of arbitrary size. 37 | * This corresponds to std::vector in C++ 38 | */ 39 | typedef struct LDKCVec_CVec_RouteHopZZ { 40 | /** 41 | * The elements in the array. 42 | * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). 43 | */ 44 | struct LDKCVec_RouteHopZ *data; 45 | /** 46 | * The number of elements pointed to by `data`. 47 | */ 48 | uintptr_t datalen; 49 | } LDKCVec_CVec_RouteHopZZ; 50 | 51 | /** 52 | * Frees the buffer pointed to by `data` if `datalen` is non-0. 53 | */ 54 | void CVec_CVec_RouteHopZZ_free(struct LDKCVec_CVec_RouteHopZZ _res); -------------------------------------------------------------------------------- /test/fixtures/parsing/binary_option_test_01.h: -------------------------------------------------------------------------------- 1 | /** 2 | * An enum which can either contain a u32 or not 3 | */ 4 | typedef enum LDKCOption_u32Z_Tag { 5 | /** 6 | * When we're in this state, this COption_u32Z contains a u32 7 | */ 8 | LDKCOption_u32Z_Some, 9 | /** 10 | * When we're in this state, this COption_u32Z contains nothing 11 | */ 12 | LDKCOption_u32Z_None, 13 | /** 14 | * Must be last for serialization purposes 15 | */ 16 | LDKCOption_u32Z_Sentinel, 17 | } LDKCOption_u32Z_Tag; 18 | 19 | typedef struct LDKCOption_u32Z { 20 | LDKCOption_u32Z_Tag tag; 21 | union { 22 | struct { 23 | uint32_t some; 24 | }; 25 | }; 26 | } LDKCOption_u32Z; -------------------------------------------------------------------------------- /test/fixtures/parsing/result_test_01.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Onion messages can be sent and received to blinded routes, which serve to hide the identity of 3 | * the recipient. 4 | */ 5 | typedef struct MUST_USE_STRUCT LDKBlindedRoute { 6 | /** 7 | * A pointer to the opaque Rust object. 8 | * Nearly everywhere, inner must be non-null, however in places where 9 | * the Rust equivalent takes an Option, it may be set to null to indicate None. 10 | */ 11 | LDKnativeBlindedRoute *inner; 12 | /** 13 | * Indicates that this is the only struct which contains the same pointer. 14 | * Rust functions which take ownership of an object provided via an argument require 15 | * this to be true and invalidate the object pointed to by inner. 16 | */ 17 | bool is_owned; 18 | } LDKBlindedRoute; 19 | 20 | /** 21 | * The contents of CResult_BlindedRouteNoneZ 22 | */ 23 | typedef union LDKCResult_BlindedRouteNoneZPtr { 24 | /** 25 | * A pointer to the contents in the success state. 26 | * Reading from this pointer when `result_ok` is not set is undefined. 27 | */ 28 | struct LDKBlindedRoute *result; 29 | /** 30 | * Note that this value is always NULL, as there are no contents in the Err variant 31 | */ 32 | void *err; 33 | } LDKCResult_BlindedRouteNoneZPtr; 34 | 35 | /** 36 | * A CResult_BlindedRouteNoneZ represents the result of a fallible operation, 37 | * containing a crate::lightning::onion_message::blinded_route::BlindedRoute on success and a () on failure. 38 | * `result_ok` indicates the overall state, and the contents are provided via `contents`. 39 | */ 40 | typedef struct LDKCResult_BlindedRouteNoneZ { 41 | /** 42 | * The contents of this CResult_BlindedRouteNoneZ, accessible via either 43 | * `err` or `result` depending on the state of `result_ok`. 44 | */ 45 | union LDKCResult_BlindedRouteNoneZPtr contents; 46 | /** 47 | * Whether this CResult_BlindedRouteNoneZ represents a success state. 48 | */ 49 | bool result_ok; 50 | } LDKCResult_BlindedRouteNoneZ; -------------------------------------------------------------------------------- /test/fixtures/parsing/tagged_value_enum_test_01.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Represents an error returned from the bech32 library during validation of some bech32 data 3 | */ 4 | typedef enum LDKBech32Error_Tag { 5 | /** 6 | * String does not contain the separator character 7 | */ 8 | LDKBech32Error_MissingSeparator, 9 | /** 10 | * The checksum does not match the rest of the data 11 | */ 12 | LDKBech32Error_InvalidChecksum, 13 | /** 14 | * The data or human-readable part is too long or too short 15 | */ 16 | LDKBech32Error_InvalidLength, 17 | /** 18 | * Some part of the string contains an invalid character 19 | */ 20 | LDKBech32Error_InvalidChar, 21 | /** 22 | * Some part of the data has an invalid value 23 | */ 24 | LDKBech32Error_InvalidData, 25 | /** 26 | * The bit conversion failed due to a padding issue 27 | */ 28 | LDKBech32Error_InvalidPadding, 29 | /** 30 | * The whole string must be of one case 31 | */ 32 | LDKBech32Error_MixedCase, 33 | /** 34 | * Must be last for serialization purposes 35 | */ 36 | LDKBech32Error_Sentinel, 37 | } LDKBech32Error_Tag; 38 | 39 | typedef struct LDKBech32Error { 40 | LDKBech32Error_Tag tag; 41 | union { 42 | struct { 43 | uint32_t invalid_char; 44 | }; 45 | struct { 46 | uint8_t invalid_data; 47 | }; 48 | }; 49 | } LDKBech32Error; -------------------------------------------------------------------------------- /test/fixtures/parsing/tagged_value_enum_test_02.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Arbitrary 32 bytes, which could represent one of a few different things. You probably want to 3 | * look up the corresponding function in rust-lightning's docs. 4 | */ 5 | typedef struct LDKThirtyTwoBytes { 6 | /** 7 | * The thirty-two bytes 8 | */ 9 | uint8_t data[32]; 10 | } LDKThirtyTwoBytes; 11 | 12 | /** 13 | * Some information provided on receipt of payment depends on whether the payment received is a 14 | * spontaneous payment or a \"conventional\" lightning payment that's paying an invoice. 15 | */ 16 | typedef enum LDKPaymentPurpose_Tag { 17 | /** 18 | * Information for receiving a payment that we generated an invoice for. 19 | */ 20 | LDKPaymentPurpose_InvoicePayment, 21 | /** 22 | * Because this is a spontaneous payment, the payer generated their own preimage rather than us 23 | * (the payee) providing a preimage. 24 | */ 25 | LDKPaymentPurpose_SpontaneousPayment, 26 | /** 27 | * Must be last for serialization purposes 28 | */ 29 | LDKPaymentPurpose_Sentinel, 30 | } LDKPaymentPurpose_Tag; 31 | 32 | typedef struct LDKPaymentPurpose_LDKInvoicePayment_Body { 33 | /** 34 | * The preimage to the payment_hash, if the payment hash (and secret) were fetched via 35 | * [`ChannelManager::create_inbound_payment`]. If provided, this can be handed directly to 36 | * [`ChannelManager::claim_funds`]. 37 | * 38 | * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment 39 | * [`ChannelManager::claim_funds`]: crate::ln::channelmanager::ChannelManager::claim_funds 40 | * 41 | * Note that this (or a relevant inner pointer) may be NULL or all-0s to represent None 42 | */ 43 | struct LDKThirtyTwoBytes payment_preimage; 44 | /** 45 | * The \"payment secret\". This authenticates the sender to the recipient, preventing a 46 | * number of deanonymization attacks during the routing process. 47 | * It is provided here for your reference, however its accuracy is enforced directly by 48 | * [`ChannelManager`] using the values you previously provided to 49 | * [`ChannelManager::create_inbound_payment`] or 50 | * [`ChannelManager::create_inbound_payment_for_hash`]. 51 | * 52 | * [`ChannelManager`]: crate::ln::channelmanager::ChannelManager 53 | * [`ChannelManager::create_inbound_payment`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment 54 | * [`ChannelManager::create_inbound_payment_for_hash`]: crate::ln::channelmanager::ChannelManager::create_inbound_payment_for_hash 55 | */ 56 | struct LDKThirtyTwoBytes payment_secret; 57 | } LDKPaymentPurpose_LDKInvoicePayment_Body; 58 | 59 | typedef struct MUST_USE_STRUCT LDKPaymentPurpose { 60 | LDKPaymentPurpose_Tag tag; 61 | union { 62 | LDKPaymentPurpose_LDKInvoicePayment_Body invoice_payment; 63 | struct { 64 | struct LDKThirtyTwoBytes spontaneous_payment; 65 | }; 66 | }; 67 | } LDKPaymentPurpose; -------------------------------------------------------------------------------- /test/fixtures/parsing/trait_test_01.h: -------------------------------------------------------------------------------- 1 | /** 2 | * A Record, unit of logging output with Metadata to enable filtering 3 | * Module_path, file, line to inform on log's source 4 | */ 5 | typedef struct MUST_USE_STRUCT LDKRecord { 6 | /** 7 | * A pointer to the opaque Rust object. 8 | * Nearly everywhere, inner must be non-null, however in places where 9 | * the Rust equivalent takes an Option, it may be set to null to indicate None. 10 | */ 11 | LDKnativeRecord *inner; 12 | /** 13 | * Indicates that this is the only struct which contains the same pointer. 14 | * Rust functions which take ownership of an object provided via an argument require 15 | * this to be true and invalidate the object pointed to by inner. 16 | */ 17 | bool is_owned; 18 | } LDKRecord; 19 | 20 | /** 21 | * A trait encapsulating the operations required of a logger 22 | */ 23 | typedef struct LDKLogger { 24 | /** 25 | * An opaque pointer which is passed to your function implementations as an argument. 26 | * This has no meaning in the LDK, and can be NULL or any other value. 27 | */ 28 | void *this_arg; 29 | /** 30 | * Logs the `Record` 31 | */ 32 | void (*log)(const void *this_arg, const struct LDKRecord *NONNULL_PTR record); 33 | /** 34 | * Frees any resources associated with this object given its this_arg pointer. 35 | * Does not need to free the outer struct containing function pointers and may be NULL is no resources need to be freed. 36 | */ 37 | void (*free)(void *this_arg); 38 | } LDKLogger; -------------------------------------------------------------------------------- /test/fixtures/parsing/trait_test_03.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Represents a valid secp256k1 public key serialized in "compressed form" as a 33 byte array. 3 | */ 4 | typedef struct LDKPublicKey { 5 | /** 6 | * The bytes of the public key 7 | */ 8 | uint8_t compressed_form[33]; 9 | } LDKPublicKey; 10 | 11 | /** 12 | * The contents of CResult_NoneNoneZ 13 | */ 14 | typedef union LDKCResult_NoneNoneZPtr { 15 | /** 16 | * Note that this value is always NULL, as there are no contents in the OK variant 17 | */ 18 | void *result; 19 | /** 20 | * Note that this value is always NULL, as there are no contents in the Err variant 21 | */ 22 | void *err; 23 | } LDKCResult_NoneNoneZPtr; 24 | 25 | /** 26 | * A CResult_NoneNoneZ represents the result of a fallible operation, 27 | * containing a () on success and a () on failure. 28 | * `result_ok` indicates the overall state, and the contents are provided via `contents`. 29 | */ 30 | typedef struct LDKCResult_NoneNoneZ { 31 | /** 32 | * The contents of this CResult_NoneNoneZ, accessible via either 33 | * `err` or `result` depending on the state of `result_ok`. 34 | */ 35 | union LDKCResult_NoneNoneZPtr contents; 36 | /** 37 | * Whether this CResult_NoneNoneZ represents a success state. 38 | */ 39 | bool result_ok; 40 | } LDKCResult_NoneNoneZ; 41 | 42 | /** 43 | * A trait to sign lightning channel transactions as described in BOLT 3. 44 | */ 45 | typedef struct LDKBaseSign { 46 | struct LDKPublicKey (*lambda_name_foo)(const void *this_arg, const uint8_t (*argument_name_bar)[32], uint64_t idx); 47 | void (*set_pubkeys)(const struct LDKBaseSign*NONNULL_PTR ); 48 | 49 | 50 | void *this_arg; 51 | 52 | struct LDKPublicKey (*get_per_commitment_point)(const void *this_arg, uint64_t idx); 53 | 54 | struct LDKCResult_NoneNoneZ (*validate_holder_commitment)(const void *this_arg, const struct LDKPublicKey *NONNULL_PTR holder_tx, struct LDKPublicKey preimages); 55 | 56 | struct LDKPublicKey pubkeys; 57 | 58 | 59 | 60 | struct LDKPublicKey (*channel_keys_id)(const void *this_arg); 61 | 62 | 63 | 64 | void (*free)(void *this_arg); 65 | } LDKBaseSign; -------------------------------------------------------------------------------- /test/fixtures/parsing/tuple_test_01.h: -------------------------------------------------------------------------------- 1 | /** 2 | * A serialized transaction, in (pointer, length) form. 3 | * 4 | * This type optionally owns its own memory, and thus the semantics around access change based on 5 | * the `data_is_owned` flag. If `data_is_owned` is set, you must call `Transaction_free` to free 6 | * the underlying buffer before the object goes out of scope. If `data_is_owned` is not set, any 7 | * access to the buffer after the scope in which the object was provided to you is invalid. eg, 8 | * access after you return from the call in which a `!data_is_owned` `Transaction` is provided to 9 | * you would be invalid. 10 | * 11 | * Note that, while it may change in the future, because transactions on the Rust side are stored 12 | * in a deserialized form, all `Transaction`s generated on the Rust side will have `data_is_owned` 13 | * set. Similarly, while it may change in the future, all `Transaction`s you pass to Rust may have 14 | * `data_is_owned` either set or unset at your discretion. 15 | */ 16 | typedef struct LDKTransaction { 17 | /** 18 | * The serialized transaction data. 19 | * 20 | * This is non-const for your convenience, an object passed to Rust is never written to. 21 | */ 22 | uint8_t *data; 23 | /** 24 | * The length of the serialized transaction 25 | */ 26 | uintptr_t datalen; 27 | /** 28 | * Whether the data pointed to by `data` should be freed or not. 29 | */ 30 | bool data_is_owned; 31 | } LDKTransaction; 32 | 33 | /** 34 | * A tuple of 2 elements. See the individual fields for the types contained. 35 | */ 36 | typedef struct LDKC2Tuple_usizeTransactionZ { 37 | /** 38 | * The element at position 0 39 | */ 40 | uintptr_t a; 41 | /** 42 | * The element at position 1 43 | */ 44 | struct LDKTransaction b; 45 | } LDKC2Tuple_usizeTransactionZ; -------------------------------------------------------------------------------- /test/fixtures/parsing/vector_test_01.h: -------------------------------------------------------------------------------- 1 | /** 2 | * A dynamically-allocated array of u8s of arbitrary size. 3 | * This corresponds to std::vector in C++ 4 | */ 5 | typedef struct LDKCVec_u8Z { 6 | /** 7 | * The elements in the array. 8 | * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). 9 | */ 10 | uint8_t *data; 11 | /** 12 | * The number of elements pointed to by `data`. 13 | */ 14 | uintptr_t datalen; 15 | } LDKCVec_u8Z; -------------------------------------------------------------------------------- /test/fixtures/parsing/vector_test_02.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Represents a valid secp256k1 public key serialized in "compressed form" as a 33 byte array. 3 | */ 4 | typedef struct LDKPublicKey { 5 | /** 6 | * The bytes of the public key 7 | */ 8 | uint8_t compressed_form[33]; 9 | } LDKPublicKey; 10 | 11 | /** 12 | * A dynamically-allocated array of crate::c_types::PublicKeys of arbitrary size. 13 | * This corresponds to std::vector in C++ 14 | */ 15 | typedef struct LDKCVec_PublicKeyZ { 16 | /** 17 | * The elements in the array. 18 | * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). 19 | */ 20 | struct LDKPublicKey *data; 21 | /** 22 | * The number of elements pointed to by `data`. 23 | */ 24 | uintptr_t datalen; 25 | } LDKCVec_PublicKeyZ; -------------------------------------------------------------------------------- /test/fixtures/parsing/vector_test_03.h: -------------------------------------------------------------------------------- 1 | /** 2 | * A hop in a route 3 | */ 4 | typedef struct MUST_USE_STRUCT LDKRouteHop { 5 | /** 6 | * A pointer to the opaque Rust object. 7 | * Nearly everywhere, inner must be non-null, however in places where 8 | * the Rust equivalent takes an Option, it may be set to null to indicate None. 9 | */ 10 | LDKnativeRouteHop *inner; 11 | /** 12 | * Indicates that this is the only struct which contains the same pointer. 13 | * Rust functions which take ownership of an object provided via an argument require 14 | * this to be true and invalidate the object pointed to by inner. 15 | */ 16 | bool is_owned; 17 | } LDKRouteHop; 18 | 19 | /** 20 | * A dynamically-allocated array of crate::lightning::routing::router::RouteHops of arbitrary size. 21 | * This corresponds to std::vector in C++ 22 | */ 23 | typedef struct LDKCVec_RouteHopZ { 24 | /** 25 | * The elements in the array. 26 | * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). 27 | */ 28 | struct LDKRouteHop *data; 29 | /** 30 | * The number of elements pointed to by `data`. 31 | */ 32 | uintptr_t datalen; 33 | } LDKCVec_RouteHopZ; 34 | 35 | /** 36 | * A dynamically-allocated array of crate::c_types::derived::CVec_RouteHopZs of arbitrary size. 37 | * This corresponds to std::vector in C++ 38 | */ 39 | typedef struct LDKCVec_CVec_RouteHopZZ { 40 | /** 41 | * The elements in the array. 42 | * If datalen is non-0 this must be a valid, non-NULL pointer allocated by malloc(). 43 | */ 44 | struct LDKCVec_RouteHopZ *data; 45 | /** 46 | * The number of elements pointed to by `data`. 47 | */ 48 | uintptr_t datalen; 49 | } LDKCVec_CVec_RouteHopZZ; -------------------------------------------------------------------------------- /test/fixtures/parsing/vector_test_04.h: -------------------------------------------------------------------------------- 1 | /** 2 | * A dynamically-allocated array of u8s of arbitrary size. 3 | * This corresponds to std::vector in C++ 4 | */ 5 | typedef struct LDKCVec_u8Z { 6 | 7 | uint8_t *data; 8 | 9 | /** second comment */ 10 | uintptr_t datalen; 11 | 12 | } LDKCVec_u8Z; -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "ES2020", 4 | "moduleResolution": "Node", 5 | "target": "es2021", 6 | "sourceMap": true, 7 | "esModuleInterop": false, 8 | "allowSyntheticDefaultImports": true, 9 | "allowUnreachableCode": false, 10 | "allowUnusedLabels": false, 11 | "noImplicitOverride": true, 12 | "noImplicitReturns": true, 13 | "noImplicitThis": true, 14 | "exactOptionalPropertyTypes": true, 15 | "noFallthroughCasesInSwitch": true, 16 | "noPropertyAccessFromIndexSignature": true, 17 | // "noUncheckedIndexedAccess": true, 18 | "strictNullChecks": true, 19 | "strictFunctionTypes": true, 20 | "noImplicitAny": true 21 | // "rootDir": "src", 22 | // "resolveJsonModule": true 23 | }, 24 | "compileOnSave": true, 25 | "include": [ 26 | "src", 27 | "test" 28 | ], 29 | "exclude": [ 30 | "node_modules", 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /xcode/LDKFramework/DirectlyLinkedBindingsApp/Assets.xcassets/AccentColor.colorset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "colors" : [ 3 | { 4 | "idiom" : "universal" 5 | } 6 | ], 7 | "info" : { 8 | "author" : "xcode", 9 | "version" : 1 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /xcode/LDKFramework/DirectlyLinkedBindingsApp/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "scale" : "2x", 6 | "size" : "20x20" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "scale" : "3x", 11 | "size" : "20x20" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "scale" : "2x", 16 | "size" : "29x29" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "scale" : "3x", 21 | "size" : "29x29" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "scale" : "2x", 26 | "size" : "40x40" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "scale" : "3x", 31 | "size" : "40x40" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "scale" : "2x", 36 | "size" : "60x60" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "scale" : "3x", 41 | "size" : "60x60" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "scale" : "1x", 46 | "size" : "20x20" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "scale" : "2x", 51 | "size" : "20x20" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "scale" : "1x", 56 | "size" : "29x29" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "scale" : "2x", 61 | "size" : "29x29" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "scale" : "1x", 66 | "size" : "40x40" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "scale" : "2x", 71 | "size" : "40x40" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "scale" : "2x", 76 | "size" : "76x76" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "scale" : "2x", 81 | "size" : "83.5x83.5" 82 | }, 83 | { 84 | "idiom" : "ios-marketing", 85 | "scale" : "1x", 86 | "size" : "1024x1024" 87 | } 88 | ], 89 | "info" : { 90 | "author" : "xcode", 91 | "version" : 1 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /xcode/LDKFramework/DirectlyLinkedBindingsApp/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /xcode/LDKFramework/DirectlyLinkedBindingsApp/ContentView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ContentView.swift 3 | // DirectlyLinkedBindingsApp 4 | // 5 | // Created by Arik Sosman on 8/20/21. 6 | // 7 | 8 | import SwiftUI 9 | 10 | struct ContentView: View { 11 | 12 | @State private var isRunningTestFlow = false 13 | 14 | @State private var multiPeerSimulation: PolarIntegrationSample.MultiPeerSimulator? = nil 15 | 16 | var body: some View { 17 | 18 | Button( 19 | action: { 20 | self.isRunningTestFlow = true 21 | if #available(iOS 15.0, *) { 22 | let sample = PolarIntegrationSample() 23 | Task { 24 | try? await sample.testPolarFlow() 25 | self.isRunningTestFlow = false 26 | } 27 | } else { 28 | // Fallback on earlier versions 29 | } 30 | 31 | }, 32 | label: { 33 | Text("Test Polar Invoice Invoice Payment Flow") 34 | } 35 | ) 36 | .disabled(self.isRunningTestFlow) 37 | 38 | if let simulation = self.multiPeerSimulation { 39 | Button { 40 | // self.multiPeerSimulation = nil 41 | Task { 42 | await self.multiPeerSimulation?.interrupt() 43 | 44 | // freeing the simulation 45 | // try! await Task.sleep(nanoseconds: 5_000_000_000) 46 | // self.multiPeerSimulation = nil 47 | } 48 | } label: { 49 | Text("Stop multi-peer simulation") 50 | } 51 | } else { 52 | Button { 53 | self.multiPeerSimulation = PolarIntegrationSample.MultiPeerSimulator() 54 | Task { 55 | try? await self.multiPeerSimulation!.simulateMultiplePeers() 56 | } 57 | } label: { 58 | Text("Simulate multiple peers") 59 | } 60 | } 61 | 62 | } 63 | 64 | /*@StateObject private var experiment = PolarConnectionExperiment() 65 | var body: some View { 66 | if !self.experiment.isMonitoring { 67 | Button("Monitor Chain") { 68 | self.experiment.startMonitoring() 69 | }.padding() 70 | } else { 71 | VStack { 72 | Text("Monitoring…").padding() 73 | if !self.experiment.hasCaughtUpToChainTip { 74 | Text("Complete Sync").padding() 75 | } else if !self.experiment.hasCompletedChainSync { 76 | Button("Complete Sync") { 77 | self.experiment.completeChainSync() 78 | }.padding() 79 | } else { 80 | 81 | Text("Sync Complete").padding() 82 | 83 | if !self.experiment.isConnectedToAlice { 84 | Button("Connect to Alice") { 85 | self.experiment.connectToAlice() 86 | }.padding() 87 | } else { 88 | Text("Connected to Alice").padding() 89 | 90 | if !self.experiment.isChannelWithAliceOpen { 91 | Button("Open Channel w/ Alice") { 92 | self.experiment.openChannelWithAlice() 93 | }.padding() 94 | } else { 95 | Text("Channel w/ Alice Open") 96 | } 97 | } 98 | } 99 | } 100 | } 101 | }*/ 102 | } 103 | 104 | struct ContentView_Previews: PreviewProvider { 105 | static var previews: some View { 106 | ContentView() 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /xcode/LDKFramework/DirectlyLinkedBindingsApp/DirectlyLinkedBindingsAppApp.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DirectlyLinkedBindingsAppApp.swift 3 | // DirectlyLinkedBindingsApp 4 | // 5 | // Created by Arik Sosman on 7/11/22. 6 | // 7 | 8 | import SwiftUI 9 | 10 | @main 11 | struct DirectlyLinkedBindingsAppApp: App { 12 | 13 | init() { 14 | print("Directly linked bindings app is initialized") 15 | Bindings.setLogThreshold(severity: .DEBUG) 16 | 17 | func printCompiledVersion() { 18 | let compiledVersion = Bindings.getLDKSwiftBindingsSerializationHash() 19 | print("Compiled version: \(compiledVersion)\n\(#file)::\(#function):\(#line)") 20 | } 21 | printCompiledVersion() 22 | 23 | do { 24 | let thing = Bindings.Fallback.initWithSegWitProgram(version: 255, program: []) 25 | } 26 | 27 | Fallback.enableDeinitLogging = false 28 | do { 29 | let thing = Bindings.Fallback.initWithSegWitProgram(version: 255, program: []) 30 | let otherThing = Bindings.UserConfig.initWithDefault() 31 | } 32 | 33 | // let tx = BuiltCommitmentTransaction(transactionArg: [], txidArg: [UInt8](repeating: 0, count: 32)) 34 | 35 | let nativeNetwork = LDKNetwork_Regtest 36 | let swiftNetwork = Bindings.Network.Bitcoin 37 | 38 | let restoredNetwork = swiftNetwork.getCValue() 39 | let reconstructedNetwork = Bindings.Network(value: nativeNetwork) 40 | 41 | print("here we are") 42 | 43 | } 44 | 45 | var body: some Scene { 46 | WindowGroup { 47 | ContentView() 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /xcode/LDKFramework/DirectlyLinkedBindingsApp/Preview Content/Preview Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "author" : "xcode", 4 | "version" : 1 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /xcode/LDKFramework/DirectlyLinkedBindingsApp/app-batteries/CombineUtils.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CombineUtils.swift 3 | // DirectBindingsApp 4 | // 5 | // From https://www.swiftbysundell.com/articles/async-and-concurrent-forEach-and-map/ 6 | // 7 | // Created by Jurvis Tan on 4/18/22. 8 | // 9 | 10 | import Combine 11 | import Foundation 12 | 13 | //extension Publisher { 14 | // public func asyncMap( 15 | // _ transform: @escaping (Output) async throws -> T 16 | // ) -> Publishers.FlatMap, 17 | // Publishers.SetFailureType> { 18 | // flatMap { value in 19 | // Future { promise in 20 | // Task { 21 | // do { 22 | // let output = try await transform(value) 23 | // promise(.success(output)) 24 | // } catch { 25 | // promise(.failure(error)) 26 | // } 27 | // } 28 | // } 29 | // } 30 | // } 31 | //} 32 | -------------------------------------------------------------------------------- /xcode/LDKFramework/DirectlyLinkedBindingsApp/app-batteries/RegtestBlockchainManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BlockchainObserver.swift 3 | // DirectBindingsApp 4 | // 5 | // Created by Arik Sosman on 4/10/22. 6 | // 7 | 8 | import Foundation 9 | 10 | /// A class that's supposed to help monitoring a regtest blockchain data using the bitcoin RPC interface. 11 | /// 12 | @available(iOS 15.0, *) 13 | class RegtestBlockchainManager: BlockchainObserver { 14 | 15 | /** 16 | Mine regtest blocks 17 | - Parameters: 18 | - number: The number of blocks to mine 19 | - coinbaseDestinationAddress: The output address to be used in the coinbase transaction(s) 20 | - Returns: Array of the mined blocks' hashes 21 | - Throws: If the RPC connection fails or the call results in an error 22 | */ 23 | public func mineBlocks(number: Int64, coinbaseDestinationAddress: String) async throws -> [String] { 24 | let response = try await self.callRpcMethod( 25 | method: "generatetoaddress", 26 | params: [ 27 | "nblocks": number, 28 | "address": coinbaseDestinationAddress, 29 | ]) 30 | let result = response["result"] as! [String] 31 | return result 32 | } 33 | 34 | /** 35 | Invalidate or un-mine a block 36 | - Parameter hash: The block hash hex to invalidate 37 | - Returns: 38 | - Throws: 39 | */ 40 | public func unmineBlock(hash: String) async throws { 41 | let response = try await self.callRpcMethod(method: "invalidateblock", params: [hash]) 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /xcode/LDKFramework/DirectlyLinkedBindingsApp/app-batteries/RegtestBroadcasterInterface.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MyBroadcasterInterface.swift 3 | // LDKSwiftARC 4 | // 5 | // Created by Arik Sosman on 5/17/21. 6 | // 7 | 8 | import Foundation 9 | 10 | class RegtestBroadcasterInterface: BroadcasterInterface { 11 | 12 | override func broadcastTransactions(txs: [[UInt8]]) { 13 | 14 | 15 | let url = URL(string: "http://localhost:3000/api/lab/broadcast")! 16 | 17 | var components = URLComponents(url: url, resolvingAgainstBaseURL: false)! 18 | 19 | for tx in txs { 20 | print("TX TO BROADCAST: \(tx)") 21 | components.queryItems = [ 22 | URLQueryItem(name: "tx", value: "\(tx)") 23 | ] 24 | 25 | let query = components.url!.query 26 | 27 | var request = URLRequest(url: url) 28 | request.httpMethod = "POST" 29 | request.httpBody = Data(query!.utf8) 30 | 31 | let session = URLSession(configuration: .default) 32 | let task = session.dataTask( 33 | with: request, 34 | completionHandler: { data, response, error in 35 | print("transaction broadcast result") 36 | }) 37 | task.resume() 38 | } 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /xcode/LDKFramework/DirectlyLinkedBindingsApp/app-batteries/RegtestChannelManagerPersister.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MyChannelManagerPersister.swift 3 | // LDKSwiftARC 4 | // 5 | // Created by Arik Sosman on 5/27/21. 6 | // 7 | 8 | import Foundation 9 | 10 | class RegtestChannelManagerPersister: Persister, ExtendedChannelManagerPersister { 11 | 12 | 13 | private let channelManager: ChannelManager? 14 | private let keysManager: KeysManager? = nil 15 | 16 | init(channelManager: ChannelManager?) { 17 | self.channelManager = channelManager 18 | super.init() 19 | } 20 | 21 | func handleEvent(event: Event) -> Result_NoneReplayEventZ { 22 | privateHandleEvent(event: event) 23 | } 24 | 25 | private func privateHandleEvent(event: Event) -> Result_NoneReplayEventZ { 26 | if let spendableOutputEvent = event.getValueAsSpendableOutputs() { 27 | 28 | let outputs = spendableOutputEvent.getOutputs() 29 | 30 | let fastFeerate = 7500 31 | let destinationScriptHardcoded: [UInt8] = [ 32 | 118, 169, 20, 25, 18, 157, 83, 230, 49, 155, 175, 25, 219, 160, 89, 190, 173, 22, 109, 249, 10, 184, 33 | 245, 136, 172, 34 | ] 35 | 36 | guard 37 | let result = self.keysManager?.asOutputSpender() 38 | .spendSpendableOutputs( 39 | descriptors: outputs, outputs: [], changeDestinationScript: destinationScriptHardcoded, 40 | feerateSatPer1000Weight: UInt32(fastFeerate), locktime: nil) 41 | else { 42 | return .initWithErr(e: ReplayEvent()) 43 | } 44 | 45 | if let transaction = result.getValue() { 46 | // sendEvent(eventName: MARKER_BROADCAST, eventBody: ["txhex": bytesToHex(bytes: transaction)]) 47 | } 48 | 49 | return .initWithOk() 50 | 51 | } else if let paymentSentEvent = event.getValueAsPaymentSent() { 52 | // print what needs printing 53 | } else if let pendingHTLCsForwardableEvent = event.getValueAsPendingHtlcsForwardable() { 54 | channelManager?.processPendingHtlcForwards() 55 | 56 | 57 | } else if let fundingReadyEvent = event.getValueAsFundingGenerationReady() { 58 | let outputScript = fundingReadyEvent.getOutputScript() 59 | let amount = fundingReadyEvent.getChannelValueSatoshis() 60 | 61 | print("ready stuff: \(amount) to \(outputScript)") 62 | print("funding event ready!") 63 | 64 | let url = URL(string: "http://localhost:3000/api/lab/funding-generation-ready")! 65 | var components = URLComponents(url: url, resolvingAgainstBaseURL: false)! 66 | 67 | let tcid = fundingReadyEvent.getTemporaryChannelId() 68 | 69 | components.queryItems = [ 70 | URLQueryItem(name: "script", value: "\(outputScript)"), 71 | URLQueryItem(name: "amount", value: "\(amount)"), 72 | URLQueryItem(name: "tcid", value: "\(fundingReadyEvent.getTemporaryChannelId())"), 73 | URLQueryItem(name: "ucid", value: "\(fundingReadyEvent.getUserChannelId())"), 74 | ] 75 | 76 | let query = components.url!.query 77 | 78 | var request = URLRequest(url: url) 79 | request.httpMethod = "POST" 80 | request.httpBody = Data(query!.utf8) 81 | 82 | let session = URLSession(configuration: .default) 83 | let task = session.dataTask( 84 | with: request, 85 | completionHandler: { data, response, error in 86 | print("received local funding generation ready response") 87 | }) 88 | task.resume() 89 | } 90 | 91 | return .initWithOk() 92 | } 93 | 94 | override func persistManager(channelManager: Bindings.ChannelManager) -> Bindings.Result_NoneIOErrorZ { 95 | .initWithOk() 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /xcode/LDKFramework/DirectlyLinkedBindingsAppTests/DirectlyLinkedBindingsAppTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DirectlyLinkedBindingsAppTests.swift 3 | // DirectlyLinkedBindingsAppTests 4 | // 5 | // Created by Arik Sosman on 7/11/22. 6 | // 7 | 8 | import XCTest 9 | 10 | @testable import DirectlyLinkedBindingsApp 11 | 12 | class DirectlyLinkedBindingsAppTests: XCTestCase { 13 | 14 | override func setUpWithError() throws { 15 | // Put setup code here. This method is called before the invocation of each test method in the class. 16 | } 17 | 18 | override func tearDownWithError() throws { 19 | // Put teardown code here. This method is called after the invocation of each test method in the class. 20 | } 21 | 22 | func testExample() throws { 23 | // This is an example of a functional test case. 24 | // Use XCTAssert and related functions to verify your tests produce the correct results. 25 | // Any test you write for XCTest can be annotated as throws and async. 26 | // Mark your test throws to produce an unexpected failure when your test encounters an uncaught error. 27 | // Mark your test async to allow awaiting for asynchronous code to complete. Check the results with assertions afterwards. 28 | } 29 | 30 | func testPerformanceExample() throws { 31 | // This is an example of a performance test case. 32 | self.measure { 33 | // Put the code you want to measure the time of here. 34 | } 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /xcode/LDKFramework/DirectlyLinkedBindingsAppTests/polar/CombineUtils.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CombineUtils.swift 3 | // DirectBindingsApp 4 | // 5 | // From https://www.swiftbysundell.com/articles/async-and-concurrent-forEach-and-map/ 6 | // 7 | // Created by Jurvis Tan on 4/18/22. 8 | // 9 | 10 | import Combine 11 | import Foundation 12 | 13 | extension Publisher { 14 | func asyncMap( 15 | _ transform: @escaping (Output) async throws -> T 16 | ) 17 | -> Publishers.FlatMap< 18 | Future, 19 | Publishers.SetFailureType 20 | > 21 | { 22 | flatMap { value in 23 | Future { promise in 24 | Task { 25 | do { 26 | let output = try await transform(value) 27 | promise(.success(output)) 28 | } catch { 29 | promise(.failure(error)) 30 | } 31 | } 32 | } 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /xcode/LDKFramework/DirectlyLinkedBindingsAppTests/polar/RegtestBlockchainManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BlockchainObserver.swift 3 | // DirectBindingsApp 4 | // 5 | // Created by Arik Sosman on 4/10/22. 6 | // 7 | 8 | import Foundation 9 | 10 | /// A class that's supposed to help monitoring a regtest blockchain data using the bitcoin RPC interface. 11 | /// 12 | @available(iOS 15.0, *) 13 | class RegtestBlockchainManager: BlockchainObserver { 14 | 15 | /** 16 | Mine regtest blocks 17 | - Parameters: 18 | - number: The number of blocks to mine 19 | - coinbaseDestinationAddress: The output address to be used in the coinbase transaction(s) 20 | - Returns: Array of the mined blocks' hashes 21 | - Throws: If the RPC connection fails or the call results in an error 22 | */ 23 | public func mineBlocks(number: Int64, coinbaseDestinationAddress: String) async throws -> [String] { 24 | let response = try await self.callRpcMethod( 25 | method: "generatetoaddress", 26 | params: [ 27 | "nblocks": number, 28 | "address": coinbaseDestinationAddress, 29 | ]) 30 | let result = response["result"] as! [String] 31 | return result 32 | } 33 | 34 | /** 35 | Invalidate or un-mine a block 36 | - Parameter hash: The block hash hex to invalidate 37 | - Returns: 38 | - Throws: 39 | */ 40 | public func unmineBlock(hash: String) async throws { 41 | let response = try await self.callRpcMethod(method: "invalidateblock", params: [hash]) 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /xcode/LDKFramework/Framework/Framework.h: -------------------------------------------------------------------------------- 1 | // 2 | // LDKFramework.h 3 | // LDKFramework 4 | // 5 | // Created by Arik Sosman on 5/4/21. 6 | // EDITED BY ARIK AT 12:39AM 7 | // 8 | 9 | #import 10 | 11 | #import "lightning.h" 12 | #import "ldk_net.h" 13 | 14 | //! Project version number for LDKFramework. 15 | FOUNDATION_EXPORT double LDKFrameworkVersionNumber; 16 | 17 | //! Project version string for LDKFramework. 18 | FOUNDATION_EXPORT const unsigned char LDKFrameworkVersionString[]; 19 | 20 | // In this header, you should import all the public headers of your framework using statements like #import 21 | 22 | 23 | -------------------------------------------------------------------------------- /xcode/LDKFramework/Framework/FrameworkTests-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | -------------------------------------------------------------------------------- /xcode/LDKFramework/Framework/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | 22 | 23 | -------------------------------------------------------------------------------- /xcode/LDKFramework/Framework/LDKExampleClass.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LDKExampleClass.swift 3 | // LDKFramework 4 | // 5 | // Created by Arik Sosman on 5/5/21. 6 | // 7 | 8 | import Foundation 9 | 10 | public class LDKExampleClass { 11 | 12 | public class func printSomething() -> Void { 13 | print("hello world!") 14 | } 15 | 16 | public func printInstance() -> Void { 17 | print("instance print") 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /xcode/LDKFramework/FrameworkTests/FrameworkTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LDKFrameworkTests.swift 3 | // LDKFrameworkTests 4 | // 5 | // Created by Arik Sosman on 5/4/21. 6 | // 7 | 8 | import XCTest 9 | @testable import LDKFramework 10 | 11 | class LDKFrameworkTests: XCTestCase { 12 | 13 | override func setUpWithError() throws { 14 | // Put setup code here. This method is called before the invocation of each test method in the class. 15 | } 16 | 17 | override func tearDownWithError() throws { 18 | // Put teardown code here. This method is called after the invocation of each test method in the class. 19 | } 20 | 21 | func testExample() throws { 22 | // This is an example of a functional test case. 23 | // Use XCTAssert and related functions to verify your tests produce the correct results. 24 | } 25 | 26 | func testPerformanceExample() throws { 27 | // This is an example of a performance test case. 28 | self.measure { 29 | // Put the code you want to measure the time of here. 30 | } 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /xcode/LDKFramework/FrameworkTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE) 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /xcode/LDKFramework/LDK.xcodeproj/xcshareddata/xcschemes/DirectlyLinkedBindingsApp.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 34 | 40 | 41 | 42 | 43 | 44 | 56 | 58 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /xcode/LDKFramework/LightningDevKit.modulemap: -------------------------------------------------------------------------------- 1 | framework module LightningDevKit { 2 | umbrella header "Framework.h" 3 | 4 | module * { export * } 5 | export * 6 | 7 | explicit module LDK { 8 | header "ldk_rust_types.h" 9 | header "lightning.h" 10 | header "ldk_ver.h" 11 | header "ldk_net.h" 12 | link "libldk.a" 13 | export * 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /xcode/MISSING_STEPS.md: -------------------------------------------------------------------------------- 1 | ```shell 2 | # genbindings.sh, stable 3 | rustup target add aarch64-apple-darwin 4 | 5 | # compile_dependency_binaries.sh, stable 6 | rustup target add aarch64-apple-ios 7 | rustup target add x86_64-apple-ios 8 | 9 | # compile_dependency_binaries.sh, nightly 10 | rustup component add rust-src --toolchain nightly-x86_64-apple-darwin 11 | rustup component add rust-src --toolchain nightly-2022-05-13-x86_64-apple-darwin 12 | 13 | 14 | ``` 15 | -------------------------------------------------------------------------------- /xcode/build_framework.sh: -------------------------------------------------------------------------------- 1 | set -e # bail upon first error 2 | 3 | BIN_OUTPUT_DIRECTORY=`pwd` 4 | BUILD_DIR=${BIN_OUTPUT_DIRECTORY}/build 5 | 6 | mkdir -p $BUILD_DIR 7 | 8 | pushd $BUILD_DIR 9 | rm -rf LDKFramework* 10 | popd 11 | 12 | # As of clang 13, the `13.0` in the target `x86_64-apple-ios13.0-macabi` is dropped. 13 | # However, in cc-rs, it is still hard-coded that way (https://github.com/rust-lang/cc-rs/pull/678). 14 | # The only way for this script to run completely (i.e. include Mac Catalyst) is to switch to a version of Xcode 15 | # that uses clang 12 (13.2.1 being the latest). Should be resolved after https://github.com/rust-lang/cc-rs/pull/678 16 | sudo xcode-select -s /Applications/Xcode\ 13.2.1.app/Contents/Developer/ 17 | 18 | rm -f LDK/libldk.a 19 | # Build for iOS 20 | xcodebuild archive \ 21 | -scheme LDKFramework \ 22 | -project 'LDK/LDKFramework.xcodeproj' \ 23 | -destination 'generic/platform=iOS' \ 24 | -archivePath ${BUILD_DIR}/LDKFramework-iOS \ 25 | ENABLE_BITCODE=NO \ 26 | CLANG_ADDRESS_SANITIZER=NO CLANG_ADDRESS_SANITIZER_ALLOW_ERROR_RECOVERY=NO CLANG_ADDRESS_SANITIZER_USE_AFTER_SCOPE=NO \ 27 | SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES 28 | 29 | rm -f LDK/libldk.a 30 | # Build for iOS Simulator 31 | xcodebuild archive \ 32 | -scheme LDKFramework \ 33 | -project 'LDK/LDKFramework.xcodeproj' \ 34 | -destination 'generic/platform=iOS Simulator' \ 35 | -archivePath ${BUILD_DIR}/LDKFramework-Sim \ 36 | ENABLE_BITCODE=NO \ 37 | CLANG_ADDRESS_SANITIZER=NO CLANG_ADDRESS_SANITIZER_ALLOW_ERROR_RECOVERY=NO CLANG_ADDRESS_SANITIZER_USE_AFTER_SCOPE=NO \ 38 | SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES 39 | 40 | rm -f LDK/libldk.a 41 | # Build for OS X Darwin 42 | xcodebuild archive \ 43 | -scheme LDKFramework_Mac \ 44 | -project 'LDK/LDKFramework.xcodeproj' \ 45 | -destination 'generic/platform=OS X' \ 46 | -archivePath ${BUILD_DIR}/LDKFramework-Darwin \ 47 | ENABLE_BITCODE=NO \ 48 | CLANG_ADDRESS_SANITIZER=NO CLANG_ADDRESS_SANITIZER_ALLOW_ERROR_RECOVERY=NO CLANG_ADDRESS_SANITIZER_USE_AFTER_SCOPE=NO \ 49 | SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES 50 | 51 | rm -f LDK/libldk.a 52 | # Build for macOS Catalyst 53 | xcodebuild archive \ 54 | -scheme LDKFramework \ 55 | -project 'LDK/LDKFramework.xcodeproj' \ 56 | -destination 'generic/platform=macOS' \ 57 | -archivePath ${BUILD_DIR}/LDKFramework-Catalyst \ 58 | ENABLE_BITCODE=NO \ 59 | CLANG_ADDRESS_SANITIZER=NO CLANG_ADDRESS_SANITIZER_ALLOW_ERROR_RECOVERY=NO CLANG_ADDRESS_SANITIZER_USE_AFTER_SCOPE=NO \ 60 | SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES 61 | 62 | xcodebuild -create-xcframework \ 63 | -framework ${BUILD_DIR}/LDKFramework-iOS.xcarchive/Products/Library/Frameworks/LDKFramework.framework \ 64 | -framework ${BUILD_DIR}/LDKFramework-Sim.xcarchive/Products/Library/Frameworks/LDKFramework.framework \ 65 | -framework ${BUILD_DIR}/LDKFramework-Darwin.xcarchive/Products/Library/Frameworks/LDKFramework_Mac.framework \ 66 | -framework ${BUILD_DIR}/LDKFramework-Catalyst.xcarchive/Products/Library/Frameworks/LDKFramework.framework \ 67 | -output ${BUILD_DIR}/LDKFramework.xcframework 68 | 69 | # Switch back to default version of Xcode (presumably latest) 70 | sudo xcode-select -s /Applications/Xcode.app/Contents/Developer/ 71 | --------------------------------------------------------------------------------