@getsafle/vault-bitcoin-controller
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "@getsafle/vault-bitcoin-controller", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "", | ||
@@ -33,9 +33,3 @@ "engines": { | ||
"bitcoinjs-message": "^2.2.0", | ||
"bitcore-explorers": "^1.0.1", | ||
"bitcore-lib": "^8.25.10", | ||
"browser-passworder": "^2.0.3", | ||
"crypto-js": "^4.0.0", | ||
"ed25519-hd-key": "^1.2.0", | ||
"hdkey": "^2.0.1", | ||
"loglevel": "^1.8.0", | ||
"obs-store": "^4.0.3" | ||
@@ -42,0 +36,0 @@ }, |
@@ -7,3 +7,3 @@ # bitcoin-controller | ||
## Initialize the Polygon Controller class | ||
## Initialize the Bitcoin Controller class | ||
@@ -10,0 +10,0 @@ ``` |
@@ -0,0 +0,0 @@ module.exports = { |
@@ -1,2 +0,1 @@ | ||
const axios = require('axios') | ||
const bitcore = require("bitcore-lib") | ||
@@ -13,3 +12,3 @@ const { SATOSHI } = require("../config/index") | ||
const {totalAmountAvailable, inputs, fee} = await getFeeAndInput(URL) | ||
const { totalAmountAvailable, inputs, fee } = await getFeeAndInput(URL) | ||
@@ -16,0 +15,0 @@ if (totalAmountAvailable - satoshiToSend - fee < 0) { |
const getNetwork = require('./getNetwork'); | ||
const generateAddress = require('./generateAddress'); | ||
const calcBip32ExtendedKeys = require('./calcBip32ExtendedKeys'); | ||
const getAddressFromPk = require('./getAddressFromPk'); | ||
@@ -8,3 +9,4 @@ module.exports = { | ||
generateAddress, | ||
calcBip32ExtendedKeys | ||
calcBip32ExtendedKeys, | ||
getAddressFromPk | ||
} |
@@ -1,5 +0,2 @@ | ||
const { EventEmitter } = require('events') | ||
const log = require('loglevel') | ||
const ObservableStore = require('obs-store') | ||
const encryptor = require('browser-passworder') | ||
@@ -27,2 +24,3 @@ const bitcoinjs = require('bitcoinjs-lib') | ||
this.generateWallet() | ||
this.importedWallets = [] | ||
} | ||
@@ -61,2 +59,13 @@ | ||
async importWallet(_privateKey) { | ||
try { | ||
const { network } = this.store.getState() | ||
const address = helpers.utils.getAddressFromPk(_privateKey, network) | ||
this.importedWallets.push(address); | ||
return address | ||
} catch (e) { | ||
return Promise.reject(e) | ||
} | ||
} | ||
/** | ||
@@ -63,0 +72,0 @@ * NATIVE_TRANSFER : {from, to, amount} |
@@ -6,2 +6,11 @@ module.exports = { | ||
EXTERNAL_ACCOUNT_PRIVATE_KEY_MAINNET: "KxF7H3kLetxkVG2545MhhW3vGi6NViLMAhhPfU9M6Qirdx8Thrnw", // works on MAINNET ONLY | ||
EXTERNAL_ACCOUNT_ADDRESS_MAINNET: "bc1qtqectlurn5uhgzdym8ehn8ssxu0vamwsm9he0v", | ||
EXTERNAL_ACCOUNT_PRIVATE_KEY: "cSmqQzpnXgQamBLsNqGXJXEbDx6X9Co1yuUTCpikXLtv8ChNssiY", // works on TESTNET ONLY | ||
EXTERNAL_ACCOUNT_ADDRESS: "tb1qfl644sg3vcyv3gk6h4e8yc8jsmndpclhgusm3p", | ||
EXTERNAL_ACCOUNT_WRONG_PRIVATE_KEY_1: "random_private_key", | ||
EXTERNAL_ACCOUNT_WRONG_PRIVATE_KEY_2: "0xbcb7a8680126610ca94440b020280f9ef829ad26637bfb5cc", | ||
EXTERNAL_ACCOUNT_WRONG_PRIVATE_KEY_3: "QUWL7cmUp9Cj9DF3gLFqqSipopXyzuF4QXmDNV3ZTZ28GB6Ug98Z", | ||
EXTERNAL_ACCOUNT_WRONG_PRIVATE_KEY_4: "0xbcb7a8680126610ca94440b020280f9ef82194a4dc2760653073b5f5b150c9c3", | ||
TESTING_MESSAGE_1: "ThisMessageOneIsForTesting", | ||
@@ -8,0 +17,0 @@ TESTING_MESSAGE_2: "This_message_two_is_for_testing", |
@@ -7,2 +7,10 @@ var assert = require('assert'); | ||
HD_WALLET_12_MNEMONIC_TEST_OTHER, | ||
EXTERNAL_ACCOUNT_PRIVATE_KEY, | ||
EXTERNAL_ACCOUNT_ADDRESS, | ||
EXTERNAL_ACCOUNT_PRIVATE_KEY_MAINNET, | ||
EXTERNAL_ACCOUNT_ADDRESS_MAINNET, | ||
EXTERNAL_ACCOUNT_WRONG_PRIVATE_KEY_1, | ||
EXTERNAL_ACCOUNT_WRONG_PRIVATE_KEY_2, | ||
EXTERNAL_ACCOUNT_WRONG_PRIVATE_KEY_3, | ||
EXTERNAL_ACCOUNT_WRONG_PRIVATE_KEY_4, | ||
TESTING_MESSAGE_1, | ||
@@ -85,2 +93,13 @@ TESTING_MESSAGE_2, | ||
it("Should import correct account ", async () => { | ||
if (opts.network === MAINNET) { | ||
const address = await bitcoinWallet.importWallet(EXTERNAL_ACCOUNT_PRIVATE_KEY_MAINNET) | ||
assert(address.toLowerCase() === EXTERNAL_ACCOUNT_ADDRESS_MAINNET.toLowerCase(), "Wrong address") | ||
} else { | ||
const address = await bitcoinWallet.importWallet(EXTERNAL_ACCOUNT_PRIVATE_KEY) | ||
assert(address.toLowerCase() === EXTERNAL_ACCOUNT_ADDRESS.toLowerCase(), "Wrong address") | ||
} | ||
assert(bitcoinWallet.importedWallets.length === 1, "Should have 1 imported wallet") | ||
}) | ||
}) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20893
6
18
379
- Removedbitcore-explorers@^1.0.1
- Removedbrowser-passworder@^2.0.3
- Removedcrypto-js@^4.0.0
- Removeded25519-hd-key@^1.2.0
- Removedhdkey@^2.0.1
- Removedloglevel@^1.8.0
- Removedajv@6.12.6(transitive)
- Removedasn1@0.2.6(transitive)
- Removedassert-plus@1.0.0(transitive)
- Removedasynckit@0.4.0(transitive)
- Removedaws-sign2@0.7.0(transitive)
- Removedaws4@1.13.2(transitive)
- Removedbcrypt-pbkdf@1.0.2(transitive)
- Removedbitcore-explorers@1.0.1(transitive)
- Removedbitcore-lib@0.13.19(transitive)
- Removedbrowser-passworder@2.0.3(transitive)
- Removedbrowser-request@0.3.3(transitive)
- Removedbrowserify-unibabel@3.0.0(transitive)
- Removedcaseless@0.12.0(transitive)
- Removedcombined-stream@1.0.8(transitive)
- Removedcore-util-is@1.0.2(transitive)
- Removedcrypto-js@4.2.0(transitive)
- Removeddashdash@1.14.1(transitive)
- Removeddelayed-stream@1.0.0(transitive)
- Removedecc-jsbn@0.1.2(transitive)
- Removeded25519-hd-key@1.3.0(transitive)
- Removedextend@3.0.2(transitive)
- Removedextsprintf@1.3.0(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stable-stringify@2.1.0(transitive)
- Removedforever-agent@0.6.1(transitive)
- Removedform-data@2.3.3(transitive)
- Removedgetpass@0.1.7(transitive)
- Removedhar-schema@2.0.0(transitive)
- Removedhar-validator@5.1.5(transitive)
- Removedhdkey@2.1.0(transitive)
- Removedhttp-signature@1.2.0(transitive)
- Removedis-typedarray@1.0.0(transitive)
- Removedisstream@0.1.2(transitive)
- Removedjsbn@0.1.1(transitive)
- Removedjson-schema@0.4.0(transitive)
- Removedjson-schema-traverse@0.4.1(transitive)
- Removedjson-stringify-safe@5.0.1(transitive)
- Removedjsprim@1.4.2(transitive)
- Removedloglevel@1.9.2(transitive)
- Removedmime-db@1.52.0(transitive)
- Removedmime-types@2.1.35(transitive)
- Removednode-addon-api@5.1.0(transitive)
- Removednode-gyp-build@4.8.4(transitive)
- Removedoauth-sign@0.9.0(transitive)
- Removedperformance-now@2.1.0(transitive)
- Removedpsl@1.13.0(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedqs@6.5.3(transitive)
- Removedrequest@2.88.2(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedsecp256k1@4.0.4(transitive)
- Removedsshpk@1.18.0(transitive)
- Removedtough-cookie@2.5.0(transitive)
- Removedtunnel-agent@0.6.0(transitive)
- Removedtweetnacl@0.14.51.0.3(transitive)
- Removeduri-js@4.4.1(transitive)
- Removeduuid@3.4.0(transitive)
- Removedverror@1.10.0(transitive)