edge-currency-monero 1.5.1 → 2.0.1

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
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 2.0.1 (2025-11-17)
6
+
7
+ - fixed: Handle REST responses from monero-lws.
8
+
9
+ ## 2.0.0 (2025-10-02)
10
+
11
+ - changed: *Breaking change* Change to use Edge LWS servers. Must specify edgeApiKey in plugin options, instead of apiKey
12
+
5
13
  ## 1.5.1 (2025-07-03)
6
14
 
7
15
  - fixed: Fix `getFreshAddress` to return a non-empty `publicAddress` when calling immediately after creating a wallet.
@@ -97,7 +97,7 @@ const PRIMARY_CURRENCY_TOKEN_ID = null
97
97
  const initOptions = _moneroTypes.asMoneroInitOptions.call(void 0, _nullishCoalesce(env.initOptions, () => ( {})))
98
98
  const { networkInfo } = tools
99
99
 
100
- this.apiKey = initOptions.apiKey
100
+ this.apiKey = initOptions.edgeApiKey
101
101
  this.io = env.io
102
102
  this.log = opts.log
103
103
  this.engineOn = false
@@ -110,7 +110,7 @@ const PRIMARY_CURRENCY_TOKEN_ID = null
110
110
  this.currencyInfo = _moneroInfo.currencyInfo
111
111
  this.currencyTools = tools
112
112
  this.myMoneroApi = new (0, _MyMoneroApi.MyMoneroApi)(tools.cppBridge, {
113
- apiKey: initOptions.apiKey,
113
+ apiKey: initOptions.edgeApiKey,
114
114
  apiServer: networkInfo.defaultServer,
115
115
  fetch: env.io.fetch,
116
116
  nettype: networkInfo.nettype
@@ -134,9 +134,6 @@ const PRIMARY_CURRENCY_TOKEN_ID = null
134
134
  )
135
135
  }
136
136
 
137
- // Hard coded for testing
138
- // this.walletInfo.keys.moneroKey = '389b07b3466eed587d6bdae09a3613611de9add2635432d6cd1521af7bbc3757'
139
- // this.walletInfo.keys.moneroAddress = '0x9fa817e5A48DD1adcA7BEc59aa6E3B1F5C4BeA9a'
140
137
  this.edgeTxLibCallbacks = callbacks
141
138
  this.walletLocalDisklet = walletLocalDisklet
142
139
 
@@ -264,12 +261,8 @@ const PRIMARY_CURRENCY_TOKEN_ID = null
264
261
  ourReceiveAddresses.push(this.walletInfo.keys.moneroAddress.toLowerCase())
265
262
  }
266
263
 
267
- let blockHeight = tx.height
268
- if (tx.mempool) {
269
- blockHeight = 0
270
- }
271
-
272
- const date = Date.parse(tx.timestamp) / 1000
264
+ const blockHeight = tx.height == null || tx.mempool ? 0 : tx.height
265
+ const date = tx.timestamp == null ? new Date() : new Date(tx.timestamp)
273
266
 
274
267
  // Expose legacy payment ID's to the GUI. This only applies
275
268
  // to really old transactions, before integrated addresses:
@@ -285,7 +278,7 @@ const PRIMARY_CURRENCY_TOKEN_ID = null
285
278
  const edgeTransaction = {
286
279
  blockHeight,
287
280
  currencyCode: 'XMR',
288
- date,
281
+ date: date.valueOf() / 1000,
289
282
  isSend: _biggystring.lt.call(void 0, netNativeAmount, '0'),
290
283
  memos,
291
284
  nativeAmount: netNativeAmount,
@@ -404,20 +397,20 @@ const PRIMARY_CURRENCY_TOKEN_ID = null
404
397
  })
405
398
  } else {
406
399
  const txs = this.getTxs(tokenId)
407
- const edgeTx = txs[idx]
400
+ const oldTx = txs[idx]
401
+
402
+ // Keep the first-seen date for unconfirmed transactions:
403
+ if (edgeTransaction.blockHeight === 0) edgeTransaction.date = oldTx.date
408
404
 
409
405
  // Already have this tx in the database. Consider a change if blockHeight changed
410
- if (edgeTx.blockHeight === edgeTransaction.blockHeight) return
406
+ if (oldTx.blockHeight === edgeTransaction.blockHeight) return
411
407
  this.log(
412
408
  `Update transaction: ${edgeTransaction.txid} height:${edgeTransaction.blockHeight}`
413
409
  )
414
410
 
415
411
  // The native amounts returned from the API take some time before they're
416
412
  // accurate. We can trust the amounts we saved instead.
417
- edgeTransaction = {
418
- ...edgeTransaction,
419
- nativeAmount: edgeTx.nativeAmount
420
- }
413
+ edgeTransaction.nativeAmount = oldTx.nativeAmount
421
414
 
422
415
  // Update the transaction
423
416
  txs[idx] = edgeTransaction
@@ -37,7 +37,7 @@ function getParameterByName(param, url) {
37
37
 
38
38
 
39
39
  __init() {this.networkInfo = {
40
- defaultServer: 'https://edge.mymonero.com:8443',
40
+ defaultServer: _moneroInfo.MONERO_LWS_SERVER,
41
41
  nettype: 'MAINNET'
42
42
  }}
43
43
 
@@ -125,13 +125,13 @@ const asGetAddressTxsResponse = _cleaners.asObject.call(void 0, {
125
125
  _cleaners.asObject.call(void 0, {
126
126
  coinbase: asNumberBoolean, // True if tx is coinbase
127
127
  hash: _cleaners.asString, // Bytes of tx hash
128
- height: _cleaners.asNumber, // Block height
128
+ height: _cleaners.asOptional.call(void 0, _cleaners.asNumber), // Block height
129
129
  id: _cleaners.asNumber, // Index of tx in blockchain
130
130
  mempool: asNumberBoolean, // True if tx is in mempool
131
131
  mixin: _cleaners.asNumber, // Mixin of the receive
132
132
  payment_id: _cleaners.asOptional.call(void 0, _cleaners.asString), // Bytes of tx payment id
133
133
  spent_outputs: _cleaners.asOptional.call(void 0, _cleaners.asArray.call(void 0, asSpentOutput)), // List of possible spends
134
- timestamp: _cleaners.asString, // Timestamp of block
134
+ timestamp: _cleaners.asOptional.call(void 0, _cleaners.asString), // Timestamp of block
135
135
  total_received: _cleaners.asString, // Total XMR received
136
136
  total_sent: _cleaners.asString, // XMR possibly being spent
137
137
  unlock_time: _cleaners.asNumber // Tx unlock time field
@@ -252,6 +252,9 @@ const asGetAddressTxsResponse = _cleaners.asObject.call(void 0, {
252
252
  use_dust: true,
253
253
  view_key: privateViewKey
254
254
  })
255
+ for (const out of unspentOuts.outputs) {
256
+ if (out.spend_key_images == null) out.spend_key_images = []
257
+ }
255
258
 
256
259
  // Grab some random outputs to mix in:
257
260
  const randomOutsCb = async (count) => {
package/lib/moneroInfo.js CHANGED
@@ -2,9 +2,11 @@
2
2
 
3
3
 
4
4
 
5
+ const MONERO_LWS_SERVER = 'https://monerolws1.edge.app'; exports.MONERO_LWS_SERVER = MONERO_LWS_SERVER
6
+
5
7
  const defaultSettings = {
6
8
  enableCustomServers: false,
7
- moneroLightwalletServer: 'https://edge.mymonero.com:8443'
9
+ moneroLightwalletServer: exports.MONERO_LWS_SERVER
8
10
  }
9
11
 
10
12
  const currencyInfo = {
@@ -16,7 +16,7 @@ var _cleaners = require('cleaners');
16
16
 
17
17
 
18
18
  const asMoneroInitOptions = _cleaners.asObject.call(void 0, {
19
- apiKey: _cleaners.asOptional.call(void 0, _cleaners.asString, '')
19
+ edgeApiKey: _cleaners.asOptional.call(void 0, _cleaners.asString, '')
20
20
  }); exports.asMoneroInitOptions = asMoneroInitOptions
21
21
 
22
22
 
@@ -1923,7 +1923,7 @@ var MoneroEngine = /*#__PURE__*/function () {
1923
1923
  walletLocalDisklet = opts.walletLocalDisklet;
1924
1924
  var initOptions = (0,_moneroTypes__WEBPACK_IMPORTED_MODULE_4__.asMoneroInitOptions)((_env$initOptions = env.initOptions) !== null && _env$initOptions !== void 0 ? _env$initOptions : {});
1925
1925
  var networkInfo = tools.networkInfo;
1926
- this.apiKey = initOptions.apiKey;
1926
+ this.apiKey = initOptions.edgeApiKey;
1927
1927
  this.io = env.io;
1928
1928
  this.log = opts.log;
1929
1929
  this.engineOn = false;
@@ -1937,7 +1937,7 @@ var MoneroEngine = /*#__PURE__*/function () {
1937
1937
  this.currencyInfo = _moneroInfo__WEBPACK_IMPORTED_MODULE_2__.currencyInfo;
1938
1938
  this.currencyTools = tools;
1939
1939
  this.myMoneroApi = new _MyMoneroApi__WEBPACK_IMPORTED_MODULE_5__.MyMoneroApi(tools.cppBridge, {
1940
- apiKey: initOptions.apiKey,
1940
+ apiKey: initOptions.edgeApiKey,
1941
1941
  apiServer: networkInfo.defaultServer,
1942
1942
  fetch: env.io.fetch,
1943
1943
  nettype: networkInfo.nettype
@@ -1949,10 +1949,7 @@ var MoneroEngine = /*#__PURE__*/function () {
1949
1949
 
1950
1950
  if (this.currentSettings.enableCustomServers && this.currentSettings.moneroLightwalletServer != null) {
1951
1951
  this.myMoneroApi.changeServer(this.currentSettings.moneroLightwalletServer, '');
1952
- } // Hard coded for testing
1953
- // this.walletInfo.keys.moneroKey = '389b07b3466eed587d6bdae09a3613611de9add2635432d6cd1521af7bbc3757'
1954
- // this.walletInfo.keys.moneroAddress = '0x9fa817e5A48DD1adcA7BEc59aa6E3B1F5C4BeA9a'
1955
-
1952
+ }
1956
1953
 
1957
1954
  this.edgeTxLibCallbacks = callbacks;
1958
1955
  this.walletLocalDisklet = walletLocalDisklet;
@@ -2176,13 +2173,8 @@ var MoneroEngine = /*#__PURE__*/function () {
2176
2173
  ourReceiveAddresses.push(this.walletInfo.keys.moneroAddress.toLowerCase());
2177
2174
  }
2178
2175
 
2179
- var blockHeight = tx.height;
2180
-
2181
- if (tx.mempool) {
2182
- blockHeight = 0;
2183
- }
2184
-
2185
- var date = Date.parse(tx.timestamp) / 1000; // Expose legacy payment ID's to the GUI. This only applies
2176
+ var blockHeight = tx.height == null || tx.mempool ? 0 : tx.height;
2177
+ var date = tx.timestamp == null ? new Date() : new Date(tx.timestamp); // Expose legacy payment ID's to the GUI. This only applies
2186
2178
  // to really old transactions, before integrated addresses:
2187
2179
 
2188
2180
  var memos = [];
@@ -2198,7 +2190,7 @@ var MoneroEngine = /*#__PURE__*/function () {
2198
2190
  var edgeTransaction = {
2199
2191
  blockHeight: blockHeight,
2200
2192
  currencyCode: 'XMR',
2201
- date: date,
2193
+ date: date.valueOf() / 1000,
2202
2194
  isSend: (0,biggystring__WEBPACK_IMPORTED_MODULE_0__.lt)(netNativeAmount, '0'),
2203
2195
  memos: memos,
2204
2196
  nativeAmount: netNativeAmount,
@@ -2333,15 +2325,15 @@ var MoneroEngine = /*#__PURE__*/function () {
2333
2325
  } else {
2334
2326
  var _txs2 = this.getTxs(tokenId);
2335
2327
 
2336
- var edgeTx = _txs2[idx]; // Already have this tx in the database. Consider a change if blockHeight changed
2328
+ var oldTx = _txs2[idx]; // Keep the first-seen date for unconfirmed transactions:
2329
+
2330
+ if (edgeTransaction.blockHeight === 0) edgeTransaction.date = oldTx.date; // Already have this tx in the database. Consider a change if blockHeight changed
2337
2331
 
2338
- if (edgeTx.blockHeight === edgeTransaction.blockHeight) return;
2332
+ if (oldTx.blockHeight === edgeTransaction.blockHeight) return;
2339
2333
  this.log("Update transaction: ".concat(edgeTransaction.txid, " height:").concat(edgeTransaction.blockHeight)); // The native amounts returned from the API take some time before they're
2340
2334
  // accurate. We can trust the amounts we saved instead.
2341
2335
 
2342
- edgeTransaction = _objectSpread(_objectSpread({}, edgeTransaction), {}, {
2343
- nativeAmount: edgeTx.nativeAmount
2344
- }); // Update the transaction
2336
+ edgeTransaction.nativeAmount = oldTx.nativeAmount; // Update the transaction
2345
2337
 
2346
2338
  _txs2[idx] = edgeTransaction;
2347
2339
  this.walletLocalDataDirty = true;
@@ -3443,7 +3435,7 @@ var MoneroTools = /*#__PURE__*/function () {
3443
3435
  _classCallCheck(this, MoneroTools);
3444
3436
 
3445
3437
  _defineProperty(this, "networkInfo", {
3446
- defaultServer: 'https://edge.mymonero.com:8443',
3438
+ defaultServer: _moneroInfo__WEBPACK_IMPORTED_MODULE_3__.MONERO_LWS_SERVER,
3447
3439
  nettype: 'MAINNET'
3448
3440
  });
3449
3441
 
@@ -3876,7 +3868,7 @@ var asGetAddressTxsResponse = (0,cleaners__WEBPACK_IMPORTED_MODULE_0__.asObject)
3876
3868
  // True if tx is coinbase
3877
3869
  hash: cleaners__WEBPACK_IMPORTED_MODULE_0__.asString,
3878
3870
  // Bytes of tx hash
3879
- height: cleaners__WEBPACK_IMPORTED_MODULE_0__.asNumber,
3871
+ height: (0,cleaners__WEBPACK_IMPORTED_MODULE_0__.asOptional)(cleaners__WEBPACK_IMPORTED_MODULE_0__.asNumber),
3880
3872
  // Block height
3881
3873
  id: cleaners__WEBPACK_IMPORTED_MODULE_0__.asNumber,
3882
3874
  // Index of tx in blockchain
@@ -3888,7 +3880,7 @@ var asGetAddressTxsResponse = (0,cleaners__WEBPACK_IMPORTED_MODULE_0__.asObject)
3888
3880
  // Bytes of tx payment id
3889
3881
  spent_outputs: (0,cleaners__WEBPACK_IMPORTED_MODULE_0__.asOptional)((0,cleaners__WEBPACK_IMPORTED_MODULE_0__.asArray)(asSpentOutput)),
3890
3882
  // List of possible spends
3891
- timestamp: cleaners__WEBPACK_IMPORTED_MODULE_0__.asString,
3883
+ timestamp: (0,cleaners__WEBPACK_IMPORTED_MODULE_0__.asOptional)(cleaners__WEBPACK_IMPORTED_MODULE_0__.asString),
3892
3884
  // Timestamp of block
3893
3885
  total_received: cleaners__WEBPACK_IMPORTED_MODULE_0__.asString,
3894
3886
  // Total XMR received
@@ -4058,7 +4050,7 @@ var MyMoneroApi = /*#__PURE__*/function () {
4058
4050
  var _createTransaction = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(keys, opts) {
4059
4051
  var _this = this;
4060
4052
 
4061
- var address, privateSpendKey, privateViewKey, publicSpendKey, _opts$isSweepTx, isSweepTx, paymentId, _opts$priority, priority, targets, unspentOuts, randomOutsCb, destinations;
4053
+ var address, privateSpendKey, privateViewKey, publicSpendKey, _opts$isSweepTx, isSweepTx, paymentId, _opts$priority, priority, targets, unspentOuts, _i2, _unspentOuts$outputs2, out, randomOutsCb, destinations;
4062
4054
 
4063
4055
  return regeneratorRuntime.wrap(function _callee5$(_context5) {
4064
4056
  while (1) {
@@ -4081,7 +4073,12 @@ var MyMoneroApi = /*#__PURE__*/function () {
4081
4073
  case 4:
4082
4074
  unspentOuts = _context5.sent;
4083
4075
 
4084
- // Grab some random outputs to mix in:
4076
+ for (_i2 = 0, _unspentOuts$outputs2 = unspentOuts.outputs; _i2 < _unspentOuts$outputs2.length; _i2++) {
4077
+ out = _unspentOuts$outputs2[_i2];
4078
+ if (out.spend_key_images == null) out.spend_key_images = [];
4079
+ } // Grab some random outputs to mix in:
4080
+
4081
+
4085
4082
  randomOutsCb = /*#__PURE__*/function () {
4086
4083
  var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(count) {
4087
4084
  var amounts, i;
@@ -4125,7 +4122,7 @@ var MyMoneroApi = /*#__PURE__*/function () {
4125
4122
  };
4126
4123
  }); // Make the transaction:
4127
4124
 
4128
- _context5.next = 9;
4125
+ _context5.next = 10;
4129
4126
  return this.cppBridge.createTransaction({
4130
4127
  destinations: destinations,
4131
4128
  priority: priority,
@@ -4140,10 +4137,10 @@ var MyMoneroApi = /*#__PURE__*/function () {
4140
4137
  randomOutsCb: randomOutsCb
4141
4138
  });
4142
4139
 
4143
- case 9:
4140
+ case 10:
4144
4141
  return _context5.abrupt("return", _context5.sent);
4145
4142
 
4146
- case 10:
4143
+ case 11:
4147
4144
  case "end":
4148
4145
  return _context5.stop();
4149
4146
  }
@@ -4254,11 +4251,13 @@ var MyMoneroApi = /*#__PURE__*/function () {
4254
4251
  "use strict";
4255
4252
  __webpack_require__.r(__webpack_exports__);
4256
4253
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4254
+ /* harmony export */ MONERO_LWS_SERVER: () => (/* binding */ MONERO_LWS_SERVER),
4257
4255
  /* harmony export */ currencyInfo: () => (/* binding */ currencyInfo)
4258
4256
  /* harmony export */ });
4257
+ var MONERO_LWS_SERVER = 'https://monerolws1.edge.app';
4259
4258
  var defaultSettings = {
4260
4259
  enableCustomServers: false,
4261
- moneroLightwalletServer: 'https://edge.mymonero.com:8443'
4260
+ moneroLightwalletServer: MONERO_LWS_SERVER
4262
4261
  };
4263
4262
  var currencyInfo = {
4264
4263
  // Basic currency information:
@@ -4382,7 +4381,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
4382
4381
  */
4383
4382
 
4384
4383
  var asMoneroInitOptions = (0,cleaners__WEBPACK_IMPORTED_MODULE_0__.asObject)({
4385
- apiKey: (0,cleaners__WEBPACK_IMPORTED_MODULE_0__.asOptional)(cleaners__WEBPACK_IMPORTED_MODULE_0__.asString, '')
4384
+ edgeApiKey: (0,cleaners__WEBPACK_IMPORTED_MODULE_0__.asOptional)(cleaners__WEBPACK_IMPORTED_MODULE_0__.asString, '')
4386
4385
  });
4387
4386
  var asMoneroUserSettings = (0,cleaners__WEBPACK_IMPORTED_MODULE_0__.asObject)({
4388
4387
  enableCustomServers: (0,cleaners__WEBPACK_IMPORTED_MODULE_0__.asMaybe)(cleaners__WEBPACK_IMPORTED_MODULE_0__.asBoolean, false),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edge-currency-monero",
3
- "version": "1.5.1",
3
+ "version": "2.0.1",
4
4
  "description": "Edge Monero currency plugin",
5
5
  "homepage": "https://edge.app",
6
6
  "repository": {