edge-currency-monero 2.0.0 → 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,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 2.0.1 (2025-11-17)
6
+
7
+ - fixed: Handle REST responses from monero-lws.
8
+
5
9
  ## 2.0.0 (2025-10-02)
6
10
 
7
11
  - changed: *Breaking change* Change to use Edge LWS servers. Must specify edgeApiKey in plugin options, instead of apiKey
@@ -261,12 +261,8 @@ const PRIMARY_CURRENCY_TOKEN_ID = null
261
261
  ourReceiveAddresses.push(this.walletInfo.keys.moneroAddress.toLowerCase())
262
262
  }
263
263
 
264
- let blockHeight = tx.height
265
- if (tx.mempool) {
266
- blockHeight = 0
267
- }
268
-
269
- 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)
270
266
 
271
267
  // Expose legacy payment ID's to the GUI. This only applies
272
268
  // to really old transactions, before integrated addresses:
@@ -282,7 +278,7 @@ const PRIMARY_CURRENCY_TOKEN_ID = null
282
278
  const edgeTransaction = {
283
279
  blockHeight,
284
280
  currencyCode: 'XMR',
285
- date,
281
+ date: date.valueOf() / 1000,
286
282
  isSend: _biggystring.lt.call(void 0, netNativeAmount, '0'),
287
283
  memos,
288
284
  nativeAmount: netNativeAmount,
@@ -401,20 +397,20 @@ const PRIMARY_CURRENCY_TOKEN_ID = null
401
397
  })
402
398
  } else {
403
399
  const txs = this.getTxs(tokenId)
404
- 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
405
404
 
406
405
  // Already have this tx in the database. Consider a change if blockHeight changed
407
- if (edgeTx.blockHeight === edgeTransaction.blockHeight) return
406
+ if (oldTx.blockHeight === edgeTransaction.blockHeight) return
408
407
  this.log(
409
408
  `Update transaction: ${edgeTransaction.txid} height:${edgeTransaction.blockHeight}`
410
409
  )
411
410
 
412
411
  // The native amounts returned from the API take some time before they're
413
412
  // accurate. We can trust the amounts we saved instead.
414
- edgeTransaction = {
415
- ...edgeTransaction,
416
- nativeAmount: edgeTx.nativeAmount
417
- }
413
+ edgeTransaction.nativeAmount = oldTx.nativeAmount
418
414
 
419
415
  // Update the transaction
420
416
  txs[idx] = edgeTransaction
@@ -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) => {
@@ -2173,13 +2173,8 @@ var MoneroEngine = /*#__PURE__*/function () {
2173
2173
  ourReceiveAddresses.push(this.walletInfo.keys.moneroAddress.toLowerCase());
2174
2174
  }
2175
2175
 
2176
- var blockHeight = tx.height;
2177
-
2178
- if (tx.mempool) {
2179
- blockHeight = 0;
2180
- }
2181
-
2182
- 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
2183
2178
  // to really old transactions, before integrated addresses:
2184
2179
 
2185
2180
  var memos = [];
@@ -2195,7 +2190,7 @@ var MoneroEngine = /*#__PURE__*/function () {
2195
2190
  var edgeTransaction = {
2196
2191
  blockHeight: blockHeight,
2197
2192
  currencyCode: 'XMR',
2198
- date: date,
2193
+ date: date.valueOf() / 1000,
2199
2194
  isSend: (0,biggystring__WEBPACK_IMPORTED_MODULE_0__.lt)(netNativeAmount, '0'),
2200
2195
  memos: memos,
2201
2196
  nativeAmount: netNativeAmount,
@@ -2330,15 +2325,15 @@ var MoneroEngine = /*#__PURE__*/function () {
2330
2325
  } else {
2331
2326
  var _txs2 = this.getTxs(tokenId);
2332
2327
 
2333
- 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:
2334
2329
 
2335
- if (edgeTx.blockHeight === edgeTransaction.blockHeight) return;
2330
+ if (edgeTransaction.blockHeight === 0) edgeTransaction.date = oldTx.date; // Already have this tx in the database. Consider a change if blockHeight changed
2331
+
2332
+ if (oldTx.blockHeight === edgeTransaction.blockHeight) return;
2336
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
2337
2334
  // accurate. We can trust the amounts we saved instead.
2338
2335
 
2339
- edgeTransaction = _objectSpread(_objectSpread({}, edgeTransaction), {}, {
2340
- nativeAmount: edgeTx.nativeAmount
2341
- }); // Update the transaction
2336
+ edgeTransaction.nativeAmount = oldTx.nativeAmount; // Update the transaction
2342
2337
 
2343
2338
  _txs2[idx] = edgeTransaction;
2344
2339
  this.walletLocalDataDirty = true;
@@ -3873,7 +3868,7 @@ var asGetAddressTxsResponse = (0,cleaners__WEBPACK_IMPORTED_MODULE_0__.asObject)
3873
3868
  // True if tx is coinbase
3874
3869
  hash: cleaners__WEBPACK_IMPORTED_MODULE_0__.asString,
3875
3870
  // Bytes of tx hash
3876
- height: cleaners__WEBPACK_IMPORTED_MODULE_0__.asNumber,
3871
+ height: (0,cleaners__WEBPACK_IMPORTED_MODULE_0__.asOptional)(cleaners__WEBPACK_IMPORTED_MODULE_0__.asNumber),
3877
3872
  // Block height
3878
3873
  id: cleaners__WEBPACK_IMPORTED_MODULE_0__.asNumber,
3879
3874
  // Index of tx in blockchain
@@ -3885,7 +3880,7 @@ var asGetAddressTxsResponse = (0,cleaners__WEBPACK_IMPORTED_MODULE_0__.asObject)
3885
3880
  // Bytes of tx payment id
3886
3881
  spent_outputs: (0,cleaners__WEBPACK_IMPORTED_MODULE_0__.asOptional)((0,cleaners__WEBPACK_IMPORTED_MODULE_0__.asArray)(asSpentOutput)),
3887
3882
  // List of possible spends
3888
- timestamp: cleaners__WEBPACK_IMPORTED_MODULE_0__.asString,
3883
+ timestamp: (0,cleaners__WEBPACK_IMPORTED_MODULE_0__.asOptional)(cleaners__WEBPACK_IMPORTED_MODULE_0__.asString),
3889
3884
  // Timestamp of block
3890
3885
  total_received: cleaners__WEBPACK_IMPORTED_MODULE_0__.asString,
3891
3886
  // Total XMR received
@@ -4055,7 +4050,7 @@ var MyMoneroApi = /*#__PURE__*/function () {
4055
4050
  var _createTransaction = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(keys, opts) {
4056
4051
  var _this = this;
4057
4052
 
4058
- 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;
4059
4054
 
4060
4055
  return regeneratorRuntime.wrap(function _callee5$(_context5) {
4061
4056
  while (1) {
@@ -4078,7 +4073,12 @@ var MyMoneroApi = /*#__PURE__*/function () {
4078
4073
  case 4:
4079
4074
  unspentOuts = _context5.sent;
4080
4075
 
4081
- // 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
+
4082
4082
  randomOutsCb = /*#__PURE__*/function () {
4083
4083
  var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(count) {
4084
4084
  var amounts, i;
@@ -4122,7 +4122,7 @@ var MyMoneroApi = /*#__PURE__*/function () {
4122
4122
  };
4123
4123
  }); // Make the transaction:
4124
4124
 
4125
- _context5.next = 9;
4125
+ _context5.next = 10;
4126
4126
  return this.cppBridge.createTransaction({
4127
4127
  destinations: destinations,
4128
4128
  priority: priority,
@@ -4137,10 +4137,10 @@ var MyMoneroApi = /*#__PURE__*/function () {
4137
4137
  randomOutsCb: randomOutsCb
4138
4138
  });
4139
4139
 
4140
- case 9:
4140
+ case 10:
4141
4141
  return _context5.abrupt("return", _context5.sent);
4142
4142
 
4143
- case 10:
4143
+ case 11:
4144
4144
  case "end":
4145
4145
  return _context5.stop();
4146
4146
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edge-currency-monero",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Edge Monero currency plugin",
5
5
  "homepage": "https://edge.app",
6
6
  "repository": {