Questions tagged [programming-bitcoin-book]

Programming Bitcoin is a book by Jimmy Song teaching the math used in Bitcoin and inner workings of the components of the Bitcoin protocol. The book includes exercises in each chapter per which the reader implements a Bitcoin library in Python. Programming Bitcoin was published in 2019.

Filter by
Sorted by
Tagged with
2 votes
1 answer
47 views

In the PrivateKey sign() method why are s and N-s equivalent solutions?

In the PrivateKey sign() method (Chapter 3 page 70) s is calculated like this # s = (z + re)/k s = (z + r * self.secret) * k_inv % N if s > N / 2: s = N - s Why does s and N - s work? Closest ...
Jon's user avatar
  • 23
2 votes
1 answer
97 views

What is the content of ScriptPubKey for P2WPKH?

What is the content of ScriptPubKey for P2WPKH? Master bitcoin book 2end edition says the following (link): Example P2WPKH output script 0 ab68025513c3dbd2f7b92a94e0581f5d50f654e7 In programming ...
dassd's user avatar
  • 1,029
1 vote
0 answers
51 views

Error when trying to broadcast multi input tx (Programming Bitcoin by Jimmy Song)

I am reading Programming Bitcoin (chapter 7 exercise 5) and I have created a 2 inputs 1 output transaction on testnet which I have signed and it now verifies as true. When I go broadcast the ...
user144329's user avatar
2 votes
1 answer
124 views

Fail at coding my private to public key converter (Pyhon)

Fail at coding my private to public key converter script for Bitcoin (Secp256k1) Currently going through the book "Programming Bitcoin by Jimmy Song", got stuck on page 61 (Chapter 3), but ...
Maltoon Yezi's user avatar
1 vote
1 answer
78 views

Why we need to repalce the ScriptSig with the previous ScriptPubKey when calculate the per input signature hash?

I'm reading Programming Bitcoin. And in Chapter7, the author talked about the way how signature hash is calculated by replacing the transaction's ScriptSig with the corresponding previous ScriptPubKey....
Shawn C's user avatar
  • 37
1 vote
1 answer
117 views

How does the SegWit part of a transaction get serialized and parsed?

I'm reading Programming Bitcoin. And in Chapter13, I am confused with how the witness part is serialized and parsed. The auther gives the following method to parse it: def parse_segwit(cls, s, testnet=...
Shawn C's user avatar
  • 37
4 votes
1 answer
226 views

Jimmy Song 'Programming Bitcoin' book math doubt

I guess this is a math question and not a bitcoin question, but I would have a hard time expressing the doubt in a math forum, whereas here, maybe someone who knows the book and has the right ...
rubdottocom's user avatar
0 votes
1 answer
141 views

Retrieving a WIF bits private key

Suppose I have a Wif private key from Electrum 4.0.9: L2pt3eVopnxfBBvMwrJV2saZeAyQfF77UQSH5WGj5q9LBS6WWBmN ( this one or the other generated from the seed is non used of course ) with a corresponding ...
Saxtheowl's user avatar
  • 2,770
0 votes
1 answer
140 views

Invalid p2sh transaction accepted by the network

I have try to build a 2 of 2 p2sh transaction from scratch using the book "programming bitcoin" by Jimmy Song, we are not directly guided to make one of those so I had to modify some of the ...
Saxtheowl's user avatar
  • 2,770
2 votes
1 answer
374 views

p2pkh vs. p2pk keeping public key private

I just got into learning Bitcoin programming through Jimmy Song's Programming Bitcoin. Jimmy says that some of p2pkh's advantages over p2pk include: a smaller ScriptPubKey keeping one's public key ...
yoyobigmanyo's user avatar
2 votes
1 answer
101 views

why is my p2sh raw transaction not being mined or erroring ERROR: 64: NON-MANDATORY-SCRIPT-VERIFY-FLAG (EXTRA ITEMS LEFT ON STACK AFTER EXECUTION?

I created this 2-of-2 multi-signature address for testnet following the instructions on the book Programming Bitcoin. I tried to spend the funds in this address following the standard forms (...
Oscar Serna's user avatar
1 vote
0 answers
120 views

BIP0034 block height using python-bitcoinlib

I'm doing some experiments for finding coinbase height from freshly mined block which is received from ZMQ. tx_coinbase = CTransaction.deserialize(x('...
Ilya Evdokimov's user avatar
1 vote
0 answers
137 views

Can't inititate network handshake with my full node

I am running a custom Python script to initiate network handshakes with other nodes. While testing the code I decided to initiate an handshake with my own node but I am getting a timeout error. ...
Rajarshi Maitra's user avatar