Can't connect to Bitcoind remotely I am running a Bitcoin Cash node on my server, and starting it like this:

start bitcoind.exe --server=1 --rpcuser=user --rpcpassword=password --rest=1 --rpcport=8332 --datadir=F:\Bitcoin --bind=10.1.0.4 --testnet=1 --rpcallowip=0.0.0.0/0

The node runs, and I can connect to it locally.

However, I can't connect to it remotely, from my C# application, using the BitcoinLib library:

ICoinService coinService = new BitcoinService(ConfigurationManager.AppSettings["Bitcoin_DaemonUrl"], ConfigurationManager.AppSettings["Bitcoin_RpcUsername"],
ConfigurationManager.AppSettings["Bitcoin_RpcPassword"], ConfigurationManager.AppSettings["WalletPassword"]);

I am getting this error:

  BitcoinLib: There was a problem sending the request to the wallet.
  System: Unable to connect to the remote server.

I have created inbound/outbound rules in the server's firewall settings, allowing access to the 8332 port, and I think that --rpcallowip=0.0.0.0/0 should allow all IPs to connect to my node... So I really don't know what the problem is.

Edit: I can't access the node from https://bitnodes.earn.com/ either.

Update: the node has finished reindexing blocks, and I still can't connect to it remotely.

It turns out that the solution didn't really have anything to do with bitcoind itself - I was running it on a virtual machine hosted on Azure, and I needed to create firewall rules for the port not only on the actual Windows machine, but also in the Azure portal!


How block explorer technology works? If you click on random wallet at block explorer you get an instant info of all the transactions, balance etc etc. My question is, how their technology works exactly? Do they transform blk????.dat files in some kind of database and then read the stuff from database? If they are, what technology they use to put all transactions in database? Is there any protocol I try to do as well with programme?

When I open blk.dat files, I see only weird chars and from what I have read so far, the info there is not really transparent.

blk.dat files contain blocks data in raw format. Also a leveldb index is maintained that helps to quickly lookup blocks/utxo. You can find the details here and here.

Blockexplorers will not directly read these files. It is not safe for multiple process to access leveldb at the same time (blockexplorer and bitcoin node  process). Here is a brief summary of what a blockexplorer will do:

Create tables having indexes to store blocks/transactions/addresses
Do RPC calls/ listen to callbacks to bitcoind to get latest data
Store fetched data into tables
Goto 2.

Most of the commonly used blockexplorers are forked from the below opensource  code:

insight
bitcoin abe


Create a wallet generator? Is it possible to generate private and public keys using only a calculator?   If not how many lines of code would it take to write a wallet generator, and how difficult would it be?   How would you do this?

Bitcoin Address Generator in Obfuscated Python is a fun piece  of Python 2.7 code:

_                   =r"""A(W/2,*M(3*G
               *G*V(2*J%P),G,J,G)+((M((J-T
            )*V((G-S)%P),S,T,G)if(S@(G,J))if(
         W%2@(S,T)))if(W@(S,T);H=2**256;import&h
       ashlib&as&h,os,re,bi    nascii&as&k;J$:int(
     k.b2a_hex(W),16);C$:C    (W/    58)+[W%58]if(W@
    [];X=h.new("rip           em    d160");Y$:h.sha25
   6(W).digest();I$                 d=32:I(W/256,d-1)+
  chr(W%256)if(d>0@"";                  U$:J(k.a2b_base
 64(W));f=J(os.urando       m(64))        %(H-U("AUVRIxl
Qt1/EQC2hcy/JvsA="))+      1;M$Q,R,G       :((W*W-Q-G)%P,
(W*(G+2*Q-W*W)-R)%P)       ;P=H-2**       32-977;V$Q=P,L=
1,O=0:V(Q%W,W,O-Q/W*                      L,L)if(W@O%P;S,
T=A(f,U("eb5mfvncu6                    xVoGKVzocLBwKb/Nst
zijZWfKBWxb4F5g="),      U("SDra         dyajxGVdpPv8DhEI
qP0XtEimhVQZnEfQj/       sQ1Lg="),        0,0);F$:"1"+F(W
 [1:])if(W[:1           ]=="\0"@""        .join(map(B,C(
  J(W))));K$:               F(W          +Y(Y(W))[:4]);
   X.update(Y("\4"+                     I(S)+I(T)));B$
    :re.sub("[0OIl    _]|            [^\\w]","","".jo
     in(map(chr,ra    nge    (123))))[W];print"Addre
       ss:",K("\0"+X.dig    est())+"\nPrivkey:",K(
         "\x80"+I(f))""";exec(reduce(lambda W,X:
            W.replace(*X),zip(" \n&$@",["","",
               " ","=lambda W,",")else "])

I'd check out these two Python modules:

Bitcoinaddress
Pybitcointools (a fantastic Bitcoin library: see the README.txt for usage)

A private key is just/can be a very large number. However it's not possible to use a calculator to calculate an address easily, mainly because:

modular arithmetic is involved
base 58 check is not a straightforward conversion
there's appended bytes and such

I'd recommend either this web app to get the next best thing.


Does the bitcoin design make bitcoins suitable as a medium of exchange, a store of value, or both? Money is often seen as having various functions, such as "medium of exchange" (something useful for conducting transactions, and "store of value" (something valuable as an investment).

Was bitcoin designed to provide both functions, or just one?  How does it mainly function today?

Today, it primarily serves as a store of value. It is inherently more useful as a medium of exchange, its intended purpose. Perhaps a bit ironically, its expected future usefulness as a medium of exchange is what is driving its present usefulness as a store of value. The thinking is that if you get them now when they're cheap, in the future when they're used as a medium of exchange (and thus there's much more demand) they'll be worth more.


What is the safest way to rename my altcoin from "bitcoin" to "myaltcoin" in the source code? Some Context

I am creating my own altcoin for learning purposes and have successfully built the bitcoin code from source with my own genesis block.

Now is it time for me to change the name of the coin, so that it is truly my own alt coin.

To do this, I presume that I must change every instance of bitcoin to myaltcoin in the code, so that when I run bitcoin-qt (after the change I hope to be able to run myaltcoin-qt), everything inside the GUI will say myaltcoin and not bitcoin.

How I propose to do this...

I figure that the best way to do this would be to do some kind of case sensitive find and replace, to recursively go through all files and directories and the strings in the files, changing every instance of bitcoin to myaltcoin

The Question

What is the safest way to do this in the linux terminal? To do this safely I assume I must:

Account for case sensitivity.
Replace file names of bitcoin to myaltcoin
Replace text instances of bitcoin to myaltcoin within files
Replace bitcoin to myaltcoin in directory names

I presume there is some way to do this with find, but I'm not sure what the best way is.

To find string with in the files (including binary files), issue the command:

grep -rnw '/home/user/' -e 'bitcoin'

It will return every single entry for the word bitcoin in your code.

But I do not think that's the best way to get what you have in mind, what about "if" you have a CONST or a variable in the code called const BITCOIN or bitcoin ?

Your approach would be catastrophic for the base code and probably it will not compile. Just do not do that, instead try to find all the points with the command above, once you find all the entries, change it manually (read the code before you do that) and not using find and replace option from your code editor.


Get real fee per transaction I am trying to get real fee per trasnaction.

So I have an account whit balance 0.06940000 and have a second account with balance 0.00000000.

To get current fee I have run the command

bitcoin-cli getmempoolinfo

and got the mempoolminfee = 0.00001000.
I thought that when I send the 0.06939000 in my account rest balance will 0.00000000. but I got 0.00004860. Actually the fee was  0.0000514.

general question is WhY ?

Please tell me to understand how is fees working!

What getmempoolinfo is returning is not the minimum fee to send a transaction, but the minimum rate per kilobyte to send a transaction. Your bitcoin client will take the configured fee and multiply it by the size of the transaction in kilobytes to calculate the actual transaction fee.

The size of a transaction is somewhat difficult to compute (for a person) because it requires understanding the number of inputs that are required to fulfil the transaction, the number of outputs (primary recipients + change address), and the targeted transaction fee (since appropriate fees could eliminate the need for a change address).

There are online fee calculators out there you can use to estimate these, but it is still difficult to completely empty a wallet with a known fee using the straight bitcoin client.


How do I find out the reward value of a generated block Using the bitcoin client's JSON API (or any other altcoin client) how do I find out the reward given for finding that block?

The information you get for a getblock call doesn't seem to include the block reward. You could find it with a gettransaction call for the first transaction, but bitcoind only allows lookup for transactions in your own wallet, so that won't work either.

So indeed, as Diego points out, the only option is to look at the block height. This wiki page lists the different reward values for the different block height intervals.


Using BitcoinJS - How do you verify a message using a segwit bech32 (bc1…) / P2SH (3…) addresses? I created a signature from a message using my private key. But how do I verify this signed message using my segwit addresses of 3... or bc1...? How do I verify this using the BitcoinJS library?

A Trezor signed message with a 3 address can be verified here:

https://jhoenicke.github.io/brainwallet.github.io/#verify

Or your can verify it with another Trezor wallet.


How can one Bitcoin address be associated with mulitple IP addresses? I'm new to Bitcoin and I'm having trouble understanding the concept of "address". I understand that an address is created when you want to send or receive bitcoins from someone. You create a bitcoin address and you give that address to someone so that he or she can send bitcoin to that address and you'll receive the payment.

However, how can a bitcoin address be associated with multiple IPs? For example: https://blockchain.info/address-relayed-ips/15VjRaDX9zpbA8LVnbrCAFzrVzN7ixHNsC

This bitcoin address is connected with multiple IPs. I know that many bitcoin users advocate that we shouldn't reuse addresses. There is no way that someone else can just "pick up" the address that we just abandoned, since addresses are generated randomly. Then how is it possible that an address can be used in different IPs? Is it because the associated IPs include the IPs from which it has received payments?

A bitcoin address is not based on or tied to a network address, they are completely different.

Think of the Bitcoin address as a bank account number and the IP as a telephone caller ID. When you call your bank from different phones they'll see different caller IDs but you'll give them the same account number each time. They can write down the caller ID if they're spying on you, but that doesn't have anything to do with the account number other than the fact that you yourself are using both.

Likewise an observer can watch you sending transactions to the network from your IP address, and if you use the same Bitcoin address more than once they can see your sending IP address each time (unelss you use Tor...). But that doesn't have anything to do with the Bitcoin address other than the fact that you yourself are using both.


Minar cryptocurrencies without software or special hardware I know that it is very difficult to mine at the moment without special equipment, but I think in a way, even if it is a hobby, to try to mine either by developing a program in Java or with Excel.

I have basic equipment, currently I work with Minergate.

I want to make my own mining system, as I would do the following:

Connect to the cryptocurrency network.
Read the hash
Interpret the hash
Enter the new hash

And which currency would be feasible to undermine.

Thank you

Are you asking which altcoin to mine?

You mainly just need to look at www.cryptocompare.com and find some of the low priced coins.

However, Bytecoin would be a good thing to start with.


In the case the difficulty increases as much in future, will the possible hashes run out/be insecure? As I understood, in the block hash, the amount of zero's is the nonce, like this:

0000000000000000005f54622d97866453137466737289c2500e67f6fce1cd4e

When there are more blocks found than in the average of 10 minutes, the nonce will increase. Then the hash is recomputed for each value until a hash containing the required number of zero bits is found.

But imagine the development of ASIC's accerlates expotentially, so the nonce for the required hash will be like this, for example:

000000000000000000000000000000000000000000000000000000000000004e

I know there are more information required, but let's imagine this in 2020 if the development of new ASIC could accelerate.

So in theory there are only 28 (note the position of 4 in block hash) x 28 (position of e in block hash) = 784 remaining possible hashes. Would thatn't mean that the Bitcoin ecosystem with an insane difficulty will eventually runs out of possible hash combinations for blocks?

As I understood, in the block hash, the amount of zero's is the nonce,

No, that is incorrect.

The nonce is a value in the block header, which is then hashed. By changing the nonce, a new block header is effectively created which has its own unique hash.

  Then the hash is recomputed for each value until a hash containing the required number of zero bits is found.

No. Contrary to popular belief, the correct hash is not based on the number of zeros in the block hash. That is just an abstraction to make it easier for people to understand.

What the correct hash actually uses is a target value. This target value is a 256 bit integer. In order for a block hash to be considered having a valid proof of work, it, when interpreted as a 256 bit integer must be less than or equal to the target value.

Since it is actually an integer comparison and not checking the number of 0 bits, there are far more possible target values.


How does block propagation delay not cause accidental forks? Block propagation delay, it looks like, is about 122 seconds in some cases. If another block is formed before the first block is completed, wouldn't this accidentally create a fork? How would this fork be resolved? Someone's transactions are bound to get lost.
Example:
Let's start with a block A. Say block B was just completed, and is now being propagated.
If, during that delay, someone made a transaction and a new block C was created before block B reached them, wouldn't their blockchain become forked, with A->C and A->B? How does bitcoin prevent accidental forks like this?

How does bitcoin prevent accidental forks like this?

It doesn't. Bitcoin make little effort to prevent forks at a technical level, instead relying on the fact that when a fork does happen, it can be resolved by waiting for additional blocks and picking the chain with the most work.
As Pieter mentioned, the mining mechanism itself prevents long term forks. The act of mining extends one chain beyond the other, reducing the shorter chain to a temporary and now discarded fork.
For miners specifically, they put in a lot of effort to avoid this - mining on even a minor fork is inherently risky, as they could lose their blocks if the other side of the fork wins, thus losing the block rewards.
To reduce this risk, all serious miners join high speed links as Bitcoin Fibre. These are specially designed to minimize propagation delay.
No serious mining operation will be looking at propagation delays of 122 seconds - those would only be happening at nodes run by people with absolutely abysmal peering and internet access. For the vast majority of nodes, blocks are received in a few seconds, and for miners, usually in <1s.


Refunding of payments if scam I was called by someone when I tried to withdraw my money, who works for Bluesave,  but when I log in the platform was Optima platform and when to proceed for withdraw he send me to Jubiter page. The problem is that the first time when I opened my account was in March and I put a deposit of 275 euros. Today I requested my money back and he took another 275 euros from my account saying that is the verification procedure. And then he said, in order to send me the full amount in my bank account I have to buy some bitcoins for about another 500 euros. I am concerned about this transactions an I want to ask if this is the correct procedure in order to get my money back?..If not what can I do to get them back? Thank you

I want to ask if this is the correct procedure in order to get my money back?

No.

You are being tricked by a criminal. A confidence trickster (con-man). It is a common type of fraud or scam.

  If not what can I do to get them back?

There's no way to get the money back. Bitcoin transactions are not reversible and cannot be undone or cancelled.

You can report this fraud to your local police so that the police crime statistics are more accurate - but they won't be able to recover your money for you.

You will be contacted by people who say they, or someone they know, can get your money back. They are lying to you. They also will eventually ask you to pay release fees, transfer fees, decryption fees or some other kinds of fees they invent. None of these fees are real. I urge you to ignore such offers and accept that your money is gone and move on with your life.

  Today I requested my money back and he took another 275 euros from my account

From what you say, your Bluesave and/or Optima and/or Jubiter accounts are no longer under your control, any money in one or all of  those accounts is now under the control of a criminal. It will be best to not ever use these accounts again. Even after changing passwords, they cannot be guaranteed to be safe.

If I were you, I would make a list of all accounts the criminal might know of, then I would set aside any information given by the criminal (phone numbers and email addresses etc) and independently find out the true contact details for the businesses that provide those accounts (but be aware that some may be fake businesses run by the criminal), then I would ask, in writing, each business to close the account explaining that you are the victim of fraud.


SIGHASH_SINGLE vbuterin/pybitcointools Checking the implementation of Buterin's bitcoin tools I've noticed something strange. According to the Bitcoin developers guide, sighash_single signs only the outputs that match the input where the scriptSig is going to be placed, that is, input i should sign only output i. However, the code is always signing the current input with the last output of the transaction.

Is it a workaround to deal with a non-matching number of inputs and outputs, or I am missing something?

Just in case someone struggles with the same issue, the code was actually incorrect. Pull request #163 fixes the issue.

Here you can also see an equivalent solution properly commented and cited.


bitcoind sync time incredibly slow I am currently running bitcoind v0.16.0.0 on my macbook (osx 10.12.6) and the initial sync time is really slow. I'm syncing at roughly 88 blocks per hour which would mean it would take another 2 months to sync up..
In the activity monitor it looks like bitcoind is using only 3% of the CPU time.
Could this be the issue? Is there any way to speed it up?

Yes there is. The bottleneck is I/O speed and normal HD drives are really slow. You can move the chainstate directory (around 3GB) to an SSD. If your laptop doesn't have an SSD you can use an SSD thumb drive.

There are instruction how to do that in the wiki. I did that using an usb stick SSD and the whole chain synced in a liitle less than 12 hours.


can one account have more than one address? Bitcoin core support the methods :

getnewaddress [account]
getBalance [account] [minconf=1]

All of them are base on account concept. So I wonder that if one account can contains more than one address?

When I call the getnewaddress with the same account name many times, what does happen? The account will associate with all addresses that the method created, right?

First of all, do not use the accounts feature. It is both broken and going to be removed. It is important to note that accounts are not part of Bitcoin at all and are just a part of Bitcoin Core.

You can associate multiple accounts with the same address. It just means that the account's balance will update with each amount sent to an address associated with the account. However, sending Bitcoin from an account in your wallet WILL NOT necessarily "send from" the addresses associated with the account. It will just decrease the balance of that account.


MULTIBIT: How to restore wallet with following information? I am a noob to this whole BTC thing, so please bear with me.

I reformatted my computer and lost everything on it.
I decided I want to restore my multibit wallet but I only have the following info:

Secret words
Old password

I do not have a backup of the wallet file or whatever it is called.

My question is, how do I reopen this wallet with that information? It has a lot of BTCs it in and I really want to salvage it.

Thanks for reading!

The MultiBit HD wallet can be restored with just the seed words. Click "Restore" on the unlock screen and follow the instructions.


Can I lock a transaction from being used until a particular condition is met I plan to open an ecommerce website from which I will accept BTC as payment. However users dont want to pay with BTC without getting the goods since my site is just starting up. What are the options I have?

Your question indicates some experience with bitcoin, so I am going to be very technical. You may want to look up "smart contracts" as keywords. In the bitcoin world we talk about checklocktimeverify and checksequenceverify, together with some multisig (as escrow service). There are many examples, e.g. here (this is basically what I posted in bitcointalk):
IF
    2 <Alice's pubkey> <Bob's pubkey> <Escrow's pubkey> 3 CHECKMULTISIG
ELSE
    "30d" CHECKSEQUENCEVERIFY DROP
    <Alice's pubkey> CHECKSIG
ENDIF

or something like this:
 if
  <merchant pubkey> checksigverify
 else
  <timestamp> checklocktimeverify drop
 endif
 <customer pubkey> checksig

imho, n-of-m multisig is the easiest form of a contract. Escrow service is the next layer (as in examples above). They can make sure, that BTC is only payed, when a specific condition is met.
And then one can create very specific constructs like:

CHECKSEQUENCEVERIFY: lock some Satoshis until a specific number of
block have passed, before one can use them
CHECKLOCKTIMEVERIFY: lock some Satoshis until a specific number of
block appears (aka my son is 18 years old...), but use a 2-3 multisig
to release the funds in case funds are required earlier

It goes even up to the point where you can create tx spends, where the hash of a condition must be equal to a previously defined value.
I see some limitations when trying to use Oracles (aka data from "outsides"), maybe data from exchanges, or from real live (in case of death).
Some more example in Andreas' book "Mastering Bitcoin" (second edition) in the chapter "Timelocks".
or here:

https://bitcointalk.org/index.php?topic=1300723.0
https://bitcointalk.org/index.php?topic=1558207.0
https://bitcointalk.org/index.php?topic=1952248.0

or here:

https://www.reddit.com/r/Bitcoin/comments/4kit49/is_it_safe_to_use_cltv_for_recurring_payments/
https://www.reddit.com/r/Bitcoin/comments/4p4klg/bitcoin_core_project_the_csv_soft_fork_has/d4i01he/

and here:

https://en.bitcoin.it/wiki/Timelock
https://en.bitcoin.it/wiki/Contracts


Your intensity is very low (I:8) - dynamic intensity does not work well with scrypt. You will need to increase it manually. You can set a value to use when starting the program by adding --intensity 13 to your command line options/batch file. Replace the number 13 with the desired intensity. For a HD6850, I suggest you try values from 10 to 15.

If increasing the value by one notch does not significantly raise kh/s, gives you hardware errors (the number after HW:) or starts impacting in a noticeable way on desktop performance, then reduce it again.

You can also change the intensity whilst cgminer is running. Press g, then i, then carefully type the number, then enter.


Any API to estimate the miner fee for a Bitcoin raw transaction? Coming from the ethereum development scene, I guess I'm kinda spoiled by the availability of the web3 library which has easy access to the eth.gasPrice and eth.estimateGas methods to get the default gas price and gas limit for raw transactions. I'm wondering if there are similar APIs from the bitcoin clients like Bitcoin Core? So that given a particular transaction, there will be a fast and easy way to calculate a suggested miner fee for it? Thanks.

Fees in Bitcoin are actually a bit simpler than ethereum, you don't have to deal with gas costs, just a fee per byte.

Bitcoin Core includes an estimatesmartfee function. You can call it (estimatesmartfee 2, for example) and it will give you an idea of the fee rate you need to be confirmed in n blocks (2 in my example).

You can then check your tx size, which varies by number of inputs and outputs, and just multiply it by the fee rate to get your recommended fee, and subtract that from your change output.


Is there an easy way to give people a Bitcoin address? I see that Bitcoin addresses have built in checksums that helps prevent typos (ie. it is highly unlikely that you can mistype a Bitcoin address and have it still be valid). However, I still think the addresses are too long to easily give to someone, publish on a business card, etc. Is there any way to shorten addresses or get specific addresses?

Here are a few tips to help you distribute your addresses on a more readable form:

Firstbits.net shortens your address to (usually) less than 7 characters. To get the full address just enter the firstbits at the website (ex: http://firstbits.net/?a=1kk5k)
Use vanity generator to create a more customized address. You can try to create an address that has your name on it or any other word that you like. Bear in mind that this will still be a long address with many 'strange' characters (ex: 1stDownqyMHHqnDPRSfiZ5GXJ8Gk9dbjL)
If you use an e-wallet service, there are usually shortcodes that allow users to transfer bitcoins instantaneously between users. You can only use this if the other person uses the same e-wallet as you (ex: check Flexcoin, TradeHill or CampBX)
If you want to print your address into a business card, I suggest using QR Codes. They can easily be scanned with a smart phone.


Saving a customer's info so I can accept bitcoin I have a business that basically works using a subscription (I'm simplifying here). I see that Stripe accepts Bitcoin, but it's for a one time payment. Is there any way to save a customer's Bitcoin info, or is it just for one time payments? The nice thing about a credit card is you can keep charging it...

Bitcoin transactions are "pushed" by the payer. There is no way for the recipient to "pull" payments.

You should use a new address for each customer. That way you can see who paid their subscription fee by checking which address received the payment. However, the customer would still have to repeat the payment every time.


Should i invest in a Antminer L3+ or a Antminer S9 i've been looking to invest in a antminer s9, at the moment the earning i can get from that machine is around 10$/day. but it's a litecoin miner (Antminer L3+) for the exact same price that i could earn 30$ a day from. people say that the value of bitcoin will rise like a rocket, but i dont know about litecoin.

Invest? Run the math first on bitcoinwisdom.com. Unless you have free power (and won't get into trouble drawing a kW of AC 24/7; it won't be profitable for long.

Difficulty rises and will continue to do so; until the correction comes; which- it will.

Now would be a bad time to buy a miner. I would wait for a major price correction-- even if BTC hit 10k before the correction- the money to make would be after it drops back down to 5k and the miners are all worthless; then start them up after the price rebounds.

Bitcoin mining is too hot to touch right now if you are not already heavily invested in the game.


What is the difference between an SPV wallet and an API wallet? I understand what an api wallet is, but I'm unfamiliar with what an SPV wallet details. I'd like a technical explanation on what an SPV wallet is, how it differs from traditional thin clients and how I could go about implementing one.

SPV wallet: only download block headers from blockchain network, it's kind of lightweight node, SPV wallet is able to verify the TX with Merkel branch that from full node.

There are lots of SPV wallet implementation at Github with different coding language, you can go and check it.


I have blockchain.info wallet with BTC and BCC. What will happen if I send BTC only to that address? Previous question: In case of the Bitcoin split - when holding BTC on blockchain.info - will I receive coins on both forks?

I know that I can restore private key from the 12 words BIP 39 recovery phrase.

I was silly / stupid / risky enough to move 1.11111111 BTC pre-fork - https://twitter.com/stefek99/status/891777250089209857 - to ViaBTC and now there is ฿ 1.25469771 post-fork Bitcoin.

I have no idea how to reconcile this. Thinking about splitting my remaining pre-fork Bitcoin, trading BCC for BTC and keeping post-fork balance only.

Sending post-fork BTC to pre-fork BTC and BCC address seems risky. Is there anything I should consider?

https://blockchain.info official statement: https://blog.blockchain.com/2017/07/30/bitcoin-cash-hard-fork-blockchain-users/

At the time of the fork, your previous key now gives you access to two independent wallets one BTC, one BCH. They both start with the amount you had before the fork. There are no "pre-fork" nor "post-fork" bitcoin, there are now only one key opening two different wallets.

The two wallets are not compatible anymore, it means that you cannot move some coins from the BCH wallet to BTC wallet, nor BTC to BCH.

If you send BTC to your BTC wallet, then your BTC wallet will get the coins, and the BCH wallet will stay unchanged.
If you want to fill the BCH wallet also, you have to make another transaction, on the BCH network, of the same amount.

Best pratice would be to separate your BCH wallets from BTC wallets. You can do this with Electron Cash software with the "recovery passphrase", as described here: [https://thebot.net/threads/tutorial-how-to-get-your-private-key-from-blockchain-info-redeem-your-bch-from-blockchain-info.396919/][1]. Don't forget that until you move the coins to new wallets, the same key will give access to both BTC and BCH wallets, even if they have different lives, so keep them safe!


how to concat our website url in our bit coin transaction in blockchain send api Hi im using block chain send api in my web application, and it is working fine without any issues. My requirements is when the payment is done thought blockchain send api, is it possible to concat our website url with custom name in the transaction?

In this address https://blockchain.info/address/1H7FMLas2d7HqSstx8xVDMURvWphv4bnFd user has concatinated his website name with url.

How can i do the same using send api?

Address Tag

There are two ways I know of to tag an address on blockchain.info but both require a captcha so I don't think you can do it in an automated way. But the tag applies to the whole address, not a specific transaction. So if you have a small number of addresses, you can tag them all so that all your transactions will have the link. If you are automatically generating addresses, that would be hard.

The first way is with a signed message. You sign their specific message and send it to them. That means only you can tag your address this way.

The second way is if an address is viewable on a website, then anyone can come along and tag the address so it links to that page.

These will allow you to make it look like the "DPR Seized Coins 2" in your example.

Public Note

A separate thing is to use a public note like this message in your example:

  WTF??? What is it??? Is this guy CAN CLONE BTC? OR COPY BTC? Is it real? WTF??? Somebody can explain??? WTF!! I found this: http://sharma.binhoster.com

A note applies to a specific transaction, not an entire address. Also it does not require a captcha so it can be automated. But it can't have clickable links. Here's information on how to do that.


Bitcoin withdrawal issue I have withdrawn BTC from an exchange to be sent to another. However, I haven't receieved it. When I check it with the transaction hash, it shows as it took so many confirmations. Can anybody tell me where the problem is? Please check my Tx hash : 1db23c2bdc95d1b889ae0489103a0d0041bd5e046c07ebefdffd81abab343978

Double check to make sure you didn't send your coins to the address of another coin. Sending BTC to BCH (BCC) is a very common mistake.
If you sent the coins to the wrong address, you'll need to contact the exchange and ask them to import that private key into your BTC wallet. Whether or not they will comply depends on the exchange.


bitcoin node startup daemon with created wallet When I restart the Bitcoin node, I would like to load the wallet I created in the "wallets" subdirectory.

bitcoin-cli createwallet "1"
bitcoin-cli listwallets -> result : "", "1"
bitcoin-cli -testnet stop
bitcoind -testnet -daemon
bitcoin-cli listwallets -> result : ""

thanks.

You load a wallet using the loadwallet command.

To load the wallet named 1, do

bitcoin-cli loadwallet "1"

In order to have that specific wallet always loaded, add to your bitcoin.conf file:

wallet=1


How is a block header hash compared to the target (bits)? I'm trying to wrap my head around the mining process by doing a small example of block hashing.

According to the Wiki entry about difficulty, the target for a block hash can be read from the "bits" part of the header as follows:
In this example, the bits part is 535f0119.

535f0119 * 2**(8*(0x1b - 3))

My resulting target would be:

535f0119000000000000000000000000000000000000000000000000

The target in decimal would be:

8780002705592212783085671453687210878315895819816253650256038723584

Let's say the hash I got with my current nonce is

4d47599dd86834282a8ae6f20ba454704ddbe6eb23aa31b9fdec97fc7679b559

How can I now compare if the hash is smaller than the target? What do I have to do with the hash to be able to say "hash < target"?


Where do the mined bitcoins go? I am trying to understand how the mining process works. I haven't ever mined, so I would probably understand it if I mine (maybe using zcash or another crypto that is starting).
I understand the overall how the process of mining works, but what happens with the coins that a miner earns?
Like, if I am a miner and I earn some coins after resolving the problem, where do all the released coins go? Do they all go to the miner?
If so, can the miners hoard all the coins for themselves and not share them the rest of the world?

When miners are trying to find a block, they are doing so for a specific set of transactions. This set of transactions includes a special transaction, the coinbase transaction. It's the first transaction in a block and collects the transaction fees and the block subsidy. The coinbase transaction's output sends the mining reward to an address specified by the miner.

This way, finding a valid block also ensures payment of the successful miner: the payout is part of that block. Once the block has matured by 100 other blocks being built on top of it, the block reward becomes spendable. What the miner then does with the block reward is their own choice.


cannot decode block 0 to find the output address. I can decode much higher blocks. what am i missing? Can you please decode block 0 output transaction manually showing me how to get the output address namely: 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa

Never mind I figured out my mistake. Earlier bitcoin blocks stored the public key in the signature instead of its hash.
Thank you anyway.


I sent some Bitcoin to a Bitcoincash adress on Trezor I sent some Bitcoin to a Bitcoincash adress on Trezor and it doesn't show on my Bitcoin in Trezor, how can I get them back ?

You should upgrade your Trezor firmware. Follow the steps here: https://doc.satoshilabs.com/trezor-user/updatingfirmware.html

After it, your problem should be solved. If not, try these steps: https://blog.trezor.io/claim-bcash-bitcoin-cash-bch-bcc-trezor-wallet-f0a810d5864a


How to validate raw transactions using bitcoind and/or bitcoin-cli (preferably offline)? I've been wanting to join in the fun on this Bitcoin transaction contest but while I'm comfortable enough working out the scripts themselves and playing with the web-based tools suggested, as a relative newbie to Bitcoin I haven't got a clue how to use bitcoind/qt to do the raw transaction validation.

I've downloaded bitcoind/qt/cli but I don't know what to put in my bitcoin.conf nor do I know how to run the tools nor what data I should feed them in order to validate my raw transactions.

I'd prefer to run my raw transaction validations offline but I don't even know if that's a possibility with these tools?

Despite searching wikis, forums, etc, I haven't found a 'dummy's guide' for these tools; everything seems to start from a level of knowledge which is somewhere above where I am at the moment.

I'd be very grateful if somebody could point me in the direction of some suitable information or else provide it here?

And although the organiser of the Bitcoin contest proposed using bitcoind for validating raw transactions I'm happy to consider any other tools/services that would do the equivalent job so if anybody can point me at (simpler?) alternatives that would be fine too.

Thanks in advance.

You can validate transactions in an offline instance of bitcoind that has absolutely none of the block chain!

Launch it like this:

$ bitcoind -datadir=some-datadir -server -connect=localhost:9999

The "connect" parameter gives it the remote connect to. If you point it at a non-listening port, it will never gather any blocks. This is fine for validating transactions.

It will tell you that you need to create a bitcoin.conf, and where, and what to put into it (rpcuser=bitcoinrpc and rpcpassword=some_long_string).

Then your bitcoind RPC url will be

http://bitcoinrpc:password@localhost:8332/

You use the JSON API signrawtransaction documented in section 7.2 of https://en.bitcoin.it/wiki/Raw_Transactions. You will need to pass in the inputs, since they will not be known to the bitcoin daemon.

I'm the author of the Python library pycoin https://github.com/richardkiss/pycoin/ and I use bitcoind to verify that transactions created by pycoin are valid (or in some cases, invalid). See bitcoind_agrees_on_transaction_validity in https://github.com/richardkiss/pycoin/blob/offline_tx/pycoin/services/bitcoind.py for an example usage.

(You could also use pycoin to validate transactions. It works, but it's not quite there yet documentation-wise. It also hasn't been extensively tested on non-standard transactions, so its VM implementation is hardly authoritative.)


Can't understand specific problem of Bitcoin anonymity There is an problem shown in bitcoinwiki:

  Someone runs both a money
  exchanger and a site meant to trap people. When Mr. Doe buys from the
  exchanger and uses those same coins to buy something from the trap
  site, the attacker can prove that these two transactions were made by
  the same person. The block chain would show:

  Import coins from address A. Send 100 to B. Authorized by (signature).

  Import coins from address B. Send 100 to C. Authorized by (signature).

  Bitcoin transactions do not have a "from" address, but if the attacker
  believes that address B is controlled by Mr. Doe because the attacker
  received $5 from Mr. Doe's PayPal account and then sent 100 BTC to
  that address then they can infer the identity of the party sending to
  C. This assumption is not always correct because address B may have
  been an address held on behalf of Mr. Doe by a third party and the
  transaction to C may have been unrelated.

I can't understand several issues. Is "someone who runs both a money exchanger and a site meant to trap people" attacker? If so, than I (as attacker) already know the owner of address B, don't I? why I need trap site?

I (as attacker) already know the owner of address B, don't I? why I
  need trap site?

You're right, if you sold the bitcoin and sent it to an address, and you know the identity of the person to whom it was sold (from KYC, for example), then you can associate that person that address. Since it is publicly verifiable on the blockchain, you don't need a trap site in order to see when that bitcoin is spent, but if you run a trap site, you can determine what they spent the Bitcoin on.


Where in the source code are transaction validation checks implemented? I understand that consensus (mining) and transaction validation are different concepts. Correct me if I'm wrong, but I believe each full node validates transactions and puts the valid ones into its own memory pool. Miners select transactions from the mempool and carry out the mining/consensus process to create a block.

Are there additional checks carried out by miners? If so, where are they in the Bitcoin source code? So far, I've found that transaction validation is carried out by some functions in main.cpp like AccepttoMemoryPool, while mining is implemented in miner.cpp. However, miner.cpp apparently also contains some checks.

Your general understanding is correct.

Mining doesn't perform any additional checks then any other full node.  Mining serves the function of giving transactions an ordering which is difficult to undo, but validation is just a function performed by every node.

Some tests are in miner.cpp because creating a block that matches some set of rules needs different code than checking if a block matches those rules. For example, some space needs to be set aside for the coinbase transaction (which is produced externally in normal use).


Bitcoin RPC estimatesmartfee argument keys necessary? I am attempting to use a PHP RPC Wrapper to connect to bitcoind for RPC API calls, estimatesmartfee, more specifically.

My question is, do I need to specify the argument keys, or just the values?

For example, the below is with just the values

public function getSmartFeeEstimate($blocks)
{
    $command = new \Nbobtc\Command\Command('estimatesmartfee', [$blocks, 'CONSERVATIVE']);
    $response = $this->client->sendCommand($command);
    $contents = $response->getBody()->getContents();

    return $contents;
}

or do I need to specify the keys as well, for example...

public function getSmartFeeEstimate($blocks)
{
    $command = new \Nbobtc\Command\Command('estimatesmartfee', ['conf_target' => $blocks, 'estimate_mode' => 'CONSERVATIVE']);
    $response = $this->client->sendCommand($command);
    $contents = $response->getBody()->getContents();

    return $contents;
}

Normally I would just try each one and see what the functions return, however, I am in regtest mode, and its returning the same thing for both, which leads me to believe that it's ignoring the arguments and just telling me its not working...

{"result":{"errors":["Insufficient data or no feerate found"],"blocks":2},"error":null,"id":null}

It's not working because it does not have sufficient data to give you a reasonable estimation.

You will need a steady rate of transactions on the network for a sustained period of time. On regtest, that means you'll need to simulate those transactions as there is no network to provide them.

It's easier to see estimatesmartfee in action on testnet or mainnet.


If each miner has a different share difficulty in a PPS pool, how should I calculate and reward the relative effort of each? For discussion purposes, suppose I have an ASIC miner, several GPUs and a CPU botnet all mining with different difficulties.

When a share is returned to the pool, at what difficulty threshold should I consider multiplying the per-share value for that user?

For example if the ASIC miner returns a share that is substantially closer to the target than what a difficulty of 1 would return, should I treat that as any more valuable?

Am I incentivising correct behavior in a client?

You should count each share as valuable as the difficulty of the pre-determined target for that miner. If you count the actual value of the hash it found itself, either the math won't work, or you'll introduce massive variance instead of reducing it (which a pool is intended to do).

When you choose a particular share difficulty D, you are restricting the set of valid hashes to a set that is D times smaller than the set of valid hashes for difficulty 1. Given that each of such results is D times less likely to be found, it is fair to count it as D shares of difficulty. However, each hash is either good or not good, and each has a fixed probability of being good.

If you're going to use the actual hash value obtained to calculate share value, most hashes won't be valid, but those that do will introduce extra variance: some (unlikely) ones will result in a very high score, and some won't. There is no need for this: just giving each hash the same score is just as well a way of measuring their hash rate, which is what this is all about.

Of course, you can't let a miner choose its share difficulty after finding one: that would allow them to cheat.


Does the 256-bit integer secret exponent define the X, Y pair? I'm trying to understand better how bitcoin works and I'm stuck. I've read a blog showing how to construct the WIF from the 256-bit secret integer and up to that point, I think I follow.

However I'm "lost" when it comes to the (X,Y) point.

In the following facetious example (where the 256-bit secret exponent as been set to '1' on purpose), what defines the value of X and Y?

A related question: for the same secret exponent ('1' in this case), could we have ended up with a different (X,Y)?

secret exponent: 1
  hex:           1
WIF:             KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn
  uncompressed:  5HpHagT65TZzG1PH3CSu63k8DbpvD8s5ip4nEB3kEsreAnchuDf
public pair x:   55066263022277343669578718895168534326250603453777594175500187360389116729240
public pair y:   32670510020758816978083085130507043184471273380659243275938904335757337482424
  x as hex:      79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
  y as hex:      483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
y parity:        even
key pair as sec: 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
  uncompressed:  0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\
                   483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
hash160:         751e76e8199196d454941c45d1b3a323f1433bd6
  uncompressed:  91b24bf9f5288532960ac687abb035127b1d28a5
Bitcoin address: 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH
  uncompressed:  1EHNa6Q4Jz2uvNExL497mE43ikXhwF6kZm

That example has been generated with an utility you can find here:

http://blog.richardkiss.com/?p=371

I usually use the following analogy to oversimplify things: The secret key is how far you walk along a known curve starting from a known point and the public point is where on the curve you wind up when you finish. If you repeat the same walk, you will always wind up at the same place. The operation is irreversible because the curve is complex, you can only figure out where you wind up by taking steps. Given a destination, you cannot figure out how to get there because you must walk in integer steps.


Solving a block and share relationship [pool mining] I have a somewhat odd question. I am currently pool mining and it is telling me my best share and the difficulty (this is an altcoin but same question applies). My miner is telling me my best share was 16.7K and the difficulty is a little over 100, does it matter what my 'best share' is for that round? How do I know when I solve a block in the pool? I hope this made sense

When your share is better than the difficulty you have solved a block. Other than that, the best share is only for your information/amusement. Although, some pools only count shares above a certain difficulty towards the work one has provided.

Even succeeding at the difficulty, you could still not be discovering a block for one of the following reasons:

The difficulty you were looking at was the difficulty at which the pool is accepting shares as work, instead of the networks difficulty.
You were working on a stale block chain.
Another block was found at the same time and was accepted right before yours.


File structure of wallet.dat I have a corrupted wallet.dat that is unreadable by pywallet and db5.3-util.
Having a look in the corrupted wallet in a hex editor, its easy to find the plaintext pubkeys.
Is the structure of the dat file such that it is possible to copy/paste sections of the corrupted wallet so that the key is now part of a new wallet file?
edit - it also seems useful to ask if there is any other manual process for key recovery?

There are various ways to extract and dump the private/public keys from a wallet.dat depending on how it became corrupted.
First, try to run -salvagewallet command to repair it.
If you have a tool to dump the mongo db, yes its possible to find possible keypairs (pub/priv) and dump them out using python tools. Of course you would need the passphrase for this.
What system are you using, mac, Linux, Windows, and what version was the wallet created with?


Can I verify a sub public key came from it's parent public key in a HD wallet without involving any private keys? I know I can sign a piece of text using a bitcoin private key to prove control over a public address but are there any operations I can perform to know if a public key submitted to me was derived from a parent public key if I do not have any private keys at my disposal?

I have looked at:
https://github.com/richardkiss/pycoin and
https://github.com/jmcorgan/bip32utils
but have not yet found a way to do it.

Thank you for any input :)

Yes, you can, assuming that the child key isn't hardened, and you know the chain code of the parent public key and the index of the child. (Also known as the extended public key.)
Just compute

CKDpub((Kpar, cpar), i) → (Ki, ci)
Kpar is the parent public key, cpar is the chain code, i is the index, and Ki is the child public key

as defined here and compare it to the child key you were given.


How to copy wallet.dat from v0.10.2.0 to v0.11.0. I am trying to import the balance from the older version to the newer one. I deleted the wallet.dat from the newer one and copied the older one into its place. However, the wallet will not start with the old wallet.dat. I get a small "error" msg box. When I click "ok" qt closes down.

Are the two wallets incompatible? If so, is there another way to import my balance to the new wallet?

Thanks

As there was no response for this, and in case someone else has the same problem, I dumped the private keys, and then imported them to the other client.


Mining operation calculation My goal is to understand bitcoin.

I have read what happens during a transaction and have a question about it:

When a transaction happen, the miners compute a value called "prof of work". This value is calculated in order to get a 0 value (or something very closed to 0) for the hash of the value + the transaction + the last pow.

So the miner work is to calculate a prof of work. But i have read the miner discover new bitcoins too. Is it another form of mining ? I do not see the link between the POW calculation and the new bitcoins)

Thanks

When a transaction happen, the miners compute a value called "prof of work". This value is calculated in order to get a 0 value (or something very closed to 0) for the hash of the value + the transaction + the last pow.

The miner does not perform the PoW on each transaction individually, but on a set of transactions, whose combined size is less than approximately 1MB when serialized (There is a 1MB limit for non-SegWit parts and 4MB limit for the entire structure including SegWit parts).

The set of transactions is placed into a structure called a block. The block has a header which contains, among other things, a timestamp, the target, a nonce, the hash of the previous block's header, and the merkle root of the set of transactions in this block. The actual representation of the transactions in the block structure is a simple serialized list.

Miners can choose which transactions they wish to include in a block and in what order. However, the usual method is to sort transactions by highest paying fee and select the first bunch of transactions which fit within the block size limit.

The merkle root is calculated by placing the transaction ids (the hash of the serialized transaction) into a binary tree where each parent's value is the hash of the concatenation of its two children's values. The value of the root of this tree is then placed into the block header, along with the other necessary information.

Proof-of-Work is then performed by taking a hash of this block header, and the proof of work is successful if the resulting hash is less than the value specified by the target, which determines the difficulty. The target indicates how many leading zeroes the hash must have - the more leading zeroes, the smaller the possible range of hashes becomes, making it more difficult to produce a matching hash. This difficulty is adjusted according to a consensus algorithm which attempts to make blocks created on average every 10 minutes - using historical data from the past 2016 blocks and their timestamps.

The Proof-of-Work is essentially brute-forcing the double-SHA256 of the block header by using different value for the nonce in the header until the resulting hash of the header is a value which is less than the target. The nonce can be randomly selected, but it is more sensible to simply cycle through all possible 32-bit integer values in order.

  But i have read the miner discover new bitcoins too. Is it another form of mining ? I do not see the link between the POW calculation and the new bitcoins)

Each block must contain at least one transaction in its set, which must appear first in the list. This is known as the coinbase transaction. Unlike other transactions, it has no UTXOs as inputs - but its virtual input is newly generated coins plus the aggregate of fees paid in all transactions in this block. Newly generated coins must be strictly less than or equal to 50 >> floor(block_height / 210000) bitcoin, which determines that the number of new bitcoins which may be generated is halved approximately every 4 years (210000 blocks).

The coinbase can also be used to include an extra nonce value because the nonce in the regular block header is too small (32-bits), and its entire range can be exhausted by modern miners more quickly than new transactions are added to the block. Mining pools also usually insert their name into the coinbase transaction so it can be public knowledge.


Does BTC.com support ASICBOOST Does the www.btc.com pool support Asic Boost? Does it have to support it for me to use Asic Boost on it? If it doesn't support Asic Boost which pools do?

I believe mining Bitcoin with overt (version-rolling) ASICBoost is currently (may 2018) supported by Slushpool, Ckpool, F2pool and my own pool Bitminter.

I would expect this list to keep growing, although adoption has been very slow for some reason.


retrieving an original data from a hash: is it reliable? Normally, one of the purposes of hashing a string (such as a transaction) is summarizing the data to save the size because of the space limitation.

If this proposition is true, now assume we need to read the original data and so we need to extract the exact original data (with all details).

Now the question is if the extracted data from the hash data is exotically equal to the original data?

And if yes, is there any tool to do this? (for example, for retrivieng the original data from SHA256 hashing algorithm).

And if we cannot retrieve the original data from a hashed value, how hashed data can help us for validating an original data?

Normally, one of the purposes of hashing a string (such as a transaction) is summarizing the data to save the size because of the space limitation.

No, that would be a compression function. Hash functions are not compression functions, there is no reversing a hash. The point of a hash is to get a unique representation of the data that is the same size for any farbitrary length data.

  If this proposition is true, now assume we need to read the original data and so we need to extract the exact original data (with all details).

No, that is false. You cannot get the original data back.

  And if we cannot retrieve the original data from a hashed value, how hashed data can help us for validating an original data?

If you have the original data and a hash of it (calculated at a different time or by someone else), you can hash the original data and check that the hash matches the hash you were given.


What is transaction "finality"? bitcoind IsFinalTx() as seen here checks the properties of a transaction in this order:

Is nLockTime exactly 0? That's final. return.
If it's not 0, is it below the current block height / time? If so, it's final. return.
Ensure that every tx input is exactly 0xffffffff. If so, it's final.

Because these are checked in order with return statements, nSequence won't even be checked if nLockTime == 0. Furthermore, a transaction that is NOT past its nLockTime value could still be "final" as long as all the nSequence values are 0xffffffff

Non-final transactions are not valid in blocks, so my questions are:

Why is a "bad" locktime ok as long as all sequences are final? The tx won't be mineable anyway, right?
What are the implications for replace-by-fee and Check Sequence Verify transactions (when a non-final nSequence value is used)? Does this mean that to use those features, nLockTime has to be set a certain way?
Or, maybe, because nLockTime has to be below the current time/height anyway, this is all just moot and really, nSequence doesn't really impact transaction finality at all.

Why is a "bad" locktime ok as long as all sequences are final? The tx won't be mineable anyway, right?

According to BIP 68, setting nSequence value to 0xFFFFFFFF for every input in the transaction disables nLocktime. So, whatever may be the value of nLocktime, it will have no effect on the transaction as far as nSequence value is 0xFFFFFFFF.

  What are the implications for replace-by-fee and Check Sequence Verify transactions (when a non-final nSequence value is used)? Does this mean that to use those features, nLockTime has to be set a certain way?

It considered a transaction has opted in to allow replacement of itself, if any of its inputs have an nSequence number LESS than 0xFFFFFFFE. To use CSV your nSequence value has to be <= 0xEFFFFFFF. If nSequence value > 0xEFFFFFFF, then there us no consensus meaning to the sequence number and it can be included in any block under all currently possible circumstances. So for using nLocktime along with Opt-in RBF, your nSequence value has to be between 0xF0000000 to 0xFFFFFFFD. Refer this for more info on nSequence and how it has evolved in the last few years.

  Or, maybe, because nLockTime has to be below the current time/height anyway, this is all just moot and really, nSequence doesn't really impact transaction finality at all..

nLocktime is a transaction level feature while nSequence is an input level feature. So, the program basically is optimized so that individual inputs are not checked if the transaction itself is invalid due to nLocktime. If you check the function below IsFinalTx, it checks the validity of each transaction inputs by verifying that the nSequence numbers are valid.


How to best structure Internal bitcoin payments within a webapp? I'm building out a pet project webapp called CollaboTree, a big part of it is allowing users to set bounties for completing/collaborating on little bits of work. I'd like these micro payments to be as cheap/free as possible, and fast (instant?) would be good.

Would it make sense to:

Make a wallet for every user on signup, and make all internal payments go onto the blockchain between real wallets
allow users to load/unload bitcoin onto their accounts to some kind of shared wallet which only the app has access to, then maintain a balance for each user in database letting them transfer among themselves instantly outside of the blockchain, then letting them get their coins back 'live' when needed
Have one big wallet for the entire app, with each user having their own address which is the only one they can spend from or something?

The Block.io api supports accounts for similar usage.

With Block.io, you can create wallet addresses for users inside your games, auction sites, stores, etc.
To create a user's wallet on your account, create addresses for them using get_new_address. You should specify a sequence of labels for that user. For instance, if we wish to create a number of addresses for User A, we'd want to call get_new_address with label=userAx{address_number} as many times as wish to create a new address for User A.
Once we have addresses for User A, we can query balances for their addresses, and send coins on the user's behalf.


Is the time value in transaction or block information the time it arrived at my client? Both transactions and blocks have a time field when you use Bitcoin's getblock or gettransaction methods. The API method list defines the transaction time as " time the transaction occurred".

Is this the time the transaction or block arrived at my client? Or is this time defined by the sender of the transaction or block?

I tried to encode a transaction to a raw transaction and decode it again afterwards, but the lock_time property is set to 0 when I do this.

The reason for this question is that I want to make sure that when you check all transactions twice, all new ones of the second check have a time value higher than the highest one of the first check.

Blocks have timestamps, transactions don't. The time of a block creation is known, the time of the transaction can only be guessed. Most clients use the block's time for transactions, and if they're still in the transaction mempool (not in a block) they use the time the transaction was first seen by the client.


Can I "duplicate" a wallet using a backup phrase (12 words)? My understanding is that a wallet isn't a wallet at all*, it doesn't hold my coins, but its a key store; my coins are of course "stored" as records of the events on the blockchain.
Imagine I have bitcoins with Cloud Wallet Company (A), but I then setup Wallet Company (B)'s app. And let's assume they both use the same crypto algos to compute the seed from the 12-word recovery key, as per this answer.
Is the "recovery phrase" generated by a wallet app platform independent?
If I login to (B) and choose to import/recover my wallet and punch in the 12 words I got from (A), would I effectively now have two wallets? i.e. both (A) and (B) are setup with the same wallet.
Where is my balance stored? After entering my 12-words into (B) would their servers have to "run a query" on the blockchain to aggregate all the transactions and arrive at my balance??
And if I send from (A) to a friend's wallet (Z), would my reduced balance also show on (B)? Or would (B) cache my balance to avoid expensive query/compute from the blockchain, and so it would become out of sync?
Thanks!!
*Maybe I'm wrong but I think the wallet analogy only confuses noobs, since it sets up a mental model that's the opposite of the whole point of a blockchain.

Can I “duplicate” a wallet using a backup phrase (12 words)?

Yes

Where is my balance stored?

Both wallets will scan the relevant parts of the public  transaction-journal ("blockchain") to add up the amount of money controlled by the keys derived from your backup phrase - this total is your balance.
Wallets are very likely to store this total locally, as a convenience, so they don't have to re-scan the blockchain and add up the total all over again every time the wallet is opened. Exactly where and how this number is stored is likely to vary depending on the software used. The storage of this total is of no real consequence.

if I send from (A) to a friend's wallet (Z), would my reduced balance also show on (B)?

Yes, both wallets will learn about new confirmed transactions that affect your balance.
Wallet A might show the transaction amount as pending until it receives a confirmation, a confirmation is just a new block appearing in the public transaction journal that either contains the transaction in question or which builds on top of such a block. Wallet B learns about the confirmation in the same way and will similarly notice that the block contains a transaction that affects an amount associated with an address derived from your backup phrase. The mechanism is the same for both wallets, Wallet A has no special privileges.
To elaborate a little:
As Murch noted in a comment, wallet A might have some additional information that doesnt get transmitted to wallet B. This is information which isn't transmitted to the rest of the Bitcoin network and which has no effect on validation of a transaction or on the mining process by which payments are considered to be confirmed. One example is if you choose to add a memo "payment for new trinket" to the transaction, this memo is not transmitted to anyone else and so is not known to Wallet B (or anyone else). It is also lost if you destroy wallet A and re-create it (e.g. by deleting an app and associated data and then reinstalling the app and using the old backup phrase). If your wallet A allows you to organise transactions into accounts, wallet B wouldn't automatically know about those accounts. Similarly, if wallet A is a Lightning-capable wallet, Wallet B wouldn't normally know about the lightning transactions that Wallet A made, only about the final on-chain settlements made e.g. when a lightning channel is closed.
However Wallet B should still normally show that same total as Wallet A for total amount of Bitcoins that the basic Bitcoin network and it's public replicated transaction-journal ("blockchain") consider to be controlled by private keys which are in your wallets A and B.


How to create a bitcoin clone? I'm still new to all this, but would like to know how to make a clone of bitcoin, including required files and sources.
Thanks

Register at github, go to https://github.com/bitcoin/bitcoin and press "fork"


How safe is it to use online wallets? I want to know if it is safe to use online wallets? Can we trust online storages which stores our privkeys, passphase and wallet.dat files?

I read that at least one android wallet was hacked so I think this is not safe when private keys stored into foreign remote storage. Maybe I misunderstood something?

Holy war question in fact.

Yes, using online wallets means that you trust their developers. But the same situation is in standalone applications - you should trust their developers.

Many online wallets do not store your private keys. But it does not mean that they do not have an ability to steal/lose your funds


OP_RETURN malleability? Can anyone alter the data after OP_return?

My question needs to have more characters, so I insert an example, that doesn't hurt:

"vout" : [
    {
        "value" : 0.00000000,
        "n" : 0,
        "scriptPubKey" : {
            "asm" : "OP_RETURN 636861726c6579206c6f766573206865696469",
            "hex" : "6a13636861726c6579206c6f766573206865696469",
            "type" : "nulldata"
        }
    }
],

The OP_RETURN is in the scriptPubKey, which is signed as part of the transaction, so it can't be altered. So it is not malleable.

The known types of malleability are described in BIP 62.


A security need for Bitcoin to fork to quantum resistant algorithm in a few years? in just a few years I believe that quantums will exist that break asymmetric ciphers, and bitcoin is based on asymmetric ones like public-key-cryptography, correct? Symmetric algorithms are supposed to be safe.

Question is to experts here:

1) Which components of the bitcoin blockchain would be exposed to quantum attacks?

2) Are these components relevant the the blockchain's full functionality if they get "broken" or just minor nuisance but no major negative impact?

3) What do bitcoin (core)devs brainstorm currently, what could be feasible methods to make these above components more resistant against quantums?

Thanks for insights

asymmetric ciphers

Ones based on specific primitives, like RSA and ECDSA specifically.

  Symmetric algorithms are supposed to be safe.

With approximately half the number of bits of security due to Grover's algorithm.

  Which components of the bitcoin blockchain would be exposed to quantum attacks?

The security of SHA256 would be halved, ECDSA would be weaked beyond usability. In Bitcoin raw ECDSA keys are typically only exposed during the portion of time when the transaction is signed and when it is confirmed, assuming that there are not large chain reorganisations ("double spending") during this time, the window of opportunity is relatively limited.

Due to the way many pieces of software re-use keys, this is not the case for a large portion of the total Bitcoin in existence however. More than 10B USD worth of UTXOs are stored in addresses with known ECDSA public keys, which would be the obvious target for anybody to steal.

  Are these components relevant the the blockchain's full functionality if they get "broken" or just minor nuisance but no major negative impact?

Generally speaking, all money would be vulnerable to being stolen without consequence or interaction from its owner.

  what could be feasible methods to make these above components more resistant against quantums?

Bitcoin has upgrade paths available to it to use quantum safe cryptography like hash based signatures if such a thing were necessary in the future, but there's not a lot of strong evidence to suggest that true quantum computers that are capable of running the sort of algorithms will ever exist. We would expect to see gradual progress towards it rather than a definitive success story about it anyway, which gives a lot of room for making these sorts of changes.

Why don't we use hash based cryptography today? It's fairly awful and to be avoided unless necessary.                           Signatures are extremely large, public keys are even larger, and they don't allow for interesting constructions like is the case with ECDSA / Schnorr.


Can you generate a url from a payment request? I am writing a java webserver that can use bitcoin as a payment method. Thanks to the helpful advice in this question, I am able to generate payment addresses for various signed up vendors. I am now taking that address and creating a Payment Request using the bitcoinJ library. I would like, however, to have this request as a meaningful URL still, so the web browser or client making the payment can do something with it. That is to say, I create the payment request on the server and return it to the client. The client can then put that request in their wallet of choice and make a payment.

Is the payment request able to work that way? I saw this post on stackoverflow that indicates that it can, however I haven't been able to see anything within the API I am using that can do that. Is that a limitation of the specification, the library I'm using, or is it possible to do?

You can. If you make a Bitcoin URI with the r parameter, it will interpret that as a url to fetch the PaymentRequest from.

Documentation on this feature is frustratingly sparse, so I'm having trouble figuring out how to implement all of the details, though.


How is Bitcoin itself represented (either technically or code level) I've gone through dozens of videos and texts, but haven't found properly how is the actual bitcoin itself represented technically or at code level?

From what I have understood thus-so-far (if correct), is that a single bitcoin itself is NOT represented by any class/object at code level (or technically NOT represented by a unique ID like fiat money has printed on it), but rather bitcoin is ONLY a figure that's stored in a distributed ledger (blockchain).  And that the creation of a 'new' bitcoin is out of thin air as a reward for verifying transactions together with proof-of-work (i.e. solving a math problem in order to delay the broadcast of verification of transactions) for security purposes (and thus NOT as some put it to discover new bitcoins - as no bitcoin has a permanent unique ID to be discovered).

Is there a bitcoin expert or bitcoin developer that could verify (and possibly add more info) if my understanding is correct, and if not, to please explain how bitcoin itself is represented either technically or at code level (and it will help me understand more clearly if you could also explain the technically process of the creation - or the so-called discovery) of 'new' bitcoins in a way that's related to this question)?

Thanks.

these questions would justify a whole section of a book. To avoid this, I put a link at the end of the message. In between, I'll try to answer some parts of your question.

  I've gone through dozens of videos and texts, but haven't found
  properly how is the actual bitcoin itself represented technically or
  at code level?

That is a known problem with all these videos. It is not sufficient :-)
The bitcoin is represented as data in the blockchain. Effectivly, a transaction moves bitcoins around, taking transaction from an address, sending it to a new address. When you take a look at some bitcoin explorers, they provide details, e.g. here as an example. To answer your question, you'd need to understand the details presented in this transaction. In short: you'll discover 2 inputs and 4 outputs. This is, what moves the Bitcoins (or Satoshis). Many transactions can then be combined into a block, which then create the blockchain.

  From what I have understood thus-so-far (if correct), is that a single
  bitcoin itself is NOT represented by any class/object at code level
  (or technically NOT represented by a unique ID like fiat money has
  printed on it),

yes, I mean, no serial number on it. But programming wise (there are dozens of implementations), you could think of a class "bitcoin". The default core code has no such thing, code reference is here.

  but rather bitcoin is ONLY a figure that's stored in a distributed
  ledger (blockchain).

yes

  And that the creation of a 'new' bitcoin is out of thin air

well, thin air is often a repeated idea, which sounds like discrediting distinction to the FIAT world. But effectivly you have to do some work ("mining"), which costs a lot. So thin air is probably wrong.

  as a reward for verifying transactions together with proof-of-work
  (i.e. solving a math problem in order to delay the broadcast of
  verificationof transactions) for security purposes (and thus NOT as
  some put it to discover new bitcoins - as no bitcoin has a permanent
  unique ID to be discovered).

somehow - please read chapter 10 of the refenced book :-)

  to please explain how bitcoin itself is represented either technically

Yup: here is Andreas wonderful book "Mastering Bitcoin", which has lots of examples relevant for developers.
My proposal to you: start to evaluate transactions in detail (Chapter 6), and work over into wallets and keys. This gives you the picture within 2-3 hours. And then you probably get the idea. Otherwise you extend your question here, or raise a new question :-)


How to attach an encrypted message to a payment transaction inside a contract? How can I attach an encrypted message to a payment transaction from inside a contract? In release 2.2.0e it was possible by just calling the SendMoneyCall API with .messageToEncrypt:

SendMoneyCall sendMoneyCall = SendMoneyCall.create(<chain id>)
        .recipient(<recipient account>)
        .amountNQT(<amount>)
        .messageToEncrypt("test message");

this doesn’t seem to work in version 2.2.1.
Do I have to do it manually now? Like first encrypting and compressing the message and then adding it to the transaction via sendMoneyCall.message(“test message”)?

I've asked this question in ardors slack developer channel and post it here for documentation. After a small dialog in which I detailed the occurring error with a small example contract I got an explanation with a working solution:

About the messageToEncrypt parameter, the problem is that when a transaction is submitted by a contract it is first generated without a secretPhrase then signed and broadcasted. This means that message cannot be encrypted when the transaction is generated.
Therefore to submit an encrypted message in your contract you need to encrypt it yourself using the technique in sample contract IgnisArdorRates line 94:

   // Encrypt the message
   EncryptedData encryptedData = context.getConfig().encryptTo(Account.getPublicKey(context.getSenderId()), Convert.toBytes(response.toJSONString(), true), true);

   // Send a message back to the user who requested the information
   SendMessageCall sendMessageCall = SendMessageCall.create(context.getChainOfTransaction().getId()).recipient(context.getSenderId()).
           encryptedMessageData(encryptedData.getData()).
           encryptedMessageNonce(encryptedData.getNonce()).
           encryptedMessageIsPrunable(true);
   return context.createTransaction(sendMessageCall);

I've adapted my example contract according to this answer and post it here to share the solution:

example contract:

package com.jelurida.ardor.contracts;

import nxt.account.Account;
import nxt.addons.AbstractContract;
import nxt.addons.JO;
import nxt.addons.TransactionContext;
import nxt.crypto.EncryptedData;
import nxt.http.callers.SendMoneyCall;
import nxt.http.responses.TransactionResponse;
import nxt.util.Convert;

public class TestContract extends AbstractContract {

    @Override
    public JO processTransaction(TransactionContext context) {
        TransactionResponse transaction = context.getTransaction();
        EncryptedData encryptedData = context.getConfig().encryptTo(Account.getPublicKey(context.getSenderId()), Convert.toBytes("test message", true), true);

        SendMoneyCall sendMoneyCall = SendMoneyCall.create(transaction.getChainId())
                .recipient(transaction.getSender())
                .amountNQT(transaction.getAmount())
                .encryptedMessageData(encryptedData.getData())
                .encryptedMessageNonce(encryptedData.getNonce())
                .encryptedMessageIsPrunable(true);

        return context.createTransaction(sendMoneyCall);
    }
}

unit test:

package com.jelurida.ardor.contracts;

import nxt.addons.JO;
import nxt.blockchain.Block;
import nxt.blockchain.ChildTransaction;
import nxt.blockchain.FxtTransaction;
import nxt.messaging.PrunableEncryptedMessageAppendix;
import nxt.util.Convert;
import org.junit.Assert;
import org.junit.Test;

import static nxt.blockchain.ChildChain.IGNIS;

public class TestContractTest extends AbstractContractTest {

    @Test
    public void encryptedMessageTest() {
        String contractName = ContractTestHelper.deployContract(TestContract.class);

        JO messageJson = new JO();
        messageJson.put("contract", contractName);
        String message = messageJson.toJSONString();
        ContractTestHelper.bobPaysContract(message, IGNIS);
        generateBlock();

        Block lastBlock = getLastBlock();
        boolean transactionFound = false;
        for (FxtTransaction transaction : lastBlock.getFxtTransactions()) {
            for (ChildTransaction childTransaction : transaction.getSortedChildTransactions()) {

                transactionFound = true;
                Assert.assertEquals("test message", extractMessage(childTransaction));

            }
        }
        Assert.assertTrue(transactionFound);
    }

    private String extractMessage(ChildTransaction transaction) {
        PrunableEncryptedMessageAppendix appendix = (PrunableEncryptedMessageAppendix) transaction.getAppendages().stream().filter(a -> a instanceof PrunableEncryptedMessageAppendix).findFirst().orElse(null);
        byte[] compressedData = appendix.getEncryptedData().decrypt(BOB.getSecretPhrase(), ALICE.getPublicKey());
        byte[] data = Convert.uncompress(compressedData);
        return Convert.toString(data, true);
    }

Hope it's helpful :).


Unable to transfer Bitcoin to USD I have Bitcoins in my Bitpay wallet that I need to cash out. I earlier assumed that a Bitpay wallet would have a linked Online Bitpay account. I gave my BitPay Wallet Address to a client who transferred bitcoins to my wallet. Bitpay Support says that they do not see any Bitcoins on my Online acc. How does this work? Bitpay is not clear about what they want me to do. Please help.

There is no link between a BitPay business account and a BitPay wallet. If you gave an individual a receiving address belonging to your wallet, then you should see the bitcoin arrive directly to your wallet.

If you were trying to have those funds routed through your business account, you should send your client a bill using the Email Bill tool or add a payment button on your website.  They can generate an invoice from the bill or payment button and when they pay the invoice, the funds are deposited to your BitPay business ledger and then settled through the settlement process.

If you need more information, please contact BitPay via the support form at https://help.bitpay.com/requestHelp.  There is also a lot of information about setting up your business to accept bitcoin as a payment option at the following link: https://bitpay.com/docs.


Why A Block have a Merkle root hash? That is the question, why a block needs to have a Merkle root hash, as Iundestand, once a block is mined the hash value of this block is stored at the header of the next one so, it generates the chain.

Is some data is changed, the hash will not be the same so, it is possible to notice that some data is changed.

So I see that storing the merkle root hash at the header of a block is unuseful as it is doing the same thing as hash pointer of the next block of the chain is doing

Every transaction has a hash associated with it. In a block, all of the transaction hashes in the block are themselves hashed (sometimes several times — the exact process is complex), and the result is the Merkle root.

In other words, the Merkle root is the hash of all the hashes of all the transactions in the block. The Merkle root is a part of the block header. With this scheme, it is possible to securely verify that a transaction has been accepted by the network (and get the number of confirmations) by downloading just the small block headers and Merkle tree – downloading the entire block chain is unnecessary. This feature is currently not used in Bitcoin, but it will be in the future.

UPDATE: This feature is currently used by lightweight bitcoin clients

  "Is some data is changed, the hash will not be the same so, it is
  possible to notice that some data is changed."

Yes if some data is changed then the Merkle root hash will be different.


What happens when "Request expires" in Electrum? If I understand correctly, wallet is a collection of private keys.

Electrum client, in "Receive" tab has this form to request money.
Every time new "Receiving address" changes, Electrum has to generate new sequence:

private key → public key → bitcoin address

What I'm unsure about, is whether Electrum ever deletes private keys that were generated, consequently making some bitcoin addresses it previously generated no longer controlled by me?

As long as you only work on the GUI, Electrum won't create private keys it doesn't generate again when you restore the wallet. On the console, you can increase the gap limit which can cause Electrum to not generate the private keys you already used to secure funds if you don't also increase the gap limit after restoring your wallet. But this doesn't mean your funds are lost, afterwards, if you keep the seed. For one thing, you can increase the gap limit in your stored wallet, for another thing, your funds will become "unlocked" after you used the restored wallet enough to make Electrum generate the private keys, again.

The "receive money" functionality of Electrum only is a built-in note program. You note for yourself that you're expecting a payment of 30 mBTC from Mark until January 18th. If he didn't pay until then, Electrum will tell you that his payment is overdue and you can get angry at him. However, Electrum has no means of sending Mark an email or something, and therefore doesn't do so. It's just notes for you. Furthermore, these nodes aren't restored when you restore your wallet via your seed as they remain on your computer and aren't sent to a cloud service.

And no, Electrum won't delete the private key corresponding to the public key corresponding to the address you noted as the receiving address, afterwards. That'd be a really bad thing. Just imagine, Mark is 10 minutes late with his payment. Then, the money he sent slightly too late would be lost forever.

You can even find this out for yourself: If you go to the tab "Addresses", you will see your wallet's addresses. The receiving address in the tab "Receive" always is the upper most unused and unmarked address, but the address is already there, before you create the receive note. And so, of course, is its corresponding public key and the private key which corresponds to that.

The only things happening when you tell Electrum that you plan to receive money, is that the note in the receive tab is generated and the address is assigned a label (which you can see in the addresses tab), which is just another local note.

You can of course hand your addresses out to people (in arbitrary order), without telling Electrum that you plan to receive money on them.


Can Initial Channel Balances be figured out from the Funding Transaction? The Initial Funding Transaction happens in Bitcoin and is linked to the Lightning Network.

Can an adversary figure out the initial channel balances by identifying the according Bitcoin Funding Transaction?

A funding transaction is one where some money is paid into a P2WSH transaction output, where the redeeemScript is a 2-of-2 multisig between the two participants. No other information is provided.

Technically, even the redeemScript for the funding is not revealed until the funding transaction output is spent (channel closed), which makes it less obvious that the unspent output is even a channel. Private channels are not known to be channels, and even when closed, are indistinguishable from any other kind of 2-of-2 multisig transaction.

For public channels, however, the redeemScript can be recreated from information published over Lightning's gossip network, making it possible for network participants to discover which transactions are public channel funding transactions.

There is no information regarding balances. The single funding transaction output has an amount representing the entire channel capacity. This is all that is known to anybody but the two channel participants.

The way channel opening works is that both parties create asymmetric initial commitment transactions, which spend the funding transaction with their previously agreed upon balances. This happens before the initiator reveals or broadcasts the funding transaction. The initiator creates (but doesn't broadcast) the funding transaction and only transmits its transaction id and output index to the other party. This information is sufficient for both parties to create their initial commitments which spend it, and to sign those commitments, but not sufficient for the other party to broadcast the transaction and lock up the funds before the commitments have been agreed. Once both parties have signed, the initiator then broadcasts the funding transaction and the channel is considered opened after it reaches the minimum confirmation depth.

It may be possible to determine channel closing balances based on the transaction which spends the funding output.


How to verify that downloaded files such as Ubuntu, BitcoinQT, Armory, and Electrum have not been tampered with? When creating a secure offline wallet, the first step is to download some software or OS (such as Ubunutu) to create the wallet.

How can you verify that the software you are downloading has not been tampered with?

Some downloads have a SHA of the file on the download page. But a hacker could  change the SHA on the download page. So how do you know that the file is not tainted and the SHA is the correct SHA of the tainted file?

For example, the download page for Armory has installer files and SHA's for some of the files.

How would you verify that the download of Ubuntu is not tainted?

It all depends on the security mechanisms of your operating system. On Ubuntu, packages are signed, and the installer checks the signature. So, a man in the middle, or a rogue mirror site could not have modified the copy of Electrum that I installed.

The safety of your bitcoins on your machine does not depend only on your bitcoin applications. If the operating system itself is compromised, it can steal your bitcoins (using a keylogger to find the possible passwords) so pay attention to use a safe operating system, with security updates and so on.


Setting up Statistics with litecoin-qt or bitcoin-qt I'm trying to set up a bitcoin/altcoin pool server, but I've run in to a bit of a problem, I have no way to verify I've connected to the pool succesfully, and no stats or informations on the actual pool operations. Is there some way I could find these stats in litecoin-qt or bitcoin-qt? The getinfo command seems to only return stats about the client, versus the actual pool info. I'd also like to have them generated automatically vs having to calculate myself.

Dylan, i suggest you do a lot more reading before you attempt to run a pool. A pool is not an easy job, you need an in-depth knowledge of bitcoin/c++/python etc. It's not simply cut and paste.

Unfourtunately from waht i am reading you are only running a coin daemon as your pool node which won't work for a pool. check out how to install mmcfe for litecoin. that should help you out


Is there any link between Bitcoin's PoW and BFT? As per Bitcoin's documentation, the consensus mechanism in Bitcoin Blockchain is based on PoW.  Thus, any miner node successfully computing the hash as per difficulty is eligible to mine a block and also validate all transactions included in the block. Now, once the block is mined, all full nodes check the validity of the computed nonce and also validate the transactions based on the complete history of transaction input and output. My question is that is there any relation between PoW and typical Byzantine Fault Tolerance used as a state replication protocol?

PoW achieves the same outcome as BFT. However, the way in which they arrive at the same outcome is different. PoW is for environment where there are untrusted actors. Unlike BFT protocols where it is semi-trusted.


When do miners stop waiting for new transactions? I know my question might sound familiar to the question as follow:
When does a miner decide to stop collecting transactions and start calculating hashes to try to win?

But actually, the reply marked as answer in that topic didn't answer the question: when will miners stop waiting/listening to new transactions?

According the answer in the link above, miners will start calculating nonce number but as far as I know, the nonce number is result of hash calculation of block header. Since the block header contains the hash of the merkle tree's root which is generated by all the transactions included in the block, so waiting and adding new transactions means the hash of the merkle tree's root will keep changing so how can miners determine to stop and concentrate in 'mining' the nonce from a stable source of transactions (or merkle tree's root hash)?

Let's simplify the questions by an example in case you cannot understand my language: miner A receives transaction a1 and then start calculating the nonce number for 1 minute (let's assume that in this period of time, there's no new transactions come and interrupt the process) but then a transaction a2 arrives, what will miner A do? Adding a2 into the candidate block, getting new hash of merkle tree's root and restarting to find the nonce number? Or just ignore the transaction a2? If A chooses to ignore new transactions to be included, can anybody tell me when it will do that (assume all of the transactions collected are not larger than the MAX_BLOCK_SIZE constant)?

Any replies or explainations for some of my questions are highly appreciated. Thank you!!

They were never "waiting" in the first place.

A miner is incrementing nonces and computing hashes continuously.  As soon as a new transaction a2 arrives, it is added to the Merkle tree, the block header is regenerated, and hashing continues with the new block header.

It's misleading to call this a "restart", since that implies there was some progress that is being lost.  Mining is progress-free.  Each hash is an independent trial with equal probability to succeed, regardless of what the underlying block header is.

To emphasize this, suppose you have a block header h1 on which you have already tried a billion nonce values, and a header h2 which has just been generated and on which no nonces have been tried yet.  If you have the choice as to which one to hash next, which should you choose, for the greatest chance of finding a winning nonce?  The answer is, it makes no difference - they both have exactly the same probability.  So there is no harm in switching to h2.


How are messages exactly sent in bitcoin p2p protocol In order to send a NetMsgType::PING message to a node pnode, we simply invoke the function pnode->PushMessage(NetMsgType::PING) in src/main.cpp

This translates into following logic in src/net.h:

void PushMessage(const char* pszCommand)
{
    try
    {
        BeginMessage(pszCommand);
        EndMessage(pszCommand);
    }
    catch (...)
    {
        AbortMessage();
        throw;
    }
}

If we look carefully, the BeginMessage and EndMessage are just for acquiring and releasing the lock. Where exactly is the PING getting passed to the other node? I think the working is similar for other message types but the overloaded function PushMessage may use a Datastream which I guess does the passing to requested node. But I am particularly clueless about cases like NetMsgType::GETADDR, NetMsgType::VERACK and old version without nonce of NetMsgType::PING where there is only the command string pszCommand being passed

I got the answer myself. Sorry!

The src/net.cpp has this logic which explains all:

void CNode::BeginMessage(const char* pszCommand) EXCLUSIVE_LOCK_FUNCTION(cs_vSend)
{
    ENTER_CRITICAL_SECTION(cs_vSend);
    assert(ssSend.size() == 0);
    ssSend << CMessageHeader(Params().MessageStart(), pszCommand, 0);
    LogPrint("net", "sending: %s ", SanitizeString(pszCommand));
}


Are Web Wallets Secure? I normally keep only small amounts in a web wallet because I heard that web wallets are not secure. The rest of my Bitcoins are kept in cold storage in my safe.

I'm just wondering if you have any experience with web wallets, if they have gotten hacked and/or if you think I should worry about it.

With web wallets you need to be careful. As you stated, if they get hacked and they store your private keys, your Bitcoins are at risk. You really just need to ask yourself:

how risk adverse are you?
can you afford to lose your coins?
does the convenience of a web wallet outweigh the risks?


Was libbitcoin a part of bitcoin core in the past? I am trying to use c++ code from the book of Antonopoulos for some time now and I seem to lack an include named bitcoin/bitcoin.hpp.

To compile the code the g++ compiler gets a pkg-config input with libbitcoin. So I suspect I would have to install this library.

Since the book does not mention to install anything else then bitcoin core I really wonder if parts of libbitcoin have originally been part of bitcoin core and have been excluded at some point.

The other explanation would be that the author forgot to mention it. But it seems a bit overload that I have to install another complete system for a full node (libbitcoin) to be able to run the code since the book explicitly says that running a full node with bitcoin core should suffice.

It is just a minor thing and probably laughable for an expert in the field but I am also learning how to use pkg-config and the compiler by doing this.

There have been suggestions to just install parts of libbitcoin but the developers said it is advisable to install the full thing with the automatic install skript.

Also, there is libbitcoin-dev, which is a package in debian (I run Raspbian Buster), but I was not able to compile the code with it.

libbitcoin is not, and was never a part of Bitcoin Core. Both are standalone implementations of the Bitcoin protocol.

Bitcoin Core, in its build process, will create a number of files named "libbitcoin_...". These are just locally generated files that are unrelated to the libbitcoin project.

Bitcoin Core does not have any files with the "hpp" extension. So are you sure you're actually trying to build Bitcoin Core?


What does DOA stand for? What does DOA stand for?

I've seen this in the context of P2Pool stales, specifically here.

Dead On Arrival. The term is referring to about valid shares your miner discovers that were found too late to be included in the P2Pool internal block chain and therefor aren't paid to the miner. Counter intuitively a DOA share can still be a valid Bitcoin block.


How can the government tax you using bitcoin Bitcoin is decentralised and anonymous so how can governments issue /enforce taxes on any transactions made with bitcoin?

Governments can set up laws and regulations and then set up "departments" to monitor and enforce.

Whether it is successful or not is another question. No doubt they will have to skill up and understand how digital currencies really work, maybe monitor a few people, monitor the flow of their btc's and audit them, create some "high profile" cases to be made examples of etc.

One can draw an analogy with cash.