@@ -166,42 +166,43 @@ public extension BitcoinCore {
166166 }
167167 }
168168
169- func send( to address: String , value: Int , feeRate: Int , sortType: TransactionDataSortType , unspentOutputs: [ UnspentOutputInfo ] ? , pluginData: [ UInt8 : IPluginData ] = [ : ] ) throws -> FullTransaction {
169+ func send( to address: String , memo : String ? , value: Int , feeRate: Int , sortType: TransactionDataSortType , unspentOutputs: [ UnspentOutputInfo ] ? , pluginData: [ UInt8 : IPluginData ] = [ : ] ) throws -> FullTransaction {
170170 guard let transactionCreator else {
171171 throw CoreError . readOnlyCore
172172 }
173+
173174 let outputs = unspentOutputs. map { $0. outputs ( from: unspentOutputSelector. all) }
174- return try transactionCreator. create ( to: address, value: value, feeRate: feeRate, senderPay: true , sortType: sortType, unspentOutputs: outputs, pluginData: pluginData)
175+ return try transactionCreator. create ( to: address, memo : memo , value: value, feeRate: feeRate, senderPay: true , sortType: sortType, unspentOutputs: outputs, pluginData: pluginData)
175176 }
176177
177- func send( to address: String , value: Int , feeRate: Int , sortType: TransactionDataSortType , pluginData: [ UInt8 : IPluginData ] ) throws -> FullTransaction {
178- try send ( to: address, value: value, feeRate: feeRate, sortType: sortType, unspentOutputs: nil , pluginData: pluginData)
178+ func send( to address: String , memo : String ? , value: Int , feeRate: Int , sortType: TransactionDataSortType , pluginData: [ UInt8 : IPluginData ] ) throws -> FullTransaction {
179+ try send ( to: address, memo : memo , value: value, feeRate: feeRate, sortType: sortType, unspentOutputs: nil , pluginData: pluginData)
179180 }
180181
181- func send( to hash: Data , scriptType: ScriptType , value: Int , feeRate: Int , sortType: TransactionDataSortType , unspentOutputs: [ UnspentOutputInfo ] ? ) throws -> FullTransaction {
182+ func send( to hash: Data , memo : String ? , scriptType: ScriptType , value: Int , feeRate: Int , sortType: TransactionDataSortType , unspentOutputs: [ UnspentOutputInfo ] ? ) throws -> FullTransaction {
182183 guard let transactionCreator else {
183184 throw CoreError . readOnlyCore
184185 }
185186
186187 let outputs = unspentOutputs. map { $0. outputs ( from: unspentOutputSelector. all) }
187188 let toAddress = try addressConverter. convert ( lockingScriptPayload: hash, type: scriptType)
188- return try transactionCreator. create ( to: toAddress. stringValue, value: value, feeRate: feeRate, senderPay: true , sortType: sortType, unspentOutputs: outputs, pluginData: [ : ] )
189+ return try transactionCreator. create ( to: toAddress. stringValue, memo : memo , value: value, feeRate: feeRate, senderPay: true , sortType: sortType, unspentOutputs: outputs, pluginData: [ : ] )
189190 }
190191
191- internal func redeem( from unspentOutput: UnspentOutput , to address: String , feeRate: Int , sortType: TransactionDataSortType ) throws -> FullTransaction {
192+ internal func redeem( from unspentOutput: UnspentOutput , memo : String ? , to address: String , feeRate: Int , sortType: TransactionDataSortType ) throws -> FullTransaction {
192193 guard let transactionCreator else {
193194 throw CoreError . readOnlyCore
194195 }
195196
196- return try transactionCreator. create ( from: unspentOutput, to: address, feeRate: feeRate, sortType: sortType)
197+ return try transactionCreator. create ( from: unspentOutput, to: address, memo : memo , feeRate: feeRate, sortType: sortType)
197198 }
198199
199- func createRawTransaction( to address: String , value: Int , feeRate: Int , sortType: TransactionDataSortType , unspentOutputs: [ UnspentOutput ] ? , pluginData: [ UInt8 : IPluginData ] = [ : ] ) throws -> Data {
200+ func createRawTransaction( to address: String , memo : String ? , value: Int , feeRate: Int , sortType: TransactionDataSortType , unspentOutputs: [ UnspentOutput ] ? , pluginData: [ UInt8 : IPluginData ] = [ : ] ) throws -> Data {
200201 guard let transactionCreator else {
201202 throw CoreError . readOnlyCore
202203 }
203204
204- return try transactionCreator. createRawTransaction ( to: address, value: value, feeRate: feeRate, senderPay: true , sortType: sortType, unspentOutputs: unspentOutputs, pluginData: pluginData)
205+ return try transactionCreator. createRawTransaction ( to: address, memo : memo , value: value, feeRate: feeRate, senderPay: true , sortType: sortType, unspentOutputs: unspentOutputs, pluginData: pluginData)
205206 }
206207
207208 func validate( address: String , pluginData: [ UInt8 : IPluginData ] = [ : ] ) throws {
@@ -212,23 +213,23 @@ public extension BitcoinCore {
212213 paymentAddressParser. parse ( paymentAddress: paymentAddress)
213214 }
214215
215- func sendInfo( for value: Int , toAddress: String ? = nil , feeRate: Int , unspentOutputs: [ UnspentOutput ] ? , pluginData: [ UInt8 : IPluginData ] = [ : ] ) throws -> BitcoinSendInfo {
216+ func sendInfo( for value: Int , toAddress: String ? = nil , memo : String ? , feeRate: Int , unspentOutputs: [ UnspentOutput ] ? , pluginData: [ UInt8 : IPluginData ] = [ : ] ) throws -> BitcoinSendInfo {
216217 guard let transactionFeeCalculator else {
217218 throw CoreError . readOnlyCore
218219 }
219220
220- return try transactionFeeCalculator. sendInfo ( for: value, feeRate: feeRate, senderPay: true , toAddress: toAddress, unspentOutputs: unspentOutputs, pluginData: pluginData)
221+ return try transactionFeeCalculator. sendInfo ( for: value, feeRate: feeRate, senderPay: true , toAddress: toAddress, memo : memo , unspentOutputs: unspentOutputs, pluginData: pluginData)
221222 }
222223
223- func maxSpendableValue( toAddress: String ? = nil , feeRate: Int , unspentOutputs: [ UnspentOutputInfo ] ? , pluginData: [ UInt8 : IPluginData ] = [ : ] ) throws -> Int {
224+ func maxSpendableValue( toAddress: String ? = nil , memo : String ? , feeRate: Int , unspentOutputs: [ UnspentOutputInfo ] ? , pluginData: [ UInt8 : IPluginData ] = [ : ] ) throws -> Int {
224225 guard let transactionFeeCalculator else {
225226 throw CoreError . readOnlyCore
226227 }
227228
228229 let outputs = unspentOutputs. map { $0. outputs ( from: unspentOutputSelector. all) }
229230 let balance = outputs. map { $0. map ( \. output. value) . reduce ( 0 , + ) } ?? balance. spendable
230231
231- let sendAllFee = try transactionFeeCalculator. sendInfo ( for: balance, feeRate: feeRate, senderPay: false , toAddress: toAddress, unspentOutputs: outputs, pluginData: pluginData) . fee
232+ let sendAllFee = try transactionFeeCalculator. sendInfo ( for: balance, feeRate: feeRate, senderPay: false , toAddress: toAddress, memo : memo , unspentOutputs: outputs, pluginData: pluginData) . fee
232233 return max ( 0 , balance - sendAllFee)
233234 }
234235
0 commit comments