Skip to content

Commit f2796b8

Browse files
Merge pull request #32 from babylonchain/release/v0.1.2
Release/v0.1.2
2 parents 6102461 + f5d04a9 commit f2796b8

File tree

6 files changed

+130
-6
lines changed

6 files changed

+130
-6
lines changed

README.md

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,84 @@
1-
# CLI-TOOLS
1+
# CLI-Tools
22

3-
Set of CLI tools to run as Batch jobs on phase-1 main net
3+
Set of CLI tool which are used for different purposes:
4+
- processing unbonding requests
5+
- building test staking/unbonding/withdraw phase-1 Bitcoin transactions
6+
- building Bitcon transactions timestamping files
7+
8+
See [deployment guide](/docs/commands.md) to review all available commands.
9+
10+
### Installation
11+
12+
#### Prerequisites
13+
14+
This project requires Go version 1.21 or later.
15+
16+
Install Go by following the instructions on the official Go installation [guide](https://go.dev/doc/install).
17+
18+
#### Download the code
19+
20+
To get started, clone the repository to your local machine from GitHub; please
21+
use the version according to the phase-1 system guidelines --
22+
you can find all versions in the official
23+
[releases](https://github.com/babylonchain/cli-tools/releases) page.
24+
25+
```shell
26+
git clone https://github.com/babylonchain/cli-tools.git
27+
cd cli-tools
28+
git checkout <release-tag>
29+
```
30+
31+
#### Build and install the binary
32+
33+
At the top-level directory of the project
34+
35+
```shell
36+
make install
37+
```
38+
39+
The above command will build and install the `cli-tools` binary to
40+
`$GOPATH/bin`.
41+
42+
If your shell cannot find the installed binaries, make sure `$GOPATH/bin` is in
43+
the `$PATH` of your shell. The following updates to `$PATH` can be performed to
44+
this direction:
45+
46+
```shell
47+
export PATH=$HOME/go/bin:$PATH
48+
echo 'export PATH=$HOME/go/bin:$PATH' >> ~/.profile
49+
```
50+
51+
### Usage
52+
53+
To see all available commands:
54+
55+
```shell
56+
cli-tools --help
57+
```
58+
59+
Example output:
60+
61+
```shell
62+
Set of cli tools used in phase-1
63+
64+
Usage:
65+
cli-tools [command]
66+
67+
Available Commands:
68+
completion Generate the autocompletion script for the specified shell
69+
create-phase1-staking-tx create phase1 staking tx
70+
create-phase1-unbonding-request create phase1 unbonding tx
71+
create-phase1-withdaw-request create phase1 withdraw tx
72+
create-timestamp-transaction Creates a timestamp btc transaction by hashing the file input.
73+
dump-cfg dumps default confiiguration file
74+
help Help about any command
75+
process-failed-transactions tries to re-send unbonding transactions that failed to be sent to the network
76+
run-unbonding-pipeline runs unbonding pipeline
77+
78+
Flags:
79+
--config string path to the directory with configuration file
80+
-h, --help help for cli-tools
81+
--params string path to the global params file
82+
83+
Use "cli-tools [command] --help" for more information about a command.
84+
```

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var (
1717

1818
rootCmd = &cobra.Command{
1919
Use: "cli-tools",
20-
Short: "Set of cli tools to run batch jobs on phase-1 mainnet",
20+
Short: "Set of cli tools used in phase-1",
2121
}
2222

2323
// C:\Users\<username>\AppData\Local\tools on Windows

docs/commands.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,46 @@ $ bitcoin-cli -rpcwallet=timestamp-w gettransaction 25b65b31c6f4d2f46ebeb5fa4c9a
138138
}
139139
}
140140
```
141+
142+
## BTC Transaction creation commands
143+
144+
The following set of commands are used to create phase-1 compatible transactions
145+
with the goal to ease up testing of the phase-1 system:
146+
- `create-phase1-staking-tx`
147+
- `create-phase1-unbonding-request`
148+
- `create-phase1-withdaw-request`
149+
150+
Disclaimer: Those commands should only be used for testing purposes and should not be
151+
used with real BTC.
152+
153+
## Dump config command
154+
155+
Some of the commands require a config file to work properly. To generate a config
156+
file the `dump-cfg` command can be used.
157+
158+
```shell
159+
cli-tools dump-cfg --config "./config.toml"
160+
```
161+
162+
will generate a `config.toml` file in the same directory as the one
163+
the `cli-tools` program binary resides in.
164+
165+
166+
## Unbonding processing commands
167+
168+
There are two commands responsible for processing unbonding requests:
169+
- `run-unbonding-pipeline`
170+
- `process-failed-transactions`
171+
172+
Both of those commands require:
173+
- config file path
174+
- global parameters paths
175+
176+
Example:
177+
178+
```shell
179+
cli-tools run-unbonding-pipeline --config "./config/config.toml" --params "./config/global-params.json"
180+
```
181+
182+
For these commands to work, they must have access to the data source (mongo-db) containing
183+
unbonding transactions already signed by staker and validated by some other process.

internal/config/remote_signer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (c *RemoteSignerConfig) Parse() (*ParsedRemoteSignerConfig, error) {
4646
if err != nil {
4747
return nil, fmt.Errorf("invalid url %s: %w", urlStr, err)
4848
}
49-
urls[i] = fmt.Sprintf("http://%s", parsedUrl.Host)
49+
urls[i] = fmt.Sprintf("%s://%s", parsedUrl.Scheme, parsedUrl.Host)
5050

5151
publicKeyStr := parsedUrl.User.String()
5252
pkBytes, err := hex.DecodeString(publicKeyStr)

internal/services/remote_signer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (rs *RemoteSigner) SignUnbondingTransaction(req *SignRequest) (*PubKeySigPa
4545
)
4646

4747
if err != nil {
48-
return nil, err
48+
return nil, fmt.Errorf("request to coventant %s, with url:%s, failed: %w", pkStr, url, err)
4949
}
5050

5151
return &PubKeySigPair{

internal/services/unbonding_pipeline.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ func (up *UnbondingPipeline) requestSigFromCovenant(req *SignRequest, resultChan
184184
// TODO record metrics
185185
up.logger.Error("failed to get signatures from covenant",
186186
"signer_pk", pkStr,
187-
"error", res.Err)
187+
"error", err)
188188

189189
res.Err = err
190190
} else {

0 commit comments

Comments
 (0)