Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs for mint token && Improvement: create wallet && docker-compose.yaml #61

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3994152
remove mege
ThreeAndTwo Sep 11, 2024
cd1d2ab
added shell script
ThreeAndTwo Sep 11, 2024
176ae86
changed config.example.json
ThreeAndTwo Sep 11, 2024
1603b8a
fixed code
ThreeAndTwo Sep 11, 2024
004ab28
fixed bugs for chosen gas
ThreeAndTwo Sep 11, 2024
771d135
changed fee rate
ThreeAndTwo Sep 11, 2024
6c4c5bc
clean code
ThreeAndTwo Sep 11, 2024
7075c6e
change fee range step
ThreeAndTwo Sep 11, 2024
9deafc6
changed base gas
ThreeAndTwo Sep 11, 2024
590840e
changed create commands
ThreeAndTwo Sep 12, 2024
505dd39
Merge branch 'main' of https://github.com/ThreeAndTwo/cat-token-box
ThreeAndTwo Sep 12, 2024
7c62528
updated create.command.ts
ThreeAndTwo Sep 12, 2024
e61c2d2
updated docker-compose
ThreeAndTwo Sep 12, 2024
579a7bb
Delete packages/cli/config.example.json
ThreeAndTwo Sep 13, 2024
10ee5e6
Delete packages/cli/script.sh
ThreeAndTwo Sep 13, 2024
1a5e471
changed config.example.json
ThreeAndTwo Sep 13, 2024
afb561a
Update config.example.json to default params
ThreeAndTwo Sep 13, 2024
bb7113c
Update config.example.json to default params
ThreeAndTwo Sep 13, 2024
201d3a4
Merge branch 'CATProtocol:main' into main
ThreeAndTwo Sep 14, 2024
3ec864b
updated code
ThreeAndTwo Sep 14, 2024
de16afc
cp bitcoin.conf to bitcoin dir
ThreeAndTwo Sep 14, 2024
ae60379
fix bugs for init_script.sh
ThreeAndTwo Sep 14, 2024
a4aba76
updated tracker configs
ThreeAndTwo Sep 14, 2024
0ca11b9
updated: remove the reindex command in bitcoind
ThreeAndTwo Sep 14, 2024
6031a5c
removed init_cat20.sh
ThreeAndTwo Sep 14, 2024
8982149
Merge branch 'CATProtocol:main' into main
ThreeAndTwo Sep 16, 2024
e6f5e3e
fix bugs for chosen UTXO
ThreeAndTwo Sep 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions init_cat20.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
pkg_name=your_project_name
mnemonic=your_mnemonic
path_index=your_path_index
git clone https://github.com/ThreeAndTwo/cat-token-box $pkg_name
cd $pkg_name
yarn install
yarn build
sudo chmod 777 packages/tracker/docker/data
sudo chmod 777 packages/tracker/docker/pgdata

cd packages/cli
cat config.json
yarn cli wallet create -m "$mnemonic" -p $path_index
chmod +x script.sh
yarn cli wallet address
yarn cli wallet balances
2 changes: 1 addition & 1 deletion packages/cli/config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
"username": "bitcoin",
"password": "opcatAwesome"
}
}
}
39 changes: 36 additions & 3 deletions packages/cli/src/commands/wallet/create.command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import * as bip39 from 'bip39';

interface CreateCommandOptions extends BaseCommandOptions {
name: string;
path_index: number;
mnemonic: string;
}

@SubCommand({
Expand Down Expand Up @@ -39,10 +41,18 @@ export class CreateCommand extends BaseCommand {
? options.name
: `cat-${randomBytes(4).toString('hex')}`;

const path_index = options.path_index
? options.path_index
: 0;

const mnemonic = options.mnemonic
? options.mnemonic
: bip39.generateMnemonic();

const wallet: Wallet = {
accountPath: "m/86'/0'/0'/0/0",
accountPath: `m/86'/0'/0'/0/${path_index}`,
name: name,
mnemonic: bip39.generateMnemonic(),
mnemonic: mnemonic,
};

this.walletService.createWallet(wallet);
Expand Down Expand Up @@ -72,4 +82,27 @@ export class CreateCommand extends BaseCommand {

return val;
}
}
@Option({
flags: '-p,--path_index [path_index]',
description: 'path index',
})
parsePathIndex(val: number): number {
if (!val || val < 0) {
logerror("path index can't be empty!", new Error('invalid path_index option'));
process.exit(0);
}
return val;
}

@Option({
flags: '-m,--mnemonic [mnemonic]',
description: 'mnemonic',
})
parseMnemonic(val: string): string {
if (!val) {
logerror("mnemonic can't be empty!", new Error('invalid mnemonic option'));
process.exit(0);
}
return val;
}
}
8 changes: 6 additions & 2 deletions packages/tracker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ services:
bitcoind:
image: fractalbitcoin/fractal:v0.2.1
restart: always
entrypoint: ["bitcoind", "-datadir=/data/", "-maxtipage=504576000"]
entrypoint: ["bitcoind", "-datadir=/data/", "-maxtipage=504576000", "-reindex"]
command: ""
healthcheck:
test: ["CMD", "bitcoin-cli", "-datadir=/data/", "getblockchaininfo"]
Expand All @@ -27,8 +27,12 @@ services:
deploy:
resources:
limits:
memory: 60G
cpus: '4.0'
reservations:
memory: 40G
memswap_limit: 60G
cpus: '2.0'
memswap_limit: 80G
mem_swappiness: 100
volumes:
- ./docker/data:/data
Expand Down