@bitpay-labs/bitcore-wallet-service 11.5.2
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/.coveralls.yml +1 -0
- package/.travis.yml +27 -0
- package/DKG-flow.png +0 -0
- package/DSG-flow.png +0 -0
- package/Dockerfile +18 -0
- package/Installation.md +138 -0
- package/LICENCE +22 -0
- package/Makefile +5 -0
- package/README.md +429 -0
- package/TSS.md +136 -0
- package/bws.example.config.js +451 -0
- package/package.json +119 -0
- package/scripts/checkCopayerIds.js +118 -0
- package/scripts/clean_db.mongodb +5 -0
- package/scripts/deleteDupAddresses.mongo +6 -0
- package/scripts/deleteWallet.mongo +18 -0
- package/scripts/delme.ts +468 -0
- package/scripts/findEmail.js +32 -0
- package/scripts/fixAddressType.js +98 -0
- package/scripts/getSolStats2.js +81 -0
- package/scripts/migrateToNamedTestnets.js +191 -0
- package/scripts/migrateWalletsNetwork.js +204 -0
- package/scripts/preview-email.js +359 -0
- package/scripts/purgeNotifications.js +107 -0
- package/scripts/resetV8registration.mongo +21 -0
- package/scripts/v8tool-list.ts +93 -0
- package/scripts/v8tool.ts +82 -0
- package/scripts/walletStats.js +290 -0
- package/src/app.ts +28 -0
- package/src/bcmonitor/bcmonitor.ts +11 -0
- package/src/bws.ts +85 -0
- package/src/cleanfiatrates/cleanfiatrates.ts +9 -0
- package/src/config.ts +540 -0
- package/src/db/.empty +0 -0
- package/src/deprecated-serverMessages.ts +15 -0
- package/src/emailservice/emailservice.ts +11 -0
- package/src/externalservices/banxa.ts +261 -0
- package/src/externalservices/changelly.ts +371 -0
- package/src/externalservices/coingecko.ts +453 -0
- package/src/externalservices/moonpay.ts +435 -0
- package/src/externalservices/oneInch.ts +169 -0
- package/src/externalservices/ramp.ts +259 -0
- package/src/externalservices/sardine.ts +237 -0
- package/src/externalservices/simplex.ts +281 -0
- package/src/externalservices/thorswap.ts +197 -0
- package/src/externalservices/transak.ts +320 -0
- package/src/externalservices/wyre.ts +131 -0
- package/src/fiatrateservice/fiatrateservice.ts +15 -0
- package/src/index.ts +9 -0
- package/src/lib/bchaddresstranslator.ts +59 -0
- package/src/lib/blockchainexplorer.ts +84 -0
- package/src/lib/blockchainexplorers/v8/client.ts +177 -0
- package/src/lib/blockchainexplorers/v8.ts +730 -0
- package/src/lib/blockchainmonitor.ts +423 -0
- package/src/lib/chain/arb/index.ts +8 -0
- package/src/lib/chain/base/index.ts +8 -0
- package/src/lib/chain/bch/index.ts +40 -0
- package/src/lib/chain/btc/index.ts +991 -0
- package/src/lib/chain/doge/index.ts +387 -0
- package/src/lib/chain/eth/abi-erc20.ts +222 -0
- package/src/lib/chain/eth/abi-invoice.ts +277 -0
- package/src/lib/chain/eth/index.ts +657 -0
- package/src/lib/chain/index.ts +178 -0
- package/src/lib/chain/ltc/index.ts +9 -0
- package/src/lib/chain/matic/index.ts +8 -0
- package/src/lib/chain/op/index.ts +8 -0
- package/src/lib/chain/sol/index.ts +349 -0
- package/src/lib/chain/xrp/index.ts +338 -0
- package/src/lib/cleanfiatrates.ts +160 -0
- package/src/lib/common/constants.ts +231 -0
- package/src/lib/common/defaults.ts +436 -0
- package/src/lib/common/index.ts +11 -0
- package/src/lib/common/services.ts +43 -0
- package/src/lib/common/utils.ts +506 -0
- package/src/lib/emailservice.ts +741 -0
- package/src/lib/errors/clienterror.ts +44 -0
- package/src/lib/errors/errordefinitions.ts +158 -0
- package/src/lib/expressapp.ts +2415 -0
- package/src/lib/fiatrateproviders/bitpay.ts +20 -0
- package/src/lib/fiatrateproviders/bitstamp.ts +16 -0
- package/src/lib/fiatrateproviders/index.ts +8 -0
- package/src/lib/fiatrateproviders/provider.d.ts +10 -0
- package/src/lib/fiatrateservice.ts +338 -0
- package/src/lib/iconsconfig.ts +31 -0
- package/src/lib/index.ts +0 -0
- package/src/lib/lock.ts +112 -0
- package/src/lib/logger.ts +77 -0
- package/src/lib/messagebroker.ts +42 -0
- package/src/lib/model/address.ts +226 -0
- package/src/lib/model/addressmanager.ts +138 -0
- package/src/lib/model/advertisement.ts +84 -0
- package/src/lib/model/copayer.ts +162 -0
- package/src/lib/model/email.ts +103 -0
- package/src/lib/model/index.ts +12 -0
- package/src/lib/model/notification.ts +77 -0
- package/src/lib/model/preferences.ts +79 -0
- package/src/lib/model/pushnotificationsub.ts +50 -0
- package/src/lib/model/session.ts +65 -0
- package/src/lib/model/tsskeygen.ts +154 -0
- package/src/lib/model/tsssign.ts +136 -0
- package/src/lib/model/txconfirmationsub.ts +50 -0
- package/src/lib/model/txnote.ts +60 -0
- package/src/lib/model/txproposal.ts +561 -0
- package/src/lib/model/txproposal_legacy.ts +236 -0
- package/src/lib/model/txproposalaction.ts +48 -0
- package/src/lib/model/wallet.ts +359 -0
- package/src/lib/notificationbroadcaster.ts +17 -0
- package/src/lib/pushnotificationsservice.ts +802 -0
- package/src/lib/routes/helpers/error.ts +51 -0
- package/src/lib/routes/helpers/index.ts +1 -0
- package/src/lib/routes/middleware/authRequest.ts +117 -0
- package/src/lib/routes/middleware/authTssRequest.ts +66 -0
- package/src/lib/routes/middleware/createWalletLimiter.ts +21 -0
- package/src/lib/routes/middleware/log.ts +63 -0
- package/src/lib/routes/middleware/verifyTssMessage.ts +37 -0
- package/src/lib/routes/tss.ts +123 -0
- package/src/lib/server.ts +5342 -0
- package/src/lib/stats.ts +174 -0
- package/src/lib/storage.ts +1919 -0
- package/src/lib/tss.ts +446 -0
- package/src/lib/updatestats.ts +291 -0
- package/src/messagebroker/messagebroker.ts +18 -0
- package/src/pushnotificationsservice/pushnotificationsservice.ts +11 -0
- package/src/serverMessages.ts +30 -0
- package/src/types/chain.d.ts +62 -0
- package/src/types/emailservice.d.ts +11 -0
- package/src/types/expressapp.d.ts +15 -0
- package/src/types/externalservices.d.ts +41 -0
- package/src/types/notifications.d.ts +8 -0
- package/src/types/pushnotificationservice.d.ts +51 -0
- package/src/types/server.d.ts +24 -0
- package/src/updatestats/updatestats.ts +10 -0
- package/start-docker.sh +18 -0
- package/start.sh +38 -0
- package/static/images/down-arrow-green.png +0 -0
- package/static/images/failed-icon.png +0 -0
- package/static/images/green-check.png +0 -0
- package/static/images/person-plus.png +0 -0
- package/static/images/up-arrow-gray.png +0 -0
- package/static/images/writing-gray.png +0 -0
- package/stop.sh +19 -0
- package/templates/en/new_copayer.html +13 -0
- package/templates/en/new_copayer.plain +2 -0
- package/templates/en/new_incoming_tx.html +11 -0
- package/templates/en/new_incoming_tx.plain +2 -0
- package/templates/en/new_incoming_tx_testnet.html +13 -0
- package/templates/en/new_incoming_tx_testnet.plain +2 -0
- package/templates/en/new_outgoing_tx.html +11 -0
- package/templates/en/new_outgoing_tx.plain +2 -0
- package/templates/en/new_tx_proposal.html +13 -0
- package/templates/en/new_tx_proposal.plain +2 -0
- package/templates/en/new_zero_outgoing_tx.html +13 -0
- package/templates/en/new_zero_outgoing_tx.plain +2 -0
- package/templates/en/tx_confirmation.html +13 -0
- package/templates/en/tx_confirmation.plain +2 -0
- package/templates/en/tx_confirmation_receiver.html +13 -0
- package/templates/en/tx_confirmation_receiver.plain +2 -0
- package/templates/en/tx_confirmation_sender.html +13 -0
- package/templates/en/tx_confirmation_sender.plain +2 -0
- package/templates/en/txp_finally_rejected.html +13 -0
- package/templates/en/txp_finally_rejected.plain +2 -0
- package/templates/en/wallet_complete.html +13 -0
- package/templates/en/wallet_complete.plain +2 -0
- package/templates/es/new_copayer.html +13 -0
- package/templates/es/new_copayer.plain +2 -0
- package/templates/es/new_incoming_tx.html +11 -0
- package/templates/es/new_incoming_tx.plain +2 -0
- package/templates/es/new_incoming_tx_testnet.html +13 -0
- package/templates/es/new_incoming_tx_testnet.plain +2 -0
- package/templates/es/new_outgoing_tx.html +11 -0
- package/templates/es/new_outgoing_tx.plain +2 -0
- package/templates/es/new_tx_proposal.html +13 -0
- package/templates/es/new_tx_proposal.plain +2 -0
- package/templates/es/new_zero_outgoing_tx.html +13 -0
- package/templates/es/new_zero_outgoing_tx.plain +2 -0
- package/templates/es/tx_confirmation.html +13 -0
- package/templates/es/tx_confirmation.plain +2 -0
- package/templates/es/tx_confirmation_receiver.html +13 -0
- package/templates/es/tx_confirmation_receiver.plain +2 -0
- package/templates/es/tx_confirmation_sender.html +13 -0
- package/templates/es/tx_confirmation_sender.plain +2 -0
- package/templates/es/txp_finally_rejected.html +13 -0
- package/templates/es/txp_finally_rejected.plain +2 -0
- package/templates/es/wallet_complete.html +13 -0
- package/templates/es/wallet_complete.plain +2 -0
- package/templates/fr/new_copayer.html +13 -0
- package/templates/fr/new_copayer.plain +2 -0
- package/templates/fr/new_incoming_tx.html +11 -0
- package/templates/fr/new_incoming_tx.plain +2 -0
- package/templates/fr/new_incoming_tx_testnet.html +13 -0
- package/templates/fr/new_incoming_tx_testnet.plain +2 -0
- package/templates/fr/new_outgoing_tx.html +11 -0
- package/templates/fr/new_outgoing_tx.plain +2 -0
- package/templates/fr/new_tx_proposal.html +13 -0
- package/templates/fr/new_tx_proposal.plain +2 -0
- package/templates/fr/new_zero_outgoing_tx.html +13 -0
- package/templates/fr/new_zero_outgoing_tx.plain +2 -0
- package/templates/fr/tx_confirmation.html +13 -0
- package/templates/fr/tx_confirmation.plain +2 -0
- package/templates/fr/tx_confirmation_receiver.html +13 -0
- package/templates/fr/tx_confirmation_receiver.plain +2 -0
- package/templates/fr/tx_confirmation_sender.html +13 -0
- package/templates/fr/tx_confirmation_sender.plain +2 -0
- package/templates/fr/txp_finally_rejected.html +13 -0
- package/templates/fr/txp_finally_rejected.plain +2 -0
- package/templates/fr/wallet_complete.html +13 -0
- package/templates/fr/wallet_complete.plain +2 -0
- package/templates/ja/new_copayer.html +13 -0
- package/templates/ja/new_copayer.plain +2 -0
- package/templates/ja/new_incoming_tx.html +11 -0
- package/templates/ja/new_incoming_tx.plain +2 -0
- package/templates/ja/new_incoming_tx_testnet.html +13 -0
- package/templates/ja/new_incoming_tx_testnet.plain +2 -0
- package/templates/ja/new_outgoing_tx.html +11 -0
- package/templates/ja/new_outgoing_tx.plain +2 -0
- package/templates/ja/new_tx_proposal.html +13 -0
- package/templates/ja/new_tx_proposal.plain +2 -0
- package/templates/ja/new_zero_outgoing_tx.html +13 -0
- package/templates/ja/new_zero_outgoing_tx.plain +2 -0
- package/templates/ja/tx_confirmation.html +13 -0
- package/templates/ja/tx_confirmation.plain +2 -0
- package/templates/ja/tx_confirmation_receiver.html +13 -0
- package/templates/ja/tx_confirmation_receiver.plain +2 -0
- package/templates/ja/tx_confirmation_sender.html +13 -0
- package/templates/ja/tx_confirmation_sender.plain +2 -0
- package/templates/ja/txp_finally_rejected.html +13 -0
- package/templates/ja/txp_finally_rejected.plain +2 -0
- package/templates/ja/wallet_complete.html +13 -0
- package/templates/ja/wallet_complete.plain +2 -0
- package/templates/master-template.html +494 -0
- package/test/bchaddresstranslator.test.ts +50 -0
- package/test/blockchainexplorer.test.ts +66 -0
- package/test/chain/bch.test.ts +115 -0
- package/test/chain/btc.test.ts +331 -0
- package/test/chain/doge.test.ts +347 -0
- package/test/chain/eth.test.ts +21 -0
- package/test/chain/ltc.test.ts +328 -0
- package/test/chain/matic.test.ts +21 -0
- package/test/chain/xrp.test.ts +206 -0
- package/test/expressapp.test.ts +513 -0
- package/test/integration/bcmonitor.test.ts +381 -0
- package/test/integration/cashAddrMigration.test.ts +127 -0
- package/test/integration/data/tss/2of3/index.ts +3 -0
- package/test/integration/data/tss/2of3/party0.key.ts +5 -0
- package/test/integration/data/tss/2of3/party1.key.ts +5 -0
- package/test/integration/data/tss/2of3/party2.key.ts +5 -0
- package/test/integration/emailnotifications.test.ts +864 -0
- package/test/integration/externalservices/banxa.test.ts +373 -0
- package/test/integration/externalservices/changelly.test.ts +515 -0
- package/test/integration/externalservices/coinGecko.test.ts +284 -0
- package/test/integration/externalservices/moonpay.test.ts +569 -0
- package/test/integration/externalservices/oneInch.test.ts +162 -0
- package/test/integration/externalservices/ramp.test.ts +475 -0
- package/test/integration/externalservices/sardine.test.ts +352 -0
- package/test/integration/externalservices/simplex.test.ts +384 -0
- package/test/integration/externalservices/thorswap.test.ts +309 -0
- package/test/integration/externalservices/transak.test.ts +410 -0
- package/test/integration/externalservices/wyre.test.ts +270 -0
- package/test/integration/fiatrateservice.test.ts +979 -0
- package/test/integration/helpers.ts +694 -0
- package/test/integration/history.test.ts +1142 -0
- package/test/integration/hugetx.ts +6986 -0
- package/test/integration/pushNotifications.test.ts +1523 -0
- package/test/integration/server.test.ts +10740 -0
- package/test/integration/tss.test.ts +340 -0
- package/test/lock.test.ts +224 -0
- package/test/model/address.test.ts +187 -0
- package/test/model/addressmanager.test.ts +146 -0
- package/test/model/advertisement.test.ts +31 -0
- package/test/model/copayer.test.ts +131 -0
- package/test/model/txproposal.test.ts +185 -0
- package/test/model/wallet.test.ts +191 -0
- package/test/storage.test.ts +430 -0
- package/test/test-config.ts +12 -0
- package/test/testdata.ts +388 -0
- package/test/utils.test.ts +457 -0
- package/test/v8.test.ts +332 -0
- package/ts_build/package.json +119 -0
- package/ts_build/scripts/delme.d.ts +2 -0
- package/ts_build/scripts/delme.d.ts.map +1 -0
- package/ts_build/scripts/delme.js +453 -0
- package/ts_build/scripts/delme.js.map +1 -0
- package/ts_build/scripts/v8tool-list.d.ts +3 -0
- package/ts_build/scripts/v8tool-list.d.ts.map +1 -0
- package/ts_build/scripts/v8tool-list.js +80 -0
- package/ts_build/scripts/v8tool-list.js.map +1 -0
- package/ts_build/scripts/v8tool.d.ts +3 -0
- package/ts_build/scripts/v8tool.d.ts.map +1 -0
- package/ts_build/scripts/v8tool.js +69 -0
- package/ts_build/scripts/v8tool.js.map +1 -0
- package/ts_build/src/app.d.ts +3 -0
- package/ts_build/src/app.d.ts.map +1 -0
- package/ts_build/src/app.js +29 -0
- package/ts_build/src/app.js.map +1 -0
- package/ts_build/src/bcmonitor/bcmonitor.d.ts +3 -0
- package/ts_build/src/bcmonitor/bcmonitor.d.ts.map +1 -0
- package/ts_build/src/bcmonitor/bcmonitor.js +16 -0
- package/ts_build/src/bcmonitor/bcmonitor.js.map +1 -0
- package/ts_build/src/bws.d.ts +3 -0
- package/ts_build/src/bws.d.ts.map +1 -0
- package/ts_build/src/bws.js +98 -0
- package/ts_build/src/bws.js.map +1 -0
- package/ts_build/src/cleanfiatrates/cleanfiatrates.d.ts +3 -0
- package/ts_build/src/cleanfiatrates/cleanfiatrates.d.ts.map +1 -0
- package/ts_build/src/cleanfiatrates/cleanfiatrates.js +11 -0
- package/ts_build/src/cleanfiatrates/cleanfiatrates.js.map +1 -0
- package/ts_build/src/config.d.ts +3 -0
- package/ts_build/src/config.d.ts.map +1 -0
- package/ts_build/src/config.js +256 -0
- package/ts_build/src/config.js.map +1 -0
- package/ts_build/src/deprecated-serverMessages.d.ts +10 -0
- package/ts_build/src/deprecated-serverMessages.d.ts.map +1 -0
- package/ts_build/src/deprecated-serverMessages.js +20 -0
- package/ts_build/src/deprecated-serverMessages.js.map +1 -0
- package/ts_build/src/emailservice/emailservice.d.ts +3 -0
- package/ts_build/src/emailservice/emailservice.d.ts.map +1 -0
- package/ts_build/src/emailservice/emailservice.js +16 -0
- package/ts_build/src/emailservice/emailservice.js.map +1 -0
- package/ts_build/src/externalservices/banxa.d.ts +11 -0
- package/ts_build/src/externalservices/banxa.d.ts.map +1 -0
- package/ts_build/src/externalservices/banxa.js +254 -0
- package/ts_build/src/externalservices/banxa.js.map +1 -0
- package/ts_build/src/externalservices/changelly.d.ts +18 -0
- package/ts_build/src/externalservices/changelly.d.ts.map +1 -0
- package/ts_build/src/externalservices/changelly.js +356 -0
- package/ts_build/src/externalservices/changelly.js.map +1 -0
- package/ts_build/src/externalservices/coingecko.d.ts +43 -0
- package/ts_build/src/externalservices/coingecko.d.ts.map +1 -0
- package/ts_build/src/externalservices/coingecko.js +416 -0
- package/ts_build/src/externalservices/coingecko.js.map +1 -0
- package/ts_build/src/externalservices/moonpay.d.ts +19 -0
- package/ts_build/src/externalservices/moonpay.d.ts.map +1 -0
- package/ts_build/src/externalservices/moonpay.js +397 -0
- package/ts_build/src/externalservices/moonpay.js.map +1 -0
- package/ts_build/src/externalservices/oneInch.d.ts +11 -0
- package/ts_build/src/externalservices/oneInch.d.ts.map +1 -0
- package/ts_build/src/externalservices/oneInch.js +179 -0
- package/ts_build/src/externalservices/oneInch.js.map +1 -0
- package/ts_build/src/externalservices/ramp.d.ts +12 -0
- package/ts_build/src/externalservices/ramp.d.ts.map +1 -0
- package/ts_build/src/externalservices/ramp.js +256 -0
- package/ts_build/src/externalservices/ramp.js.map +1 -0
- package/ts_build/src/externalservices/sardine.d.ts +10 -0
- package/ts_build/src/externalservices/sardine.d.ts.map +1 -0
- package/ts_build/src/externalservices/sardine.js +232 -0
- package/ts_build/src/externalservices/sardine.js.map +1 -0
- package/ts_build/src/externalservices/simplex.d.ts +11 -0
- package/ts_build/src/externalservices/simplex.d.ts.map +1 -0
- package/ts_build/src/externalservices/simplex.js +261 -0
- package/ts_build/src/externalservices/simplex.js.map +1 -0
- package/ts_build/src/externalservices/thorswap.d.ts +9 -0
- package/ts_build/src/externalservices/thorswap.d.ts.map +1 -0
- package/ts_build/src/externalservices/thorswap.js +206 -0
- package/ts_build/src/externalservices/thorswap.js.map +1 -0
- package/ts_build/src/externalservices/transak.d.ts +13 -0
- package/ts_build/src/externalservices/transak.d.ts.map +1 -0
- package/ts_build/src/externalservices/transak.js +311 -0
- package/ts_build/src/externalservices/transak.js.map +1 -0
- package/ts_build/src/externalservices/wyre.d.ts +7 -0
- package/ts_build/src/externalservices/wyre.d.ts.map +1 -0
- package/ts_build/src/externalservices/wyre.js +144 -0
- package/ts_build/src/externalservices/wyre.js.map +1 -0
- package/ts_build/src/fiatrateservice/fiatrateservice.d.ts +3 -0
- package/ts_build/src/fiatrateservice/fiatrateservice.d.ts.map +1 -0
- package/ts_build/src/fiatrateservice/fiatrateservice.js +20 -0
- package/ts_build/src/fiatrateservice/fiatrateservice.js.map +1 -0
- package/ts_build/src/index.d.ts +8 -0
- package/ts_build/src/index.d.ts.map +1 -0
- package/ts_build/src/index.js +11 -0
- package/ts_build/src/index.js.map +1 -0
- package/ts_build/src/lib/bchaddresstranslator.d.ts +5 -0
- package/ts_build/src/lib/bchaddresstranslator.d.ts.map +1 -0
- package/ts_build/src/lib/bchaddresstranslator.js +66 -0
- package/ts_build/src/lib/bchaddresstranslator.js.map +1 -0
- package/ts_build/src/lib/blockchainexplorer.d.ts +3 -0
- package/ts_build/src/lib/blockchainexplorer.d.ts.map +1 -0
- package/ts_build/src/lib/blockchainexplorer.js +87 -0
- package/ts_build/src/lib/blockchainexplorer.js.map +1 -0
- package/ts_build/src/lib/blockchainexplorers/v8/client.d.ts +31 -0
- package/ts_build/src/lib/blockchainexplorers/v8/client.d.ts.map +1 -0
- package/ts_build/src/lib/blockchainexplorers/v8/client.js +191 -0
- package/ts_build/src/lib/blockchainexplorers/v8/client.js.map +1 -0
- package/ts_build/src/lib/blockchainexplorers/v8.d.ts +91 -0
- package/ts_build/src/lib/blockchainexplorers/v8.d.ts.map +1 -0
- package/ts_build/src/lib/blockchainexplorers/v8.js +662 -0
- package/ts_build/src/lib/blockchainexplorers/v8.js.map +1 -0
- package/ts_build/src/lib/blockchainmonitor.d.ts +32 -0
- package/ts_build/src/lib/blockchainmonitor.d.ts.map +1 -0
- package/ts_build/src/lib/blockchainmonitor.js +413 -0
- package/ts_build/src/lib/blockchainmonitor.js.map +1 -0
- package/ts_build/src/lib/chain/arb/index.d.ts +5 -0
- package/ts_build/src/lib/chain/arb/index.d.ts.map +1 -0
- package/ts_build/src/lib/chain/arb/index.js +12 -0
- package/ts_build/src/lib/chain/arb/index.js.map +1 -0
- package/ts_build/src/lib/chain/base/index.d.ts +5 -0
- package/ts_build/src/lib/chain/base/index.d.ts.map +1 -0
- package/ts_build/src/lib/chain/base/index.js +12 -0
- package/ts_build/src/lib/chain/base/index.js.map +1 -0
- package/ts_build/src/lib/chain/bch/index.d.ts +9 -0
- package/ts_build/src/lib/chain/bch/index.d.ts.map +1 -0
- package/ts_build/src/lib/chain/bch/index.js +43 -0
- package/ts_build/src/lib/chain/bch/index.js.map +1 -0
- package/ts_build/src/lib/chain/btc/index.d.ts +65 -0
- package/ts_build/src/lib/chain/btc/index.d.ts.map +1 -0
- package/ts_build/src/lib/chain/btc/index.js +829 -0
- package/ts_build/src/lib/chain/btc/index.js.map +1 -0
- package/ts_build/src/lib/chain/doge/index.d.ts +9 -0
- package/ts_build/src/lib/chain/doge/index.d.ts.map +1 -0
- package/ts_build/src/lib/chain/doge/index.js +338 -0
- package/ts_build/src/lib/chain/doge/index.js.map +1 -0
- package/ts_build/src/lib/chain/eth/abi-erc20.d.ts +39 -0
- package/ts_build/src/lib/chain/eth/abi-erc20.d.ts.map +1 -0
- package/ts_build/src/lib/chain/eth/abi-erc20.js +226 -0
- package/ts_build/src/lib/chain/eth/abi-erc20.js.map +1 -0
- package/ts_build/src/lib/chain/eth/abi-invoice.d.ts +42 -0
- package/ts_build/src/lib/chain/eth/abi-invoice.d.ts.map +1 -0
- package/ts_build/src/lib/chain/eth/abi-invoice.js +281 -0
- package/ts_build/src/lib/chain/eth/abi-invoice.js.map +1 -0
- package/ts_build/src/lib/chain/eth/index.d.ts +66 -0
- package/ts_build/src/lib/chain/eth/index.d.ts.map +1 -0
- package/ts_build/src/lib/chain/eth/index.js +516 -0
- package/ts_build/src/lib/chain/eth/index.js.map +1 -0
- package/ts_build/src/lib/chain/index.d.ts +40 -0
- package/ts_build/src/lib/chain/index.d.ts.map +1 -0
- package/ts_build/src/lib/chain/index.js +143 -0
- package/ts_build/src/lib/chain/index.js.map +1 -0
- package/ts_build/src/lib/chain/ltc/index.d.ts +6 -0
- package/ts_build/src/lib/chain/ltc/index.d.ts.map +1 -0
- package/ts_build/src/lib/chain/ltc/index.js +12 -0
- package/ts_build/src/lib/chain/ltc/index.js.map +1 -0
- package/ts_build/src/lib/chain/matic/index.d.ts +5 -0
- package/ts_build/src/lib/chain/matic/index.d.ts.map +1 -0
- package/ts_build/src/lib/chain/matic/index.js +12 -0
- package/ts_build/src/lib/chain/matic/index.js.map +1 -0
- package/ts_build/src/lib/chain/op/index.d.ts +5 -0
- package/ts_build/src/lib/chain/op/index.d.ts.map +1 -0
- package/ts_build/src/lib/chain/op/index.js +12 -0
- package/ts_build/src/lib/chain/op/index.js.map +1 -0
- package/ts_build/src/lib/chain/sol/index.d.ts +52 -0
- package/ts_build/src/lib/chain/sol/index.d.ts.map +1 -0
- package/ts_build/src/lib/chain/sol/index.js +305 -0
- package/ts_build/src/lib/chain/sol/index.js.map +1 -0
- package/ts_build/src/lib/chain/xrp/index.d.ts +46 -0
- package/ts_build/src/lib/chain/xrp/index.d.ts.map +1 -0
- package/ts_build/src/lib/chain/xrp/index.js +300 -0
- package/ts_build/src/lib/chain/xrp/index.js.map +1 -0
- package/ts_build/src/lib/cleanfiatrates.d.ts +13 -0
- package/ts_build/src/lib/cleanfiatrates.d.ts.map +1 -0
- package/ts_build/src/lib/cleanfiatrates.js +176 -0
- package/ts_build/src/lib/cleanfiatrates.js.map +1 -0
- package/ts_build/src/lib/common/constants.d.ts +387 -0
- package/ts_build/src/lib/common/constants.d.ts.map +1 -0
- package/ts_build/src/lib/common/constants.js +234 -0
- package/ts_build/src/lib/common/constants.js.map +1 -0
- package/ts_build/src/lib/common/defaults.d.ts +326 -0
- package/ts_build/src/lib/common/defaults.d.ts.map +1 -0
- package/ts_build/src/lib/common/defaults.js +356 -0
- package/ts_build/src/lib/common/defaults.js.map +1 -0
- package/ts_build/src/lib/common/index.d.ts +793 -0
- package/ts_build/src/lib/common/index.d.ts.map +1 -0
- package/ts_build/src/lib/common/index.js +14 -0
- package/ts_build/src/lib/common/index.js.map +1 -0
- package/ts_build/src/lib/common/services.d.ts +34 -0
- package/ts_build/src/lib/common/services.d.ts.map +1 -0
- package/ts_build/src/lib/common/services.js +44 -0
- package/ts_build/src/lib/common/services.js.map +1 -0
- package/ts_build/src/lib/common/utils.d.ts +47 -0
- package/ts_build/src/lib/common/utils.d.ts.map +1 -0
- package/ts_build/src/lib/common/utils.js +385 -0
- package/ts_build/src/lib/common/utils.js.map +1 -0
- package/ts_build/src/lib/emailservice.d.ts +62 -0
- package/ts_build/src/lib/emailservice.d.ts.map +1 -0
- package/ts_build/src/lib/emailservice.js +727 -0
- package/ts_build/src/lib/emailservice.js.map +1 -0
- package/ts_build/src/lib/errors/clienterror.d.ts +11 -0
- package/ts_build/src/lib/errors/clienterror.d.ts.map +1 -0
- package/ts_build/src/lib/errors/clienterror.js +46 -0
- package/ts_build/src/lib/errors/clienterror.js.map +1 -0
- package/ts_build/src/lib/errors/errordefinitions.d.ts +76 -0
- package/ts_build/src/lib/errors/errordefinitions.d.ts.map +1 -0
- package/ts_build/src/lib/errors/errordefinitions.js +82 -0
- package/ts_build/src/lib/errors/errordefinitions.js.map +1 -0
- package/ts_build/src/lib/expressapp.d.ts +8 -0
- package/ts_build/src/lib/expressapp.d.ts.map +1 -0
- package/ts_build/src/lib/expressapp.js +2221 -0
- package/ts_build/src/lib/expressapp.js.map +1 -0
- package/ts_build/src/lib/fiatrateproviders/bitpay.d.ts +3 -0
- package/ts_build/src/lib/fiatrateproviders/bitpay.d.ts.map +1 -0
- package/ts_build/src/lib/fiatrateproviders/bitpay.js +22 -0
- package/ts_build/src/lib/fiatrateproviders/bitpay.js.map +1 -0
- package/ts_build/src/lib/fiatrateproviders/bitstamp.d.ts +3 -0
- package/ts_build/src/lib/fiatrateproviders/bitstamp.d.ts.map +1 -0
- package/ts_build/src/lib/fiatrateproviders/bitstamp.js +18 -0
- package/ts_build/src/lib/fiatrateproviders/bitstamp.js.map +1 -0
- package/ts_build/src/lib/fiatrateproviders/index.d.ts +3 -0
- package/ts_build/src/lib/fiatrateproviders/index.d.ts.map +1 -0
- package/ts_build/src/lib/fiatrateproviders/index.js +8 -0
- package/ts_build/src/lib/fiatrateproviders/index.js.map +1 -0
- package/ts_build/src/lib/fiatrateservice.d.ts +18 -0
- package/ts_build/src/lib/fiatrateservice.d.ts.map +1 -0
- package/ts_build/src/lib/fiatrateservice.js +313 -0
- package/ts_build/src/lib/fiatrateservice.js.map +1 -0
- package/ts_build/src/lib/iconsconfig.d.ts +2 -0
- package/ts_build/src/lib/iconsconfig.d.ts.map +1 -0
- package/ts_build/src/lib/iconsconfig.js +31 -0
- package/ts_build/src/lib/iconsconfig.js.map +1 -0
- package/ts_build/src/lib/index.d.ts +1 -0
- package/ts_build/src/lib/index.d.ts.map +1 -0
- package/ts_build/src/lib/index.js +1 -0
- package/ts_build/src/lib/index.js.map +1 -0
- package/ts_build/src/lib/lock.d.ts +14 -0
- package/ts_build/src/lib/lock.d.ts.map +1 -0
- package/ts_build/src/lib/lock.js +55 -0
- package/ts_build/src/lib/lock.js.map +1 -0
- package/ts_build/src/lib/logger.d.ts +7 -0
- package/ts_build/src/lib/logger.d.ts.map +1 -0
- package/ts_build/src/lib/logger.js +95 -0
- package/ts_build/src/lib/logger.js.map +1 -0
- package/ts_build/src/lib/messagebroker.d.ts +11 -0
- package/ts_build/src/lib/messagebroker.d.ts.map +1 -0
- package/ts_build/src/lib/messagebroker.js +77 -0
- package/ts_build/src/lib/messagebroker.js.map +1 -0
- package/ts_build/src/lib/model/address.d.ts +47 -0
- package/ts_build/src/lib/model/address.d.ts.map +1 -0
- package/ts_build/src/lib/model/address.js +158 -0
- package/ts_build/src/lib/model/address.js.map +1 -0
- package/ts_build/src/lib/model/addressmanager.d.ts +41 -0
- package/ts_build/src/lib/model/addressmanager.d.ts.map +1 -0
- package/ts_build/src/lib/model/addressmanager.js +103 -0
- package/ts_build/src/lib/model/addressmanager.js.map +1 -0
- package/ts_build/src/lib/model/advertisement.d.ts +38 -0
- package/ts_build/src/lib/model/advertisement.d.ts.map +1 -0
- package/ts_build/src/lib/model/advertisement.js +68 -0
- package/ts_build/src/lib/model/advertisement.js.map +1 -0
- package/ts_build/src/lib/model/copayer.d.ts +48 -0
- package/ts_build/src/lib/model/copayer.d.ts.map +1 -0
- package/ts_build/src/lib/model/copayer.js +116 -0
- package/ts_build/src/lib/model/copayer.js.map +1 -0
- package/ts_build/src/lib/model/email.d.ts +23 -0
- package/ts_build/src/lib/model/email.d.ts.map +1 -0
- package/ts_build/src/lib/model/email.js +84 -0
- package/ts_build/src/lib/model/email.js.map +1 -0
- package/ts_build/src/lib/model/index.d.ts +13 -0
- package/ts_build/src/lib/model/index.d.ts.map +1 -0
- package/ts_build/src/lib/model/index.js +28 -0
- package/ts_build/src/lib/model/index.js.map +1 -0
- package/ts_build/src/lib/model/notification.d.ts +23 -0
- package/ts_build/src/lib/model/notification.d.ts.map +1 -0
- package/ts_build/src/lib/model/notification.js +40 -0
- package/ts_build/src/lib/model/notification.js.map +1 -0
- package/ts_build/src/lib/model/preferences.d.ts +37 -0
- package/ts_build/src/lib/model/preferences.d.ts.map +1 -0
- package/ts_build/src/lib/model/preferences.js +61 -0
- package/ts_build/src/lib/model/preferences.js.map +1 -0
- package/ts_build/src/lib/model/pushnotificationsub.d.ts +23 -0
- package/ts_build/src/lib/model/pushnotificationsub.d.ts.map +1 -0
- package/ts_build/src/lib/model/pushnotificationsub.js +40 -0
- package/ts_build/src/lib/model/pushnotificationsub.js.map +1 -0
- package/ts_build/src/lib/model/session.d.ts +22 -0
- package/ts_build/src/lib/model/session.d.ts.map +1 -0
- package/ts_build/src/lib/model/session.js +52 -0
- package/ts_build/src/lib/model/session.js.map +1 -0
- package/ts_build/src/lib/model/tsskeygen.d.ts +67 -0
- package/ts_build/src/lib/model/tsskeygen.d.ts.map +1 -0
- package/ts_build/src/lib/model/tsskeygen.js +69 -0
- package/ts_build/src/lib/model/tsskeygen.js.map +1 -0
- package/ts_build/src/lib/model/tsssign.d.ts +70 -0
- package/ts_build/src/lib/model/tsssign.d.ts.map +1 -0
- package/ts_build/src/lib/model/tsssign.js +54 -0
- package/ts_build/src/lib/model/tsssign.js.map +1 -0
- package/ts_build/src/lib/model/txconfirmationsub.d.ts +23 -0
- package/ts_build/src/lib/model/txconfirmationsub.d.ts.map +1 -0
- package/ts_build/src/lib/model/txconfirmationsub.js +40 -0
- package/ts_build/src/lib/model/txconfirmationsub.js.map +1 -0
- package/ts_build/src/lib/model/txnote.d.ts +23 -0
- package/ts_build/src/lib/model/txnote.d.ts.map +1 -0
- package/ts_build/src/lib/model/txnote.js +46 -0
- package/ts_build/src/lib/model/txnote.js.map +1 -0
- package/ts_build/src/lib/model/txproposal.d.ts +196 -0
- package/ts_build/src/lib/model/txproposal.d.ts.map +1 -0
- package/ts_build/src/lib/model/txproposal.js +382 -0
- package/ts_build/src/lib/model/txproposal.js.map +1 -0
- package/ts_build/src/lib/model/txproposal_legacy.d.ts +93 -0
- package/ts_build/src/lib/model/txproposal_legacy.d.ts.map +1 -0
- package/ts_build/src/lib/model/txproposal_legacy.js +185 -0
- package/ts_build/src/lib/model/txproposal_legacy.js.map +1 -0
- package/ts_build/src/lib/model/txproposalaction.d.ts +21 -0
- package/ts_build/src/lib/model/txproposalaction.d.ts.map +1 -0
- package/ts_build/src/lib/model/txproposalaction.js +37 -0
- package/ts_build/src/lib/model/txproposalaction.js.map +1 -0
- package/ts_build/src/lib/model/wallet.d.ts +110 -0
- package/ts_build/src/lib/model/wallet.d.ts.map +1 -0
- package/ts_build/src/lib/model/wallet.js +224 -0
- package/ts_build/src/lib/model/wallet.js.map +1 -0
- package/ts_build/src/lib/notificationbroadcaster.d.ts +6 -0
- package/ts_build/src/lib/notificationbroadcaster.d.ts.map +1 -0
- package/ts_build/src/lib/notificationbroadcaster.js +19 -0
- package/ts_build/src/lib/notificationbroadcaster.js.map +1 -0
- package/ts_build/src/lib/pushnotificationsservice.d.ts +56 -0
- package/ts_build/src/lib/pushnotificationsservice.d.ts.map +1 -0
- package/ts_build/src/lib/pushnotificationsservice.js +721 -0
- package/ts_build/src/lib/pushnotificationsservice.js.map +1 -0
- package/ts_build/src/lib/routes/helpers/error.d.ts +10 -0
- package/ts_build/src/lib/routes/helpers/error.d.ts.map +1 -0
- package/ts_build/src/lib/routes/helpers/error.js +54 -0
- package/ts_build/src/lib/routes/helpers/error.js.map +1 -0
- package/ts_build/src/lib/routes/helpers/index.d.ts +2 -0
- package/ts_build/src/lib/routes/helpers/index.d.ts.map +1 -0
- package/ts_build/src/lib/routes/helpers/index.js +18 -0
- package/ts_build/src/lib/routes/helpers/index.js.map +1 -0
- package/ts_build/src/lib/routes/middleware/authRequest.d.ts +6 -0
- package/ts_build/src/lib/routes/middleware/authRequest.d.ts.map +1 -0
- package/ts_build/src/lib/routes/middleware/authRequest.js +106 -0
- package/ts_build/src/lib/routes/middleware/authRequest.js.map +1 -0
- package/ts_build/src/lib/routes/middleware/authTssRequest.d.ts +3 -0
- package/ts_build/src/lib/routes/middleware/authTssRequest.d.ts.map +1 -0
- package/ts_build/src/lib/routes/middleware/authTssRequest.js +56 -0
- package/ts_build/src/lib/routes/middleware/authTssRequest.js.map +1 -0
- package/ts_build/src/lib/routes/middleware/createWalletLimiter.d.ts +4 -0
- package/ts_build/src/lib/routes/middleware/createWalletLimiter.d.ts.map +1 -0
- package/ts_build/src/lib/routes/middleware/createWalletLimiter.js +28 -0
- package/ts_build/src/lib/routes/middleware/createWalletLimiter.js.map +1 -0
- package/ts_build/src/lib/routes/middleware/log.d.ts +9 -0
- package/ts_build/src/lib/routes/middleware/log.d.ts.map +1 -0
- package/ts_build/src/lib/routes/middleware/log.js +52 -0
- package/ts_build/src/lib/routes/middleware/log.js.map +1 -0
- package/ts_build/src/lib/routes/middleware/verifyTssMessage.d.ts +2 -0
- package/ts_build/src/lib/routes/middleware/verifyTssMessage.d.ts.map +1 -0
- package/ts_build/src/lib/routes/middleware/verifyTssMessage.js +34 -0
- package/ts_build/src/lib/routes/middleware/verifyTssMessage.js.map +1 -0
- package/ts_build/src/lib/routes/tss.d.ts +14 -0
- package/ts_build/src/lib/routes/tss.d.ts.map +1 -0
- package/ts_build/src/lib/routes/tss.js +120 -0
- package/ts_build/src/lib/routes/tss.js.map +1 -0
- package/ts_build/src/lib/server.d.ts +250 -0
- package/ts_build/src/lib/server.d.ts.map +1 -0
- package/ts_build/src/lib/server.js +4115 -0
- package/ts_build/src/lib/server.js.map +1 -0
- package/ts_build/src/lib/stats.d.ts +17 -0
- package/ts_build/src/lib/stats.d.ts.map +1 -0
- package/ts_build/src/lib/stats.js +203 -0
- package/ts_build/src/lib/stats.js.map +1 -0
- package/ts_build/src/lib/storage.d.ts +163 -0
- package/ts_build/src/lib/storage.d.ts.map +1 -0
- package/ts_build/src/lib/storage.js +1513 -0
- package/ts_build/src/lib/storage.js.map +1 -0
- package/ts_build/src/lib/tss.d.ts +70 -0
- package/ts_build/src/lib/tss.d.ts.map +1 -0
- package/ts_build/src/lib/tss.js +379 -0
- package/ts_build/src/lib/tss.js.map +1 -0
- package/ts_build/src/lib/updatestats.d.ts +16 -0
- package/ts_build/src/lib/updatestats.d.ts.map +1 -0
- package/ts_build/src/lib/updatestats.js +308 -0
- package/ts_build/src/lib/updatestats.js.map +1 -0
- package/ts_build/src/messagebroker/messagebroker.d.ts +3 -0
- package/ts_build/src/messagebroker/messagebroker.d.ts.map +1 -0
- package/ts_build/src/messagebroker/messagebroker.js +20 -0
- package/ts_build/src/messagebroker/messagebroker.js.map +1 -0
- package/ts_build/src/pushnotificationsservice/pushnotificationsservice.d.ts +3 -0
- package/ts_build/src/pushnotificationsservice/pushnotificationsservice.d.ts.map +1 -0
- package/ts_build/src/pushnotificationsservice/pushnotificationsservice.js +16 -0
- package/ts_build/src/pushnotificationsservice/pushnotificationsservice.js.map +1 -0
- package/ts_build/src/serverMessages.d.ts +2 -0
- package/ts_build/src/serverMessages.d.ts.map +1 -0
- package/ts_build/src/serverMessages.js +35 -0
- package/ts_build/src/serverMessages.js.map +1 -0
- package/ts_build/src/updatestats/updatestats.d.ts +3 -0
- package/ts_build/src/updatestats/updatestats.d.ts.map +1 -0
- package/ts_build/src/updatestats/updatestats.js +15 -0
- package/ts_build/src/updatestats/updatestats.js.map +1 -0
- package/ts_build/templates/en/new_copayer.html +13 -0
- package/ts_build/templates/en/new_copayer.plain +2 -0
- package/ts_build/templates/en/new_incoming_tx.html +11 -0
- package/ts_build/templates/en/new_incoming_tx.plain +2 -0
- package/ts_build/templates/en/new_incoming_tx_testnet.html +13 -0
- package/ts_build/templates/en/new_incoming_tx_testnet.plain +2 -0
- package/ts_build/templates/en/new_outgoing_tx.html +11 -0
- package/ts_build/templates/en/new_outgoing_tx.plain +2 -0
- package/ts_build/templates/en/new_tx_proposal.html +13 -0
- package/ts_build/templates/en/new_tx_proposal.plain +2 -0
- package/ts_build/templates/en/new_zero_outgoing_tx.html +13 -0
- package/ts_build/templates/en/new_zero_outgoing_tx.plain +2 -0
- package/ts_build/templates/en/tx_confirmation.html +13 -0
- package/ts_build/templates/en/tx_confirmation.plain +2 -0
- package/ts_build/templates/en/tx_confirmation_receiver.html +13 -0
- package/ts_build/templates/en/tx_confirmation_receiver.plain +2 -0
- package/ts_build/templates/en/tx_confirmation_sender.html +13 -0
- package/ts_build/templates/en/tx_confirmation_sender.plain +2 -0
- package/ts_build/templates/en/txp_finally_rejected.html +13 -0
- package/ts_build/templates/en/txp_finally_rejected.plain +2 -0
- package/ts_build/templates/en/wallet_complete.html +13 -0
- package/ts_build/templates/en/wallet_complete.plain +2 -0
- package/ts_build/templates/es/new_copayer.html +13 -0
- package/ts_build/templates/es/new_copayer.plain +2 -0
- package/ts_build/templates/es/new_incoming_tx.html +11 -0
- package/ts_build/templates/es/new_incoming_tx.plain +2 -0
- package/ts_build/templates/es/new_incoming_tx_testnet.html +13 -0
- package/ts_build/templates/es/new_incoming_tx_testnet.plain +2 -0
- package/ts_build/templates/es/new_outgoing_tx.html +11 -0
- package/ts_build/templates/es/new_outgoing_tx.plain +2 -0
- package/ts_build/templates/es/new_tx_proposal.html +13 -0
- package/ts_build/templates/es/new_tx_proposal.plain +2 -0
- package/ts_build/templates/es/new_zero_outgoing_tx.html +13 -0
- package/ts_build/templates/es/new_zero_outgoing_tx.plain +2 -0
- package/ts_build/templates/es/tx_confirmation.html +13 -0
- package/ts_build/templates/es/tx_confirmation.plain +2 -0
- package/ts_build/templates/es/tx_confirmation_receiver.html +13 -0
- package/ts_build/templates/es/tx_confirmation_receiver.plain +2 -0
- package/ts_build/templates/es/tx_confirmation_sender.html +13 -0
- package/ts_build/templates/es/tx_confirmation_sender.plain +2 -0
- package/ts_build/templates/es/txp_finally_rejected.html +13 -0
- package/ts_build/templates/es/txp_finally_rejected.plain +2 -0
- package/ts_build/templates/es/wallet_complete.html +13 -0
- package/ts_build/templates/es/wallet_complete.plain +2 -0
- package/ts_build/templates/fr/new_copayer.html +13 -0
- package/ts_build/templates/fr/new_copayer.plain +2 -0
- package/ts_build/templates/fr/new_incoming_tx.html +11 -0
- package/ts_build/templates/fr/new_incoming_tx.plain +2 -0
- package/ts_build/templates/fr/new_incoming_tx_testnet.html +13 -0
- package/ts_build/templates/fr/new_incoming_tx_testnet.plain +2 -0
- package/ts_build/templates/fr/new_outgoing_tx.html +11 -0
- package/ts_build/templates/fr/new_outgoing_tx.plain +2 -0
- package/ts_build/templates/fr/new_tx_proposal.html +13 -0
- package/ts_build/templates/fr/new_tx_proposal.plain +2 -0
- package/ts_build/templates/fr/new_zero_outgoing_tx.html +13 -0
- package/ts_build/templates/fr/new_zero_outgoing_tx.plain +2 -0
- package/ts_build/templates/fr/tx_confirmation.html +13 -0
- package/ts_build/templates/fr/tx_confirmation.plain +2 -0
- package/ts_build/templates/fr/tx_confirmation_receiver.html +13 -0
- package/ts_build/templates/fr/tx_confirmation_receiver.plain +2 -0
- package/ts_build/templates/fr/tx_confirmation_sender.html +13 -0
- package/ts_build/templates/fr/tx_confirmation_sender.plain +2 -0
- package/ts_build/templates/fr/txp_finally_rejected.html +13 -0
- package/ts_build/templates/fr/txp_finally_rejected.plain +2 -0
- package/ts_build/templates/fr/wallet_complete.html +13 -0
- package/ts_build/templates/fr/wallet_complete.plain +2 -0
- package/ts_build/templates/ja/new_copayer.html +13 -0
- package/ts_build/templates/ja/new_copayer.plain +2 -0
- package/ts_build/templates/ja/new_incoming_tx.html +11 -0
- package/ts_build/templates/ja/new_incoming_tx.plain +2 -0
- package/ts_build/templates/ja/new_incoming_tx_testnet.html +13 -0
- package/ts_build/templates/ja/new_incoming_tx_testnet.plain +2 -0
- package/ts_build/templates/ja/new_outgoing_tx.html +11 -0
- package/ts_build/templates/ja/new_outgoing_tx.plain +2 -0
- package/ts_build/templates/ja/new_tx_proposal.html +13 -0
- package/ts_build/templates/ja/new_tx_proposal.plain +2 -0
- package/ts_build/templates/ja/new_zero_outgoing_tx.html +13 -0
- package/ts_build/templates/ja/new_zero_outgoing_tx.plain +2 -0
- package/ts_build/templates/ja/tx_confirmation.html +13 -0
- package/ts_build/templates/ja/tx_confirmation.plain +2 -0
- package/ts_build/templates/ja/tx_confirmation_receiver.html +13 -0
- package/ts_build/templates/ja/tx_confirmation_receiver.plain +2 -0
- package/ts_build/templates/ja/tx_confirmation_sender.html +13 -0
- package/ts_build/templates/ja/tx_confirmation_sender.plain +2 -0
- package/ts_build/templates/ja/txp_finally_rejected.html +13 -0
- package/ts_build/templates/ja/txp_finally_rejected.plain +2 -0
- package/ts_build/templates/ja/wallet_complete.html +13 -0
- package/ts_build/templates/ja/wallet_complete.plain +2 -0
- package/ts_build/templates/master-template.html +494 -0
- package/ts_build/test/bchaddresstranslator.test.d.ts +2 -0
- package/ts_build/test/bchaddresstranslator.test.d.ts.map +1 -0
- package/ts_build/test/bchaddresstranslator.test.js +76 -0
- package/ts_build/test/bchaddresstranslator.test.js.map +1 -0
- package/ts_build/test/blockchainexplorer.test.d.ts +2 -0
- package/ts_build/test/blockchainexplorer.test.d.ts.map +1 -0
- package/ts_build/test/blockchainexplorer.test.js +98 -0
- package/ts_build/test/blockchainexplorer.test.js.map +1 -0
- package/ts_build/test/chain/bch.test.d.ts +2 -0
- package/ts_build/test/chain/bch.test.d.ts.map +1 -0
- package/ts_build/test/chain/bch.test.js +135 -0
- package/ts_build/test/chain/bch.test.js.map +1 -0
- package/ts_build/test/chain/btc.test.d.ts +2 -0
- package/ts_build/test/chain/btc.test.d.ts.map +1 -0
- package/ts_build/test/chain/btc.test.js +310 -0
- package/ts_build/test/chain/btc.test.js.map +1 -0
- package/ts_build/test/chain/doge.test.d.ts +2 -0
- package/ts_build/test/chain/doge.test.d.ts.map +1 -0
- package/ts_build/test/chain/doge.test.js +343 -0
- package/ts_build/test/chain/doge.test.js.map +1 -0
- package/ts_build/test/chain/eth.test.d.ts +2 -0
- package/ts_build/test/chain/eth.test.d.ts.map +1 -0
- package/ts_build/test/chain/eth.test.js +51 -0
- package/ts_build/test/chain/eth.test.js.map +1 -0
- package/ts_build/test/chain/ltc.test.d.ts +2 -0
- package/ts_build/test/chain/ltc.test.d.ts.map +1 -0
- package/ts_build/test/chain/ltc.test.js +323 -0
- package/ts_build/test/chain/ltc.test.js.map +1 -0
- package/ts_build/test/chain/matic.test.d.ts +2 -0
- package/ts_build/test/chain/matic.test.d.ts.map +1 -0
- package/ts_build/test/chain/matic.test.js +51 -0
- package/ts_build/test/chain/matic.test.js.map +1 -0
- package/ts_build/test/chain/xrp.test.d.ts +2 -0
- package/ts_build/test/chain/xrp.test.d.ts.map +1 -0
- package/ts_build/test/chain/xrp.test.js +228 -0
- package/ts_build/test/chain/xrp.test.js.map +1 -0
- package/ts_build/test/expressapp.test.d.ts +2 -0
- package/ts_build/test/expressapp.test.d.ts.map +1 -0
- package/ts_build/test/expressapp.test.js +523 -0
- package/ts_build/test/expressapp.test.js.map +1 -0
- package/ts_build/test/integration/bcmonitor.test.d.ts +2 -0
- package/ts_build/test/integration/bcmonitor.test.d.ts.map +1 -0
- package/ts_build/test/integration/bcmonitor.test.js +375 -0
- package/ts_build/test/integration/bcmonitor.test.js.map +1 -0
- package/ts_build/test/integration/cashAddrMigration.test.d.ts +2 -0
- package/ts_build/test/integration/cashAddrMigration.test.d.ts.map +1 -0
- package/ts_build/test/integration/cashAddrMigration.test.js +147 -0
- package/ts_build/test/integration/cashAddrMigration.test.js.map +1 -0
- package/ts_build/test/integration/data/tss/2of3/index.d.ts +4 -0
- package/ts_build/test/integration/data/tss/2of3/index.d.ts.map +1 -0
- package/ts_build/test/integration/data/tss/2of3/index.js +20 -0
- package/ts_build/test/integration/data/tss/2of3/index.js.map +1 -0
- package/ts_build/test/integration/data/tss/2of3/party0.key.d.ts +6 -0
- package/ts_build/test/integration/data/tss/2of3/party0.key.d.ts.map +1 -0
- package/ts_build/test/integration/data/tss/2of3/party0.key.js +9 -0
- package/ts_build/test/integration/data/tss/2of3/party0.key.js.map +1 -0
- package/ts_build/test/integration/data/tss/2of3/party1.key.d.ts +6 -0
- package/ts_build/test/integration/data/tss/2of3/party1.key.d.ts.map +1 -0
- package/ts_build/test/integration/data/tss/2of3/party1.key.js +9 -0
- package/ts_build/test/integration/data/tss/2of3/party1.key.js.map +1 -0
- package/ts_build/test/integration/data/tss/2of3/party2.key.d.ts +6 -0
- package/ts_build/test/integration/data/tss/2of3/party2.key.d.ts.map +1 -0
- package/ts_build/test/integration/data/tss/2of3/party2.key.js +9 -0
- package/ts_build/test/integration/data/tss/2of3/party2.key.js.map +1 -0
- package/ts_build/test/integration/emailnotifications.test.d.ts +2 -0
- package/ts_build/test/integration/emailnotifications.test.d.ts.map +1 -0
- package/ts_build/test/integration/emailnotifications.test.js +805 -0
- package/ts_build/test/integration/emailnotifications.test.js.map +1 -0
- package/ts_build/test/integration/externalservices/banxa.test.d.ts +2 -0
- package/ts_build/test/integration/externalservices/banxa.test.d.ts.map +1 -0
- package/ts_build/test/integration/externalservices/banxa.test.js +382 -0
- package/ts_build/test/integration/externalservices/banxa.test.js.map +1 -0
- package/ts_build/test/integration/externalservices/changelly.test.d.ts +2 -0
- package/ts_build/test/integration/externalservices/changelly.test.d.ts.map +1 -0
- package/ts_build/test/integration/externalservices/changelly.test.js +509 -0
- package/ts_build/test/integration/externalservices/changelly.test.js.map +1 -0
- package/ts_build/test/integration/externalservices/coinGecko.test.d.ts +2 -0
- package/ts_build/test/integration/externalservices/coinGecko.test.d.ts.map +1 -0
- package/ts_build/test/integration/externalservices/coinGecko.test.js +295 -0
- package/ts_build/test/integration/externalservices/coinGecko.test.js.map +1 -0
- package/ts_build/test/integration/externalservices/moonpay.test.d.ts +2 -0
- package/ts_build/test/integration/externalservices/moonpay.test.d.ts.map +1 -0
- package/ts_build/test/integration/externalservices/moonpay.test.js +567 -0
- package/ts_build/test/integration/externalservices/moonpay.test.js.map +1 -0
- package/ts_build/test/integration/externalservices/oneInch.test.d.ts +2 -0
- package/ts_build/test/integration/externalservices/oneInch.test.d.ts.map +1 -0
- package/ts_build/test/integration/externalservices/oneInch.test.js +182 -0
- package/ts_build/test/integration/externalservices/oneInch.test.js.map +1 -0
- package/ts_build/test/integration/externalservices/ramp.test.d.ts +2 -0
- package/ts_build/test/integration/externalservices/ramp.test.d.ts.map +1 -0
- package/ts_build/test/integration/externalservices/ramp.test.js +459 -0
- package/ts_build/test/integration/externalservices/ramp.test.js.map +1 -0
- package/ts_build/test/integration/externalservices/sardine.test.d.ts +2 -0
- package/ts_build/test/integration/externalservices/sardine.test.d.ts.map +1 -0
- package/ts_build/test/integration/externalservices/sardine.test.js +364 -0
- package/ts_build/test/integration/externalservices/sardine.test.js.map +1 -0
- package/ts_build/test/integration/externalservices/simplex.test.d.ts +2 -0
- package/ts_build/test/integration/externalservices/simplex.test.d.ts.map +1 -0
- package/ts_build/test/integration/externalservices/simplex.test.js +383 -0
- package/ts_build/test/integration/externalservices/simplex.test.js.map +1 -0
- package/ts_build/test/integration/externalservices/thorswap.test.d.ts +2 -0
- package/ts_build/test/integration/externalservices/thorswap.test.d.ts.map +1 -0
- package/ts_build/test/integration/externalservices/thorswap.test.js +316 -0
- package/ts_build/test/integration/externalservices/thorswap.test.js.map +1 -0
- package/ts_build/test/integration/externalservices/transak.test.d.ts +2 -0
- package/ts_build/test/integration/externalservices/transak.test.d.ts.map +1 -0
- package/ts_build/test/integration/externalservices/transak.test.js +409 -0
- package/ts_build/test/integration/externalservices/transak.test.js.map +1 -0
- package/ts_build/test/integration/externalservices/wyre.test.d.ts +2 -0
- package/ts_build/test/integration/externalservices/wyre.test.d.ts.map +1 -0
- package/ts_build/test/integration/externalservices/wyre.test.js +281 -0
- package/ts_build/test/integration/externalservices/wyre.test.js.map +1 -0
- package/ts_build/test/integration/fiatrateservice.test.d.ts +2 -0
- package/ts_build/test/integration/fiatrateservice.test.d.ts.map +1 -0
- package/ts_build/test/integration/fiatrateservice.test.js +838 -0
- package/ts_build/test/integration/fiatrateservice.test.js.map +1 -0
- package/ts_build/test/integration/helpers.d.ts +57 -0
- package/ts_build/test/integration/helpers.d.ts.map +1 -0
- package/ts_build/test/integration/helpers.js +633 -0
- package/ts_build/test/integration/helpers.js.map +1 -0
- package/ts_build/test/integration/history.test.d.ts +2 -0
- package/ts_build/test/integration/history.test.d.ts.map +1 -0
- package/ts_build/test/integration/history.test.js +1064 -0
- package/ts_build/test/integration/history.test.js.map +1 -0
- package/ts_build/test/integration/hugetx.d.ts +46 -0
- package/ts_build/test/integration/hugetx.d.ts.map +1 -0
- package/ts_build/test/integration/hugetx.js +6459 -0
- package/ts_build/test/integration/hugetx.js.map +1 -0
- package/ts_build/test/integration/pushNotifications.test.d.ts +2 -0
- package/ts_build/test/integration/pushNotifications.test.d.ts.map +1 -0
- package/ts_build/test/integration/pushNotifications.test.js +1379 -0
- package/ts_build/test/integration/pushNotifications.test.js.map +1 -0
- package/ts_build/test/integration/server.test.d.ts +2 -0
- package/ts_build/test/integration/server.test.d.ts.map +1 -0
- package/ts_build/test/integration/server.test.js +9980 -0
- package/ts_build/test/integration/server.test.js.map +1 -0
- package/ts_build/test/integration/tss.test.d.ts +2 -0
- package/ts_build/test/integration/tss.test.d.ts.map +1 -0
- package/ts_build/test/integration/tss.test.js +360 -0
- package/ts_build/test/integration/tss.test.js.map +1 -0
- package/ts_build/test/lock.test.d.ts +2 -0
- package/ts_build/test/lock.test.d.ts.map +1 -0
- package/ts_build/test/lock.test.js +226 -0
- package/ts_build/test/lock.test.js.map +1 -0
- package/ts_build/test/model/address.test.d.ts +2 -0
- package/ts_build/test/model/address.test.d.ts.map +1 -0
- package/ts_build/test/model/address.test.js +209 -0
- package/ts_build/test/model/address.test.js.map +1 -0
- package/ts_build/test/model/addressmanager.test.d.ts +2 -0
- package/ts_build/test/model/addressmanager.test.d.ts.map +1 -0
- package/ts_build/test/model/addressmanager.test.js +178 -0
- package/ts_build/test/model/addressmanager.test.js.map +1 -0
- package/ts_build/test/model/advertisement.test.d.ts +2 -0
- package/ts_build/test/model/advertisement.test.d.ts.map +1 -0
- package/ts_build/test/model/advertisement.test.js +61 -0
- package/ts_build/test/model/advertisement.test.js.map +1 -0
- package/ts_build/test/model/copayer.test.d.ts +2 -0
- package/ts_build/test/model/copayer.test.d.ts.map +1 -0
- package/ts_build/test/model/copayer.test.js +161 -0
- package/ts_build/test/model/copayer.test.js.map +1 -0
- package/ts_build/test/model/txproposal.test.d.ts +2 -0
- package/ts_build/test/model/txproposal.test.d.ts.map +1 -0
- package/ts_build/test/model/txproposal.test.js +198 -0
- package/ts_build/test/model/txproposal.test.js.map +1 -0
- package/ts_build/test/model/wallet.test.d.ts +2 -0
- package/ts_build/test/model/wallet.test.d.ts.map +1 -0
- package/ts_build/test/model/wallet.test.js +215 -0
- package/ts_build/test/model/wallet.test.js.map +1 -0
- package/ts_build/test/storage.test.d.ts +2 -0
- package/ts_build/test/storage.test.d.ts.map +1 -0
- package/ts_build/test/storage.test.js +433 -0
- package/ts_build/test/storage.test.js.map +1 -0
- package/ts_build/test/test-config.d.ts +8 -0
- package/ts_build/test/test-config.d.ts.map +1 -0
- package/ts_build/test/test-config.js +14 -0
- package/ts_build/test/test-config.js.map +1 -0
- package/ts_build/test/testdata.d.ts +91 -0
- package/ts_build/test/testdata.d.ts.map +1 -0
- package/ts_build/test/testdata.js +304 -0
- package/ts_build/test/testdata.js.map +1 -0
- package/ts_build/test/utils.test.d.ts +2 -0
- package/ts_build/test/utils.test.d.ts.map +1 -0
- package/ts_build/test/utils.test.js +450 -0
- package/ts_build/test/utils.test.js.map +1 -0
- package/ts_build/test/v8.test.d.ts +2 -0
- package/ts_build/test/v8.test.d.ts.map +1 -0
- package/ts_build/test/v8.test.js +341 -0
- package/ts_build/test/v8.test.js.map +1 -0
- package/tsconfig.json +43 -0
- package/tsconfig.prod.json +6 -0
|
@@ -0,0 +1,1513 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.Storage = void 0;
|
|
40
|
+
const async = __importStar(require("async"));
|
|
41
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
42
|
+
const mongodb = __importStar(require("mongodb"));
|
|
43
|
+
const preconditions_1 = __importDefault(require("preconditions"));
|
|
44
|
+
const bchaddresstranslator_1 = require("./bchaddresstranslator");
|
|
45
|
+
const common_1 = require("./common");
|
|
46
|
+
const logger_1 = __importDefault(require("./logger"));
|
|
47
|
+
const model_1 = require("./model");
|
|
48
|
+
const tsskeygen_1 = require("./model/tsskeygen");
|
|
49
|
+
const tsssign_1 = require("./model/tsssign");
|
|
50
|
+
const $ = preconditions_1.default.singleton();
|
|
51
|
+
const collections = {
|
|
52
|
+
WALLETS: 'wallets',
|
|
53
|
+
TXS: 'txs',
|
|
54
|
+
ADDRESSES: 'addresses',
|
|
55
|
+
ADVERTISEMENTS: 'advertisements',
|
|
56
|
+
NOTIFICATIONS: 'notifications',
|
|
57
|
+
COPAYERS_LOOKUP: 'copayers_lookup',
|
|
58
|
+
PREFERENCES: 'preferences',
|
|
59
|
+
EMAIL_QUEUE: 'email_queue',
|
|
60
|
+
CACHE: 'cache',
|
|
61
|
+
FIAT_RATES2: 'fiat_rates2',
|
|
62
|
+
TX_NOTES: 'tx_notes',
|
|
63
|
+
SESSIONS: 'sessions',
|
|
64
|
+
PUSH_NOTIFICATION_SUBS: 'push_notification_subs',
|
|
65
|
+
TX_CONFIRMATION_SUBS: 'tx_confirmation_subs',
|
|
66
|
+
LOCKS: 'locks',
|
|
67
|
+
TSS_KEYGEN: 'tss_keygen',
|
|
68
|
+
TSS_SIGN: 'tss_sign'
|
|
69
|
+
};
|
|
70
|
+
const Defaults = common_1.Common.Defaults;
|
|
71
|
+
const Utils = common_1.Common.Utils;
|
|
72
|
+
const ObjectID = mongodb.ObjectID;
|
|
73
|
+
const objectIdDate = function (date) {
|
|
74
|
+
return Math.floor(date / 1000).toString(16) + '0000000000000000';
|
|
75
|
+
};
|
|
76
|
+
class Storage {
|
|
77
|
+
static BCHEIGHT_KEY = 'bcheight';
|
|
78
|
+
static collections = collections;
|
|
79
|
+
db;
|
|
80
|
+
client;
|
|
81
|
+
constructor(opts = {}) {
|
|
82
|
+
opts = opts || {};
|
|
83
|
+
this.db = opts.db;
|
|
84
|
+
}
|
|
85
|
+
static createIndexes(db) {
|
|
86
|
+
logger_1.default.info('Creating DB indexes');
|
|
87
|
+
if (!db.collection) {
|
|
88
|
+
logger_1.default.error('DB not ready: [storage.ts] no db.collection');
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
db.collection(collections.WALLETS).createIndex({
|
|
92
|
+
id: 1
|
|
93
|
+
});
|
|
94
|
+
db.collection(collections.COPAYERS_LOOKUP).createIndex({
|
|
95
|
+
copayerId: 1
|
|
96
|
+
});
|
|
97
|
+
db.collection(collections.COPAYERS_LOOKUP).createIndex({
|
|
98
|
+
walletId: 1
|
|
99
|
+
});
|
|
100
|
+
db.collection(collections.TXS).createIndex({
|
|
101
|
+
walletId: 1,
|
|
102
|
+
id: 1
|
|
103
|
+
});
|
|
104
|
+
db.collection(collections.TXS).createIndex({
|
|
105
|
+
walletId: 1,
|
|
106
|
+
isPending: 1,
|
|
107
|
+
txid: 1
|
|
108
|
+
});
|
|
109
|
+
db.collection(collections.TXS).createIndex({
|
|
110
|
+
walletId: 1,
|
|
111
|
+
createdOn: -1
|
|
112
|
+
});
|
|
113
|
+
db.collection(collections.TXS).createIndex({
|
|
114
|
+
txid: 1
|
|
115
|
+
});
|
|
116
|
+
db.collection(collections.NOTIFICATIONS).createIndex({
|
|
117
|
+
walletId: 1,
|
|
118
|
+
id: 1
|
|
119
|
+
});
|
|
120
|
+
db.collection(collections.ADVERTISEMENTS).createIndex({
|
|
121
|
+
advertisementId: 1,
|
|
122
|
+
title: 1
|
|
123
|
+
}, { unique: true });
|
|
124
|
+
db.collection(collections.ADDRESSES).createIndex({
|
|
125
|
+
walletId: 1,
|
|
126
|
+
createdOn: 1
|
|
127
|
+
});
|
|
128
|
+
db.collection(collections.ADDRESSES).createIndex({
|
|
129
|
+
address: 1,
|
|
130
|
+
coin: 1
|
|
131
|
+
}, { unique: true });
|
|
132
|
+
db.collection(collections.ADDRESSES).createIndex({
|
|
133
|
+
address: 1,
|
|
134
|
+
beRegistered: 1
|
|
135
|
+
});
|
|
136
|
+
db.collection(collections.ADDRESSES).createIndex({
|
|
137
|
+
walletId: 1,
|
|
138
|
+
address: 1
|
|
139
|
+
});
|
|
140
|
+
db.collection(collections.EMAIL_QUEUE).createIndex({
|
|
141
|
+
id: 1
|
|
142
|
+
});
|
|
143
|
+
db.collection(collections.EMAIL_QUEUE).createIndex({
|
|
144
|
+
notificationId: 1
|
|
145
|
+
});
|
|
146
|
+
db.collection(collections.CACHE).createIndex({
|
|
147
|
+
walletId: 1,
|
|
148
|
+
type: 1,
|
|
149
|
+
key: 1
|
|
150
|
+
});
|
|
151
|
+
db.collection(collections.TX_NOTES).createIndex({
|
|
152
|
+
walletId: 1,
|
|
153
|
+
txid: 1
|
|
154
|
+
});
|
|
155
|
+
db.collection(collections.PREFERENCES).createIndex({
|
|
156
|
+
walletId: 1
|
|
157
|
+
});
|
|
158
|
+
db.collection(collections.FIAT_RATES2).createIndex({
|
|
159
|
+
coin: 1,
|
|
160
|
+
code: 1,
|
|
161
|
+
ts: 1
|
|
162
|
+
});
|
|
163
|
+
db.collection(collections.PUSH_NOTIFICATION_SUBS).createIndex({
|
|
164
|
+
copayerId: 1
|
|
165
|
+
});
|
|
166
|
+
db.collection(collections.TX_CONFIRMATION_SUBS).createIndex({
|
|
167
|
+
copayerId: 1,
|
|
168
|
+
txid: 1
|
|
169
|
+
});
|
|
170
|
+
db.collection(collections.TX_CONFIRMATION_SUBS).createIndex({
|
|
171
|
+
isActive: 1,
|
|
172
|
+
txid: 1,
|
|
173
|
+
copayerId: 1
|
|
174
|
+
});
|
|
175
|
+
db.collection(collections.SESSIONS).createIndex({
|
|
176
|
+
copayerId: 1
|
|
177
|
+
});
|
|
178
|
+
db.collection(collections.TSS_KEYGEN).createIndex({
|
|
179
|
+
id: 1
|
|
180
|
+
}, { unique: true });
|
|
181
|
+
}
|
|
182
|
+
connect(opts, cb) {
|
|
183
|
+
opts = opts || {};
|
|
184
|
+
if (this.db)
|
|
185
|
+
return cb();
|
|
186
|
+
const config = opts.mongoDb || {};
|
|
187
|
+
if (opts.secondaryPreferred) {
|
|
188
|
+
if (config.uri.indexOf('?') > 0) {
|
|
189
|
+
config.uri = config.uri + '&';
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
config.uri = config.uri + '?';
|
|
193
|
+
}
|
|
194
|
+
config.uri = config.uri + 'readPreference=secondaryPreferred';
|
|
195
|
+
logger_1.default.info('Read operations set to secondaryPreferred');
|
|
196
|
+
}
|
|
197
|
+
if (!config.dbname) {
|
|
198
|
+
logger_1.default.error('No dbname at config.');
|
|
199
|
+
return cb(new Error('No dbname at config.'));
|
|
200
|
+
}
|
|
201
|
+
mongodb.MongoClient.connect(config.uri, { useUnifiedTopology: true }, (err, client) => {
|
|
202
|
+
if (err) {
|
|
203
|
+
logger_1.default.error('Unable to connect to the mongoDB. Check the credentials.');
|
|
204
|
+
return cb(err);
|
|
205
|
+
}
|
|
206
|
+
this.db = client.db(config.dbname);
|
|
207
|
+
this.client = client;
|
|
208
|
+
logger_1.default.info(`Connection established to db: ${config.uri}`);
|
|
209
|
+
Storage.createIndexes(this.db);
|
|
210
|
+
return cb();
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
disconnect(cb) {
|
|
214
|
+
if (this.client) {
|
|
215
|
+
this.client.close(err => {
|
|
216
|
+
if (err)
|
|
217
|
+
return cb(err);
|
|
218
|
+
this.db = null;
|
|
219
|
+
this.client = null;
|
|
220
|
+
return cb();
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
return cb();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
fetchWallet(id, cb) {
|
|
228
|
+
if (!this.db)
|
|
229
|
+
return cb('not ready');
|
|
230
|
+
this.db.collection(collections.WALLETS).findOne({
|
|
231
|
+
id
|
|
232
|
+
}, (err, result) => {
|
|
233
|
+
if (err)
|
|
234
|
+
return cb(err);
|
|
235
|
+
if (!result)
|
|
236
|
+
return cb();
|
|
237
|
+
return cb(null, model_1.Wallet.fromObj(result));
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
storeWallet(wallet, cb) {
|
|
241
|
+
this.db.collection(collections.WALLETS).replaceOne({
|
|
242
|
+
id: wallet.id
|
|
243
|
+
}, wallet.toObject(), {
|
|
244
|
+
w: 1,
|
|
245
|
+
upsert: true
|
|
246
|
+
}, cb);
|
|
247
|
+
}
|
|
248
|
+
storeWalletAndUpdateCopayersLookup(wallet, cb) {
|
|
249
|
+
const copayerLookups = (wallet.copayers || []).map(copayer => {
|
|
250
|
+
try {
|
|
251
|
+
$.checkState(copayer.requestPubKeys, 'Failed state: copayer.requestPubkeys undefined at <storeWalletAndUpdateCopayersLookup()>');
|
|
252
|
+
}
|
|
253
|
+
catch (e) {
|
|
254
|
+
return cb(e);
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
copayerId: copayer.id,
|
|
258
|
+
walletId: wallet.id,
|
|
259
|
+
requestPubKeys: copayer.requestPubKeys
|
|
260
|
+
};
|
|
261
|
+
});
|
|
262
|
+
this.db.collection(collections.COPAYERS_LOOKUP).deleteMany({
|
|
263
|
+
walletId: wallet.id
|
|
264
|
+
}, {
|
|
265
|
+
w: 1
|
|
266
|
+
}, err => {
|
|
267
|
+
if (err)
|
|
268
|
+
return cb(err);
|
|
269
|
+
this.db.collection(collections.COPAYERS_LOOKUP).insertMany(copayerLookups, {
|
|
270
|
+
w: 1
|
|
271
|
+
}, err => {
|
|
272
|
+
if (err)
|
|
273
|
+
return cb(err);
|
|
274
|
+
return this.storeWallet(wallet, cb);
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
fetchCopayerLookup(copayerId, cb) {
|
|
279
|
+
this.db.collection(collections.COPAYERS_LOOKUP).findOne({
|
|
280
|
+
copayerId
|
|
281
|
+
}, (err, result) => {
|
|
282
|
+
if (err)
|
|
283
|
+
return cb(err);
|
|
284
|
+
if (!result)
|
|
285
|
+
return cb();
|
|
286
|
+
if (!result.requestPubKeys) {
|
|
287
|
+
result.requestPubKeys = [
|
|
288
|
+
{
|
|
289
|
+
key: result.requestPubKey,
|
|
290
|
+
signature: result.signature
|
|
291
|
+
}
|
|
292
|
+
];
|
|
293
|
+
}
|
|
294
|
+
return cb(null, model_1.Copayer.fromObj(result));
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
_completeTxData(walletId, txs, cb) {
|
|
298
|
+
this.fetchWallet(walletId, (err, wallet) => {
|
|
299
|
+
if (err)
|
|
300
|
+
return cb(err);
|
|
301
|
+
lodash_1.default.each([].concat(txs), tx => {
|
|
302
|
+
tx.derivationStrategy = wallet.derivationStrategy || 'BIP45';
|
|
303
|
+
tx.creatorName = wallet.getCopayer(tx.creatorId).name;
|
|
304
|
+
lodash_1.default.each(tx.actions, action => {
|
|
305
|
+
action.copayerName = wallet.getCopayer(action.copayerId).name;
|
|
306
|
+
});
|
|
307
|
+
if (tx.status == 'accepted')
|
|
308
|
+
tx.raw = tx.getRawTx();
|
|
309
|
+
});
|
|
310
|
+
return cb(null, txs);
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
fetchTx(walletId, txProposalId, cb) {
|
|
314
|
+
if (!this.db)
|
|
315
|
+
return cb();
|
|
316
|
+
this.db.collection(collections.TXS).findOne({
|
|
317
|
+
id: txProposalId,
|
|
318
|
+
walletId
|
|
319
|
+
}, (err, result) => {
|
|
320
|
+
if (err)
|
|
321
|
+
return cb(err);
|
|
322
|
+
if (!result)
|
|
323
|
+
return cb();
|
|
324
|
+
return this._completeTxData(walletId, model_1.TxProposal.fromObj(result), cb);
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
fetchTxByHash(hash, cb) {
|
|
328
|
+
if (!this.db)
|
|
329
|
+
return cb();
|
|
330
|
+
this.db.collection(collections.TXS).findOne({
|
|
331
|
+
txid: hash
|
|
332
|
+
}, (err, result) => {
|
|
333
|
+
if (err)
|
|
334
|
+
return cb(err);
|
|
335
|
+
if (!result)
|
|
336
|
+
return cb();
|
|
337
|
+
return this._completeTxData(result.walletId, model_1.TxProposal.fromObj(result), cb);
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
fetchLastTxs(walletId, creatorId, limit, cb) {
|
|
341
|
+
this.db
|
|
342
|
+
.collection(collections.TXS)
|
|
343
|
+
.find({
|
|
344
|
+
walletId,
|
|
345
|
+
creatorId
|
|
346
|
+
}, {
|
|
347
|
+
limit: limit || 5
|
|
348
|
+
})
|
|
349
|
+
.sort({
|
|
350
|
+
createdOn: -1
|
|
351
|
+
})
|
|
352
|
+
.toArray((err, result) => {
|
|
353
|
+
if (err)
|
|
354
|
+
return cb(err);
|
|
355
|
+
if (!result)
|
|
356
|
+
return cb();
|
|
357
|
+
const txs = lodash_1.default.map(result, tx => {
|
|
358
|
+
return model_1.TxProposal.fromObj(tx);
|
|
359
|
+
});
|
|
360
|
+
return cb(null, txs);
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
fetchEthPendingTxs(multisigTxpsInfo) {
|
|
364
|
+
return new Promise((resolve, reject) => {
|
|
365
|
+
this.db
|
|
366
|
+
.collection(collections.TXS)
|
|
367
|
+
.find({
|
|
368
|
+
txid: { $in: multisigTxpsInfo.map(txpInfo => txpInfo.transactionHash) }
|
|
369
|
+
})
|
|
370
|
+
.sort({
|
|
371
|
+
createdOn: -1
|
|
372
|
+
})
|
|
373
|
+
.toArray(async (err, result) => {
|
|
374
|
+
if (err)
|
|
375
|
+
return reject(err);
|
|
376
|
+
if (!result)
|
|
377
|
+
return reject();
|
|
378
|
+
const multisigTxpsInfoByTransactionHash = lodash_1.default.groupBy(multisigTxpsInfo, 'transactionHash');
|
|
379
|
+
const actionsById = {};
|
|
380
|
+
const txs = lodash_1.default.compact(lodash_1.default.map(result, tx => {
|
|
381
|
+
if (!tx.multisigContractAddress) {
|
|
382
|
+
return undefined;
|
|
383
|
+
}
|
|
384
|
+
tx.status = 'pending';
|
|
385
|
+
tx.multisigTxId = multisigTxpsInfoByTransactionHash[tx.txid][0].transactionId;
|
|
386
|
+
for (const action of tx.actions) {
|
|
387
|
+
if (lodash_1.default.some(multisigTxpsInfoByTransactionHash[tx.txid], { event: 'ExecutionFailure' })) {
|
|
388
|
+
action.type = 'failed';
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
if (tx.amount === 0) {
|
|
392
|
+
actionsById[tx.multisigTxId] = [...tx.actions, ...(actionsById[tx.multisigTxId] || [])];
|
|
393
|
+
return undefined;
|
|
394
|
+
}
|
|
395
|
+
return model_1.TxProposal.fromObj(tx);
|
|
396
|
+
}));
|
|
397
|
+
for (const tx of txs) {
|
|
398
|
+
if (actionsById[tx.multisigTxId]) {
|
|
399
|
+
tx.actions = [...tx.actions, ...(actionsById[tx.multisigTxId] || [])];
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
return resolve(txs);
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
fetchPendingTxs(walletId, cb) {
|
|
407
|
+
this.db
|
|
408
|
+
.collection(collections.TXS)
|
|
409
|
+
.find({
|
|
410
|
+
walletId,
|
|
411
|
+
isPending: true
|
|
412
|
+
})
|
|
413
|
+
.sort({
|
|
414
|
+
createdOn: -1
|
|
415
|
+
})
|
|
416
|
+
.toArray((err, result) => {
|
|
417
|
+
if (err)
|
|
418
|
+
return cb(err);
|
|
419
|
+
if (!result)
|
|
420
|
+
return cb();
|
|
421
|
+
const txs = lodash_1.default.map(result, tx => {
|
|
422
|
+
return model_1.TxProposal.fromObj(tx);
|
|
423
|
+
});
|
|
424
|
+
return this._completeTxData(walletId, txs, cb);
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
fetchTxs(walletId, opts, cb) {
|
|
428
|
+
opts = opts || {};
|
|
429
|
+
const tsFilter = {};
|
|
430
|
+
if (lodash_1.default.isNumber(opts.minTs))
|
|
431
|
+
tsFilter.$gte = opts.minTs;
|
|
432
|
+
if (lodash_1.default.isNumber(opts.maxTs))
|
|
433
|
+
tsFilter.$lte = opts.maxTs;
|
|
434
|
+
const filter = {
|
|
435
|
+
walletId
|
|
436
|
+
};
|
|
437
|
+
if (!lodash_1.default.isEmpty(tsFilter))
|
|
438
|
+
filter.createdOn = tsFilter;
|
|
439
|
+
const mods = {};
|
|
440
|
+
if (lodash_1.default.isNumber(opts.limit))
|
|
441
|
+
mods.limit = opts.limit;
|
|
442
|
+
this.db
|
|
443
|
+
.collection(collections.TXS)
|
|
444
|
+
.find(filter, mods)
|
|
445
|
+
.sort({
|
|
446
|
+
createdOn: -1
|
|
447
|
+
})
|
|
448
|
+
.toArray((err, result) => {
|
|
449
|
+
if (err)
|
|
450
|
+
return cb(err);
|
|
451
|
+
if (!result)
|
|
452
|
+
return cb();
|
|
453
|
+
const txs = lodash_1.default.map(result, tx => {
|
|
454
|
+
return model_1.TxProposal.fromObj(tx);
|
|
455
|
+
});
|
|
456
|
+
return this._completeTxData(walletId, txs, cb);
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
fetchBroadcastedTxs(walletId, opts, cb) {
|
|
460
|
+
opts = opts || {};
|
|
461
|
+
const tsFilter = {};
|
|
462
|
+
if (lodash_1.default.isNumber(opts.minTs))
|
|
463
|
+
tsFilter.$gte = opts.minTs;
|
|
464
|
+
if (lodash_1.default.isNumber(opts.maxTs))
|
|
465
|
+
tsFilter.$lte = opts.maxTs;
|
|
466
|
+
const filter = {
|
|
467
|
+
walletId,
|
|
468
|
+
status: 'broadcasted'
|
|
469
|
+
};
|
|
470
|
+
if (!lodash_1.default.isEmpty(tsFilter))
|
|
471
|
+
filter.broadcastedOn = tsFilter;
|
|
472
|
+
const mods = {};
|
|
473
|
+
if (lodash_1.default.isNumber(opts.limit))
|
|
474
|
+
mods.limit = opts.limit;
|
|
475
|
+
this.db
|
|
476
|
+
.collection(collections.TXS)
|
|
477
|
+
.find(filter, mods)
|
|
478
|
+
.sort({
|
|
479
|
+
createdOn: -1
|
|
480
|
+
})
|
|
481
|
+
.toArray((err, result) => {
|
|
482
|
+
if (err)
|
|
483
|
+
return cb(err);
|
|
484
|
+
if (!result)
|
|
485
|
+
return cb();
|
|
486
|
+
const txs = lodash_1.default.map(result, tx => {
|
|
487
|
+
return model_1.TxProposal.fromObj(tx);
|
|
488
|
+
});
|
|
489
|
+
return this._completeTxData(walletId, txs, cb);
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
fetchNotifications(walletId, notificationId, minTs, cb) {
|
|
493
|
+
function makeId(timestamp) {
|
|
494
|
+
return lodash_1.default.padStart(timestamp, 14, '0') + lodash_1.default.repeat('0', 4);
|
|
495
|
+
}
|
|
496
|
+
let minId = makeId(minTs);
|
|
497
|
+
if (notificationId) {
|
|
498
|
+
minId = notificationId > minId ? notificationId : minId;
|
|
499
|
+
}
|
|
500
|
+
this.db
|
|
501
|
+
.collection(collections.NOTIFICATIONS)
|
|
502
|
+
.find({
|
|
503
|
+
walletId,
|
|
504
|
+
id: {
|
|
505
|
+
$gt: minId
|
|
506
|
+
}
|
|
507
|
+
})
|
|
508
|
+
.sort({
|
|
509
|
+
id: 1
|
|
510
|
+
})
|
|
511
|
+
.toArray((err, result) => {
|
|
512
|
+
if (err)
|
|
513
|
+
return cb(err);
|
|
514
|
+
if (!result)
|
|
515
|
+
return cb();
|
|
516
|
+
const notifications = lodash_1.default.map(result, notification => {
|
|
517
|
+
return model_1.Notification.fromObj(notification);
|
|
518
|
+
});
|
|
519
|
+
return cb(null, notifications);
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
storeNotification(walletId, notification, cb) {
|
|
523
|
+
if (!this.db) {
|
|
524
|
+
logger_1.default.warn('Trying to store a notification with close DB %o', notification);
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
this.db.collection(collections.NOTIFICATIONS).insertOne(notification, {
|
|
528
|
+
w: 1
|
|
529
|
+
}, cb);
|
|
530
|
+
}
|
|
531
|
+
storeTx(walletId, txp, cb) {
|
|
532
|
+
this.db.collection(collections.TXS).replaceOne({
|
|
533
|
+
id: txp.id,
|
|
534
|
+
walletId
|
|
535
|
+
}, txp.toObject(), {
|
|
536
|
+
w: 1,
|
|
537
|
+
upsert: true
|
|
538
|
+
}, cb);
|
|
539
|
+
}
|
|
540
|
+
removeTx(walletId, txProposalId, cb) {
|
|
541
|
+
this.db.collection(collections.TXS).deleteOne({
|
|
542
|
+
id: txProposalId,
|
|
543
|
+
walletId
|
|
544
|
+
}, {
|
|
545
|
+
w: 1
|
|
546
|
+
}, cb);
|
|
547
|
+
}
|
|
548
|
+
removeWallet(walletId, cb) {
|
|
549
|
+
async.parallel([
|
|
550
|
+
next => {
|
|
551
|
+
this.db.collection(collections.WALLETS).deleteOne({
|
|
552
|
+
id: walletId
|
|
553
|
+
}, next);
|
|
554
|
+
},
|
|
555
|
+
next => {
|
|
556
|
+
const otherCollections = lodash_1.default.without(lodash_1.default.values(collections), collections.WALLETS);
|
|
557
|
+
async.each(otherCollections, (col, next) => {
|
|
558
|
+
this.db.collection(col).deleteMany({
|
|
559
|
+
walletId
|
|
560
|
+
}, next);
|
|
561
|
+
}, next);
|
|
562
|
+
}
|
|
563
|
+
], cb);
|
|
564
|
+
}
|
|
565
|
+
fetchAddresses(walletId, cb) {
|
|
566
|
+
this.db
|
|
567
|
+
.collection(collections.ADDRESSES)
|
|
568
|
+
.find({
|
|
569
|
+
walletId
|
|
570
|
+
})
|
|
571
|
+
.sort({
|
|
572
|
+
createdOn: 1
|
|
573
|
+
})
|
|
574
|
+
.toArray((err, result) => {
|
|
575
|
+
if (err)
|
|
576
|
+
return cb(err);
|
|
577
|
+
if (!result)
|
|
578
|
+
return cb();
|
|
579
|
+
return cb(null, Utils.sortAsc(result.map(model_1.Address.fromObj), 'createdOn', 'path'));
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
migrateToCashAddr(walletId, cb) {
|
|
583
|
+
const cursor = this.db.collection(collections.ADDRESSES).find({
|
|
584
|
+
walletId
|
|
585
|
+
});
|
|
586
|
+
cursor.on('end', () => {
|
|
587
|
+
console.log(`Migration to cash address of ${walletId} Finished`);
|
|
588
|
+
return this.clearWalletCache(walletId, cb);
|
|
589
|
+
});
|
|
590
|
+
cursor.on('err', err => {
|
|
591
|
+
return cb(err);
|
|
592
|
+
});
|
|
593
|
+
cursor.on('data', doc => {
|
|
594
|
+
cursor.pause();
|
|
595
|
+
let x;
|
|
596
|
+
try {
|
|
597
|
+
x = bchaddresstranslator_1.BCHAddressTranslator.translate(doc.address, 'cashaddr');
|
|
598
|
+
}
|
|
599
|
+
catch (e) {
|
|
600
|
+
return cb(e);
|
|
601
|
+
}
|
|
602
|
+
this.db.collection(collections.ADDRESSES).updateMany({ _id: doc._id }, { $set: { address: x } });
|
|
603
|
+
cursor.resume();
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
fetchUnsyncAddresses(walletId, cb) {
|
|
607
|
+
this.db
|
|
608
|
+
.collection(collections.ADDRESSES)
|
|
609
|
+
.find({
|
|
610
|
+
walletId,
|
|
611
|
+
beRegistered: null
|
|
612
|
+
})
|
|
613
|
+
.toArray((err, result) => {
|
|
614
|
+
if (err)
|
|
615
|
+
return cb(err);
|
|
616
|
+
if (!result)
|
|
617
|
+
return cb();
|
|
618
|
+
return cb(null, result);
|
|
619
|
+
});
|
|
620
|
+
}
|
|
621
|
+
fetchNewAddresses(walletId, fromTs, cb) {
|
|
622
|
+
this.db
|
|
623
|
+
.collection(collections.ADDRESSES)
|
|
624
|
+
.find({
|
|
625
|
+
walletId,
|
|
626
|
+
createdOn: {
|
|
627
|
+
$gte: fromTs
|
|
628
|
+
}
|
|
629
|
+
})
|
|
630
|
+
.sort({
|
|
631
|
+
createdOn: 1
|
|
632
|
+
})
|
|
633
|
+
.toArray((err, result) => {
|
|
634
|
+
if (err)
|
|
635
|
+
return cb(err);
|
|
636
|
+
if (!result)
|
|
637
|
+
return cb();
|
|
638
|
+
return cb(null, result.map(model_1.Address.fromObj));
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
storeAddress(address, cb) {
|
|
642
|
+
this.db.collection(collections.ADDRESSES).replaceOne({
|
|
643
|
+
walletId: address.walletId,
|
|
644
|
+
address: address.address
|
|
645
|
+
}, address, {
|
|
646
|
+
w: 1,
|
|
647
|
+
upsert: false
|
|
648
|
+
}, cb);
|
|
649
|
+
}
|
|
650
|
+
markSyncedAddresses(addresses, cb) {
|
|
651
|
+
this.db.collection(collections.ADDRESSES).updateMany({
|
|
652
|
+
address: { $in: addresses }
|
|
653
|
+
}, { $set: { beRegistered: true } }, {
|
|
654
|
+
w: 1,
|
|
655
|
+
upsert: false
|
|
656
|
+
}, cb);
|
|
657
|
+
}
|
|
658
|
+
deregisterWallet(walletId, cb) {
|
|
659
|
+
this.db.collection(collections.WALLETS).updateOne({
|
|
660
|
+
id: walletId
|
|
661
|
+
}, { $set: { beRegistered: null } }, {
|
|
662
|
+
w: 1,
|
|
663
|
+
upsert: false
|
|
664
|
+
}, () => {
|
|
665
|
+
this.db.collection(collections.ADDRESSES).updateMany({
|
|
666
|
+
walletId
|
|
667
|
+
}, { $set: { beRegistered: null } }, {
|
|
668
|
+
w: 1,
|
|
669
|
+
upsert: false
|
|
670
|
+
}, () => {
|
|
671
|
+
this.clearWalletCache(walletId, cb);
|
|
672
|
+
});
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
storeAddressAndWallet(wallet, addresses, cb) {
|
|
676
|
+
const clonedAddresses = [].concat(addresses);
|
|
677
|
+
if (!addresses || !clonedAddresses.length)
|
|
678
|
+
return cb();
|
|
679
|
+
let duplicate;
|
|
680
|
+
this.db.collection(collections.ADDRESSES).insertMany(clonedAddresses, {
|
|
681
|
+
w: 1
|
|
682
|
+
}, err => {
|
|
683
|
+
if (err) {
|
|
684
|
+
if (!err.toString().match(/E11000/)) {
|
|
685
|
+
return cb(err);
|
|
686
|
+
}
|
|
687
|
+
else {
|
|
688
|
+
duplicate = true;
|
|
689
|
+
logger_1.default.warn('Found duplicate address: ' + clonedAddresses.map(a => a.address).join(','));
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
this.storeWallet(wallet, err => {
|
|
693
|
+
return cb(err, duplicate);
|
|
694
|
+
});
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
fetchAddressByWalletId(walletId, address, cb) {
|
|
698
|
+
this.db.collection(collections.ADDRESSES).findOne({
|
|
699
|
+
walletId,
|
|
700
|
+
address
|
|
701
|
+
}, (err, result) => {
|
|
702
|
+
if (err)
|
|
703
|
+
return cb(err);
|
|
704
|
+
if (!result)
|
|
705
|
+
return cb();
|
|
706
|
+
return cb(null, model_1.Address.fromObj(result));
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
fetchAddressesByWalletId(walletId, addresses, cb) {
|
|
710
|
+
this.db
|
|
711
|
+
.collection(collections.ADDRESSES)
|
|
712
|
+
.find({
|
|
713
|
+
walletId,
|
|
714
|
+
address: { $in: addresses }
|
|
715
|
+
}, {})
|
|
716
|
+
.toArray((err, result) => {
|
|
717
|
+
if (err)
|
|
718
|
+
return cb(err);
|
|
719
|
+
if (!result)
|
|
720
|
+
return cb();
|
|
721
|
+
return cb(null, result);
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
fetchAddressByChain(chain, address, cb) {
|
|
725
|
+
if (!this.db)
|
|
726
|
+
return cb();
|
|
727
|
+
this.db
|
|
728
|
+
.collection(collections.ADDRESSES)
|
|
729
|
+
.find({
|
|
730
|
+
address
|
|
731
|
+
})
|
|
732
|
+
.toArray((err, result) => {
|
|
733
|
+
if (err)
|
|
734
|
+
return cb(err);
|
|
735
|
+
if (!result || lodash_1.default.isEmpty(result))
|
|
736
|
+
return cb();
|
|
737
|
+
if (result.length > 1) {
|
|
738
|
+
result = lodash_1.default.find(result, address => {
|
|
739
|
+
return chain == (address.chain || address.coin || 'btc');
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
else {
|
|
743
|
+
result = lodash_1.default.head(result);
|
|
744
|
+
}
|
|
745
|
+
if (!result)
|
|
746
|
+
return cb();
|
|
747
|
+
return cb(null, model_1.Address.fromObj(result));
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
fetchPreferences(walletId, copayerId, cb) {
|
|
751
|
+
this.db
|
|
752
|
+
.collection(collections.PREFERENCES)
|
|
753
|
+
.find({
|
|
754
|
+
walletId
|
|
755
|
+
})
|
|
756
|
+
.toArray((err, result) => {
|
|
757
|
+
if (err)
|
|
758
|
+
return cb(err);
|
|
759
|
+
if (copayerId) {
|
|
760
|
+
result = lodash_1.default.find(result, {
|
|
761
|
+
copayerId
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
if (!result)
|
|
765
|
+
return cb();
|
|
766
|
+
const preferences = lodash_1.default.map([].concat(result), r => {
|
|
767
|
+
return model_1.Preferences.fromObj(r);
|
|
768
|
+
});
|
|
769
|
+
if (copayerId) {
|
|
770
|
+
return cb(null, preferences[0]);
|
|
771
|
+
}
|
|
772
|
+
else {
|
|
773
|
+
return cb(null, preferences);
|
|
774
|
+
}
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
storePreferences(preferences, cb) {
|
|
778
|
+
this.db.collection(collections.PREFERENCES).replaceOne({
|
|
779
|
+
walletId: preferences.walletId,
|
|
780
|
+
copayerId: preferences.copayerId
|
|
781
|
+
}, preferences, {
|
|
782
|
+
w: 1,
|
|
783
|
+
upsert: true
|
|
784
|
+
}, cb);
|
|
785
|
+
}
|
|
786
|
+
storeEmail(email, cb) {
|
|
787
|
+
this.db.collection(collections.EMAIL_QUEUE).replaceOne({
|
|
788
|
+
id: email.id
|
|
789
|
+
}, email, {
|
|
790
|
+
w: 1,
|
|
791
|
+
upsert: true
|
|
792
|
+
}, cb);
|
|
793
|
+
}
|
|
794
|
+
fetchUnsentEmails(cb) {
|
|
795
|
+
this.db
|
|
796
|
+
.collection(collections.EMAIL_QUEUE)
|
|
797
|
+
.find({
|
|
798
|
+
status: 'fail'
|
|
799
|
+
})
|
|
800
|
+
.toArray((err, result) => {
|
|
801
|
+
if (err)
|
|
802
|
+
return cb(err);
|
|
803
|
+
if (!result || lodash_1.default.isEmpty(result))
|
|
804
|
+
return cb(null, []);
|
|
805
|
+
const emails = lodash_1.default.map(result, x => {
|
|
806
|
+
return model_1.Email.fromObj(x);
|
|
807
|
+
});
|
|
808
|
+
return cb(null, emails);
|
|
809
|
+
});
|
|
810
|
+
}
|
|
811
|
+
fetchEmailByNotification(notificationId, cb) {
|
|
812
|
+
this.db.collection(collections.EMAIL_QUEUE).findOne({
|
|
813
|
+
notificationId
|
|
814
|
+
}, (err, result) => {
|
|
815
|
+
if (err)
|
|
816
|
+
return cb(err);
|
|
817
|
+
if (!result)
|
|
818
|
+
return cb();
|
|
819
|
+
return cb(null, model_1.Email.fromObj(result));
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
getTxHistoryCacheStatusV8(walletId, cb) {
|
|
823
|
+
this.db.collection(collections.CACHE).findOne({
|
|
824
|
+
walletId,
|
|
825
|
+
type: 'historyCacheStatusV8',
|
|
826
|
+
key: null
|
|
827
|
+
}, (err, result) => {
|
|
828
|
+
if (err)
|
|
829
|
+
return cb(err);
|
|
830
|
+
if (!result)
|
|
831
|
+
return cb(null, {
|
|
832
|
+
tipId: null,
|
|
833
|
+
tipIndex: null
|
|
834
|
+
});
|
|
835
|
+
return cb(null, {
|
|
836
|
+
updatedOn: result.updatedOn,
|
|
837
|
+
updatedHeight: result.updatedHeight,
|
|
838
|
+
tipIndex: result.tipIndex,
|
|
839
|
+
tipTxId: result.tipTxId,
|
|
840
|
+
tipHeight: result.tipHeight
|
|
841
|
+
});
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
getWalletAddressChecked(walletId, cb) {
|
|
845
|
+
this.db.collection(collections.CACHE).findOne({
|
|
846
|
+
walletId,
|
|
847
|
+
type: 'addressChecked',
|
|
848
|
+
key: null
|
|
849
|
+
}, (err, result) => {
|
|
850
|
+
if (err || !result)
|
|
851
|
+
return cb(err);
|
|
852
|
+
return cb(null, result.totalAddresses);
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
setWalletAddressChecked(walletId, totalAddresses, cb) {
|
|
856
|
+
this.db.collection(collections.CACHE).replaceOne({
|
|
857
|
+
walletId,
|
|
858
|
+
type: 'addressChecked',
|
|
859
|
+
key: null
|
|
860
|
+
}, {
|
|
861
|
+
walletId,
|
|
862
|
+
type: 'addressChecked',
|
|
863
|
+
key: null,
|
|
864
|
+
totalAddresses
|
|
865
|
+
}, {
|
|
866
|
+
w: 1,
|
|
867
|
+
upsert: true
|
|
868
|
+
}, cb);
|
|
869
|
+
}
|
|
870
|
+
getTxHistoryCacheV8(walletId, skip, limit, cb) {
|
|
871
|
+
$.checkArgument(skip >= 0);
|
|
872
|
+
$.checkArgument(limit >= 0);
|
|
873
|
+
this.getTxHistoryCacheStatusV8(walletId, (err, cacheStatus) => {
|
|
874
|
+
if (err)
|
|
875
|
+
return cb(err);
|
|
876
|
+
if (lodash_1.default.isNull(cacheStatus.tipId))
|
|
877
|
+
return cb(null, []);
|
|
878
|
+
let firstPosition = cacheStatus.tipIndex - skip - limit + 1;
|
|
879
|
+
const lastPosition = cacheStatus.tipIndex - skip + 1;
|
|
880
|
+
if (firstPosition < 0)
|
|
881
|
+
firstPosition = 0;
|
|
882
|
+
if (lastPosition <= 0)
|
|
883
|
+
return cb(null, []);
|
|
884
|
+
this.db
|
|
885
|
+
.collection(collections.CACHE)
|
|
886
|
+
.find({
|
|
887
|
+
walletId,
|
|
888
|
+
type: 'historyCacheV8',
|
|
889
|
+
key: {
|
|
890
|
+
$gte: firstPosition,
|
|
891
|
+
$lt: lastPosition
|
|
892
|
+
}
|
|
893
|
+
})
|
|
894
|
+
.sort({
|
|
895
|
+
key: -1
|
|
896
|
+
})
|
|
897
|
+
.toArray((err, result) => {
|
|
898
|
+
if (err)
|
|
899
|
+
return cb(err);
|
|
900
|
+
if (!result)
|
|
901
|
+
return cb();
|
|
902
|
+
const txs = lodash_1.default.map(result, 'tx');
|
|
903
|
+
return cb(null, txs);
|
|
904
|
+
});
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
clearWalletCache(walletId, cb) {
|
|
908
|
+
this.db.collection(collections.CACHE).deleteMany({
|
|
909
|
+
walletId
|
|
910
|
+
}, {}, cb);
|
|
911
|
+
}
|
|
912
|
+
storeTxHistoryStreamV8(walletId, streamKey, items, cb) {
|
|
913
|
+
this.db.collection(collections.CACHE).replaceOne({
|
|
914
|
+
walletId,
|
|
915
|
+
type: 'historyStream',
|
|
916
|
+
key: null
|
|
917
|
+
}, {
|
|
918
|
+
walletId,
|
|
919
|
+
type: 'historyStream',
|
|
920
|
+
key: null,
|
|
921
|
+
streamKey,
|
|
922
|
+
items
|
|
923
|
+
}, {
|
|
924
|
+
w: 1,
|
|
925
|
+
upsert: true
|
|
926
|
+
}, cb);
|
|
927
|
+
}
|
|
928
|
+
clearTxHistoryStreamV8(walletId, cb) {
|
|
929
|
+
this.db.collection(collections.CACHE).deleteMany({
|
|
930
|
+
walletId,
|
|
931
|
+
type: 'historyStream',
|
|
932
|
+
key: null
|
|
933
|
+
}, {}, cb);
|
|
934
|
+
}
|
|
935
|
+
getTxHistoryStreamV8(walletId, cb) {
|
|
936
|
+
this.db.collection(collections.CACHE).findOne({
|
|
937
|
+
walletId,
|
|
938
|
+
type: 'historyStream',
|
|
939
|
+
key: null
|
|
940
|
+
}, (err, result) => {
|
|
941
|
+
if (err || !result)
|
|
942
|
+
return cb(err);
|
|
943
|
+
return cb(null, result);
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
storeTxHistoryCacheV8(walletId, tipIndex, items, updateHeight, cb) {
|
|
947
|
+
let index = lodash_1.default.isNull(tipIndex) ? 0 : tipIndex + 1;
|
|
948
|
+
let pos;
|
|
949
|
+
lodash_1.default.each(items.reverse(), item => {
|
|
950
|
+
item.position = index++;
|
|
951
|
+
});
|
|
952
|
+
async.each(items, (item, next) => {
|
|
953
|
+
pos = item.position;
|
|
954
|
+
delete item.position;
|
|
955
|
+
this.db.collection(collections.CACHE).insertOne({
|
|
956
|
+
walletId,
|
|
957
|
+
type: 'historyCacheV8',
|
|
958
|
+
key: pos,
|
|
959
|
+
tx: item
|
|
960
|
+
}, next);
|
|
961
|
+
}, err => {
|
|
962
|
+
if (err)
|
|
963
|
+
return cb(err);
|
|
964
|
+
const first = lodash_1.default.first(items);
|
|
965
|
+
const last = lodash_1.default.last(items);
|
|
966
|
+
try {
|
|
967
|
+
$.checkState(last.txid, 'Failed state: missing txid in tx to be cached at <storeHistoryCacheV8()>');
|
|
968
|
+
$.checkState(last.blockheight, 'Failed state: missing blockheight in tx to be cached at <storeHistoryCacheV8()>');
|
|
969
|
+
$.checkState(first.blockheight, 'Failed state: missing blockheight in tx to be cached at <storeHistoryCacheV8()>');
|
|
970
|
+
$.checkState(last.blockheight >= 0, 'Failed state: blockheight <=0 om tx to be cached at <storeHistoryCacheV8()>');
|
|
971
|
+
$.checkState(first.blockheight <= last.blockheight, 'Failed state: tx to be cached are in wrong order (lastest should be first)');
|
|
972
|
+
}
|
|
973
|
+
catch (e) {
|
|
974
|
+
return cb(e);
|
|
975
|
+
}
|
|
976
|
+
logger_1.default.debug(`Cache Last Item: ${last.txid} blockh: ${last.blockheight} updatedh: ${updateHeight}`);
|
|
977
|
+
this.db.collection(collections.CACHE).replaceOne({
|
|
978
|
+
walletId,
|
|
979
|
+
type: 'historyCacheStatusV8',
|
|
980
|
+
key: null
|
|
981
|
+
}, {
|
|
982
|
+
walletId,
|
|
983
|
+
type: 'historyCacheStatusV8',
|
|
984
|
+
key: null,
|
|
985
|
+
updatedOn: Date.now(),
|
|
986
|
+
updatedHeight: updateHeight,
|
|
987
|
+
tipIndex: pos,
|
|
988
|
+
tipTxId: last.txid,
|
|
989
|
+
tipHeight: last.blockheight
|
|
990
|
+
}, {
|
|
991
|
+
w: 1,
|
|
992
|
+
upsert: true
|
|
993
|
+
}, cb);
|
|
994
|
+
});
|
|
995
|
+
}
|
|
996
|
+
storeFiatRate(coin, rates, cb) {
|
|
997
|
+
const now = Date.now();
|
|
998
|
+
async.each(rates, (rate, next) => {
|
|
999
|
+
const i = {
|
|
1000
|
+
ts: now,
|
|
1001
|
+
coin,
|
|
1002
|
+
code: rate.code,
|
|
1003
|
+
value: rate.value
|
|
1004
|
+
};
|
|
1005
|
+
this.db.collection(collections.FIAT_RATES2).insertOne(i, {
|
|
1006
|
+
w: 1
|
|
1007
|
+
}, next);
|
|
1008
|
+
}, cb);
|
|
1009
|
+
}
|
|
1010
|
+
fetchFiatRate(coin, code, ts, cb) {
|
|
1011
|
+
this.db
|
|
1012
|
+
.collection(collections.FIAT_RATES2)
|
|
1013
|
+
.find({
|
|
1014
|
+
coin,
|
|
1015
|
+
code,
|
|
1016
|
+
ts: {
|
|
1017
|
+
$lte: ts
|
|
1018
|
+
}
|
|
1019
|
+
})
|
|
1020
|
+
.sort({
|
|
1021
|
+
ts: -1
|
|
1022
|
+
})
|
|
1023
|
+
.limit(1)
|
|
1024
|
+
.toArray((err, result) => {
|
|
1025
|
+
if (err || lodash_1.default.isEmpty(result))
|
|
1026
|
+
return cb(err);
|
|
1027
|
+
return cb(null, result[0]);
|
|
1028
|
+
});
|
|
1029
|
+
}
|
|
1030
|
+
fetchHistoricalRates(coin, code, ts, cb) {
|
|
1031
|
+
this.db
|
|
1032
|
+
.collection(collections.FIAT_RATES2)
|
|
1033
|
+
.find({
|
|
1034
|
+
coin,
|
|
1035
|
+
code,
|
|
1036
|
+
ts: {
|
|
1037
|
+
$gte: ts
|
|
1038
|
+
}
|
|
1039
|
+
})
|
|
1040
|
+
.sort({
|
|
1041
|
+
ts: -1
|
|
1042
|
+
})
|
|
1043
|
+
.toArray((err, result) => {
|
|
1044
|
+
if (err || lodash_1.default.isEmpty(result))
|
|
1045
|
+
return cb(err);
|
|
1046
|
+
return cb(null, result);
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
fetchTxNote(walletId, txid, cb) {
|
|
1050
|
+
this.db.collection(collections.TX_NOTES).findOne({
|
|
1051
|
+
walletId,
|
|
1052
|
+
txid
|
|
1053
|
+
}, (err, result) => {
|
|
1054
|
+
if (err)
|
|
1055
|
+
return cb(err);
|
|
1056
|
+
if (!result)
|
|
1057
|
+
return cb();
|
|
1058
|
+
return this._completeTxNotesData(walletId, model_1.TxNote.fromObj(result), cb);
|
|
1059
|
+
});
|
|
1060
|
+
}
|
|
1061
|
+
_completeTxNotesData(walletId, notes, cb) {
|
|
1062
|
+
this.fetchWallet(walletId, (err, wallet) => {
|
|
1063
|
+
if (err)
|
|
1064
|
+
return cb(err);
|
|
1065
|
+
lodash_1.default.each([].concat(notes), note => {
|
|
1066
|
+
note.editedByName = wallet.getCopayer(note.editedBy).name;
|
|
1067
|
+
});
|
|
1068
|
+
return cb(null, notes);
|
|
1069
|
+
});
|
|
1070
|
+
}
|
|
1071
|
+
fetchTxNotes(walletId, opts, cb) {
|
|
1072
|
+
const filter = {
|
|
1073
|
+
walletId
|
|
1074
|
+
};
|
|
1075
|
+
if (lodash_1.default.isNumber(opts.minTs))
|
|
1076
|
+
filter.editedOn = {
|
|
1077
|
+
$gte: opts.minTs
|
|
1078
|
+
};
|
|
1079
|
+
this.db
|
|
1080
|
+
.collection(collections.TX_NOTES)
|
|
1081
|
+
.find(filter)
|
|
1082
|
+
.toArray((err, result) => {
|
|
1083
|
+
if (err)
|
|
1084
|
+
return cb(err);
|
|
1085
|
+
const notes = lodash_1.default.compact(lodash_1.default.map(result, note => {
|
|
1086
|
+
return model_1.TxNote.fromObj(note);
|
|
1087
|
+
}));
|
|
1088
|
+
return this._completeTxNotesData(walletId, notes, cb);
|
|
1089
|
+
});
|
|
1090
|
+
}
|
|
1091
|
+
storeTxNote(txNote, cb) {
|
|
1092
|
+
this.db.collection(collections.TX_NOTES).replaceOne({
|
|
1093
|
+
txid: txNote.txid,
|
|
1094
|
+
walletId: txNote.walletId
|
|
1095
|
+
}, txNote.toObject(), {
|
|
1096
|
+
w: 1,
|
|
1097
|
+
upsert: true
|
|
1098
|
+
}, cb);
|
|
1099
|
+
}
|
|
1100
|
+
getSession(copayerId, cb) {
|
|
1101
|
+
this.db.collection(collections.SESSIONS).findOne({
|
|
1102
|
+
copayerId
|
|
1103
|
+
}, (err, result) => {
|
|
1104
|
+
if (err || !result)
|
|
1105
|
+
return cb(err);
|
|
1106
|
+
return cb(null, model_1.Session.fromObj(result));
|
|
1107
|
+
});
|
|
1108
|
+
}
|
|
1109
|
+
storeSession(session, cb) {
|
|
1110
|
+
this.db.collection(collections.SESSIONS).replaceOne({
|
|
1111
|
+
copayerId: session.copayerId
|
|
1112
|
+
}, session.toObject(), {
|
|
1113
|
+
w: 1,
|
|
1114
|
+
upsert: true
|
|
1115
|
+
}, cb);
|
|
1116
|
+
}
|
|
1117
|
+
fetchPushNotificationSubs(copayerId, cb) {
|
|
1118
|
+
this.db
|
|
1119
|
+
.collection(collections.PUSH_NOTIFICATION_SUBS)
|
|
1120
|
+
.find({
|
|
1121
|
+
copayerId
|
|
1122
|
+
})
|
|
1123
|
+
.toArray((err, result) => {
|
|
1124
|
+
if (err)
|
|
1125
|
+
return cb(err);
|
|
1126
|
+
if (!result)
|
|
1127
|
+
return cb();
|
|
1128
|
+
const tokens = lodash_1.default.map([].concat(result), r => {
|
|
1129
|
+
return model_1.PushNotificationSub.fromObj(r);
|
|
1130
|
+
});
|
|
1131
|
+
return cb(null, tokens);
|
|
1132
|
+
});
|
|
1133
|
+
}
|
|
1134
|
+
fetchLatestPushNotificationSubs(cb) {
|
|
1135
|
+
const fromDate = new Date().getTime() - Defaults.PUSH_NOTIFICATION_SUBS_TIME;
|
|
1136
|
+
this.db
|
|
1137
|
+
.collection(collections.PUSH_NOTIFICATION_SUBS)
|
|
1138
|
+
.find({
|
|
1139
|
+
_id: {
|
|
1140
|
+
$gte: new ObjectID(objectIdDate(fromDate))
|
|
1141
|
+
}
|
|
1142
|
+
})
|
|
1143
|
+
.sort({ _id: -1 })
|
|
1144
|
+
.toArray((err, result) => {
|
|
1145
|
+
if (err)
|
|
1146
|
+
return cb(err);
|
|
1147
|
+
if (!result)
|
|
1148
|
+
return cb();
|
|
1149
|
+
const tokens = lodash_1.default.map([].concat(result), r => {
|
|
1150
|
+
return model_1.PushNotificationSub.fromObj(r);
|
|
1151
|
+
});
|
|
1152
|
+
return cb(null, tokens);
|
|
1153
|
+
});
|
|
1154
|
+
}
|
|
1155
|
+
storePushNotificationSub(pushNotificationSub, cb) {
|
|
1156
|
+
this.db.collection(collections.PUSH_NOTIFICATION_SUBS).replaceOne({
|
|
1157
|
+
copayerId: pushNotificationSub.copayerId,
|
|
1158
|
+
token: pushNotificationSub.token
|
|
1159
|
+
}, pushNotificationSub, {
|
|
1160
|
+
w: 1,
|
|
1161
|
+
upsert: true
|
|
1162
|
+
}, cb);
|
|
1163
|
+
}
|
|
1164
|
+
removePushNotificationSub(copayerId, token, cb) {
|
|
1165
|
+
this.db.collection(collections.PUSH_NOTIFICATION_SUBS).deleteMany({
|
|
1166
|
+
copayerId,
|
|
1167
|
+
token
|
|
1168
|
+
}, {
|
|
1169
|
+
w: 1
|
|
1170
|
+
}, cb);
|
|
1171
|
+
}
|
|
1172
|
+
storePushNotificationBrazeSub(pushNotificationSub, cb) {
|
|
1173
|
+
this.db.collection(collections.PUSH_NOTIFICATION_SUBS).replaceOne({
|
|
1174
|
+
copayerId: pushNotificationSub.copayerId,
|
|
1175
|
+
externalUserId: pushNotificationSub.externalUserId
|
|
1176
|
+
}, pushNotificationSub, {
|
|
1177
|
+
w: 1,
|
|
1178
|
+
upsert: true
|
|
1179
|
+
}, cb);
|
|
1180
|
+
}
|
|
1181
|
+
removePushNotificationBrazeSub(copayerId, externalUserId, cb) {
|
|
1182
|
+
this.db.collection(collections.PUSH_NOTIFICATION_SUBS).deleteMany({
|
|
1183
|
+
copayerId,
|
|
1184
|
+
externalUserId
|
|
1185
|
+
}, {
|
|
1186
|
+
w: 1
|
|
1187
|
+
}, cb);
|
|
1188
|
+
}
|
|
1189
|
+
streamActiveTxConfirmationSubs(copayerId, txids) {
|
|
1190
|
+
if (!this.db) {
|
|
1191
|
+
logger_1.default.warn('Trying to fetch notifications with closed DB');
|
|
1192
|
+
return;
|
|
1193
|
+
}
|
|
1194
|
+
const filter = {
|
|
1195
|
+
isActive: true,
|
|
1196
|
+
txid: { $in: txids }
|
|
1197
|
+
};
|
|
1198
|
+
if (copayerId)
|
|
1199
|
+
filter.copayerId = copayerId;
|
|
1200
|
+
return this.db
|
|
1201
|
+
.collection(collections.TX_CONFIRMATION_SUBS)
|
|
1202
|
+
.find(filter)
|
|
1203
|
+
.addCursorFlag('noCursorTimeout', true);
|
|
1204
|
+
}
|
|
1205
|
+
storeTxConfirmationSub(txConfirmationSub, cb) {
|
|
1206
|
+
this.db.collection(collections.TX_CONFIRMATION_SUBS).replaceOne({
|
|
1207
|
+
copayerId: txConfirmationSub.copayerId,
|
|
1208
|
+
txid: txConfirmationSub.txid
|
|
1209
|
+
}, txConfirmationSub, {
|
|
1210
|
+
w: 1,
|
|
1211
|
+
upsert: true
|
|
1212
|
+
}, cb);
|
|
1213
|
+
}
|
|
1214
|
+
removeTxConfirmationSub(copayerId, txid, cb) {
|
|
1215
|
+
this.db.collection(collections.TX_CONFIRMATION_SUBS).deleteMany({
|
|
1216
|
+
copayerId,
|
|
1217
|
+
txid
|
|
1218
|
+
}, {
|
|
1219
|
+
w: 1
|
|
1220
|
+
}, cb);
|
|
1221
|
+
}
|
|
1222
|
+
_dump(cb, fn) {
|
|
1223
|
+
fn = fn || console.log;
|
|
1224
|
+
cb = cb || function () { };
|
|
1225
|
+
this.db.collections((err, collections) => {
|
|
1226
|
+
if (err)
|
|
1227
|
+
return cb(err);
|
|
1228
|
+
async.eachSeries(collections, (col, next) => {
|
|
1229
|
+
col.find().toArray((err, items) => {
|
|
1230
|
+
fn('--------', col.s.name);
|
|
1231
|
+
fn(items);
|
|
1232
|
+
fn('------------------------------------------------------------------\n\n');
|
|
1233
|
+
next(err);
|
|
1234
|
+
});
|
|
1235
|
+
}, cb);
|
|
1236
|
+
});
|
|
1237
|
+
}
|
|
1238
|
+
checkAndUseGlobalCache(key, duration, cb) {
|
|
1239
|
+
const now = Date.now();
|
|
1240
|
+
this.db.collection(collections.CACHE).findOne({
|
|
1241
|
+
key,
|
|
1242
|
+
walletId: null,
|
|
1243
|
+
type: null
|
|
1244
|
+
}, (err, ret) => {
|
|
1245
|
+
if (err)
|
|
1246
|
+
return cb(err);
|
|
1247
|
+
if (!ret)
|
|
1248
|
+
return cb();
|
|
1249
|
+
const validFor = ret.ts + duration - now;
|
|
1250
|
+
return cb(null, validFor > 0 ? ret.result : null, ret.result);
|
|
1251
|
+
});
|
|
1252
|
+
}
|
|
1253
|
+
storeGlobalCache(key, values, cb) {
|
|
1254
|
+
const now = Date.now();
|
|
1255
|
+
this.db.collection(collections.CACHE).updateOne({
|
|
1256
|
+
key,
|
|
1257
|
+
walletId: null,
|
|
1258
|
+
type: null
|
|
1259
|
+
}, {
|
|
1260
|
+
$set: {
|
|
1261
|
+
ts: now,
|
|
1262
|
+
result: values
|
|
1263
|
+
}
|
|
1264
|
+
}, {
|
|
1265
|
+
w: 1,
|
|
1266
|
+
upsert: true
|
|
1267
|
+
}, cb);
|
|
1268
|
+
}
|
|
1269
|
+
clearGlobalCache(key, cb) {
|
|
1270
|
+
this.db.collection(collections.CACHE).deleteMany({
|
|
1271
|
+
key,
|
|
1272
|
+
walletId: null,
|
|
1273
|
+
type: null
|
|
1274
|
+
}, {
|
|
1275
|
+
w: 1
|
|
1276
|
+
}, cb);
|
|
1277
|
+
}
|
|
1278
|
+
walletCheck = async (params) => {
|
|
1279
|
+
const { walletId } = params;
|
|
1280
|
+
return new Promise(resolve => {
|
|
1281
|
+
const addressStream = this.db.collection(collections.ADDRESSES).find({ walletId });
|
|
1282
|
+
let sum = 0;
|
|
1283
|
+
let lastAddress;
|
|
1284
|
+
addressStream.on('data', walletAddress => {
|
|
1285
|
+
if (walletAddress.address) {
|
|
1286
|
+
lastAddress = walletAddress.address.replace(/:.*$/, '');
|
|
1287
|
+
const addressSum = Buffer.from(lastAddress).reduce((tot, cur) => (tot + cur) % Number.MAX_SAFE_INTEGER);
|
|
1288
|
+
sum = (sum + addressSum) % Number.MAX_SAFE_INTEGER;
|
|
1289
|
+
}
|
|
1290
|
+
});
|
|
1291
|
+
addressStream.on('end', () => {
|
|
1292
|
+
resolve({ lastAddress, sum });
|
|
1293
|
+
});
|
|
1294
|
+
});
|
|
1295
|
+
};
|
|
1296
|
+
acquireLock(key, expireTs, cb) {
|
|
1297
|
+
this.db.collection(collections.LOCKS).insertOne({
|
|
1298
|
+
_id: key,
|
|
1299
|
+
expireOn: expireTs
|
|
1300
|
+
}, {}, cb);
|
|
1301
|
+
}
|
|
1302
|
+
releaseLock(key, cb) {
|
|
1303
|
+
this.db.collection(collections.LOCKS).deleteMany({
|
|
1304
|
+
_id: key
|
|
1305
|
+
}, {}, cb);
|
|
1306
|
+
}
|
|
1307
|
+
clearExpiredLock(key, cb) {
|
|
1308
|
+
this.db.collection(collections.LOCKS).findOne({
|
|
1309
|
+
_id: key
|
|
1310
|
+
}, (err, ret) => {
|
|
1311
|
+
if (err || !ret)
|
|
1312
|
+
return;
|
|
1313
|
+
if (ret.expireOn < Date.now()) {
|
|
1314
|
+
logger_1.default.info('Releasing expired lock : ' + key);
|
|
1315
|
+
return this.releaseLock(key, cb);
|
|
1316
|
+
}
|
|
1317
|
+
return cb();
|
|
1318
|
+
});
|
|
1319
|
+
}
|
|
1320
|
+
fetchTestingAdverts(cb) {
|
|
1321
|
+
this.db
|
|
1322
|
+
.collection(collections.ADVERTISEMENTS)
|
|
1323
|
+
.find({
|
|
1324
|
+
isTesting: true
|
|
1325
|
+
})
|
|
1326
|
+
.toArray((err, result) => {
|
|
1327
|
+
if (err)
|
|
1328
|
+
return cb(err);
|
|
1329
|
+
if (!result)
|
|
1330
|
+
return cb();
|
|
1331
|
+
return cb(null, result.map(model_1.Advertisement.fromObj));
|
|
1332
|
+
});
|
|
1333
|
+
}
|
|
1334
|
+
fetchActiveAdverts(cb) {
|
|
1335
|
+
this.db
|
|
1336
|
+
.collection(collections.ADVERTISEMENTS)
|
|
1337
|
+
.find({
|
|
1338
|
+
isAdActive: true
|
|
1339
|
+
})
|
|
1340
|
+
.toArray((err, result) => {
|
|
1341
|
+
if (err)
|
|
1342
|
+
return cb(err);
|
|
1343
|
+
if (!result)
|
|
1344
|
+
return cb();
|
|
1345
|
+
return cb(null, result.map(model_1.Advertisement.fromObj));
|
|
1346
|
+
});
|
|
1347
|
+
}
|
|
1348
|
+
fetchAdvertsByCountry(country, cb) {
|
|
1349
|
+
this.db
|
|
1350
|
+
.collection(collections.ADVERTISEMENTS)
|
|
1351
|
+
.find({
|
|
1352
|
+
country
|
|
1353
|
+
})
|
|
1354
|
+
.toArray((err, result) => {
|
|
1355
|
+
if (err)
|
|
1356
|
+
return cb(err);
|
|
1357
|
+
if (!result)
|
|
1358
|
+
return cb();
|
|
1359
|
+
return cb(null, result.map(model_1.Advertisement.fromObj));
|
|
1360
|
+
});
|
|
1361
|
+
}
|
|
1362
|
+
fetchAllAdverts(_cb) {
|
|
1363
|
+
this.db.collection(collections.ADVERTISEMENTS).find({});
|
|
1364
|
+
}
|
|
1365
|
+
removeAdvert(adId, cb) {
|
|
1366
|
+
this.db.collection(collections.ADVERTISEMENTS).deleteOne({
|
|
1367
|
+
advertisementId: adId
|
|
1368
|
+
}, {
|
|
1369
|
+
w: 1
|
|
1370
|
+
}, cb);
|
|
1371
|
+
}
|
|
1372
|
+
storeAdvert(advert, cb) {
|
|
1373
|
+
this.db.collection(collections.ADVERTISEMENTS).updateOne({
|
|
1374
|
+
advertisementId: advert.advertisementId
|
|
1375
|
+
}, { $set: advert }, {
|
|
1376
|
+
upsert: true
|
|
1377
|
+
}, cb);
|
|
1378
|
+
}
|
|
1379
|
+
fetchAdvert(adId, cb) {
|
|
1380
|
+
this.db.collection(collections.ADVERTISEMENTS).findOne({
|
|
1381
|
+
advertisementId: adId
|
|
1382
|
+
}, (err, result) => {
|
|
1383
|
+
if (err)
|
|
1384
|
+
return cb(err);
|
|
1385
|
+
if (!result)
|
|
1386
|
+
return cb();
|
|
1387
|
+
return cb(null, model_1.Advertisement.fromObj(result));
|
|
1388
|
+
});
|
|
1389
|
+
}
|
|
1390
|
+
activateAdvert(adId, cb) {
|
|
1391
|
+
this.db.collection(collections.ADVERTISEMENTS).updateOne({
|
|
1392
|
+
advertisementId: adId
|
|
1393
|
+
}, { $set: { isAdActive: true, isTesting: false } }, {
|
|
1394
|
+
upsert: true
|
|
1395
|
+
}, cb);
|
|
1396
|
+
}
|
|
1397
|
+
deactivateAdvert(adId, cb) {
|
|
1398
|
+
this.db.collection(collections.ADVERTISEMENTS).updateOne({
|
|
1399
|
+
advertisementId: adId
|
|
1400
|
+
}, {
|
|
1401
|
+
$set: { isAdActive: false, isTesting: true }
|
|
1402
|
+
}, {
|
|
1403
|
+
upsert: true
|
|
1404
|
+
}, cb);
|
|
1405
|
+
}
|
|
1406
|
+
async fetchTssKeyGenSession({ id }) {
|
|
1407
|
+
const doc = await this.db.collection(collections.TSS_KEYGEN).findOne({ id });
|
|
1408
|
+
if (!doc) {
|
|
1409
|
+
return null;
|
|
1410
|
+
}
|
|
1411
|
+
return tsskeygen_1.TssKeyGenModel.fromObj(doc);
|
|
1412
|
+
}
|
|
1413
|
+
async storeTssKeyGenSession({ doc }) {
|
|
1414
|
+
return this.db.collection(collections.TSS_KEYGEN).insertOne(doc);
|
|
1415
|
+
}
|
|
1416
|
+
async storeTssKeyGenParticipant({ id, partyId, copayerId }) {
|
|
1417
|
+
return this.db.collection(collections.TSS_KEYGEN).updateOne({ id }, {
|
|
1418
|
+
$set: {
|
|
1419
|
+
[`participants.${partyId}`]: copayerId
|
|
1420
|
+
}
|
|
1421
|
+
}, { upsert: false });
|
|
1422
|
+
}
|
|
1423
|
+
async storeTssKeyGenMessage({ id, message, __v }) {
|
|
1424
|
+
const result = await this.db.collection(collections.TSS_KEYGEN).updateOne({ id, __v }, {
|
|
1425
|
+
$push: {
|
|
1426
|
+
[`rounds.${message.round}`]: {
|
|
1427
|
+
fromPartyId: message.partyId,
|
|
1428
|
+
messages: message
|
|
1429
|
+
}
|
|
1430
|
+
},
|
|
1431
|
+
$inc: {
|
|
1432
|
+
__v: 1
|
|
1433
|
+
}
|
|
1434
|
+
}, { upsert: false });
|
|
1435
|
+
if (!result.matchedCount) {
|
|
1436
|
+
throw new Error('MONGO_DOC_OUTDATED: No document found for version ' + __v);
|
|
1437
|
+
}
|
|
1438
|
+
return result;
|
|
1439
|
+
}
|
|
1440
|
+
async storeTssKeySharedPubKey({ id, publicKey }) {
|
|
1441
|
+
return this.db.collection(collections.TSS_KEYGEN).updateOne({ id }, {
|
|
1442
|
+
$set: {
|
|
1443
|
+
sharedPublicKey: publicKey
|
|
1444
|
+
}
|
|
1445
|
+
}, { upsert: false });
|
|
1446
|
+
}
|
|
1447
|
+
async storeTssKeyShare({ id, partyId, encryptedKeyChain }) {
|
|
1448
|
+
return this.db.collection(collections.TSS_KEYGEN).updateOne({ id }, {
|
|
1449
|
+
$set: {
|
|
1450
|
+
[`keyShares.${partyId}`]: encryptedKeyChain
|
|
1451
|
+
}
|
|
1452
|
+
}, { upsert: false });
|
|
1453
|
+
}
|
|
1454
|
+
async storeTssKeyBwsJoinSecret({ id, secret }) {
|
|
1455
|
+
return this.db.collection(collections.TSS_KEYGEN).updateOne({
|
|
1456
|
+
id
|
|
1457
|
+
}, {
|
|
1458
|
+
$set: {
|
|
1459
|
+
bwsJoinSecret: secret
|
|
1460
|
+
}
|
|
1461
|
+
}, { upsert: false });
|
|
1462
|
+
}
|
|
1463
|
+
async fetchTssSigSession({ id }) {
|
|
1464
|
+
const doc = await this.db.collection(collections.TSS_SIGN).findOne({ id });
|
|
1465
|
+
if (!doc) {
|
|
1466
|
+
return null;
|
|
1467
|
+
}
|
|
1468
|
+
return tsssign_1.TssSigGenModel.fromObj(doc);
|
|
1469
|
+
}
|
|
1470
|
+
async storeTssSigSession({ doc }) {
|
|
1471
|
+
return this.db.collection(collections.TSS_SIGN).insertOne(doc);
|
|
1472
|
+
}
|
|
1473
|
+
async storeTssSigParticipant({ id, partyId, copayerId, __v }) {
|
|
1474
|
+
const result = await this.db.collection(collections.TSS_SIGN).updateOne({ id, __v }, {
|
|
1475
|
+
$push: {
|
|
1476
|
+
participants: {
|
|
1477
|
+
partyId,
|
|
1478
|
+
copayerId
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
}, { upsert: false });
|
|
1482
|
+
if (!result.matchedCount) {
|
|
1483
|
+
throw new Error('MONGO_DOC_OUTDATED: No document found for version ' + __v);
|
|
1484
|
+
}
|
|
1485
|
+
return result;
|
|
1486
|
+
}
|
|
1487
|
+
async storeTssSigMessage({ id, message, __v }) {
|
|
1488
|
+
const result = await this.db.collection(collections.TSS_SIGN).updateOne({ id, __v }, {
|
|
1489
|
+
$push: {
|
|
1490
|
+
[`rounds.${message.round}`]: {
|
|
1491
|
+
fromPartyId: message.partyId,
|
|
1492
|
+
messages: message
|
|
1493
|
+
}
|
|
1494
|
+
},
|
|
1495
|
+
$inc: {
|
|
1496
|
+
__v: 1
|
|
1497
|
+
}
|
|
1498
|
+
}, { upsert: false });
|
|
1499
|
+
if (!result.matchedCount) {
|
|
1500
|
+
throw new Error('MONGO_DOC_OUTDATED: No document found for version ' + __v);
|
|
1501
|
+
}
|
|
1502
|
+
return result;
|
|
1503
|
+
}
|
|
1504
|
+
async storeTssSignature({ id, signature }) {
|
|
1505
|
+
return this.db.collection(collections.TSS_SIGN).updateOne({ id }, {
|
|
1506
|
+
$set: {
|
|
1507
|
+
signature
|
|
1508
|
+
}
|
|
1509
|
+
}, { upsert: false });
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
exports.Storage = Storage;
|
|
1513
|
+
//# sourceMappingURL=storage.js.map
|