Is Bitcoin future-proof? As I understand things, the security and integrity of Bitcoin rely on the assumption that its hashing is "hard" in some sense.  However, in the past, processing power has increased exponentially.  This has made some problems solvable in a reasonable amount of time that were not solvable before.  How does Bitcoin account for the possibility that processing power will continue to increase in the future?

BitCoin is futureproof, because in the event that processing power (or more relevantly, mathematical advances) make its algorithms weak or obsolete, the protocol can simply be upgraded.

Copied from Stack Overflow:

Upgrades to the Bitcoin protocol that break compatibility are implementable by social mechanisms but not by any technical process, which is by design.  In order to change the hashing or signing algorithms in the event that new techniques weaken them, the following process could be followed:

As soon as the existing algorithms are discovered to be weakened, have a trusted entity sign a copy of the existing blockchain, marking it as authoritative via a non-weakened algorithm.
Create a new protocol that 'respects' the existing blockchain (which contains all records of bitcoin ownership), and allows for an upgrade path to exist indefinitely.
Implement the new protocol dormantly in one or more clients, with a designated block number to switch over, and the trusted version of the blockchain hardcoded in.
Convince the vast majority of Bitcoin users that your trusted entity is trustworthy, and to switch to the new client(s) before the designated block is mined.  There really is no equilibrium allowing both versions to coexist, since people who own bitcoins will be able to spend them in both communities.  Unless the modified client achieves near-universal adoption before the designated block is mined, users will switch back before the change goes live.


How can I copy an address (with the private key) using JSON-RPC? I need to be able to create an address in 2 different Bitcoin-qt instances (actually 2 different PCs).

I can create it using "getnewaddress" on the first one but how can I import it to the second one with the private key?

Thank you!

Check this section out: https://en.bitcoin.it/wiki/How_to_import_private_keys#Using_bitcoind

Essentially you can use importprivkey

$ bitcoind help
[...]
  importprivkey <bitcoinprivkey> [label]


Multibit : transferring coins between local wallets I've created a second local wallet in my multibit. The first wallet is aimed for receiving and sending coins, while the second one is aimed to separate savings.
Is there a way to transfer coins between these two local wallets without paying fees ?
It is possible in a normal bank account but the fees here are really too big.
Thanks for your help :)

You need to send the coins to an address in your second wallet.  MultiBit maintains each wallet as a separate file on disk, so there is no interaction between them.  One suggestion (which is how I handle this) is to wait until your wallet reaches a large enough amount and then make a single send request to your savings address.  This bundles multiple input transactions into a single output transaction with a single fee.


Destination Tag of Ripple Desktop Wallet I want to withdraw some xrp from an exchange and deposit to my Ripple desktop wallet. I know the address to deposit, but what is the destination tag? The exchange does not let the destination tag to be empty? What should I enter in this field?

I've never seen an exchange that required a destination tag even when sending to an account that doesn't require one. But any destination tag will do. The destination tag just tells the recipient account holder who to credit for the payment. But you are the recipient account holder, so you don't need this information. Entering one should be fine.


How does the prune target size work? Judging from the docs I understand that pruning, in laymen terms, only allows to get rid of information that cannot have any follow up transaction.

Now, how/why is it possible to set the prune option to a custom value?

What if 550 MiB would be too small, "cutting out" important information?

Judging from the docs I understand that pruning, in laymen terms, only allows to get rid of information that cannot have any follow up transaction.

That's incorrect.

The process for block validation (simplified) is:

Receive a block
Find all the block's inputs in the database of unspent outputs (the "UTXO set"), and verify them (signature checking etc)
Remove all the block's inputs from the UTXO set (as those outputs now become spent)
Add all the block's outputs to the UTXO set.

Once a block has been validated, and its effects been applied to the UTXO set, we don't generally need the contents of the block anymore, at all. Except for:

Giving it to other nodes on the network that are trying to figure out what happened in the past (which you can't do yet when in pruning mode)
Rescanning to find historical transactions in the wallet (e.g. after importing an address or a key), which is a feature you give up when pruning.
Reorganizations. Sometimes a block is found that is not a successor of the previous block we saw, but one that branches off further back. In this case we need to be able to roll back the effects of the last block(s) before validating the new block(s). In order to roll back, we do need the contents of the blocks again. This is the reason why the client forces you to keep at least 550 MB of block data, so that you can always rewind the last few days.

So TL;DR: It's technically possible to create a client that prunes to an arbitrarily small value, but to prevent clients from tripping over when a reorganization happens, the code forces you to keep a few days worth of data regardless.


Do I need to open the client(I use multiBit) while transaction is being confirmed? Do I need to keep the client(I use multiBit) running while transaction is being confirmed? I have started a transaction at 1:00 nignight, when I get up at 6:00, it still didn't finish! they say a transaction need 6 confirm witch cost about 1,5 hours.

No need to keep the client open. Whatever client that is.
The confirmations take place in the bitcoin network, not locally.


cpuminer json rpc call failed root@i-M116V:/var/www/cpuminer-2.2.3# ./minerd
[2013-12-27 15:22:35] 2 miner threads started, using 'scrypt' algorithm.
[2013-12-27 15:22:35] Binding thread 1 to cpu 1
[2013-12-27 15:22:35] Binding thread 0 to cpu 0
[2013-12-27 15:22:35] HTTP request failed: Failed connect to 127.0.0.1:9332; Connection refused
[2013-12-27 15:22:35] json_rpc_call failed, retry after 30 seconds

I'm using a laptop with no GPU.

root@i-M116V:~# netstat -anp | grep 9332
root@i-M116V:~#

i@i-M116V:~$ cd /home/i/デスクトップ/cpuminer-master/cpuminer
i@i-M116V:~/デスクトップ/cpuminer-master/cpuminer$ ./minerd -o ltc.give-me-coins.com:3333 -u sukarutinohu.1 -p 1

You should sign up for a pool service and configure minerd to send shares to that service.  Right now it is attempting to connect to a local instance of a scrypt coin (litecoind I would presume) on port 9332 for solo mining.  If that is what you intended then verify that you have a server running and listening on that port.  It is also not recommended to run minerd as root in case theres is a remote buffer overflow vulnerability in the application.  You can check by executing the following command:

netstat -anp | grep 9332

This will tell you what application had that port open if any does.


What are the web3py equivalent for communicating with bitcoin in Python? I am fairly new to working with Python, I have a requirement where I need to perform some basic bitcoin operations on my local system rather than relying on some external API's, those function mainly include :

1. Wallet Creation

2. Address Creation

3. Transaction signing

For other operations, I am willing to use external API's like blockcypher. I need the above operations to be performed locally so to ensure some security. FOr ethereum I use web3.py which provides me these functions.
Can anyone help me with the same for bitcoin?

Libraries like Web3py or Web3js are connected to a node using JSON-RPC behind the scene. I am not aware of any library for bitcoin like Web3py. But Bitcoin do provide JSON-RPC interface, which you can use to perform these operations.


secret sharing scheme for 3-of-5 shares (for BIP39 mnemonic phrase of 24 words) Given a 24 word BIP39 mnemonic phrase, I would like to have a way to split it into 5 shares, so that any 3 would allow me to reconstruct the phrase (but any less than 3 would not).

This is easy enough to do with Shamir Secret Sharing, and very secure. But that requires, at the minimum, a computer, and I would rather have a way to achieve the same (or something similar) with only a pen and paper (and let's say not more than an hour's work).

Now, I don't mind it being slightly less secure, in the sense that obtaining 2 of the 5 shares makes it easier to guess any of the other 3, as long as the difficulty is reasonable (e.g. 90 bits entropy). I feel like a 24 word phrase is really entropy overkill, and a third of that entropy is, by itself, quite a lot and sufficient for my purposes.

Ideas?

Figured out a solution that can easily be done with a pen and paper and at most a pocket calculator.

You take your secret (264 bits) and divide into 6 equal-length parts. Call them A, B, C, D, E, F.

For brevity I write XY as meaning X xor Y.

Share 1: A,B
Share 2: C,D
Share 3: E,F
Share 4: CE,AF,BD (remember these are xors)
Share 5: ABCE,ACDF,BDEF

Now with a bit of xoring any 3 of these give you the entire secret. I'll write a proper blog post with instructions exactly how to combine shares and a proof that it's reliable.

Downside is that unlike SSSS, each share is only 1/3 of the entropy, so if someone has two of the five shares, it's only 2**88 attempts to guess the third. Still, 88 bit entropy by itself is not bad at all, at least in my book.

Also, unlike SSSS, the "order" of shares is important. You need to note beside each share which it's supposed to be (S1, S2...) so you know what sort of xoring to do.

What do you think? Any other weakness in this?


How to fetch the latest unspent transaction by an address using bitcoind? I want to build a server, which provide following APIs:

1.Get balance by address.
2.Get latest unspent transaction.
3.broadcast the transaction.

First by first, I know I can do above stuffes by blockchain and coinb, but I want to build my own APIs. What I have tried with the Python code has list as below:

import binascii
import json
from decimal import Decimal
from pprint import pprint
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException
from config import ConfigBasic

class BitPort(object):

    def __init__(self, config=None):
        self.conf = ConfigBasic()
        # pass
        self.rpc = AuthServiceProxy("http://{}:{}@{}".format(
        self.conf.rpc_user, self.conf.rpc_password, self.conf.rpc_host))

    def get_amount_by_addr(self, addr):
        return self.rpc.getreceivedbyaddress(addr)

    def get_unconfirm(self, addr):
        return self.rpc.getunconfirmedbalance(addr)

    def get_unspent(self, addr):
        """
        @param addr: A array with address, ["0xxxxxx", "0x122222"]
        """
        return self.rpc.listunspent(0, 999999, addr)

    def sign_rawtransaction(self, addr):
        fee_obj = self.rpc.estimatesmartfee(6)
        fee = fee_obj.get("feerate")

    def sendrawtransaction(self, address, pubkey):
        pass

if __name__ == '__main__':
    addr = '2NCTreR1GmHXMNSYnt2J76QZgv8PH1k4PHB'
    addr = '2MsHfXEmutS2GWPgK55JD4i1gKSFYmJgKXv'
    addr = 'n2eMqTT929pb1RDNuqEnxdaLau1rxy3efi'
    bp = BitPort(config=ConfigBasic)
    print(bp.get_amount_by_addr(addr))
    #print(bp.get_unconfirm(addr))
    print(bp.get_unspent([addr]))

Let's say, Why I need to do such stuff. The client-side need to check how many money are available. so I need to provide the 1. The client-side also want to send its money to someone else, so I need to broadcast its transaction to the public's chain, but before do that, I the client-side need to make a transaction hex, which require the server side provide an API to get the unspent transaction. Why?

Because make a raw transaction need the following at least:

1.vout (from unspent transaction)
2.txid (from unspent transaction)
3.amount (user custom)
4.fee (default value is ok)
5.public key (client side store or calculate it by itself)
6.private key client side store or calculate it by itself)

From many tutorial, like How to create a raw transaction, which is good. but didn't mention how to get an unspent by a address. which don't store inside the bitcoind side.

Unfortunately, I can only fetch all transaction by my wallet's address, which live in the bitcoind node. Once I tried the someone address, and I got the following exception:

Traceback (most recent call last):
  File "core.py", line 43, in <module>
    print(bp.get_amount_by_addr(addr))
  File "core.py", line 17, in get_amount_by_addr
    return self.rpc.getreceivedbyaddress(addr)
  File "/Users/frank/venv/bitcoin/lib/python2.7/site-packages/bitcoinrpc/authproxy.py", line 141, in __call__
    raise JSONRPCException(response['error'])
bitcoinrpc.authproxy.JSONRPCException: -4: Address not found in wallet

BTW, I run it on testnet, Anyone help me?

Bitcoind does not index transactions for non-wallet addresses. If you wish to build this yourself, you will need to:

Enable txindex=1 in your bitcoin.conf
Rescan the chain
Set up blocknotify and then parse the chain block by block, building an index of which outputs have been spent, and which haven't, and which addresses are involved in each transaction

Then, when working with a specific address, you first query your database for all unspent outputs, and then can use getrawtransaction to get the unspent tx information (although, you could store enough information in your index to not need to make the getrawtransaction call).

Alternatively, you can run something such as ElectrumX or insight, which will do all of the above for you.


Retrieve last x transactions from multiple wallet I create an app which allow each user to own 20 wallets that support 20 coins (btc, eth, monero, neo etc), as well as support but BTC with USD.

IF i want to retrieve last 10 transactions of user (of all coins, which include deposit, withdrawal and buy BTC with USD) based on latest date, how should it be done best?

I am thinking of firing 20 api query to get wallet transaction history, along with another api to get the buy BTC with USD from my database, and finally filter the result but i don't think it is a good way.

Deposit ETH  50
Withdraw ETH 100
Deposit BTC 100
USD<->BTC conversion 100

Idea: Every transaction received on any wallet goes to a local database with a time stamp. That local database might just be 100 entries long. In the overview over all wallets you display info from that database.


Why are there two byte sizes for timestamps in the Bitcoin protocol? Reading Block Headers on the Bitcoin wiki, I learned that the timestamp in a block header is four bytes, and the timestamp in the "version" message is eight bytes. Why are there two sizes, and why isn't it more consistent?

This was discussed in the mailing list a while back:
http://sourceforge.net/mailarchive/message.php?msg_id=30824341

I'm guessing 32-bit timestamp was used by Satoshi in the original client and the 64-bit timestamp was introduced later to avoid timestamp overflow.

We may need to change (hardfork) the old 32-bit timestamp fields to 64-bit at some point. See https://en.bitcoin.it/wiki/Hardfork_Wishlist


incorrect passphrase Here's goes the steps that lead me to a wallet passphrase error:

OS: Mac Mojave (64bits)

Started bitcoin-qt app to sync (long outdated)
While managing to solve disk size errors (external drive), I updated bitcoin-qt to the latest version (18), but not sure what the previous one version was (perhaps 16.0).
As soon sync finished, I choose to encrypt my wallet :(.
I saved my passphrase, as it was created (100% sure!). To make sure it works, I changed the passphrase twice, but making sure the last change was the one I saved previously.
As bitcoin base was huge in my external drive, I set prune mode on (550).
All set, asked to received from my exchange.
Finally, when I tried to send the received amount, bitcoin-qt asked me the wallet passphrase, were I got the wrong passphrase error...

Is the only cause for that the wrong passphrase ? I mean, I'm sure I have typed the right one...

I'm assuming you've already tried caps lock, the intermediate passwords you used etc.

Ideally you would backup your wallet before making changes such that you have a library of them: wallet.dat.1jun2018, wallet.dat.2jul2018 etc. Then if something goes wrong, you already know that the previous copy of the wallet is still available.

I can't tell what's gone wrong for you from your description above, but OSX Mojave does offer some facilities. First, you MUST copy your wallet as it currently stands - even though you don't have the password - to an external disk, date it as above. Then use Time machine even if you haven't been using it to have a look at the folder ~/Library/Application Support/Bitcoin. Mojave stores local backups on your computer "even when your Time Machine backup disk isn't available." You're hoping to see that wallet.dat is available from a date prior to the encryption.

If it is, then you might try restoring it. Also copy it under a new name to your external disk. You might be lucky enough that bitcoin-qt works straight away without the password. If you can restore a previous version but cannot seem to use it, things start to get a lot more tricky, very quickly.

If you don't have the local backups, or the wallet isn't within it, I would turn the computer off and sleep on it. When you get up, write down everything you did, every password you tried, in the hope that something jogs your memory.


Fast way to get details of all transactions in a block I would like to extract all transactions in history.
What I'm presently doing is calling getrawtransaction and than decoderawtransaction for each transaction in the block. This works, except that the extraction process takes forever.

Is there a faster way to do this?

Use getblock with verbosity level 2. e.g.

getblock 0000000000000000000cedb96c93635edfb2755a3357e7febe5929fb6db1658d 2

This will return the block with all of the transactions already decoded.

Since you mentioned that you are doing getrawtransaction and then decoderawtransaction, getrawtransaction has another parameter to decode a transaction for you so you don't have to go to decoderawtransaction. You can do something like

getrawtransaction 0374d2bab7ce78429dc8660fb0100f260e1528dca4854ca7d761dd849211ff75 true

Lastly, most RPCs have a set of options with a description of what they do and an explanation of the output. You can do something lie

help getblock

to get the help description. In the future, you can do this for any command that you are using so that you can use it to its fullest potential.


When will my no fee transaction come back? i've sent bitcoin with 0 fee 2 weeks ago.
but it doesn't come back.

i saw unconfirmed transactions coming back in 72 hours.

Is there a way to solve it other than double spend?

https://blockchain.info/ja/tx/0e846d7d4ea858cee2e6ba5915caffaa9628f60c120b4a5e6a493dc74f7ec58a

It generally "comes back" in a week or two. Actually the transaction gets discarded by the mining nodes from their memory pools. Until then, your transaction is stuck.
However it depends on the wallet software as well if they let you spend it.
I had complete control over the addresses I was using so it was easier for me to retrieve the funds.


What testnet environment and configuration for Bitcoin? Every tutorial I have gone through to download bitcoind, I haven't been able to complete because my computer can't handle the full node download.

These are my specs:
2017
Processor - 2.3 GHz Intel Core i5
Memory - 8 GB
Storage: 50.8 GB available.

What's the lightest way I can run testnet so I can develop applications / hardware with the protocol but not buy new hardware (can't afford it)?

Many thanks for any suggestions.

You can run your node in pruned mode if storage is your concern. Reduce Storage

If you want to try to use bitcoin on testnet you can use Electrum wallet.
Be sure to download it from their official website https://electrum.org/. (Do not download Electrum from another source than electrum.org, and learn to verify GPG signatures.)


What are some examples of previous first contributions improving Bitcoin Core tests? I have heard that improving the Bitcoin Core tests is a good way to start contributing to Bitcoin Core. What are some good examples of previous first contributions to the tests to take some inspiration from?

PR #8836 was one of John Newbery's earlier contributions to Bitcoin Core. He introduced this code so that bitcoin-util-test.py would fail when the output_cmp file is empty.
if not outputData:
            print("Output data missing for " + outputFn)
            sys.exit(1)

PR #16445 was Fabian Jahr's first contribution to Bitcoin Core. One particular test (checking that an unknown message type would result in a disconnect) had been highlighted as flaky on MacOS and so Fabian wrote some code to wrap the test in an if, else statement so that it would be skipped when on MacOS.
if sys.platform != 'darwin':
.....
.....
else:
    self.log.info("Skipping test p2p_invalid_messages/1 (oversized message) under macOS")

PR #20023 wasn't a first contribution but was a neat contribution nonetheless. theStack used vulture via the following script to find constants in the functional tests that aren't used anymore.
#!/bin/sh
for F in $(git ls-files -- "*.py"); do vulture "$F" | grep "unused variable"; done


How do you make bitcoins bought from a exchange anonymous? Contrary to what most people think, bitcoin is not 100% anonymous. It is pseudonym.

Now, let us say you bought bitcoins from a exchange. The exchange has your government issued ID. Then you send your bitcoins to a offline wallet.

Now, the blockchain has a record of the exchange sending you bitcoins to your wallet, and the exchange has a record of what offline wallet is linked to you.

How do you effectively separate this link?

My theory is that you can send your bitcoins from your offline wallet to a bitcoin casino site, then withdraw your balance to another wallet.

Would that remove all the links to your bitcoins from your ID/make it impossible to trace back to you?

You should do some mixing transactions in between, I would recommend Wasabi Wallet or JoinMarket. They are both decentralized solutions, where you don't risk loosing your funds, like it is with centralized tumbling services.


How do I call JSON RPC API using C#? How do I access the JSON RPC API in C# in such a way that I can also read the errors that the interface provides?

I use the Newtonsoft.Json.Linq library as shown below to get the data.  Soon, I'll be posting Strongly typed C# client libraries at http://www.coinapi.net

The main trick to getting the JSON error code is to call GetWebResponse() again in the catch method.  Then return and parse the data.  I've debated about including the WebException itself in the return code, but that may require too many changes. If anyone has ideas I'll be glad to take them.

        var ret = InvokeMethod("getblockhash", index);

Here is the definition of InvokeMethod

    public JObject InvokeMethod(string a_sMethod, params object[] a_params)
    {
        HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(Url);
        webRequest.Credentials = Credentials;

        webRequest.ContentType = "application/json-rpc";
        webRequest.Method = "POST";

        JObject joe = new JObject();
        joe["jsonrpc"] = "1.0";
        joe["id"] = "1";
        joe["method"] = a_sMethod;

        if (a_params != null)
        {
            if (a_params.Length > 0)
            {
                JArray props = new JArray();
                foreach (var p in a_params)
                {
                    props.Add(p);
                }
                joe.Add(new JProperty("params", props));
            }
        }

        string s = JsonConvert.SerializeObject(joe);
        // serialize json for the request
        byte[] byteArray = Encoding.UTF8.GetBytes(s);
        webRequest.ContentLength = byteArray.Length;

        try
        {
            using (Stream dataStream = webRequest.GetRequestStream())
            {
                dataStream.Write(byteArray, 0, byteArray.Length);
            }
        }
        catch (WebException we)
        {
            //inner exception is socket
            //{"A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 23.23.246.5:8332"}
            throw;
        }
        WebResponse webResponse = null;
        try
        {
            using (webResponse = webRequest.GetResponse())
            {
                using (Stream str = webResponse.GetResponseStream())
                {
                    using (StreamReader sr = new StreamReader(str))
                    {
                        return JsonConvert.DeserializeObject<JObject>(sr.ReadToEnd());
                    }
                }
            }
        }
        catch (WebException webex)
        {

            using (Stream str = webex.Response.GetResponseStream())
            {
                using (StreamReader sr = new StreamReader(str))
                {
                    var tempRet =  JsonConvert.DeserializeObject<JObject>(sr.ReadToEnd());
                    return tempRet;
                }
            }

        }
        catch (Exception)
        {

            throw;
        }
    }


ScriptCode field in P2SH-P2WPKH BIP-143 Test Vector I'm trying to understand the meaning of scriptCode in the context of spending a P2SH(P2WPKH) UTXO.

I've already read the following answer to a similar question, but it does not fully address my misunderstanding.

After reading BIP141 for P2WPKH nested in BIP16 P2SH, we're told that the structure is:

witness:      <signature> <pubkey>
scriptSig:    <0 <20-byte-key-hash>>
                  (0x160014{20-byte-key-hash})
scriptPubKey: HASH160 <20-byte-script-hash> EQUAL
                  (0xA914{20-byte-script-hash}87)

I noticed that the scriptCode gets committed to the hash to be signed for each input. Can someone explain why 1976a91479091972186c449eb1ded22b78e40d009bdf008988ac (dup hash160 [79091972186c449eb1ded22b78e40d009bdf0089] equalverify checksig) is used as the script code (from my understanding the scriptPubKey or locking script) for a p2sh(p2wpkh) UTXO? That script corresponds to a p2pkh scriptPubKey (surely this is out of context here)?

I understand the sequence of execution as:

witness <signature> <pubkey> and scriptSig <0 <20-byte-key-hash-compressed-pub-key>> are pushed onto the stack.
Then the scriptPubKey: HASH160 <20-byte-script-hash> EQUAL is executed with redeemScript (<0 <20-byte-key-hash-compressed-pub-key>>) as the arg, eventually resulting in the execution of   CHECKSIG.

Why include a scriptCode that corresponds to a script that is seemingly out of context and not used?

Why is the following true?

For P2WPKH witness program, the scriptCode is 0x1976a914{20-byte-pubkey-hash}88ac.

It is referenced as prevOutScript in this Javascript library: https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/src/transaction.js#L396

The one that you are referring to is sighashing. There is no good reason to use 1976a91479091972186c449eb1ded22b78e40d009bdf008988ac (dup hash160 [79091972186c449eb1ded22b78e40d009bdf0089] equalverify checksig as the scriptCode in Segwit but to limit the number of changes SegWit makes to the original sighashing. In designing SegWit, only intended changes were made. The hash structure remains the same, and contains all the same data. The sighash flags still have the same effect. The only thing that changes in BIP-143 is that some data is organized under precomputed hashes, and the input amounts go into it.


Who gives the block to the miner Im still making my way into the block-chain world. I have been reading a lot.

I want to know who gives a block to the miners?, then they compete to get the challenge right, whoever gets the challenge right has the privilege to add the block. My confusion is how is a block created in the first place? where does the transaction come to the pool of miners?

Nobody gives the block, the miner comes up with it. Think of it as designing a mansion. The possibilities are endless: it can even be an empty block without transactions (there is no mansion, just a garden shed). It only needs to be valid in two ways: no conflicting transactions (the design is physically possible to build) and it has to be cryptographically secured (you have to go through the legal bureaucracy before the construction may begin). In bitcoin world, only the last part takes any significant time, and it doesn't depend on your design at all, it's pure luck.

Only certain blocks are valid, so miners have to spend time manipulating the contents of the block until it satisfies the target hash. The transactions however are merely suggestions, the miner has the complete authority and can "build" whatever they want. When they work on the block to make it meet the difficulty standard, they only "manipulate" the parts that don't matter.


Does mining bitcoin on a laptop have an expected revenue exceeding the cost of electricity and wear and tear on the computer? My understanding, from a relatively old source, that it used to be that hobbyists would get bitcoins from mining on their private computers, but that more recently there was a heavy shift to e.g. Iceland where geothermal electricity is cheaper.
What is the expected value of mining bitcoin with spare computrons from laptop including an NVidia Geforce GTX, in the USA near Chicago as far as utilities go? If the expected value is (say) 105% of electricity burning up, what are the chances of breaking even? Does it have (say) a 10% chance of doubling an investment, or are we talking a financial lottery ticket where one minute's mining could theoretically return thousands of dollars worth of BTC, but the expected amount of crunching to get the winning lottery ticket is impractically long?
I've seen some discussion suggesting that Bitcoin is even more volatile than traditional currency, and I'd be a bit surprised at being told, "It's entirely worth it; go ahead." However, I wanted to ask, and confirm my expected answer about whether mining bitcoin is profitable in a reasonable amount of time.
Thanks,

No.
The cost of electricity will far exceed the value of the bitcoin you generate. People who are using specialised ASICs in regions with low electricity cost barely break even. Your laptop wil do far, far worse than that.


Is there any concrete evidence that Wright & Kleiman were involved or not involved in the creation of Bitcoin? Is there any cryptographically verifiable evidence that one or both Wright & Kleiman were or were not involved with the Satoshi Nakamoto character?

Looking for information related to Bitcoin keys, addresses, PGP keys, or any other type of cryptographic evidence. Information that disproves their involvement also welcome (faked PGP keys inserted into documents, etc), also welcome.

Wright:
While his supposed credentials pointed at a polymath with a range of interests along the lines of what Satoshi must have studied, neither his contributions at a recent discussion panel, nor his published work indicate that he has worked sufficiently on the main ideas of Bitcoin. Additionally, large parts of the corroborating evidence have not been substantiated or outright disproven.

Kleiman:
After a career as a soldier, technician, deputy sheriff, and detective, Kleiman only switched to working with computers in 1995 (at 30) after a crash turned him paraplegic.
He then made career in computer forensics which, derived from the list of his publications, seemingly focused on password security, data recovery, and Windows exploits. On January 1, 2007 he was named a Microsoft MVP for Windows - Security.

It seems unlikely that Wright and Kleiman, whether solely or as a team could be the creators of Bitcoin.

Edit: I just found out that the first version of Bitcoin was Windows only. So, maybe it is a shade more likely then.


How do we verify the signature on a raw transaction using Bitcoinj? I managed to create a raw tx using Bitcoinj but not able to figure out how to verify its signatures.
Assuming I know the addresses corresponding to the (supposedly) unspent outputs used as inputs to the Tx, what is the easiest way to verify the Tx?

You're interested in the following API calls:

public List<TransactionInput> Transaction.getInputs()
public Script TransactionInput.getScriptSig() throws ScriptException
public void Script.correctlySpends(Transaction txContainingThis, long scriptSigIndex, Script scriptPubKey)

Use them like so:

Transaction tx = ...
List<TransactionInput> inputs = tx.getInputs();
for(int i = 0; i < inputs.size(); i++) {
    TransactionInput input = inputs.get(i);
    Script scriptSig = input.getScriptSig();
    Script scriptPubKey = ...
    scriptSig.correctlySpends(tx, i, scriptPubKey);
}

The tricky bit is getting scriptPubKey. If you have the transactions you're spending in memory, it's as simple as input.getConnectedOutput().getScriptPubKey();

If it isn't, then you can make an educated guess by converting the address to a P2PKH scriptPubKey.

public static Script ScriptBuilder.createOutputScript(Address to)

This creates an edge case where if someone tries to spend a P2PK output, it will appear to be signed incorrectly to your program. (Both are represented by addresses.)


Inflatory and deflatory economy comparison Does anyone know of any good book/paper/article comparing the inflatory and deflatory economies? I would like to know if there are any scientific publications on the matter that are approachable to non-economists (I`m a computer science student). I need it as a source for background information for my master thesis.

This topic on bitcointalk forum might be a good place to start:
Deflation and Bitcoin, the last word on this forum


Paper backup of Core descriptor wallet As I understand it, using dumpwallet for a non-descriptor wallet in Core will give you the wallet seed in WIF format. This seed can then be used with sethdseed in a new wallet, thereby recovering the original wallet. So in effect, one can make a paper backup of a Core wallet.
But with descriptor wallets, dumpwallet does not work.
Is there a way to make a paper backup of a Bitcoin Core descriptor wallet?

There is currently no way to make such a backup of a Bitcoin Core descriptor wallet. There are open PRs that will allow you to export the descriptors stored in the wallet, however these have not been merged yet.


Has anyone ever gained control of the blockchain? I've heard discussion that if you have 51% of the network's hash power, you can effectively accept or reject any changes to the blockchain (and therefore create undeserved gain for yourself).

Has anyone ever accomplished this? It's theoretically possible, but has it been done?

I think it is safe to assume that the creator once had full control of the blockchain. And at the beginning, there probably were times when someone had 51% hash power.

However, those people would have no incentive to perform an attack, so my guess would be that it has not happened yet.


Lightning Network `channel_update` message Flag clarification This is a lnd.log line:

2019-01-11 12:20:13.904 [DBG] PEER: Sending ChannelUpdate(chain_hash=000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f, short_chan_id=601495532567724033, flag=256, update_time=2019-01-11 12:19:08 +0100 CET) to 46.229.165.136:9735

Since I cannot find a direct correlation with the spec at https://github.com/lightningnetwork/lightning-rfc/blob/master/07-routing-gossip.md
can someone clarify the "flag" value?

Where can I find the information below?

[1:message_flags]
[1:channel_flags]
[2:cltv_expiry_delta]
[8:htlc_minimum_msat]
[4:fee_base_msat]
[4:fee_proportional_millionths]
[8:htlc_maximum_msat] (option_channel_htlc_max)

Are they encoded in some way in this "flag"? How?

The flags field (2 bytes) has been split into two different (1 byte) fields, the message_flags (most significant bits) and the channel_flags field (least significant bits). Hence the flags value displayed in lnd has the message_flags byte set to 0x00 and the message_flags set to 0x01.

message_flags indicates that this channel_update has some optional fields appended to the end. In this case it has the 0th bit set, which corresponds to the option_channel_htlc_max option, hence the channel_update has an additional field htlc_maximum_msat appended.


How to move the blockchain data while still being able to use the wallet? Using the standard client, Bitcoin-Qt, v0.8.1: (win10x64)

I would like to move the blockchain data from its default location to a different location (maybe even an external disk or NAS drive). What should I do to make this working while moving that data?

This step-by-step how-to assumes you are using Windows 7 and installed Bitcoin-Qt to the default directory.

Make sure Bitcoin-Qt is not running
Create a desktop shortcut
Right click on the shortcut
Select Properties
In the "target" box, add -datadir="the new data directory"
Move everything in C:/Users/"your user name"/AppData/Roaming/Bitcoin/ to your new data directory.
Start Bitcoin-Qt with your new shortcut.


Are DAG-based crypto currencies as secure as proof-of-work based blockchains? A key feature of blockchain based cryptocurrencies is that they provide inherently secure systems that don't rely on third parties. The newer DAG-based cryptos like Byteball are being touted as superior to blockchains because they have faster transaction times and eliminate the need for miners. However, these cryptos use something called "trusted witnesses" to resolve double spend conflicts. Isn't this inherently less secure than a true trustless system like Proof of Work? I thought that the whole point of a blockchain was to provide intrinsic security without the need for trusted third parties.

You need to prove that the witness Selection process is random and independent. Alice can double-spent if she has control over the witness and the network.
Let assume Alice can double-spent, in bitcoin one can wait for 6 confirmations to rule out most of the double-spent. E.g. Seller only sends out the goods after 6 confirmation. How can you achieve this in DAG? since the account is only updated by its' own transaction. On top of that, the graph DAG is very complex compared to bitcoins' link-listed blockchain.
DOuble-spent transactions may get buried by other transactions.


Can you mine bitcoins with an intermittent Internet connection? I've got a very precise question and this is not a dupe of:

Does Bitcoin rely on the internet?

My question boils down to: when you mine bitcoins, how "often" does the computer/hardware doing the mining need to connect to the Internet?

However to better explain what I mean by that question, here are a few sub-questions.

When a computer is mining, when is the result of the mining accepted/confirmed?

For example, after the computer received sufficient information to start mining, when will that information not be sufficient anymore to continue mining?  In other words: when will the computer need to have Internet access so that it can continue mining? 1 picosecond? 1 nanosecond? 1 ms? 1 second? 1 minute? 1 hour? 1 day?

What happens if some computation is done on my mining computer, but then Internet connection is off? Is the result "lost" and if that result is lost, after how much time is it lost? 1 picosecond? 1 nanosecond? 1 ms? 1 minute? 1 hour? 1 day?

It may look like a "stupid" question but it would really help me better understand how BitCoin works...

(as I'm new here [but certainly not new on the SE network] I don't know which tag to use: thanks for retagging accordingly if needed)

Assuming you are mining on a pool, your miner needs to receive and send work (shares) every few seconds, with the exact frequency depending on your hashing speed and the difficulty of the shares.

For example, my ASIC sends and receives shares at least once every 20 seconds or so.

So you need a reliable network connection if you don't want your miner to sit idle. This is the same reason why you normally configure the miner to have fall-back pool servers in case the main pool server goes down.


where is the bitcoin's private key saved? I'm making a service and I will have to take charge of users' private keys
So I'm really worried about it.how should i take charge of that?

You should not ask users for their private keys. Instead, generate new addresses (with private keys) for the users to deposit bitcoin into. Then ensure you keep those keys safe and secure, back them up and keep them encrypted


How to validate a Bitcoin address is a real one? Is there a code snippet that validates a bitcoin address?

I'm looking for both javascript and java snippets. The code should support both testnet and real addresses.

also, the official client bitcoind has a 'validateaddress' command. see https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list

you could call that from your code if you happen to have bitcoind running already.


Convert byte string into a base58 string using Base58Check encoding I'm trying to learn every bit of the process of converting a private key to WIF (Wallet Import Format).
I've been following the steps on this page and have made it all the way to the last step (Step 7 - "Convert the result from a byte string into a base58 string using Base58Check encoding") and that's where I'm stuck.
I need to use this process:

   code_string = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
   x = convert_bytes_to_big_integer(hash_result)

   output_string = ""

   while(x > 0)
       {
           (x, remainder) = divide(x, 58)
           output_string.append(code_string[remainder])
       }

   repeat(number_of_leading_zero_bytes_in_hash)
       {
       output_string.append(code_string[0]);
       }

   output_string.reverse();

That process is from the Bitcoin wiki.
I'm pretty sure I've managed to decipher all of it except for this part:

x = convert_bytes_to_big_integer(hash_result)

It looks like its telling me to convert the bytes of a hash result into a "big integer", but I'm not sure what hash result it's referring to (I think maybe this one?: 800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D507A5B8D) and I don't know how to convert its bytes to a "big integer" (keep in mind that I'm trying to learn and therefore need to do all of the math myself instead of simply having an existing programming command or web tool do it for me).

And to a lesser extent this part:

repeat(number_of_leading_zero_bytes_in_hash)

I'm not sure what "hash" it's referring to.

I've spent many hours trying to figure all this out and have done a lot of searching and tried many possible interpretations so please don't think I'm just looking for someone to do the work for me.
Thank you.

I think maybe this one?: 800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D507A5B8D

Yep!

  and I don't know how to convert its bytes to a "big integer" (keep in mind that I'm trying to learn and therefore need to do all of the math myself instead of simply having an existing programming command or web tool do it for me).

First, you need to convert it to an integer. Let me give you a simple example that you can use to test your program:

hex = fb4d9a
dec = 16469402

How do you get an integer from hex? It's like reading a base ten number, only it's base 16.

hex = fb4d9a
           ^ one's column
          ^ 16's column
         ^ 256's column (16*16)
        ^ etc.

Once you figure this out, upgrade your program to handle 'big integers.' Some programming languages have a limit on how big of numbers they can handle. In C, you can't put five billion into an int type variable. Some languages, like Python, can handle big integers without any help.

The number you get for the hash you referenced should be 63680997318088143281752740767766707563546963464218564507450892460763521488675430192536461.

  I'm not sure what "hash" it's referring to.

It's the same one you just referenced. In this case, there are zero leading zeroes, which means that the output address should not start with a one.


You Have 1 Bitcoin in your account I continue to receive text messages on my mobile advising I've got 1 bitcoin in my account, to go to: http:// (etc) to confirm my account.  However, when I follow the link, there's nothing relevant
Can you help please?

It's a scam. Do NOT click. Will be a virus your take your passwords


Wrong Wallet Balance I set up MultiBit Wallet 0.5.13 with three wallets and bought 1BTC to practice with.

From Wallet 1 I moved .25BTC to Wallet 2,
then 0.1 BTC from Wallet 2 to Wallet 3.

Wallets 2 and 3 both have correct balances: There are 0.1499BTC in Wallet 2 and 0.1BTC in wallet 3 (the slight difference was caused by the transaction fee).

However, in Wallet 1, which should have about 0.75BTC, the client shows 1.6695BTC.

When I try to move 1.5BTC out of Wallet 1, it says there are not enough BTC to do that... but the "Balance" shows:  1.6695 in the balance box on the top left when I am on Wallet 1.

Any idea what is happening?

My guess is that you have an address (or addresses) in Wallet 1 to which you do not also have the private key. This would account for both having more money that you should as well as the fact that you can't spend it.


Bitcoin how to get X value from Y How to get X value from Y?

ECDSA x,y coordinate validity verification doesn't seem to work

X = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798

Python code,

p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f
x = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
ysquared = ((x*x*x+7) % p)
print "ysquared= %s " % hex(ysquared)
y = pow(ysquared, (p+1)/4, p)
print "y1 = %s " % hex(y)
print "y2 = %s " % hex(y * -1 % p)

Output
Y1 = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8
Y2 = 0xb7c52588d95c3b9aa25b0403f1eef75702e84bb7597aabe663b82f6f04ef2777

print hex((x**3 + 7 - y1**2) % p)  // output 0

print hex((x**3 + 7 - y2**2) % p) // output 0

above python code to get Two possible y values from x

like the same how to get possible x values from y?,

Is it any formula or script available

My question is how to get x value from y

if y value

Y = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8

above y value how to get x value

I posted this answer on BitcoinTalk but will copy it here for those who don't want to chase links. The following is a direct paste from that link:

If you can, installing sage and using that rather than Python will make your life much easier. There is an example notebook on bitcoin.ninja which does some ECDSA stuff on Bitcoin's curve.

To directly answer your question, we can get x from y in basically the same way you got y from x. To see this, let's walk through why your method works.

We have from our curve equation that Y = y^2 = x^3 + 7. You can compute Y easily from x, then you're solving Y = y^2 for y. By Fermat's Little Theorem we can write 1 = y^(p - 1) = Y^(p - 1)/2. Write Q = (p - 1)/2; then we have Y^Q = 1, so Y^(Q + 1) = Y = y^2, so Y^((Q + 1)/2) = y. As it turns out, (Q + 1)/2 = (p + 1)/4, which is why you were able to solve for y by using an exponent of (p + 1)/4. Notice that this depends crucially on p being 3 mod 4; otherwise (p + 1)/4 would not be an integer and we wouldn't be able to compute this. Fortunately our choice of p satisfies this.

OK! So let's do the analogous thing for x. Let's write X = x^3 = y^2 - 7. X can be computed from y easily, so we need to solve X = x^3. Write Q = (p - 1)/3; then X^Q = x^(p - 1) = 1, so X^(Q + 1) = Q = x^3, so X^((Q + 1)/3) = x. As it turns out, (Q + 1)/3 = (p + 2)/9. This time we depend crucially on p being 7 mod 9, in order that this is an integer. Luckily it is! So there you go.

TL;DR use (p + 2)/9 in place of (p + 1)/4.

Oh, and to get the other two cube roots you multiply by a nontrivial cube root of 1. (Similar to you multiplying by -1 in your original code.) One such cube root is 0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee.

Here is Python code analogous to yours. It takes one of your output y values and returns the input x value as x2.

## Input
y = 0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8

## Field parameters
# Field modulus
p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f
# Cube root of 1
beta = 0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee

## Actual code
xcubed = (y*y - 7) % p
print "xcubed = 0x%x" % xcubed

x = pow(xcubed, (p + 2) / 9, p)
print "x1 = 0x%x" % x
print "x2 = 0x%x" % (x * beta % p)
print "x3 = 0x%x" % (x * beta * beta % p)

Its output is

xcubed = 0x4866d6a5ab41ab2c6bcc57ccd3735da5f16f80a548e5e20a44e4e9b8118c26eb
x1 = 0xc994b69768832bcbff5e9ab39ae8d1d3763bbf1e531bed98fe51de5ee84f50fb
x2 = 0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
x3 = 0xbcace2e99da01887ab0102b696902325872844067f15e98da7bba04400b88fcb


Where should one suggest new terminology? What is the proper place to suggest Bitcoin-related terminology that one believes should be used by the community? For example, when one wants to standardise some terms people use to describe different things, or coin a new term to describe something that wasn't yet described?

Bitcoin is completely decentralized.  Most terms in use today "pools", "51% attack", "miner", "rigs", "stales" came about simply because they were adopted by most users of bitcoin.

In addition to the IRC options already given, http://bitcointalk.org has a general discussion forum which may finds some interest if you start a "glossary" thread.

Alternatively you could look to influencing the discussion via the bitcoin wiki.  You can add entries for existing terms, clarify terms, request terms be merged with othe terms in an attempt to improve standardization.

Just remember bitcoin is decentralized.  You can only gain adoption by winning mind share.  You can't force a term by committee.


How websites like silkroad and pandora process transactions? I've been reading about Bitcoin on the news and I decided to learn how it works. I'm sorry if I'm posting dumb questions.

How these websites process transactions? How can they monitor one or more receiving addresses per registered users? Do they use custom software that interacts directly with the blockchain?

The underlying mechanism is to generate an address specifically for one payment. The address space for Bitcoin is mind-boggingly large (almost any 256 bits number is an address) so that's not an issue. That address is monitored for a payment and once the payment is received, automatically transferred to the merchant's final address (or payment).

As to software, it's a bit all over the map. You can either use something that will make the whole process transparent (like BitPay or Coinbase) or use lower-level APIs interacting with the BlockChain like BlockCypher.


Where in the Bitcoin Cash code is the retargetting period defined? I'm specifically looking for the difficulty retargetting period of Bitcoin Cash, but since it is a fork of Core it should be the same code.

Looks like the answer lies here for bitcoin Cash:
https://reviews.bitcoinabc.org/rABC7ad1105f43d7bff158d4b5c882ab9bf1b74d6cce

More specifically it is here:
https://github.com/Bitcoin-ABC/bitcoin-abc/blob/master/src/pow.cpp#L73


How long do miner collect transactions to include in a block? I don't really understand which transactions a miner includes in a block. Since the transactions are hashed, any newly included transaction in a block should cause a restart of finding the correct nounce, shouldn't it? So a miner has to collect the whole set of transactions he wants to include in the block he is calculating for before beginning to find the nounce?

I presume it works the following way:
A Miner collects all transactions reaching him while the network still calculates the nounce for the block before. If he receices a newly found block from another miner, the includes all transactions that reached him up to this time and begins trying to finde the node. Is this correct?

There is hardly any performance penalty for updating the block with a new hash (including new transactions) for the miners. In fact, even if they do not get any new transactions, they change the hash (using an extra nounce), at the very latest when they have exhausted all possible 32-bit nonce value in the block they were currently working on.

You likely have a misunderstanding of the mining process. It does not work such that you have to invest a large fixed amount of work. Instead, you do something fairly fast, calculating a double SHA256 hash, to see if the result is just right (for the current level of difficulty). Then you repeat the process until you get lucky.


Finding mixed transaction I have a hard time understanding how mixed transactions can be recongnized on the blockchain.

Is this type of transaction a mixed one ?

https://www.blockchain.com/fr/btc/tx/cf903272cac49e28ff0e5fa109758954ed403480f68224e8ca5ccce7fcabccaa

Thank you for your attention

Mixing techniques are designed in a way so that it cannot be identified. There is no sure shot way of telling whether a transaction is mixed unless the mixing is shoddy. It might as well appear that this is a transaction where one party is using multiple inputs to pay multiple parties. Example would be an establishment accepting bitcoins for its services from its customers and pays employees/suppliers/partners at the end of the day using bitcoins. It would have to use multiple inputs and multiple outputs.

Having said that, there are some techniques for determining which outputs are created by which inputs and if it is mixing, but these techniques are not foolproof and often make assumptions that are not guaranteed.


Implementing an "ad-hoc-like network of payment channels" on top of Bitcoin network? If we define an ad-hoc network as follows:

  "An ad hoc network is a network that is composed of individual devices
  communicating with each other directly." [1]

ad-hoc networks do not rely on routers or access points (as a point of failure) to avoid moving towards centralization. In case of using routers or access point, some kind of centralization is inherent.

With this definition of decentralization, can we implement an ad-hoc-like network between users connected by payment channels such that similar to ad-hoc network, they do not use any router to find and communicate each other?

Please note that I used term of ad-hoc-like network (instead of saying ad-hoc network) just to say that the target is removing any pre-existing infrastructure, such as routers from communications between users similar to an ad-hoc network.

[1] https://www.techopedia.com/definition/5868/ad-hoc-network

This is absolutely possible. The negotiation between the payment-channel participants can happen over the ad-hoc network.

However, each participant must still run a fully validating node at all times when he/she has an open channel-state, to be able to react to cheating counterparties. This validating full node may receive its updates over the ad-hoc network as well, but must be in consensus with the wider Bitcoin network.

If the ad-hoc network prevents Bitcoin nodes from connecting with other nodes outside of it, this will obviously be a problem.


Bitcoin V0.1 Not Connected My Bitcoin V 0.1 says, "not connected" when I try to generate coins. I have ensured the port is connected through the firewall. Also, I have read that V 0.1.3 corrected this problem. However, I am trying to connect without installing V 0.1.3.
Does anyone know how to correct a V 0.1 "not connected"?

You cannot.
There have been both changes to the P2P protocol that prevent this, and changes to the way that nodes are discovered.
The method which 0.1.0 discovered new nodes was by joining the #bitcoin channel on freenode. Your IP address would be encoded in a certain way and that would be the IRC nick for your node. However this has long since been removed from the Bitcoin software and any node that does connect to the #bitcoin channel will be kicked from it (the encoding is unique and identifiable).
Since 0.1.0 can't connect to the IRC channel to discover new nodes, it is unable to learn about nodes that it can connect to.
Furthermore, the P2P protocol has changed since 0.1.0 was released and thus 0.1.0 is unable to communicate with modern nodes. This change was to add a checksum to the end of the P2P message header. Messages without this checksum will be rejected by modern nodes.
Lastly, 0.1.0 is too old so modern nodes won't connect to it. They have a minimum supported protocol version number, and 0.1.0's protocol version number is far too low. So even if you could get it to connect, the connection would be dropped.

The way to deal with the node discovery issue is to manually modify the peers.dat file to have the IP address and port of nodes that you want to connect to.
The only way to deal with the P2P protocol changes (checksum and version number) is to have a shim that sits in between all of your connections and modifies the P2P messages to work with modern node software. Or you can connect to a modified node which can deal with 0.1.0 traffic.

Even if you are able to connect to the Bitcoin network with 0.1.0, you won't be able to mine anything as the CPU mining is no longer viable, and the CPU miner implementation in 0.1.0 is not efficient. You also wouldn't be able to even sync as it syncs too slowly. Blocks will be found faster than it is able to process them. It will run into additional issues when it receives a new block before it is able to sync the blockchain that precedes that block.


Searching for the comprehensive guide to creating Crypto Currency A few months ago I came across (by accident) a very detailed and well written guide on how to create your own crypto-currency from the bitcoin source code.  I skimmed through it and "Stared" in Firefox for future reference.

Now that I want to read through it I can't find it in my bookmarks. (I sometimes think Firefox is not saving them), anyway...

The guide had highlighted source code, complete explanations of what was necessary, how to generate the genesis block, etc.  He even offered a service were he would do it all for you.

Does any one have the link to that site?

Would this be it? It seems to be what you're asking for.

https://andarazoroflove.org/how-to-create-alt-coin-scrypt-clones-for-fun-and-profit-bitcoin-litecoin-secrets-exposed/


Solo mining just for luck, realistic? Just turned my attention to mining and the concepts are quite new to me. First of let me be clear: I realize that my hardware setup is far from ideal for mining. This is also the reason why I do not want to pool, I would simply provide a too small a share. I will be CPU mining at first, ASIC later on.

I would however like to test my luck. Mostly just for fun, I'm completely fine with the idea of never actually solving a block. I see it more as a lottery. I just want to confirm my idea so that I am not missing something: Do I have a chance of solving a block?

If a block is solved every 10 minutes, and the difficulty goes up continously. Do I even have the time to attempt a solution? I understand that the current work has to be abandoned when a block has been solved, rigth? Is there, for example, a lag here that yields my efforts useless?

What are the odds? Are the actually the % of my speed vs the network's?

Check this page: How soon might I expect to generate a block?

So with the current difficulty  510,929,738, and a 1Ghash/s mining rig (faster than your CPU) you'd do this math:

510929738 * Math.pow(2,32) / Math.pow(10,9) / 60 / 60 / 24 / 365

So to find a block at this difficulty with a 1Ghash mining rig it would take you about 69 years on average.
Good Luck!

PS: Math.pow(2, 32) is simply the JavaScript version of 2^32


Writing an article on Bitcoin for my school paper I am writing an article on Bitcoin for our high school paper. What points do you think are important to include?

I'm writing this article for a high school paper, so please put it into those terms.

(NOTE: This answer is meant to be understood at a high school level)

Bitcoin is the first and currently most popular cryptocurrency created by the mysterious Satoshi Nakamoto.

It was designed to allow users to securely and anonymously transmit wealth to each other in a way where no single entity has control.

It is secure because it uses the nearly the same technology that has been used for decades to transmit information securely across the web.  It does this somewhat anonymously because nothing about a user is recorded.  It is "decentralized" (no one person or group of persons) has control because every transaction is verified by "hashing" it in a very difficult and original way yet can be hashed by anyone.  The transactions are hashed into something called the "blockchain" which is essentially a collection of rule-abiding transactions so that a record of all transactions alllll the way back to the very first transaction is available for all to see.

Yes, but what exactly is it?

It's basically a program that everyone uses, originally created by Satoshi Nakamoto.  If someone tries to use a different program or change the original code beyond certain parameters, called the "protocol", all other programs will reject anything that the different program will try to do.

Security

Transactions are secure because a user gets a private key/public key pair generated by a program.  They have to be generated in such a way so that for every private key there is almost certainly only one public key, so a user can choose a random private key, and an acceptable program will generate a corresponding public key.

Once a user has this pair, they can "sign" a transaction with the private key that the user keeps only to oneself, but anyone can view the true data when using the corresponding public key.

The "private key" is more like a "private lock".  A user can create a transaction and lock it with the "private lock" that only the user has while anyone can unlock it with the public key.

The public key is actually the address that all users use to receive coins.  So, if I want to send you money, you give me your public key while keeping your private key to yourself, and I sign a transaction that says "give X bitcoins to okarin's public key" and append my public key to the transaction so everyone can use it to decrypt my message which could only have been sent from me (or someone who stole my private key) because I used my private key to encrypt the transaction.

Anonymity

As long as no one knows who owns a public key, that user is anonymous.  Bitcoin records no other information.

No one controls it

This is mostly true.  Remember, this is all based upon a single program, and someone actually does control the source code to that program.  Whenever it's changed, most people adopt the change, but if they don't, one legitimate transaction record can turn into two: one for the people using the old code and one for the people using the new code.

Aside from that, the program itself is decentralized yet unified because after a transaction is sent out, it is verified by someone else on the network.

This has to be done because if, going back to the example above where I've sent you money, only some people see our transaction but others don't, I could send the exact same money that I sent you a second time to someone else who doesn't know about our transaction.

To prevent that problem, all transactions are included into a single record, the blockchain.  And the longest rule-abiding blockchain is recognized to be the legitimate one.

A single person or group of persons is prevented from having control over the blockchain because a "block" of transactions are hashed.  This requires a computer to do a calculation that costs resources such as a computer strong enough to do this quickly.  Since there are many people trying to do this because they get paid in new bitcoins to do so, it's really hard for a single person or group of persons to do all of the hashing themselves.

Not only are the new transactions hashed, but all of the old ones are too.  This turns into a very large transaction record constantly reverified and rehashed, called the blockchain.  Transactions are verified in batches called "blocks".

Where do bitcoins come from

Remember, they essentially come from the program, but new ones are rewarded to those verifying transactions as payment for doing a good job.  If someone tries to cheat, no one will give them new bitcoins.

New bitcoins are created according to the rules in the protocol.  And since the protocol says that everyone should award the first to verify transactions properly, users who use the right program do.

If a user uses the right program, this is all done more or less automatically, so a user can simply get coins from someone and send them to someone without having to worry about all of this complexity.

Good luck on your article and feel free to plagiarize this (but only you, okarin)!

If there's anything you still don't understand, send me a comment, and I'll try to help.

If you want the technical outline of what bitcoin is, you can read the original Satoshi Nakamoto paper.

Yes, I know there are a ton of ifs ands or buts, powerusers, but I was trying to outline the basics.  Feel free to edit this as necessary into layman's terms.


What is the difference in hashing algorithm between bitcoin and litecoin? I am having trouble finding litecoin mining specifications. I would first of all require something like this:
https://en.bitcoin.it/wiki/Block_hashing_algorithm

Except for litecoins. I need to know how to dissect the getwork data, what kind of operations to do on it (eg. hex to uint32 conversions, byte order shifts, etc.) and what specification of scrypt to use and what are its input, difficulty and expected output.

I would really love to have some input/output data, on which I can write BDD specifications so I can write a miner on top of that.

Anyone know for some good resources I could use?

Thanks

Edit: I would really appreciate some sample input/output, I can figure out the rest myself.

Here you find an example, how to extract the data from getwork and call the scrypt function
http://litecoin.info/Scrypt

Unfortunately it is not clear (to me) what the resulting values of the scrypt should be. First I thought it is the result of the valid block above, but that has a different nounce.

If you find a valid result, please let me know the value.


output descriptor serialization I'm looking at the following official test vector:
wsh(multi(1,xpub661MyMwAqRbcFW31YEwpkMuc5THy2PSt5bDMsktWQcFF8syAmRUapSCGu8ED9W6oDMSgv6Zz8idoc4a6mr8BDzTJY47LJhkJ8UB7WEGuduB/1/0/*,xpub69H7F5d8KSRgmmdJg2KhpAK8SR3DjMwAdkxj3ZuxV27CprR9LgpeyGmXUbC6wb7ERfvrnKZjXoUmmDznezpbZb7ap6r1D3tgFxHmwMkQTPH/0/0/*))

which is serialized for the first key as:
04 ; version 4
88b21e ; `xpub`
00 ; depth 0 == public key of a master key
00000000 ; parent fingerprint
00000000 ; child index
60499f801b896d83179a4374aeb7822aaeaceaa0db1f85ee3e904c4defbd9689 ; chain code
03cbcaa9c98c877a26977d00825c956a238e8dddfbd322cce4f74b0b5bd6ace4a7 ; key data
e233a252 ; base58 checksum

and the second key:
04 ; version 4
88b21e ; `xpub`
01 ; depth 1
bd16bee5 ; parent fingerprint
00000000 ; child index
f0909affaa7ee7abe5dd4e100598d4dc53cd709d5a5c2cac40e7412f232f7c9c ; chain code
02fc9e5af0ac8d9b3cecfe2a888e2117ba3d089d8585886c9c826b6b22a98d12ea ; key data
44183bfc ; base58 checksum

My question is for example for the second key: is the depth connected with the appended tail /0/0/*? If it is, shouldn't it be 2 instead of 1? Can depth be restored from the appended tail?

Why is the child index zero for the second key? Should it not be equal to the number that corresponds to the star. Can a child index be restored from the appended tail /0/0/*?

It looks like you are confusing the BIP 32 serialization with output descriptor serialization.
Output descriptors contain an extended public key serialized using the method described in BIP 32. This serialization applies only to that particular public key. The derivation appended to the end is independent and separate from that xpub's serialization. That is part of descriptors.

My question is for example for the second key: is the depth connected with the appended tail /0/0/*? If it is, shouldn't it be 2 instead of 1? Can depth be restored from the appended tail?

No. The tail is independent from the xpub. The depth applies only to the pubkey serialized by the xpub, which the derivation path is not a part of.

Why is the child index zero for the second key? Should it not be equal to the number that corresponds to the star. Can a child index be restored from the appended tail /0/0/*?

Because the serialization is only for that particular xpub. The appended derivation information is not part of this serialization.


What is the Coin Base Text of a bitcoin block? On the site https://coin.dance/blocks#blockDetails, there is a column Coin Base Text with values like Mined by AntPoolk9 Z4,b or *3Zc/BTC.COM/mm.j΀n~OoBրn*e*@ for example. What does it mean? Is it equivalent to the nonce (because I thought, the nonce is always numeric)?

And where is this information stored? In each bitcoin block? And why?

Every block has one coinbase transaction, which is a transaction that miners use to send the block reward and fees to one or more outputs.

Since that transaction is generating new coins it has a special kind of input, that is called the coinbase, which allows up to 100 bytes of arbitrary data to be written to the blockchain. Most mining pools will put some sort of text in that field to identify themselves as the miner of that block. A solo miner can put anything* they want in that field, such as the message that Satoshi Nakamoto put in the Genesis Block coinbase:

  The Times 03/Jan/2009 Chancellor on brink of second bailout for banks

*As of block 227,836, the first few bytes of the coinbase must contain the block height


How to generate a testnet address? Bitcoin addresses can be generated on this site https://www.bitaddress.org, but the test network needs m or n at the beginning of the address, where can those be generated？

The site that you reference itself allows you to create Testnet addresses: https://www.bitaddress.org/?testnet=true (Hat tip to Nick ODell)

On the other hand, you could simply use a wallet that supports testnet, see e.g. Running Bitcoin Core in testnet mode.


What are the security considerations for hosting *your own* Electrum server? Lets say I wanted to use an electrum client but I'm so paranoid and also can't or won't read and understand python code so that I only trust my own server.

What security considerations should I have in mind? eg: Do I need to add any encryption to the filesystem to protect the wallets that are being served?

Do you gain security by validating with other servers? Given extreme levels of paranoia should you even trust other servers?

Electrum servers don't save any private information. All they do is create an interface to a bitcoind instance that is exposed in such a way the Electrum client, which stores the important and private data, can read it.

The only 'evil' thing an Electrum server could do is lying about certain transactions, feeding you misinformation. When you run your own server this is the only thing you will gain.

Encryption won't be needed, but is a good practice overall. No wallets will be saved on the server, except the wallet from Bitcoind. This wallet however will always be empty.


How do I make Bitcoin Core listen on IPV6? I know my ISP provides IPV6. It was previously broken, but restarting my router fixed it. I confirmed my IPV6 connectivity on several websites. Then I restarted Bitcoin Core so it would see the new IPV6 address on startup, but bitnodes.21.co says my IPV6 address can't be reached. Any advice?

Normally it should autodetect. Check for lines like these in debug.log:

AddLocal([2a02:91a:f3:21aa::1]:8333,1)

If that's the case, Bitcoin Core is listening to it, and if another service can't reach it, it may be a network configuration problem or a problem with that service.

If it isn't, you can manually bind to an IP address (IPv4 or IPv6) using the -bind option.


orphaned transaction how to find parent basically a newbie and received mining transactions from a pool in 2013/14. cannot remember which pool. recently pulled out wallet.dat and now have TXs which are not in the mempool with 0 confirmations.  when rebroadcasting says missing parents or missing inputs.  how can i find the parents or inputs.  help will receive btc as reward.

can anyone help please!

The missing inputs error can mean two things: the parent transactions do not exist anymore OR the outputs that your transaction is trying to spend are already spent by another transaction.

You can first try looking up the txids of the inputs for your transaction in a block explorer. Those txids are the parent transactions, and if you see the transactions in a block explorer, check to see whether the outputs you are trying to spend are already spent. If they are, then your transaction is actually a double spend and is invalid. There is no way to make it valid nor is there any way to "retrieve the coins" from it.

If you see that the outputs your transaction is trying to spend from are still unspent, or if the transaction that spends them has the same transaction ID as your transaction, then that means that your wallet is not fully synced yet.

If you do not see any of the parent transactions, then there is nothing that you can do. It is impossible to determine the contents of the parent transaction given just its hash. You would need to have the full transaction of each parent transaction, but if you do not have those, then there is nothing that you can do.


Aren't blocks generated too slowly to catch up to transactions? I read somewhere that it takes 10 minutes to mine a block.

What happens when the number of transactions exceeds the block size. Do we all have to wait 10 minutes until another block comes in?

Yes. If there are more unconfirmed transactions than can fit in one block at a time, then those unconfirmed transactions can be confirmed in the next block.

However having more transactions than can be confirmed in one block is not a bad thing. If the sum of the transaction fees of all of the unconfirmed transaction is high, then that means that miners are more incentivized to mine the next block instead of engaging in fee sniping where they will continue to mine for the block that was just found so that they can collect the transaction fees for that block. If all unconfirmed transactions were cleared, it would be more profitable (for some time) for a miner to continue mining the previous block as the reward for that block would include transaction fees and thus be greater than the reward for the next block which, for some time, would not include any transaction fees.


How does change address interact with original address change address is an additional address inside a wallet, which u can create with a raw transaction with 2 outputs.
What I want to know is how does this change address interact with the (for a lack of words) "original" address, when sending money back to the "original" address.
Does the change address have a pre-written script which sends BTC back to "original" address?

There is no relation at all between the two addresses, except that they're owned by the same person/wallet.
At the protocol level, "change" does not exist. It's just another output (with a corresponding address), indistinguishable from normal "payment" outputs. It is your wallet that's creating it: it needs a place to send the remainder of a spent UTXO of yours that you don't actually want to transfer, so it creates a new address of its own (just like you'd do when receiving funds), and sends the remainder there. And it stays there, until there is a need to spend those funds. It could send them back to the same address, but this would be a serious privacy leak (it lets people distinguish change from payment), and have no cost advantage.


What happens to transactions in the mempool when their parent transaction expires? I was just reading the Coin Metrics Newsletter #53, and it included a section about the recent mempool congestion. After mentioning transactions that got evicted due to the network's queue of unconfirmed transactions exceeding the default mempool limit, it mentions about transactions expiring due to the 14 day limit:

Secondly, transactions residing in the mempool for over two weeks expired. By default, Bitcoin Core nodes remove transactions from their mempool if no miner found transaction fees to be attractive enough to include them in a block over the last 336 hours (two weeks).
In total 1,627 transactions expired between May 25th, and May 30th. Only 35% of these resided in the mempool for two weeks. The remaining 65% likely spent unconfirmed parent transactions and became invalid as their parents expired.

In the last sentence (highlight added), the newsletter describes that transactions chained from expired transactions would get dropped from the mempool as well. Is that an accurate description of the mempool behavior?
If yes, let's say txA was in the mempool for two weeks and got dropped, and txB was a CPFP transaction spending an output of txA which therefore got invalidated and dropped as well.
What would happen if the original sender rebroadcast txB? Given that txB inputs would appear to not exist without the context of txA, would the peers of the sender request the preceding transaction txA or just reject txB? Would then the two transactions repropagate as a unit?

Yes, this is an accurate description of the mempool behaviour. When a transaction is expired from the mempool, its descendants are as well.
When txA gets dropped, so does txB. If we later re-broadcast txB (and it's not too large) our peers will add it to a (small) cache of orphaned transaction they keep for us. If we broadcast txA in the next 20 minutes (timeout for orphan tx cache eviction), and it passes policy checks on its own txA would be added back to the mempool.
Note that the peers would only request it if we send them an inv for txA.
However, there are no such thing as "propagation as a unit" on the P2P network currently (package relay design is being discussed here). This is the reason why in your example txA must pass the policy checks on its own.
This has implications on L2 protocols with pre-signed transactions, for example in the Lightning Network where the transaction relay is critical. A pre-signed txA which happens to be below most of the network mempool minimum feerate at the time of broadcast won't be accepted even with a high fee-paying txB (1)(2).

(1) This is the reason why the Lightning protocol kept the update_fee message even post anchor outputs.
(2) This has implication in other L2 protocols too. For example in Revault it could prevent one to unvault a vault until the mempool backlog is processed.


Is there any mechanism in Bitcoin that allows it to dynamically adapt to the flow of transactions? I've read some books and articles on Bitcoin and feel like I've understood many of its concepts but I'm not able to find an answer to a question I've had for a long time:

How does the Bitcoin network adapt to an increased or decreased number of transactions per time interval?

I know that the network tries to constantly adjust the cryptographic difficulty so that new blocks are mined in 10 minute intervals on average. When the block size is limited, every block can only include a maximum number of transactions.

This means that miners need to prioritize some transactions over others (most likely those that pay the higher fees) when the number of incoming transactions per 10 min interval exceeds this maximum. When the number of incoming transaction decreases over time below this maximum, those unprocessed transactions (those with the lower fees) will be included in the next blocks.

But what happens if, over a longer period of time, the number of incoming transactions per 10 min interval never decreases?

Consequently, this would mean than all transactions with a fee that's not high enough never make it into the blockchain (or at least not for a very long time).

How does the Bitcoin network solve this problem?

(Surely, with increased adoption, there will be more than a couple hundred or thousand transactions every 10 min?)

Why is there a limit? Why don't we change it?

No matter the number of transactions broadcast to the network, there is an implicit maximum number of transactions that can be included in a block (see @JamesC's answer), and the number of blocks found is regulated by the network's difficulty adjustment algorithm, aiming for an average of one block every ten minutes. This puts an effective cap on the number of transactions / second the network can confirm in the blockchain record.

You might therefore believe that adding an adjustment mechanism for the size or frequency of blocks would be beneficial to the network, but further investigation shows this to actually be detrimental to the health of the network. The reason there is no adjustment to the number of transactions included in a block (ie. an adjustable block size), is that such a mechanism would have undesirable implications for the ability of users to run nodes, and for the game theory of bitcoin mining:

For full nodes: In general, the larger a block is, the more computational resources (bandwidth, storage, computation) a node will need in order to validate it. So a larger block size puts pressure on the least capable nodes in the network, any increase in resource requirements should be expected to cause some number nodes to drop off the network. Thus we can see that a growing block size can be used as a DOS attack against resource-constrained nodes on the network, and this is obviously undesirable.

For miners: no matter the hardware, a larger block will take longer to download and validate. As a miner, this means that when you hear about a new block on the network, there is a brief period of time during which you will be downloading the new block, but are unable to begin mining on top of it before ensuring it is valid. This leads to an increase in orphan block rate, which will affect smaller miners more than larger miners. Thus we can see that a larger miner would be incentivized to create larger blocks, because the latency issues associated with large blocks will affect their competitors (smaller miners) more than it would affect themselves. Ultimately, we would expect this to concentrate mining power amongst a few large-scale operations, which is obviously undesirable.

What other solutions are there?

So all of that sounds pretty dismal in regards to scaling the Bitcoin network up to deal with a global transaction volume. BUT! The good news is that scaling the block size is perhaps the most obvious approach, but certainly not the only one.

For example, the lightning network (LN) moves transactions off-chain, allowing pretty much unbounded transaction volume to occur off-band between LN participants. Further still, LN channel factories could allow participants to transact with incredible cost savings. Note that there are trade-offs involved in using the LN, and the model of trust and security is slightly different than transacting on-chain.

Sidechains are also coming online, such an example is the Liquid Network created by Blockstream. Note that sidechains don't increase scalability, but they can increase scale, though again with a different security and trust assumption than that of the underlying Bitcoin blockchain.

Schnorr signatures provide a number of benefits over ECDSA, in terms of scalability we can see that signatures can be smaller (meaning less bytes per transaction), and more flexible signature aggregation (many participants represented by a single aggregate signature, effectively reducing the 'number of bytes per user' in a transaction). Note that Schnorr signatures are not currently used on the Bitcoin network, but many developers would like to see their implementation in the future.

In conclusion: lets reconsider what a 'transaction' can represent

To wrap all this up, I'll encourage you to move towards an understanding that a user interacting with the Bitcoin network to exchange some value does not necessarily have to map 1:1 to an on-chain transaction. An on-chain transaction can in fact represent a huge number of individual user transactions (eg. a transaction that opens a LN channel, or a transaction that includes an aggregated signature representing a huge number of individuals participating in a single transaction), or as Nic Carter put it:

  [Bitcoin transactions] are nothing like Visa transactions, which they are commonly compared to. I like to refer to them as containerships, not parcels.

Which is to say that a single on-chain transaction can represent the economic activity of a great number of individual users, not just a single user's transaction.

So we can see that 'number of transactions per second' is not a perfect measure of the social scalability of bitcoin, instead the 'economic throughput per second' is perhaps more interesting. If we can include the economic actions of more users per transaction, we may find a more viable path to scale the Bitcoin network to a global level.


As a Bitcoin Trader, what tools are available to execute trades? Looking to expand beyond using bitstamp and gox's (ok, well, that one was easy) built-in trading interfaces to something more unified and manageable. RTBTC seems to have a clean interface. What about alerts sent out when a certain price is reached? Are there any tools that track transactions for tax purposes?

CrypTrader is a website that unifies the exchanges via your API keys, so that you can trade all on one platform.

MyBitAlert lets you set up email alerts when the price reaches a certain level.

CoinReporting lets you enter your trades (or import them automatically) and show your P&L, and can even export trades for your tax declaration.


Why doesn't Bitcoin Core use Google's OSS-Fuzz? Google offers free access to their ClusterFuzz fuzzing infrastructure (through OSS-Fuzz) to open source projects. Why does Bitcoin Core not take advantage of this?

The primary reason that Bitcoin Core doesn't use OSS-Fuzz is that as Greg Maxwell states in this secp256k1 issue, there is an:

extremely short timeframe mandatory disclosure (edit: 90 days) which basically made
anything except blindly installed automatic updates a viable way to
deploy fixes

Pieter Wuille adds some additional context here:

This extraordinary requirement for exact consistency between implementations means that these classes of issues cannot be fixed in the time scale of software releases, but requires network-wide coordination. The most relevant example is how a platform dependent deviation from the DER standard in OpenSSL threatened a network split a few years ago; you can read about the issue and its timeline here. In that case, it took 9 months between discovery and eventual resolution, but I believe that similar issues these days would take significantly longer still.

Without a future exception granted by Google, Bitcoin Core using OSS-Fuzz is a non-starter.
I am less clear on exactly how much additional value Bitcoin Core would get from using OSS-Fuzz in a theoretical world where Google granted that exception. It is partly discussed in the issue in addition to the current state of fuzzing in Core and the secp256k1 library.
There is also the consideration of dependence on a specific corporation's infrastructure. Open source projects aren't locked in to OSS-Fuzz but it is generally time consuming and disruptive to make the transition off of them.
Update on May 5th 2021: Bitcoin Core has signed up to use Google's OSS-Fuzz.


How does restoring an HD wallet work? I was trying to learn working of bitcoin and trying to understand the working of bitcoin wallet.

I can see the behavior of how an HD wallet starts with an address and adds additional addresses later for receiving bitcoin.

I read bip-0032, but still am  confused. If I regenerate a wallet from the seed (in another mobile phone), how the system will populate the wallet with all previous addresses containing a balance? Will it try to download the earlier blockchain and search it, or is there another way?

How do we locate a list of all addresses we created with the HD wallet? How can we verify the balance of those addresses?

I know that this question is going to receive down votes, please give me some ideas.

Also it would be helpful if somebody can share some links where I could get some help on clarifying doubts (not programming, general working).

The seed derivation works by increasing a "nonce" and deriving an address from that. So, by example, if we pretend that we have 1234 as our seed, then we could increase that seed by 1 for each address derivation. If we use a simple sha256 hash of that as our private key, then we get the following addresses:

NonceFinal SeedAddress
    0      12341B3PHXB6g5YGLvzTkxrrPEdLbpvfEoC5Qi
    1      12351NxaF9cYPL53fNTHMN6wtmq1w8bmHEe3gp
    2      12361DPF9wFiuFowUK4NwJdbd2W9L59bPPnWNM
    3      123713ehhpMndUoh5E4QcHJ7QSWwuKC7ySpxrL
    4      123817CF5qesU9KXBHAsa9tEz1126kqSDy56tC
    5      12391MfTGTiszztzzjzKajvS1Wc3TznqpfyPh7
    6      124016t3QqxUVssdTAYUibdY8K4aCFYsP6pUWE

This is obviously oversimplified, and not the derivation that is used in most BIP32 implementations. As to how they are restored, you simply keep deriving addresses until you hit a bunch in a row that are unused. This is called a lookup gap, and is normally configurable.


API or framework for handling transactions I am developing a JSP web (based on Java) and I would like to let users send the altcoins to my servers wallet. I need something what would monitor if the coins (DOGE/BTC etc.) has arrived and just after that let the users do something.

Is there anything like this? I am new here and maybe it is broad but let me explain better if you need.

I mean something like this: http://bitcoinj.github.io/getting-started

but not only for BTC also for other coins.

for example you can subscribe to unconfirmed transaction on the blockchain websocket and monitor when your addresses appear in the flow.


Is it possible to have proof of stake and proof of work transactions in the same block ? To understand more of the blockchain technology i asked myself , is it possible to have proof of stake and proof of work transactions in the same block ?

Proof of Stake and Proof of Work are two strategies of arriving at consensus. I'm not aware that the transaction format would need to be impacted whatsoever by having one or the other in play.


Specific instance of Tx using a malformed null byte vector for P2SH; insight req From Biteasy's API for TXID fccf964964c34994e5dbbb9ff7f914159b524b0831f6eea12255aa424b39090e we can see the following info regarding inputs (for a P2SH Tx):

"script_sig_string": "[] [3044022016c09f09b6c55....]
"script_sig": "ff473044022016c09f09b6c55....

I do know a null byte vector (OP_0) is required for the off by 1 error for multisig Txs. But it's the raw hex where ff is representing the OP_0 (empty array) that is confusing me.  Is this being read as 2's complement of 0x00 or is it reading OP_INVALIDOPCODE as outlined on the Bitcoin Wiki Script page (quoted below)?

OP_PUBKEYHASH      253  0xfd    Represents a public key hashed with OP_HASH160.
OP_PUBKEY          254  0xfe    Represents a public key compatible with OP_CHECKSIG.
OP_INVALIDOPCODE   255  0xff    Matches any opcode that is not yet assigned.

FYI, this Tx caused issues with the core software parsing the blockchain awhile back; that much I am aware. However I have yet to find an explanation online (omitting github/C++ code, which I am not well versed in reading)

Another very interesting question!

First, note the date of the transaction. Specifically:

"created_at": "2013-10-25T13:16:51.598Z"

It turns out that until this issue, ANY value could be used instead of OP_0. To quote Peter Todd:

  While normally OP_0 is used, the actual value of this argument is not
  checked, and thus creates a source of mutability for any transaction
  with CHECKMULTISIG inputs.

The patch here actually made it so that the first argument of a standard multisig had to be OP_0 as to not cause transaction malleability.

Given that this transaction was before this commit got into the standard bitcoin client, that transaction was perfectly fine. You literally could have put almost any value as the first byte and it would have gone through.

Also note that this was a soft-forking change. It's still legal to put OP_INVALIDCODE instead of OP_0, it just won't be propagated by the standard bitcoin client and thus probably won't get into a block. Otherwise, this would have been a hard-forking change.

Edit: It looks like the API from biteasy is different than other places like blockchain:

Note that the script begins with 00, not ff as with biteasy.

https://blockchain.info/rawtx/fccf964964c34994e5dbbb9ff7f914159b524b0831f6eea12255aa424b39090e

{
"ver": 1,
"inputs": [
{
"sequence": 4294967295,
"prev_out": {
"spent": true,
"tx_index": 38094378,
"type": 0,
"addr": "35aHovjnZ9xdfYZsB2yBVTs6CWqnBpHNDY",
"value": 100000,
"n": 1,
"script": "a9142a9ada309638ec606f67e6b107867184c58a3aab87"
},
"script": "00473044022016c09f09b6c55c0afefa1c0f0b7fa5789b3fa486d19ba3e7f5338fc8a2701dc502203ab665792d477ffabcfb736b6d6951d238d5a8af8f9754cc29e9caab46b9b1dd01473044022016c09f09b6c55c0afefa1c0f0b7fa5789b3fa486d19ba3e7f5338fc8a2701dc502203ab665792d477ffabcfb736b6d6951d238d5a8af8f9754cc29e9caab46b9b1dd014cc9524104d9399e85461d925e4c3932cc033aee59873e1212216c81943d5634c2e45ee0f45181f69d63b236e53d286a43b2de2b0ee64850191771924430f92ac6542f3cf24104d9399e85461d925e4c3932cc033aee59873e1212216c81943d5634c2e45ee0f45181f69d63b236e53d286a43b2de2b0ee64850191771924430f92ac6542f3cf241046d38a48ed6f12b132cdf14e84d1d6678bbf0e148e1b4791ee39fa0945cecf86ecb870cd4c74a4e472b8e3034f771df0375a7c097adf2bc48ce9f2ea3e64e20dc53ae"
}
],
"block_height": 265976,
"relayed_by": "24.212.184.180",
"out": [
{
"spent": true,
"tx_index": 38095095,
"type": 0,
"addr": "1QKjwQ7tJGaWrXyftce4ns47gvZ67GoqMt",
"value": 80000,
"n": 0,
"script": "76a914ffd6391cff55413edb04761ecf1a447d80bfe74188ac"
}
],
"lock_time": 0,
"size": 435,
"double_spend": false,
"time": 1382706718,
"tx_index": 38095095,
"vin_sz": 1,
"hash": "fccf964964c34994e5dbbb9ff7f914159b524b0831f6eea12255aa424b39090e",
"vout_sz": 1
}


How to implement a game like SatoshiDice? Everyone knows what SatoshiDice is. Their core mechanic is gambling through the use of Bitcoin transactions with the payout being directly linked to the transaction that fuelled the bed to avoid double-spend attacks. My question is, how to implement such a mechanism? Can it be done in the Standard Client, or does it need some extra software to pick the exact inputs of a transaction?

Creating a SatoshiDice-like game is rather easy.  Below are the high level steps involved in making such a game.

For each incoming transaction...

Get the customer amount and payment address

Call bitcoind getrawtransaction [The incoming transaction ID] 1.  The 1 at the end will return the data in "verbose mode", which essentially the raw data in JSON format.
From the raw transaction details, take the txid and vout from the vin object.  With this transaction, again call bitcoind getrawtransaction on the txid.
From these raw transaction details find the vout object, referenced by the vout index from step #2.  Within this vout object, there should be a list of payment recipient addresses.  Take and store the first address.

Determine the Win/Loss state of the round and return the results

Hash the txid+vout index of the transaction.  Seed your hash function with a secret key.  As an aside note, you will need to provide your secret key on a periodic basis.  Without updating and providing your secret keys, there is no way for your players to verify your fairness.
Compare the last four bytes of your hash to determine the win/loss condition.

In case of a loss...

Call bitcoind createrawtransaction.  You must pass in the originating txid and vout of your customers payment.  With the customers address, include a small, fractional value to send back to the customer.  This informs them that they've lost the round.  Also, include a second payment address that will receive the remaining portion of bitcoins from the customers originating payment.  This should be an address within your wallet.
Call bitcoind signrawtransaction to sign the transaction.  If it returns a value of complete=true, your transaction is valid.
Call bitcoind sendrawtransaction and include the above constructed raw transaction.

In case of a win

Calculate the customers winning amount.
Call bitcoind listunspent.  This will return a list of inputted transactions that have not been spent by your wallet.
Create a list of transactions to process as payments.  First, include the customer's originating txid and vout index of their payment.  Next, append to the list any number of unspent transactions (from step #1) that are necessary to pay your customer their winnings.

Remember to include an additional payment address that will receive the remaining portion of bitcoins from the final unspent transaction that may contain overages above the player's winnings.
Call bitcoind createrawtransaction, passing in all of the transactions accumulated in step #3.
Call bitcoind signrawtransaction to sign the transaction.
Call bitcoind sendrawtransaction and include the above constructed raw transaction.

That's it!  That's a very simplistic, SatoshiDice processor.  You may want to add more validation, cache your transactions, monitor orphaned blocks and just integrate some other administrative routines.

It is worth mentioning that you always include a portion of the customers original payment with all of your return transactions.  This is because if their payment is orphaned, or is marked as invalid, you want to be sure that your transaction is also removed from the block-chain.

Using this method you can actually respond near-instantaneously and there is no need for confirmations.  If their transaction is malformed and rejected by the network, your transaction will also be thrown out by the network since it is a child of their original transaction.