text:
minerd disappears when i try to launch it with a batch file?
I started using pooler cpuminer v 2.3.3 yesterday and it works.
Today, it doesn't. I have no idea what the problem is, when I open the batch file, the minerd file disappears.
This is my command line thing:
http://pastebin.com/DyqstLrn
UPDATE: The thing that was causing the problem was Malwarebytes Anti-Malware. It works fine now, thanks for every one's support!

What do you mean by "the minerd file disappears"? It is deleted from its directory?

disappears as in it got deleted somehow

If you copy the minerd file back into the directory and run the script again, does it get deleted again?

it disappears every time I copy and run it

This is very strange. But I think the explanation provided by jamd315 is quite plausible. Antivirus software looks for mining programs because they are often used by viruses to hijack people's computers and mine without their knowledge.

I disable my antivirus every time I run it and turn it back on but it still does that, so I don't know why this is happening

This is probably your antivirus either deleting or quarantining it.  Depending on your antivirus, you need to manually trust minerd.exe and/or restore it from quarantine.
I use Norton 360.  To unquarantine with Norton

Open Norton
Click tasks at the top
Click "Check Security History" on the left
Find minerd.exe, it might be easier to re-extract or re-download
Click more details
Click restore at the bottom

Comment and I will try for other antiviruses

avast antivirus?

I googled and found this as easiest to understand http://www.youtube.com/watch?v=-ZcWsAcA8dU

I removed it from the chest and added it to the exclusions but still after I run it, it disappears.

Can you show me the contents of the file?


text:
No update on API when receiving payments from other Blockchain.info wallets
I am using the Blockchain.info API for an online shopping website. I have a problem in my Receive API: Payments from other wallets are working fine. Also, payments done by copying the address and sending payment to that address is working fine, but when a user sends payment from another Blockchain.info wallet using QR code (scanning the QR code via Blockchain App for Android), the index.php page remains as it is. Neither the .js file is called, nor the callback.php.
How can I still be notified of such payments?

EDIT : It doesn't work only if the user sends payment by scanning QR code from the Blockchain android mobile app. (haven't checked with iPhone)

You need to tell us what software or service you are using. As it is this question doesn't provide sufficient information to be answered.

I am using Blockchain API to Receive payments. Integrating this API with an online shopping website.

Yeah, well, how about you edit your question to put the information there instead of posting comments? Imagine that you are not familiar with your project, but hearing the first thing about it: You will realize that it is not clear what information you are scraping, what you have tried and so forth. Please provide more information, otherwise nobody will be able to help you, due to sheer lack of comprehensibility. – I have tried to get you started by editing some of the provided information into your post.

How can a .js be called, considering it runs clientside?

Can't see what would be different from a QR scan.  If the correct BTC address is getting paid, it shouldn't matter if the address was copied, QR'd or hand-pecked.
I have an example of the callback from Blockchain's Receive API here:
https://github.com/damonp/simplebtcpay/blob/master/www/callback.php

If each address you give to a user to deposit funds is unique, then you can check the balance of that address and get a response with the current balance & total deposited. You specify the confirmations in the URL of the api call.
Also are you using the Receive Payments API to receive payments, and the Wallet API for everything else? Because that seems silly.

Can you please mention the exact details of how to check balance and amount deposited?
I am not using Wallet API, just Receive API. My question is that if payments by copying the address and making payment is working, then why doesn't payment by scanning QR code work?

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Why does the hash come before the signature?
The first figure in the original paper of Satoshi is a diagram of transactions.  This diagram seems to indicate that the transaction data is hashed before the sender's signature is appended.  Why not just hash the entire transaction, including the signature, to produce all-encompassing transaction hash?
Update:  I want to highlight the comment by @David Schwartz on the accepted answer.

Because it would not have a function. The hash listed in the picture of the original whitepaper is just to make the signature shorter (and possibly the process of creating it faster) without losing security, its only function is the authentication of a transaction, it is not used for anything else (or even stored).
To clarify, this is the diagram mentioned in the question:

You seem to be implying that the original transaction (unencrypted) is not stored in the block chain.  If it were, one could plainly view all details of the transaction, including the signature and the message that it signs ...

Hm, I think I understood your question wrong, I'll edit the answer.

I'm marking this as the solution because it seems reasonable.  I would still be interested in seeing some references to support your claim.  If I understand correctly, you are claiming that the sole purpose of that hash is to shorten (and/or speed up) the signature.  (I assume then that these hashes have nothing to do with the tree of hashes that leads up to the Merkle root.)

That is correct. Take PGP (or GPG) for example, you almost never see someone signing an entire message, because this would add a considerably long overhead. Instead a hash of the data is constructed and signed to prove that the data indeed originated from some party, because with a secure hashing algorithm it is almost impossible to find an other piece of data that results in the same hash. Merkle roots have to with how transactions are represented inside blocks.

The algorithms used can't sign anything that exceeds the curve size. So you must hash before signing.

authors: Лёня Цукерман

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
How much entropy is lost alphabetising your mnemonics?
Yes I know this is a horrible idea and not BIP39 compliant, but please help satisfy my curiosity with this "thought experiment" and applied maths exercise.
Two questions, one for 12 words, the other for 24.
Assuming "perfectly random" entropy to start, and yes the final checksum word gets changed with the new ordering, not itself included in the alphabetical sort.
Just how much entropy is lost in the phrase's re-sorting, compared to the original random sort?
I don't need the "show your work" maths, more like practically speaking about current brute-forcing capabilities,  "you would lose 70% of your entropy, and 40% respectively"
If not too inconvenient, something ELI5 like, how many supercomputer-years of effort's difference?

TL;DR: you get around a factor 500 million attack speedup for 12 words, bringing it not quite in the realm of feasible attacks, but it's getting close. For 24 words, the speedup is around a factor half a septillion, but still far beyond the realm of feasible attacks.
Repetition of words or not?
First I need to ask: are words permitted to occur multiple times within the same sorted phrase? If not, Mike D's answer is correct. If they are, the question just got a lot more complicated, at least if you care about the exact numbers.
The difficulty with allowing repetition
Once you allow repetition, the distribution you obtain by sorting uniformly chosen phrases, is no longer uniform. For example the sorted phrase "act act act act act act act act act act act zoo" can be obtained from 12 distinct unsorted phrases ("act ... act zoo", "act ... act zoo act", "act ... act zoo act act", ...). The sorted phrase "mad mad mad mad mad mad mad mad mad mad mad mad" can only be obtained in one way. Thus, if you start with a random unsorted phrase, and sort it, the "act ... act zoo" phrase is 12 times more likely than the "mad ... mad" phrase.
This non-uniformity has a subtle but complicated impact on our question. If the phrases are uniformly distributed, with N possibilities, then it holds that:

The number of distinct phrases is N.
The entropy (in bits) of a sampled phrase is log2(N).
The average number of tries an attacker needs to brute-force guess a sampled phrase is (N + 1) / 2.

When the phrases are not uniform (as would be the case when sorting uniform phrases with repetition), the answer to (2) and (3) cannot be simply expressed anymore as a function of N. It depends on exactly how non-uniform the distribution is. Worse, you can't even compute (3) from (2) or the other way around, because entropy is not a measure for how secure something is, but for how compressible it is. These two are strongly correlated, but not exactly the same, and the difference between the two again will depend on the exact distribution.
This is all to say that the answer to these three questions is distinct, and it depends on what you're interested in:

How many distinct sorted phrases are there?
How much entropy do phrases obtained by sorting uniform unsorted phrases have?
How hard is it for attackers to guess a phrase obtained by sorting a uniform unsorted phrase has?

1. How many distinct sorted phrases are there?
The number of distinct multisets of k elements, drawn from a set of N elements is .

For k=12 and N=2048 that is 11737947382912650038702322439680, or ~2103.211.
For k=24 and N=2048 that is 54640990776272965318633918350257589558711775320768326400, or ~2185.156

Note that these numbers only differ slightly from the corresponding numbers when repetition is not allowed (2103.118 and 2184.767 respectively)
2. How much entropy do phrases obtained by sorting uniform unsorted phrases have?
The entropy of a distribution is how many bits on average an optimal compression scheme needs per element to encode a (long) list of randomly sampled elements from that distribution. For a discrete distribution taking on possibilities a1, a2, ..., an, with respective probabilities p1, p2, ..., pn, that is . By applying this formula to the probability distribution of sorted phrases exactly, you get:

For 12 words: ~103.196 bits
For 24 words: ~185.097 bits

3. How hard is it for attackers to guess a phrase obtained by sorting a uniform unsorted phrase has?
The optimal strategy for an attacker that tries to brute force, and who knows the probability distribution, is to try values from most likely to least likely. The expected number of tries under such a strategy is , assuming the pi are sorted from high to low. Applying this formula to the exact probability distribution in question here we get:

For 12 words: ~(2103.166 + 1) / 2
For 24 words: ~(2184.985 + 1) / 2

In other words, the average time an attacker needs for guessing these sorted phrase distributions is as if they were uniform distributions with ~103.166 resp. ~184.985 bits of entropy (but, as demonstrated in the previous section, that is not exactly the entropy the sorted phrase distributions have).
Summary
The following table summarizes the numbers for all 4 scenarios (repetition allows and not allowed, sorted or not), under all 3 metrics (number of possibilities, entropy, and expected number of tries for an attacker):

12 words
# possibilities
entropy
mean tries

Normal, repetition
2132
132 bits
(2132 + 1) / 2

Normal, no repetition
~2131.953
~131.953 bits
~(2131.953 + 1) / 2

After sorting, repetition (*)
~2103.211
~103.196 bits
~(2103.166 + 1) / 2

After sorting, no repetition
~2103.118
~103.118 bits
~(2103.118 + 1) / 2

24 words
# possibilities
entropy
mean tries

Normal, repetition
2264
264 bits
(2264 + 1) / 2

Normal, no repetition
~2263.805
~263.805 bits
~(2263.805 + 1) / 2

After sorting, repetition (*)
~2185.156
~185.097 bits
~(2184.985 + 1) / 2

After sorting, no repetition
~2184.767
~184.767 bits
~(2184.767 + 1) / 2

(*) = Note that only the lines for after sorting with repetition have distinct numbers in their expressions for the three columns. For all others, they follow the pattern 2v, v, (2v + 1) / 2 for some value v perfectly, because they induce uniform distributions.

Wow, mind blown, what an honor, I am incredulous you put in that level of effort. Thank you! And yes I meant allowing repetition but that seems to not make much difference?

@HansBKK Yeah, the numbers differ at most by a few percent between repetition and no repetition. And I may have gotten nerdsniped a bit here...

Learned a new word today...  The world is a better place for the effort you put into it, so glad you deemed it interesting enough.

The number of possible 12 word phrases (disregarding the checksum) is 2048 ^ 12 = 5444517870735015415413993718908291383296
The number of alphabetically ordered 12 word phrases is

= 11005261717918037175659349191168
The second number is smaller by a factor of 500 million or a reduction of 99.9999998% but you measure such large numbers in bits in which case you get an entropy reduction of 29 bits (132 - 103)

Fantastic, thanks. So for 24 words, the ratio is similar?

for 24 words just replace 12 with 24 in the formula above

Sorry I do not know what the notation means on a computer, only did maths on paper as a boy, and can't figure out how to google that

I think ^ means exponent, like "to the power of" but my calc gives a different answer https://i.imgur.com/AMD0DHV.jpg . I have no idea about the expression with the parentheses

You are right the correct number is 5444517870735015415413993718908291383296 (same as your calc). For the second number type “2048 choose 12” in google

OK so a "choose" operator. But every definition and discussion I look at says specifically that it means "order is ignored" ???   https://math.stackexchange.com/a/3979642/1052171   But if that were true, wouldn't the answer be same as the exponent one?

We want order to be ignored when counting ordered groups otherwise we would double count the same 12 words in a different order

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
BIP85: Is the list of mnemonic sentences deterministically ordered?
There aren't many working implementations of BIP85 yet.
Ian Coleman's, Grondilu just added support to their Bitcoin Bash Tools, COLDCARDwallet, AirGap Vault and the Python demonstration library https://github.com/ethankosakovsky/bip85
Please post comments with any others you know of.
All should generate the same set of mnemonic sentences, but is the order supposed to be the same?
So I could specify "mnemonic #5" and "mnemonic #14" and those index numbers will point to the same sentences no matter which tool I use to generate them?
Also, hypothetically asking only, is there any practical limit to the number of mnemonic sentences generated or can you just keep going say past a million of them?
Is it theoretically possible there might be collisions between BIP85 sets?

JavaScript library implementations:                https://github.com/hoganri/bip85-js
https://github.com/scgbckbone/btc-hd-wallet

This is the typescript implementation which is used by the iancoleman tool: https://github.com/AndreasGassmann/bip85

The "order" of mnemonics is the same, assuming the implementations are correct. The derivation path that is used is defined in the specs. Specifically, it is: "m/${BIP85_DERIVATION_PATH}'/${BIP85_APPLICATIONS.BIP39}'/${language}'/${words}'/${index}'" (Taken from the BIP85 library linked above).
Reference: https://github.com/bitcoin/bips/blob/master/bip-0085.mediawiki#12-english-words
You can generate millions of them by increasing the index. You can get even more by using an additional BIP39 passphrase.
I'm not a cryptographer, but it's probably about as likely as randomly generating the same mnemonic 2 times by accident.

You can get even more by using an additional BIP39 passphrase.  / That would derive an entirely new "set" though, right? So if my first "root mnemonic" were compromised, I would switch all the derived wallets over to the new root's derived set.

The derived path + specified indices do indeed define sentence order deterministically. Pretty sure a good answer, will just leave it open a bit longer?

If you use a BIP39 passphrase, an attacker that has your "root mnemonic" will have to know your BIP39 passphrase to get your derived child mnemonics. So the security here depends on how long your BIP39 passphrase is. But generally, if your root mnemonics is compromised, you should consider your child mnemonics compromised as well and you should move to a completely new mnemonic.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
What changed about coinbase.com to make it a "regulated exchange"?
It's all over the news that coinbase "will open the first regulated bitcoin exchange in the U.S.".   But what exactly is the news here?  Hasn't coinbase been serving customers from all across the U.S. for more than a year now?  What is changing?

As the Reddit post linked in your answer points out, the Coinbase that we already knew uses ACH transactions to move money in and out of your account, which makes it not very good for day trading.
Coindesk coverage of the new exchange states that Coinbase previously acted largely as a brokerage for Bitcoin users. A brokerage firm trades securities on behalf of investors. In contrast, an exchange is a market where brokers and dealers meet, with infrastructure to facilitate buying and selling. The Coindesk article goes onto state that Bitcoin will have a full order book, which is a list of interested buyers and sellers for each financial instrument. A matching engine uses the list to determine what trades can be made.
In addition, Coinbase needed money transmitter licenses to operate as an exchange.  They already obtained money transmitter licenses in order to legally operate USD wallets (which is why their USD wallets are not available in all US states), but Bitcoin couldn't hope to operate as a legal exchange in the United States without money transmitter licenses.
Regulations in the United States have required that certain types of Bitcoin businesses have money transmitter licenses, as business attorney Marco Santori explains:

The Financial Crimes Enforcement Network (“FinCEN”) is the bureau of
  the US Department of the Treasury that enforces federal regulation of
  money services businesses in the United States.
On March 18, 2013, FinCEN published guidance announcing that it would
  make no distinction between transmitters of government (or “fiat”)
  currency and transmitters of bitcoin, which it now famously referred
  to as a “decentralized convertible virtual currency”, rather than by
  name itself.
Thus, businesses that transmitted, sold or exchanged bitcoin were now
  Money Services Businesses, specifically “money transmitters”, required
  to register with FinCEN and satisfy ongoing record-keeping and
  reporting requirements. From the perspective of the federal
  government, an entire industry of visionary startups that had not
  already registered, and had no intention of registering, became
  potential criminal enterprises overnight.

He goes on to state that spending Bitcoins on goods / services does not make one a money transmitter, but that transmitting money (fiat money or cryptocurrency) does. In addition, exchanging fiat currency for cryptocurrency, cryptocurrency for fiat currency, or even between different cryptocurrencies makes one a money transmitter in the eyes of the US federal government.

This old reddit post kind of answered it for me.  But I won't be marking this as the answer, in case anyone would care to provide a more direct and well-referenced explanation.

authors: ศักดิ์สุริยา จ่าสินธุ์


text:
Where do transactions get sent?
Related: how do transactions get to miners, but I'm looking for a slightly (and only slightly) more technical discussion.
Say I download a lightweight bitcoin client and set up a wallet on machine A. From another machine B, I send a coin to this new wallet.

How does my transaction reach a miner? Presumably, the client on machine B sends a message out to the internet ... but doesn't it have to specify which IP address to send such a message? Which IP addresses does it send to?
Similarly, how does machine A learn of the transaction? Is the client continually pinging the network to query for new transactions to its address? How does it know what IP addresses to ping the first time it executes?

This discussion appears to answer the bulk of the question. A summary overview could still be helpful: https://bitcoin.stackexchange.com/questions/53260/what-precisely-are-vseeds-seednodes-how-to-they-work-how-to-create-one-for-a?rq=1

How does my transaction reach a miner?

First, when you start up your wallet, it will connect to several other nodes on the network using the mechanism described here. These connections are TCP connections, so they are data streams from one computer directly to another; the IP addresses are known and data transmission is handled by the TCP layer.
Over this TCP connection, the two nodes will begin exchanging data. This first consists of some initial handshake stuff like version messages, various filters for the other node to apply before sending data to the other node, etc. Then it consists of block and transaction data. These are typically first announced via an inv message (basically just says "I have this piece of data"), requested with a getdata message (says "please give me this piece of data"), and sent with the appropriate message type (block, tx, etc.).
So when you send a transaction, your node announces via an inv message to the nodes that it is connected to that it has a transaction. The other nodes request it and the transaction is sent. Then those nodes repeat the same process; they announce to their peers that they have a transaction, it is requested and then sent. That is how a transaction propagates through the network. Eventually it will reach a nodes which belong to miners so the miners will be able to include your transaction in their next block.

Similarly, how does machine A learn of the transaction?

Since the TCP connections are bi-directional, your node is also receiving blocks and transactions from its peers. For full nodes, it will receive every block and transaction that its peers knows of, which, in general, will be every block and transaction on the network. It can then interpret each transaction and find the ones which pertain to your wallet.
For a lightweight wallet, it will use a special set of messages which allow it to set a filter on the transactions it receives. This filter is sent to the nodes it is connected to and those nodes will only send to your wallet the transactions that match this filter. Then your wallet will do additional filtering locally to find exactly which transactions pertain to it (the filters set can have false positives).


text:
How can I configure Vim to work with bitcoin core C++ source code and have Intellisense like functionality?
I use Vim for editing, I installed Conquer Of Completion (COC) plugin and now I can edit C++ projects with Vim taking advantage of syntax highlighting, autocompletion, inline error messages, etc. But when I try to open bitcoin source code files I get too many errors, like:
Too many errors emitted, stopping now
'wallet/coinselection.h' file not found
Unknown type name 'OutputGroup'
Etc.
Is there a best practice to work with the source code in Vim, or at least some general recommendations you can share?
Thanks!

I found the problem, a build database, based on the project, had to be generated for Clangd language server to do it's work. To do it, I used Bear, a tool that intercepts the build commands and generates a compilation database for clang tooling (compile_commands.json). I also made a video:
https://youtu.be/lC5USwFM6EQ (English),
https://www.youtube.com/watch?v=5tkgqzxic-Q (Spanish) explaining how I did the installation and configuration. I hope this helps other developers.

I suspect this is a problem with your plugin rather than Vim. Try disabling the plugin and see if you have the same issue. I have no problems opening and editing all Bitcoin Core source code files including wallet/coinselection.h with Vim.
I'm not a Vim guru by any means (hopefully someone who is will answer) but for recommendations on using Vim generally (not Bitcoin Core specific) vimrc is a popular Vim configuration and this Changelog podcast contained a number of tips for using Vim including links to the guests' dot files.
You'll want to make use of vimdiff for reviewing pull requests. As Jon Atack says in this doc:

While the build and tests are running, begin reviewing each commit separately in your local environment using a diff tool like gitk, meld, meld for macOS, GNU ediff for Emacs, vimdiff or vim-diffconflicts for Vim, opendiff on macOS, or diffoscope

There is also a Vi/Vim StackExchange.

Thx, I'm very familiar with Vim configuration. I do can open Bitcoin source files, but I want autocopletion, goto definition and member list help. Do you use tab completion and goto definition when you edit bitcoin source files? Do you use any plugin?

@Bitcoin_1o1: I use ctags, cscope for goto definitions but personally I don't use autocompletion (excluding basic find and replace) or member list help. As I said I'm no Vim guru so there may be plugins for those. https://stackoverflow.com/questions/563616/vim-and-ctags-tips-and-tricks

You say "But when I try to open bitcoin source code files I get too many errors" in your question?

thanks, I managed to make it work, I'm going to make a video so other people who work with Vim can do the configuration. Best!

Cool, post the link here. I'll watch it :)


text:
Does Liquid block explorer omits range proofs?
I am looking at a random Liquid TX like this one. It is a CT with the total size of 9205 bytes. Am I correct to assume that the bulk of the total size are range proofs, but they are not shown in the explorer (probably for readability reasons)? What is the best way to actually see them otherwise?


text:
BTC-e funding/withdrawal methods. Anybody tried any of these?
When one tries to deposit or withdraw, a dropdown list shows several choices, including Perfect Money, MoneyPolo, and OKPAY (and some other ones, including various cellphone-related ones with high fees, which I'm not interested in). If I'm not wrong, Mt. Gox supported OKPAY too, back in the day.
Has anybody tried any of these three and is willing to share their experience? (MoneyPolo and OKPAY are both owned by Mayzus, apparently, but I don't know what differences are there between them).
Also, if anyone knows there's another SE site where this question would be more likely to be answered, or somewhere else where I can find this info, it would be really helpful too.

I am using perfectmoney there for funding there and it goes always instant to get credit my account balance, i think that is nice method to use there.


text:
Bitcoin trading volume: what's going on?
Since January, bitcoin trading volume on exchanges has been slowly dropping (more or less, on average), but it's had a significant drop around May 13th, and has stayed low since then. I checked the volume from BTC China mainly, but it seems several (if not all) exchanges exhibit this phenomenon. Up to this point, I'm just stating facts.
My question is: does anybody know about any reasonable explanation for this? I mean, based on facts, evidence, or meaningful experience on the subject. For example, has this happened before? If so, it could be some temporary/cyclic phenomenon, maybe (?). Also, if this happens to be some sort of pattern that has occurred before, can we expect the volume to go up again anytime soon? Is it some sort of "bad sign" ? (as in "this pattern is often followed by a big crash" or something like that).
I know nobody has the crystal ball, and I'm not asking for unfounded opinions; I just thought that maybe someone with more financial experience or knowledge on the subject (than me, which shouldn't be very hard) could shed some light on this.

That's a good edit, but the question appears still very speculative too me. For example my guess would be that it is the overlay of us going through the Trough of Disillusionment of this hype cycle and summer starting. Bitcoin is still very much hobby driven, and people spend less time on computer hobbies during the summer. In the past years Bitcoin was exhibiting more growth in winter.

I don't see how it hurts if people are allowed to post such answers. In other SE sites I've seen really bad questions being answered, and sometimes the answers themselves addressed the flaws of the question. If my question is so unworthy of being answered, why not leave it alone (and just let it get no answers, eventually)? Why prevent everyone from answering? I'll have to ask somewhere else, or keep wondering. And I don't get the point.

I've reopened the question. In any answers, please focus on facts and argument supported statements. Posts consisting only of unsubstantiated claims and opinions will be treated as low-quality.

I am not sure that exchanges show us correct "trading volumes". Can we trust these digits?

@amaclin I don't know, but there's no better source. Besides, all or most exchanges' data agree with each other.

@Murch thanks. If nobody answers, ok, but let's at least let them.

This question could be asked of any financial instrument. Volumes decreasing is not a bad or good sign. It's simply something that occurs when volatility decreases. The market theory behind it might go like this.. Price has fallen to such low points sellers are no longer interested in selling. Buyers are still hoping for lower prices. This effect causes the price to trade within a range where anytime the price rises to an acceptably high level sellers begin to sell again and any time it reaches an acceptably low level buyers begin to buy. As traders notice the price is range bound more traders stop trading. This compounds decreasing volumes and also decreases the trading range. Eventually this will lead to reduced trading interest which can then lead to the price breaking out of the range in the direction of least resistance (as traders give up their respective buying or selling).
Sorry there is no provable answer to your question, as this is all market theory. However, if you were to look at different financial instruments historical volumes you would see many instances similar to what is currently happening in bitcoin's market volumes. This is a common pattern in markets and is normally described as not predictive of future events (range trading is often thought as having a random breakout direction).
https://en.wikipedia.org/wiki/Triangle_%28chart_pattern%29#The_symmetrical_triangle

Thanks for anwering. So it seems it isn't that strange for this to happen, and there's no useful info to extract.


text:
How to make a P2SH-P2WPKH output using bitcoin-cli?
Can you give a simple step-by-step example on how to create a transaction with an output of P2SH-P2WPKH using bitcoin-cli on Regtest?

By P2SH-P2WPKH transaction, you mean a transaction that has such an output, or has an input spending such an output?

Thx, I modified the question to clarify that is a transaction with such an output

For this example, we will use a transaction that spends two outputs from a previous transaction. The first output (1N2) is paid to the pubkey script "P2SH-P2WPKH" and the second output (1N3) is paid to the pubkey script "P2SH".

Create the first transaction that spends the two outputs from a previous transaction. In this example, the first output (1N2) is paid to the pubkey script "P2SH-P2WPKH" and the second output (1N3) is paid to the pubkey script "P2SH".

bitcoin-cli sendtoaddress 1N2 P2SH-P2WPKH
bitcoin-cli sendtoaddress 1N3 P2SH

Get the hex encoded transaction data for the first transaction.

bitcoin-cli gettransaction 1N2

you might want to use markup and/or example values or otherwise somehow make it more clear what strings in your answer are variables, flags, commands, etc

As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.


text:
Why Bitcoin Core source code use #include bracket syntax instead of quote syntax
Why Bitcoin Core source code use #include <rpc/wallet.h> bracket syntax instead of #include "rpc/wallet.h" quote syntax. Can intellisense C++ editors understand this option and not show a warning?

Double quotes means that the compiler will search for the include relative to the source file. Angle brackets means the compiler will search only the include paths. By using angle brackets and including all of the header files in the include path, the paths given in the include will always need to be relative to the project's source root.
The purpose of doing this is to reduce developer confusion as there are several files in different directories that are named the same. Requiring the include path to be relative to the source root, it becomes unambiguous as to which file is being included.
The PR that implemented this was (a rebase of) https://github.com/bitcoin/bitcoin/pull/11053, and that links to other discussions for motivation.

Is there a CLANG flag to avoid this message in Vim? `'bech32.h' file not found with  include; use "quotes" instead"

You need to make sure the project's src/ directory is in the include paths. For clang, if running in src/, that'd just be -I..


text:
Why does the network allow a fraudster (double spender) to broadcast a transaction to a single node (the victim)?
Let's assume for the sake of argument that a fraudster is able to create blocks faster than the rest of the network. Given that, they would be able to achieve double spending by making a fraudulent transaction, broadcasting only to a single node (the victim), and by being able to find proofs of work and broadcast blocks to the victim (and only to him, otherwise no double spending will be achieved) faster than everyone else, the victim accepts that transaction as authentic and updates their wallet.
That could've been prevented if a node can only broadcast its transactions and blocks to everyone else in the network.
In that case, why does the network allow any node to broadcast a transaction or a block, only to one node? Is it unable to prevent it, or is it a result of bad design?

How would you practically imagine that one can enforce that anything shared with anyone must be shared with everyone? What if you're only connected to one peer for example?

I am not familiar of how bitcoin is implemented (or how a P2P network is implemented in general), but I could imagine that as a client I get to make a transaction, rather than decide who I broadcast it to. In other words, if I make a transaction it's broadcasted to everyone which is how the DEX would've been implemented, and based on your comment I figure this is what I am unaware of, that it's impossible in a P2P network or against its fundamental feature.

In the real world, "the network" isn't a separate entity that we can magically cause to behave the way we want. It consists of individual nodes, which may or may not be malicious. We don't get to say how other nodes behave, only our own. Bitcoin is designed so that it economically incentivizes the behavior we want, but this has significant limitations. There are basically no restrictions on what nodes do with individual transactions before they get mined. So no, all we can do is say how/when/where to the transaction creator's own node sends it.

Furthermore, even if (and that's a very big if) we could decree how every node behaves, we still could not prevent double spends, simply due to the law of physics. Signals cannot travel faster than the speed of light. If two conflicting transactions spending the same coin were authored and broadcast nearly simultaneously, one in the US and one in Australia, then necessarily, some nodes will hear about one first, and others will hear about the other first. In a decentralized system, there is no objective concept of "first". Someone will have to choose: in Bitcoin, the miners.

why does the network allow any node to broadcast a transaction or a block, only to one node?

The Bitcoin network is a set of computers that communicate over the Internet using the Internet Protocol (IP) and the Transport Control Protocol (TCP). The Bitcoin network protocol is an application layer protocol that is a layer above the transport layer (TCP) and Internet layer (IP).
As such IP and TCP do not provide a mechanism that prevents one computer from communicating with one specific other. They don't prevent this because this is exactly what they were designed to do.
IP does include both broadcast and multicast capabilities however Bitcoin uses an approach generally described as a gossip protocol. Each node communicates on a direct one-to-one basis with each of a small number of other nodes. I'm not familiar with managing an IP multicast domain but I suspect it might be difficult in a purely peer-to-peer arrangement of nodes such as Bitcoin requires. You also have to allow for nodes that are offline at the time of the broadcast.
It is hard to imagine how one could enforce a broadcast-only policy since new Bitcoin nodes are continuously being created and older Bitcoin nodes disappearing and regular Bitcoin nodes are on computers that are only intermittently connected. We wouldn't want the whole network forced to a halt because someone with a Bitcoin wallet on their phone walked into a part of a building where phone reception was poor, or ran their battery down, suffered a power cut, broke their phone, etc. There will never be a time when all nodes are available.
I believe this would be especially difficult in a peer-to-peer network like Bitcoin, where there is no centralised control and anyone can write a Bitcoin application.

IP multicast/broadcast are not a solution. They too cannot guarantee that everyone will hear about everything (e.g. network connections can be flaky, packets can be lost). What OP is calling for is a theoretical concept called broadcast channel... and Bitcoin has one: it's called the blockchain. If the network layer itself already provided a broadcast channel, we wouldn't need the blockchain in the first place.

@PieterWuille could you please explain what is the broadcast channel you are referring to and how is the blockchain one?

A broadcast channel is some kind of system where any participant can put a message on, and if successful, they know that every other participant will get that message. That is precisely what the blockchain provides: if someone sees their transaction included on chain, they know everyone else will see it. But the P2P network (or no real network) provides it in the way you're asking for.

Then the blockchain would be a broadcast channel only if the participants broadcast their transaction to everyone, otherwise, by assuming that a fraudster is able to create blocks faster than others, the victim will have a different blockchain than the rest on the network, contrasting the guarantee that "if someone sees their transaction included on the chain, they know everyone else will see it." Which is the case, that is the bitcoin blockchain provides no such guarantee (virtually does as the assumption is very extreme), because bitcoin is a / on a P2P network. Did I get that right?

Given that, they would be able to achieve double spending by making a fraudulent transaction, broadcasting only to a single node (the victim), and by being able to find proofs of work and broadcast blocks to the victim (and only to him, otherwise no double spending will be achieved) faster than everyone else, the victim accepts that transaction as authentic and updates their wallet.

Which version of the blockchain is accepted by the victim node is not determined by the speed at which blocks are added, but by the total combined hashrate which was used to make those blocks which can be cryptographically verified. A Bitcoin node always chooses the "heaviest" chain with the most combined hashrate, not the "longest" chain with the most blocks.
You'd need to pull off a 51% attack to do this unless you could also convince the victim node to somehow not talk to any other nodes on the network, in which case you could insure that your "version" of the chain is accepted by that node as it is the heaviest version out of 1 total versions. You could spend BTC in your "version" and when the victim node re-connected to the rest of the blockchain it would see that you didn't actually spend those coins since you spent them on a dead fork.
Note that even if you could isolate your victim node from all other nodes in the Bitcoin network, you would need enough hashpower to solve the cryptographic proof in the block previous to the start of your attack, which would require many resources and be a significant feat. Whatever you are "buying" with your double-spent BTC would have to be more expensive than the cost of the attack. Anybody accepting high-value payments is going to require a few block confirmations. So not only would you need to make one fraudulent block which matches the network's previous hashrate, you would need to make multiple.
Also, anybody who:

Runs their own node
Accepts high-value payments for goods or services which you are trying to steal

Is probably going to realize that their node is somehow disconnected from the rest of the Bitcoin network.


text:
How do we know that Bitcoin supply is actually capped at 21 million?
Everyone says that the Bitcoin supply is capped at 21 million. But how did everybody come to this number? In Nakamoto's paper, I could not find this number. Can someone explain where it is or how we can infer this maximum based on Nakamoto's paper? I'm not a mathematician. Maybe, it's clear for everybody but to me this seems to be a fantasy number.
Nakamoto, S. (2008). Bitcoin: A peer-to-peer electronic cash system. Decentralized
Business Review, page 21260.

Thanks in advance for your reply.

Does this answer your question? How is the bitcoin 21 million cap implemented?

The whitepaper doesn't mention any specific supply cap, and actually the distribution parameters it suggests are very different from the actual parameters implemented in Bitcoin:

6. Incentive
By convention, the first transaction in a block is a special transaction that starts a new coin owned by the creator of the
block. This adds an incentive for nodes to support the network, and
provides a way to initially distribute coins into circulation, since
there is no central authority to issue them. The steady addition of a
constant of amount of new coins is analogous to gold miners expending
resources to add gold to circulation. [...] Once a
predetermined number of coins have entered circulation, the incentive
can transition entirely to transaction fees and be completely
inflation free.

I would interpret the words "steady addition of a constant of amount of new coins" as a constant mining subsidy that abruptly ends after a predetermined amount has been mined.
The announcement of the release of the first Bitcoin client by Nakamoto mentions the supply cap and parameters as we know them today:
https://www.metzdowd.com/pipermail/cryptography/2009-January/014994.html

Total circulation will be 21,000,000 coins.  It'll be distributed to
network nodes when they make blocks, with the amount cut in half every
4 years.
first 4 years: 10,500,000 coins
next 4 years: 5,250,000 coins
next 4 years: 2,625,000 coins
next 4 years: 1,312,500 coins etc...

And of course, you can look into the source code of Bitcoin Core or any other Bitcoin node software to verify the supply cap for yourself. See this answer.


text:
How to store/export coins from bitcoind to papper wallet 'cold storage'
I have bitcoind 0.9.1 installed on my VPS debian server. I would like to store my coins via "cold storage", on paper wallets.
I read some articles over internet, but i don't know which one is usable/achievable in this case.
Could someone tell me some ideas how can i achieving cold storage via bitcoind.

With that do you need help? Creating a paper wallet, sending bitcoins, or whether its possible or not?

Well, i would like to know how can i transfer coins from my bitcoind's wallet into a papper wallet.If its possibel, how can i do that, i think i need a "step by step tutorial".

You can create a paper wallet (from a link from here for example) and then send the bitcoin to the address associated to that wallet. Then it is in the so-called cold storage. The paper does not need to know there are bitcoins on it, you just want to have the private key (which is printed on it) associated to the address you have sent you BTC to, whenever you want to access the BTC again

The idea is that you have a private key on the paper wallet, which is the ONLY (so dont loose it ;) ) option to access that specific wallet. Whatever ends up in that wallet is yours, whenever you send it (so before or after printing, but you have to create the address/key before sending of course)

@Mathias711 Those comments together would make a nice answer.

Yeah, I thought about it. But I needed to ask where he need help with. And then I just answered in the comments instead of the answer box. I will copy/paste it :)

You can create a paper wallet (from a link from here for example) and then send the bitcoin to the address associated to that wallet. Then it is in the so-called cold storage. The paper does not need to know there are bitcoins on it, you just want to have the private key (which is printed on it) associated to the address you have sent you BTC to, whenever you want to access the BTC again
The idea is that you have a private key on the paper wallet, which is the ONLY (so dont loose it ;) ) option to access that specific wallet. Whatever ends up in that wallet is yours, whenever you send it (so before or after printing, but you have to create the address/key before sending of course)


text:
What was the OP_IF opcode used for (except Lightning) before 2023?
There is the OP_IF opcode in Script. What did users use the OP_IF opcode for (use cases except for Lightning) before 2023? What tools to use to extract the transactions (with OP_IF) from historical data?

Some examples of early uses of OP_IF:

d105d570237d5be5476287fb1cfefb660996c054af133995ad7c7a1c2a8054b6 (2014-03-25): This script has two alternative branches, each containing a different 2-of-2 multisig.
15b11e8d4e5b9425f024b381ba0cb7a54a35e52389bb4855f505772ce685b39c (2014-06-24): This script has two alternative branches, one requires three hash preimages and the other requires a signature.
ce0b4c3d01abaca1592f06c73013c327a8a94cf2de8258b262db32f31981198a (2014-08-20): This script has two alternative branches, one requires a single signature and the other is a 2-of-2 multisig.
0b274321565b7eb2d7b71af60be3e3d7a710e6681c3407c9c51dd21e569614d9 (2014-09-11): This script uses two OP_IF opcodes to create three alternative branches, each containing a different 2-of-2 multisig.
2a1fe1e23bf766d87949415b49d11cacbe8d86dbc6071c311e798c37b3b906d9 (2014-09-20): This script has two alternative branches, one requires a signature and the other requires a hash preimage.

Re "What tools to use to extract the transactions (with OP_IF) from historical data?" did you query the blockchain data here yourself @Vojtech or use something else?

I wrote a script that extracts this data from a local node.

@VojtěchStrnad - is that script something you could share here (i.e. a link to github or something?)

@HannahVernon Not meaningfully, it has a lot of private dependencies so you wouldn't be able to run it, and it extracts all kinds of scripts, it's not specialized for OP_IF so it's a lot more complicated than it needs to be for this task.


text:
Example of key-path BIP-0341 signature message computation
Is there an example of key-path BIP-0341 signature message computation, perhaps? Or, could you tell what is incorrect in the example below, please?
deriveaddresses "rawtr(cV628xvqToz45dwdPmTcJ9RgEVnWMwP8dpZBGzb9LfTk3sBHFNwc)#5u2k7u2l"
[
  "tb1p2564e2pujul3m97wpcuy8jza0zg94uttfhznr0zg3etjztfrqytq7n93n2"
]
testmempoolaccept '["020000000001015f1ab0cd64d050721e4bcd63ffee5c1b4f6224b5fa8f7343062d1f0e32ab87eb0000000000fdffffff01e8030000000000001600140bc6dda83a5c6346d31808f685c7cbf1ae20a23e0140caf56a13c54a7d786579ad9b92868082685dafa4c7d97ee5d031d80105de0eea501548e63812806ec1adaf2fab6de48ec59a59701c5cdfa2e9f84e9a3c4109d900000000"]'

[
  {
    "txid": "466474502a15ca2258cf5cadcfec6743c499720843cd51c2c646ad501befffe2",
    "wtxid": "c3808cff6390357ed24705c470d4da0e3608fdcb43d34b5283a933bccb439c84",
    "allowed": false,
    "reject-reason": "non-mandatory-script-verify-flag (Invalid Schnorr signature)"
  }
]

The rest of the text has been truncated.

There are 4 issues:

Missing 0x00 prefix byte (epoch byte)
The message needs to be hashed before it can be signed. It should be a tagged hash with the tag "TapSighash".
The txid in your prevouts is backwards. It should be byteswapped from what is displayed (i.e. it is the actual result of the hash)
The sequence in your input is 0xfdffffff, not 0xffffff

Here is what I have computed for each part:

Message part
Serialization

Epoch
00

hash_type
00

nVersion
02000000

nLockTime
00000000

sha_prevouts
1da888957df6ce1ac5462fc1b08fe98f2f211026b4b91b71dbd8470239495faf

sha_amounts
3e1f6dbf626619317d04b24ac25799871709e0f3e35cc0e05dae4da21bc5a162

sha_scriptpubkeys
1e43f82396d787c36855662b53aa84af812f10cb9bdca5f2328b12ffea3f833c

sha_sequencues
23e9829bfb4e23fbd3c4848baa035af15d73bcb83e510f7f097f90a21a4280d2

sha_outputs
fd984a928339e11d1dcda5174c34ddfc8bcc976edceb919d0f52f127d0cd0bf7

spend_type
00

input_index
00000000

The entire thing that you hash should be
000002000000000000001da888957df6ce1ac5462fc1b08fe98f2f211026b4b91b71dbd8470239495faf3e1f6dbf626619317d04b24ac25799871709e0f3e35cc0e05dae4da21bc5a1621e43f82396d787c36855662b53aa84af812f10cb9bdca5f2328b12ffea3f833c23e9829bfb4e23fbd3c4848baa035af15d73bcb83e510f7f097f90a21a4280d2fd984a928339e11d1dcda5174c34ddfc8bcc976edceb919d0f52f127d0cd0bf70000000000

and you should get a hash of
1b9589328e6c5d8b71288ee5f93a78d655b724ffa0f5ebf23f88983dda8c5676

Still something is missing despite replacing the big-endian with little-endian txid. Thanks for a response.

I've updated my answer to include Pieter's comment and the remaining issue I found.

Elaborating on the answer:

Position
Name of a message part
Explanatory expression
Value before SHA-256
Final value (hex)

1
hash_type
0x00
not applicable
00

2
nVersion
LE( 0x00000002 )
not applicable
02000000

3
nLockTime
LE( 0x00000000 )
not applicable
00000000

4
sha_prevouts
sha256( LE( predecessor_txid ) || LE( predecessor_vout ) )
sha256( 5f1ab0cd64d050721e4bcd63ffee5c1b4f6224b5fa8f7343062d1f0e32ab87eb00000000 )
1da888957df6ce1ac5462fc1b08fe98f2f211026b4b91b71dbd8470239495faf

5
sha_amounts
sha256( LE( predecessor_tx_amount ) )
sha256( LE( 0000000000001f40 ) )
3e1f6dbf626619317d04b24ac25799871709e0f3e35cc0e05dae4da21bc5a162

6
sha_scriptpubkeys
sha256( predecessor_scriptpubkey_length || predecessor_scriptpubkey )
sha256( 22512055355ca83c973f1d97ce0e3843c85d78905af16b4dc531bc488e57212d230116 )
1e43f82396d787c36855662b53aa84af812f10cb9bdca5f2328b12ffea3f833c

7
sha_sequences
sha256( LE( predecessor_tx_sequences )
sha256( LE( fffffffd ) )
23e9829bfb4e23fbd3c4848baa035af15d73bcb83e510f7f097f90a21a4280d2

8
sha_outputs
sha256( LE( new_tx_amount ) || new_tx_scriptpubkey_length || new_tx_scriptpubkey
sha256( e8030000000000001600140bc6dda83a5c6346d31808f685c7cbf1ae20a23e )
fd984a928339e11d1dcda5174c34ddfc8bcc976edceb919d0f52f127d0cd0bf7

9
spend_type
0x00
not applicable
00

10
input_index
LE( 0x00000000)
not applicable
00000000

message digest = hashTapSighash( 0x00 || SigMsg( 0x00, 0 ) ) = sha256( sha256( "TapSighash" ) || sha256( "TagSighash" ) || sighash_epoch || message_parts_above ) = sha256( sha256( 0x54617053696768617368 ) || sha256( 0x54617053696768617368 ) || 0x00 || 0x0002000000000000001da888957df6ce1ac5462fc1b08fe98f2f211026b4b91b71dbd8470239495faf3e1f6dbf626619317d04b24ac25799871709e0f3e35cc0e05dae4da21bc5a1621e43f82396d787c36855662b53aa84af812f10cb9bdca5f2328b12ffea3f833c23e9829bfb4e23fbd3c4848baa035af15d73bcb83e510f7f097f90a21a4280d2fd984a928339e11d1dcda5174c34ddfc8bcc976edceb919d0f52f127d0cd0bf70000000000 ) = 0x1b9589328e6c5d8b71288ee5f93a78d655b724ffa0f5ebf23f88983dda8c5676

Reference.py used to compute the signature:
reference.schnorr_sign(b'\x1b\x95\x892\x8el]\x8bq(\x8e\xe5\xf9:x\xd6U\xb7$\xff\xa0\xf5\xeb\xf2?\x88\x98=\xda\x8cVv', b'\xdf\xf1\xc8\xc2\xc0\x16\xa5r\x91KLZ\xdb\x87\x91\xd6+Gh\xae\x9d\na\xbe\x8a\xb9L\xf5\x03\x8d}\x90', b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')

Signature=0x082779351eb8509993140dbcb9c6d1d4928c6cf397569c49891334ba6d6c9c0bbe6312d4f7af558f3d83398c4dfdf6caabb1b6bcd7cba216141450e240746299
Verification:
testmempoolaccept '["020000000001015f1ab0cd64d050721e4bcd63ffee5c1b4f6224b5fa8f7343062d1f0e32ab87eb0000000000fdffffff01e8030000000000001600140bc6dda83a5c6346d31808f685c7cbf1ae20a23e0140082779351eb8509993140dbcb9c6d1d4928c6cf397569c49891334ba6d6c9c0bbe6312d4f7af558f3d83398c4dfdf6caabb1b6bcd7cba216141450e24074629900000000"]'

[
  {
    "txid": "466474502a15ca2258cf5cadcfec6743c499720843cd51c2c646ad501befffe2",
    "wtxid": "9fbcd4eb32f2811786d46ff5272347891badba07b7b7d1d02d64d71430a2778f",
    "allowed": true,
    "vsize": 99,
    "fees": {
      "base": 0.00007000,
      "effective-feerate": 0.00070707,
      "effective-includes": [
        "9fbcd4eb32f2811786d46ff5272347891badba07b7b7d1d02d64d71430a2778f"
      ]
    }
  }
]
deriveaddresses "rawtr(cV628xvqToz45dwdPmTcJ9RgEVnWMwP8dpZBGzb9LfTk3sBHFNwc)#5u2k7u2l"
[
  "tb1p2564e2pujul3m97wpcuy8jza0zg94uttfhznr0zg3etjztfrqytq7n93n2"
]


text:
SHA256 * 2 on header - what am I doing wrong?
I've been experimenting with the php code here: https://en.bitcoin.it/wiki/Block_hashing_algorithm  (after correcting the small bug of $x=; to $x=""; )
With these blocks 0 and 125552 (for example) it works fine and I get the expected hash.
With blocks 225552 and 300000, I get:
7a7bb195e8bcc8e73205df7906eb68f26144c6fbc577d59dd4e8a0cfdb8b90df (rather than 00000000000001f4f14b09019b23d71c222a2c1245ef3df52875d79ff4488709)
and
178d6fe6cbf696311e7f46263067eeb688797e4c790060c1f6edf6daec76c59e (rather than 000000000000000082ccf8f1557c5d40b21edabb18d2d691cfbf87118bac7254)
...respectively - which doesn't match the hash of either block.
What am I missing or doing incorrectly?
Additional note - I confirmed these results using "openssl dgst -sha256 -binary test-input.bin |openssl dgst -sha256"...
Further to this, using the python code from the same page:
>>> import hashlib
>>> header_hex = ("01000000" +
...     "81cd02ab7e569e8bcd9317e2fe99f2de44d49ab2b8851ba4a308000000000000" +
...     "e320b6c2fffc8d750423db8b1eb942ae710e951ed797f7affc8892b0f1fc122b" +
...     "c7f5d74d" +
...     "f2b9441a" +
...      "42a14695")
>>> header_bin = header_hex.decode('hex')
>>> hash = hashlib.sha256(hashlib.sha256(header_bin).digest()).digest()
>>> hash.encode('hex_codec')
'1dbd981fe6985776b644b173a4d0385ddc1aa2a829688d1e0000000000000000'
>>> hash[::-1].encode('hex_codec')
'00000000000000001e8d6829a8a21adc5d38d0a473b144b6765798e61f98bd1d'

...works fine... but:
>>> import hashlib
>>> header_hex = ("01000000" +
...     "7ef055e1674d2e6551dba41cd214debbee34aeb544c7ec670000000000000000" +
...     "d3998963f80c5bab43fe8c26228e98d030edf4dcbe48a666f5c39e2d7a885c91" +
...     "02c86d53" +
...     "6c890019" +
...     "593a470d")
>>> header_bin = header_hex.decode('hex')
>>> hash = hashlib.sha256(hashlib.sha256(header_bin).digest()).digest()
>>> hash.encode('hex_codec')
'9ec576ecdaf6edf6c16000794c7e7988b6ee673026467f1e3196f6cbe66f8d17'
>>> hash[::-1].encode('hex_codec')
'178d6fe6cbf696311e7f46263067eeb688797e4c790060c1f6edf6daec76c59e'

...gets the same erroneous result as the php code.

You have the wrong block version number.  Block 300000 is a version 2 block, whereas 125552 was version 1.  So the first word in the block header should be "02000000" not "01000000".

Thank you so much - I think I'll update the bitcoin wiki page to reflect that... I spun my wheels for quite some time before posting my question - so I really do appreciate the answer.

This is the header for block #300000
02 00 00 00 7E F0 55 E1 │ 67 4D 2E 65 51 DB A4 1C
D2 14 DE BB EE 34 AE B5 │ 44 C7 EC 67 00 00 00 00
00 00 00 00 D3 99 89 63 │ F8 0C 5B AB 43 FE 8C 26
22 8E 98 D0 30 ED F4 DC │ BE 48 A6 66 F5 C3 9E 2D
7A 88 5C 91 02 C8 6D 53 │ 6C 89 00 19 59 3A 47 0D

Version number is 2 (the very first digit), but you have hardcoded it to 1

header_hex = ("01000000" +

Thank you - the info is not present in the wiki page.  Much appreciated.


text:
Looking for a tiny go/golang snippet to connect to bitcoin core json rpc
I've done it previously in C++ and I'm currently learning go/golang
I'd rather do it "from scratch" rather than trust a third party's library
Just a call from golang for a json-rpc call to getrpcinfo would be enough to get me moving!
My search so far has only led to entire libraries and applications

Ah... got there myself taking things from multiple sources!
Here's the code snippet:
package main

import (
    "fmt"
    "io/ioutil"
    "net/http"
    "strings"
)

func main() {
    testRequest := `{"jsonrpc": "1.0", "id":"", "method": "getrpcinfo", "params": []}`

    req, _ := http.NewRequest("POST", "http://127.0.0.1:8332/", strings.NewReader(testRequest))
    req.SetBasicAuth("", "notmypassword")
    req.Header.Add("content-type", "text/plain;")

    res, e := http.DefaultClient.Do(req)
    if e != nil {
        fmt.Println(e)
    } else {
        defer res.Body.Close()
        body, _ := ioutil.ReadAll(res.Body)
        fmt.Println(string(body))
    }
}

At lest you could accept your own answer :)


text:
Trying CashApp to add funds and purchase Bitcoin immediately but not working, Have done all banking requirements, IS THERE ALTERNATIVE
Details: I was successful in entering in my bank information on Cash App however, keeps saying transfer failed even in the process of adding cash into the app from my bank, so I can use that to buy bitcoin immediately, And of cash app will not let me buy bitcoin using my debit card and there is always a routing number always showing that I did not enter(I assume that is Cash App routing for my new[just started it 6-12-2020]cash app account? The app doesn't say which place it is pulling from except for the 1st time..
**I am wondering what the common causes are..could 1 be you must be connected to wi-fi, if so why since I do other transactions this way without connecting to wi-fi
**If CashApp is just too much trouble, WHAT IS ANOTHER APP TO INSTANTLY UPLOAD YOUR BANK INFO AND BUY BITCOIN not a 7-10 day thing__?...Does CoinBase now do immediate purchase?

Buy bitcoin through Simplex using the Abra app. You could also make an arrangement with a Bitcoin seller on LocalBitcoin.com.
If you can connect with a miner directly you can get around these fees, verification, and BS waiting periods when purchasing Bitcoin. Reaching out on online mining communities could go a long way.

I value and appreciate your conciseness, unfortunately I am not aware of a whole lot yet so I understand and get your general gist, yet to apply(wisely use)may take some other correlating or simple key leanings especially regarding connecting with miners, yet I have thought that because it is the way to produce a value so it has a value along with the system of bitcoin itself. I will start digging into Simplex using Abra app uses & ease and progress from there. Thank you very much, & am always available & glad to exchange info. Sincerely, Mark


text:
If the bitcoin address changes every time, why there is more than one transaction for an address in the ledger?
I was checking a random address in blockchain.com, there are alot of transactions that is done over this address. While in the website it is mentioned that the address is changing everytime! So it means that every address should hold at most one transaction!

There is no such thing as a Bitcoin address.

You need to differentiate between the website's wallet (Blockchain.info-wallet) and the blockchain itself.
You are allowed (by the bitcoin protocol) to make as many transactions per adress as you want.
But wallets try to make it as comfortable as possible for you and use one adress only one time so that you are acting as pseudonymously as possible.
You have probably seen an adress that has not been handled within such a "only one time"-wallet.

Even if no reuse took place, you'd still see 2 transactions (one that creates an output assigned to that address, and one that spends that output).

I didn't get your point about the differences between wallet and blockchain!? A transaction inside a blockchain is from a bitcoin address (wallet) to another one. isn't it? So my question is if after a transaction, the address is changing, then I should not have more than a transaction with one address while it is not like this in the ledger.

No, an adress is not a wallet. A transaction is from one or more adress(es) to one or more adress(es). A wallet is only a nice tool to handle/store all your adresses and private keys and it tells you your balance... You don't even need such a wallet to send or receive bitcoins. It's your choice / the choice of your wallet provider to use an adress only one time or multiple times.

The blockchain.info-wallet maybe allows you to use an adress only one time because they think, it's more secure. But the decentralized blockchain accepts any number of transactions from one adress.

@Rahas: "in the website it is mentioned that the address is changing everytime" Indeed blockchain.info is just one website; it is not "the blockchain" nor does it have any official status with respect to Bitcoin. So while it may be blockchain.info's practice with respect to its users' wallets to issue a new address for each transaction, it is not the practice of every wallet to do that. Some wallets issue a new address only when the user requests a new address. Regardless, anyone is free to give any one receiving address to multiple senders.

@Alpha Thanks for the explanation. I got it. :)


text:
How can I look at the genesis block raw txn?
If I try to look at the txn in the genesis block, I get:
root@0eef0ed7601c:/home/bitcoin# bitcoin-cli getrawtransaction 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
error code: -5
error message:
The genesis block coinbase is not considered an ordinary transaction and cannot be retrieved

Is another way to get it to display?

The genesis block is a special case. Among other quirks, its coinbase transaction doesn't actually create any spendable outputs, which is why the getrawtransaction RPC treats it as if it doesn't exist.
You can still display the transaction as part of the genesis block using getblock:
$ bitcoin-cli getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f 2
{
  "hash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
  "confirmations": 799215,
  "height": 0,
  "version": 1,
  "versionHex": "00000001",
  "merkleroot": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
  "time": 1231006505,
  "mediantime": 1231006505,
  "nonce": 2083236893,
  "bits": "1d00ffff",
  "difficulty": 1,
  "chainwork": "0000000000000000000000000000000000000000000000000000000100010001",
  "nTx": 1,
  "nextblockhash": "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048",
  "strippedsize": 285,
  "size": 285,
  "weight": 1140,
  "tx": [
    {
      "txid": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
      "hash": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
      "version": 1,
      "size": 204,
      "vsize": 204,
      "weight": 816,
      "locktime": 0,
      "vin": [
        {
          "coinbase": "04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73",
          "sequence": 4294967295
        }
      ],
      "vout": [
        {
          "value": 50.00000000,
          "n": 0,
          "scriptPubKey": {
            "asm": "04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f OP_CHECKSIG",
            "desc": "pk(04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f)#vlz6ztea",
            "hex": "4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac",
            "type": "pubkey"
          }
        }
      ],
      "hex": "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000"
    }
  ]
}

ok.. I was hoping to see it as its raw hex representation.  Is there any way to do that?

The hex field of the transaction is its hexadecimal representation.


text:
Node doesn't find segwit transactions
I had to move around wallets and so on, and when I re-installed Knots (yeah I'm that edgy), it doesn't find the transactions to my segwit addresses. I can probably find the SW addresses somewhere, but probably not the regular ones I used addwitnessaddress with. Is this solvable?

If you are restoring a backup from before you had done addwitnessaddress to your addresses, then it will not know to look for the segwit scripts that correspond to your wallet. You will need to do addwitnessaddress again for all of your addresses and then rescan the blockchain in order for your wallet to find those transactions.

Is there a way to find the address that you used addwitnessaddress on, if you know the segwit address?

Currently, no, because the segwit addresses are actually P2SH addresses and it is impossible to know the redeemScript of a P2SH address given just the address. The redeemScript would allow you to know the non-segwit address that it corresponds to.


text:
How do I set up bitcoin.conf in Bitcoin Knots to stop spam and low value transactions?
Having run Bitcoin Core with Luke's patch and with permitbaremultisig=0 and datacarrier=0 in bitcoin.conf for a couple of weeks I finally decided to make a switch to Bitcoin Knots.
The following options seem to be relevant to the matter of limiting spam (inscriptions not applicable to finance, BRC-20, ordinals and the like).

# Relay and mine non-OP_RETURN datacarrier injection (default: 0)
#acceptnonstddatacarrier=1

# Relay and mine "non-standard" transactions (default: 0)
#acceptnonstdtxn=1

# Equivalent bytes per sigop in transactions for relay and mining
# (default: 20)
#bytespersigop=1

# Minimum bytes per sigop in transactions we relay and mine (default: 20)
#bytespersigopstrict=1

# Relay and mine data carrier transactions (default: 1)
#datacarrier=1

# Treat extra data in transactions as at least N vbytes per actual byte
# (default: 1)
#datacarriercost=1

# Maximum size of data in data carrier transactions we relay and mine
# (default: 42)
#datacarriersize=1

# Maximum size of scripts we relay and mine (default: 1650)
#maxscriptsize=1

# Relay non-P2SH multisig (default: 0)
#permitbaremultisig=1

# Relay legacy pubkey outputs (default: 0)
#permitbarepubkey=1

How might I set up the above parameters in order to stop or limit spam?
I noticed that datacarrier is set to 1 by default. Why is that so? Is it because of other, more effective settings such as acceptnonstdtxn and acceptnonstddatacarrier  being set to 0 by default?
If I want to lower the maximum size of data in datacarrier transaction to less than 42 bytes, lets say to 35 bytes, should I apply datacarriersize=35? What are the pros and cons of lowering this parameter below the current default of 42 bytes?

Bitcoin Knots aims to default to reasonable node policies. The reason datacarrier is enabled by default, is that it's impractical to prevent 32-byte spam from abusing p2*h outputs which is much more harmful. So to that end, turning a blind eye to small spam isn't terrible.
The reason it was originally 42 bytes is because there was a possibility back in 2014 that it could be useful for committing to external data, and that data might need a tag of some sort. Since that time, there have been developments to make such usage unnecessary (eg, paytocontract and Taproot). But there hasn't been much rationale to change it either.
Reducing the size to 35 should be perfectly fine.
P.S. Since you specifically mention low-value transactions, you may be interested in testing out the new dustdynamic option: https://github.com/bitcoinknots/bitcoin/issues/74

Thank you for your answer. I am definitely interested in testing the new dustdynamic option. I've set it to dustdynamic=target:1008 while doubling the default dustrelayfee to 0.00006.


text:
Estimate hashrate from block info
Hi for POW is it possible to estimate hashrate for that block
using only available info from getblock rpc ( difficulty , timestamp, etc ) ?
Is there a correlation between difficulty and block found time ( this block - last block time )

is the calculation applicable for other POW such as ETH pre merge / ETC ?

You'd have to ask in a an ETH forum or Q&A website - people who answer questions in bitcoin.stackexchange.com mostly specialise in Bitcoin so other cryptocurrencies are treated as off-topic.


text:
How to deal with bitcoin/crypto volatility as an online casino?
Let's say an online casino has btc as a deposit and withdrawal method.
Assuming A player deposits 1 btc, plays and does neither win nor lose much and then cashes out the balance, which happens to be exactly 1 btc. I am using simple values to focus on the main issue.
However, the btc price was 15% volatile since the deposit was made.
Technically, the player has neither won nor lost based on game play, but he would get a free 15% in value just due to the btc price increase.
The opposite applies if btc loses 15% of value.
Of course it is a nice thing for the casino if the btc price plummets, but potentially disastrous if the price goes up, assuming an average 4% house edge for the casino.
What would be a fair solution for both parties?
Edit: The main game play would be slots, but the same problem arises for Black Jack, Roulette and sports book events. Poker could be affected to a degree as well.
There is no crypto to fiat conversion. An option would be to convert the bitcoin to a Casino token, but fiat is off the table .

If the player wins, isn't the BTC coming from a losing player, rather than the casino itself?

@Rodrigo de Azevedo . Not really, imagine every player is a bitcoin depositor, the house takes 4% on average, but the btc price goes up by 15%. The casino would be in a severe deficit for that period. And the initial btc wallet has to have some funds to cover a potential big winners payout. It could or could not be coming from other players losses, you never know. Even an online casino can get unlucky and have negative revenue for a month sometimes.

At the roulette table, you are exposing yourself to risk, for you're "the house". If your casino only had games in which players play against each other and you're never "the house" but rather a venue that "rents" tables, then your problem would disappear. If that is not attainable, then why not convert the initial BTC deposit into a dollar amount and gamble in dollars? The players would bear the "FX" risk, not you. If that is not attainable either, why not use BTC futures?

The conversion to fiat is legally delicate. The conversion to a tether like token would be possible, though. Thanks for the hint for a rent like service, but that is not part of the core business(I have updated the question).

I assume you'd need a licence to operate such a casino, for it would be trivial to use it to launder BTC. In other words, it could be used as a mixer.

Do players gamble in USD or in BTC?
If players gamble in BTC then it is not your problem to deal with. You just deal in BTC and take a cut of the BTC. If the player who wins BTC ends up losing USD, that's not your problem - just like if a player goes to a European casino and wins EUR but then loses money after converting to USD, it's not the casino's problem.
If players gamble in USD and use BTC only as a transfer mechanism, then you should have some sort of financial mechanism to hedge against price changes. For example, you could sell the BTC as soon as you get it, and buy more BTC when players withdraw.
I am not a lawyer and this is not legal advice.

good point , I have added an edit: There is no crypto to fiat conversion. An option would be to convert the bitcoin to a Casino token, but fiat is off the table. Looks like cashing in on a bitcoin price drop would be morally justified. The hedging after deposits could be laid out in the terms and conditions saying the casino will consider the price at the moment of the deposit for the next withdrawal.

However, the initial hot wallet needs to have a substantive amount, paid for by the casino. Even if all the funds in the wallet came from depositors. Let us draft an extreme example. At the time of the deposits bitcoin averages 10k in GBP per btc. All the players use minimum turn over and are not going all in(all or nothing). They leave their balance pending and then request a withdrawal once 1 btc is valued 20k per btc. The Casino would be providing a better service to the players than any crypto exchange out there. This risk needs to be mitigated imo.


text:
I need help figuring out what happened with my BFGminer overnight
I'm a newbie to crypto and was experimenting with usb erupters because I was getting into ETH mining with my rig and wanted to test it on something less risky. I ran ck pool for my USB erupter just to see and monitor its temps over a course of time. I ended up getting a message from the pool stating: accepted 000593e0 (usb erupter name) Diff 11.7/10k. I have no idea what this means but my efficiency rose to 12.66 and my accepted shares are at 1. Back of my mind I'm wondering if I lucked out and mining a block but I check my coinbase wallet and I see no BTC. So, im wondering what this means.


text:
Script for Success of HTLC in the Lightning Network
BOLT #3 specifies that an HTLC success transaction (the second-stage transaction that spends an HTLC by providing the preimage) has the witness script 0 <remotehtlcsig> <localhtlcsig>  <payment_preimage>.
This question and the respective answers assume that the input script of the HTLC success transaction is <remotehtlcsig> <payment_preimage>. The answers explain in detail how the scripts are executed.
As implementations seem to implement the script according to the specification, I wonder how the script is actually executed. How does the script execution work if there is the additional localhtlcsig? Is the localhtlcsig dropped from the stack at some point during the execution?

At the present time the Script for a "received HTLC output", that is for an HTLC that is paying us materialized as an output in our own commitment transaction, is (comments mine):
# Is it the hash of the revocation public key that we are presented?
OP_DUP OP_HASH160 <RIPEMD160(SHA256(revocationpubkey))> OP_EQUAL
OP_IF
    # If so, anyone that can provide a signature for it can spend this coin.
    OP_CHECKSIG
OP_ELSE
    # Otherwise, are we presented a 32-bytes long bytestring?
    <remote_htlcpubkey> OP_SWAP OP_SIZE 32 OP_EQUAL
    OP_IF
        # If so, we assume this is the payment hash preimage.
        # It must hash through ripemd160(sha256()) to the ripemd160() of the payment hash (because the payment hash is itself the sha256() of the payment preimage).
        OP_HASH160 <RIPEMD160(payment_hash)> OP_EQUALVERIFY
        # Now the payment preimage is valid verify we've got a signature from both the local and the remote node to spend this coin.
        2 OP_SWAP <local_htlcpubkey> 2 OP_CHECKMULTISIG
    OP_ELSE
        # Otherwise, we assume this is the timeout path.
        # We must not be able to spend through this path before `cltv_expiry` blocks.
        OP_DROP <cltv_expiry> OP_CHECKLOCKTIMEVERIFY OP_DROP
        # A signature against the remote HTLC pubkey is enough to spend after the timelock.
        OP_CHECKSIG
    OP_ENDIF
OP_ENDIF

(I omitted option_anchor_outputs for simplicity and since it doesn't matter for this question.)
If this output ends up onchain and we know the sha256() preimage of payment_hash, we can spend it using the corresponding HTLC-success transaction. We also cannot spend it another way, to make sure the revocation delay is enforced (see this and this answers for more about 2-stage HTLCs).
Here is the detailed script execution when spending using the HTLC-success transaction:

Initial stack: 0 <remotehtlcsig> <localhtlcsig>  <payment_preimage>
Executing OP_DUP. Resulting stack: 0 <remotehtlcsig> <localhtlcsig>  <payment_preimage> <payment_preimage>.
Executing OP_HASH160 <RIPEMD160(SHA256(revocationpubkey))> OP_EQUAL. Resulting stack: 0 <remotehtlcsig> <localhtlcsig> <payment_preimage> 0.
Executing OP_HASH160 <RIPEMD160(SHA256(revocationpubkey))> OP_EQUAL. Resulting stack: 0 <remotehtlcsig> <localhtlcsig> <payment_preimage> 0.
Executing OP_IF, we "jump" in the ELSE branch of the conditional. Resulting stack: 0 <remotehtlcsig> <localhtlcsig> <payment_preimage>.
Executing <remote_htlcpubkey> OP_SWAP. Resulting stack: 0 <remotehtlcsig> <localhtlcsig> <remote_htlcpubkey> <payment_preimage>.
Executing OP_SIZE 32 OP_EQUAL. Resulting stack (since payment_preimage is 32 bytes long): 0 <remotehtlcsig> <localhtlcsig> <remote_htlcpubkey> <payment_preimage> 1.
Executing OP_IF, we "jump" in the first branch of the conditional. Resulting stack: 0 <remotehtlcsig> <localhtlcsig> <remote_htlcpubkey> <payment_preimage>.
Executing OP_HASH160 <RIPEMD160(payment_hash)> OP_EQUALVERIFY. Resulting stack: 0 <remotehtlcsig> <localhtlcsig> <remote_htlcpubkey>.
Executing 2 OP_SWAP <local_htlcpubkey> 2. Resulting stack: 0 <remotehtlcsig> <localhtlcsig> 2 <remote_htlcpubkey> <local_htlcpubkey> 2.
Executing OP_CHECKMULTISIG. Resulting stack: 1. (Do keep in mind the CHECKMULTISIG bug that makes it consume one-too-many elements on the stack.)

Thank you! I see. I had overlooked the fact that the second-stage HTLC success transactions are for "received HTLC outputs" while the second-stage HTLC timeout transactions are for "offered HTLC outputs".

You're welcome. I've added comments to the Script as well to (hopefully!) give more clarity about what it's doing.


text:
What is the historical number of sigops?
What is the most convenient way to calculate the total number of signature operations in Bitcoin history?


text:
BIP68 does not apply on regtest
On regtest, I can use generateblock to successfully a mine transaction i.e containing an input with nSequence (0x05000000), although the input has not reached the specified age (5 confirmations). Though I get non-BIP68-final (code -26) error when I use sendrawtransaction. Wondering why this is the case.
Here's how I do it:
For easy demonstration I fund OP_TRUE (decodescript 51). It gives me p2wsh address: bcrt1qft5p2uhsdcdc3l2ua4ap5qqfg4pjaqlp250x7us7a8qqhrxrxfsqseac85.
Then I fund this address 1000 sats: TXID: a21c3ccc203f0c30c613e4409b011e5753ca10bb93fe5036849ab87e14e4cb6c, VOUT: 1.
Then I mine this funding transaction:
generateblock 2N1AwW2Jv4NcsgBWwggDPN7PLx4MpgRNjhs '["a21c3ccc203f0c30c613e4409b011e5753ca10bb93fe5036849ab87e14e4cb6c"]'

Then I manually construct a raw tx spending this input with witness 0x51, with nSequence 0x02000000:
020000000001016ccbe4147eb89a843650fe93bb10ca53571e019b40e413c6300c3f20cc3c1ca201000000000200000001f4010000000000002251209bb9efbddf9d70afd3ac2cef011747236bdf90832a78b08f57d1139f07aa918501015100000000

sendrawtransaction 020000000001016ccbe4147eb89a843650fe93bb10ca53571e019b40e413c6300c3f20cc3c1ca201000000000200000001f4010000000000002251209bb9efbddf9d70afd3ac2cef011747236bdf90832a78b08f57d1139f07aa918501015100000000 gives me the error: “non-BIP68-final (code -26)”
However,
generateblock 2N1AwW2Jv4NcsgBWwggDPN7PLx4MpgRNjhs '["020000000001016ccbe4147eb89a843650fe93bb10ca53571e019b40e413c6300c3f20cc3c1ca201000000000200000001f4010000000000002251209bb9efbddf9d70afd3ac2cef011747236bdf90832a78b08f57d1139f07aa918501015100000000"]'
successfully mines the block:
{
  "hash": "0f63ae01726730e186a5a8e16c2b4f9673ce135c46d033f8c60ee636319ffa6a"
}

Can you provide the transaction you are attempting to broadcast and the details about the UTXO(s) it spends?

Updated my post.

Transaction validity rules applied to the mempool/unconfirmed transactions are static; they include all known softforks, for example, independent of whether those are (already) active on the chain. This simplifies mempool reasoning around the time softforks activate, as the alternative would mean the mempool needs to be re-evaluated every time rules change.
On regtest it is possible to operate in a state where the BIP68 software isn't active from the very beginning. What does getdeploymentinfo say under "csv"?

I've upgraded to v23.0.0 from v22.0.0. Now I get TestBlockValidity failed: bad-txns-nonfinal (code -25) error. Thank you!

Prior to 23.0, CSV would activate after height 432. In 23.0 and later, all soft forks are set to always be active, although this can be overridden in configuration.


text:
Error compile bitcoin mac OS
I have straggle to compile bitcoin core on mac OS machine. it has an error as the following:
/usr/local/include/QtCore/qglobal.h:667:65: error: expected '>'
         typename = std::enable_if_t<std::is_arithmetic_v<T> && std::is_arithmetic_v<U> &&
                                                                ^
/usr/local/include/QtCore/qglobal.h:667:65: error: expected ',' or '>' in
      template-parameter-list
/usr/local/include/QtCore/qglobal.h:668:66: error: expected unqualified-id
                                     std::is_floating_point_v<T> == std::is_floating_po...
                                                                 ^
/usr/local/include/QtCore/qglobal.h:679:35: error: no type named 'Promoted' in namespace
      'QTypeTraits::detail'
using Promoted = typename detail::Promoted<T, U>::type;
                 ~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/local/include/QtCore/qglobal.h:679:43: error: expected ';' after alias declaration
using Promoted = typename detail::Promoted<T, U>::type;
                                          ^
                                          ;
/usr/local/include/QtCore/qglobal.h:691:31: error: no template named 'Promoted' in namespace
      'QTypeTraits'
constexpr inline QTypeTraits::Promoted<T, U> qMin(const T &a, const U &b)
                 ~~~~~~~~~~~~~^
/usr/local/include/QtCore/qglobal.h:693:28: error: no template named 'Promoted' in namespace
      'QTypeTraits'
    using P = QTypeTraits::Promoted<T, U>;
              ~~~~~~~~~~~~~^
/usr/local/include/QtCore/qglobal.h:694:5: error: unknown type name 'P'
    P _a = a;
    ^
/usr/local/include/QtCore/qglobal.h:695:5: error: unknown type name 'P'
    P _b = b;
    ^
/usr/local/include/QtCore/qglobal.h:699:31: error: no template named 'Promoted' in namespace
      'QTypeTraits'
constexpr inline QTypeTraits::Promoted<T, U> qMax(const T &a, const U &b)
                 ~~~~~~~~~~~~~^
/usr/local/include/QtCore/qglobal.h:701:28: error: no template named 'Promoted' in namespace
      'QTypeTraits'
    using P = QTypeTraits::Promoted<T, U>;
              ~~~~~~~~~~~~~^
/usr/local/include/QtCore/qglobal.h:702:5: error: unknown type name 'P'
    P _a = a;
    ^
/usr/local/include/QtCore/qglobal.h:703:5: error: unknown type name 'P'
    P _b = b;
    ^
/usr/local/include/QtCore/qglobal.h:707:31: error: no template named 'Promoted' in namespace
      'QTypeTraits'
constexpr inline QTypeTraits::Promoted<T, U> qBound(const T &min, const U &val, const T &max)
                 ~~~~~~~~~~~~~^
/usr/local/include/QtCore/qglobal.h:710:31: error: no template named 'Promoted' in namespace
      'QTypeTraits'
constexpr inline QTypeTraits::Promoted<T, U> qBound(const T &min, const T &val, const U &max)
                 ~~~~~~~~~~~~~^
/usr/local/include/QtCore/qglobal.h:713:31: error: no template named 'Promoted' in namespace
      'QTypeTraits'
constexpr inline QTypeTraits::Promoted<T, U> qBound(const U &min, const T &val, const T &max)

Please advise.
i used command brew install qt5

How did you install Qt? what's its version?

I had the same issue, seems like the problem is that I had both qt5 and qt6 installed, and it used qt6. Try running:
brew uninstall qt
brew install qt5


text:
Bitcoin public key — why do we have a compressed and uncompressed version?
My understanding is that the public key can start with 04 if it's uncompressed, or 02 or 03 if it's compressed.
What's the purpose of this?
It appears that you'd have greater entropy if it's uncompressed.
And if this is indeed the case, why would you want a compressed public key?
Wouldn't it be safer to use the larger one?

My understanding is that the public key can start with 04 if it's uncompressed, or 02(x-coor) or 03(y-coor) if it's compressed.

That's not exactly right. There are two encodings:

Uncompressed encoding: (0x04, X coordinate, Y coordinate)
Compressed encoding:

(0x02, X coordinate) if Y is even
(0x03, X coordinate) if Y is odd

What's the purpose of this?

And if this is indeed the case, why would you want a compressed public key?

If you're asking about intent, you need to be aware that these standards for encoding aren't specific to Bitcoin. They're defined by SEC1, and adopted by many other systems. Presumably their goal for having both is:

Compressed encoding is smaller, and thus desirable when space/bandwidth considerations matter more.
Uncompressed encoding is slightly more efficient to work with, so if space/bandwidth isn't a concern it's faster to choose this.

If Bitcoin was designed today, it would probably only have compressed keys.

Greater entropy as we can have a larger public key if it's uncompressed?

Wouldn't it be safer to use the larger one?

No, there is a one-to-one conversion between compressed and uncompressed keys, in both direction. There is no difference in entropy (both have 256 bits of entropy) and thus equally secure.

There's five encodings if you want to parse all of the ones in the Bitcoin blockchain, though I guess that's not valid to be used today.

You mean the hybrid encoding? Yeah, that exists too. Its reason for existence is a pure mystery to me (it has the disadvantages of both...).

That's the one, I'd forgotten the name, 0x05 and 0x06. I would love to be able to find the any justification for its existence, surely someone somewhere had a use-case, surely.

0x06 and 0x07 actually ;)

Right, right. What do you think 0x05 was? I'm thinking it only encodes y, twice.

There is no 0x05 as far as I know. The idea I think is that the top 7 bits encode the mechanism (0 = infinity, 1 = compressed, 2 = uncompressed, 3 = hybrid), and the bottom bit encodes Y's parity (but only for compressed and hybrid modes where it matters).

Thank you, great explanation! Trying to wrap my head around Bitcoin addresses and this is great stuff. I read today that the private key (a 2^256 bit number) is the number of times the generative points in the elliptic curve function are computed to compute the public key -- the x and y coordinates are used at the last computed point. Is this correct?

Yes, though "times" isn't your normal multiplication here. It's the number of times the elliptic curve group operation is applied to the generator point ("adding" it to itself).


text:
What is an «open Ponzi scheme»?
I recently read that Nassim N. Taleb thinks that Bitcoin is an open Ponzi scheme. An influental and intelligent person like him surely doesn't say something without thinking about it first. Therefore I asked myself what he means with that term.
In my view the key ingredient of a Ponzi scheme is deception - deception of investors about the real source of their revenue. In order to keep this deception from becoming public knowledge, a Ponzi scheme must remain «closed» in that regard. An «open Ponzi scheme» would mean that there is no deception because «the secret» of the revenue is known to everyone. Isn't «openness» exactly the necessary ingredient which would legitimize even a Ponzi scheme by making it possible to investors to «add» fair value to it, which would most possibly be Zero?
Wouldn't any asset be an open Ponzi scheme by Nassim N. Talebs logic?
I mean every investor tries to make money by selling his investment to others for a higher price at some point.
I feel that following his Logic even gold, diamonds, company shares, etc.  are «open Ponzi schemes» - our whole economy would be an «open Ponzi scheme».
If my logic would be right, this term has no meaning and someone just added a total useless term to the vocabulary.
(I don't ask if Bitcoin is a Ponzi-Scheme - I'm interested in the logic behind the idea of «open ponzi sheme»)

I am curios if the concept of an «open Ponzi scheme» is at all possible. Nassim N. Taleb seems to have created this term to use it specifically for Bitcoin. If we agree on his suggestion, without questioning the term at all, we will have to submit to his explanation of the term. I personally believe the concept of an «open Ponzi Scheme» to be a contradiction and therefore his main idea to be invalid.

If I google for "open ponzi" I find (a) a reference to Nassin's characterization of Bitcoin and (b) this SE question. So I'm afraid this is indeed a newly-coined term.

Does he simply mean a "bubble" or a "pump and dump"?   I'm not seeing the difference  between these and Taleb's "open Ponzi scheme".

It's commonplace that when there's an investment or monetary instrument someone doesn't like, they call it a "ponzi scheme".
For example, gold (ie gold bullion) is indeed often called a "ponzi scheme". Diamonds and gems certainly are.
Some folks think that conventional stock market shares in the current historical era .. ie "Apple shares" or "Ford shares" are a "ponzi scheme".
So, people buy APPL at a higher and higher price, there's no intrinsic value at all (they argue), and the one and only way to make money is to sell to the "greater fool."
Note that I do not know, do not care, and don't have an opinion either way on whether or not these things are indeed ponzi schemes.  The point is, it's completely commonplace to label things like gold, or even shares as "ponzi schemes".
You can find endless discussions where certian folks think government money ("fiat money!") is just a ponzi scheme.
(Just the other day someone commented that real estate in a certain city is "just a ponzi scheme"; ie they believe the prices are un-real and the only reason to buy is to sell to a "greater fool" - until someone is left holding the bag.)
So it's completely normal and commonplace to describe something as a "ponzi scheme"
Note that the term is now used very generally (to mean "a scam" or "something with no real value"). It is NOT used CAREFULLY in an exact sense of how "the original ponzi scheme" operated.
(If you object to "the exact meaning of words changing" - whatever, would have to go live on another planet. You can immediately list huge numbers of words in English that have no connection to their "older, precise" meaning.)
Regarding the talking head's appending the trendy word "open".
It's: an attempt to be clever and attract publicity, more TV appearances, and more book sales.
It would be wildly reading too much in to it, to try to tease out the exact "meaning" of adding "open".
Here are a few other clever! phrases in the same vein:

"it's a prime based ponzi!"

"ponzi mining!"

"a ponzi scheme that's listed on major indexes!"

and so on.

An influental and intelligent person like Nassim N. Taleb

Football players make money via: creating television programming which generates tv ad income.
Bakers make money via selling buns.
"Talking heads" like Taleb make money via: catchy soundbites which generate more interviews and book sales.
It's exactly like being a tiktok'er or youtuber and generating views with shlock.

Nicely put - Thank you for this great answer! I got hung up on this term too much...Thanks for putting it in another perspective.

To be blunt, it's a case of your intelligence and learning caught you up on a dumb-ass marketing-speak term!  haha!  :)

It is kinda like Taleb «sold» this term to «the greater fool» (me and possibly others) in order to advertise for himself. More People believe in him and his words and start buying his books - which have no intrinsic value....It's an open, book-based, wordtwisting, non-Ponzi, Ponzi scheme.

Yes, it's a talk ponzi  :)

"It's commonplace that when there's an investment or monetary instrument someone doesn't like, they call it a 'ponzi scheme'."
Everything you write is an excellent answer... until you specifically mention Taleb. At this point in your answer it becomes clear you know nothing of his work.
When Taleb uses the phrase "open Ponzi scheme" he does so accurately and advisedly, not flippantly nor facetiously. It's "open" in the sense that it can be seen by all to have no basis in value—everyone knows it's a pyramid built in the clouds.
One can argue that shares in Apple are overvalued, that the prices for gold or tulips are too high.  One cannot argue iPhones are imaginary, that Dutch tulips do not exist. There's real stuff you can reach out and touch.
This is not the case with Bitcoin. Ethereum has SmartContracts and Distributed Applications, the Weimar Republic had wheelbarrows of money burnable for heat, but what real thing of some actual value does Bitcoin offer? At best, one could argue Bitcoin is a ledger of past energy consumption, but that's about it.
I can see Bitcoin hitting $100k late 2021, early 2022 before the masses start to realize the truth of Bitcoin: There's no "there" there.

Hello OEMichael, on stackexchange, the order of posts shifts with votes so that the best answer can bubble to the top. Our platform does not work like on a forum where you respond to the prior post. Foremost, each answer must independently address the question. You may also comment on points other answers made, but should only do so in the context of providing your own answer. If you wish to provide improvement suggestions or follow-up questions to another answerer, you should comment on their post.


text:
Single-leaf script-path example
I'm searching for Taproot script-path examples and so far found a two-leaf example here. Is there any single-leaf construction on testnet or somewhere?
I'm wondering if TapBranch calculation is skipped for single-leaf constructions. Is single-leaf TapLeaf directly commits to TapTweak, or TapBranch is applied in-between?

With a single leaf, there is no TapBranch step. That would be impossible, as there are no two branches to combine. The TapLeaf hash is directly used in the TapTweak step.
I will try to add a few examples to the BIP soon.

Thanks! Looking forward to more examples.

Update: Used TapLeaf directly in the TapTweak step and this time managed to spend a single-leaf P2TR output (using btcdeb).
https://blockstream.info/testnet/tx/d5f3924fa35c913e03f6c16061c860c5209d6c7190c75c13b6e5ac8f4326b96d


text:
What happens if nSequence is set to 0x00000000?
I know setting nSequence 0x00000001 means the transaction is not valid until 1 block has elapsed since its's prevout confirms. At most one spend per two blocks.
What happens if it's set to 0x00000000? I think it means that the transaction is valid and can be relayed as soon as it's prevout is confirmed. At most one spend per block.
..Or does it mean prevout can be zero-conf? Unconfirmed transaction chain limit applies.

From the relevant section in BIP 68:

When the relative lock-time is block-based, it is interpreted as a minimum block-height constraint over the input's age. A relative block-based lock-time of zero indicates an input which can be included in any block. More generally, a relative block lock-time n can be included n blocks after the mining date of the output it is spending, or any block thereafter.

So an nSequence value of 0 means the transaction can be included in the same block as the transaction whose output it is spending.
In the Bitcoin Core software, transactions can be relayed under the condition that they can be included in the next block. For nSequence=0 transactions that implies they can be relayed before their parents are confirmed.

In the Bitcoin Core software, transactions can be relayed under the condition that they can be included in the next block.
Does it mean an input whose nSequence is 0x00000001, but prevout is zero-conf, can be relayed because age will be “1” the moment it's included in the next block?

I would think not, because the prevout transactions needs to confirm firm, and then only the block after that its nSequence=1 spend can confirm, but I'd need to go check the code to be sure.