Skip to content

Commit

Permalink
contrib/localnet/darkfid-single-node: automated wallet stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
skoupidi committed Nov 14, 2024
1 parent 3153069 commit 9ca09af
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 23 deletions.
15 changes: 5 additions & 10 deletions contrib/localnet/darkfid-single-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,21 @@ If we want to test wallet stuff, we must generate
a testing wallet and pass its address to the `darkfid`
config, so the wallet gets the block rewards the node
produces. We generate a wallet, set it as the default
and grab its address:
and set its address as the `recipient` field in
`darkfid.toml`, using the porvided automated script:
```
% ../../../drk -c drk.toml wallet --initialize
% ../../../drk -c drk.toml wallet --keygen
% ../../../drk -c drk.toml wallet --default-address 1
% ../../../drk -c drk.toml wallet --address
% ./init-wallet.sh
```

Then we replace the `recipient` field in `darkfid.toml`
config with the output of the last command, start
`darkfid` and wait until its initialized:
Then start `darkfid` and wait until its initialized:
```
% ./tmux_sessions.sh
```

After some blocks have been generated we
will see some `DRK` in our test wallet.
```
% ../../../drk -c drk.toml scan
% ../../../drk -c drk.toml wallet --balance
% ./wallet-balance.sh
```

See the user guide in the book for more info.
Expand Down
1 change: 1 addition & 0 deletions contrib/localnet/darkfid-single-node/clean.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/sh
rm -rf darkfid drk
sed -i -e "s|recipient =.*|recipient = \"9vw6WznKk7xEFQwwXhJWMMdjUPi3cXL8NrFKQpKifG1U\"|g" darkfid.toml
10 changes: 10 additions & 0 deletions contrib/localnet/darkfid-single-node/init-wallet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

# Path to `drk` binary
DRK="../../../drk -c drk.toml"

$DRK wallet --initialize
$DRK wallet --keygen
$DRK wallet --default-address 1
wallet=$($DRK wallet --address)
sed -i -e "s|9vw6WznKk7xEFQwwXhJWMMdjUPi3cXL8NrFKQpKifG1U|$wallet|g" darkfid.toml
14 changes: 14 additions & 0 deletions contrib/localnet/darkfid-single-node/wallet-balance.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

# Path to `drk` binary
DRK="../../../drk -c drk.toml"

while true; do
if $DRK ping 2> /dev/null; then
break
fi
sleep 1
done

$DRK scan
$DRK wallet --balance
20 changes: 7 additions & 13 deletions doc/src/testnet/node.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,33 +147,27 @@ wallet CLI:
$ make darkfid minerd drk
```

Enter the localnet folder, generate a wallet, set it as the
default one and grab its address:
Enter the localnet folder, and initialize a wallet:

```
$ cd contrib/localnet/darkfid-single-node/
$ ../../../drk -c drk.toml wallet --initialize
$ ../../../drk -c drk.toml wallet --keygen
$ ../../../drk -c drk.toml wallet --default-address 1
$ ../../../drk -c drk.toml wallet --address
$ ./init-wallet.sh
```

Then we replace the `recipient` field in `darkfid.toml`
config, existing in the folder, with the output of the last
command, start `darkfid` and wait until its initialized:
Then start `darkfid` and wait until its initialized:

```
$ ./tmux_sessions.sh
```

After some blocks have been generated we
will see some `DRK` in our test wallet.
On a different shell, navigate to `contrib/localnet/darkfid-single-node`
folder again and scan for new blocks
On a different shell(or tmux pane in the session),
navigate to `contrib/localnet/darkfid-single-node`
folder again and check wallet balance

```
$ ../../../drk -c drk.toml scan
$ ../../../drk -c drk.toml wallet --balance
$ ./wallet-balance.sh
```

Don't forget that when using this local node, all operations
Expand Down

0 comments on commit 9ca09af

Please sign in to comment.