Skip to content

Commit

Permalink
Merge branch 'master' of github.com:bitpay/bitcore into taproot
Browse files Browse the repository at this point in the history
  • Loading branch information
kajoseph committed Apr 18, 2024
2 parents 1214b5c + 1f1e38a commit d770fe1
Show file tree
Hide file tree
Showing 345 changed files with 62,130 additions and 14,569 deletions.
22 changes: 20 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version: 2.1
executors:
main:
machine:
image: ubuntu-2004:202201-02
image: default # https://discuss.circleci.com/t/linux-image-deprecations-and-eol-for-2024/50177
docker_layer_caching: true
resource_class: large
working_directory: ~/bitcore
Expand All @@ -30,6 +30,15 @@ commands:
- run:
name: Build & start blockchain containers
command: docker-compose -f docker-compose.test.base.yml -f docker-compose.test.ci.yml up --detach
use_python2:
description: Set python 2.7 as global python version on the executor machine
steps:
- run:
name: Use Python 2
command: |
pyenv versions
pyenv install -s 2.7
pyenv global 2.7
use_node:
description: Force usage of correct node version on the executor machine
steps:
Expand Down Expand Up @@ -68,6 +77,7 @@ jobs:
executor: main
steps:
- checkout
- use_python2
- use_node
# - run:
# name: Install Chrome
Expand All @@ -81,7 +91,7 @@ jobs:
name: Print versions
command: |
nvm use default
set -x && node -v && npm -v && google-chrome --version && docker version
set -x && node -v && npm -v && google-chrome --version && docker version && python --version
- restore_dependency_cache
- run: | # TODO figure out how to make this only run on a cache miss in restore_dependency_cache
nvm use default
Expand Down Expand Up @@ -165,6 +175,11 @@ jobs:
steps:
- run_test:
package: bitcore-p2p
bitcore-client:
executor: main
steps:
- run_test:
package: bitcore-client

workflows:
version: 2
Expand Down Expand Up @@ -201,3 +216,6 @@ workflows:
- bitcore-p2p:
requires:
- build
- bitcore-client:
requires:
- build
25 changes: 25 additions & 0 deletions bitcore-test.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,31 @@
"threads": 0
}
},
"BASE": {
"testnet": {
"chainSource": "external",
"trustedPeers": [
{
"host": "localhost",
"port": "30012/ws"
}
],
"provider": {
"host": "docs-demo.base-mainnet.quiknode.pro/",
"protocol": "https",
"port": "",
"dataType": "historical"
},
"providers": [
{
"host": "docs-demo.base-mainnet.quiknode.pro/",
"protocol": "https",
"port": "",
"dataType": "combined"
}
]
}
},
"XRP": {
"testnet": {
"chainSource": "rpc",
Expand Down
4 changes: 2 additions & 2 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"lerna": "2.9.1",
"version": "10.0.11",
"version": "10.0.32",
"packages": [
"packages/*"
"packages/[^insight]*"
]
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
"ci:bitcore-p2p-doge": "./ci.sh 'npm run test:bitcore-p2p-doge'",
"test:bitcore-mnemonic": "cd ./packages/bitcore-mnemonic && npm run test",
"ci:bitcore-mnemonic": "./ci.sh 'npm run test:bitcore-mnemonic'",
"test:bitcore-client": "cd ./packages/bitcore-client && npm run test",
"ci:bitcore-client": "./ci.sh 'npm run test:bitcore-client'",
"lerna:ci:all": "npx lerna run test:ci --concurrency 1 --stream",
"lerna:ci:unit": "npx run test:ci:unit --concurrency 1 --stream",
"lerna:ci:integration": "npx run test:ci:integration --concurrency 1 --stream",
Expand Down
4 changes: 2 additions & 2 deletions packages/bitcore-build/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/bitcore-build/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bitcore-build",
"version": "10.0.11",
"version": "10.0.21",
"description": "A helper for common tasks to build bitcore modules'",
"main": "index.js",
"scripts": {
Expand Down
40 changes: 22 additions & 18 deletions packages/bitcore-client/bin/multi-sig/wallet-derive-address
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const fs = require('fs');
const CWC = require('crypto-wallet-core');
const program = require('commander');
const { Wallet } = require('../../ts_build/wallet');
const { Wallet } = require('../../ts_build/src/wallet');
const promptly = require('promptly');
const bitcoreLibs = {
BTC: CWC.BitcoreLib,
Expand All @@ -14,17 +14,17 @@ const bitcoreLibs = {

program
.version(require('../../package.json').version)
.option('--path <path>', 'REQUIRED - Filepath where wallet is stored')
.option('--m <m>', 'REQUIRED - Number of signers required')
.option('--currency <currency>', 'REQUIRED - currency. [BTC, DOGE, LTC, BCH]')
.option('--depth <depth>', 'REQUIRED - Number of addresses to derive (will derive that many change addresses too)')
.option('--network <network>', 'REQUIRED - Network to derive for')
.option('--input [input]', 'OPTIONAL - A json string to parse in the form {"xpubkey": "mXy1234"}')
.option('--file [file]', 'OPTIONAL - A jsonl file with {"xpubkey": "mXy1234"} in it')
.option('--prompt', 'OPTIONAL - Ask for the xpubkeys to derive from')
.option('--importToWallet [importToWallet]', 'OPTIONAL flag - import the derived addresses. Requires path')
.option('--exportToFile [export]', 'OPTIONAL flag - File path to save derived addresses to')
.option('--bech32', 'OPTIONAL - Use this flag if you need bech32 addresses')
.requiredOption('--path <path>', 'REQUIRED - Filepath where wallet is stored')
.requiredOption('--m <m>', 'REQUIRED - Number of signers required')
.requiredOption('--currency <currency>', 'REQUIRED - currency. [BTC, DOGE, LTC, BCH]')
.requiredOption('--depth <depth>', 'REQUIRED - Number of addresses to derive (will derive that many change addresses too)')
.requiredOption('--network <network>', 'REQUIRED - Network to derive for')
.option('--input <input>', 'optional - A json string to parse in the form {"xpubkey": "mXy1234"}')
.option('--file <file>', 'optional - A jsonl file with {"xpubkey": "mXy1234"} in it')
.option('--prompt', 'optional - Ask for the xpubkeys to derive from')
.option('--exportToFile <file>', 'optional flag - Export addresses')
.option('--importFromFile <file>', 'optional flag - Import exported addresses')
.option('--bech32', 'optional - Use this flag if you need bech32 addresses')
.parse(process.argv);

const getFileKeys = file => {
Expand Down Expand Up @@ -65,7 +65,7 @@ function getAddress(publicKeyRing, addressIndex, isChange, m, network, currency)
});
let nestedWitness;
let type;
if (program.bech32) {
if (program.opts().bech32) {
nestedWitness = false;
type = 'witnessscripthash';
}
Expand Down Expand Up @@ -99,14 +99,16 @@ async function importAddressesToWallet(path, addresses) {
if (!password) {
throw new Error('No password provided. Keys can\'t be imported without unlocking the wallet');
}
let wallet = await Wallet.loadWallet({ path });
wallet = await Wallet.loadWallet({ path });
wallet = await wallet.unlock(password);
await wallet.importKeys({ keys: addresses });
console.log(`${addresses.length} Adresses Imported`);
}

let wallet;

const main = async () => {
const { path, file, input, prompt, importToWallet, m, network, exportToFile, depth, currency } = program;
const { file, input, prompt, importFromFile, m, network, exportToFile, depth, currency } = program.opts();
if (!currency || !['BTC', 'DOGE', 'LTC', 'BCH'].includes(currency)) {
throw new Error('Invalid currency. Currency must be BTC, DOGE, LTC, or BCH');
}
Expand Down Expand Up @@ -134,12 +136,14 @@ const main = async () => {
console.log(`Exported Addresses to ${exportToFile}`);
}

if (path && importToWallet) {
await importAddressesToWallet(path, allAddresses);
if (importFromFile) {
await importAddressesToWallet(importAddresses, allAddresses);
}
} catch (e) {
console.error(e);
}
};

main();
main()
.catch(console.error)
.finally(() => wallet?.storage?.close());
1 change: 1 addition & 0 deletions packages/bitcore-client/bin/wallet
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ program
.command('send', 'simple send from wallet to an address').alias('s')
.command('sign', 'sign a transaction')
.command('token', 'add an ERC20 token to an eth wallet')
.command('flags', 'check or set wallet flags (XRP only)')
.command('storage', 'storage util for wallets')
.command('sign-message', 'sign a message with an address')
.parse(process.argv);
Expand Down
28 changes: 16 additions & 12 deletions packages/bitcore-client/bin/wallet-balance
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
#!/usr/bin/env node

const program = require('../ts_build/program');
const { Wallet } = require('../ts_build/wallet');
const program = require('commander');
const { Wallet } = require('../ts_build/src/wallet');

try {
program
.version(require('../package.json').version)
.option('--name <name>', 'REQUIRED - Wallet name')
.option('--time [time]', 'optional - Get balance at specific time')
.option('--path [path]', 'optional - Custom wallet storage path')
.option('--storageType [storageType]', 'optional - name of the database to use (default level)')
.option('--token [token]', 'optional - Get balance of an ERC20 token')
.requiredOption('--name <name>', 'REQUIRED - Wallet name')
.option('--time <time>', 'optional - Get balance at specific time')
.option('--path <path>', 'optional - Custom wallet storage path')
.option('--storageType <storageType>', 'optional - name of the database to use (default level)')
.option('--token <token>', 'optional - Get balance of an ERC20 token')
.option('--tokenName <tokenName>', 'optional - Get balance of an ERC20 token using custom token name')
.parse(process.argv);
} catch (e) {
console.log(e.message);
return program.help();
}

let wallet;

async function main() {
const { name, path, time, storageType, token } = program;
const wallet = await Wallet.loadWallet({ name, path, storageType });
const balance = await wallet.getBalance(time, token);
const { name, path, time, storageType, token, tokenName } = program.opts();
wallet = await Wallet.loadWallet({ name, path, storageType });
const balance = await wallet.getBalance(time, token, tokenName);
return Object.assign(balance, {
currency: token || wallet.chain,
currency: tokenName || token || wallet.chain,
network: wallet.network
});
}

main()
.then(res => console.log(res))
.catch(err => console.error(err));
.catch(err => console.error(err))
.finally(() => wallet?.storage?.close());
20 changes: 10 additions & 10 deletions packages/bitcore-client/bin/wallet-balance-all
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#!/usr/bin/env node
'use strict';

const program = require('commander');
const { Transform } = require('stream');
const { Storage } = require('../ts_build/storage');
const { Wallet } = require('../ts_build/wallet');
const program = require('../ts_build/program');
const { Storage } = require('../ts_build/src/storage');
const { Wallet } = require('../ts_build/src/wallet');

program
.version(require('../package.json').version)
.option('--path [path]', 'optional - Where wallets are stored')
.option('--chain [chain]', 'Chain to get balances from')
.option('--network [network]', 'Network to get balances from')
.option('--name [name]', 'regex matching wallet name')
.option('--time [time]', 'optional - Get balance at specific time')
.option('--storageType [storageType]', 'optional - the name of the database (default Level)')
.option('--chain <chain>', 'optional - Chain to get balances from')
.option('--network <network>', 'optional - Network to get balances from')
.option('--name <name>', 'optregex matching wallet name')
.option('--time <time>', 'optional - Get balance at specific time')
.option('--storageType <storageType>', 'optional - the name of the database (default Level)')
.option('--path <path>', 'optional - Where wallets are stored')
.parse(process.argv);

const { path, chain, network, time, name: regex, storageType } = program;
const { path, chain, network, time, name: regex, storageType = 'Level' } = program.opts();
const regExp = new RegExp(regex);

const parser = new Transform({
Expand Down
21 changes: 12 additions & 9 deletions packages/bitcore-client/bin/wallet-broadcast
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
#!/usr/bin/env node

const program = require('../ts_build/program');
const { Wallet } = require('../ts_build/wallet');
const program = require('commander');
const { Wallet } = require('../ts_build/src/wallet');

program
.version(require('../package.json').version)
.option('--name <name>', 'REQUIRED - Wallet name')
.option('--tx <tx>', 'REQUIRED - Signed transaction to broadcast')
.option('--path [path]', 'optional - Custom wallet storage path')
.option('--storageType [storageType]', 'optional - name of the database to use (default Level)')
.requiredOption('--name <name>', 'REQUIRED - Wallet name')
.requiredOption('--tx <tx>', 'REQUIRED - Signed transaction to broadcast')
.option('--storageType <storageType>', 'optional - name of the database to use (default Level)')
.option('--path <path>', 'optional - Custom wallet storage path')
.parse(process.argv);

let wallet;

const main = async () => {
const { tx, name, path, storageType } = program;
let wallet;
const { tx, name, path, storageType = 'Level' } = program.opts();
try {
wallet = await Wallet.loadWallet({ name, path, storageType });
const transaction = await wallet.broadcast({ tx });
Expand All @@ -29,4 +30,6 @@ const main = async () => {
}
};

main();
main()
.catch(console.error)
.finally(() => wallet?.storage?.close());

0 comments on commit d770fe1

Please sign in to comment.