Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor (chain = { network: networks.bitcoin, segwit: false }, numberOfBlockConfirmation = 1) {
super(Bitcoin, `${chain.segwit ? '49' : '44'}'/${chain.network.coinType}'/0'/`, chain.network, 'BTC')
this._derivationPath = `${chain.segwit ? '49' : '44'}'/${chain.network.coinType}'/0'/`
this._network = chain.network
this._bjsnetwork = chain.network.name.replace('bitcoin_', '') // for bitcoin js
this._segwit = chain.segwit
this._coinType = chain.network.coinType
this._walletPublicKeyCache = {}
}
constructor (chain = { network: networks.bitcoin }, mode = 'p2wsh') {
super()
this._network = chain.network
if (!['p2wsh', 'p2shSegwit', 'p2sh'].includes(mode)) {
throw new Error('Mode must be one of p2wsh, p2sSegwit, p2sh')
}
this._mode = mode
if (this._network.name === networks.bitcoin.name) {
this._bitcoinJsNetwork = bitcoin.networks.mainnet
} else if (this._network.name === networks.bitcoin_testnet.name) {
this._bitcoinJsNetwork = bitcoin.networks.testnet
} else if (this._network.name === networks.bitcoin_regtest.name) {
this._bitcoinJsNetwork = bitcoin.networks.regtest
}
}
constructor (chain = { network: networks.bitcoin }, mode = 'p2wsh') {
super()
this._network = chain.network
if (!['p2wsh', 'p2shSegwit', 'p2sh'].includes(mode)) {
throw new Error('Mode must be one of p2wsh, p2shSegwit, p2sh')
}
this._mode = mode
}
constructor (chain = { network: networks.bitcoin }) {
super()
this._network = chain.network
}
import WalletProvider from '@liquality/wallet-provider'
import JsonRpcProvider from '@liquality/jsonrpc-provider'
import BitcoinNetworks from '@liquality/bitcoin-networks'
import { AddressTypes } from '@liquality/bitcoin-utils'
import * as bitcoin from 'bitcoinjs-lib'
import { sha256 } from '@liquality/crypto'
import { Address, addressToString } from '@liquality/utils'
import _ from 'lodash'
import { version } from '../package.json'
const BIP70_CHAIN_TO_NETWORK = {
'main': BitcoinNetworks.bitcoin,
'test': BitcoinNetworks.bitcoin_testnet,
'regtest': BitcoinNetworks.bitcoin_regtest
}
export default class BitcoinNodeWalletProvider extends WalletProvider {
constructor (network, uri, username, password, addressType = 'bech32') {
super()
if (!AddressTypes.includes(addressType)) {
throw new Error(`addressType must be one of ${AddressTypes.join(',')}`)
}
this._addressType = addressType
this._network = network
this._rpc = new JsonRpcProvider(uri, username, password)
}
async signMessage (message, from) {
constructor (chain = { network: networks.bitcoin }, mode = 'p2wsh') {
super()
this._network = chain.network
if (!['p2wsh', 'p2shSegwit', 'p2sh'].includes(mode)) {
throw new Error('Mode must be one of p2wsh, p2sSegwit, p2sh')
}
this._mode = mode
if (this._network.name === networks.bitcoin.name) {
this._bitcoinJsNetwork = bitcoin.networks.mainnet
} else if (this._network.name === networks.bitcoin_testnet.name) {
this._bitcoinJsNetwork = bitcoin.networks.testnet
} else if (this._network.name === networks.bitcoin_regtest.name) {
this._bitcoinJsNetwork = bitcoin.networks.regtest
}
}