Skip to content

Commit

Permalink
feat: review node-ethereum-locale.md
Browse files Browse the repository at this point in the history
  • Loading branch information
BoboTiG committed Feb 4, 2024
1 parent c0acdc0 commit 219899a
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 17 deletions.
43 changes: 31 additions & 12 deletions sources/blockchain/node-ethereum-locale.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Un fichier *UTC--…* sera créé dans le dossier *dev/node/keystore*.

```{literalinclude} snippets/node-ethereum-locale.py
:caption: dev/get-private-key.py
:emphasize-lines: 10
:emphasize-lines: 14
:language: python
```

Expand Down Expand Up @@ -62,13 +62,9 @@ Dans notre cas, le compte aura `1 000 000 $ETH`.
Les adresses ne doivent pas être préfixées de `0x`.
```

```{todo}
Voir si les données sont toujours d'actualité. Par exemple, il y a plus de clefs dans le [dépôt officiel](https://github.com/ethereum/go-ethereum/blob/master/cmd/devp2p/internal/ethtest/testdata/genesis.json).
```

```{code-block} json
:caption: dev/genesis.json
:emphasize-lines: 20
:emphasize-lines: 33
{
"config": {
Expand All @@ -84,15 +80,34 @@ Voir si les données sont toujours d'actualité. Par exemple, il y a plus de cle
"istanbulBlock": 0,
"muirGlacierBlock": 0,
"berlinBlock": 0,
"londonBlock": 0
"londonBlock": 0,
"arrowGlacierBlock": 0,
"grayGlacierBlock": 0,
"mergeNetsplitBlock": 0,
"shanghaiTime": 0,
"cancunTime": 0,
"terminalTotalDifficulty": 0,
"terminalTotalDifficultyPassed": true,
"ethash": {}
},
"difficulty": "0x1",
"gasLimit": "0xffffffffffff",
"nonce": "0x0",
"timestamp": "0x0",
"extraData": "0x",
"gasLimit": "0x23f3e20",
"difficulty": "0x10000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC": {
"balance": "1000000000000000000000000"
"balance": "1000000000000000000000000"
}
}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"baseFeePerGas": null,
"excessBlobGas": null,
"blobGasUsed": null
}
```

Expand All @@ -109,7 +124,7 @@ Démarrez le nœud (pensez à adapter l'adresse publique du compte) :

```{literalinclude} snippets/node-ethereum-locale.sh
:lines: 20-35
:emphasize-lines: 12-13
:emphasize-lines: 12-13,15
:language: shell
```

Expand All @@ -132,6 +147,10 @@ Et voilà !

## 📜 Historique

2024-02-04
: Revue de l'article.
: Simplification du script Python pour récupérer la clef privée du compte.

2024-01-31
: Déplacement de l'article depuis le [blog](https://www.tiger-222.fr/?d=2022/02/28/15/49/31-noeud-ethereum-local).
: Mise à jour de Geth (`1.10.17-25c9b49``1.13.11-8f7eb9cc`).
Expand Down
10 changes: 7 additions & 3 deletions sources/blockchain/snippets/node-ethereum-locale.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
"""Tool to get the private key of a keystore file."""
"""Tool to get the private key of a keystore file.
Setup:
python -m pip install eth-account
"""
import sys
from binascii import b2a_hex
from pathlib import Path

from web3.auto import w3
from eth_account.account import Account

path = Path(__file__).parent / "node" / "keystore" / sys.argv[1]
encrypted_key = path.read_text()
password = "" # Adapt accordingly to what was set at the account creation
private_key = w3.eth.account.decrypt(encrypted_key, password)
private_key = Account.decrypt(encrypted_key, password)
print(b2a_hex(private_key).decode())
3 changes: 1 addition & 2 deletions sources/blockchain/snippets/node-ethereum-locale.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,4 @@ geth \
--unlock '0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC' \
--password 'dev/account-pwd.txt' \
--mine \
--miner.threads '1' \
--miner.noverify
--miner.etherbase '0x8db97C7cEcE249c2b98bDC0226Cc4C2A57BF52FC'

0 comments on commit 219899a

Please sign in to comment.