New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@getsafle/vault-bitcoin-controller

Package Overview
Dependencies
Maintainers
4
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@getsafle/vault-bitcoin-controller - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

6

CHANGELOG.md

@@ -12,1 +12,7 @@ ### 1.0.0 (2021-12-27)

- Added importWallet() to import account using privateKey.
### 1.1.0 (2022-02-16)
##### Implement get balance functionality
- Added getBalance() to fetch the balance in BTC.

2

package.json
{
"name": "@getsafle/vault-bitcoin-controller",
"version": "1.0.1",
"version": "1.1.0",
"description": "",

@@ -5,0 +5,0 @@ "engines": {

@@ -10,5 +10,5 @@ # bitcoin-controller

```
const controller = require('@getsafle/vault-bitcoin-controller');
const { KeyringController, getBalance } = require('@getsafle/vault-bitcoin-controller');
const bitcoinController = new controller({
const bitcoinController = new KeyringController({
// 12 words mnemonic to create wallet

@@ -61,1 +61,7 @@ mnemonic: string,

```
### Get balance
```
const balance = await getBalance(address, network); // if network !== TESTNET then it will fetch mainnet balance
```

@@ -13,5 +13,4 @@ const ObservableStore = require('obs-store')

class KeyringController {
class BTCHdKeyring {
/**

@@ -150,2 +149,12 @@ *

module.exports = BTCHdKeyring
const getBalance = async (address, networkType) => {
try {
const URL = `https://sochain.com/api/v2/get_address_balance/${networkType === TESTNET.NETWORK ? 'BTCTEST' : "BTC"}/${address}`
const balance = await axios.get(URL)
return { balance: balance.data.data.confirmed_balance }
} catch (err) {
throw err
}
}
module.exports = { KeyringController, getBalance }
var assert = require('assert');
const bitcoinMessage = require('bitcoinjs-message')
const Bitcoin = require('../src/index')
const { KeyringController: Bitcoin, getBalance } = require('../src/index')
const {

@@ -87,5 +87,2 @@ HD_WALLET_12_MNEMONIC,

console.log("signedTransaction ", signedTransaction)
const sendTransaction = await bitcoinWallet.sendTransaction(signedTransaction)
console.log("sendTransaction ", sendTransaction)
})

@@ -104,2 +101,9 @@

it("Should get balance of the address ", async () => {
const acc = await bitcoinWallet.getAccounts()
const balance = await getBalance(acc[0], opts.network)
console.log("acc ", acc)
console.log("balance ", balance)
})
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc