@exodus/bitcoin-api 2.27.0 → 2.28.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
@@ -3,6 +3,20 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.28.0](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@2.27.0...@exodus/bitcoin-api@2.28.0) (2024-10-31)
7
+
8
+
9
+ ### Features
10
+
11
+ * update bip322-js to 2.0.0 ([#4414](https://github.com/ExodusMovement/assets/issues/4414)) ([da2a7dd](https://github.com/ExodusMovement/assets/commit/da2a7dd217a6664f02fa722968bf6ff16f53ea39))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * stringify sent amount NU's ([#4433](https://github.com/ExodusMovement/assets/issues/4433)) ([f2886a8](https://github.com/ExodusMovement/assets/commit/f2886a85060f5e347df9bb2bf892bb52257ece6b)), closes [#4437](https://github.com/ExodusMovement/assets/issues/4437)
17
+
18
+
19
+
6
20
  ## [2.27.0](https://github.com/ExodusMovement/assets/compare/@exodus/bitcoin-api@2.26.1...@exodus/bitcoin-api@2.27.0) (2024-10-17)
7
21
 
8
22
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/bitcoin-api",
3
- "version": "2.27.0",
3
+ "version": "2.28.0",
4
4
  "description": "Exodus bitcoin-api",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -23,7 +23,7 @@
23
23
  "@exodus/asset-lib": "^5.0.0",
24
24
  "@exodus/basic-utils": "^3.0.1",
25
25
  "@exodus/bip32": "^3.3.0",
26
- "@exodus/bip322-js": "^1.1.0",
26
+ "@exodus/bip322-js": "^2.0.0",
27
27
  "@exodus/bip44-constants": "^195.0.0",
28
28
  "@exodus/bitcoin-lib": "^2.4.2",
29
29
  "@exodus/bitcoinjs": "^1.1.0",
@@ -56,5 +56,5 @@
56
56
  "type": "git",
57
57
  "url": "git+https://github.com/ExodusMovement/assets.git"
58
58
  },
59
- "gitHead": "3218754fdfad087b6d789eb81f7fe9f21b636fef"
59
+ "gitHead": "65c334463a6fd913d73d2873ac455c5ec675705a"
60
60
  }
@@ -58,3 +58,11 @@ export function parseCurrency(val, currency) {
58
58
  if (typeof val === 'string') return currency.parse(val)
59
59
  return currency.parse(val.value + ' ' + val.unit)
60
60
  }
61
+
62
+ export function serializeCurrency(val, currency) {
63
+ if (val === undefined) {
64
+ return val
65
+ }
66
+
67
+ return parseCurrency(val, currency).toDefaultString({ unit: true })
68
+ }
@@ -505,7 +505,10 @@ export class BitcoinMonitorScanner {
505
505
  if (isSent && !txLogItem.to) {
506
506
  const val = currency.defaultUnit(vout.value)
507
507
  const sentDisplayAddress = asset.address.displayAddress?.(sentAddress) || sentAddress
508
- txLogItem.data.sent.push({ address: sentDisplayAddress, amount: val })
508
+ txLogItem.data.sent.push({
509
+ address: sentDisplayAddress,
510
+ amount: val.toDefaultString({ unit: true }),
511
+ })
509
512
  }
510
513
 
511
514
  return
@@ -5,7 +5,7 @@ import { retry } from '@exodus/simple-retry'
5
5
  import lodash from 'lodash'
6
6
  import assert from 'minimalistic-assert'
7
7
 
8
- import { parseCurrency } from '../fee/fee-utils.js'
8
+ import { parseCurrency, serializeCurrency } from '../fee/fee-utils.js'
9
9
  import { selectUtxos } from '../fee/utxo-selector.js'
10
10
  import { findUnconfirmedSentRbfTxs } from '../tx-utils.js'
11
11
  import { getUnconfirmedTxAncestorMap } from '../unconfirmed-ancestor-data.js'
@@ -376,7 +376,7 @@ export const getPrepareSendTransaction =
376
376
  replaceTx = replaceTx.clone()
377
377
  replaceTx = replaceTx.update({ data: { ...replaceTx.data } })
378
378
  replaceTx.data.sent = replaceTx.data.sent.map((to) => {
379
- return { ...to, amount: parseCurrency(to.amount, asset.currency) }
379
+ return { ...to, amount: serializeCurrency(to.amount, asset.currency) }
380
380
  })
381
381
  selectedUtxos = selectedUtxos.union(
382
382
  // how to avoid replace tx inputs when inputs are ordinals? !!!!
@@ -389,7 +389,9 @@ export const getPrepareSendTransaction =
389
389
  // Inputs and Outputs
390
390
  const inputs = shuffle(createInputs(assetName, selectedUtxos.toArray(), rbfEnabled))
391
391
  let outputs = replaceTx
392
- ? replaceTx.data.sent.map(({ address, amount }) => createOutput(assetName, address, amount))
392
+ ? replaceTx.data.sent.map(({ address, amount }) =>
393
+ createOutput(assetName, address, parseCurrency(amount, currency))
394
+ )
393
395
  : []
394
396
 
395
397
  // Send output
@@ -408,7 +410,10 @@ export const getPrepareSendTransaction =
408
410
  }
409
411
 
410
412
  const totalAmount = replaceTx
411
- ? replaceTx.data.sent.reduce((total, { amount }) => total.add(amount), sendAmount)
413
+ ? replaceTx.data.sent.reduce(
414
+ (total, { amount }) => total.add(parseCurrency(amount, asset.currency)),
415
+ sendAmount
416
+ )
412
417
  : sendAmount
413
418
 
414
419
  const change = selectedUtxos.value
@@ -655,8 +660,11 @@ export const createAndBroadcastTXFactory =
655
660
  ? replaceTx.data.sent
656
661
  : []
657
662
  : replaceTx
658
- ? [...replaceTx.data.sent, { address: displayReceiveAddress, amount }]
659
- : [{ address: displayReceiveAddress, amount }]
663
+ ? [
664
+ ...replaceTx.data.sent,
665
+ { address: displayReceiveAddress, amount: serializeCurrency(amount, asset.currency) },
666
+ ]
667
+ : [{ address: displayReceiveAddress, amount: serializeCurrency(amount, asset.currency) }]
660
668
 
661
669
  const calculateCoinAmount = () => {
662
670
  if (selfSend) {