@@ -2475,11 +2475,15 @@ public protocol OnchainPaymentProtocol : AnyObject {
24752475
24762476 func bumpFeeByRbf( txid: Txid , feeRate: FeeRate ) throws -> Txid
24772477
2478+ func listSpendableOutputs( ) throws -> [ SpendableUtxo ]
2479+
24782480 func newAddress( ) throws -> Address
24792481
2482+ func selectUtxosWithAlgorithm( targetAmountSats: UInt64 , feeRate: FeeRate ? , algorithm: CoinSelectionAlgorithm , utxos: [ SpendableUtxo ] ? ) throws -> [ SpendableUtxo ]
2483+
24802484 func sendAllToAddress( address: Address , retainReserve: Bool , feeRate: FeeRate ? ) throws -> Txid
24812485
2482- func sendToAddress( address: Address , amountSats: UInt64 , feeRate: FeeRate ? ) throws -> Txid
2486+ func sendToAddress( address: Address , amountSats: UInt64 , feeRate: FeeRate ? , utxosToSpend : [ SpendableUtxo ] ? ) throws -> Txid
24832487
24842488}
24852489
@@ -2543,13 +2547,31 @@ open func bumpFeeByRbf(txid: Txid, feeRate: FeeRate)throws -> Txid {
25432547} )
25442548}
25452549
2550+ open func listSpendableOutputs( ) throws -> [ SpendableUtxo ] {
2551+ return try FfiConverterSequenceTypeSpendableUtxo . lift ( try rustCallWithError ( FfiConverterTypeNodeError . lift) {
2552+ uniffi_ldk_node_fn_method_onchainpayment_list_spendable_outputs ( self . uniffiClonePointer ( ) , $0
2553+ )
2554+ } )
2555+ }
2556+
25462557open func newAddress( ) throws -> Address {
25472558 return try FfiConverterTypeAddress . lift ( try rustCallWithError ( FfiConverterTypeNodeError . lift) {
25482559 uniffi_ldk_node_fn_method_onchainpayment_new_address ( self . uniffiClonePointer ( ) , $0
25492560 )
25502561} )
25512562}
25522563
2564+ open func selectUtxosWithAlgorithm( targetAmountSats: UInt64 , feeRate: FeeRate ? , algorithm: CoinSelectionAlgorithm , utxos: [ SpendableUtxo ] ? ) throws -> [ SpendableUtxo ] {
2565+ return try FfiConverterSequenceTypeSpendableUtxo . lift ( try rustCallWithError ( FfiConverterTypeNodeError . lift) {
2566+ uniffi_ldk_node_fn_method_onchainpayment_select_utxos_with_algorithm ( self . uniffiClonePointer ( ) ,
2567+ FfiConverterUInt64 . lower ( targetAmountSats) ,
2568+ FfiConverterOptionTypeFeeRate . lower ( feeRate) ,
2569+ FfiConverterTypeCoinSelectionAlgorithm . lower ( algorithm) ,
2570+ FfiConverterOptionSequenceTypeSpendableUtxo . lower ( utxos) , $0
2571+ )
2572+ } )
2573+ }
2574+
25532575open func sendAllToAddress( address: Address , retainReserve: Bool , feeRate: FeeRate ? ) throws -> Txid {
25542576 return try FfiConverterTypeTxid . lift ( try rustCallWithError ( FfiConverterTypeNodeError . lift) {
25552577 uniffi_ldk_node_fn_method_onchainpayment_send_all_to_address ( self . uniffiClonePointer ( ) ,
@@ -2560,12 +2582,13 @@ open func sendAllToAddress(address: Address, retainReserve: Bool, feeRate: FeeRa
25602582} )
25612583}
25622584
2563- open func sendToAddress( address: Address , amountSats: UInt64 , feeRate: FeeRate ? ) throws -> Txid {
2585+ open func sendToAddress( address: Address , amountSats: UInt64 , feeRate: FeeRate ? , utxosToSpend : [ SpendableUtxo ] ? ) throws -> Txid {
25642586 return try FfiConverterTypeTxid . lift ( try rustCallWithError ( FfiConverterTypeNodeError . lift) {
25652587 uniffi_ldk_node_fn_method_onchainpayment_send_to_address ( self . uniffiClonePointer ( ) ,
25662588 FfiConverterTypeAddress . lower ( address) ,
25672589 FfiConverterUInt64 . lower ( amountSats) ,
2568- FfiConverterOptionTypeFeeRate . lower ( feeRate) , $0
2590+ FfiConverterOptionTypeFeeRate . lower ( feeRate) ,
2591+ FfiConverterOptionSequenceTypeSpendableUtxo . lower ( utxosToSpend) , $0
25692592 )
25702593} )
25712594}
@@ -5340,6 +5363,63 @@ public func FfiConverterTypeSendingParameters_lower(_ value: SendingParameters)
53405363 return FfiConverterTypeSendingParameters . lower ( value)
53415364}
53425365
5366+
5367+ public struct SpendableUtxo {
5368+ public var outpoint : OutPoint
5369+ public var valueSats : UInt64
5370+
5371+ // Default memberwise initializers are never public by default, so we
5372+ // declare one manually.
5373+ public init ( outpoint: OutPoint , valueSats: UInt64 ) {
5374+ self . outpoint = outpoint
5375+ self . valueSats = valueSats
5376+ }
5377+ }
5378+
5379+
5380+
5381+ extension SpendableUtxo : Equatable , Hashable {
5382+ public static func == ( lhs: SpendableUtxo , rhs: SpendableUtxo ) -> Bool {
5383+ if lhs. outpoint != rhs. outpoint {
5384+ return false
5385+ }
5386+ if lhs. valueSats != rhs. valueSats {
5387+ return false
5388+ }
5389+ return true
5390+ }
5391+
5392+ public func hash( into hasher: inout Hasher ) {
5393+ hasher. combine ( outpoint)
5394+ hasher. combine ( valueSats)
5395+ }
5396+ }
5397+
5398+
5399+ public struct FfiConverterTypeSpendableUtxo : FfiConverterRustBuffer {
5400+ public static func read( from buf: inout ( data: Data , offset: Data . Index ) ) throws -> SpendableUtxo {
5401+ return
5402+ try SpendableUtxo (
5403+ outpoint: FfiConverterTypeOutPoint . read ( from: & buf) ,
5404+ valueSats: FfiConverterUInt64 . read ( from: & buf)
5405+ )
5406+ }
5407+
5408+ public static func write( _ value: SpendableUtxo , into buf: inout [ UInt8 ] ) {
5409+ FfiConverterTypeOutPoint . write ( value. outpoint, into: & buf)
5410+ FfiConverterUInt64 . write ( value. valueSats, into: & buf)
5411+ }
5412+ }
5413+
5414+
5415+ public func FfiConverterTypeSpendableUtxo_lift( _ buf: RustBuffer ) throws -> SpendableUtxo {
5416+ return try FfiConverterTypeSpendableUtxo . lift ( buf)
5417+ }
5418+
5419+ public func FfiConverterTypeSpendableUtxo_lower( _ value: SpendableUtxo ) -> RustBuffer {
5420+ return FfiConverterTypeSpendableUtxo . lower ( value)
5421+ }
5422+
53435423// Note that we don't yet support `indirect` for enums.
53445424// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
53455425
@@ -5774,6 +5854,75 @@ extension ClosureReason: Equatable, Hashable {}
57745854
57755855
57765856
5857+ // Note that we don't yet support `indirect` for enums.
5858+ // See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
5859+
5860+ public enum CoinSelectionAlgorithm {
5861+
5862+ case branchAndBound
5863+ case largestFirst
5864+ case oldestFirst
5865+ case singleRandomDraw
5866+ }
5867+
5868+
5869+ public struct FfiConverterTypeCoinSelectionAlgorithm : FfiConverterRustBuffer {
5870+ typealias SwiftType = CoinSelectionAlgorithm
5871+
5872+ public static func read( from buf: inout ( data: Data , offset: Data . Index ) ) throws -> CoinSelectionAlgorithm {
5873+ let variant : Int32 = try readInt ( & buf)
5874+ switch variant {
5875+
5876+ case 1 : return . branchAndBound
5877+
5878+ case 2 : return . largestFirst
5879+
5880+ case 3 : return . oldestFirst
5881+
5882+ case 4 : return . singleRandomDraw
5883+
5884+ default : throw UniffiInternalError . unexpectedEnumCase
5885+ }
5886+ }
5887+
5888+ public static func write( _ value: CoinSelectionAlgorithm , into buf: inout [ UInt8 ] ) {
5889+ switch value {
5890+
5891+
5892+ case . branchAndBound:
5893+ writeInt ( & buf, Int32 ( 1 ) )
5894+
5895+
5896+ case . largestFirst:
5897+ writeInt ( & buf, Int32 ( 2 ) )
5898+
5899+
5900+ case . oldestFirst:
5901+ writeInt ( & buf, Int32 ( 3 ) )
5902+
5903+
5904+ case . singleRandomDraw:
5905+ writeInt ( & buf, Int32 ( 4 ) )
5906+
5907+ }
5908+ }
5909+ }
5910+
5911+
5912+ public func FfiConverterTypeCoinSelectionAlgorithm_lift( _ buf: RustBuffer ) throws -> CoinSelectionAlgorithm {
5913+ return try FfiConverterTypeCoinSelectionAlgorithm . lift ( buf)
5914+ }
5915+
5916+ public func FfiConverterTypeCoinSelectionAlgorithm_lower( _ value: CoinSelectionAlgorithm ) -> RustBuffer {
5917+ return FfiConverterTypeCoinSelectionAlgorithm . lower ( value)
5918+ }
5919+
5920+
5921+
5922+ extension CoinSelectionAlgorithm : Equatable , Hashable { }
5923+
5924+
5925+
57775926// Note that we don't yet support `indirect` for enums.
57785927// See https://github.com/mozilla/uniffi-rs/issues/396 for further discussion.
57795928
@@ -6577,6 +6726,8 @@ public enum NodeError {
65776726
65786727 case NoSpendableOutputs( message: String )
65796728
6729+ case CoinSelectionFailed( message: String )
6730+
65806731}
65816732
65826733
@@ -6814,6 +6965,10 @@ public struct FfiConverterTypeNodeError: FfiConverterRustBuffer {
68146965 message: try FfiConverterString . read ( from: & buf)
68156966 )
68166967
6968+ case 57 : return . CoinSelectionFailed(
6969+ message: try FfiConverterString . read ( from: & buf)
6970+ )
6971+
68176972
68186973 default : throw UniffiInternalError . unexpectedEnumCase
68196974 }
@@ -6937,6 +7092,8 @@ public struct FfiConverterTypeNodeError: FfiConverterRustBuffer {
69377092 writeInt ( & buf, Int32 ( 55 ) )
69387093 case . NoSpendableOutputs( _ /* message is ignored*/) :
69397094 writeInt ( & buf, Int32 ( 56 ) )
7095+ case . CoinSelectionFailed( _ /* message is ignored*/) :
7096+ writeInt ( & buf, Int32 ( 57 ) )
69407097
69417098
69427099 }
@@ -8145,6 +8302,27 @@ fileprivate struct FfiConverterOptionTypePaymentFailureReason: FfiConverterRustB
81458302 }
81468303}
81478304
8305+ fileprivate struct FfiConverterOptionSequenceTypeSpendableUtxo : FfiConverterRustBuffer {
8306+ typealias SwiftType = [ SpendableUtxo ] ?
8307+
8308+ public static func write( _ value: SwiftType , into buf: inout [ UInt8 ] ) {
8309+ guard let value = value else {
8310+ writeInt ( & buf, Int8 ( 0 ) )
8311+ return
8312+ }
8313+ writeInt ( & buf, Int8 ( 1 ) )
8314+ FfiConverterSequenceTypeSpendableUtxo . write ( value, into: & buf)
8315+ }
8316+
8317+ public static func read( from buf: inout ( data: Data , offset: Data . Index ) ) throws -> SwiftType {
8318+ switch try readInt ( & buf) as Int8 {
8319+ case 0 : return nil
8320+ case 1 : return try FfiConverterSequenceTypeSpendableUtxo . read ( from: & buf)
8321+ default : throw UniffiInternalError . unexpectedOptionalTag
8322+ }
8323+ }
8324+ }
8325+
81488326fileprivate struct FfiConverterOptionSequenceTypeSocketAddress : FfiConverterRustBuffer {
81498327 typealias SwiftType = [ SocketAddress ] ?
81508328
@@ -8530,6 +8708,28 @@ fileprivate struct FfiConverterSequenceTypeRouteHintHop: FfiConverterRustBuffer
85308708 }
85318709}
85328710
8711+ fileprivate struct FfiConverterSequenceTypeSpendableUtxo : FfiConverterRustBuffer {
8712+ typealias SwiftType = [ SpendableUtxo ]
8713+
8714+ public static func write( _ value: [ SpendableUtxo ] , into buf: inout [ UInt8 ] ) {
8715+ let len = Int32 ( value. count)
8716+ writeInt ( & buf, len)
8717+ for item in value {
8718+ FfiConverterTypeSpendableUtxo . write ( item, into: & buf)
8719+ }
8720+ }
8721+
8722+ public static func read( from buf: inout ( data: Data , offset: Data . Index ) ) throws -> [ SpendableUtxo ] {
8723+ let len : Int32 = try readInt ( & buf)
8724+ var seq = [ SpendableUtxo] ( )
8725+ seq. reserveCapacity ( Int ( len) )
8726+ for _ in 0 ..< len {
8727+ seq. append ( try FfiConverterTypeSpendableUtxo . read ( from: & buf) )
8728+ }
8729+ return seq
8730+ }
8731+ }
8732+
85338733fileprivate struct FfiConverterSequenceTypeLightningBalance : FfiConverterRustBuffer {
85348734 typealias SwiftType = [ LightningBalance ]
85358735
@@ -9815,13 +10015,19 @@ private var initializationResult: InitializationResult {
981510015 if ( uniffi_ldk_node_checksum_method_onchainpayment_bump_fee_by_rbf ( ) != 53877 ) {
981610016 return InitializationResult . apiChecksumMismatch
981710017 }
10018+ if ( uniffi_ldk_node_checksum_method_onchainpayment_list_spendable_outputs ( ) != 19144 ) {
10019+ return InitializationResult . apiChecksumMismatch
10020+ }
981810021 if ( uniffi_ldk_node_checksum_method_onchainpayment_new_address ( ) != 37251 ) {
981910022 return InitializationResult . apiChecksumMismatch
982010023 }
10024+ if ( uniffi_ldk_node_checksum_method_onchainpayment_select_utxos_with_algorithm ( ) != 14084 ) {
10025+ return InitializationResult . apiChecksumMismatch
10026+ }
982110027 if ( uniffi_ldk_node_checksum_method_onchainpayment_send_all_to_address ( ) != 37748 ) {
982210028 return InitializationResult . apiChecksumMismatch
982310029 }
9824- if ( uniffi_ldk_node_checksum_method_onchainpayment_send_to_address ( ) != 55646 ) {
10030+ if ( uniffi_ldk_node_checksum_method_onchainpayment_send_to_address ( ) != 28826 ) {
982510031 return InitializationResult . apiChecksumMismatch
982610032 }
982710033 if ( uniffi_ldk_node_checksum_method_spontaneouspayment_send ( ) != 48210 ) {
0 commit comments