Cannot read property 'toWIF' of undefined I am working on a cryptocurrency site in which each user will have there own individual deposit address to put currency on site. I am using bitcoin-core, bitcoinjs-lib, along with quite a few other modules.

Currently I am receiving an error after running the following code via node generate_wallet.js

var bip32 = require('bip32')
var bitcoinjs = require('bitcoinjs-lib');

var privKey = process.env.BIP32_PRIV;
var hdNode = bitcoinjs.HDNode.fromBase58(privKey);

var count = process.env.GENERATE_ADDRESSES ? parseInt(process.env.GENERATE_ADDRESSES) : 1000; // how many addresses to watch

var rescan = 'false';

for (var i = 1; i <= count; ++i) {
  console.log('bitcoin-cli importprivkey ' +  hdNode.derive(i).keyPair.toWIF() + " '' " + rescan)
}

The error:

console.log('bitcoin-cli importprivkey ' +  hdNode.derive(i).keyPair.toWIF(L4tvCJoE9nxFnmZ4znCDvpqMLo9m8ybpAzxdE4ZKWDAfBqeM8JsR) + " '' " + rescan)
                                                                      ^

TypeError: Cannot read property 'toWIF' of undefined
    at Object.<anonymous> (/root/bustabit-depositor/src/generate_wallet.js:13:71)
    at Module._compile (internal/modules/cjs/loader.js:736:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:747:10)
    at Module.load (internal/modules/cjs/loader.js:628:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:568:12)
    at Function.Module._load (internal/modules/cjs/loader.js:560:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:801:12)
    at executeUserCode (internal/bootstrap/node.js:526:15)
    at startMainThreadExecution (internal/bootstrap/node.js:439:3)
root@ubuntu:~/bustabit-depositor/src#

Any suggestions would be greatly appreciated. I don't even know how to work around this as there's no results online about this. Maybe i'm just dumb haha

First, note that HDNode was removed in 4.0.0, so you should use the BIP32 module you included. Second, you don't need the extra keyPair property, so your code becomes:

var bip32 = require('bip32')

var privKey = process.env.BIP32_PRIV;
var hdNode = bip32.fromBase58(privKey);

var count = process.env.GENERATE_ADDRESSES ? parseInt(process.env.GENERATE_ADDRESSES) : 1000; // how many addresses to watch

var rescan = 'false';

for (var i = 1; i <= count; ++i) {
  console.log('bitcoin-cli importprivkey ' +  hdNode.derive(i).toWIF() + " '' " + rescan)
}


How many nodes need to validate a newly created block? It must be impossible for a newly created block to be propagated and validated by every node in bitcoin network considering offline nodes and the ones with poor Internet connectivity.

How many validations is sufficient for a newly create block to be added as the latest block?

Every node in the Bitcoin network acts independently. When a node hears about a new block, it will perform a series of checks to see if it is valid according to the network's rules.

If the block is valid, the node adds it onto it's local copy of the blockchain, and broadcasts the block to the other nodes its connected to.

If the block isn't valid, the node will reject it, and not broadcast it.

So by following the network's rules, even though each node acts independently, together the network is able to remain in consensus regarding the blockchain history.


Can an account prefix in a NXT clone blockchain be longer than three characters? I'm getting errors setting up the account prefix after cloning NXT with the Nxt Blockchain Creation Kit. Are there restrictions on how many characters?

No, currently the account prefix (ACCOUNT_PREFIX constant) must be exactly 3 characters. This could be fixed in future.


Is 30,000 rounds really needed for PBKDF2? In the browser, I'm using AES-256-CBC with 128bit IV & PBKDF2 to encrypt the mnemonic

"tell file snow green proof evil six squeeze budget various orbit clock"

with a password

"s0mesuperl0ng!password@!"

with 30,000 rounds it's taking roughly 22 seconds. It feels too long, but I don't want to make it insecure.

Can I safely reduce the rounds to make it a bit faster? and if so what would be the minimum?

Could I get away with 10,000?

Can I safely reduce the rounds to make it a bit faster? and if so what would be the minimum?
Could I get away with 10,000?

Anyone trying to crack your encrypted data is not going to be limited by the speed of javascript executing in a browser. They'll be running FPGAs or something much faster than that. So 20,000, 10,000 or 0 doesn't make any sort of difference here.
Where I learned this


What happens if R is not revealed by one of Lightning Network nodes? (Payment cancelation) Let's say we have route of 3 hops A -> B -> C -> D (A pays D). And in the middle of payment (revealing secret R stage) node C disappear from network. In this case B will be not able to finalise payment because he don't know secret of hashlock.

I know that there is timelock, so most probably node B will need to start closing channel procedure (channel B -> C).

But what is happening with payment? Is it accepted/rejected/hanging? What is happening with A->B and C->D channels? Will they be hanging until situation with B->C is resolved? Or there is some kind of payment cancelation protocol?

The situation is less worse than you seem to assume. If node C disappears the channel A,B won't be affected. Also there is no direct need to affect the channel B, C and C, D. So most channels will stay open.

The payment process is a two stage process and it depends during which stage of the process node C disappears to see what happens and how nodes react.

First stage: setting up htlcs from A to D. If C disappears before the htlcs have reached C the onion /payment is cancelled. No channel will be closed. Otherwise the resolution of the second stage takes place.

Second stage: preimage is propagated. Node D might force close the channel to settle the htlc on chain. In that case B could also see the preimage on chain an settle off chain. C has time to come back and claim money from B. If C is away too long C will have lost money sich B will have won. If D has settled before C disappears C will not be incentivesed to disappear as C could not get Reimbursed by B.

So we see the only channel that might break in such a situation is the C,D channel. But in any cases only C can loose money / funds by disappearing. This C is Incentivised to stay online and be responsive


How can someone get my private data (such as email, name, IP ...) from bitcoin transaction? I am curious about privacy of bitcoin transactions. I heard that if you are good enough at hacking, you can get private data from bitcoin transaction, or associate someone to transaction. How is it possible? Is it possible to associate someone to transaction without IP (for example: I don't know IP, but know email or other private data), or is there some other ways to do so? Can someone explain this side of BTC transactions really well?

IP addresses are not private information. As for email and name no one can get that information based on the blockchain data alone unless you go out of your way to publicly associate your identity with a specific address. For example by mentioning your email, name and address together on some website. Another possibility is that you reveal your identity to some service like a bitcoin exchange or payment processor and then send or receive bitcoin using that service. That service will now have some idea of what addresses belong to you simply because you used their service. The world at large will not know though.

Note also that you have many addresses in your wallet not just one address. Ideally you use a different address each time you want to receive bitcoin. This is better from a privacy and security standpoint. It also makes it easy for you to track who sent you how much by giving each person a different address for every transaction.


Alternative: Mining scheme driven by logistic function Could a mining scheme driven by logistic function bring a greater price (= exchange rate) stability to a crypto-currency in comparison to Bitcoin for example since it better models natural growth?

Simply the monetary base would grow according to this function. This would mean that till half of the scheme period block rewards would rise from 0 coins to X coins and in the second half fall from X to 0. After the scheme's period would be over and all currency had been mined, transaction fees could be introduced to keep the system working.

Picture: Chart of logistic function (credits: https://en.wikipedia.org/wiki/File:Logistic-curve.svg)

I think this is a viable idea and is worth exploring further, Are there any alt coins employing this function yet?

I have been thinking about it for over a year now and see that with Bitcoin by having the early adopters hold a majority of coins helps to preserve the original protocol, as those invested in the system stand to lose the most if it is changed.    The result is as the Bitcoin network grows the protocol and clients side use of the network is strengthened by the coins that will remain with the preferred fork.

With the normal distribution model facilitated by a logistic function, early adopters will not hold as much influence in keeping the original intent of the protocol intact, as early majority adopters will hold the most influence.

There are possible alternates like a proof of stake, mining option that could be reworded for maintaining the original blockchain, and can be redeemed/ utilised as a stake to mine, thus regulating mining growth with that of maintaining the growth in bandwidth and storage. (allowing for 2 specialisations: 1) mining coins - 2) maintaining the block chain.

The result is when mining jumps significantly: 1) early adopters can sell their mining options (maintaining the original protocall) 2) the market demand to mine more is held in balance with bandwidth and storage growth. (making it more environmentally viable and allowing for greater decentralised block chain storage.)

Ie. the protocol stake holders are the ones who maintain the block chain. And to do a 51% attack you would have to strengthen the base network, I can imagine preventing modification of the block chain.


multiple outputs, address forking i did read up some stuff about bitcoin but never used it until today. i might be asking something very obvious, but how can i get rid of address forking? that is, after several transactions my address list grown and each has a tiny amount of btc(its a mess now, and it was unexpected for me). i would like to send further transactions without implicit generation of new addresses, how can that be achieved? i use bitcoin-qt or bitcoind.

should i be using createrawtransaction to reassemble my btc to one address and avoid forking in the future?

If you have not seen this yet, here is a diagram by zerohedge.com I found enlightening in order to understand how transactions fit into the Bitcoin concept.

The wiki at bitcoin.it has a more in detail overview of the inner works of Transactions and the inner workings of Raw Transactions.

From what I understand inputs to Bitcoin addresses are always spent completely in a transaction, so whatever you don't assign to a recipient will be available to be collected by a miner as transaction fee. So you'd need to set your client software to use the same address as source as well as for the recipient address of the transaction's change.

You could create a transaction that collects the complete balance from your wallet and sends them to a single output address. However, it is beneficial to use more than one address in order to make it more difficult to connect different transactions as belonging to the same identity. The bitcoin.it wiki has more information on privacy concerns

Additionally, Gavin Andresen, the lead developer of the reference client explained in this question, why change is sent to another address.


Bitcoin investment vehicles I've heard of at least 2 financial products which enable people to take positions on bitcoin in the stock market. Here's a Reuter's article on one. Can anyone explain what the purpose of these investment vehicles is? Why would someone want to pay a financial institution ~2%/year to hold their bitcoin for them? Not to mention the counterparty risk...

  "By listing the ETI on the Gibraltar Stock Exchange, which is an EU-regulated market, we are able to bring a high level of transparency and liquidity to investors", said Revoltura CEO Ransu Salovaara.

Transparency? How is an opaque financial product - which may or may not be backed by actual bitcoin - going to provide more transparency than trades on a public blockchain?

Is this simply a money grab to exploit the people who don't have a clue or am I missing something?

Regarding audience: ETIs are regulated. Not just regulated, but they are marketed for sophisticated investors. In fact regulation prevents marketing these for general audience, so there shouldn't be issues having investors who do not know what they are doing. Investors in this case are banks and pension fund like actor, though I am not sure what's the definition of the sophisticated investor in EU.
Regarding cost: There is a premium cost bringing a new investment vehicle to market. Mainly, because to have something regulated it should be insured. Bitcoin is very new. Financial market operators are not familiar with all risk models yet. Thus, insurance carries a high premium. BitcoinETI is audited by PriceWaterhouseCoopers and needs to pay various fees to stock markets, exchanges and such. For comparison, Digital Currency Group's Grayscale Bitcoin trust carries 2% maintenance fee.
Regarding transparency: BitcoinETI prospectus is public, vetted by regulators and all fees are clear up front. The ETI must publish it Net Asset Value (NAV) continuously. Public blockchain doesn't include fiat nominated (USD, EUR) transactions of traded Bitcoins. These are internal to Bitcoin exchanges. Some exchanges choose to publish this data independently. Even if it's published, it is suspected that many Chinese exchanges manipulate this data. As virtual currency exchanges companies are not regulated, this practice cannot be confirmed or stopped.


Transferring Bitcoins from Wallet to Wallet Say I buy a Bitcoin from a specific market, like BTC-e, and it goes into my wallet. Is it possible for me to transfer that Bitcoin from its current wallet (BTC-e) into a wallet that I have on another market, like LocalBitcoins? If so, how can I do that and is there a fee?

Also, do all markets (BTC-e, LocalBitcoins, etc.) allow you to withdraw a Bitcoin from your wallet and exchange it for cash?

1) The exchange that has your bitcoin should have the option to withdraw bitcoins. It will then ask you to what bitcoin address you want to withdraw and how much.

2) The exchange you want to transfer the bitcoin to should have the option to deposit bitcoins, which will give you a bitcoin address to transfer to.

3) You can then directly withdraw your bitcoins to your deposit address.

4) Almost always these kinds of withdrawals and deposits are free except for the miner's fee, which will usually be BTC 0.0001.

5) No, exchange for cash is not always supported. I don't think a lot of exchanges would support this at all actually (unless by cash you also mean bank transfers?)


How to resolve eclair-node-gui-0.3.3-12ac145.jar getting CAPSULE EXCEPTION after java update to version 11.0.9.1? I've been running Eclair node release eclair-node-gui-0.3.3-12ac145.jar smoothly for some time now on Ubuntu 18.04.5 LTS, but recently had an update to the java version i was using to the latest (?) through the software updater to java version 11.0.9.1.
This now causes the usual procedure i took to run the node -
open terminal -
cd Downloads
java -jar eclair-node-gui-0.3.3-12ac145.jar

to fail. The terminal gives me the following message:

CAPSULE EXCEPTION: Could not parse version: 11.0.9.1 while processing attribute Min-Update-Version: {} (for stack trace, run with -Dcapsule.log=verbose)
USAGE: java  -jar eclair-node-gui-0.3.3-12ac145.jar
Actions:
capsule.version - Prints the capsule and application versions.
capsule.modes - Prints all available capsule modes.
capsule.jvms - Prints a list of all JVM installations found.
capsule.help - Prints this help message.
Options:
capsule.mode= - Picks the capsule mode to run.
capsule.reset - Resets the capsule cache before launching. The capsule to be re-extracted (if applicable), and other possibly cached files will be recreated.
capsule.log= (default: quiet) - Picks a log level. Must be one of none, quiet, verbose, or debug.
capsule.java.home= - Sets the location of the Java home (JVM installation directory) to use; If 'current' forces the use of the JVM that launched the capsule.
capsule.java.cmd= - Sets the path to the Java executable to use.
capsule.jvm.args= - Sets additional JVM arguments to use when running the application.
I have tried vainly to tease some information from the terminal by trying to paste some of the actions and options commands in ,in the form of, for example -
java capsule.version -jar eclair-node-gui-0.3.3-12ac145.jar
to be met with-
Error: Could not find or load main class capsule.version
Caused by: java.lang.ClassNotFoundException: capsule.version
and -
java capsule.reset -jar eclair-node-gui-0.3.3-12ac145.jar
Error: Could not find or load main class capsule.reset
Caused by: java.lang.ClassNotFoundException: capsule.reset
Would appreciate any advice on where i stand with resolving this problem.

You're using a very old version of eclair which used Capsule to simplify packaging and deployment. We've moved away from Capsule (which seems to be a dead project) quite some time ago and now package applications as zipped directories which include a bin/ subfolder with launcher scripts for linux/macos/windows. I strongly suggest that you upgrade your node to the latest release of eclair which you'll find there: https://github.com/ACINQ/eclair/releases. I also suggest that you switch from the GUI (we don't package it anymore but it's very easy to build yourself) to the server version and use it through it's JSON API.
You can get technical support for eclair at https://gitter.im/ACINQ/eclair if needed. Thanks!


Is there any way to store personal data in a blockchain? Generally everyone can see all data stored in a blockchain.
Is there any way to handle private personal data like personal medical records which only right person can see?

You can store data or its hash in the blockchain using OP_RETURN outputs which can store up to 80 bytes http://blog.coinprism.com/2015/02/11/80-bytes-op-return/


How does WalletExplorer know which wallets belong to whom? I do understand that for two addresses to be on the same side of a transaction, they must be within the same wallet, since one private key is used to sign a transaction.

However, how is WalletExplorer able to put a name to some of these wallets?

What walletexplorer does is called address clustering. When you spend bitcoins, your wallet will take input from several txouts belonging to several addresses depending on amount to be spend. So walletexplorer works on a simple heuristic:

If two addresses appear as inputs in any given transaction, they belong to same user

More detail about this method can be seen in this paper by Reid and Harrigan. Of course, this method will fail in case of mixers and coinjoin transactions. There are advanced ways to even detect transaction that go through mixers, but I don't think wallet explorer does that

To find name of wallets it can scrap forums like bitcointalk, some addresses are tagged publicly in blockchain.info, also it can has bots trade on major exchanges to get their addresses.


How to download blk.dat files from a specific block number? I want to download blk.dat of a specific block number, How can I do this ?

Note: I'm only interested in specific blocks, I only want to download blocks for example that are numbered between 100 and 200,etc...

I see two broad solutions:
Use an API that allows you to get blocks by block height
BlockChain.info allows you to query for blocks at a certain height. Example:
https://blockchain.info/block-height/100?format=json

returns
{ "blocks" : [
{
    "hash":"000000007bc154e0fa7ea32218a72fe2c1bb9f86cf8c9ebf9a715ed27fdb229a",
    "ver":1,
(snipped)

(Remember to filter out blocks that aren't on the main chain, by looking at the "main_chain" attribute.)
You can take that hash, and look up the block:
https://blockchain.info/rawblock/000000007bc154e0fa7ea32218a72fe2c1bb9f86cf8c9ebf9a715ed27fdb229a

returns
{
    "hash":"000000007bc154e0fa7ea32218a72fe2c1bb9f86cf8c9ebf9a715ed27fdb229a",
    "ver":1,
    "prev_block":"00000000cd9b12643e6854cb25939b39cd7a1ad0af31a9bd8b2efe67854b1995",
    "mrkl_root":"2d05f0c9c3e1c226e63b5fac240137687544cf631cd616fd34fd188fc9020866",
    "time":1231660825,
(snipped)

(This is in a JSON format custom to BlockChain - I haven't found any API providers that will return the raw block. Kinda annoying.)
Write a client that gets the blocks from the network
This downloads the headers of the Bitcoin blockchain (much smaller than the whole blockchain). Then, it goes through the block headers and downloads the ones you want.
WalletAppKit kit = new WalletAppKit(MainNetParams.get(), new java.io.File("."), "test");
// Download headers
kit.startAndWait();
BlockChain chain = kit.chain();
BlockStore bs = chain.getBlockStore();
Peer peer = kit.peerGroup().getDownloadPeer();
// Get last block
StoredBlock current = bs.getChainHead();
// Loop until you reach the genesis block
while(current.getHeight() > 1) {
    // Fully download blocks between 100 and 200
    if(100 <= current.getHeight() && current.getHeight() <= 200) {
        Block b = peer.getBlock(current.getHeader().getHash()).get();
        System.out.println(b);
    }
    current = current.getPrev(bs);
}

This example uses BitcoinJ, but other SPV Bitcoin libraries can do this too.
(Thanks to Diego Basch for the code.)


What's a better investment? Buying an ASIC-based mining rig, or buying bitcoin itself? Seems like some miners are saying they would have made more money by simply buying and holding Bitcoin, rather than mining it. Is that likely to be the case going forward? I know I'm asking for speculation -- but, if one is working under the bullish assumption that BTC will gain in popularity and more people will start using it, is it a better bet to buy and hold than to invest in mining equipment?

Investing in expensive mining equipment hedges a bet that the return on investment, in the form of Bitcoin, will eventually pay off the initial investment and continue paying a return for some time before becoming obsolete (like CPU mining has and GPU mining shortly will) or breaking down. It may be possible operate this as a business, writing off expenses while selling generated Bitcoin for a profit. This is all based on an assumption that this mining system may eventually be profitable. It's safe to assume that it will be once running, but, like any dividend play, it's a long term investment. Unlike dividend plays, the return will likely only decrease over time.

By buying Bitcoin itself, one participates in the economy. While Bitcoin supporters would hope that one would not hold on to Bitcoin as an investment, but rather spend it in order to further the economy, it is possible to still make a return on investment if one's goal is to earn a return in government issued currency.

Consider a $1,200 investment in a mining setup versus a $1,200 investment in Bitcoin itself.

The former is a long term play, slowing building up to profitability through the course of months or years. Something may happen that causes the system to fail and halt returns.

The latter is a more liquid play, where one can sell the Bitcoin at a profit (or loss) short-term or long-term, or exchange Bitcoin for goods and services, thereby furthering the economy.

It comes down to investment style. Does one fancy themselves a miner or a jeweler?


Fastest filesystem for blockchain? I am running Linux with a harddisk. Currently the blockchain is on an NTFS partition, which probably isn't the fastest. Which filesystem should I choose? As I understand it, a Bitcoin node will only ever append to the blockchain, which means I should not choose a filesystem that is optimized for e.g. fast deletion.

Bitcoin-Core does serval read and write operations. Blocks can also get deleted in case you have enabled -prune. There are many read operations because your node will very likely serve/relay blocks to other nodes.

The performance of bitcoin-core is more likely constraint by your CPU because of heavy EC verify operations.


On SPV clients and Segwit An article released by Blockstream claims that after Segwit, SPV clients can verify that transactions have been accepted by the network without having to download the signatures/witness-data.

I'm trying to understand why this was not possible pre-Segwit. Why was the signature data a part of what's sent to an SPV client, when it was of no use to them anyway?

Pre-segwit, the TXID was a hash over the scriptSig (signature data) and the outputs (value, locational data). SPV clients can not validate signature data by definition, so this is not useful information for them to have for anything but verifying the TXIDs position in the merkle tree. For segwit outputs the signatures can be stripped before being provided without altering the TXID, with massive data transfer savings.


BitCoin Linux Application / Proper method to set up 1 - Can I run the BitCoin daemon (before KDM is even started)?

2 - Once I've started KDM, can I then run the GUI which will attach to the daemon, so only one BitCoin 'app' actually working?

3 - Can you get a status report from bitcoin-cli, similar to the qt-app (status of catching/caught up with blocks etc...)

Following the BitCoin Install Guide , I ran the qt-app after installtion, it worked fine. I tried the daemon after and got issues with 'no cookies' / problem with rpc authorisation.  I've also stopped the qt-app, then tried the daemon, it worked fine, then tried the qt-app and it complained something was already connected to the default port.

What is the correct order of running it, note the machine is on 24/7 (minus the desktop).

1 - Can I run the BitCoin daemon (before KDM is even started)?

You can run the non-graphical bitcoind daemon with or without starting KDM first.

  2 - Once I've started KDM, can I then run the GUI which will attach to the daemon, so only one BitCoin 'app' actually working?

No. You can stop bitcoind and start Bitcoin-Qt, though.

  3 - Can you get a status report from bitcoin-cli, similar to the qt-app (status of catching/caught up with blocks etc...)

Yes.

bitcoin-cli getblockchaininfo

(Source.)


Is the first input in a transaction always the sender's? I'm trying to figure out what the input address is from a transaction with multiple inputs. Can it safely be said that the first input in the inputs of the transaction is the sender's?

Can it safely be said that the first input in the inputs of the transaction is the sender's?

No, no such ordering exists.
Transactions consume UTXOs as inputs, and create new UTXOs as outputs. A transaction can have multiple inputs from one person, or inputs from multiple people. In some cases, more than one person can own an input. So there isn't really any useful way to point to a particular input in a random transaction, and say "this is from the sender".
In cases where there are two or more inputs, there is also the potential that the transaction is a 'payjoin' style transaction, which is specifically built to break common heuristics that attempt to determine UTXO ownership/transaction participation.
More generally, it is prudent to craft transactions in ways which do not surrender information needlessly, so that you can maintain privacy while still engaging with the Bitcoin network.


Check which bitcoind version I am running I have a version of bitcoind on my server and I can't remember which version it is.

How can I find out what version my bitcoind is ?

eg: ./bitcoind -version ..or such

EDIT: As of 0.16.0, use getnetworkinfo to get the version of bitcoind:

getnetworkinfo: version, protocolversion, timeoffset, connections, proxy, relayfee, warnings

Send a getinfo command to the server. It shows the version of bitcoind:

{
  "version": 80400,
  "protocolversion": 70001,
  "walletversion": 60000,
  "balance": 102.2899977,
  "blocks": 104358,
  "timeoffset": 1,
  "connections": 15,
  "proxy": "",
  "difficulty": 1.0,
  "testnet": true,
  "keypoololdest": 1372886245,
  "keypoolsize": 101,
  "paytxfee": 0.0,
  "errors": ""
}


Share balance between lnd and bitcoind I have a bitcoind instance with some balance. When I run lnd (which is connected to this bitcoind instance) it seems to use its own wallet. Is there any way I can use lnd with the bitcoind balance without having to send the coins to lnd wallet?

As far as I know, this is not possible. lnd and bitcoind are two separate daemons, that interact with the bitcoin network in different ways.

The only way I could think of doing this would be to import keys from one daemon to the other, but exploring the help command of lnd I'm not currently seeing any options to import or export private keys.

In any case, I think sharing keys across the daemons may in fact be dangerous, as bitcoind will not recognize funds as being locked in a LN channel. So if bitcoind tried to spend a LN channel UTXO, it may cause a total loss of that channel's funds (since your published transaction was not the LN channel's most recent state, the counterparty would broadcast the revocation transaction, and all funds would be spent to them). Perhaps someone with a deeper knowledge of these daemons could comment, but by my reasoning I believe this would be true


Does a HD Wallet log my IP when i do a transaction? Companies like BitPay and Electrum, can log my IP when I make a transaction, right? If so, should I use a Web Wallet (plus VPN) for transactions?

HD vs non-deterministic:

"HD" means "hierarchical deterministic".

"deterministic" means: all your private keys are generated from a seed, "knowing your seed = knowing all your private keys", so that frequent backup is no longer needed.

"hierarchical" means: you can manage multiple coins/accounts/address types with only one seed. Watch-only wallets are supposed to import account extended public keys only, instead of the master public key, so that: even if there's a security breach, hardened parent nodes could still protect other accounts from being hacked, as long as the master private key is not leaked.

HD only affects how your private keys are generated and how you should backup your wallet. It has nothing to do with how you broadcast a transaction, nor with your IP address.

Bitcoin-QT was once a non-deterministic wallet: all private keys are independently generated. This might be true even if you are using a modern version of Bitcoin Core (which supports HD since 0.13), since Bitcoin Core won't upgrade a legacy non-deterministic wallet.dat to HD automatically. You can upgrade it manually by restarting Bitcoin Core with -upgradewallet command-line argument - of course, you must backup your wallet once again after this operation. BTW, if you enabled wallet encryption, or executed something like importprivkey or sethdseed in the console, you also need to backup it once again.

However, Bitcoin Core uses hardened address derivation, which means you cannot export any xpub extended public key to a watch-only wallet. Besides, Bitcoin Core doesn't provide any mnemonic.

Full node vs light-weight client

Full node wallets like Bitcoin Core reconstruct your wallet balance and transaction history by rescaning the whole blockchain locally, so that the receiving privacy is almost perfect - however, this is true only for 3rd party surveillance, your transacting counterparty obviously knows that the address which you gave him belongs to you, so that he can still try to track your transactions, which is exactly why the users are suggested to avoid address reuse (including both receiving and change address).

Light-weight clients like Electrum ask other people for your transaction history and wallet balance, so there are inevitably some privacy leaks. However, Electrum uses TLS to encrypt the traffic, so that your ISP/public WiFi provider/etc won't know your transaction history and wallet balance. You may use Tor to hide your IP address, but the Electrum server is still able to log which addresses have common owner.

BTW: Electrum servers are not controlled by the developers. Anyone is able to spin up his own server to join the network.

As for sending privacy, the Electrum server which you are using obviously knows both your IP address and what transaction you are broadcasting. However, since your connection to the Electrum server is encrypted by TLS, middlemen like your ISP cannot sniff what transaction you are sending.

Bitcoin Core relays other transactions by default, which makes traffic sniffing a little bit tricky, but not impossible still. Anyone who's able to monitor your Internet traffic, including your ISP/public WiFi provider/etc, is also able to find out which transaction is sent by you. Elipse attack is also likely to be a threat. Therefore, to protect your sending privacy, you may use Tor to broadcast your raw transaction (you may use Tor browser with an online block explorer service which supports transaction broadcasting, like this).

Using Tor with full node is still not enough

All bitcoin transactions are public information. For example, sending coins (UTXOs in other terms) which were received from different origins can reveal that they had a common owner (this was mentioned in Satoshi's whitepaper). You may learn some more advanced techniques to protect your privacy further: https://en.bitcoin.it/wiki/Privacy


Which part of code (function) handles received transactions? I was trying to understand the flow of control between functions (operations performed and their order) when a transaction is received.

Any transaction

main.cpp, AcceptToMemoryPool:

bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,
                        bool* pfMissingInputs, bool fRejectInsaneFee)

A transaction that pays to or from you

wallet.cpp, CWallet::AddToWallet:

bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet)


Previous block hash on first Bitcoin block? The bitcoin-explorer command bx fetch-header -t 1 fetches the first Bitcoin block and shows the block header.
If I check the "first" block header, where does "previous block hash" come from?

Found the solution, the command for the genesis block should be:

bx fetch-header -t 0


Who can change the code governing how much of BTC is released? I understand that BTC's will be continually released by the year 2040, when it will reach 21M coins. Actual numbers don't really matter, but I'm interested in who has the power to change this rule. Is this an individual, a "github community"?

It's a bit complicated. Anyone can do it and nobody can...

Let's assume that you want to increase the total number of bitcoins to 42M. To do so you need to:

implement it in code
convince the community that it is a good thing
make a hard fork and hope that miners and users will support you

Something similar but in a smaller scale was happening for the last few years. It was about bitcoin block size, not the amount, but the principle was similar: people were suggesting 2MB blocks, 8MB blocks, variable size blocks and many other things and were trying to convince people that it is necessary, making there own forks and hoping they will become a real bitcoin (Bitcoin Cash, Bitcon ABC, Bitcoin Insert Your Fork Name Here)

As you can see, the block size is still 1MB. The same is with the total amount of bitcoins - you need to convince the majority of the community, then it can become true. But I doubt that anyone could ever do it.


Transfer coins from Armory paper backup without Armory I have an armory offline installation on a USB stick with Ubuntu. From this wallet I have a paper backup. To access my funds I tried to install Armory on Mac OS and Windows 7 with no luck. The best result was on the mac. Bitcoin QT is running and is completely synchronized. But if I start Armory it stays at status "Organizing Blockchain" forever. I just ordered a Trezor to get around this problem in the future.

So my question: How can I transfer my coins from the armory cold-storage to a new address without an armory online installation?

Here it is step-by-step

Run armory in offline mode (simply run armory --offline)
Import the wallet into armory if you haven't already. (Import wallet, etc) (you probably don't need to do this if you have it on USB, just run that instance)
Click on the wallet and click "Backup This Wallet" and enter the password.
Select "Export Key Lists" and click the button at the bottom
Check "Private Key (Plain Base58)" from the checklist and nothing else.
Select "Omit spaces in key data", as these may cause an "Invalid private key encoding" during import
Take each private key listed in the window and import them into some other program (this might take a while)
Transfer the funds from the private key to a new address.


Can A Raspberry pi mine bitcoin without an ASIC miner? I want to know if a raspberry pi can mine bitcoin without using an ASIC miner.

You certainly can compile a Bitcoin node on a Raspberry Pi, and it will act as a fullnode relaying transactions for the network.  For mining, while it probably would work technically, the chances of you ever mining a bitcoin are so low that its probably a waste of time.

You can run other coins based on PoS on a Raspberry Pi though and make money that way, I personally use Raspberry Pis as my Gridcoin and SolarCoin staking nodes.


What are the relations between these number theorems and ECC? I'm currently working on a bigger assignment where I have to write about the connection between bitcoin/blockchain and maths. I've gotten far, but one of my tasks is to talk about principal rest, modulus, greatest common divisor, the fundamentals of arithmetic theorem, fermats theorem, eulers theorem and function.

The point of the assignment is to make everything as a flow, and not go out of context, so I'm wondering what all of these mathematical theories has to do with bitcoin and blockchain.

Any answers or sources to where I can read about it, would be highly appreciated!

Only on a high level (because I won't do your homework for you)

principal rest and modulus create groups in particular F_p which are fields arising from the the ring of integer modulo a prime. You can look at elliptic curves over such a field (which is a discrete set of points) and define a geometric point addition which (surprisingly?) is a group again. If you find cyclic subgroup with a generator of high (prime) order it will be useful for cryptography for two reasons:

The discrete log problem seems to be difficult
Related to 1.) factorizing the large generator into its primes is hard (which is related to the fact that computing the greatest common divisor) is also hard.

I hope you see the gist where this is going. I strongly recommend reading up the wikipedia articles of the topics you mention. But connecting the dots is obviously  up to you.


Having trouble getting poclbm to work on linux, Segmentation fault I am a linux noob, so please take that in to account.  I believe i have compile poclbm and all it's dependencies correctly however when I try and run it

python poclbm.py http://xxxx@xxxxx@pit.deepbit.net:8332 -d 0

I get the following error

21/02/2014 15:45:26, Setting server (xxxx@xxxxx @ pit.deepbit.net:8332)
pit.deepbit.net:8332 21/02/2014 15:45:26, checking for stratum...
Segmentation fault

Does anyone have an idea of why this might be happening?  Changing my logging a bit I can see it's a 3044 Segmentation fault.

Thank you

This turned out to be a problem with installing two different versions of the nvidia driver on *nix


How can I start mining Bitcoin? Ok. I don't care if I make only a small amount of bitcoins mining. I want to mine.

How do I setup my machine (amd x64 4.6Ghz 6GB/RAM with GeForce Nvidia 7300, LinuxMint 10) to start mining?

Is it damn simple, or it's a damn-high-geek-setup?

Can I set up to use both CPU and GPU?

How much should I expect in this simple system per month with my machine on all time?

Please check this question first:
How much Bitcoin will I mine right now with hardware X?

Before you go through all this work, it is important to know what to expect from your hardware.

There are two options: solo mining or pool mining. Unless you have a lot of computing power (several ASICs), you should probably mine at a pool.

So the first thing to do is to sign up at a bitcoin pool. The stickies in this bitcointalk section have links for the top 10 pools. The main differences between them are the payout models and the fees. If you just want to try things out, choose one of the most popular pools like Deepbit or BTC Guild. You can then try others, according to your needs.

Now you need to install a miner. It has a simple interface, a drop down menu with a list of pre-configured pools and it is not difficult to setup.

After you install the miner, you need to point it towards your pool. So select device you want to mine with (probably your FPGA/ASIC), enter the pool URL (if you don't know what it is, check the FAQ/help section of your pool's website) and your username/password.

That's it. You can now see your progress at the pool's website.

Useful links:

What is a Mining Pool, what is it good for?
Is CPU mining even worth it?
What is a good mining pool/payout model for infrequent mining?

In your specific case, you have no ASICs or FPGAs, so you will earn less than a penny of Bitcoin.


How can I ensure that bitcoind does not use unspent outputs for a given address? With RPC calls to bitcoind, from separate (python) scripts, I'm:

calling getnewaddress to set up a new key pair for a 'special' address, assigned to a distinct account (let's call this 'specialAccount')
building raw transactions (outside bitcoind) that spend outputs to this special address and then calling bitcoind to sign send

In addition to the above, it is possible that bitcoind is also called directly, to make payments, or whatever.

How can I be absolutely sure that bitcoind does not consume outputs to my special address outside of signing outputs to this address in signrawtransaction?

We can assume that there are no calls that explicitly spend from 'specialAccount', but the problem is that, as I understand it, it is possible for bitcoind to borrow arbitrary unspent outputs for the purpose of paying transaction fees. (See this issue, for example, and also this one.)

Is there any way for me to lock the special address, and prevent this being used to pay transaction fees for other accounts, or to otherwise be able to use bitcoind to sign raw transactions that use outputs to this address without making the public key for the address more generally available within bitcoind?

You can use lockunspent to lock (in-memory only) unspent inputs created by transactions whose at least one output was pointing to your "special address".


What happens if the US govt. bans Bitcoin? They can do that because they are the US govt.

What would be the likely consequences of the ban?

Same as the ban on drugs:

People would continue to use them, they'll just do it in secret.
The value will rise.
The government will spend lots of your taxes to try to fight it and fail.


I need to find a pool that supports cpuminer I've been to mine with cpuminer with lots of different pools but nothing works!!! I only made it to mine litecoin on litecoinpool.org, but I need bitcoin! Which pool would you recommend?

None exist. CPU mining had been impossible for years now. You better stop wasting energy and the life time of your computer.


How is the distributed transaction log stored in P2P network? After mining, a block is validated and broadcasted by the miner. Then, where does this newly mined block get stored at? Where does my Bitcoin client pull the transaction data from?

Your client gets it from another client that has already received it. You then relay it to other clients that connect to you, and the cycle repeats.


How to recover Bitcoin Cash from Multibit Wallet? I have been reading through posts and cannot figure out if this is possible or not. But I had bitcoin on an old Multibit wallet. I do not have the seed phrase from when I opened the wallet, just the key to the wallet. I have just moved the bitcoin off to a secure wallet. However is there any way to recover the bitcoin cash? Thanks in advance!

Export the private keys from the Multibit wallet, then import them into a Bitcoin Cash wallet. How to import them will depend on which wallet you choose to use.

Don't use the public addresses associated with those private keys again for Bitcoin transactions (I think you know that already though since you've already shifted your bitcoins away... which is the safe thing to do).


Understanding cryptocurrency exchange working Exchanges are 2 types : centralised and decentralised. Now, if any new user is coming to the centralised platform then they need to deposit BTC (taking BTC as an example). For depositing, each time exchanges create a public key(give this to user to deposit) and private key(hold by exchange). Now, let user have 10 BTC in his wallet (Which he can check in bitcoin explorer). In a day, he traded his 2 BTC against ETH. This 2 BTC he traded with 10 people. So, now his actual balance at his public key would be 8 BTC. And all transaction which he did with 10 people will also get reflected at bitcoin explorer. Trading also works instantaneously. it means as soon as someone sell or bought BTC, his balances get chcngaed accordingly BUT bitcoin actual transaction take 10 minutes for getting first confirmation. So, how the actual system is working behind the scene?

When users deposit cryptocurrency into an exchange, the exchange takes custody. The cryptocurrency is now the exchange's and the exchange adds a corresponding balance for the depositor to their books. The user specific address is only used to identify whom to credit the deposit to. After the deposit, there is no reason to keep track of the funds in the context of the user.

  So, now his actual balance at his public key would be 8 BTC.

Tracking all trades on the blockchain would be incredibly inefficient. Rather, the exchange updates the user's balance in their books to increase the ETH amount and decrease the BTC amount. Any balance changes of the user on the exchange are only tracked in the exchange's books until the user withdraws from the exchange. When they withdraw the exchange sends an on-chain transaction to the user and reduces the user's balance by a corresponding amount.


How do I buy bitcoins in USA? I spent last weekend learning all about Bitcoin and am excited to use them to purchase some web-based services. But alas I'm stumbling on the most fundamental part: how do I buy them?

I paid cash for a pre-paid VISA this morning, bound that card to a PayPal account, and was psych'd to start buying coins, but was bummed to discover that:

(1) PayPal wants to charge me a $14 fee to transfer $500 to a seller (rip off!)

(2) No seller wants to use PayPal because the buyer has the ability to nix the payment retroactively using a "charge back" (strange that they'd allow people to do this, but ok)

(3) This forum indicates that #1 and #2 are moot anyway because PayPal's terms of service don't allow for BTC purchases.

Yeah, I blew it. But what are my alternatives? I could use a bank account via an online exchange but that requires a lot of legal documentation and philosophically flies in the face of the whole "anonymity" feature of Bitcoin.

A lot of people are doing face to face transactions via a localized transaction match-making service. Is this really the way to go? Seems like that would make sense if you were transacting $50-$100 but what if you wanted to do $5k-$10k? I'm not Walter White. I don't have fat stacks of cash laying around. :)

What other alternatives do I have to purchase bitcoins?

For anyone else who's in the same situation...

I had some some fairly detailed discussions with some helpful folks on the #bitcoin-otc IRC channel and they gave me the scoop. To avoid getting hit with large transaction fees and/or revealing your name, SS#, routing numbers, etc., you really need to go over-the-counter.

In some cases that might mean doing the deal in person (localbitcoins.com) but a safer way is to use MoneyPak. It was described to me as follows: You buy a moneypack in whatever denomination you're interested in converting to BTC, and you provide the MP number to the seller. He, in turn, sends the coins. He can use that moneypack number to load his PayPal account and buy goods/services. The fee is $4.95 -- not unreasonable. And everything is anonymous.

The other point that was made crystal clear to me is that you can't just jump into the OTC community and start doing large volume transactions. The liquidity is there if you know where to look but the community has to trust you first. They even have a rating system.

I was walked through the initial steps of reserving a name, creating a GPG key, binding that to my identity, etc. etc. and will probably execute a few small-sized moneyPak-based transactions ($10, $50, etc.) and see how it goes.

Hope these comments will be of value to other new Bitcoin enthusiasts.


BitcoinLib SignRawTransaction JSON-RPC returns false when using private key This is a repost of (JSON-RPC signrawtransaction returns false when using private keys) but I could not comment because of my reputation (new user).

I've been using BitcoinLib via Litecoin Testnet for a week now and I got stuck with SignRawTransaction. It returns false but when I use the RPC call via litecoin-cli

litecoin-cli.exe signrawtransaction 020000000152cf5e76f1ac0fd42e97ec60db30406b019621da497601b430e7adf5642e1fa20000000000ffffffff02e09c4100000000001976a914fbb4b6ef02914490e99f899cb8538b03105331df88acc095a905000000001976a91471efff92af2740dd4fe088fc3de98ceebaa4c13488ac00000000 "[]" "[\"cQ3HSi45qrfGGZjYAci22gATWfhb1QhWR8JGBHBbzbPsD8Uuu2n2\"]"

the result is OK.

This is how I use the SignRawTransaction (Sample):

SignRawTransactionRequest signRawRequest = new SignRawTransactionRequest("020000000152cf5e76f1ac0fd42e97ec60db30406b019621da497601b430e7adf5642e1fa20000000000ffffffff02e09c4100000000001976a914fbb4b6ef02914490e99f899cb8538b03105331df88acc095a905000000001976a91471efff92af2740dd4fe088fc3de98ceebaa4c13488ac00000000");
signRawRequest.AddKey("cQ3HSi45qrfGGZjYAci22gATWfhb1QhWR8JGBHBbzbPsD8Uuu2n2");

SignRawTransactionResponse signRawResponse = coinService.SignRawTransaction(signRawRequest);

Has anyone encountered this problem before?

I'm sorry but there were missing inputs when I created my Raw transaction. This error has nothing to do with BitcoinLib.


What is the use case of bitcoind ZeroMQ? What is the use case of ZeroMQ implementation for bitcoind which will be merged into Bitcoin Core v0.12.0?

Block and Transaction Broadcasting With ZeroMQ
https://github.com/bitcoin/bitcoin/blob/master/doc/zmq.md

ZeroMQ is a publisher / subscriber messaging system. In the case of Bitcoin Core it is a socket which other applications can connect to and get notifications of new events in real time, without having to repeatedly ask the daemon if there are any new events. ZMQ support is useful for any systems interfacing with the network like miners and wallets, which can choose to subscribe either to just transaction notifications or block notifications as their situation requires. It covers a lot of the same use area as the prexisting walletnotify and blocknotify systems, but with significantly improved performance and ease of configuration. These older systems have the unfortunate side effect of spawning a new process for every notification, which tends to incapacitate the host if not used extremely carefully.


How to correctly implement the FEE increase using bitcoind? I have read that once a Bitcoin transaction is created, it never automatically expires. In theory, a transaction could be created, get stuck at 0 confirmations for some years, and then all of a sudden confirm.

The proper way of increasing the fee would be to send another transaction that uses exactly the same coins as the first transaction.

How can I program the correct way via bitcoind?
Which commands should I use?

You can use Opt-in Replace By Fee to do this. Bitcoin Core already implements support for signaling Opt-in RBF and for increasing the fee later (with some caveats).

When creating a transaction from the command line, the send* commands have an optional argument named replaceable. If you set that to true, then the transaction created will automatically signal that it can be replaced in the future. To increase your fee, you then use the bumpfee command. Note that the command currently only works if the transaction has a change output. The fee will be deducted from the change output.

Note that these commands and the arguments are not necessarily listed on the bitcoin wiki (it is frequently out of date). To actually get the full listing of RPC commands, their arguments, and how to use them, use the help and help <command> commands.


Blockchain.info: Which address should I give for "New Shared Address"? I am new to Blockchain.info's wallet's features.

I clicked the "Receive Money" tab, then clicked "Shared" and then the green button labeled "New Shared Address". It gave me the following:

Address       Forward to      Expires in
abcdefg       123456          3 days

Which address should I give to my friend so that he will send the funds to a shared wallet of my account?

The one marked "Address". It will forward it to the one marked "Forward To".


Correct way to use joinpsbt for manual coinjoin? I am developing a feature in my app for "manual coinjoins" which follows this as inspiration: https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#Manual_CoinJoin_Workflow

I am not an experienced coinjoin user and just want to make sure I am not missing something here.

The flow I am using is:

User A creates a PSBT with one utxo input of 0.1 btc and one output of 0.0995 btc sending the output to a new address of theirs.
User A processes the PSBT to sign for the input.

User A passes the PSBT on to user B who creates another PSBT with identical input amount and identical output amount and processes the PSBT to sign the input.

User B can pass it on to others who repeat the process or finalize and broadcast.

Is this the proper way to do it? Does the order in which the users process the PSBT with their wallet matter?

No, that won't work. joinpsbts must be used before any signatures are created. Otherwise existing signatures will not be valid for the joined transaction. Rather, each person must create their own PSBT, send them to each other or to some coordinator where the PSBTs are then joined together with joinpsbts. Then the joined PSBT can be distributed back to everyone, who processes and signs it. Once signed, each person must, again, send the signed PSBT to everyone else or to the coordinator where all the PSBTs are combined with combinepsbt. Then the combined PSBT can be finalized and broadcast.

Note that currently joinpsbts has a major privacy leak as the inputs and outputs are added to the joined PSBT in the order that the transactions were specified. There is an open Pull Request that fixes this issue.


How is the lightning network secured against hacking and double spends? As I understand payment-channels, like the lightning network, they are working off chain (no record in the blockchain). The only record to the blockchain is the deposit transaction to open the payment-channel and by closing the payment channel. But later all the transactions inside the payment-channel running on centralized servers, like traditional bank transfers. This is very fast, and could be very cheap if there is competition. But how the banks, who would run such payment-channels can secure that inside the payment-channel the transactions are not hacked and safe? And how the bank guarantee the customers that they dont double spend the funds if inside the channel all transaction are totally anonymous?

All transactions that are sent between the two parties in a channel are valid bitcoin transactions, and they can be used to close the channel at any time by either party.

When a channel is opened, those bitcoins are locked up in that channel until it is closed with a spending transaction, sending an agreed amount of bitcoin to each party in the channel. Initially this spending transaction is created to return the same amount of bitcoin that each party put in to the channel. But 'transactions' are made, which is really just each party agreeing to create new spending transactions to replace the old one, giving each party a different amount.

If each party, for example, locks in 1 BTC to a channel, they will also create a spending transaction at the same time returning that 1 BTC to each person. Then let's say person A wants to send 0.2 BTC to person B. To do this, they simply work together to create a new valid spending transaction to replace the old one, the new one would pay A 0.8 BTC and B 1.2 BTC, effectively transferring that 0.2 BTC from A to B. New transactions like this are continually created every time either person wants to send coins, until finally one of the two participants wishes to close the channel and actually get their BTC back. This also happens if one party stops responding/cooperating. The final transaction they agreed upon is broadcast to the actual blockchain, closing the channel and paying both participants.

Thus, at all times, the transactions are valid and the actual bitcoins being exchanged are locked up in the blockchain, so there is no way for anyone to double-spend the transactions.


Anyone able to run Bitcoin-Qt 0.8.6 on Mac OSX 10.9.2? I ran the Mavericks update today, putting me at 10.9.2 and now my Bitcoin-Qt stops responding after it notifies me that it is "verifying blocks". I am using it for ongoing research and am in a bad spot now. I realize I should have thought about the possible ramifications of running the update.

At any rate, is anyone able to get it to run? I've tried running it from the .dmg via the gui and via command line. I get the same results in both cases. As soon as it goes to verify blocks, it stops responding.

Yes, it's running on my system, which is a 5 year old Macbook Pro running 10.9.2.  I have 4gb ram and a 2.4ghz Core 2 Duo.

I did have problems however trying to sync the blockchain initially.  I had a partial blockchain that I had on another computer, which I copied over.  Normally in this case the computer reindexes the block files on disk, figures out where it is, and then picks up downloading from the last point.

However, I got behaviour very similar to what you're describing.  It would go to "verifying blocks" and stay that way for a very long time.

In the end I fixed it by deleting all of my previous blockchain (I deleted everything but wallet.dat), and then let the app download the blockchain from the beginning.  It took about 4 days, but in the end it works as expected.

Didn't really test it out much, but I don't think I saw the same thing on my 20gb Mac Pro, so I think the MacBook was just too resource constrained.

Also, the new Bitcoin coming out, Bitcoin 0.90, is available as a 64 bit app for Mac OSX, so this will likely help. I'm running 0.90 on my Windows machine and it's fine.  Haven't put it on the Mac yet.


Why do we need Proof of Work in bitcoin? I know that proof of work shows that the person has put in some time and power into the processing. I also know that bitcoin mining is adding a transaction into the blockchain and then the miner will need to solve a pow problem.

Why do we need this? What if we eliminated the proof of work step for the miners and what are the consequences of doing so?

Imagine I have 1 bitcoin. And imagine I can form a transaction to send that bitcoin to Alice or I can form a transaction to send that bitcoin to Charlie.

Now, what stops me from forming both transactions? Nothing.

So, if I do that, how will people know which transaction is valid? Clearly, without some reliable way to tell which of those two transactions are valid, the system is doomed.

This is what PoW does. A miner cannot contribute PoW to both transactions at the same time -- he must pick one.


Importing private key to bitcoin node is slow. Can it be faster? I have launched the bitcoin node and synchronized it. The issue is that importing the private key forces the node to scan the blockchain for the operations with the key. Is there a way to import the key in a fast way?

No.

Bitcoin core is a full node and doesn't use SPV or any equivalent. Therefore, when importing a private key, it must scan the Blockchain copy it holds rather than trust third parties.

Sweeping the private key into Bitcoin core ought to be faster.


Is it safe to uninstall an old version of Bitcoin-qt after having installed the latest one? I´ve been using Bitcoin-qt (version 0.8.1.) for several weeks but lately I´ve had problems due to a so called "corrupted block database" issue, so I´ve decided to update my client to the latest version (0.8.5.).

It´s already installed (I just installed it on my laptop without removing the older version), synchronized and working properly.

Can I remove the older version of the client by clicking on the uninstall icon?
Is it safe to do so? If so, do I have to backup my wallet.dat file again or the previous backup still works with the latest version?

Thanks in advance.

Since you don't mention the operating system, but talk about "clicking the uninstall icon" I am assuming that you are using Windows.

Making a backup of your wallet.dat before updates and at regular intervals is sensible. If you installed bitcoin-qt 0.8.5 into the same directory as bitcoin-qt 0.8.1, uninstalling the older bitcoin-qt 0.8.1 might break your new install. If they are in separate install directories I would expect it to be alright (just based on what I would consider expected behaviour, I don't have intimate knowledge of the behaviour of the Bitcoin-QT-Windows client).

If you added any new addresses in since you imported the wallet to bitcoin-qt 0.8.5 you might have generated them after the last backup, so it would be prudent to create an additional backup of the newest wallet.dat.

Usually, I'd consider the following the correct order for an update (unless the software has its own update function):

backup
uninstall old
install new
import backup (by keeping the backup alive!)


How can I find out how much bitcoin is in existence with PHP? I'm running a Bitcoin blog and I'd love to display a ticket of the total amount of Bitcoins in existence. Unfortunately, I'm not sure where I can find a JSON feed for this (now that MTGOX is gone). Is there something like this I can utilize?

Take a look at this, its the blockchain.info api. it gives a json feed for many things.


Historical BTC data in JSON As of now, the only API I can find that serves historical data is https://blockchain.info/charts/market-price?timespan=60days&format=json. It only uses USD, and I need to serve non-USD data. My google-fu is failing me, does anyone know of an API that serves historical data for more than one currency? Preferably a currency I can specify as part of the API call.

You could also try the Blocktrail API: https://www.blocktrail.com/api.
They are new on the scene but their API can be quite useful. They have a node.js API as well as PHP, Python, CURL and jQuery. It doesn't track prices though but hope it can be of help some other way.


DAO Dividends In Ether? A friend of mine told me that The DAO pays dividends in Ether.  I can't find this anywhere, but assuming that it's true, how is this possible that it pays dividends if a person purchases The DAO through an exchange, but does not have an Ether address with that exchange?

A friend of mine told me that The DAO pays dividends in Ether. I can't find this anywhere,

Ether is the default unit of exchange/value/etc in Ethereum.

  but assuming that it's true, how is this possible that it pays dividends if a person purchases The DAO through an exchange, but does not have an Ether address with that exchange?

The DAO tokens are an ethereum asset that can only exist on an ether address. When you buy DAO tokens from an exchange the latter will create an ether address to store your DAO tokens (or put your tokens in one of their existing ether addresses and just have an internal ledger to know who has how much DAO tokens). Remember, what you see on an exchange is not necessarily what exists on the blockchain.

Also note that unless the exchange has some kind of mechanism to allow you to vote for DAO proposals you won't be able to... and they will control your voting power. I would recommend moving the tokens off the exchange to an ether address that you control if you intend to take part on the proposal/voting process.


API Authentication via Python I'm having trouble following LakeBTC's API instructions for connecting to their API via Python.

API Documentation:
https://www.lakebtc.com/s/api

I have my key (email address) and secret. I'm using the API URL: https://www.LakeBTC.com/api_v1

No matter what I try, I get a 401 Error. Below is my code, any ideas?

tonce = str(int(time.time() * 1e6))

p = 'tonce=' + tonce \
    + '&accesskey=' + self.key \
    + '&requestmethod=post' \
    + '&id=1' \
    + '&method=' + 'getAccountInfo' \
    + '&params='

# Create signature
hmac_obj = hmac.new(self.secret, p, hashlib.sha1)

b64 = 'Basic ' + base64.b64encode(self.key + ':' + hmac_obj.digest())

header = {
    'Json-Rpc-Tonce': tonce,
    'Authorization': b64,
    'content-type': 'application/json-rpc',
}

response = requests.post(self.apiUrl, data=p, headers=header)

Am I encrypting and hashing correctly?

A closer look at their API page, you will find LakeBTC has provided a simple code for Python: https://github.com/LakeBTC/lakebtc_python

And others Sample Code you can find here: https://www.lakebtc.com/s/api include PHP, Node.JS, Ruby and Python, maybe will more Code in the future :)


Changing wallet password using double quotation marks turn out to be mysterious (Qtum Core) I installed Qtum core in my Ubuntu 16.04 server and generated my wallet, and encrypted it.

For the test purpose, I changed the password using the command like below.

I typed below command to change my password.

  ./qtum-cli walletpassphrasechange "oldpassphrase" "newpassphrase"

Let's say my oldpassphrase is test and my new passphrase is test"

Notice that I type the double quotation mark right after the word test

  ./qtum-cli walletpassphrasechange "test" "test""

This returns below line that asks me to close the double quotation mark.

  >

So I typed " to close it.

Surprisingly, the command line has passed!

I thought the new password would be test" or test""

But they both do not work.

Can anyone guess what the new password might be?

This is really a Bash question, but I'll bite.

Bash (or any UNIX shell) will treat " symbols as begin and end of a literal. Inside "", spaces and special characters inside that would otherwise have a special meaning are permitted.

One of the permitted special characters inside is the newline. That's exactly what's happening here. Your "test"" plus " on the next line is seen as "test" plus a newline between quotation marks. As a result, your new password is test plus a newline character.

If you would want test" as your password, one way would be to use single quotes instead of double quotes. One of the characters permitted inside single quotes is... the double quote character.

So you could use

walletpassphrasechange 'test' 'test"'


In a double spend attempt, how is the valid transaction chosen? Suppose I publish the private key of an address that contains 1 bitcoin. If two people try to transfer this bitcoin to another address before a new block is found, who gets it? How is this decision made?

When a node receives two conflicting transactions, it will only relay the first one that it received, dropping the other.  If one transaction fully propagates through the network before the other is sent, the first will prevent the second from ever reaching any miner nodes.

If both transactions are sent at roughly the same time, the network will be in disagreement about which one is valid.  This will be resolved once a miner node finds a block and includes whichever transaction it had first heard about.


XPUB, YPUB, ZPUB Converter Tools I was wondering if there are any good X,Y,Zpub converter tools that any of you are aware of. For instance, a tool that could convert an Xpub into the equivalent Zpub.

I was inspired to ask this question, as I was playing around with multi-sig capabilities on both Electrum and Caravan. I created a Segwit MultiSig wallet on Caravan by inserting 3 Xpubs into the tool (https://unchained-capital.github.io/caravan/#/wallet). I got a wallet with bc1 addresses...

I then tried to re-create that wallet with only the xPubs on Electrum (mimicking a scenario where I didn't have all the signor keys), but Electrum read the xPubs as legacy and generated standard P2SH 3xxx... addresses in the wallet, a completely set of addresses. Not what I was looking for!

I then recreated the initial SegWit MultiSig wallet (from step 1) on Electrum, by actually connecting the same devices. I got the same bc1 addresses as Step 1. Nice.

I opened the Electrum wallet data for the MS wallet and noticed that Zpubs were noted, rather then the xPubs I had seen in the wallet data from Caravan. Note: both of these wallets generate the same addresses depending on the tool used.

I then put the zPubs into Caravan to try and recreate the same MS wallet using the Electrum data (which worked), and it automatically converted the zPubs from the Electrum wallet to xPubs with the note: https://gyazo.com/b66d8788e62208a2bdd021fb6ce53bd7

Is there a tool that performs the opposite functions, that converts an xPubs to a zPub?
This would give me comfort that I don't have to save both xPub and zPub wallet files! I could simply use either the Caravan or Electrum wallet file and be confident I could always derive the other format if needed.

There's a command line electrum option convert_xkey. If you're on linux or macosx you can see the documentation for it via electrum help convert_xkey. Alternatively you can use the console tab of electrum on all operating systems to achieve the same result. For example convert_xkey(xkey="xpub...",xtype="p2wpkh") will convert from p2pkh to p2wpkh


Why my bitcoind cannot query all the blocks? I just install the bitcoind and run:

bitcoind -daemon

and when i tried to:

bitcoin-cli getblockhash 195876

i got an message:

error code: -8
error message:
Block height out of range

the command:

bitcoin-cli getblockchaininfo

got me the data -

{
"chain": "main",
"blocks": 195807,
 ......
}

but the current block height is more than 574000
why does bincoind doesnt see all the blocks?

That's because although the Bitcoin blockchain has a current height of 574080, your full node has synced until 195807 (the output "blocks": 195807 after running getblockchaininfo command). Block 195876, the one that you are querying, has not synced yet on your node. As you said, you have just installed Bitcoin Core. It take  many hours (or sometimes days depending on your machine) for the node to reach the tip of the blockchain. It is not the size of the blockchain that makes it take so long time, but because your full node will go through every transaction since the genesis block and make sure that they confine by the consensus protocol.


Any way to accelerate transaction for a random cryptocurrency? I see all kinds of transaction confirmation times on Blockchain.info, from really short to very long (to an unacceptable extent). I wonder if there's a way to control that in any way. Maybe by giving a bigger reward to the miners? Does the sender even have control over this? I know that Ethereum has some control over that, but is it possible for Bitcoin? What about other crypto coins/tokens?

A bigger amount to the miners won't make them mine the block faster. It will only increase your chances to be in the next block AKA have your transaction confirmed faster.

In short the answer is no, the sender has no control when the next block will be mined, nor can they influence that with higher fees on their transaction.

"Miners" try to solve a mathematic problem using their collective computing power / hashrate.

A higher amount of fees doesn't drive the hashpower up, so it seems logic that the speed of "finding" a new hash / creating a new block doesn't increase.


What's the distinction between BIP 157 and BIP 158? Are they supported by Bitcoin Core? BIP 157 and BIP 158 are both concerned with Compact Block filters. What is the distinction between them, and which of them does Bitcoin Core currently support?

This answer is a slight modification on the description used in Bitcoin Optech Newsletter #43. Full credit and thanks to Dave Harding!

BIP158 introduces Compact block filters, which are are based on an efficient method for encoding
a list of equally-sized items. In the case of the "basic" block
filters described in the BIP, this is a list of all the
spendable output scriptPubKeys in the current block plus all
the scriptPubKeys for the outputs spent by this block's inputs
(what developers call previous outputs (prevouts)).   Each of the
scriptPubKeys is hashed to give each item the same size and then
these items are sorted into a list that has duplicated elements
removed.  This list is then encoded using the Golomb-Rice Coded
Sets (GCS) algorithm also described in BIP158, losslessly
reducing the size of the list.  This specific basic filter provides
enough information for anyone who knows a Bitcoin address to find
any block containing a transaction either paying that address
(output scriptPubKey) or spending funds previously received to that
address (prevout scriptPubKey).  The search may produce false-postive
matches (so blocks which don't contain transactions for that address
will be included in the results), but will never result in false-negatives
(so blocks that do contain transactions for that address will never
be omitted from the results).

A separate BIP, BIP157, describes how these compact block
filters can be served over the network using the Bitcoin P2P
protocol.  BIP157 is designed to work with BIP158 "basic" filters
but it can also be extended to support additional filters that
encode lists of other items.  One particularly noteworthy part of
BIP157 is that it introduces the concept of filter headers where
the header for each filter commits to a hash of the previous block's
filter header plus a hash of the current filter.  This creates a
chain of filters similar to Bitcoin's chain of blocks and is
designed to make it easy to compare filters from multiple peers:
each peer can send just the filter header (32 bytes) and, if there
are any headers that don't match, the client can request earlier and
earlier headers in the chain until the divergence point is found.
Generating a filter header on demand for a particular block
would require hashing all previous filters, so servers that are provide
BIP157 filter headers will generally need to store them in advance.

At the time of writing (April 2019), Bitcoin Core can generate and store
block filters and filter headers, and users can access them using the getblockfilter
RPC. Bitcoin Core does not currently provide block filters or filters headers
over the P2P network.

Here is an example getblockfilter return object:

$ bitcoin-cli getblockfilter $( bitcoin-cli getblockhash 170 )
{
"filter": "0357e49590040c79b0",
"header": "349eaecc8bb7793c9f3c28e78df6675ef904515e9a310e4532785aeb45526090"
}

We selected block 170 because its filter is the first to contain
more than one element (it holds 3 elements) and because the latest
block as of this writing (block 572,879) has a filter that contains
8,599 elements---far too much for us to print elegantly.


Do I have access to the private key for an Instawallet? It is just numbers and letters? I have transferred my bitcoin address and want to use the key so I can move my coins from this wallet to another? As you may be aware there site is down but can I set this up on another wallet so I can still get my coins?

No, Instawallet is a hosted (shared) EWallet.

They do not provide to you the private key for the deposit addresses associated with your Instawallet.

When you request a withdrawal, Instawallet processes that request and makes the transaction.  There is no way for you to create a withdrawal transaction yourself for any funds in an Instawallet.


View market depth/ orders on mtgox? Excuse me if this is a stupid question, but does mtgox have an option to see market depth? The trading page allows me to set a price, but without know the current levels of bid/asks how can I make a judgement about what price to set?

Cryptoxchange seems to display this information on its trading page, but I can't seem to find it on mtgox.

I can't seem to find it either, I'm pretty sure that they used to show it. The market depth is available in their API though and if you want something a bit more user friendly it is also available on Bitcoin Charts.


Hardware Wallet Vulnerability Fix - Verifying Input Value I'm confused by the proposed solution posted in the blog regarding the recent vulnerability https://blog.trezor.io/details-of-firmware-updates-for-trezor-one-version-1-9-1-and-trezor-model-t-version-2-3-1-1eba8f60f2dd?gi=504a17ecca1c

  The fix is straightforward — we need to deal with Segwit transactions in the very same manner as we do with non-Segwit transactions. That means we need to require and validate the previous transactions’ UTXO amounts. That is exactly what we are introducing in firmware versions 2.3.1 and 1.9.1.

I thought the value was already required to sign a raw segwit transaction... Since the change to segwit the full value of the input was needed in order to sign the raw transaction whereas before with legacy addresses you can simply sign without the input value amount.

They basically state the same thing in the article:

  This is defined in BIP-143 and one of the changes was that the amount
  of the UTXO is present in the signed data. This helps significantly;
  if the attacker lies about the UTXO’s amount, the signature is simply
  not valid in the Bitcoin network.

I guess I need it explained to me like a child because I don't get it, what are they checking and validating, how are they validating? Are they going back two transactions now?

The way I understand it, the important part is that for BIP-143 each signature is only calculated for the amount that it's own input spends. For the other inputs only their outpoints (txid+txidx) are used for the signature digest.

Let's assume you have two UTXOs, one with 15 BTC at outpoint txid0:txidx0 and another with 20 BTC at outpoint txid1:txidx1.

Then the trick works as follows:

Create a "template" PSBT that contains the correct outpoints in the inputs, so input0: txid0:txidx0 and input1: txid1:txidx1; and an output that sends an amount equal the greatest value of UTXO you have, so e.g. 20 BTC.
Now when you feed this template to your (offline) hardware device, you give the correct UTXO information for e.g. input0 (hence 15BTC+scriptPubkey1), but fake the UTXO amount of input1 so that it adds up to the amount you send + fees (hence 5.000001BTC+scriptPubKey2).
This will leave you with a valid signature for input0, which however is worthless as long as you do not also produce a valid signature for input1 (the one we could have got now for input1 is invalid as the amount was incorrect).
We therefore now repeat the steps, but this time faking the amount of input0 (hence 0.000001BTC+scriptPubKey1), while adding the correct amount for input1 (hence 20BTC+scriptPubKey2). The idea is that it looks similar and the user will simply sign again. This gives you a valid signature for input1.
Lastly, you simply use your "template" PSBT and add for each input the valid signatures you produced. The resulting valid and signed tx then uses inputs of 15 + 20 = 45 BTC, but have as output only 20 BTC, so paying a fee of 15(!) BTC.

// Edit: The fix of adding to each PSBT input the complete transaction containing an outpoint being spend enables the hardware device to check if the amount are correct (otherwise the txid would be wrong).


Are bitcoin Merkle trees always binary? I've been doing a lot of research about bitcoin, trying to understand it at the bit & byte level.

I was wondering about the lookup efficiency of the Merkle tree.

I haven't found any evidence that Merkle trees are mandatory binary, which would allow a O(log2 n) lookup algorithm.

If a node may have an arbitrary number of children, then the lookup function would have a O(logK n * K), where K is the maximum number of allowed child nodes (as far as I remember).

Merkle trees in general can have more child nodes, but the Merkle tree for transactional data in Bitcoin is a binary tree.

"Merkle trees are binary trees of hashes." –Bitcoin-Wiki Protocol Documentation
"From these txids, the merkle tree is constructed by pairing each txid with one other txid and then hashing them together." –Developer Guide: Transaction Data

This has the advantage that only a list of root, log2(n) hash partners and the index of the transaction are sufficient to reconstruct a Merkle branch, allowing Simplified Payment Verification with much less data than the complete block.
If I am not mistaken, the binary format minimizes the amount of hashes that need to be transferred for full reconstruction of the Merkle branch, e.g. for 16 transactions

binary tree: root + 4*1 hashpartners + txid + position
three children tree: root + 3*2 hashpartners + txid + position
four children tree: root + 2*3 hashpartners + txid + position

Lookup is likely less of an issue than the wish to minimize bandwidth usage.
Yes, I'm committing the fallacy of "proof by example" here. ;)


How do I create release build of my new bitcoin wallet? I have created a new alt coin, and now I want to create a executable of my wallet in ubuntu. I don't know how to create a release build wallet with all its dependencies. How I can build my wallet application?

Bitcoin statically links in all of its dependencies by default, because many of them are consensus-critical and cannot accept a different version. Therefore, you can distribute the binaries that make creates.

However, I would recommend setting up gitian deterministic builds.


How do exchanges keep relatively similar price on coins? I know there are price difference across all exchanges but they are relatively similar.  If each exchange operated independently I would think the price of coins would be radically different since the liquidity and exchange pattern would have nothing to do with each other.  Are exchanges tied to a central index?  How do they keep a somewhat "consistent" price?

If I could buy a bitcoin on Exchange A for $2,000, turn around and immediately sell it on Exchange B for $2,500, and make an immediate profit of $500, I would do that all day long, and get rich!

But if even a small price discrepancy exists between two exchanges, many people will find it, and start buying on one/selling on the other.

All that one-sided buying in one market and selling in the other market moves the price back to equilibrium.


Bittrex Bot buy at ask I am trying to write a bot to use it on Bittrex with nodeJs, but the documentation is very poor. My problem is that I would like to be able to buy the last ask, like when in the web you click in bid the option ask, this way the buy is instant.
For developing the bot I am using:
 https://github.com/n0mad01/node.bittrex.api
I have tried:

 bittrex.buyLimit({ market: 'BTC-ETH', quantity: 0.001, rate: "ask"}, function (data) {
    console.log("Response: " +data);
})

but it does not accept the rate "ask", is there any way this can be done?

Check the Bittrex api page.

The buyLimit endpoint says that the rate must be the rate at which to place the order.

In order to get the current ask price, use the getticker api which will return something like:

{
    "success" : true,
    "message" : "",
    "result" : {
        "Bid" : 2.05670368,
        "Ask" : 3.35579531,
        "Last" : 3.35579531
    }
}


Installation of Nxt on Ubuntu I'd like to install Nxt on Ubuntu (a private node). I am a beginner and have no clue about how to do that. Is there anyone out there that could give me some directions/advices ?

Any help would be wonderful.

Thank you

Just download from https://nxt.org/download/ unzip, go to folder and ./run.sh
Then go to your browser open up nxt by going to http://127.0.0.1:7876/

Hopefully this helps.


Difference between staking and mining? It seems that one can mine bitcoin to obtain more bitcoins, whereas coins like reddcoin allow staking to have more reddcoins. What is the difference between these two processes ?

Mining requires doing work (i.e. using electricity to power machines that perform the proof of work) to produce blocks and earn coins. Staking generally requires those that are staking to lock up their coins for some period of time (i.e. can't spend the coins) for a staker to have a chance of being selected to produce a block and collect the block reward.


How do the blue encrypted bitcoin paper wallets work? Via https://www.bitaddress.org I saw you can get a paper wall but with encryption and a passphrase. What are the steps of using the wallet with the passphrase? It seems the address is on the left while the private key is on the right.  So I am guessing the private key is what's encrypted with the passphrase? How would you decrypt it with the passphrase?

When the time has come to spent your coins, whatever wallet software you use to scan the private QR code, will have to ask you for the passphrase.

Give it a try with one and any wallet app on your smartphone. You don't need to put any bitcoins on it.


Private Blockchain Key Purchase Please anyone explain as IQOPTION is telling me that I have to purchase a $700 private key to get access to my BTC Blockchian wallet once they wired my Finds in to this wallet?? anyone please have an answer?

The normal way to get started in bitcoin is

1) Choose some free wallet software. Download it to your computer. Use the wallet software to generate a private key (cost so far: zero). Write down your recovery phrase or private key on a piece of paper and store it somewhere safe where no-one else can ever see it.

2) Either

Use traditional money to buy some bitcoins. There are exchanges that offer this service. Do some careful research to find a trustworthy exchange. Alternatively there are bitcoin ATMs which take traditional money and send bitcoins to your wallet's adddress. Make sure that they send your bitcoins to the address of your wallet on your computer, don't accept an online-wallet or cloud wallet run by someone else unless you fully understand the difference. Try this out with a small amount of money first - don't invest money you can't afford to lose completely.
Mine some bitcoins. This is now impractical for anyone new to bitcoin. At least, wait until you really fully understand bitcoin inside and out.

Some tricksters will try to trick people who are new to bitcoin,. They will make promises in return for money. They will give you a useless "watch-only" address saying that it contains your bitcoins, but a watch-only address does not give you ownership. Then they will invent further reasons for you to give them money until they have extracted everything you have or until you realise you have been tricked.

As bitcoin payments cannot be reversed, there is no way to get money back. There is no central bitcoin authority who can help.

Anyone who unexpectedly says you have to pay $700 for a private key is almost certainly a crook.


How to secure a Linux node running satoshi 0.16.1? Everyone in the BTC space seems to suggest that running a full node is the way to go. But Linux has a huge attack surface and I don't want to lose my BTC by having my wallet on an insecure OS. What is everybody else doing? Version 0.16.1 doesn't support HW wallets, so are people really keeping their BTC in an actual satoshi (bitcoin-core) wallet? Or using HW wallets, and the node is just for overall network security (and bragging rights)?

As a quick answer, some wallets allow you to specify a node that they will connect to. You can run your own node, and point your wallet at it. Beyond being trustless, this has an added bonus of increasing your financial privacy, especially if your node is connected to the tor network.

Note that many such wallets are ‘light wallet’ mobile applications, but I would trust a mobile wallet over a desktop full node wallet myself. This offers a good solution of maintaining sovereignty for a day-to-day use wallet in my opinion.

For larger amounts, using a HW wallet or other cold storage mechanism is highly recommended!


ListWalletDir: Access is denied D:\System Volume Information My BTC Core wallet is not yet fully synchronized, now I got this message in the debug Notepad ''List Wallet Dir: Access is denied D:\System Volume Information'' and whenever I move the mouse over the left tab, it stops at open Wallet and nothing works anymore it will not responding and I need to close the Wallet, I hate Btc core Wallet because it's my second time now I downloaded at a new Laptop and I got another Bug again.

This long standing issue should be fixed in https://github.com/bitcoin/bitcoin/pull/21907.


Running bitcoin node in docker behind NAT A running bitcoin node doesn't accept incoming connections when it's running behind NAT in a docker container.

To confirm the problem is related to docker I edited NAT settings on my router. If router's WAN port 8333 redirects to a machine running full node as a process incoming connections are possible. But if WAN port 8333 redirects to a machine running full node in docker container - I get inaccessible from outside bitcoin node.

To test accessability that I used this URL https://bitnodes.earn.com/#join-the-network (the website auto detects your external IP address and auto fills the box; only thing left is to press the button). If the node is accessible the test finishes green, if not - red.

Root cause.

The root cause of the problem is default settings in docker container. More precisely, network settings mode which has bridge mode by default. In bridge mode all incoming connections are seen from inside docker container as coming from the same IP address (which is 172.17.0.1). There are multiple hard forks out there so a foreign node running BCH or other forked bitcoin stuff would connect to your node and try to propagate invalid transaction(s). After few attempts your bitcoin node puts such misbehaving incoming connection in a blacklist. Having one connection banned, your node effectively bans all other incoming connections as they are seemed to come from the same IP address.

Confirmation from a technical point of view (via RPC).

To confirm such situtation we can setup RPC to call bitcoin node. Configuration options such as -rpcconnect and -rpcauth can be put into bitcoin.conf file so I skip them here. The command

bitcoin-cli listbanned

shows list of blacklisted misbehaving nodes where we can see only one address.

In my case the output was like that

[
  {
    "address": "172.17.0.1/32",
    "banned_until": 1572109811,
    "ban_created": 1572023411,
    "ban_reason": "node misbehaving"
  }
]

After a successful diagnosis it's possible to clear blacklist with the following command to temporarily clear blacklist

bitcoin-cli clearbanned

Having blacklist cleared we can run another test here https://bitnodes.earn.com/#join-the-network and confirm the node is now visible from outside.

Solution.

Network settings in docker.
The most proper solution.
In my case, running on a Synology NAS, I had to recreate the container to switch off the bridge mode.
Schedule (eg, via cron) a task to clear banned.
Whitelist the only address docker accepts connections from.
Couldn't find a way to permanently implement it.

PS. Can someone tag the topic with a 'nat' and 'docker' tags. It looks like I need some reputation to make it happen.


At the moment SegWit2x forks, will mining be way easier? Is there a need for people to run full nodes that are mining on CPUs when/if the SegWit2x fork occurs?

Will almost all of the mining power be switched over to SegWit2x?

No, it will not be easier. The "difficulty" of mining is determined by the difficulty (the value). The difficulty only adjust itself every 2016 blocks, so when the Segwit2x fork happens, the difficulty will not adjust until 1152 after the fork happens. So the difficulty will not change at the time of the fork for either chain (barring any difficulty adjustment thing that segwit2x decides to implement in the future) so it will be equally difficult to mine on both chains and thus not easier at all.

When the difficulty adjusts, it can only adjust by a factor of 4 at most, so only down to a difficulty 1/4th that of the difficulty at the time of fork. This means that it won't be possible to CPU or GPU mine either chain for a while as the difficulty needs to adjust down a lot.


Can I reload my node's config from the command line without restarting the node? I needed to make some config changes to my node and I'd like to reload the config without stopping the node and then restarting it. Is that possible? I don't see any related RPC commands on the wiki.

I don't think so. There's a feature request about this, but I don't think a feature like that has been added.


Question regarding the number of bytes in an OP_RETURN transaction I was reading this very useful explanation of what an OP_RETURN transaction looks like and got tripped up by part of it.

        "hex" : "6a13636861726c6579206c6f766573206865696469"

  This first byte it followed by a byte which represents the length of the rest of the bytes in the scriptPubKey. In this case we see the hex value Ox13, which means there are 19 more bytes.

But there are 38 bytes following the hex value 0x13. Why the discrepency? I'm pretty sure I'm missing something obvious and I'd have asked in a comment on the answer itself but I haven't enough rep points. Thanks in advance.

I found the answer on Wikipedia:

  One hexadecimal digit represents a nibble, which is half of an octet
  or byte (8 bits)

So two hex digits per byte. And a "nibble" for half a byte. I like that. :)


Can everybody earn bitcoin? I am a Bangladeshi. I know little about bitcoin and I have no credit card. Is it essential having bank account to earn bitcoin? How will bitcoin help me? How and where can I start earning bitcoin?

There are no requirements about your nationality, skills or need to have a credit card to use Bitcoin. The only major requirement is that you have a smart phone or computer and access to the internet. In terms of earning bitcoin, you may earn it any way you might earn Taka or United states dollars, however you might find few employers will pay you in bitcoin.

There are some services to earn small amounts of bitcoin for simple tasks. A quick search turned up coinworker, but it looks like there are other similar sites if you find that doesn't work.

Hope that answers your question Banda!


Required number of bits in nonce Is there a formal proof that with N bits to iterate in the nonce of the block, a hash satisfying proof of work will be ever found?

How large that N (number of bits in the nonce) should be to satisfy proof of work in 10 years, 100 years?

In addition to the 32-bit nonce in the block header, miners can also update the extraNonce of arbitrary length in the coinbase transaction to get a different merkelRoot, so that a proof of work hash can always be found.


How do I extract the private keys from my namecoind wallet? Seems like namecoind doesn't support the dumpprivkey command.

https://github.com/gavinandresen/bitcointools

or pywallet (link on the site above).

These are the only ways I know. Not really comfortable. Also it is probably not possible while namecoind is running.