edge-currency-monero 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # edge-currency-monero
2
2
 
3
+ # 0.4.0 (2022-01-11)
4
+
5
+ - added: Move the forked code out of mymonero-core-js directly into this repo.
6
+ - changed: Require react-native-mymonero-core ^0.1.2.
7
+
8
+ # 0.3.4 (2022-01-11)
9
+
10
+ - Fix git urls
11
+
12
+ # 0.3.3 (2021-09-28)
13
+
14
+ - Reformat spendable balance error into 3 lines
15
+
3
16
  # 0.3.2 (2021-06-03)
4
17
 
5
18
  - Remove icon URLs
@@ -0,0 +1,119 @@
1
+ // Copyright (c) 2014-2018, MyMonero.com
2
+ //
3
+ // All rights reserved.
4
+ //
5
+ // Redistribution and use in source and binary forms, with or without modification, are
6
+ // permitted provided that the following conditions are met:
7
+ //
8
+ // 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ // conditions and the following disclaimer.
10
+ //
11
+ // 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ // of conditions and the following disclaimer in the documentation and/or other
13
+ // materials provided with the distribution.
14
+ //
15
+ // 3. Neither the name of the copyright holder nor the names of its contributors may be
16
+ // used to endorse or promote products derived from this software without specific
17
+ // prior written permission.
18
+ //
19
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20
+ // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21
+ // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22
+ // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24
+ // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
+ // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
+ // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27
+ // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+ //
29
+ "use strict"
30
+ //
31
+ // In the future this could implement web workers
32
+ const response_parser_utils = require('../hostAPI/response_parser_utils')
33
+ const monero_keyImage_cache_utils = require('../monero_utils/monero_keyImage_cache_utils')
34
+ //
35
+ class BackgroundResponseParser
36
+ {
37
+ constructor(moneroUtils)
38
+ {
39
+ this.moneroUtils = moneroUtils
40
+ }
41
+ //
42
+ // Runtime - Accessors - Interface
43
+ //
44
+ Parsed_AddressInfo(
45
+ data,
46
+ address,
47
+ view_key__private,
48
+ spend_key__public,
49
+ spend_key__private,
50
+ fn //: (err?, returnValuesByKey?) -> Void
51
+ ) {
52
+ response_parser_utils.Parsed_AddressInfo__keyImageManaged(
53
+ data,
54
+ address,
55
+ view_key__private,
56
+ spend_key__public,
57
+ spend_key__private,
58
+ this.moneroUtils,
59
+ function(err, returnValuesByKey)
60
+ {
61
+ fn(err, returnValuesByKey)
62
+ }
63
+ )
64
+ }
65
+ Parsed_AddressTransactions(
66
+ data,
67
+ address,
68
+ view_key__private,
69
+ spend_key__public,
70
+ spend_key__private,
71
+ fn //: (err?, returnValuesByKey?) -> Void
72
+ ) {
73
+ response_parser_utils.Parsed_AddressTransactions__keyImageManaged(
74
+ data,
75
+ address,
76
+ view_key__private,
77
+ spend_key__public,
78
+ spend_key__private,
79
+ this.moneroUtils,
80
+ function(err, returnValuesByKey)
81
+ {
82
+ fn(err, returnValuesByKey)
83
+ }
84
+ )
85
+ }
86
+ Parsed_UnspentOuts(
87
+ data,
88
+ address,
89
+ view_key__private,
90
+ spend_key__public,
91
+ spend_key__private,
92
+ fn //: (err?, returnValuesByKey?) -> Void
93
+ ) {
94
+ response_parser_utils.Parsed_UnspentOuts__keyImageManaged(
95
+ data,
96
+ address,
97
+ view_key__private,
98
+ spend_key__public,
99
+ spend_key__private,
100
+ this.moneroUtils,
101
+ function(err, returnValuesByKey)
102
+ {
103
+ fn(err, returnValuesByKey)
104
+ }
105
+ )
106
+ }
107
+ //
108
+ DeleteManagedKeyImagesForWalletWith(
109
+ address,
110
+ fn // ((err) -> Void)?
111
+ ) {
112
+ monero_keyImage_cache_utils.DeleteManagedKeyImagesForWalletWith(address)
113
+ if (fn) {
114
+ setImmediate(fn)
115
+ }
116
+ }
117
+ }
118
+
119
+ module.exports = { BackgroundResponseParser }
@@ -0,0 +1,42 @@
1
+ // Copyright (c) 2014-2018, MyMonero.com
2
+ //
3
+ // All rights reserved.
4
+ //
5
+ // Redistribution and use in source and binary forms, with or without modification, are
6
+ // permitted provided that the following conditions are met:
7
+ //
8
+ // 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ // conditions and the following disclaimer.
10
+ //
11
+ // 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ // of conditions and the following disclaimer in the documentation and/or other
13
+ // materials provided with the distribution.
14
+ //
15
+ // 3. Neither the name of the copyright holder nor the names of its contributors may be
16
+ // used to endorse or promote products derived from this software without specific
17
+ // prior written permission.
18
+ //
19
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20
+ // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21
+ // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22
+ // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24
+ // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
+ // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
+ // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27
+ // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+
29
+ "use strict"
30
+ //
31
+ const HostedMoneroAPIClient_Base = require('./HostedMoneroAPIClient_Base')
32
+ //
33
+ class HostedMoneroAPIClient extends HostedMoneroAPIClient_Base
34
+ {
35
+ //
36
+ // Lifecycle - Init
37
+ constructor(options, context)
38
+ {
39
+ super(options, context)
40
+ }
41
+ }
42
+ module.exports = HostedMoneroAPIClient
@@ -0,0 +1,489 @@
1
+ // Copyright (c) 2014-2018, MyMonero.com
2
+ //
3
+ // All rights reserved.
4
+ //
5
+ // Redistribution and use in source and binary forms, with or without modification, are
6
+ // permitted provided that the following conditions are met:
7
+ //
8
+ // 1. Redistributions of source code must retain the above copyright notice, this list of
9
+ // conditions and the following disclaimer.
10
+ //
11
+ // 2. Redistributions in binary form must reproduce the above copyright notice, this list
12
+ // of conditions and the following disclaimer in the documentation and/or other
13
+ // materials provided with the distribution.
14
+ //
15
+ // 3. Neither the name of the copyright holder nor the names of its contributors may be
16
+ // used to endorse or promote products derived from this software without specific
17
+ // prior written permission.
18
+ //
19
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20
+ // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21
+ // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22
+ // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24
+ // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
+ // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26
+ // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
27
+ // THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+
29
+ "use strict"
30
+ //
31
+ //
32
+ const JSBigInt = require('@mymonero/mymonero-bigint').BigInteger // important: grab defined export
33
+ const monero_config = require('@mymonero/mymonero-money-format/monero_config')
34
+ const net_service_utils = require('../hostAPI/net_service_utils.js')
35
+ const apiServer = "https://api.mymonero.com:8443"
36
+ //
37
+ class HostedMoneroAPIClient_Base
38
+ {
39
+ //
40
+ // Lifecycle - Initialization
41
+ constructor(options, context)
42
+ {
43
+ var self = this
44
+ self.options = options
45
+ self.context = context
46
+ //
47
+ self.fetch = options.fetch
48
+ // self.request = options.request_conformant_module
49
+ if (!self.fetch) {
50
+ throw `${self.constructor.name} requires an options.fetch such as require('node-fetch')`
51
+ }
52
+ if (!self.options.apiServer) {
53
+ self.options.apiServer = apiServer
54
+ }
55
+ self.setup()
56
+ }
57
+ setup()
58
+ {
59
+ var self = this
60
+ { // options
61
+ self.appUserAgent_product = self.options.appUserAgent_product
62
+ if (!self.appUserAgent_product) {
63
+ throw `${self.constructor.name} requires options.appUserAgent_product`
64
+ }
65
+ self.appUserAgent_version = self.options.appUserAgent_version
66
+ if (!self.appUserAgent_version) {
67
+ throw `${self.constructor.name} requires options.appUserAgent_version`
68
+ }
69
+ }
70
+ }
71
+ //
72
+ // Runtime - Accessors - Private - Requests
73
+ _new_apiAddress_authority()
74
+ { // overridable
75
+ return this.options.apiServer
76
+ }
77
+ //
78
+ // Runtime - Accessors - Public - Requests
79
+ LogIn(address, view_key__private, generated_locally, fn)
80
+ { // fn: (err?, new_address?) -> RequestHandle
81
+ const self = this
82
+ const endpointPath = "login"
83
+ const parameters = net_service_utils.New_ParametersForWalletRequest(address, view_key__private)
84
+ parameters.api_key = this.options.apiKey
85
+ parameters.create_account = true
86
+ parameters.generated_locally = generated_locally
87
+ const requestHandle = net_service_utils.HTTPRequest(
88
+ self.fetch,
89
+ self._new_apiAddress_authority(),
90
+ endpointPath,
91
+ parameters,
92
+ function(err, data)
93
+ {
94
+ if (err) {
95
+ fn(err)
96
+ return
97
+ }
98
+ __proceedTo_parseAndCallBack(data)
99
+ }
100
+ )
101
+ function __proceedTo_parseAndCallBack(data)
102
+ {
103
+ const new_address = data.new_address
104
+ const received__generated_locally = data.generated_locally
105
+ const start_height = data.start_height
106
+ // console.log("data from login: ", data)
107
+ // TODO? parse anything else?
108
+ //
109
+ fn(null, new_address, received__generated_locally, start_height)
110
+ }
111
+ return requestHandle
112
+ }
113
+ //
114
+ // Syncing
115
+ AddressInfo_returningRequestHandle(
116
+ address,
117
+ view_key__private,
118
+ spend_key__public,
119
+ spend_key__private,
120
+ fn
121
+ ) { // -> RequestHandle
122
+ const self = this
123
+ const endpointPath = "get_address_info"
124
+ const parameters = net_service_utils.New_ParametersForWalletRequest(address, view_key__private)
125
+ parameters.api_key = this.options.apiKey
126
+ const requestHandle = net_service_utils.HTTPRequest(
127
+ self.fetch,
128
+ self._new_apiAddress_authority(),
129
+ endpointPath,
130
+ parameters,
131
+ function(err, data)
132
+ {
133
+ if (err) {
134
+ fn(err)
135
+ return
136
+ }
137
+ __proceedTo_parseAndCallBack(data)
138
+ }
139
+ )
140
+ function __proceedTo_parseAndCallBack(data)
141
+ {
142
+ self.context.backgroundAPIResponseParser.Parsed_AddressInfo(
143
+ // key-image-managed - just be sure to dekete your wallet's key img cache when you tear down
144
+ data,
145
+ address,
146
+ view_key__private,
147
+ spend_key__public,
148
+ spend_key__private,
149
+ function(err, returnValuesByKey)
150
+ {
151
+ if (err) {
152
+ fn(err)
153
+ return
154
+ }
155
+ var total_received_JSBigInt;
156
+ const total_received_String = returnValuesByKey.total_received_String
157
+ if (total_received_String) {
158
+ total_received_JSBigInt = new JSBigInt(total_received_String)
159
+ } else {
160
+ total_received_JSBigInt = new JSBigInt(0)
161
+ }
162
+ //
163
+ var locked_balance_JSBigInt;
164
+ const locked_balance_String = returnValuesByKey.locked_balance_String
165
+ if (locked_balance_String) {
166
+ locked_balance_JSBigInt = new JSBigInt(locked_balance_String)
167
+ } else {
168
+ locked_balance_JSBigInt = new JSBigInt(0)
169
+ }
170
+ //
171
+ var total_sent_JSBigInt;
172
+ const total_sent_String = returnValuesByKey.total_sent_String
173
+ if (total_sent_String) {
174
+ total_sent_JSBigInt = new JSBigInt(total_sent_String)
175
+ } else {
176
+ total_sent_JSBigInt = new JSBigInt(0)
177
+ }
178
+ fn(
179
+ err,
180
+ //
181
+ total_received_JSBigInt,
182
+ locked_balance_JSBigInt,
183
+ total_sent_JSBigInt,
184
+ //
185
+ returnValuesByKey.spent_outputs,
186
+ returnValuesByKey.account_scanned_tx_height,
187
+ returnValuesByKey.account_scanned_block_height,
188
+ returnValuesByKey.account_scan_start_height,
189
+ returnValuesByKey.transaction_height,
190
+ returnValuesByKey.blockchain_height,
191
+ //
192
+ returnValuesByKey.ratesBySymbol
193
+ )
194
+ }
195
+ )
196
+ }
197
+ return requestHandle
198
+ }
199
+ AddressTransactions_returningRequestHandle(
200
+ address,
201
+ view_key__private,
202
+ spend_key__public,
203
+ spend_key__private,
204
+ fn
205
+ ) { // -> RequestHandle
206
+ const self = this
207
+ const endpointPath = "get_address_txs"
208
+ const parameters = net_service_utils.New_ParametersForWalletRequest(address, view_key__private)
209
+ parameters.api_key = this.options.apiKey
210
+ const requestHandle = net_service_utils.HTTPRequest(
211
+ self.fetch,
212
+ self._new_apiAddress_authority(),
213
+ endpointPath,
214
+ parameters,
215
+ function(err, data)
216
+ {
217
+ if (err) {
218
+ fn(err)
219
+ return
220
+ }
221
+ __parseAndCallBack(data)
222
+ }
223
+ )
224
+ function __parseAndCallBack(data)
225
+ {
226
+ self.context.backgroundAPIResponseParser.Parsed_AddressTransactions(
227
+ data,
228
+ address,
229
+ view_key__private,
230
+ spend_key__public,
231
+ spend_key__private,
232
+ function(err, returnValuesByKey)
233
+ {
234
+ if (err) {
235
+ fn(err)
236
+ return
237
+ }
238
+ //
239
+ const transactions = returnValuesByKey.serialized_transactions
240
+ for (let transaction of transactions) {
241
+ transaction.amount = new JSBigInt(transaction.amount)
242
+ if (typeof transaction.total_sent !== 'undefined' && transaction.total_sent !== null) {
243
+ transaction.total_sent = new JSBigInt(transaction.total_sent)
244
+ }
245
+ transaction.timestamp = new Date(transaction.timestamp)
246
+ }
247
+ //
248
+ fn(
249
+ err,
250
+ //
251
+ returnValuesByKey.account_scanned_height,
252
+ returnValuesByKey.account_scanned_block_height,
253
+ returnValuesByKey.account_scan_start_height,
254
+ returnValuesByKey.transaction_height,
255
+ returnValuesByKey.blockchain_height,
256
+ //
257
+ transactions
258
+ )
259
+ }
260
+ )
261
+ }
262
+ return requestHandle
263
+ }
264
+ //
265
+ // Getting wallet txs import info
266
+ ImportRequestInfoAndStatus(
267
+ address,
268
+ view_key__private,
269
+ fn
270
+ ) { // -> RequestHandle
271
+ const self = this
272
+ const endpointPath = "import_wallet_request"
273
+ const parameters = net_service_utils.New_ParametersForWalletRequest(address, view_key__private)
274
+ parameters.api_key = this.options.apiKey
275
+ net_service_utils.AddUserAgentParamters(
276
+ parameters,
277
+ self.appUserAgent_product,
278
+ self.appUserAgent_version
279
+ )
280
+ const requestHandle = net_service_utils.HTTPRequest(
281
+ self.fetch,
282
+ self._new_apiAddress_authority(),
283
+ endpointPath,
284
+ parameters,
285
+ function(err, data)
286
+ {
287
+ if (err) {
288
+ fn(err)
289
+ return
290
+ }
291
+ __proceedTo_parseAndCallBack(data)
292
+ }
293
+ )
294
+ function __proceedTo_parseAndCallBack(data)
295
+ {
296
+ const payment_id = data.payment_id;
297
+ const payment_address = data.payment_address;
298
+ const import_fee__JSBigInt = new JSBigInt(data.import_fee);
299
+ const feeReceiptStatus = data.status;
300
+ fn(
301
+ null,
302
+ payment_id,
303
+ payment_address,
304
+ import_fee__JSBigInt,
305
+ feeReceiptStatus
306
+ )
307
+ }
308
+ return requestHandle
309
+ }
310
+
311
+ //
312
+ // Getting outputs for sending funds
313
+ UnspentOuts(
314
+ address,
315
+ view_key__private,
316
+ spend_key__public,
317
+ spend_key__private,
318
+ mixinNumber,
319
+ sweeping,
320
+ fn
321
+ ) { // -> RequestHandle
322
+ const self = this
323
+ mixinNumber = parseInt(mixinNumber) // jic
324
+ //
325
+ const endpointPath = 'get_unspent_outs'
326
+ const parameters = net_service_utils.New_ParametersForWalletRequest(address, view_key__private)
327
+ parameters.api_key = this.options.apiKey
328
+ parameters.amount = '0'
329
+ parameters.mixin = mixinNumber
330
+ parameters.use_dust = true // Client now filters unmixable by dustthreshold amount (unless sweeping) + non-rct
331
+ parameters.dust_threshold = monero_config.dustThreshold.toString()
332
+ net_service_utils.AddUserAgentParamters(
333
+ parameters,
334
+ self.appUserAgent_product,
335
+ self.appUserAgent_version
336
+ )
337
+ const requestHandle = net_service_utils.HTTPRequest(
338
+ self.fetch,
339
+ self._new_apiAddress_authority(),
340
+ endpointPath,
341
+ parameters,
342
+ function(err, data)
343
+ {
344
+ if (err) {
345
+ fn(err)
346
+ return
347
+ }
348
+ __proceedTo_parseAndCallBack(data)
349
+ }
350
+ )
351
+ function __proceedTo_parseAndCallBack(data)
352
+ {
353
+ self.context.backgroundAPIResponseParser.Parsed_UnspentOuts(
354
+ data,
355
+ address,
356
+ view_key__private,
357
+ spend_key__public,
358
+ spend_key__private,
359
+ function(err, returnValuesByKey)
360
+ {
361
+ if (err) {
362
+ fn(err)
363
+ return
364
+ }
365
+ if (!returnValuesByKey.per_byte_fee__string || typeof returnValuesByKey.per_byte_fee__string === 'undefined') {
366
+ throw "Unexpected / missing per_kb_fee"
367
+ }
368
+ fn(
369
+ err, // no error
370
+ returnValuesByKey.unspentOutputs, // TODO: remove this
371
+ returnValuesByKey.per_byte_fee__string,
372
+ returnValuesByKey.fee_mask
373
+ )
374
+ }
375
+ )
376
+ }
377
+ return requestHandle
378
+ }
379
+ RandomOuts(
380
+ using_outs,
381
+ mixinNumber,
382
+ fn
383
+ ) { // -> RequestHandle
384
+ const self = this
385
+ //
386
+ mixinNumber = parseInt(mixinNumber)
387
+ if (mixinNumber < 0 || isNaN(mixinNumber)) {
388
+ const errStr = "Invalid mixin - must be >= 0"
389
+ const err = new Error(errStr)
390
+ fn(err)
391
+ return
392
+ }
393
+ //
394
+ var amounts = [];
395
+ for (var l = 0; l < using_outs.length; l++) {
396
+ amounts.push(using_outs[l].rct ? "0" : using_outs[l].amount.toString())
397
+ }
398
+ //
399
+ const endpointPath = 'get_random_outs'
400
+ var parameters =
401
+ {
402
+ amounts: amounts,
403
+ count: mixinNumber + 1 // Add one to mixin so we can skip real output key if necessary
404
+ }
405
+ net_service_utils.AddUserAgentParamters(
406
+ parameters,
407
+ self.appUserAgent_product,
408
+ self.appUserAgent_version
409
+ )
410
+ const requestHandle = net_service_utils.HTTPRequest(
411
+ self.fetch,
412
+ self._new_apiAddress_authority(),
413
+ endpointPath,
414
+ parameters,
415
+ function(err, data)
416
+ {
417
+ if (err) {
418
+ fn(err)
419
+ return
420
+ }
421
+ __proceedTo_parseAndCallBack(data)
422
+ }
423
+ )
424
+ function __proceedTo_parseAndCallBack(data)
425
+ {
426
+ // console.log("debug: info: random outs: data", data)
427
+ const amount_outs = data.amount_outs
428
+ // yield
429
+ fn(
430
+ null, // no error
431
+ amount_outs
432
+ )
433
+ }
434
+ return requestHandle
435
+ }
436
+ //
437
+ // Runtime - Imperatives - Public - Sending funds
438
+ SubmitSerializedSignedTransaction(
439
+ address,
440
+ view_key__private,
441
+ serializedSignedTx,
442
+ fn // (err?) -> RequestHandle
443
+ )
444
+ {
445
+ console.info('SEND', serializedSignedTx)
446
+ const self = this
447
+ // just a debug feature:
448
+ if (self.context.HostedMoneroAPIClient_DEBUGONLY_mockSendTransactionSuccess === true) {
449
+ if (self.context.isDebug === true) {
450
+ console.warn("⚠️ WARNING: Mocking that SubmitSerializedSignedTransaction returned a success response w/o having hit the server.")
451
+ fn(null)
452
+ return
453
+ } else {
454
+ throw `[${self.constructor.name}/SubmitSerializedSignedTransaction]: context.HostedMoneroAPIClient_DEBUGONLY_mockSendTransactionSuccess was true despite isDebug not being true. Set back to false for production build.`
455
+ }
456
+ }
457
+ // actual implementation:
458
+ const endpointPath = 'submit_raw_tx'
459
+ const parameters = net_service_utils.New_ParametersForWalletRequest(address, view_key__private)
460
+ parameters.api_key = this.options.apiKey
461
+ parameters.tx = serializedSignedTx
462
+ net_service_utils.AddUserAgentParamters(
463
+ parameters,
464
+ self.appUserAgent_product,
465
+ self.appUserAgent_version
466
+ )
467
+ const requestHandle = net_service_utils.HTTPRequest(
468
+ self.fetch,
469
+ self._new_apiAddress_authority(),
470
+ endpointPath,
471
+ parameters,
472
+ function(err, data)
473
+ {
474
+ if (err) {
475
+ fn(err)
476
+ return
477
+ }
478
+ __proceedTo_parseAndCallBack(data)
479
+ }
480
+ )
481
+ function __proceedTo_parseAndCallBack(data)
482
+ {
483
+ // console.log("debug: info: submit_raw_tx: data", data)
484
+ fn(null)
485
+ }
486
+ return requestHandle
487
+ }
488
+ }
489
+ module.exports = HostedMoneroAPIClient_Base