text:
Calculate hash of block header
I'm trying to calculate the hash of block #502871. This is the block:
{
"result": {
    "hash": "00000000000000000020cf2bdc6563fb25c424af588d5fb7223461e72715e4a9",
    "confirmations": 35,
    "strippedsize": 976261,
    "size": 1064277,
    "weight": 3993060,
    "height": 502871,
    "version": 536870912,
    "versionHex": "20000000",
    "merkleroot": "871148c57dad60c0cde483233b099daa3e6492a91c13b337a5413a4c4f842978",
    "tx": [
        "6fef5a38c0a76d4bfb6644afed809fe760abcbe9c1e030b7b09bd876f8d28765",
        "2506559cd75c9537108c63adddf6910eaa2c12e9e129b75528dd5dbff8e6cef3",
        ...
        "b136d220a049fd9a42261153c7d5e21e12b791c27eed9cb9e41acaea672a6af5",
        "7dbaf4d2b31d4a000b9f2028dd350e46da427b8c1721f030af67d5e47f322da5"
    ],
    "time": 1515252561,
    "mediantime": 1515249802,
    "nonce": 45291998,
    "bits": "180091c1",
    "difficulty": 1931136454487.716,
    "chainwork": "000000000000000000000000000000000000000000e0ef1d9aa7eeab21ce8628",
    "previousblockhash": "00000000000000000061abcd4f51d81ddba5498cff67fed44b287de0990b7266",
    "nextblockhash": "00000000000000000075e23616edab2b743425a064c282a7745ad38d05806e80"
},
"error": null,
"id": null

}
So according to https://en.bitcoin.it/wiki/Block_hashing_algorithm I need these values:
 versionHex: 20000000
 previousblockhash:
 00000000000000000061abcd4f51d81ddba5498cff67fed44b287de0990b7266
 merkleroot: 871148c57dad60c0cde483233b099daa3e6492a91c13b337a5413a4c4f842978
 time: 1515252561
 bits: 180091c1
 nonce: 45291998

Formatting the values I get:
version: 02000000
previousblockhash: 66720b99e07d284bd4fe67ff8c49a5db1dd8514fcdab61000000000000000000
merkleroot: 7829844f4c3a41a537b3131ca992643eaa9d093b2383e4cdc060ad7dc5481187
time: (5A50EB51)_16 -> 51eb505a
bits: c1910018
nonce: (02B319DE)_16 -> de19b302

So my block header is:
0200000066720b99e07d284bd4fe67ff8c49a5db1dd8514fcdab610000000000000000007829844f4c3a41a537b3131ca992643eaa9d093b2383e4cdc060ad7dc548118751eb505ac1910018de19b302
And when I calculate the hash:
from hashlib import sha256
import hashlib
header = "0200000066720b99e07d284bd4fe67ff8c49a5db1dd8514fcdab610000000000000000007829844f4c3a41a537b3131ca992643eaa9d093b2383e4cdc060ad7dc548118751eb505ac1910018de19b302".decode('hex')
print sha256(sha256(header).digest()).digest()[::-1].encode('hex')

The result is
0a80d313f7c8bab35b1442a194516c3ddff9ddc674c752ccfaffb1c83866a073

But not the the expected one:
00000000000000000020cf2bdc6563fb25c424af588d5fb7223461e72715e4a9

Please, what am I doing wrong? Thanks.

Please remove the answer from the question. :-)

The version is wrong:
I have 02000000
But the one that appears on the block is
Version 0x20000000

Doing the formatting:
00000020

Calculating the hash of the block:
from hashlib import sha256
import hashlib
header = "0000002066720b99e07d284bd4fe67ff8c49a5db1dd8514fcdab610000000000000000007829844f4c3a41a537b3131ca992643eaa9d093b2383e4cdc060ad7dc548118751eb505ac1910018de19b302".decode('hex')
print sha256(sha256(header).digest()).digest()[::-1].encode('hex')

And the answer is:
00000000000000000020cf2bdc6563fb25c424af588d5fb7223461e72715e4a9

That is the original hash in the block:
00000000000000000020cf2bdc6563fb25c424af588d5fb7223461e72715e4a9


text:
Help with bitocin.conf - how to configure a testnet full node in a safe way?
The general purpose here is just to have a close interaction with the bitcoin network for exploring reasons and apply some knowledge I have gained through reading here and there.
I am not expert! So, I am afraid to mess up and enable something in the bitcoin.conf, I am not fully aware of it consequences. Especially that my personal laptop (running Ubuntu) is the only resources I have right now for a full-node setup.
My initial goals are to:
 - run a testnet full node to experiment with the avaliable limited resources
   (4 RAM, 50 gigs free storage and metered internet connection)
 - secure my fullnode in the network (I setup the ufw firewall and created a
   new separate account no idea though if I must do more in terms of the
   account permissions. It is a standard one)
The only examples, I found are:
1) a very general file in github: https://github.com/bitcoin/bitcoin/blob/master/contrib/debian/examples/bitcoin.conf
2) This one I found in the bitcore.io documentation: https://bitcore.io/guides/wallet-service
I tried to edit it a little bit to serve my goal, I hope you can have a look into and I am more than happy to hear your recommendations. Maybe, I have to put it in another format, since it is meant to be a conf file for the bitcore implementation. I embedded some comments and questions in the file
Here it is:
{
      "network": "testnet",
      "port": 18333,
      "https": true,
# must I create my keys myself? Is it the pathway important here?
  "httpsOptions": {
     "key": "some-place-safe/key.nopass.pem",
     "cert": "some-place-safe/cert.pem"   },
  "servicesConfig": {
     "bitcore-wallet-service": {
 # is it ok to use this port?
       "bwsPort": 3232
     },
     "bitcoind": {
       "datadir": "/home/user/.bitcore/data"
       "exec": "/home/user/bitcoin/src/bitcoind"
     }
 },
      "services": [
         "bitcoind",
         "bitcore-wallet-service",
        "insight-api",
        "web"   ]
}

Probably, other stuff must be added, at the moment I am still lost and trying to navigate through the first conf file
Thanks a lot in advance!

Because you say that you have limited storage, you should enable prune={number >= 551 in MB} in your config.

You should use the one provided in the Bitcoin Core repository which you have linked above. That one has everything disabled by default (so only defaults are used and it will run fine out of the box and use the mainnet). All of the options that you are going to ever use are listed in that conf file with instructions on what they do and how to use them. They're all commented out.

Maybe, I have to put it in another format, since it is meant to be a conf file for the bitcore implementation

You will need to do that because that format of conf file (JSON format) is not supported by Bitcoin Core.
The questions you asked regarding the bitcore conf are completely irrelevant to Bitcoin Core as it does not support those options.

Alternatively you can use this Bitcoin Core configuration file generator which lets you choose the options you want to enable and it will generate the file for you.

This was my problem that I was lost how to use the bitcoin.conf of the reference bitcoin client: what is the minimum I need to uncomment, so I get securely running bitcoin full node of the testnet. However, I apologize for everyone bothered reading my post, since I threw many questions and it might end up unclear what I wanted. So, I only enabled the following settings and hopefully they are enough for a healthy and secure full node:
testnet=1 ,
rpcuser= *** ,
rpcpassword= ,
server = 1 # since I might try out other implementations as bitcore,
listen=0
thanks again!

source: Stack Exchange

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

sort: votes


text:
Bitcoin unconfirmed transactions - what is the best solution to fast it up?
I have couple of unconfirmed transactions that i want fast up.
How i do it quickly and easily ?
What do you do ?
the fees going insane (over $12 for the smallest transactions)
i want to send with low fees and acclerate it . which sites do you recommend ?
Edit: I tried this Free service and it works!

The simplest thing you can try is to rebroadcast the transaction and see if you get lucky. Here is one of the sites that offers this service http://www.speedupmybitcointransaction.com/
Failing that you can ask a mining pool for some help. For example ViaBTC offer a service described here https://www.cryptocompare.com/coins/guides/how-to-accelerate-your-bitcoin-transaction/
And failing that you can create a Child Pays For Parent (CPFP) transaction to increase the fee paid https://bitzuma.com/posts/how-to-clear-a-stuck-bitcoin-transaction/

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


text:
Will blockchain.info change my BTC adress each time after i SEND my BTC?
I would like to know a way to send BTC from 1 wallet but different adress each time. (because of transaction fees i dont want to use few different wallets for this)
Blockchain.info changes your BTC adress after you recieve transaction. Will it do the same after you send a transaction?

It is recommended that a new bitcoin address is used for every transaction, this is best for your privacy. So each time you receive a transaction, you should use a new address. Each time you send a transaction, your wallet should generate a brand new change address for you.
I think you are confusing the terms ‘address’ and ‘wallet’. An address is the string of random-looking characters that you can send bitcoin to, it will usually look something like this: 19STQThjmUqf2veMCWNb7JhErguiCBdy3r.
A wallet is a collection of addresses, controlled by some software that allows to to send/receive transactions.
I’m general, each time you publish a transaction you will need to include a transaction fee if you want it confirmed in the blockchain. I recommend doing some research into how transaction fees work and are calculated so you can learn how to transact most efficiently.

Thank you. Will blockchain.info wallet change "adress" from which i'm sending bitcoin every time i send it?
For example:
If i send 0.1 Bitcoin from my blockchain.info wallet, it will be send from AAA adress
.If after that i send another 0.1 Bitcoin from the same wallet, will it be sent from BBB adress? Or it will be sent from the same AAA adress?

If blockchain.info follows best practices, it will send from address ‘bbb’. As a user this shouldn’t be a worry, the wallet software will automatically manage this for you.

To go a little deeper: when ‘address aaa’ is spent, ALL of the balance is spent. This is how bitcoin works, you cannot only spend half of an address’ balance. If an address contains more btc than you’d like to spend, then a ‘change address’ is created for you in your wallet, and the excess is sent there (so you still control it, but it is in a new address). It is possible to use a pre-existing address as the change address (eg spend from address aaa, send change to address aaa), but as I mentioned this is bad for user privacy).


text:
Not sure if I accidentally double spent my LTC LITECOIN
LEDGER NANO S - CHROME APP LTC LITECOIN
I just sent two transactions (with different amounts) from one address to the same receiver one after another.
While sending the second the first was still unconfirmed.
The first went through.
The second shows [unconfirmed] and the transaction id [3e454f1dc4a08fdb64ea9e047baf504891934ea8d84ee42732d5d2eebb18e138] does not exist on the LTC blockchain.
Both the amounts of the first and of the second transaction have been substracted from my Wallet Balance.
I've tried following things:

I already reset the chrome app [SETTINGS - TOOLS - RESET APLLICATION DATA]
Clicked on [Synch] severalt times
Waited an hour

I need the following things to happen

[Mandatory] My Balance needs to be restored to the amount before the double spend TX
[Optional] The unconfirmed double-spend-transaction to disappear from the transaction list

Need your advice, thanks in advance
P.S.: This question is also posted on the official Ledger Nanon Forum
https://support.ledgerwallet.com/hc/en-us/community/posts/360000120894-Please-Help-Not-sure-if-I-accidentally-double-spent-my-LTC-LITECOIN

The underlying problem is that somehow Ledger did not broadcast my transaction to the mempool. Don't know exactly why it wasnt relayed.
Solved in the following way:

Close the LTC Chrome app
Download the LTC-Version of Electrum Wallet. This wallet interfaces with the Ledger directly, like the chrome apps. No need to import the seed.
If Electrum gives a read error make sure you enable and disable broswer support once.
Make sure you started the correct app in Ledger. In my case it was LTC.
In Electrum go under the tab "Addresses" and copy one of your receiving addresses with 0 balance
Send YOUR ENTIRE BALANCE at once to your own copied address. For good luck make sure the fees are sufficient.
Wait until it confirms.
Thats it! When you start the chrome app again the new transaction will have replaced the unbroadcasted old one and the balance returns to the correct amount.

It should work in principle with every currency.
Got it from this reddit: https://www.reddit.com/r/ledgerwallet/comments/7rkicz/bch_transactions_sent_unconfirmed_but_dont_show/


text:
Turnkey Bitcoin test clone for demonstration purpose
So I'd like to demonstrate a blockchain based digital currency within my firm. For various reasons, I can't just use bitcoin (or of course I would).
I also can't distribute pc exes, hence the requirement for a web based wallet. Security does not need to be paramount. There does not need to be a competition for mining although mining does need to be a component (ie there will probably be just one miner running on one cpu / low priority).
Is there an open source web wallet and counterpart configurable mining system ? I took a quick look at coinpunk but I'm not sure that is still supported / running (last update almost a year ago, website offline?).
All suggestions gratefully received.

Well, I can tell you that what you are looking for probably does not exist. I did the same search recently.
I was in talks with a large company and all they wanted to hear was the Blockchain and how they could use it. They asked to have their own Blockchain -i.e. altcoin. You are probably in a similar situation.
The best course of action here -in my opinion- is to try to convince them that a Blockchain that they will create is just a more expensive and much more complex version of a Database. And the altcoin will be nothing more than records on that expensive, complex and possibly insecure database.
In my case I was able to convince them -somewhat- but the response was:

We still can't use Bitcoin because of internal politics and PR risks

In the end, I convinced them to use Bitcoin testnet :) I suggest you do the same.
Bitcoin testnet is the closest thing to what you are looking for.
It's not Bitcoin, it doesn't have real value and there are online and mobile wallets built for it. You can also play around with mining on testnet.
Just call it Testnet instead of Bitcoin Testnet and hope that they will get more comfortable with Bitcoin in time.

Although testnet would solve a few problems, it still means that the client needs to install some software somewhere and also although these tokens have no real value, they might be used for demonstrating voting and kickstarter-esque funding. Any dev would easily be able to obtain a fair few testnet coins and then rig the system. It really has to be standalone :-/

there are web wallets for testnet. Your only option is to fork Bitcoin and get your own testnet up and running. Then fork an open source wallet. It will be messy. Sorry :) I don't think you're going to find a turnkey solution.

You can also look into colored coins.

Nowadays the easiest way would probably be to setup a Signet (or use testnet until wider signet adoption) with a mobile wallet that supports test network(s), such as Green wallet.

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


text:
How to trade bitcoin in bitcoin?
I'm curious about how to trade bitcoin in bitcoins. I want to do this because it squares the gains (and losses) from crypto. I'm not intending on doing this with leverage for safety reasons. So, what I mean is like (but don't say this) Bit-MEX (for the most part): the price doubles, and the amount of money in real dollars quadruples. This is like trading on x times leverage where x is the current price divided by the entry price with insignificant to no liquidation risk. I would prefer it to be for Coinbase because that is what is popular.
Example based on past data:
BTC price is $3,150 in Dec 2018...0.05 BTC bought for under $200.
BTC price is $13,400 in Jun 2019...0.21 BTC sold with ~$2,750 in return.
Note: Don't tell me to use Bit-MEX, Bitfinex, etc. because I live in the United States.

Hey Numberphile this post doesn't fit with Bitcoin Stack Overflow. Maybe try your question on a reddit subform such as BitcoinMarkets (strictly as an example) or other discussion forum.

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


text:
How to use bitcoin from the command line in Windows?
Do there exist any stable and audited bitcoin wallets that can be used from the cli on Windows? I have looked but have been unable to find any that I can use for automated tasks.

You can use bitcoind and bitcoin-cli in windows too. See this post for more information.


text:
block verification cost
When a node receives a block, is it enough to validate root of Merkel tree ?
How does block size affect the validation cost?
 What is the difference between the cost of validation 1mg-size block  and 2mg-size block? Its variations are linear or constant or quadratic?
Tnx.

It is not enough to check the merkle tree, as this says absolutely nothing about the validity of the contents of the block, just that somebody was able to follow the protocol up until that point. If a transaction say, created money out of nowhere, this would not be caught by simply looking at the existence of a transaction in a block.
To correctly validate a block a node must do the following low-cost checks:

format of the header is correct
rules about timestamps and difficulty are followed
the proof of work matches what is required

Assuming these rules pass, they must do the following high-cost checks:

the merkle tree is correct and matches the root in the header
no outputs are spent which do not exist (or have already been spent)
the values in every transaction input and output don't create money
that every script execution is successful and does not end in an error
that every ECDSA signature is valid
that misc rules such as size, format of script, and total block size are not exceeded

Most of these are CPU intensive, such as doing potentially hundreds of thousands of ECDSA, SHA256, and RIPME160 operations. Some are IO intensive, such as validating previous transaction entries if these are not already in the cache. None of these operations are exponential in cost with the number of transactions, but they need to be completed quickly to maintain consensus on the network.
Much of this work can be done ahead of time, an unconfirmed transaction can have many checks against it done, so when it arrives confirmed inside a block the validation is cached. However we can't assume this is always the case, as the Bitcoin network needs to be able to operate in adversarial conditions, such as a miner creating a block with a large number of otherwise unseen transactions.
We also need to consider that every block needs to be validated by nodes which are newly joining the network, and the cumulative cost should not be excessive to process. The historical chain at this point takes many hours or even days to validate on low-cost hardware, and we of course shouldn't be changing behavior in such a way that this cost grows more quickly.
That said, the Bitcoin network frequently has blocks above 1MB today, often exceeding 2.2MB.

So we can say the cost of validating or generating a block increase linearly as the number of transactions inside it increases?

Approximately yes. With some transaction types there is a vulnerability which allows for exponential increases in the validation time with size, however.


text:
A cheap LNB for Blockstream satellite?
Has anyone here built their own setup for connecting with the Blockstream satellite network?
I'm still looking for a cheap low-noise block downconverter.

PLL LNB (linear polarization) w/ < = 200kHz LO stability

The ones I can find range from $100 -> $200..
Seems like 200kHz is not required, broader ranges are acceptable.
"L.O. Accuracy & Stability Within +/-1.5MHz" seems to do the trick and they are considerably cheaper (~15$).

I heard that Blockstream is going to sell a 100$ one.

Grubles has written up a guide for how to set up a blockstream satellite node: https://medium.com/@notgrubles/building-your-own-bitcoin-satellite-node-6061d3c93e7. That should be helpful; it includes links to amazon where you can buy all of the materials required.

The LNB that he uses has a LO stability range, I quote "L.O. Accuracy & Stability Within +/-1.5MHz ". I'm glad it works with a broader range.


text:
Does a Node connect to all the peers?
Does a Node connect to all the peers in the network? Or just a few?
If its just a few, how many?
If its just a few, what about if all of those nodes in the list are malicious?

A node is only called a peer if you're connected to it. So by definition you are always connected to all your peers.
I assume you're asking whether you're connected to every node in the network. The answer is no; most Bitcoin node software implementations only connected to around 8 others.
What happens if one is malicious? Bitcoin is trust-minimized by design. This means that it verifies to the extent possible whether incoming data is correct. Where this isn't possible, it uses a objective and unforgeable metric (proof of work) to select the winner in case there are multiple acceptable possibilities (blocks).
For most types of attacks, the assumption is that at least one of your peers is honest. If that's the case, you'll eventually learn the best valid version of history the rest of the network learns too. If all your peers are malicious, they may prevent you from seeing actual history - though it is very hard even in this case to forge and invalid version of history and convince your node of that.

Why if we have just one honest node I’ll learn the best valid version? One honest node out of 8 means the 12.5% of your nodes, meaning, if we validate the truth by using percentage, 87.5% (malicious nodes) Vs 12.5% (the only honest one)? We would take the malicious nodes as if they were valid.

It doesn't matter how many peers say what. As long as you learn from one peer about the real chain, you will switch to it, because it will be unambiguously a better chain than what other nodes told you.

How would you know what chain is valid since it’s the first time you’re getting it? By checking the PofW?

A chain is valid if it satisfies all the rules (no invalid signatures, no double spends, no printing money, ...). When there are multiple valid chains, you accept the one with most proof of work.

The default number is 8 peers, but you can change it on the configurations. If a peer starts acting maliciously, the node will block it and find another one.

How would the node know that X peer is acting maliciously ? Since 1) The node might be getting the information for the first time. 2) The node could become malicious since its peers are malicious too.

Your node has the genesis block on its source code, from there it can verify any block its peers send to it.


text:
Blockchain: How do nodes know what Data is correct from Consensus process?
How do nodes know what data is correct from consensus?
What about if two nodes execute two different consensus with 2 different Valid blocks with the same height at the same time, can that happen?
I’m talking about Blockchain in general, not bitcoin, not mining.
Not bitcoin related, Not mining related

What do you mean by "execute two different consensus"? In my understanding, "consensus" means "agreement between a majority of nodes concerning data-state" it isn't something that is executed.

That is right. Although, at a code level, it’s an algorithm, a function, it needs to be executed, meaning, two nodes can call the function at the same time, thus proposing a consensus process.

Is your question largely about the subject covered in https://medium.com/@chrshmmmr/consensus-in-blockchain-systems-in-short-691fc7d1fefe

Consensus
My understanding of this word, in the context of cryptocurrencies, is as follows:
In a finite network of nodes with independent data-storage, consensus exists if all, or at least a majority of, nodes hold a set of data that is identical to, or at least not inconsistent with, the data sets held by other nodes.
That is, consensus is a state, independent of the rules or mechanisms used to achieve it.

How do nodes know what data is correct from consensus?

They don't necessarily. Consensus is sometimes really an emergent behavior, albeit a planned one. In some systems, nodes don't explicitly seek consensus - that is they don't confer about consensus as a subject - only about what blocks other nodes know of and have already validated.
In these types of system consensus emerges simply because nodes follow the same rules, for example that the chain with the most proof-of-work (or equivalent) is accepted and any alternatives are discarded.

What about if two nodes execute two different consensus with 2 different Valid blocks with the same height at the same time, can that happen?

That can and does happen for a short while in at least some systems. For example, eventually one of those blocks will have more blocks built on top of it than the other. This block will be then accepted in place of the other by the node(s) that had previously accepted the other. The other block and all blocks built on it will then be discarded. Or there may be other ways in which rules resolve the Byzantine Generals problem.
In this specific example system, transactions in those discarded blocks are also then lost unless they have already been included in the rival block or in blocks built on the rival block. If not they may still exist in memory pools and be later incorporated into the blockchain. This is probably one reason why a significant number of confirmations are needed in this specific system.

Other sources:

Consensus in Blockchain Systems. In Short — Chris Hammerschmidt  — 2017

I think there’s a misunderstanding, I’m talking about Blockchain in general, not bitcoin, I’m talking about a system that doesn’t have proof of work. A system which doesn’t have mining involved. I’m talking about the blockchain technology itself and its problems with Byzantine fault, and how a blockchain software that processes about 10,000 blocks per minute can validate them if many of them have the same height. I did not mention that. since I didn’t want to get too technical, Just blockchain and consensus in general.

@Juan, OK but I don't understand the distinction you are making. I was trying to answer in general based on what I believe are fundamental characteristics of blockchain that ought to be general to any implementation- but my knowledge is exclusively from Bitcoin. To avoid other people making the same mistake you might want to review your question and work out if there is a rewording that might make misunderstandings less likely.


text:
What options do I have to avoid API gap limit? I am using xpub keys
I am building a app, and the design is, the "welcome page" has a qr code allowing the user to purchase a single-use of the app.
Blockchain.info conveniently allows you to use xpub to generate addresses, however, their docs mention bip 44, and the "gap limit"...  This is instantly a problem as I can imagine, say 30 users simultaneously going to the app (more realistically, 30 users going to the app under the amount of time it takes a single user to purchase), 20 will be presented bitcoin addresses to purchase, 10 will not due to the api throwing gap limit errors.
What options do I have to get around this?
I've had others suggest I just manually generate a bunch of private keys and not use xpub, but manually having to consolidate all of those single-transactions-per-address just sounds like an absolute nightmare that I would like to avoid.
UPATE
Is there any way at all to re-use the same address every time, but attach a guid to it so that when I see the txn broadcasted, I can link it with a given user's session?  This is really all that I need.  I don't need xpub.. I just need a way to identify that user A and user B both are viewing the welcome page, user A doesn't pay, user B does, user B is automatically given access, user A is not.

Possible duplicate of How to solve Blockchain 20 address gap-limit problem?

@pebwindkraft unfortunately that post doesn't offer any sort of solution or suggestion.

Use https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#Public_parent_key_rarr_public_child_key ? Do you need an implementation?

Here's my solution.
When gap limit is reached, append a random and unique satoshi amount to the total bitcoin amount and associate it with the user.
For example, if your product price is BTC 0.001, then generate an amount like 0.00100001 for user A, 0.00100002 for user B, both using the same address when gap is reached.
Now for user A, you use Blockchain.info's Receive API. In the database, you record user A, price and address.
Now in the case of user B, you use the Balance Update API. In the databae, you also record user B, price and address.
So when you receive the notification, you can check which user made the payment by checking the amount paid.

This is not a solution. It can make disaster. you should not give an address to two users at the same time and wait if one of them sending the amount. How about a time that two of them sent the amount?! That's not small collateral. That's very big flaw of this method.

First user send money and you return *ok* for your callback. 2nd user send money and the wallet don't do callback because you returned *ok* for that address before. so does not monitor anymore. it means you can not even know the second user paid!

Another better solution to this, you can use the "Balance Update" notification.

Waiting for more callbacks after one paid is bad. Maybe you get the first confirmation callback for 2nd user in the 48 hours. Balance Update is not a solution for gap limit. It seems HD wallets are not for merchant. They have big flaw for online stores and they can not handle big or even small online stores.

Small or big collateral doesn't matter. both of them are equal to a faulty system.

Issues related to gap limit as summarized in this blog post. Basically you have few options

Use wallets like electrum to increase gap limit setting
Automatically send small amount of funds to 20th unsued address to keep things going. This is done by services like blockonomics
Keep generating new address without worrying about gap limit. Later you can generate all private keys using xprv and sweep in the funds from all private keys.

can give me more information about the 3rd option?


text:
understanding bits and difficulty in a block header
This block:
https://blockchain.info/block/00000000000000000025c089d0a7b2bf6241888c4dd90ab7a4c4baa6a2823551
Shows difficulty at 3,007,383,866,429.73, and bits at 392009692.
If I want to see how many zeros need to be in the hash, I believe I can just do:
(log2(3007383866429.73) + 32) / 4) => 18.362911541451258

Which is correct..  But how does bits come from difficulty?  How can I calculate the number of zeros from the bits instead of the difficulty?

Contrary to popular belief, Bitcoin's proof of work is not actually based on the number of zeroes. Rather the block hash, when interpreted as a 256 bit integer, must be less than the target value. The target value is what actually determines the difficulty. The target value is represented in a compact form in the nBits field of the block header.
The nBits field of the block header compresses the target from 256 bits into a 32 bits. A description of the format can be found here.
Basically, the nBits field, when represented in Big endian, is split into two parts: the first byte, and the last three bytes. The formula for decompressing the nBits field is as follows: (last three bytes) * 256 ^ ((first byte) - 3). This gives you a 256 bit integer that has the first 3 most significant bytes of the target.

I see..  I am working on a project that depicts bitcoin mining at a high level, and so I want my example data to look as accurate as possible.   I am looking for some kind of formula where I can say: given difficulty X, the hash that would solve this should start with Y zeros..  And actually my project has a small amount of screen real estate available, so I'd prefer if I could literally use an extremely low difficulty like "25" for example, and have that (as realistically as possible) equate to a hash with a small-ish number of leading 0s.

I've created some javascript code as a result of my research in trying to understand how target difficulty works. It seems a good idea to share after finding this post.
First it creates the range of SHA256 powers of 2 thresholds for you to visualize the shear magnitude of these numbers.
Then the bitsToHex function is used to decompress "bits".
Then decompressed "bits" are casted as a BigInt in order to get the integer used for hashing comparison.
Code comments should clarify the rest.
console.log("\nSHA256 in powers of 2\n");

// from easy to hard
for(let i = 256n; i >= 0n; i-=4n) {
  // calc decimal representaion
  const dec = BigInt(2n**i-1n);
  // calc hexadecimal representation
  const hex = BigInt(2n**i-1n).toString(16).padStart(64, "0");

  // beautify console
  console.log(`2n**${i}-1n D`.padStart(12, " "), dec.toLocaleString("en-US").padStart(103, "."));
  console.log(`2n**${i}-1n H`.padStart(12, " "), `0x${hex}`.padEnd(116, " "));
}

/**
 * @dev Takes a Bitcoin block header property "bits" and converts it into a 256-bit hex.
 *
 * The bits property of a Bitcoin block header is a 32-bit integer that
 * represents the difficulty target for mining that block.
 * The first three bytes of the bits value are the exponent (in base 256) of
 * the difficulty target, and the last byte is the coefficient.
 * To convert the bits value into a 256-bit hex, we need to extract the
 * exponent and coefficient from the bits value and calculate the target value.
 * Then we can convert the target value into a 64-character hex string.
 *
 */
function bitsToHex(bits) {
  // calc target value from compressed "bits".
  const target = (bits & 0x007fffff) * 2 ** (8 * ((bits >>> 24) - 3));
  // convert to 256bit hex
  return target.toString(16).padStart(64, "0");
}

// console spacer
console.log("\nBitcoin Target Difficulty\n");

// Satoshi's genesis block "bits" A.K.A target hash
// for details see https://bitcoinexplorer.org/block-height/1#JSON
// "bits": "1d00ffff",
const genesisTargetDifficultyHEX = bitsToHex(0x1d00ffff);
const genesisTargetDifficultyDEC = BigInt(`0x${genesisTargetDifficultyHEX}`);
console.log('genesis block target difficulty HEX:', genesisTargetDifficultyHEX);
console.log('genesis block target difficulty DEC:', genesisTargetDifficultyDEC);

// Bitcoins's current block "bits" A.K.A target hash
// for details see https://bitcoinexplorer.org/block-height/776774#JSON
// "bits": "17073039",
const currentTargetDifficultyHEX = bitsToHex(0x17073039);
const currentTargetDifficultyDEC = BigInt(`0x${currentTargetDifficultyHEX}`);
console.log('current block target difficulty HEX:', currentTargetDifficultyHEX);
console.log('current block target difficulty DEC:', currentTargetDifficultyDEC);

...console output:
genesis block target difficulty HEX: 00000000ffff0000000000000000000000000000000000000000000000000000
genesis block target difficulty DEC: 26959535291011309493156476344723991336010898738574164086137773096960n
current block target difficulty HEX: 0000000000000000000730390000000000000000000000000000000000000000
current block target difficulty DEC: 688509036841676372057001313638142781710850853198364672n

As you can see, difficulty has gotten a lot harder since genesis block.


text:
How to prevent fake mining in mining bitcoin?
After searching about how bitcoin miners mining bitcoin work I started to thinking bitcoin miners can cheat in mining bitcoin like they said they has solved the hash and verify it while they don't really solved the hash and verify it so how can it be prevent and anyone please explaining to me? Please?

can you be a bit more specific? Do you mean, a miner can send a solution to the nonce calculation, that isn't the solution? Maybe outline a bit ...

A miner can't simply claim they solved the hash, because the result of the mining becomes part of the next block and everybody else on the network checks to see whether the calculation was done correctly.
If a miner tries to "fake" a block, the trickery would be immediately detected by every peer the miner sends it to, and the block would go nowhere.

What I mean is in verify

The network verifies/validates all blocks that are mined. If a block is not valid, a node will simply ignore and discard it. The verification is a cryptographic math function that cannot be faked. In extremely over-simplified terms, it’s like if a miner made a block that claimed ‘2+2=5’. Everyone else in the network would easily be able to figure out that the math doesn’t check out, and know the block is invalid.

If a block is not completely valid, it is completely ignored. Effectively, it is considered to be just some random junk.


text:
What is the source of initial transactions of bitcoin?
Sorry, if I am wrong or silly!
It is understood that:
a) Satoshi Nakamoto sent the first transaction to developer Hal Finney on January 12, 2009, the genesis block contains 1,073 transactions and he got 50BTC as block reward, which is non spendable by design.
b) Coins are mined during block publishing.
c) A coinbase transaction must be 100 blocks deep before you can spend its outputs
d) Coins don't merge
e) For each transaction, sender should have group of input coins, whose sum should be greater than equal to sum of transaction amount and transaction fee.
What is the total amount of all those transactions and how they got BTCs for the initial transactions?

New Bitcoin are only created when a new block is mined. The new coins are collected as "subsidy" reward from the successful miner. The miner reward can be found in the coinbase transaction, which is always the first transaction in a block. The coinbase is constructed similarly to other transactions, but doesn't reference any previous output. But since its outputs have non-zero amounts, coins are created with the coinbase. Search for other coinbase-related questions, there are several related ones.

Re: ”the genesis block contain 1,073 transactions”, this is false. The genesis block only includes an (unspendable) coinbase transaction. The payout address for that coinbase transaction has been sent many transactions since then, but they would have been included in subsequent blocks.

Statement :  "The genesis block has received 1,073 transactions..." Reference: https://news.bitcoin.com/bitcoins-quirky-genesis-block-turns-eight-years-old-today/

@AVA that statement is technically incorrect; it should read "the bitcoin address from the genesis block coinbase transaction has been the recipient of 1,073 transactions to date..". Saying "a block received a transaction" makes no sense. A block contains transactions, it does not receive them. The genesis block had just one single transaction in it. See: https://blockstream.info/block/000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f

The genesis block is block 0:
block 0
-the reward went to the address 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa.
The first regular transaction (from Nakamoto to Finney) is in block #170
txhash=f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16
-sent from
12cbQLTFMXRnSzktFkuoG3eHoMeFtpTu3S to 1Q2TWHE3GMdB6BZKafqwxXtWAWgFt5Jvm3 with the change being deposited back to the sending address. These coins were over 100 confirms.
The 1073 transactions you are talking about was probably correct at the time of writing, but they are talking about the number of transactions sending coins to the address in the genesis block over the life of bitcoin.
-There have been 1,508 transactions (as of right now) which sent coins to the address in the genesis block, so now that address holds 66.91839465 BTC, 50 of which were from the genesis transaction. That means there have been 16.91839465 BTC sent to it. (1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa)

Small correction: the block reward of the Genesis block was sent to a pay-to-pubkey output which doesn't have an address format and is misleadingly represented on some block explorers by the p2pkh address that could be derived from that pubkey. This p2pkh address is what got paid by the transactions you mention. The output of the Genesis block is unspendable as it did not get added to the UTXO set of the original client and the Genesis block is hard coded as the start of the blockchain and therefore does not get evaluated like other blocks by full nodes

What is the total amount of all those transactions

You can see Bitcoin's genesis block here:
https://en.bitcoin.it/wiki/Genesis_block
You can easily examine early blocks by using the block height in any blockchain explorer. For example here

how they got BTCs for the initial transactions?

Mined blocks can be empty (contain no transactions other than the "coinbase" mining reward). I guess this can be the case when the mempool is empty or when all the pending transactions therein have unattractive fees.


text:
What happens to the transactions included in the forks?
Let:
a) the vector triplet <x,y,z> refer <height, index, parent_index>
b) blocks, block100, block110 (of height 1) are mined together and they both refer previous block block00[null] (of height 0).
Block, block110 (of height 1) gets a child block and its branch grows but
block block100 doesn't get any child block till then and became leaf/fork.
Please advise what happens to the ith transaction t100i of block, block100 that is not included in the branching block, block110.

On nodes that had accepted block100: when they disconnect it to reorg they will remember the transactions in it and attempt to reinsert into the mempool any that fell out once they finish the reorg. If they're still valid, they'll be added and queued for mining in a future block.
On nodes that initially accepted block110: the transactions that were still valid after accepting the block will remain in the mempool queued for mining in a future block.
Transactions which were invalidated by other transactions included in block110 are forgotten by nodes.

I assume you mean t100i is confirmed in block100, and not in block110.
t100i remains in the branch which has block100 as it's tip. However, since the branch which includes block110 has a tip with more accumulated POW, it is the one that represents the current valid ordering of transactions (strong chain).
For the node following/validating the strong chain, t100i may or may not be an valid transaction:

If t100i is not mined in block block110, and there was no other confirmed transaction in the strong chain which spent the UTXO's of t100i, t100i is still a valid transaction, and can
be accepted to the mempool.
If another confirmed transaction in the strong chain spends the same UTXO's as t100i first, t100i becomes invalid, as it double-spends the same previous outputs.


text:
Can "Digital Signature of the Block by the Miner" be used in place of "Nonce"?
As it is understood that arriving nonce is very resource intensive, whether "Digital Signature of the Block by the Miner" can be considered in place of "Nonce"? Its Shortcomings, if not suitable.

You seem to be confused about what the nonce actually achieves. The nonce allows miners to "rehash" the same block multiple times, eventually finding a sufficiently "difficult" block that they can publish and be rewarded for. The nonce is either picked randomly or incremented. This is much faster than a digital signature.

This only raises the question of which miners' signatures are considered acceptable.  If anyone can be a miner and provide a signature, then there is no security and no way to objectively determine which of many conflicting blocks is authoritative.  If there is a fixed list of authorized public keys, then the currency is no longer decentralized.

It took your answer for me to understand what the question was. Could you perhaps edit the question?


text:
Generate paper wallet SegWit address
I am trying to generate SegWit paper wallet address from WIF:
My WIF is L5mHKZsCLS27nSoGM3RdAwuxjvg7XhJdP25LgqdXe6zF11wpWdbT.
I am converting WIF to compressed public key:
Compressed public key: 03fac6879502c4c939cfaadc45999c7ed7366203ad523ab83ad5502c71621a85bb
I am creating P2SH-P2WPKH address using instructions at Creation of P2SH-P2WPKH Address
using following algorithm:

Calculate the RIPEMD160 of the SHA256 of a public key:

SHA256 of public key: cfad24b0bc2bba2c8bb2c8d619dca2b74221930793bca50df73856f0bbba10c9
RIPEMD160 of SHA256 hash: d5e5d05edfe2ed61099bf3f0d53be2775bbc6d0d

Create P2SH redeemScript as OP_PUSH publicKeyHash:

redeemScript: 0014d5e5d05edfe2ed61099bf3f0d53be2775bbc6d0d

Generate scriptPubKey as OP_HASH160 hash160(redeemScript) OP_EQUAL

scriptPubKey: a914a19949e546c2f4d410cbb061c986b9ff3099ae7087

Generate RIPEMD160 hash of scriptPubKey:

hash: dc62e525af22d1f0f17cc2a091cf2c9fb36bf553

Generate address with 0x05 prefix and double SHA256 hash checksum:

result: 3MnK46gvixm8hk7mJTQTAqenniSodjXPrJ
Expected result according to segwitaddress is:
33voQqbNAYyig272KjcX8GkucWn2x25WEg
What am I doing wrong?
Update
Thanks to the accepted answer, here are correct steps to do this:
Public key - compressed:
03fac6879502c4c939cfaadc45999c7ed7366203ad523ab83ad5502c71621a85bb

SHA256(public key) =
cfad24b0bc2bba2c8bb2c8d619dca2b74221930793bca50df73856f0bbba10c9

RIPEMD160(SHA256(public key)) =
7646c030f7e75b80f0a31cdcab731e6f424f22b2

redeemScript (OP_0 pubkeyHash160):
00147646c030f7e75b80f0a31cdcab731e6f424f22b2

SHA256(redeemScript) =
a10e523968ba784d24ccd54e613d8f747d6649e42b1df4fdcec6658262620651

RIPEMD160(SHA256(redeemScript)) =
188ba16284702258959d8bb63bb9a5d979b57875

P2SH address base58(0x05 | hash | 4-byte sha256 checksum) =
33voQqbNAYyig272KjcX8GkucWn2x25WEg

Create P2SH redeemScript as OP_PUSH publicKeyHash:

redeemScript: 0014d5e5d05edfe2ed61099bf3f0d53be2775bbc6d0d

It's actually `OP_0  but you have resulted in the right thing anyways.

Generate scriptPubKey as OP_HASH160 hash160(redeemScript) OP_EQUAL

scriptPubKey: a914a19949e546c2f4d410cbb061c986b9ff3099ae7087

Generate RIPEMD160 hash of scriptPubKey:

hash: dc62e525af22d1f0f17cc2a091cf2c9fb36bf553

These steps are incorrect. The thing that is hashed for a P2SH address is the redeemScript, not the scriptPubKey. Instead of doing step 3, you would skip directly to step 4 and hash the redeemScript instead of the scriptPubKey.

Hi Andrew, I was hoping you could help. I think I'm not generating the checksum correctly. Before the base58 encoding, this is the string I have: 05188ba16284702258959d8bb63bb9a5d979b5787555c30444. After base58 that's 33voQqbNAYyig272KjcX8GkucWn2uJk5WT. Last 6 characters are incorrect. Which part am I getting wrong?

@user2298995 Your checksum is wrong. The hex should be 05188BA16284702258959D8BB63BB9A5D979B57875BFE2FCFD

Thank you very much for your comment!  How is the checksum generated then? I took the 4 bytes of sha256(sha256(redeemScript)). Is it not the proper way?

No, it is the first 4 bytes of the sha256(sha256(payload)) where the payload is the data you are encoding with the base58 check encoding. In this case, the payload is 05188BA16284702258959D8BB63BB9A5D979B57875

Oh thank you very much. Very appreciated!


text:
"request coins" address is different to top right qr code
Bitcoin wallet app (android app).
I'm familiar with how an Hierarchical Deterministic wallet generates addresses, but I'm confused by the ever changing address of "receive coins" button in the bottom left.
Literally every time I click I'm given a different address, but the qr code in top right is always the same (and informs me it will update to new address after a transaction), but the bottom left doesn't show the actual address, only qr code, and I like to save the address each time it changes so I know which wallet it's from (so later I can confirm which of my multiple wallets will receive the payment) and also go back and check I've copied it correctly etc etc.
What's going on with "receive coins" option?

For what software?

Bitcoin wallet app (android app). Sorry, tag says it all as I got here from it's help files, but should have made that a bit clearer

On the main screen (not the request coins page), you should see a little Tag symbol up the top in the menu bar. That opens up your address book. Swipe over to the 'Your addresses' tab, and you'll see a list of all the addresses generated by the request coins page. You can give each one a label on this page too so you remember what they are for.
The app generates a new address for each payment for privacy reasons.

So it's just doing it's HD addresses thing? That makes sense, but just needed to be sure. Thank you.

Also, what's "old addresses"? Now that I found the full list of addresses (mycelium totally needs this feature too, or I've just not found it yet)


text:
What will be the price for BCC bitcoin cash on August 1st?
Will there be an "initial price of a chain fork" type of opening when this new BCC comes out? Or the price will be same to the regular BTC that we currently use?

If you rename this question to be about how an initial price of a chain fork is determined, it becomes a much better question.  Without that change, this is borderline off topic speculation.

The initial price of BCC will be what the first buyer is willing to pay for it on an exchange. After that, it's simply a matter of demand and supply.
According to coinmarketcap.com, BCC futures are currently trading for $332. This is probably the best indication of what to expect once the market opens.

I would look at the volume in those futures.


text:
How much hashpower is needed to double-spend? Is >50% a minimum?
How much hashpower is needed to double-spend coins?
Some worry only about one entity getting over 50% of the hashpower, while others are complaining (at the time of writing) about an entity having more than 33%. What is the importance of 50%? Can a double-spend be done with less?

No, 50% is not a minimum to double-spend. From the Bitcoin-Wiki

Brute force attack
This attack has a chance to work even if the merchant waits for some confirmations, but requires relatively high hashrate.
The attacker submits to the merchant/network a transaction which pays the merchant, while privately mining a blockchain fork in which a double-spending transaction is included instead. After waiting for n confirmations, the merchant sends the product. If the attacker happened to find more than n blocks at this point, he releases his fork and regains his coins; otherwise, he can try to continue extending his fork with the hope of being able to catch up with the network. If he never manages to do this, the attack fails and the payment to the merchant will go through.
The probability of success is a function of the attacker's hashrate (as a proportion of the total network hashrate) and the number of confirmations the merchant waits for. For example, if the attacker controls 10% of the network hashrate but the merchant waits for 6 confirmations, the success probability is on the order of 0.1%

When you have more than 50% of the hashrate, the succeed chance is 100%:

>50% attack
If the attacker controls more than half of the network hashrate, the previous attack has a probability of 100% to succeed. Since the attacker can generate blocks faster than the rest of the network, he can simply persevere with his private fork until it becomes longer than the branch built by the honest network, from whatever disadvantage.
No amount of confirmations can prevent this attack; however, waiting for confirmations does increase the aggregate resource cost of performing the attack, which could make it unprofitable or delay it long enough for the circumstances to change or slower-acting synchronization methods to kick in.

The 33% I believe came from reports last year about a 'selfish mining' strategy which claimed originally that 33% of the hashrate can be used to manipulate nodes to secure the remainder necessary for the full 50%,

The high-level overview of the attack is this: rather than acting as a normal miner and publishing blocks to the network immediately upon finding them, the attacker selectively publishes blocks, sometimes sacrificing his own revenue but also often publishing many blocks all at once and thus forcing the rest of the network to discard blocks and lose revenue. This does reduce the attacker’s revenue in the short term, but it reduces everyone else’s revenue even more, so neutral nodes now have the incentive to join the attacker’s coalition to increase their own revenue. Eventually, the attacker’s coalition would expand to above 50% in size, potentially giving the attacker a high degree of control over the network.

From bitcoin magazine
Personally I think greed and profit motive would prevent anyone risking this strategy, over simply mining honestly.
Also I really dont think double spending ought be a concern. Its not affecting the supply rate / total quantity of coins and, if someone attempted to do a double spend, they would be delivering into the hands of the victim of their crime, irrefutable evidence of themselves as the perpetrator (the signed double spending transaction). If merchants simply refrain from selling hugely valuable items to anonymous persons/parties (common sense) there likely will never be a case of fraud using this method.


text:
Oauth - can my application use Stellar Oauth?
Does Stellar have Oauth, or is it on your road-map ?

Why'd you remove the text here?

Oauth isn't presently on our roadmap, but feel free to check back in future.


text:
Bootstrap.dat incorrect or no genesis block found
Hi all i need to add bootstrap.dat after downloading i start bitcoind with -loadblock but not work i have error Incorrect or no genesis block found. Wrong datadir for network?
I start bitcoin with ./bitcoind -loadblock=/root/.bitcoin/bootstrap.dat and connexion of my VPS are very slow what is the good solution ?
Its possible because bootstrap.dat are very big file ? And what is the difference between -reindex and tindex ?
Thanks

I don't remember exactly but i think all you need to do is put the bootstrap file in the data directory of bitcoin and then just start bitcoind.
However note that bootstrap is obsolete as of version 0.10 and downloading is faster and (disk usage lower) without it.
Don't waste too much time trying to get it to work if bandwidth is not costly for you.

Yes not work i tested in all folder but always is corrupted i wait for downloading all you think i need who many days for download all ? i have vps from ovh

Haven't tried a complete new download myself yet. I hear for some people it can be done in a ~8 hours. CPU can be a bottleneck too since all transactions needs to be verified.


text:
P2Pool Hardfork 14.0 where and when is it decided?
I have read on here that hardforks are a point where the pool with the biggest stick gets to decide which course the blockchain will take. Has the hardfork only just begun? When is the fork ultimately decided and has this one already passed the decision of the largest pool? Are most pools based on P2Pool's open source code? Is P2Pool calling for a fork that may not ultimately happen? Or have they worked in code from the other side of a fork into their own code? Do pools gravitate to different standards or always generally find some consensus? This one has the word attack in the fine print. Is this a step to eliminating an exploit? Is there an attack that could exploit the weighting and timing of the share system?
How long does a fork last? How many coins have been lost to forks and is there a tally? Sorry I know, that's a lot of questions.

This has nothing to do with any proposed hard forks of Bitcoin.
The hard fork being referred to is internal to P2Pool, and has already happened.
P2Pool has something called a sharechain is parallel to Bitcoins blockchain, only using a 30 second block time rather than a 600 second block time. It is internally used for tracking mining progress in the pool, and ordering payouts. It has the same features as the Bitcoin one, in that it is completely in consensus between all the P2Pool nodes and has very specific rules for what is acceptable and what is not. Some rule altering is a hard fork, where previously invalid things become valid after the change.
The reason a hard fork needs to happen is that BIP66 enforcement will cause all subsequent version 2 blocks to be invalidated, anybody mining a version 2 block after this point in time will be throwing away money. P2Pool had to be internally hardforked to support version 3 blocks, or risk just burning all of the miners income on rejected blocks. This Bitcoin soft fork will happen very shortly, when the average version of the last 1000 blocks is 2.95, which is why P2Pool had to make such a drastic change in such a short period of time.
P2Pool is unlike all other centralized pools in its operation and management. Other pools simply updated their Bitcoin nodes to the latest version of the software and anyone mining with them accepted the soft fork by proxy.

I have read on here that hardforks are a point where the pool with the biggest stick gets to decide which course the blockchain will take.

This is not correct. A hard fork is controlled by the users of the network, not the miners. The miners must mine blocks which the network views as acceptable, if they don't the nodes in the network will simply reject their (to the rules they have) invalid block and ban the peer that sent it to them.

Has the hardfork only just begun?

There is no accepted proposal for a Bitcoin hard fork.

The miners must mine blocks which the network views as acceptable, if they don't the nodes in the network will simply reject their (to the rules they have) invalid block and ban the peer that sent it to them. Sure, but the miners still have some input in the process.

PS. This is how you upgrade to the new version of P2Pool: https://bitcointalk.org/index.php?topic=18313.msg11723989#msg11723989

Nick: miners have input in the process, because they are part of the ecosystem. But other than for softforks, they do not have any privilege compared to other ecosystem players. Hard forks are about the community as a whole deciding to migrate to an incompatible system.

Will this effect all pool's in essence?

No, just P2Pool.


text:
How to migrate wallet from namecoin to namecore?
Today I updated namecoin by building the new "namecore" reimplementation  but when starting namecoind I got this message:
Error opening block database.

Do you want to rebuild the block database now?

and before I could do anything namecoind crashed.
So I moved away the Namecoin folder and let it regenerate everything, blockchain included.
This time it started without errors, so I copied my wallet.dat into the folder and restarted namecoind but I got an Error: and it crashed again.
The debug.log shows this:
2015-06-29 15:36:51 Using wallet wallet.dat
2015-06-29 15:36:51 init message: Verifying wallet...
2015-06-29 15:36:51 CDBEnv::Open: LogDir=/home/michele/Library/Application Support/Namecoin/database ErrorFile=/
2015-06-29 15:36:51 Renamed wallet.dat to wallet.1435592211.bak
2015-06-29 15:36:51 CDBEnv::Salvage: Database salvage found errors,     all data may not be recoverable.
2015-06-29 15:36:51 Salvage(aggressive) found no records in wallet.1435592211.bak.
2015-06-29 15:36:51 Error:

I figured the wallet format has changed somehow, so using the old client I dumped the private keys and I succefully imported them using importprivkey. I can see the address, the balances and all but name_list shows nothing.
How do I get back my names now?

Meanwhile I've answered this question at reddit.

You have already taken the first 2 out of 3 steps necessary for your wallet migration: (1) cleaned up the data directory that contained old incompatible files, (2) dumped and imported the private keys from the old wallet (alternatively, depending on how old the wallet is, one could try starting the new namecore client with the -upgradewallet parameter).
The internal bookkeeping hasn't had a chance to detect the old transactions that belong to the newly imported private keys, yet. This is the missing third step: (3) Restart namecore (i.e. namecoind) with the -rescan parameter.

In short: Now you need to restart the new client with the -rescan parameter.
EDIT: Generally I recommend using namecore's new -upgradewallet parameter:
namecoind -upgradewallet -rescan -reindex
as the dumpprivkey/importprivkey approach always bears the risk of confusing the relevant name_update transactions and addresses with older ones. If you do not know how to use the (deprecated) name_debug1 command in Namecoin-Qt then you most likely get it wrong.

Thanks. I have already tried that: name_list stays empty.

This is what happens when I use -rescan: hastebin.com/axixerizef

How many private keys did you import? hastebin shows in line 3 a transfer of NMCs to N3zSdWjXJwtnZHYdRXymSzVzgooDMpAvEw, and at line 4 the operation "name_new id/rnhmjoj" related to NH4FJp1fEMFfE2Jh1dpnAMga7YaQwyL954. The private keys for the name_firstupdate and the name_update operations are missing so far. Most important would be the latest name_update which arrived at MxeWiWXr9U9jwG2KHWyBNKg9uHbiiqZjW6. Are you sure you imported the private key for this address?

Quite sure. I have imported every address I had.

Just had a quick conversation with domob, the namecore developer. He recommends also adding the -reindex parameter: namecoind -rescan -reindex
(takes about 1 hour on an i5 with SSD. Much longer when run on a harddisk, I guess. -printtoconsole and -dbcache=400 may help)

This sounds like a bug, @cassini would you mind opening a ticket on Github?

@cassini That took a while to run however everything seems to be unchanged: name_list is still empty.

@Rnhmjoj There are several things that could have gone wrong during your dump/importprivkey attempts, also the old wallet.dat may be partially damaged, or your namecore build had issues during compiling. And as indolering already indicated there could still be a bug in namecore. I think it would be easiest if you send the old wallet file to one of the Namecoin devs. First ask phelix or me for encryption instructions. You could also try domob, biolizard or indolering. Not sure if they have time at the moment.

The wallet is working fine on another machine that is running namecoin 0.3.80. I did the whole thing several times: compiling namecore, dumping and importing the keys. I also updated the wallet to the latest format from 0.3.80. I don't think is damaged.


text:
Creating a custom transactions
I am currently learning how to create raw transactions. I can already create standard using bitcoin core (0.19.1), but when I wanted to create with custom opcode like this:
asm: OP_HASH160 d0c3f50336b5f109207d722c692191ff86263e96 OP_EQUAL OP_DROP 1
hex: a914d0c3f50336b5f109207d722c692191ff86263e96877551

I created raw transaction

createrawtransaction '[{"txid":"1c164f99a7cd0fe6dba9a7fe10ad3c2be132a9260d4ccdeaf7e279073946ac52","vout":0}]' '{"2MxmdfXx8rKGUmWUwQu59GksMNRdnQiRRM2":0.195}'

020000000152ac46390779e2f7eacd4c0d26a932e12b3cad10fea7a9dbe60fcda7994f161c0000000000ffffffff01e08b29010000000017a9143c98df42d7a69c7fd165aeb6128d45f21eeeac4d8700000000

But when I wanted to sign this transaction I occured an error (I also tried to modify raw transaction from first step) here is result with modified raw transaction from above but it still doesn't work

signrawtransactionwithkey '020000000152ac46390779e2f7eacd4c0d26a932e12b3cad10fea7a9dbe60fcda7994f161c0000000000ffffffff0130c11d000000000019a914d0c3f50336b5f109207d722c692191ff86263e9687755100000000' '["$privkey"]' '[{"txid":"1c164f99a7cd0fe6dba9a7fe10ad3c2be132a9260d4ccdeaf7e279073946ac52","vout":0,"scriptPubKey":"a914d0c3f50336b5f109207d722c692191ff86263e96877551","redeemScript":"001453352afbbaa8cad22304201de8fbcc29e83fb2db","amount":0.02}]'

Previous output scriptPubKey mismatch:
OP_HASH160 d0c3f50336b5f109207d722c692191ff86263e96 OP_EQUAL
vs:
OP_HASH160 d0c3f50336b5f109207d722c692191ff86263e96 OP_EQUAL OP_DROP 1 (code -22)

Now I know I'm doing something wrong, but I don't know what and I can't find any information on how to do it correctly. That's why I have questions:

What am I doing wrong?
Can I create custom transactions using the Bitcoin core, if so how?
If I can't use this wallet, how can I do it? I would be grateful for an example

In your script the previous ScriptPubKey is different.
If you want create custom script you need to sign manually the transaction, you can't use signrawtransactionwithkey. Bitcoin core sign only the standard transaction

I know that ScriptPubKey is different, I mention that i modified him with hope that it will change something. How can I manually sign the transaction, can You give me some example?

check this link https://bitcoin.stackexchange.com/questions/93342/sign-transaction-legacy-with-openssl
Then depends on which program you use, I tried with openssl

How can I create .pem private key file from bitcoin private key which I already had like e.g. cSEpx7zcr9hbfah5FdHVHsVWN3CpJevtomgeJJaxgUvd9otzrYKV with openssl ?

that WIF private key, you need decode base58 and remove prefix and compression byte. Check even this link man https://bitcointalk.org/index.php?topic=5226185.0 and https://bitcointalk.org/index.php?topic=5230931.0

I tried to understand what you sent, but it's harder than I thought and well ... I don't understand. Too many unknowns and few explanations, could you explain such signing step by step? I know I am asking you a lot but I really care about it and I would like to understand it.

In the second link you can find step by step from WIF to Pem. Or If you want, you can generate address from scratch by bash or some library. In that way you have all keys. Then Decide what kind of library use to sign transaction manually.

Yes, I did it, but unfortunately it just doesn't work. The number of steps is simply too large to find an error somewhere. I have a problem that I don't know how to sign manually, even using the links you gave here.

Maybe you need to open a new question with more details about signature

Okay, well, I appreciate it for your help anyway. Thank you :)

The problem was that I changed scriptPubKey, which I misinterpreted as scriptOutput of a future transaction. This was an error, scriptPubKey of the last parameter refers to scriptPubKey UTXO.


text:
What does the version number in the blockheader represent
While looking up how a block get mined I stumbled over the version number in the header - which is used to "keep track of changes to the protocol".
But even in the last 5 blocks of the chain (at the state of writing) there were 4 different version numbers - so my questions are:
"What does the version number represent?" followed by "Will a mined block with a random version number get rejected - or could a miner simply use it as an extension of nounce (and thereby effectively double the length of the nounce)

Take a look at the answer provided here, it might help you out.
Unusual Version Number in Blocks

Also check out here A Decomposition Of The Bitcoin Block Header


text:
lnd and Bluewallet LndHub integration error
I am attempting to setup LndHub with a Pi3 via docker-compose.  After bitcoind blockchain sync completed, judging by the logs from lnd (Lightning) and LndHub, it seems like LndHub is having trouble decoding messages from lnd (logs pasted below)?
Anyone faced this sort of issue before?
Or have any suggestions?
I know this is more of a JS/RPC question, but thought ppl here may have more experience with the libraries used by lnd & LndHub.
I guess my next step is probably to add some print statements somewhere in the LndHub code. Will update this post after I do that.
lnd logs:
2021-06-20 23:42:12.591 [INF] CRTR: Processed channels=38 updates=78 nodes=32 in last 59.874156103s
2021-06-20 23:42:13.955 [ERR] RPCS: [/lnrpc.Lightning/SubscribeInvoices]: encoding/hex: invalid byte: U+002F '/'
2021-06-20 23:42:13.956 [ERR] RPCS: [/lnrpc.Lightning/GetInfo]: encoding/hex: invalid byte: U+002F '/'
2021-06-20 23:42:13.958 [ERR] RPCS: [/lnrpc.Lightning/GetInfo]: encoding/hex: invalid byte: U+002F '/'
2021-06-20 23:42:13.961 [ERR] RPCS: [/lnrpc.Lightning/ListChannels]: encoding/hex: invalid byte: U+002F '/'

LndHub logs:
updateLightning()
updated
2021-06-20T22:50:34.595Z : info: [BOOTING UP] : "Listening on port 3000"
Node NOT Exiting...
{ Error: 2 UNKNOWN: encoding/hex: invalid byte: U+002F '/'
    at Object.callErrorFromStatus (/opt/LndHub/build/node_modules/@grpc/grpc-js/build/src/call.js:31:26)
    at Object.onReceiveStatus (/opt/LndHub/build/node_modules/@grpc/grpc-js/build/src/client.js:327:49)
    at Object.onReceiveStatus (/opt/LndHub/build/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:299:181)
    at process.nextTick (/opt/LndHub/build/node_modules/@grpc/grpc-js/build/src/call-stream.js:130:78)
    at process._tickCallback (internal/process/next_tick.js:61:11)
  code: 2,
  details: 'encoding/hex: invalid byte: U+002F \'/\'',
  metadata:
   Metadata { internalRepr: Map { 'content-type' => [Array] }, options: {} } }
lnd failure

Software versions:
Hardware: Raspberry Pi 3
OS: Raspbian Buster 10
Docker Base Image: Ubuntu 18.04
Bitcoin: 0.21.1
Lnd: v0.13.0-beta
LndHub: v1.3.0 (Node: v10.15.3)

Dockerfile and docker-compose files:
https://github.com/pangyuteng/bitcoin-lndhub/blob/main/docker-compose.yml
bictoind: https://github.com/pangyuteng/bitcoin-lndhub/blob/main/bitcoind/Dockerfile
lnd: https://github.com/pangyuteng/bitcoin-lndhub/blob/main/lnd/Dockerfile
LndHub: https://github.com/pangyuteng/bitcoin-lndhub/blob/main/hub/Dockerfile

--- EDIT 2021-09-22 ---
I updated bitcoin-core to v22. now lnd is giving a different error from rpcperms/interceptor.go... and I have to figure out how to get rpc to run for lnd, as below seems to indicate "rpc is not running"...
export LND_DIR=/mnt/hdd/lnd
export MACAROON_HEADER="Grpc-Metadata-macaroon: $(sudo xxd -ps -u -c 1000 $LND_DIR/data/chain/bitcoin/mainnet/admin.macaroon)"
curl -X GET --cacert $LND_DIR/tls.cert --header "$MACAROON_HEADER" https://localhost:8080/v1/balance/blockchain

{"error":"the RPC server is in the process of starting up, but not yet ready to accept calls","code":2,"message":"the RPC server is in the process of starting up, but not yet ready to accept calls","details":[]}

--- EDIT 2021-09-27 ---
Turns out my bitcoind was not syncing due having enough swap and server constantly shuts down / kernel panic.
After syncing and reenabled swap... it is back to the orginal error message but at a different location (node:internal/process/task_queues:78:11) and there seems to be some communication going on between lndhub with bitcoind! :)
bitcoind getblockchaininfo: {
  result: {
    chain: 'main',
    blocks: 702459,
    headers: 702459,
    bestblockhash: '0000000000000000000a45d676fc178cc7603ca7908af2ed1701137a848db5d3',
    difficulty: 18997641161758.95,
    mediantime: 1632764543,
    verificationprogress: 0.9999990028709793,
    initialblockdownload: false,
    chainwork: '0000000000000000000000000000000000000000221092943f73a5bddde80438',
    size_on_disk: 416306659033,
    pruned: false,
    softforks: {
      bip34: [Object],
      bip66: [Object],
      bip65: [Object],
      csv: [Object],
      segwit: [Object],
      taproot: [Object]
    },
    warnings: ''
  },
  error: null,
  id: '883e89b6-7c7e-4cd5-aa8e-a6e54879ae62'
}
lnd failure
Error: 2 UNKNOWN: encoding/hex: invalid byte: U+002F '/'
    at Object.callErrorFromStatus (/opt/LndHub/node_modules/@grpc/grpc-js/src/call.ts:81:24)
    at Object.onReceiveStatus (/opt/LndHub/node_modules/@grpc/grpc-js/src/client.ts:338:36)
    at Object.onReceiveStatus (/opt/LndHub/node_modules/@grpc/grpc-js/src/client-interceptors.ts:426:34)
    at Object.onReceiveStatus (/opt/LndHub/node_modules/@grpc/grpc-js/src/client-interceptors.ts:389:48)
    at /opt/LndHub/node_modules/@grpc/grpc-js/src/call-stream.ts:276:24
    at processTicksAndRejections (node:internal/process/task_queues:78:11) {
  code: 2,
  details: "encoding/hex: invalid byte: U+002F '/'",
  metadata: Metadata {
    internalRepr: Map(1) { 'content-type' => [Array] },
    options: {}
  }
}

All along it was a configuration error on my end in the docker-compose file, and also me not being patient enough to wait until core node is synced, since that is when lnd is willing to be able to "talk" to core node.  of note, I learned that you can't just bring down these services with docker-compose down, and ideally you need to gracefully shut down bitcoin core first via bitcoin-cli stop, then you can do a docker-compose down - the potential impact would be bitcoin blockchain file will become corrupt, thus requiring you to sync/reindex the blockchain.
         volumes:
+            - /lnd/tls.cert:/opt/LndHub/tls.cert:ro
+            - /lnd/admin.macaroon:/opt/LndHub/admin.macaroon:ro
         environment:
             CONFIG: ${HUBCONFIG}
-            TLSCERT: "/lnd/tls.cert"
-            MACAROON: "/lnd/admin.macaroon"

(Illustrative git diff shown above)
Environment variables TLSCERT and MACAROON should not have been file paths, instead, it should just be assumed to be in the lnd-hub folder, thus mounted to said locations.  Alternatively from the official website, if you want, you could also have the corresponding hex-encoded file content defined as TLSCERT and MACAROON.
The docker-compose and corresponding files are available below.
https://github.com/pangyuteng/bitcoin-lndhub


text:
What BIP32 derivation path does Electrum use?
Electrum 2.0 and up uses BIP0032 internally. I want to write code that generates the same addresses. I can't find any information about this online.
What BIP32 paths does it use to generate addresses?

It uses m/0/<n> for receiving addresses, and m/1/<n> for change addresses.
Here's some example bitcoinj code to generate receiving addresses from an extended public key.
String serialized_xpub = "xpub.....";
unsigned int address_num = 4;
NetworkParameters params = MainNetParams.get();
DeterministicKey root_xpub = DeterministicKey.deserializeB58(null, serialized_xpub, params);

DeterministicKey receiving = HDKeyDerivation.deriveChildKey(root_xpub, new ChildNumber(0, false));
DeterministicKey new_address_key = HDKeyDerivation.deriveChildKey(receiving, new ChildNumber(address_num, false));
String new_address = new_address_key.toAddress().toString();

possible duplicate?

@WizardOfOzzie Funny thing: I saw that right after I worked it out by reading the source code. "BIP32 derivation path" is totally ungoogleable, for some reason.

Just for future reference, I've been maintaining a list of deterministic wallet details, including BIP-32 derivation paths, here: https://bitcointalk.org/index.php?topic=1000544.0

@ChristopherGurnee You, sir, are a gentleman and a scholar.

and for multisig? http://bitcoin.stackexchange.com/questions/51989/what-bip32-derivation-path-does-electrum-use-for-multisig

@NickODell Thanks for your answer. I also created another valid answer (to help others based on yours) using the nodejs bitcoinjs package, deriving 5 receive and change addresses.

Inspired by @NickODell answer, I created another example using nodejs that derives 5 receiving addresses and 5 change addresses.
You will need these two modules:
npm install bitcoinjs-lib --save
and
npm install bip32-utils --save
and babel for the es6 javascript code support.
import Bitcoin from 'bitcoinjs-lib';
import Bip32Utils from 'bip32-utils';

let hdNode = Bitcoin.HDNode.fromBase58('xpub...get.the.master.public.key.from.a.wallet.like.electrum...');

let receiving = hdNode.derive(0); // BIP32 m/0/<n> path (receiving addresses)
let receivingChain = new Bip32Utils.Chain(receiving);

for (var k = 0; k < 5; ++k) {
    console.log(receivingChain.get());
    receivingChain.next();
}

let change = hdNode.derive(1); // BIP32 m/1/<n> path (change addresses)
let changeChain = new Bip32Utils.Chain(change);

for (var k = 0; k < 5; ++k) {
    console.log(changeChain.get());
    changeChain.next();
}

Tested in electrum with a real wallet.
When you don't have a multiple account wallet you can use these BIP32 paths to generate addresses:
m/0/kcorresponds to the k'th keypair of the external chain of the HDW derived from master m.
m/1/k corresponds to the k'th keypair of the internal chain of the HDW derived from master m. (internal, means change and other internal uses)
But when you want to use a wallet with multiple accounts, for example, one for each customer, the paths are more like this:
m/i/0/k corresponds to the k'th keypair of the external chain of account number i of the HDW derived from master m.
m/i/1/k corresponds to the k'th keypair of the internal chain of account number i of the HDW derived from master m.
This is the default wallet layout:

This looks like a cool bit of code, but I can't honestly say that it answers the question (there is no mention of derivation paths).  This would probably be more suited as a comment linking to a github gist or something.

Sure, you are right. The paths are in the code but not correctly commented. edited the answer.

TL;DR:

BIP32 m/0/<n> path (receiving addresses)
BIP32 m/1/<n> path (change addresses)

Some days ago I had the very same question, so I ended writing this little nodejs module that does pretty much the same that you can read on @pedro_fp_simoes' answer:
https://www.npmjs.com/package/xpub-generator
You can use it as follows:
import { XPubGenerator } from 'xpub-generator';

const g = new XPubGenerator('xpub....');
g.nthReceiving(1);
g.nthChange(1);

authors: Артём Аристов


text:
How miner validates?
How miner validates each transaction? Does he have all the information  of the transaction taking place between nodes?
Thank you.

I'm not sure I understood the first part of the question. What do you mean 'all the details' of a transaction? In Bitcoin technology the transaction is a chunk o data with all information, so all the details of a transaction is the very transaction itself.

Miners role is not to validate transactions, but to confirm them. Every node validate every transaction every time. A single invalid transaction would invalidate the entire blockchain.
In Bitcoin technology the transaction is collection of bytes. All the information about a transaction is the very transaction itself.

For eg. If A wants to give 5 bitcoin (for an instance) to B and A has only 3 bitcoin with him. In this case how this invalid transaction would be invalidated by other nodes? And here another question arises how blockchain helps to prevent duplication of bitcoins?  And also if the transaction is validated by other nodes then why there is a need of miner to confirm those same transaction?

If A wants to spend more bitcoins he has, he will setup this invalid transaction in his computer. So he'll send that transaction to another computer running bitcoin. That computer will read the transaction received via the internet, see it's invalid (spend more than it can) and delete it from its memory.
No other node will accept or relay invalid transactions.
Your third question is the answer to the second one: miners confirm transactions to prevent duplication of spending. Read more here: https://bitcoin.stackexchange.com/questions/148/what-exactly-is-mining


text:
Tamper - evident log with hash pointer
We know that the hash of the previous block is included in the header of the next block. So, if an adversary change the data in the block no. 10, then they hash of it will be changed and the header of the block no. 11 will be no longer  true.
But, in the textbooks that I read to understand the blockchain, the said that the change in block no. 10 will change the whole blocks till the header of the genesis block prevent.
Why the change of the data do backward from no 10 to the first not from no. 10 to 11 and so?
See this for example:
Imagine this for a second, a hacker attacks block 3 and tries to change the data. Because of the properties of hash functions, a slight change in data will change the hash drastically. This means that any slight changes made in block 3, will change the hash which is stored in block 2, now that in turn will change the data and the hash of block 2 which will result in changes in block 1 and so on and so forth. This will completely change the chain, which is impossible. This is exactly how blockchains attain immutability.

The current block is the child and the previous block the parent. If the parent changes in any way then this will cause a change in the previous block hash pointer of the child. So the change does not ripple back to the genesis block. However what this does do is that once a block has many generations following it then it makes it very difficult to change. So the genesis block as the first block is impossible to change because changing it would make it necessary to change the previous hash of every block that followed it.


text:
Relay bitcoin transaction attack
A user sending coins broadcast transaction hash to bitcoin network. Now if someone is able to copy the message (hashed transaction) and relay it multiple times it could lead to possible disruption.
Eg:
Node 1 sends a transaction to node 2. Node 2 forwards to node 3 and so on. This transaction gets mined.
Now what will happen if node 2 will try to relay the same message again?
How this is prevented in bitcoin network?

I don't understand. What you're describing is normal operation: every node will relay to transaction to all peers eventually, until the whole network has heard about it.

Now what will happen if node 2 will try to relay the same message again?
How this is prevented in bitcoin network?

The transaction is the same as one that the nodes have already seen; it has the same txid, so they will ignore it.
Bitcoin does not use an accounts based system. Rather Bitcoin uses a transaction outputs model, so each input directly references a transaction output that is being spent. So there is no problem with transactions being replayed; they have already been seen so they're just duplicates that can be ignored.

Andrew, Thanks!. So is it the txid a unique identifier here? Who creates txid? Is txid related to 'sender', 'receiver' and 'amount of coin' getting transferred?

The txid is a unique identifier. It is the hash of the transaction itself. It isn't something that is assigned or created by anybody. It is a property of the transaction itself that anyone can calculate.


text:
How does ring signature help in range proofs in confidential transaction?
Based on Maxwell's proposal of confidential transaction, a ring signature can solve the range proof issue. I can totally follow the pedersen commitment and everything. I don't quite get how ring signature helps in range proofs? Like we wanna know if the Bitcoin amount is not negative and we don't want to reveal it. The connection between ring signature and range proof doesn't click for me.

After a lot of research and reading couple of different documents I found the answer to my own question and thought it would be good to share it with other people in the community.
Pedersen commitment on amount a and blinding factor x is:
C(a) = x*G + a*H

Where G is generator point on Elliptic curve and H is another static point that everyone has agreed on. (It is actually a map of Hash of G on curve).
In order to prove that the amount is within a specific range without revealing the amount, CT uses ring signature.
Lets say Alice wants to prove to Bob that her transaction amount is within the range [0,y]. If Bob calculates:
C' = C(1) - 1*H

It would be equal to:
x*G

If Alice can make a signature with x as a private key (using ECDSA for example) then she can verify that she knows x thus the amount is actually 1.
In Confidential transaction however Alice doesn't want to reveal the amount so instead lets say if she does this operation for all amounts like:
C" = c(2) - 2*H

and etc for all the amounts till y. Then if Alice makes a ring signature for all these amounts then she is basically saying my amount is one of the amounts in the whole range without revealing it. Ring signature is a signature that shows one of the inputs is a signing it without revealing who.
That basically results in the range proof and alice successfully can prove that to Bob through this way without revealing the amount.


text:
Feasibility of using Ring Signatures with CoinJoin Technique
There is a Ring Signature implementation in C++ by Libbitcoin team. We can find the details in the following GitHub repository. Is it feasible to use Monero like Ring Signatures together with the CoinJoin Technique in Bitcoin without a soft fork on the core protocol.

Using ring signatures off-chain to form a coinjoin transaction sounds hard, especially since because BTC doesn't have ring signature support without a hard fork or a soft fork.
You may find Cashfusion, an instance of CoinJoin shuffling, interesting, it's fully applicable to BTC and it uses TOR, which is simpler than Ring Signatures.

Thank you so much @MCCCS. Cashfusion and Cashsuffle is very interesting. I will check it out!!


text:
Are my ripples gone?
Long time ago I registered on ripple.com and had some ripples there. I still remember my login/password but the site is completely different now and it looks like there is no option to log-in anymore.
Is there any hope to log-in to my old account and get my ripples?
Few other details to not confuse people who try to help by answering my question: I am pretty sure it was a ripple.com (I use lastpass which stores information about the site/login/password). I have not bought XRP, I got them for free (as far as I remember in the very early days they were giving ~100 or so to people just to try it).

How long ago was this?

@PieterWuille this I do not remember. I assume that it was before 2014, because this is when I stopped checking various cryptos.

Actually I remember a few years back they handed out some ripple on ripple.com. Then I think they changed to rippletrade.com (?) or something, now I think this is closed too.

@DanielMorritt this is exactly what happened. Thank you for rippletrade.com. Will check whether this is something real.

If you used ripple trade, you can retrieve your secret key here or you can migrate to a GateHub wallet.

Thank you for looking into my problem @DavidSchwartz. Sadly I never used ripple trade (at the time I received ripples there was no such thing). The only thing I have is the login/password to a ripple.com site where my ripples were 3-4 years ago.

@looking_for_ripples That was likely the original Ripple client. I believe its accounts were migrated to ripple trade automatically. But I'm not 100% sure.

I@DavidSchwartz I see that there I need to provide a country/email address which I do not remember providing when I used ripple.com. Will try to do this tomorrow. By the way do you know why does ripple need so much PII data? I am really glad that one of the top guys in ripple helped me :-)

I have had the same experience.  It seems https://id.ripple.com/auth/migrate is the place now.  But how can I trust it?  They want me to type in my private key?

Maybe you could check waybackmachine? I've searched a bit on there and can't seem to find a login page somewhere on the website in 2014/2015.
Altho it's crazy how often Ripple updated their complete layout.
Almost every year they have a new design.
https://web.archive.org/web/20150204002201/https://ripple.com/

Are you sure you were on "ripple.com" and not another phising website trying to get your money and scam you. To my knowledge Ripple never sold XRP coins directly through their website.
People reported "fake" websites for ripple in the near past ... (saw it through several twitter channels. I guess you got scammed : /

I am pretty sure it was a ripple.com (I use lastpass which stores information about the site/login/password). I have not bought XRP, I got them for free (as far as I remember in the very early days they were giving ~100 or so to people just to try it).
Added this to my question


text:
Export all address from bitcoind on one server to bitcoind on another server
I need to install bitcoind on a new server, but I already have many addresses in use on the old server. If I want to reuse all of those addresses on the new server, do I need to copy just the wallet.dat file or all files in the Bitcoin data directory?

To re-use the same addresses with the new server, it will be sufficient to copy just the wallet.dat. That single file contains the private keys to all receiving addresses that have been used since the wallet.dat file was originally created.
I would recommend copying across the wallet.dat, then making sure your addresses are there and available in bitcoind on the new server. If they are, then the wallet was copied over successfully and you're good to go.
As @Jannes mentioned, you will need to turn off bitcoind on both servers before you do the copy.

Turn OFF bitcoind on both servers before doing the copying. Don't delete the file from the old server until you're sure it works on the new server.


text:
Bitcoin Testnet Trouble with bitcoin-ruby
I am having trouble with the bitcoin-ruby gem. I get the following error when trying to send money to another address I have on the test network:

/var/lib/gems/2.2.0/gems/bitcoin-ruby-0.0.7/lib/bitcoin/protocol/txout.rb:76:in
  pk_script=': undefined methodbytesize' for nil:NilClass
  (NoMethodError)

I am generating a private key with:
def new_address
 Bitcoin::generate_address
end

And getting details for the private key with:
def key_details(prikey, pubkey)
  #returns prikey, prikey_hash58, pubkey_hash58, pubkey_uncompressed, address as a hash
  my_key = Bitcoin::Key.new(prikey, pubkey)
  { prikey:prikey,
    prikey_base58:my_key.to_base58,
    pubkey_58:my_key.hash160,
    pubkey: my_key.pub_uncompressed,
    address:my_key.addr
  }
end

The code I have to send money to myself is as follows:
require 'bitcoin'
require_relative 'utilities.rb'
require 'open-uri'

Bitcoin.network = :testnet3

def build_transaction(prev_tx, prev_out_index, key, value, addr, message)
  include Bitcoin::Builder

  new_tx = build_tx do |t|
    t.input do |i|
      i.prev_out prev_tx
      i.prev_out_index prev_out_index
      i.signature_key key
    end
    t.output do |o|
      o.value value
      o.script {|s| s.type :address; s.recipient addr }
    end
  end
end

def prev_tx(prev_hash, network)
  if network == "testnet3"
    prev_tx = Bitcoin::P::Tx.from_json(open("http://test.webbtc.com/tx/#{prev_hash}.json"))
  else
    prev_tx = Bitcoin::P::Tx.from_json(open("http://webbtc.com/tx/#{prev_hash}.json"))
  end
end

def key(publ_key, priv_key)
  key = Bitcoin::Key.new(priv_key, publ_key)
end

def bin_to_hex(s)
  s.unpack('H*').first
end

#transaction inputs
priv_key = "private_key"
publ_key = "public_key_long_format"
address = "address"
previous_tx = "previous_tx_hash"

# generate tx info off inputs
key = Bitcoin::Key.new(priv_key, publ_key)
prev_tx = prev_tx(previous_tx, "testnet3")
prev_out_index = 1
tx_value = prev_tx.outputs[prev_out_index].value

# build new tx
tx = build_transaction(prev_tx, prev_out_index, key, tx_value, address, "hello")

#
# puts tx.to_json
puts bin_to_hex(tx.to_payload)

Due to a lack of responses here, I cross posted this question on the stackoverflow channel. Here is a link with the answer:
https://stackoverflow.com/questions/31409720/using-bitcoin-ruby-to-make-a-transaction/31420786#31420786


text:
Did Satoshi intend to allow midstate computation to speed up hashing?
The design of Bitcoin allows computers to compute a hash with 2 iterations of the SHA256 compression function instead of 3 on all but 1 out of every 2^32 attempts.
When Satoshi chose SHA256d for Bitcoin, did he intend to allow this?

I think Satoshi was not aware that the hashing routine could be optimized by the use of a midstate when he first created bitcoin.
If you look here, you can see that the first version of bitcoin that had the midstate optimization built into the miner was version 0.3.5 (it says 0.3.6 in the post, but you can see where someone quoted him that the post first read 0.3.5). He also says that it was implemented by someone called tcatm.

Also in 0.3.6, faster hashing:
- midstate cache optimisation thanks to tcatm

Satoshi mentions tcatm again here when trying to encourage people to upgrade to 0.3.8 by telling them they will get a better hash rate.
It's possible he knew it was possible and just didn't have time to implement it, I guess we'll probably never know for certain. But Gavin Andresen gave a talk on what Satoshi didn't know, and he speculated that Satoshi wasn't a very advanced cryptographer, based on some of the decisions made in bitcoin. As such, he may not have known about the inner workings of the hash function he selected, but just that SHA256d was regarded as a secure hash function.

EDIT: This may be the original post where tcatm proposed the midstate hashing optimization: https://bitcointalk.org/index.php?topic=648.0.

In this commit, Satoshi refers to it as "tcatm's [...] idea," so I think you're correct. However, I can't find anything he's written that says so explicitly.


text:
To sign raw transaction with Segwit Address in the TestNet
I am using Bitcoin core 0.14.1 testnet. I created a Segwit address. transfer some coins to this address. Now I want to spend it. I created a raw transaction using console command i.e. createrawtransaction. Now I want to sign it. I tried using usual way i.e
signrawtransaction 'hex_got_from_rawtx' '[{"txid":"","vout": index,"scriptPubkey":"","redeemScript":""}]' '["Private_key_of_address_used_in_segwit_address"]'
I am getting the error is: "witness program hash mismatch"
Any idea how can I get rid of it?

How did you create the segwit address? Did you use addwitnessaddress?

Yes, exactly.I used the same.

But I got to know that, I can't be able to retrieve back the address. I.e. I used addwitnessaddress "Address" then I got one address which is result of above query. Now I forgot the original  address and not able to retrieve it. Without this I can't sign rawtx i.e. dumpprivkey is only valisd on address not witness address.

Was the address you used in addwitnessaddress an address from the Bitcoin Core wallet or from elsewhere?

Yes The address was from bitcoin core wallet of mine only. If I use validateaddress "Multisig_address" then I am getting back all the addresses which I have used to create Multisig_address but if I use validateaddress "Segwit_address" then I am not getting the address which i have used to create Segwit_address.


text:
Range proof's Confidential Transaction understanding
I've some doubt about Greg Maxwell Confidential transaction and hope someone can help to make it clear.
A commitment using Elliptic Curve math is:
                                  P=xG + aH

where G,H are public value and x,a are private.
My questions are:

xG is public or private value?
if xG is a public value  why an attacker cannot simply  make a brute force attack trying all possible value of a checking for the equality with the P value?
if xG is a private value the CT paper tell: can be proven to be a commitment to a zero by just signing a hash of the commitment with the commitment as the public or if if you want to prove a=1 make C' = C - 1H
and then sign the hash of C'. How signing C or C' can I prove the value and also how can I verify a sign if I dont know xG?

Only the overall commitment (P) is revealed. G and H are constants known to everyone. x (the blinding factor) and a (the value) are secret.

if xG is a private value the CT paper tell: can be proven to be a commitment to a zero by just signing a hash of the commitment with the commitment as the public or if if you want to prove a=1 make C' = C - 1H and then sign the hash of C'. How signing C or C' can I prove the value and also how can I verify a sign if I dont know xG?

You can only sign with a point if it's a known multiple of G. By definition, a signature with private key k can be verified with public key kG. If P = xG + aH with a nonzero, it is impossible to find a k such that kG = xG + aH - that would require knowing the ratio between G and H (and H is constructed in such a way that this ratio is unknown to everyone).

Thanks! If I've understand .. suppose we 've got a commitment C to 1 (C=xG+H) in a set [0-1]. Then make two commitment:
P0 = C=xG+H and P1= C-1H = xG+H-h=xG.
If I want to use this commitment as sign's public key I can do it only for P1 beacause dont know the logaritm of P0?

You got it. The DL of P1 (wrt G) is x, but the DL of P0 wrt G is not known (to anyone).

authors: Евгений Пономаренко


text:
basics of cryptocurrency
I recently became interested in cryptocurrency and its mining process but there are a few things I don't understand very well and I am still trying to learn the basics more before getting into trading and mining. I am totally new to this and still looking around to just understand it first.

i read that currency is mined by solving cryptographic equations. what are these equations basically and what are they used for and apart from you getting a reward for solving them i.e. cryptocurrency
apart from you who or what else benefits from the solution of such equations like what is the impact of it
what made these equations i.e. their origin
is the 21million limit on bitcoin fixed or can it be changed. on a website I read that this limit has been determined from extrapolating its existing functions and parameters.

Apart from this any helpful information or websites to learn from would be greatly appreciated because I realize that this is very complex and it will take me a while to familiarize myself with it. Thank you

Hi Ali Hamza Khan, these are good questions, but our site works best when there is only one question per topic. Please check out our [tour] to read more about how our site works. In particular, these questions have been covered here before, so I linked to a few other topics that get into the nitty gritty. Please feel free to edit this topic down to a single question or create more topics when you have follow-up questions.

ill check it out. Thanks