@getsafle/vault-bitcoin-controller
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -24,1 +24,7 @@ ### 1.0.0 (2021-12-27) | ||
- Added satPerByte to add custom gas parameter satoshi. | ||
### 1.2.1 (2022-07-19) | ||
##### Make custom gas parameter compulsory | ||
- Changed satPerByte from optional to compulsory parameter. |
{ | ||
"name": "@getsafle/vault-bitcoin-controller", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "engines": { |
@@ -46,3 +46,3 @@ # bitcoin-controller | ||
bitcoinTx: {from, to, amount, satPerByte (optional)} | ||
bitcoinTx: {from, to, amount, satPerByt} | ||
``` | ||
@@ -59,3 +59,3 @@ | ||
``` | ||
const fees = await bitcoinController.getFee(address, satPerByte (optional)); | ||
const fees = await bitcoinController.getFee(address, satPerByte); | ||
``` | ||
@@ -62,0 +62,0 @@ |
@@ -18,4 +18,3 @@ module.exports = { | ||
}, | ||
SATOSHI: 100000000, | ||
DEFAULT_SATOSHI_PER_BYTE: 20 | ||
SATOSHI: 100000000 | ||
} |
const axios = require('axios') | ||
const { SATOSHI, DEFAULT_SATOSHI_PER_BYTE } = require("../config/index") | ||
const { SATOSHI } = require("../config/index") | ||
async function getFeeAndInput(URL, satPerByte = DEFAULT_SATOSHI_PER_BYTE) { | ||
async function getFeeAndInput(URL, satPerByte) { | ||
@@ -6,0 +6,0 @@ let fee = 0; |
@@ -6,3 +6,3 @@ const bitcore = require("bitcore-lib") | ||
async function signTransaction(from, to, amountToSend, URL, privateKey, satPerByte = DEFAULT_SATOSHI_PER_BYTE) { | ||
async function signTransaction(from, to, amountToSend, URL, privateKey, satPerByte) { | ||
@@ -9,0 +9,0 @@ const satoshiToSend = amountToSend * SATOSHI; |
@@ -11,3 +11,3 @@ const ObservableStore = require('obs-store') | ||
const { bitcoin: { HD_PATH }, bitcoin_transaction: { NATIVE_TRANSFER }, bitcoin_network: { MAINNET, TESTNET }, DEFAULT_SATOSHI_PER_BYTE } = require('./config/index') | ||
const { bitcoin: { HD_PATH }, bitcoin_transaction: { NATIVE_TRANSFER }, bitcoin_network: { MAINNET, TESTNET } } = require('./config/index') | ||
@@ -87,3 +87,3 @@ class KeyringController { | ||
try { | ||
const signedTransaction = await helpers.signTransaction(from, to, amount, URL, privkey, satPerByte ? satPerByte : DEFAULT_SATOSHI_PER_BYTE) | ||
const signedTransaction = await helpers.signTransaction(from, to, amount, URL, privkey, satPerByte) | ||
return { signedTransaction }; | ||
@@ -125,3 +125,3 @@ } catch (err) { | ||
async getFee(address, satPerByte = DEFAULT_SATOSHI_PER_BYTE) { | ||
async getFee(address, satPerByte) { | ||
const { networkType } = this.store.getState() | ||
@@ -128,0 +128,0 @@ try { |
@@ -76,3 +76,3 @@ var assert = require('assert'); | ||
it("Get fees", async () => { | ||
it("Get fees will return NaN", async () => { | ||
const acc = await bitcoinWallet.getAccounts() | ||
@@ -89,7 +89,11 @@ const { transactionFees } = await bitcoinWallet.getFee(acc[0]); | ||
it("Sign Transaction", async () => { | ||
const acc = await bitcoinWallet.getAccounts() | ||
BTC_TXN_PARAM['from'] = acc[0] | ||
const { signedTransaction } = await bitcoinWallet.signTransaction(BTC_TXN_PARAM); | ||
console.log("signedTransaction ", signedTransaction) | ||
it("Sign Transaction should fail and throw error", async () => { | ||
try { | ||
const acc = await bitcoinWallet.getAccounts() | ||
BTC_TXN_PARAM['from'] = acc[0] | ||
const { signedTransaction } = await bitcoinWallet.signTransaction(BTC_TXN_PARAM); | ||
console.log("signedTransaction ", signedTransaction) | ||
} catch (err) { | ||
console.log("Catching error ", err) | ||
} | ||
}) | ||
@@ -96,0 +100,0 @@ |
22850
408