programmingbitcoin
programmingbitcoin copied to clipboard
Repository for the book
When an ECDSA signature is made with this library using [`PrivateKey.sign`](https://github.com/jimmysong/programmingbitcoin/blob/3fba6b992ece443e4256df057595cfbe91edda75/code-ch13/ecc.py#L620) it is canonicalized so the `s` value is low, ie. so (& see [Issue #296](https://github.com/jimmysong/programmingbitcoin/issues/296)) : ``` s <...
In the [PrivateKey.sign](https://github.com/jimmysong/programmingbitcoin/blob/3fba6b992ece443e4256df057595cfbe91edda75/code-ch13/ecc.py#L628) method the following code : ``` if s > N / 2: s = N - s ``` which uses the Python 3 "true division" operator `\`...
In the Base58 `decode` function [here](https://github.com/jimmysong/programmingbitcoin/blob/3fba6b992ece443e4256df057595cfbe91edda75/code-ch07/helper.py#L51), the integer is parsed into **25** bytes i.e. ```python def decode_base58(s): num = 0 for c in s: # num *= 58 num +=...
In [Tx.verify_input](https://github.com/jimmysong/programmingbitcoin/blob/3fba6b992ece443e4256df057595cfbe91edda75/code-ch13/tx.py#L313) in Chap. 13, the length of the redeem script is computed using `int_to_little_endian(len(cmd), 1)`. As stated in the code comment 'prepend the length of the RedeemScript using encode_varint'...
In the `Tx` class method `parse_segwit`, following the [BIP141 spec](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#user-content-Transaction_ID), the code : ``` for tx_in in inputs: num_items = read_varint(s) items = [] for _ in range(num_items): item_len =...
These diagrams are used from chapter 6 onwards where they are introduced on p113, and they are used quite a lot in Chap. 8. They are somewhat confusing since the...
Just as the title says, in scriptSig column of Fig. 8.3 the first command `n` should read `OP_0`.
In the class method `fetch` of class `TxFetcher` the line [`cls.cache[tx_id].testnet = testnet`](https://github.com/jimmysong/programmingbitcoin/blob/3fba6b992ece443e4256df057595cfbe91edda75/code-ch13/tx.py#L47) appears outside of the preceding `if` branch causing an unnecessary reassignment of the field `testnet` of the...
Replacing all instances of the `http://testnet.blockchain.info/pushtx` with a functioning link pointing to `https://blockstream.info/testnet/tx/push`