1
0
mirror of https://github.com/bitcoinbook/bitcoinbook synced 2024-12-27 08:58:08 +00:00
Commit Graph

80 Commits

Author SHA1 Message Date
David A. Harding
064b6a7da7 Remove unused code examples 2023-09-01 13:24:35 +02:00
David A. Harding
43ae026233 CH12: simplify PoW example
Previous example used python to describe how PoW works.  Replace
the first example with a bash one-liner and remove the unnecessary
details.

Inspired by review comments from Jorge Lesmes
2023-09-01 13:21:39 +02:00
David A. Harding
8d6972d719 Libbitcoin bx: remove all mentions of vulnerable tool
- Remove appendix dedicated to `bx`.  They had already been slated for
  deletion, as I wrote to a reviewer on 2023-07-27: "I'm also probably
  going to delete the library/tool focused appendixes as I don't think
  they add anything".  After the disclosure of CVE-2023-39910 on August
  8th, it's clear that this appendix was worse than useless: it was
  harmful.

- Remove other mentions of `bx` in the book.  I had not previously
  intended this because it looked like a pain, but mentions of a tool
  often come across as endorsements to readers and no tool created by
  the team behind Libbitcoin is one I would ever want to endorse.  I
  regret that I didn't remove the mentions earlier in the process of
  updating the book.

- Remove appendix dedicated to pycoin.  I'm now aware of any problems
  with pycoin, but I don't think these sort of short detached tutorials
  add anything.  Programming Bitcoin is an entire book built on pycoin,
  and all of these tools have their own webpages that get updated more
  frequently than the book.
2023-09-01 13:21:39 +02:00
David A. Harding
e0932e89f7 CH11-12: remove long & not-very-useful example code
Suggested by Jorge Lesmes
2023-08-02 10:06:45 -10:00
David A. Harding
825d52823c All: remove references to blockchain.info
They changed to blockchain.com and now heavily promote alcoins.

Suggested by Murchandamus and Roasbeef
2023-08-02 10:06:45 -10:00
David A. Harding
5b1a5bff0a CH03-04: edits for Murchandamus feedback
- Mention the reason for the long validation time is the verification of
  transactions.  We previously implied it was download time, but some
  people have really fast internet.

- Better describe bitcoind cookie authentication and provide an example
  to make it even more clear.

- Add a link to bitcoin-s

- Make the long sidebar on collision attacks even longer by descripting
  a pre-image attack in addition to the previous descriptions of second
  pre-image and collision.  That way we don't conflate pre-image and
  second pre-image.

- Remove redundant tip box about an oddity in language about compressed
  and uncompressed private keys.

- Link to information about vanity address "mining" (brute forcing)
2023-08-01 07:13:47 -10:00
David A. Harding
206ee88a26 CH04::vanity addresses: update, drop code, clarify security/privacy
- Explain why almost nobody uses vanity addresses any more---HD wallets
  killed them, plus they suck for privacy.

- Remove example code.  It's only useful for base58check addresses, but
  those are no longer recommended and (as mentioned above) almost nobody
  uses vanity addresses any more, so there's not much point in updating
  it for bech32(m).

- Remove vanity address security section with unvetted security claims.

- Replace outdated claim about miners using GPUs.

- Remove specific amount for cost of vanity address pooling and URL for
  a pool.  That pool doesn't work, I don't know of any others, and I
  have no idea what the pricing would be even if there were existing
  pools.
2023-02-09 20:58:47 -10:00
David A. Harding
132094b670 CH04::legacy addresses: remove code examples
We instead provide an example for bech32 addresses, which are now the
preferred format.
2023-02-09 20:58:47 -10:00
David A. Harding
5f2c61e71b CH03::shell & code examples: update for 2023 2023-02-05 13:33:02 -10:00
David A. Harding
2f0d7d8c3a Revert CC-BY-SA material added since the second edition
The commit ab5ae32bae is the last commit
for the second edition, so all changes since then are dropped except for
several commits for the third edition authored by Andreas Antonopoulos.

No attempt is made to remove CC-BY-SA or other licensed content present
in the already-published first or second editions.

This revert may itself be reverted for versions of the book published
under CC-BY-SA.
2023-02-01 06:31:10 -10:00
Andreas M. Antonopoulos
a3229bbbc0 bitcoin/Bitcoin capitalization changed everywhere 2021-10-25 23:51:17 +02:00
Samir Sadek
989cb006f1 remove reference to the old library bitcoin for the new library cryptos 2021-04-07 16:43:45 +02:00
Will Binns
06b8fe01cc
Merge branch 'develop' into patch-1 2021-03-10 08:16:25 +01:00
Will Binns
39d663ed30
ch04: Fix 'key-to-address-ecc-example'
The 'pybitcointools' library is deprecated. Vitalik mentions using the
fork from 'primal100'. This updates the code sample which is currently
broken, to use the Python package for that fork.

Runs all good now.
2021-03-08 15:59:01 +01:00
drakos
6b041e5341
Fix for Private Key (WIF-Compressed)
When testing with a `private_key = '0000000000000000000000000000000000000000000000000000000000000001'` instead of `private_key = bitcoin.random_key()`,
the generated Private Key (WIF-Compressed) is wrong `5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsrefhvB5QZ`, it should be `KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn`. As it turns out, the proper way to get the correct compressed WIF is to pass `'wif_compressed'` and not `'wif'` to the `bitcoin.encode_privkey` function, as pointed out in the Main.py from the bitcoin python package.

```
def encode_privkey(priv, formt, vbyte=0):
    if not isinstance(priv, int_types):
        return encode_privkey(decode_privkey(priv), formt, vbyte)
    if formt == 'decimal': return priv
    elif formt == 'bin': return encode(priv, 256, 32)
    elif formt == 'bin_compressed': return encode(priv, 256, 32)+b'\x01'
    elif formt == 'hex': return encode(priv, 16, 64)
    elif formt == 'hex_compressed': return encode(priv, 16, 64)+'01'
    elif formt == 'wif':
        return bin_to_b58check(encode(priv, 256, 32), 128+int(vbyte))
    elif formt == 'wif_compressed':
        return bin_to_b58check(encode(priv, 256, 32)+b'\x01', 128+int(vbyte))
    else: raise Exception("Invalid format!")
```

The fix can be done in a couple ways:

`bitcoin.encode_privkey(bitcoin.decode_privkey(compressed_private_key, 'hex'), 'wif')` -> 5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsrefhvB5QZ (WRONG)

`bitcoin.encode_privkey(bitcoin.decode_privkey(compressed_private_key, 'hex'), 'wif_compressed')` -> KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU9FMLM39zT (WRONG)

`bitcoin.encode_privkey(bitcoin.decode_privkey(compressed_private_key, 'hex_compressed'), 'wif_compressed')` -> KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn (CORRECT)

`bitcoin.encode_privkey(bitcoin.decode_privkey(private_key, 'hex'), 'wif_compressed')` -> KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn (CORRECT)
2021-02-27 23:37:29 -05:00
Hennadii Stepanov
5d50a93ee6
ch10: Align target description with the actual implementation
See: 43f3ada27b/src/pow.cpp (L86-L88)
2021-01-19 15:10:02 +02:00
Fan
c6fa743597
Update key-to-address-ecc-example.py
If line#24 use 'wif_compressed', it will produce a wrong Key (WIF-Compressed) started with 2.

So there should be 'wif', unless :
wif_compressed_private_key = bitcoin.encode_privkey(
    bitcoin.decode_privkey(private_key, 'hex'), 'wif_compressed')
This is also right. 
However, use the 'compressed_private_key' and 'wif_compressed' is wrong.
2019-12-04 11:39:59 +08:00
Will Binns
cec55847b0
Merge pull request #616 from terzim/patch-2
Update ec-math.py
2019-10-04 21:41:25 +02:00
Will Binns
ecbde7c77c
Merge pull request #568 from theStack/maxmoney_unusedvar
max_money.py: use variable start_block_reward (eliminate magic number)
2019-05-09 19:55:45 +00:00
Will Binns
ee6131abf0
Merge pull request #531 from koshikraj/code-fix
fixed hashlib library error for python3
2019-05-08 20:26:45 +00:00
Massimiliano Terzi
9e2817f50a
Update ec-math.py
python 3, no need for decoding/encoding
2019-01-01 16:58:31 +00:00
theStack
24fd7bd79b max_money.py: use variable start_block_reward (eliminate magic number) 2018-05-19 09:10:18 -04:00
Arthur O'Dwyer
9504d804e0 Stop using numeric_limits for the constant "255", and fix a bug.
The bug is that `x % 255` is not quite the same thing as `x % 256`;
but `x & 255` is.

The stylistic issue is that `numeric_limits<uint8_t>::max()` is a
very verbose way of spelling `255`.
2018-03-25 20:17:35 -07:00
koshikraj
d70a0f91f2 fixed hashlib library error for python3 2018-03-16 20:32:21 +05:30
Andreas M. Antonopoulos
7ed95b283b Errata 166266 2018-03-14 10:23:46 -06:00
MaloneGod
b01acc076b
correct an error line 24 'wif' to 'wif_compressed' 2018-02-08 20:42:50 +08:00
cclauss
ecd13d3523 whitespace fixes to placate flake8 2018-02-03 01:33:46 +01:00
Andreas M. Antonopoulos
b7d97a5e80
Use of print function from Python 3 requires () 2018-02-02 16:29:36 -06:00
Andreas M. Antonopoulos
9dacbb40e3 Merge remote-tracking branch 'github/develop' into second_edition 2018-02-02 15:08:14 -06:00
Andreas M. Antonopoulos
cbc23caf8a
Merge pull request #431 from cjjojoba/cjjojoba-patch-1
Update ec-math.py
2018-02-02 12:35:19 -08:00
ZhaoChunsheng
5460eb7a8d
Update key-to-address-ecc-example.py
The code is very possible to miss a leading '0'.
E.g:
Private Key (hex) is: 57c003d31cca32f79a22e70334fff37875617e89c04d2746b5efc22067ccb8fd
Before: Compressed Public Key (hex) is: 03 8f0de2360796ae0fe17f1a2b0be30af6fb45eccc4a1c7afb5ebea21d041b6e0
After: Compressed Public Key (hex) is: 03 08f0de2360796ae0fe17f1a2b0be30af6fb45eccc4a1c7afb5ebea21d041b6e0

The bug is in the pybitcointools, but it is not updated, we can only repair it ourselves.
2018-01-27 21:56:25 +08:00
Cihat Imamoglu
fc84c40e8b
Update ec-math.py
* Add a missing word "number"
* Convert `& 1` into `% 2 == 0` for clarity
2017-12-10 14:44:04 +00:00
Manjeet Singh Bhatia
22e17ffd3c
Update hash_example.py
As input and hash are inbuilt functions, so I'd suggest using other names for variables.
here is output from python interpreter.

>>> hash
<built-in function hash>
>>> input
<built-in function input>
2017-12-09 22:05:50 -08:00
Will Binns
d5e2316438
Merge pull request #372 from cclauss/patch-3
from __future__ import print_function
2017-11-18 07:39:50 -06:00
MarcoFalke
fa6ee0557e Rework ch03 for most recent version of Bitcoin Core 2017-10-19 22:35:15 +02:00
cclauss
b8a0cddb9f from __future__ import print_function 2017-09-06 07:23:23 +02:00
cclauss
a47fa095cf from __future__ import print_function
`from __future__ import print_function` to bring the print function from Python 3 into Python 2.6 and 2.7.

Properly deals with comma separated values in print() function.
2017-09-06 06:44:52 +02:00
Will Binns
64f851da26 Merge pull request #367 from cclauss/patch-3
Trailing L not needed in Py2 & Syntax Error in Py3
2017-09-05 20:28:22 -06:00
cclauss
14138a859f Trailing L not needed in Py2 & Syntax Error in Py3
Also print() function, ternary if, avoid backslashes.
2017-08-24 19:07:00 +02:00
cclauss
df302e9fe5 long() and print() for Python 3 2017-08-24 18:44:48 +02:00
cclauss
35fef9a94f long(), print(), xrange() for Python 3
Also remove trailing whitespace
2017-08-24 18:37:02 +02:00
cclauss
3c0b24edd7 print() function for Python 3 2017-08-24 18:29:06 +02:00
cclauss
cb1053f905 print() function for Python 3
Also ternary if
2017-08-24 18:27:27 +02:00
cclauss
bdc3743e30 print() and range() for Python 3 2017-08-24 18:22:28 +02:00
cclauss
06ecaf9168 print() function for Python 3 2017-08-24 18:20:22 +02:00
cclauss
5f3a3d4469 print() function for Python 3 2017-08-24 18:14:02 +02:00
cclauss
f396920189 from __future__ import print_function
Support print('xyz', end='') on Python 2
2017-07-23 10:21:30 +02:00
Andreas M. Antonopoulos
d930042fc6 code fixes to update to libbitcoin v3 2017-07-18 12:07:31 +08:00
Andreas M. Antonopoulos
97496a50fb fixes to code example 2017-07-18 11:37:12 +08:00
Nick Adams
c05329d9cf PR edits through Ch 5 2017-05-09 16:16:06 -04:00