2.0.7 • Published 3 months ago

@getsafle/vault-bitcoin-controller v2.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

bitcoin-controller

npm version Discussions

Install

npm install --save @getsafle/vault-bitcoin-controller

Initialize the Bitcoin Controller class

const { KeyringController, getBalance } = require('@getsafle/vault-bitcoin-controller');

const bitcoinController = new KeyringController({
    // 12 words mnemonic to create wallet
    mnemonic: string,
    // network - type of network [TESTNET|MAINNET]
    // default is MAINNET even if no network is passed
    network: string (TESTNET | MAINNET)
});

Methods

Generate Keyring with 1 account or add new account

const keyringState = await bitcoinController.addAccount();

Export the private key of an address present in the keyring

const privateKey = await bitcoinController.exportPrivateKey(address);

Get all accounts in the keyring

const privateKey = await bitcoinController.getAccounts();

Sign a transaction

const signedTx = await bitcoinController.signTransaction(bitcoinTx);

bitcoinTx: {from, to, amount, satPerByt}

Sign a message

const signedMsg = await bitcoinController.signMessage(msgString, address);

Get fees

const fees = await bitcoinController.getFees(rawTransaction);

Get balance

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

3 months ago

2.0.6

3 months ago

2.0.5

3 months ago

2.0.4

4 months ago

2.0.3

5 months ago

2.0.2

5 months ago

2.0.1

7 months ago

2.0.0

7 months ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.0

2 years ago

1.2.1

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago