SPV Wallets vs API Wallets - Pragmatic From what I know, the only advantage of an SPV node compared to a API Node, is the increase in privacy.

SPV nodes take up more bandwidth, in order to stay synced with the current chain and in some cases, store a lot of data.

With an API wallet, one could connect to multiple endpoints to see if any one is lying. There is also less data and less bandwidth.

Do most people care if their wallets are SPV?
Are there any other advantages of SPV that I have missed?

SPV wallets allow a user to verify that the information they have received is legit, thus the node they are connected to is unable to send them fraudulent transactions. This is possible because the block header that an SPV wallet will download contains the block hash (allowing the wallet to verify that the block header is indeed part of the bitcoin blockchain, tracing back to the genesis block), and the transaction merkle root (allowing the wallet to verify that a certain transaction is included in a certain block). Through these cryptographic mechanisms, a user can interact with the network without placing a large amount of trust in the node that is communicating with their wallet.

Using multiple endpoints for an API wallet does not provide a more secure solution than the cryptographic proofs utilized by an SPV wallet. By using an API wallet, you are trusting that the API provider will not provide you false information. Using multiple endpoints is probably better than just one, but the risk still remains because now you just trust that a bunch of nodes aren't lying, instead of just trusting that one node isn't lying.

Luckily, SPV wallets are not super resource intensive as is, block headers are only 80 bytes, so a year's worth of blocks only add up to about 4.2 MB.


What are the best criticisms of blockchain technology? What are the best criticisms of blockchain technology? Specifically, what are the top flaws of the blockchain as it's currently implemented by Bitcoin?

Decentralized technology is inherently more inefficient than centralized tech. In Bitcoin this expresses e.g. in the difficulties to implement Scalability and the Proof of Works energy consumption.

The other most prevalent criticism I've read is that there is no central instance in Bitcoin to dampen value swings. The predetermined rate of money creation does not leave any option of steering the money supply. While this is something many Bitcoin advocates like about the project, citing the patchy performance of central banking in the past, the resulting volatility is frequently listed as the most important design flaw of Bitcoin.


What is the function of LOCK(cs_main)? Does LOCK(cs_main) pause and branach the program in order to do some necessary job before going on?

I'm trying to publish blocks reactively (as a selfish miner) upon receipt of inventory message from pfrom and react to it after *pfrom* catches up with the  height of my secret block.

Following lines didn't help/there was no reaction on selfish node's side:
added following lines in main.cpp: after l. 3662

   ...
        {
            LOCK(cs_main);
            pfrom->PushMessage("inv", pfrom->vPrivateInv);
        }
   ...

LOCK(cs_main) causes the thread to stop execution until a lock can be obtained on cs_main. cs_main is an object representing a type/class/scope of lock. Once the lock is obtained, it lasts until the end of the LOCK statement's scope. (The LOCK macro creates an object on the stack, the destruction of which releases the lock.)

cs_main is already locked in that place, and LOCK uses recursive locks, so your LOCK doesn't do anything.


How can I accept Bitcoin donations on my blog or site? If I sell things, there are many services that allow me to accept bitcoins as payment.  But for those who simply want to accept bitcoins on their blog or other site ... as donations.

A simple bitcoin address can be listed but what other options are available, such as an icon that can be clicked on, like what Flattr offers, perhaps?

Although bloggers could turn to an external service to manage this for them, it might be more beneficial to simply offer a simple QR code with a description alongside. This would mean that all of the income from the BTCs would go direct to the blogger.

My personal blog has an article describing in detail how to do this. I'm not trying to plug anything honestly, just sharing knowledge.

This can be imaged with a Bitcoin wallet, or dragged like a Bitcoin swatch onto the Multibit client. A simple click will trigger a protocol handler within the browser (if installed) that would activate an wallet plugin.


Does BFGminer halt processing if ASIC miners reach a high temperature? From the README of BFGminer, I see:

The totals line shows the following:
 6/32   75.0C | 171.3/170.8/171.2Gh/s | A:729 R:8+0(.01%) HW:0/.81%

Each column is as follows:
  The number of devices and processors currently mining
  Hottest temperature reported by any processor

I don't see the temperature column.

Does this mean I have the incorrect Windows drivers?

Does it mean I need to pass a parameter to BFGminer?

Not all miners return temperature information, it's only shown when available.

For example with a Block Erupter, there's none to show.


To test if my wallet.dat encryption password is correct, MUST I spend coins? When a Bitcoin Core wallet is encrypted, you (apparently) have to enter the decryption passphrase only when trying to spend coins. You still get to "use" the wallet as in seeing all the transactions and labels.
I'm worried that my saved passphrase (partially on the computer/paper and in my head) is not correct. But to test this, I would have to spend coins... or do I?
I suspect that you'll say: "Use the change passphrase feature!"
But that would just put me again in the same situation. Of course, I had to repeat the passphrase (two times in total) to enter it in the first place, and this would be done again. So I'd again be paranoid that my keyboard has a faulty key or something like that.
Is there some way to "test unlock" a wallet without actually spending any money?

As you are using the Bitcoin Core wallet you can look at the right bottom if your wallet is locked or unlocked in the padlock icon.
Go to Window > Console and type: walletpassphrase "your passphrase" 60
After you type this command and you get an Error "The wallet passphrase entered was incorrect" that means your passphrase is wrong so you can try it again by typing the command again.
If you can enter the correct passphrase you will get "null" as a response and you will see the padlock icon as unlocked.


What are the benefit of mining an empty block Something peculiar just happened on the newly mined block number 655534, it contain only the coinbase transaction, nothing else.
I have searched for a similar question but only found this one Why there are blocks with single transaction in blockchain?
But the answer is kind of vague with a " we dont really know "
Here is the concerned block: https://btc.com/000000000000000000028f1ea0a3ccfac982eb53c1bd2d3d20695af87ffacaaf

Miners aren't forced to include transactions in their blocks even though they're incentivized by fee to do so.
The main cause for empty blocks is spy mining, as there's normally always something in the mempool! I don't see an answer on here containing 'spy mining' so here we go :)
Spy mining is when pools try to minimize time spent hashing an out of date block. A spy miner monitors the work other pools give out to miners (by registering a miner there)
If one of those pools starts working on new work, pointing to a block the spy miner has never seen before, he interprets it as the network has accepted that block and everyone else has moved on.
However, the spy miner hasn't received or validated this block so he doesn't know what transactions were applied, and hence is uncertain about the state of the UTXO set. If he includes a conflicting transaction in his block, his entire block will be rejected. So his safest chance of succeeding is to not add any transactions except the coinbase.
Eventually his software will receive the block, and the pool will include transactions in newly issued work.
This is slightly at odds with the timestamp on the block (30 minutes after the previous one), but it's hard to know.


Positive or negative private key of a bitcoin wallet? Private key is a number. Is the question positive or negative? Is it possible to know a positive private key or negative if you only know the public key?

For instance:

Positive private key: 2

public key:

04C6047F9441ED7D6D3045406E95C07CD85C778E4B8CEF3CA7ABAC09B95C709EE51AE168FEA63DC339A3C58419466CEAEEF7F632653266D0E1236431A950CFE52A

Negative Private Key:
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD036413F

public key:

04C6047F9441ED7D6D3045406E95C07CD85C778E4B8CEF3CA7ABAC09B95C709EE5E51E970159C23CC65C3A7BE6B99315110809CD9ACD992F1EDC9BCE55AF301705

Now I will write two public keys to "3" and "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD036413E":

04F9308A019258C31049344F85F89D5229B531C845836F99B08601F113BCE036F9388F7B0F632DE8140FE337E62A37F3566500A99934C2231B6CB9FD7584B8E672

04F9308A019258C31049344F85F89D5229B531C845836F99B08601F113BCE036F9C77084F09CD217EBF01CC819D5C80CA99AFF5666CB3DDCE4934602897B4715BD

How to determine which is a positive and which is a negative private key to these two public keys?

There really isn't a "positive" or "negative" for private keys. Private keys are unsigned integers, so they're basically all "positive". Your "negative" numbers are not actually negative, they're the modular additive inverse of the "positive" private key.

Since private keys are really unsigned integers, you can't glean any information about signed-ness from the public key because there are no signs to even look at. Every private key is the "negative" of another private key, so a private key is both "positive" and "negative". Every private key has an additive inverse.

However, given two public keys, you can determine whether their private keys are additive inverses of each other by checking whether the X coordinates are the same. If so, one should have a Y coordinate that is odd, and the other have a Y coordinate that is even. This only tells you that their private keys are additive inverses of each other. But you won't know which is the lower number or what one of them is (unless you have the private key for one of them).


Does Ripple ever charge proportional transaction fees? I spotted this sentence in WeExchange (a ripple gateway):

  *: The ripple network may charge up to a 1% fee if you are withdrawing to an address that does not trust WeExchange for the amount.

What does it mean? Why can the fee reach 1%?

The network itself doesn't really ever charge proportional transaction fees. However, when you make a payment, that payment can take a path that can invoke any number of fees. These fees are charged by the individuals or companies who provide links in that path.

The four possible fees are:

Transfer fees: A transfer fee is a fee an IOU issuer can charge when their IOUs change hands. It is imposed by the issuer of the IOUs you hold. (This is one of the services your gateway can charge for.)
Quality fees: A quality fee is a fee someone who holds multiple IOUs can charge when you give them IOUs they consider less trustworthy in exchange for IOUs they consider more trustworthy. It is imposed by the entity that holds both IOUs. (This is a fee someone can charge if you use their liquidity to swap IOU issuers.)
Service fees: A service fee is a fee imposed on an IOU exchange in either direction as payment for the convenience of changing issuers. It is imposed by the entity that holds both IOUs. (This works the same as a quality fee except it can be charged in both directions and so doesn't necessarily reflect a change in quality.)
Exchange fees: An exchange fee is essentially the same as a service fee, but it can also occur when the currency is changed as well as the issuer.

When you form a transaction, the Ripple system finds the cheapest path taking these fees into account. Generally, the cost should be very close to the amount of money you are trying to deliver to the destination -- most of these fees are typically zero. If you hold IOUs from a gateway and are paying someone who trusts a gateway, these fees should total way under 1%.

These fees provide the incentive for people to provide liquidity and connectivity in the Ripple system. Competition should drive these fees to near zero for typical cases.

So, for example, if you hold IOUs for USD at two different gateways, you could offer to exchange between the two gateways at an exchange rate that makes you a modest profit. If you provide the best path between those gateways, then someone who holds IOUs from one gateway but needs to pay someone who only trusts the other gateway can take you up on your offer and you'll wind up imposing a fee on their transaction.

Ripple transactions can include multiple paths and a maximum amount to pay. At the instant the transaction is processed, the system will incrementally take from whichever path has the lowest cost. If the transaction cannot be completed at or below the specified maximum cost, it will return an error.

You might think it would be expensive to pay all these fees, but in practice, they'll be small or zero. Say you are at one exchange and you need to pay someone at another and the fee is high, say 1%. Someone with IOUs from both exchanges will see a profit opportunity -- just offer the IOUs at .9% instead. They can make money as the IOUs move back and forth and they won't have to do much. But then someone else will see an opportunity at .8% and so on. The price will get driven down to near zero unless there's some reason for the fee.

Some of these fees can apply in reverse and actually result in you paying less than the specified amount. If you're paying with IOUs that someone else needs, you may be able to give them the IOUs they want at a profit. So it could cost you $98 to pay me $100 if you hold IOUs that are needed and I'll accept IOUs you can get below face value.

The fees serve to cause transactions to do what people need done. If I have the "wrong" IOUs, I can just offer them in exchange for the IOUs I need at a good price and someone looking for the lowest fees will wind up fixing my problem for me. If I'm holding IOUs from someone I no longer trust, I just offer them at a discount and wait until they become someone else's cheapest path.

The 1% figure comes from the way WeExchange currently processes withdrawals from your exchange account to a Ripple account. If that Ripple account trusts WeExchange, they just issue that account IOUs. If not, some of the fees I mentioned above may be incurred. WeExchange currently will allow the withdrawal if it costs up to 1% more than the amount withdrawn. So if you order WeExchange to pay $100 to a Ripple account that won't take their IOUs, it may cost you more than $100 (up to $101) to do it. If it would cost more than that, WeExchange will report an error. (At least, this is my understanding. The details were relayed to me second hand and this is still subject to change.)


How can I sign a message with a litecoin private key and also generate a litecoin address from a string? I'm working with bitcoinjs, but is there a litecoinjs equivalent? I want to be able to sign and verify messages with my litecoin private key and also generate litecoin addresses from a string. How would one go about doing these functions with a javascript library if one exists?

bitcoinjs already has support for litecoin, a quick look at /src/network.js and the README reveals this.
https://github.com/bitcoinjs/bitcoinjs-lib/blob/d853806/test/integration/basic.js#L30

See how they set the network: litecoin variable, that is probably used consistently through the code (atleast for address generation).

Nothing really major changes for signing to be honest, take a look at https://github.com/bitcoinjs/bitcoinjs-message

WIF and address generation
Do not take the warning about the cryptographically secure random number generator lightly. If you do not change it then you will constantly generate the same address and it will be horribly insecure.

//import bitcoinjs libs
var bitcoin = require('bitcoinjs-lib') // v2.x.x
var bitcoinMessage = require('bitcoinjs-message')

//set a litecoin variable equal to its network type, which we'll use throughout the example
var litecoin = bitcoin.networks.litecoin

//let's generate a litecoin keypair from a string
//WARNING: YOU MUST REPLACE rng() WITH A FUNCTION THAT ACTUALLY RETURNS CRYPTOGRAPHICALLY SECURE RANDOM DATA!
function rng () { return Buffer.from('MAKE SURE THIS IS NEW RANDOM DATA EACH TIME RNG() IS CALLED') }

var keyPair = bitcoin.ECPair.makeRandom({ network: litecoin, rng: rng })

var wif = keyPair.toWIF()
//You should store the output of the variable wif here, this is the actual key to the litecoin address (contains the private key) and is crucial to signing messages, do not share this and handle with care.

var address = keyPair.getAddress()

console.log("wif: " + wif + "\n")
console.log("address: " + address + "\n")

Message signing using WIF from example1

This takes your WIF and then signs a message.

//import bitcoinjs libs
var bitcoin = require('bitcoinjs-lib') // v2.x.x
var bitcoinMessage = require('bitcoinjs-message')

//set a litecoin variable equal to its network type, which we'll use throughout the example
var litecoin = bitcoin.networks.litecoin

// add the wif key you stored
var wif = 'WIF key goes here'

var keyPair = bitcoin.ECPair.fromWIF(wif, litecoin)
var privateKey = keyPair.d.toBuffer(32)
var message = 'This is an example of a signed message.'
var messagePrefix = litecoin.messagePrefix

var signature = bitcoinMessage.sign(message, messagePrefix, privateKey, keyPair.compressed)
console.log(signature.toString('base64'))

Replace the WIF by the one you generated in the previous example.

Message verification using the address from example1, and signature output from example2

//import bitcoinjs libs
var bitcoin = require('bitcoinjs-lib') // v2.x.x
var bitcoinMessage = require('bitcoinjs-message')

//set a litecoin variable equal to its network type, which we'll use throughout the example
var litecoin = bitcoin.networks.litecoin

var address = 'THE ADDRESS FROM EXAMPLE1'
var signature = 'THE OUTPUT OF CONSOLE LOG OF EXAMPLE2'
var message = 'This is an example of a signed message.'
var messagePrefix = litcoin.messagePrefix

console.log(bitcoinMessage.verify(message, messagePrefix, address, signature))


Why are some transactions larger (in bytes) than others? There's this transaction: http://blockchain.info/tx/2588df59035129de0f0cb20d2cb5d77d18830043aa68ad2a1a2df7d727bc7a62 that is 802 bytes but for only 1.4BTC

Another transaction: http://blockchain.info/tx-index/14803514/781333d877bae2b4d8fc7ff856b38989013f0a11668395b8f90b423dd2ffc230 is for 50.4BTC by only 118 bytes.

So what exactly goes into a transaction that would increase / decrease the size of the transaction?

I give a formula that you can use to calculate the size of a transaction given the number of inputs and outputs here.

The most significant factor contributing to the size of a transaction is the number of inputs to transaction has.  Each input contributes 179 to 181 bytes to the size, and each output contributes 34 bytes to the size.

Your large transaction has 4 inputs - that's why it's bigger than the other transaction, which has none.

The actual number of bitcoins spent by a transaction is completely irrelevant, except that there may be a tendency for transactions which spend more coins to require more inputs to make up the amount.


What happens when a gateway on the Ripple network defaults or simply vanishes? What happens when a gateway on the Ripple network defaults or simply vanishes? Do people that got their money from it lose that money, do other gateways honour the IOUs issued by that gateway still, or does something else happen?

Any of those things can happen. Likely, there will be some "hot potato" going on as people rush to offload any IOUs they hold to people who haven't yet gotten the news. It's unlikely other gateways would honor the IOUs unless they were contractually obligated to. This would likely harm their customers as they'd have to make up the losses somehow -- likely with higher fees.

Gateways are in the business of being trusted. So they have a huge incentive to find ways to induce people to trust them. We don't yet know what will happen, but some possibilities include:

Gateways could cross-insure each other. (But this might make you less likely to trust a gateway for fear that it will collapse due to the collapse of another gateway.)
Gateways could be insured by governments or private insurance companies. (They hold other people's fiat currency, so the legal framework for doing this exists in many countries.)
Gateways could post bonds or liens on physical assets that could be seized or sold if the gateway defaults and used to cover their obligations.

Note that this is only a significant issue for people who wish to use the Ripple system to hold fiat currencies as a store of value. It's not a major issue for a merchant who just wants to get paid in dollars as they can use a gateway that electronically deposits the currency in their regular bank account on a daily basis. If that gateway goes out of business, they'd only lose a day or two's revenue and could switch gateways on the Ripple system with no disruption. (You might think losing two days revenue is a big deal, but remember, businesses already pay 2% to take credit cards. That's like losing seven days revenue every year.)


Witness program hash mismatch while signing bech32 transaction I'm trying to sign a transaction using signrawtransactionwithkey on bitcoin-core 0.17 but I'm getting the following error:

{"ERROR":"[{"txid":"c7e5bc9c9662384464182c713a6a6e20a2da72adb2b2a5799457be643d764139","vout":0,"witness":[],"scriptSig":"","sequence":4294967295,"error":"Witness program hash mismatch"}]

parameters sent correctly since it's working on the testnet network
it's just the mainnet

anyway the params sent as:

["transaction_in_hex",["private_key"],[inputs]

the inputs are

[{"txid":"c7e5bc9c9662384464182c713a6a6e20a2da72adb2b2a5799457be643d764139","vout":0,"scriptPubKey":"0014f3dd9523e2a801770513e00ed717fd610ea634af","amount":"0.00099784","address":"bc1q70we2glz4qqhwpgnuq8dw9lavy82vd903k7hpe","redeemScript":""}]]

I have been reading the bitcoin source code trying to understand what's the problem and it's obvious that the exception been thrown on here

  if (memcmp(hashScriptPubKey.begin(), program.data(), 32)) {
                return set_error(serror, SCRIPT_ERR_WITNESS_PROGRAM_MISMATCH);
            }

and here

if (witness.stack.size() != 2) {
                return set_error(serror, SCRIPT_ERR_WITNESS_PROGRAM_MISMATCH); // 2 items in witness
            }

This error means that the transaction wasn't signed, which given that all of the inputs look correct, means that you are providing the wrong private key to sign the transaction with.


Why can’t the genesis block coinbase be spent? According to the bitcoin wiki:

  The first 50BTC block reward went to address 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa, though this reward can't be spent due to a quirk in the way that the genesis block is expressed in the code (this may have been intentional).

But where is this quirk? How would you change it to allow it to be spent?

When a node starts up it initializes its copy of the block database alongside the genesis block and then begins the synchronization process. For some reason, Satoshi decided not to add the coinbase transaction from the genesis block to the global transaction database. Thus all the nodes in the network would reject the block.

I'm not sure if this was done on purpose or if it was simply an oversight. In any event, it is forever bound to 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa.


Why were custom scripts made non-standard except if they're P2SH? Custom script = nonstandard
P2SH custom script = standard
Why don't  we set non-p2sh custom scripts standard too? Forcing P2SH requires adding hashes to the chain causing more bloating

To answer your question exactly: why were they made non-standard? Because originally (after a few vulnerabilities in the Script logic in 2010), all scripts were made non-standard except a few whitelisted ones. Since then, more and more groups of scripts have been added to that category (including almost all P2SH scripts, with a few exceptions).
Why have bare scripts (non-P2SH,non-segwit) not been made non-standard except for P2PK, P2PKH, and multisig up to 3 keys?
UTXO bloat.
Yes, P2SH implies slightly more blockchain space usage. But not using P2SH for potentially long scripts means those scripts have to enter the UTXO set, where they burden full nodes until spent. With P2SH, only the script hash enters the UTXO set.
In addition, there just isn't much use for non-P2SH scripts as there are no standardized way of sending to them. The ones that are permitted are due to historical usage.


Why is bitcoin better than other electronic banking, like Dwolla or Paypal? Why is bitcoin better than Dwolla or Paypal?

You don't need anyone's permission to use it. Nobody can freeze your account or charge back a payment after you received it. It's accessible to anyone with Internet access regardless of what country they're in. No single company can dictate its policy. It is almost free to use with no proportional fees.


Looking for a serious alternative to Nicehash... can you please help? After the collapse of Nicehash I am trying to find an alternative that will let me mine Monero/XMR algorithm ONLY and get paid in BTC just like Nicehash used to do.

In other words, I don't need any service that will decide for me the coin to mine, but I NEED to be in control of what coin/algo to mine, and that algo must be Monero, as it is very energy-efficient for the kind of rigs I have.

I know that Minergate does this, however I am very reluctant to use them as I have strong suspicions that they steal most of my shares for what I can see.

Do you guys know and could recommend for me such a service?

Thanks so very much for your help!

In the exchange, bittrex has the tool where. that when you receive another currency it sells automatically and you get bitcoin.
Bittrex -> Labs -> Auto-Sales

I think she's the best alternative.
https://bittrex.com/Lab/AutoSell


Failed at the bitcore-node@3.1.3 Approach

I'm trying to install bitcore on Windows 10 and Ubuntu 18 but I could not.

Problem

I have followed the following steps:

# Install NVM (1)
#  Install script
#   With CURl
# curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
#       or Wget:
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

Adds the source line to your profile (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc)

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

# Install Node.js v4 LTS
nvm install v4
# Install ZeroMQ and Tools
apt-get install libzmq3-dev build-essential
# Install Bitcore
npm install -g bitcore

  More information

Bitcore Full

NVM

But when I run it I get the following errors

  Error in Windows con git

$ npm install -g bitcore

Output

> bitcore-node@3.1.3 preinstall C:\Users\User\AppData\Roaming\npm\node_modules\bitcore\node_modules\bitcore-node
> ./scripts/download

"." no se reconoce como un comando interno o externo,
programa o archivo por lotes ejecutable.
npm WARN Error: EPERM: operation not permitted, lstat 'C:\Users\User\AppData\Roaming\npm\node_modules\bitcore\node_modules\utf-8-validate\node_modules'
npm WARN  { Error: EPERM: operation not permitted, lstat 'C:\Users\User\AppData\Roaming\npm\node_modules\bitcore\node_modules\utf-8-validate\node_modules'
npm WARN   stack: 'Error: EPERM: operation not permitted, lstat \'C:\\Users\\User\\AppData\\Roaming\\npm\\node_modules\\bitcore\\node_modules\\utf-8-validate\\node_modules\'',
npm WARN   errno: -4048,
npm WARN   code: 'EPERM',
npm WARN   syscall: 'lstat',
npm WARN   path: 'C:\\Users\\User\\AppData\\Roaming\\npm\\node_modules\\bitcore\\node_modules\\utf-8-validate\\node_modules' }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bitcore-node@3.1.3 preinstall: `./scripts/download`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bitcore-node@3.1.3 preinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\User\AppData\Roaming\npm-cache\_logs\2018-06-24T12_23_42_800Z-debug.log

  Error in Ubuntu

npm install -g bitcore

Output

> bitcore-node@3.1.3 preinstall /root/.nvm/versions/node/v4.9.1/lib/node_modules/bitcore/node_modules/bitcore-node
> ./scripts/download

./scripts/download: line 30: cd: /root/.nvm/versions/node/v4.9.1/lib/node_modules/bitcore/node_modules/bitcore-node/scripts/../bin: Permission denied
npm ERR! Linux 4.15.0-22-generic
npm ERR! argv "/root/.nvm/versions/node/v4.9.1/bin/node" "/root/.nvm/versions/node/v4.9.1/bin/npm" "install" "-g" "bitcore"
npm ERR! node v4.9.1
npm ERR! npm  v2.15.11
npm ERR! code ELIFECYCLE

npm ERR! bitcore-node@3.1.3 preinstall: `./scripts/download`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bitcore-node@3.1.3 preinstall script './scripts/download'.
npm ERR! This is most likely a problem with the bitcore-node package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ./scripts/download
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs bitcore-node
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR!     npm owner ls bitcore-node
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /root/npm-debug.log

Question

Someone who has executed it sees an erroneous step or the same thing happens to him and he has solved it.

Thank you !!

Solution

  "bitcore" is dead, regardless. It's not Bitcoin Core, to ease
  confusion.


Running pybitcointools & python-bitcoinlib concurrently This is somewhat Python-based, but I feel it is more a Bitcoin question than a Python question.

The problem is running pybitcointools and python-bitcoinlib concurrently, as both packages use the name bitcoin. This BountySource discussion sums up the issue succinctly:

  It seems that on PyPi the name bitcoin is free but... (the) ... python-bitcoinlib package on installation uses the same name "bitcoin" as the current pybitcointools, and I've had them clash (one overwrote the other)

It's also worth noting that using pip, pip install pybitcointools = version 1.1.15, whereas pip install bitcoin = version 1.1.25 (newer version).

I generally prefer Python 2.7 but whatever solutions may be applicable just to Python 3.x would also be greatly appreciated, as using both libraries concurrently would be great.

Not sure if you can do it as they seem to be the same package.
For python-bitcoinlib here:

Author: Vitalik Buterin
Home Page: http://github.com/vbuterin/pybitcointools
Package Index Owner: vbuterin
DOAP record: bitcoin-1.1.26.xml

For pybitcointools here:

Author: Vitalik Buterin
Home Page: http://github.com/vbuterin/pybitcointools
Package Index Owner: vbuterin
DOAP record: pybitcointools-1.1.15.xml

They point to the same package on github (just different versions) and running them at the same time is probably not a good idea. My guess is that Vitalik changed the python package name from pybitcointools to bitcoin when he realized the second was available.
That said, if you really need to use both packages, you can do something like this answer. Note you'll have to install manually, probably installing from source using github.


bitcoin core what is it all about does it make my desktop a server when my bitcoin core finishes synchronizing does it make my desktop to be like blockchain.nfo where people can create wallets. and must i be online always. apart from that does it mean i have all the bitcoin history from 2009 till date on my hard drive .if my hard drive is compromised does it put all the bitcoin core information in my desktop at risk

when my bitcoin core finishes synchronizing does it make my desktop to be like blockchain.nfo where people can create wallets.
and must i be online always.

No.
Bitcoin Core is purely a wallet, mostly for personal use.
When bitcoin core syncs it means it is downloading previous blocks / blocks that have ""happend"" while bitcoin core had no access to internet.

apart from that does it mean i have all the bitcoin history from 2009 till date on my hard drive

Yes. It does mean you have all bitcoin transacations and blocks since 2009 on your computer.

if my hard drive is compromised does it put all the bitcoin core information in my desktop at risk

It shouldn't if you have your wallet encrypted, otherwise, yes.


How to install bitcoind (Bitcoin Core) on Ubuntu? I want to install a command line-only full node bitcoind on a mini PC with 4GB RAM and Ubuntu. What are the steps to do it and how can I check if it works?

useradd bitcoin and passwd bitcoin
link /home/bitcoin/.bitcoin to external HDD with chown -R bitcoin:bitcoin
git clone bitcoin core in /home/USER/GitStuff
add bitcoin ppa repository
sudo apt install libdb4.8-dev && sudo apt install libdb4.8++-dev
/autogen.sh in /home/USER/GitStuff/bitcoin
/configure --withoug gui
make
make install
10 su bitcoin
start bitcoind (as user bitcoin)
curl -sL https://bitnodes.earn.com/api/v1/nodes/me-8333 | jq


How does bitcoin core generate a receiving address without using my private key? I downloaded bitcoin core from github. Now I have imported the complete blockchain and am examining the bitcoin core interface. If I click on >File >>Receiving addresses I see that bitcoin core has already created a receiving address for me. I have not yet chosen a private key (as far as I know) so how can bitcoin core generate a receiving address? How is the receiving address created?

When the wallet initializes, it will generate a master private key for the you as part of the initialization. All subsequently generated keypairs will be related to the master private key, this is called a 'Hierarchical Deterministic' Wallet (HD wallet).

An HD wallet is nice, because you only need to backup the seed phrase that generates your master private key, rather than backup every individual address.


Coinbase maturity of 100 transactions The protocol rules state that

  For each input, if the referenced output transaction is coinbase (i.e.
  only 1 input, with hash=0, n=-1), it must have at least
  COINBASE_MATURITY (100) confirmations; else reject this transaction

Why should coinbase transactions with less than 100 confirmations be unspendable? What is the point of the rule?

The reason for this is that if a fork were to occur, some blocks will be orphaned and not have any coins which can be rebroadcast. If a block containing a transaction you send me gets orphaned, I can still get my coins, but if the block you are sending me coins from gets orphaned, I can not rebroadcast since the coinbase no longer exists on the valid chain.


How to get paid providing full node services? I run a full node.  I would like to get paid for the services I provide.  How can I go about getting that to happen?

Presently, you cannot.

According to BitNodes, as of this writing there are over 5000 full nodes on the network, all of them providing this service for free.  This certainly seems to be sufficient for everyone who wants to use it.  So nobody is going to pay you money for a service they can have for free.  The effective market value of your services is zero.

It is possible that someday, as the cost of running a full node rises, there may not be enough people running free full nodes to satisfy the demand.  In that case, the market value of this service may increase above zero, and you might be able to get people to pay to use your node.  Note that if this happens, you'll probably also have to pay other nodes for the privilege of sharing their data with your customers, and getting them to help distribute data from your customers.  But at this point, this is pure speculation.


Old Bit Coin Wallet Failing to Pass 180 Weeks I have an old laptop that I have bitcoin wallet on. I left the computer alone since early 2015 and when I try to sync the bitcoin wallet, the wallet gets stuck on 180 weeks. the bitcoin wallet sync process just eats way at hard drive space and stays at 180 weeks. I free up over 70 Gb and it still just just eats at hard drive space.

First of all, backup your wallet.dat even if you are not going to do anything to the wallet.

I don't know if you are open to using other wallets, but you could recover your bitcoin by following these steps:

Unlock your wallet
Use the command dumpprivkey "YOURADDRESS" from the Bitcoin Core console
Import the private keys on a lightweight wallet such as Electrum (Warning: There was a scam message being shown in Electrum sometime ago)


Does Bitcoin's SHA256 proof make a 51% attack more likely? Ethereum's description says that Bitcoin's mining algorithm requires only a simple SHA256 computation, which caused the creation of specialised ASICs, which centralizes mining in the hands of a few actors (ie. ASIC manufacturers), making 51% attacks much more likely.

Is that right?

SHA256 >>> ASIC >>> Centralized mining >>> 51% attack?

I think what most people making the 51% attack argument for memory hardness miss is that the base unit is meaningless when you're talking about percentages. Whether your mining algorithm is implemented with ASICs, consumer hardware or well-trained Rhesus monkeys it matters little - to launch a 51% attack you must amass enough ASICs, consumer hardware or Rhesus monkeys to represent 51% or more of the available power. This, in turn, becomes an economics problem and is far more affected by the scale of mining operations as a whole than by the specifics of how that mining is done. If three networks are mining using $1,000,000 worth of ASICs, CPUs and Rhesus monkeys, including those you control, your portion needs to exceed $500,000 worth of the underlying resource regardless of its nature.

The fear that this will occur automatically as one manufacturer comes to dominate the space is perhaps slightly more realistic, but it's a real fear in memory-hard altcoins as well since most of that consumer hardware is also made by a mere two companies: Intel and AMD. These companies may not care much about the coin you're mining today, but in the sort of world where ASIC manufacturers represent a threat to Bitcoin CPU manufacturers would represent an identical threat.

The article also dismisses the "botnet mining" argument by saying that the botnets would likely not be used to attack the coins and completely ignores the crux of the argument: That people are mining on botnets. If someone is stealing CPU cycles from my system I'm not particularly concerned with the ends, I'm more upset about the means. That Bitcoin's ASIC acceleration has made botnet mining all but impossible is, in this sysadmin's view, a positive thing.

Finally, the entire democratization argument hinges on the entirely false premise that if mining only uses general purpose hardware that people will only mine with the hardware they already have. It also neglects to account for the decreased lifespan of that already-existing hardware due to mining's extraordinarily heavy use of the resource. People can and do build additional computers for the sole purpose of mining and every computer used for mining lives a shorter lifespan than one used for casual browsing and office tasks. Mining power will still centralize because this is the nature of our economy, not of our technology - those with more money will always buy more hardware. Also, Bitcoin ASICs are only expensive because they are new. ASIC cost is almost entirely in the R&D process, which leads to a price curve whereby products become dramatically cheaper with time. The image processing chip that runs the camera in every cell phone was once new, expensive and high-tech too. Give it time.

But in the end, it is the economics, not the technology, that makes a mining algorithm secure. The nature of the hashing algorithm chosen has some interesting effects, certainly, but assuming neither algorithm has an exploitable flaw (which is less likely with widely-implemented algorithms like SHA256) the question inherently boils down to "how much would it cost me to become 51% of this network" and the resulting answer is the same whether you're mining with ASICs, CPUs or GPUs... Or Rhesus monkeys: To represent more than half of the network you must more than match the existing power of all equipment (or primates) used to mine it. If the mining equipment currently on-network is worth a million dollars, you have to spend at least a million and one.


How can there be multiple outputs with same address in the same transaction? I received a transaction such as below: (I changed the actual numbers but the format is exactly the same)

{
"amount" : 0.3,
"confirmations" : 739,
"blockhash" : "0000000000000000xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"blockindex" : 390,
"blocktime" : 1392284453,
"txid" : "aaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbxxxxxxxxxxxxxxxxxxxx",
"time" : 1388888888,
"timereceived" : 1388888888,
"details" : [
{
"account" : "abc",
"address" : "address1",
"category" : "receive",
"amount" : 0.1
},
{
"account" : "abc",
"address" : "address1",
"category" : "receive",
"amount" : 0.2
}
]
}

When I check this transaction on blockchain.info. The site shows a single output to "address1" and the amount is 0.3.

When I try to replicate this situation with QT using Add Recipient, it does not allow me to enter the same address twice. I assume the sender was able to do this using sendrawtransaction.

Is it normal? Is it a non-standard transaction? Shouldn't this transaction be rejected by miners?

It definitely seems weird to have two outputs towards the same address, but if it was picked up by your bitcoind node, then miners will probably accept it, because they're also using bitcoind.

It would be interesting to read the raw scripts of the outputs. Most likely, as you say, it was created by someone using the raw commands.

One scenario that I could think for someone doing this is that you'd want the receiver to claim the outputs in separate transactions. If there was a single 0.3 output, the receiver would need to claim all 0.3 to use them.

However, I'm not sure when this would be useful.


When will FPGAs and ASICs 'replace' GPUs for mining? Please explain in detail, or provide an an estimate, at least.

Currently the hash rate is around 25 TH/sec.  It is expected that when the ASIC hit the market in Dec 2012, the new hash rate will be about 250 TH/sec.  The difficulty is directly proportional to the hash rate, so it should also increase 10x.  This would reduce the profitability of existing GPU miners by 10x.  Plus about the same time the block reward will be halved from 50 BTC to 25 BTC, again halving the profitability.

The expectation is that once ASIC takes hold most of the GPU and FPGA mining will bleed out of the network.  You should expect to see an initial influx of ASIC and then a steady growth as mininers reach for their larger share of the market.


Is Lightning Network a blockchain technology? Does the Lightning Network use a blockchain?
Is the Lightning Network still blockchain technology or not anymore?

The Lightning Network is a protocol that builds on top of a blockchain and uses cryptography to allow value to be transferred between untrusted parties outside of the blockchain, giving these value transfers the ability to handle increased capacity. But the Lightning network is built on top of a blockchain (hence it's known as a "layer 2" solution) because the value transferred in the network is funded by and settled to the originating blockchain.

For more information check out this talk announcing the lightning network


Where can I get all historical trades BTC price data? Where can I get all historical trades BTC price data?

(There are some similar questions, but I am looking for high-resolution data, while the previous questions asked for lower resolution data, such as daily prices.)

http://api.bitcoincharts.com/v1/csv/

Each of these files have every trade executed on the given exchange (except the last 15 minutes or so).


Benefits of generate address from sha256 hash than random address Is there any benefits (eg: better security) of generate a address from SHA 256 hash vs generate a random hash?

Generate adress from a SHA 256 hash

var value = Buffer.from('correct horse battery staple');
var hash = bitcore.crypto.Hash.sha256(value);
var bn = bitcore.crypto.BN.fromBuffer(hash);

var address = new bitcore.PrivateKey(bn).toAddress();

Generate a random address

var privateKey = new bitcore.PrivateKey();

var address = privateKey.toAddress();

Generating from the hash of a string is known as a Brainwallet. This has the advantage that it is potentially easier to remember and recreate your wallet if you lose the keys.

This also have the disadvantage that people are terrible at picking entropy, and it is trivial to crack most brainwallets via brute force. You have far more security relying on randomized generator than more or less any brainwallet you could come up with.


Very hard to sync Core Client from scratch Recently I started running a Core 15.1 node with the blockchain on an external hard drive, and found it very hard to fully sync the blockchain.
The problem I keep running into is that (in about 90% of my attempts) the sync does not complete. A DB corruption occurs at some point (usually pretty late in the game, maybe 36 hours into it).

I did some digging in forums and saw that I am not the first user to notice this problem. Peter Wuille mentioned that he does a full sync on like a weekly basis and it always works, and he thus suspects that these type of issues are due to sub optimal hardware.

That seemed very reasonable at first because my initial attempt was done using a pretty old 400gig pocket hard drive. So I switched hard drives.
By now, about 2 months later, I have tried to sync the blockchain from scratch about 20 or 30 times and only twice managed to complete the process.
I did that on 4 different types of hard drives, including a brand new 1T Western Digital.

One may say that all 4 hard drives I used are "suboptimal", but I would object to that because

After the sync does complete, the node runs just fine.
I think it is
desirable to be able to run a full node on a raspberry pi with a
pocket size hard drive (note that I run the node on a raspberry pi
but use my linux desktop to do the initial sync)

Now the issue I have here is not so much the crash during sync, but the fact that when I restart the client after the crash the only option is to basically start from scratch (If I understand correctly, the client is not necessarily downloading everything from scratch but that is not my point) and sync again from Genesis.
Ideally I would like the client to keep synching from the point it successfully got to and not re sync from scratch on such errors.

I am wondering if this resync from scratch on error is necessary. I assume that corruption occurs in one (or more) of the files in the blocks or chainstate directories. If that is so then why sync from Genesis? Is it not possible to, say, delete all files post the corrupted file and sync from there?

If there is no fundamental reason for this behaviour, I would also appreciate a pointer to the relevant code in the client.

Thanks!!

Database corruption means the state of your node is corrupted, not just data it downloaded.  Resuming after state corruption would be like resuming your life after having a lobotomy.

During synchronization your node operates at hundreds of times its normal load: Consider, Bitcoin has existed for over 3000 days yet sync will complete in a day. This tends to expose marginal hardware. "suboptimal" would not be a very accurate way to describe it, "totally broken" would be better.

USB drive in general are notorious for causing corruption. Not only are the drives themselves often unreliable, but many people often suffer issues from their USB controllers and even cables.

At the expense of several more gigabytes of space usage Bitcoin nodes could periodically back up their state so that they could recover more gracefully from corruption... but the cost of doing that is great enough that the gains aren't completely clear. Especially since hardware that is messing up is also probably likely to corrupt the backups.


Cryptoissues? (stocks & bonds) Are there any examples of cryptoequities or cryptoliabilities?

I've seen the cryptostocks site, but it doesn't look to be what I'm envisioning.

For simplicity's stake, please imagine a corporation that wants to issue stock that will never pay a dividend.

Could a fully integrated trading system be built off of the cryptocurrency concept?

Here are some of the criteria:

A corporation is the only issuer in a blockchain, so no mining rewards, only fees
The blockchain would probably need to be denominated in a single cryptocurrency
There would need to be some sort of automatically resolving escrow system where a buyer first deposits cash through into the blockchain before a trade can go through with automatic refunds if the trade fails
Buyer and seller would both have to sign the transaction, buyer pledging an amount of cryptocurrency, seller pledging an amount of cryptoequity
Orders would have to be able to be left in an "open" state to provide a limit book; in other words, buyers would need to be able to post how much cryptocurrency they would want to sell so to buy some amount of cryptoequity while whether the transaction will complete is uncertain, and sellers would need to be able to do the reverse while of course pre-depositing in the escrow
Open orders would need some mechanism to be canceled
Orders would need to be able to be partially filled, so an open bid could be partially filled by a seller leaving behind the remaining order and vice versa

How could this be accomplished?

(I will post any other necessary details)

There are a couple that may be what your looking for.....

Open Transactions - http://opentransactions.org/wiki/index.php?title=Main_Page
This is more general and not specifically targeted at Cryptocurrency, it seems pretty malleable and could be used for what you are describing.

https://counterparty.co/ - This is similar to above, and as I have only just recently found it cant say much, but also looks to do the job.


What is the tradeoff between privacy and implementation complexity of Dandelion (BIP156) Dandelion is a new relay protocol for transactions on cryptocurrency peer-to-peer networks. It has been heralded as a huge privacy improvement for cryptocurrencies at the networking level– I'm wondering what costs this comes at.

Does Dandelion introduce more complexity into the code base?
Are there possible attack vectors introduced with Dandelion?
What is the hold-up with implementing Dandelion in Bitcoin Core?

In my view, the main implementation detail to be worked out with Dandelion
is ensuring that there are no new DoS vectors introduced.

In the existing transaction relay model of Bitcoin Core, transactions that
do not make it into a node's mempool -- a proxy for what we expect to be
(eventually) mined -- do not get relayed to other nodes.

In the Dandelion protocol, transactions are relayed (in the stem phase) prior
to acceptance into a node's mempool.  As a result, there are potential DoS
vectors if transactions can be systematically relayed via Dandelion but
ultimately not be accepted to any node's mempool -- this could either introduce
a bandwidth DoS, where the Bitcoin network's bandwidth is used up or wasted
relaying ultimately useless data; or a CPU-exhaustion DoS, if
expensive-to-validate transactions can be relayed without ultimately being
mined.  [In general, the only way attackers "pay" for the network's resources
they consume when relaying is via the transaction fee in their transactions; if
attackers can generate transactions that do not ultimately get mined, then any
side effects of the relay -- such as validation cost and bandwidth used -- can
be achieved for free since those transaction fees are never actually paid,
which typically implies that the network's resources could be utilized entirely
(since it would be costless for an attacker to ramp up usage).]

It turns out that -- in a naive Dandelion implementation -- it would not be
very difficult to generate transactions that would propagate in the stem-phase
but never be accepted to the mempool (at very low cost).  This is largely a
consequence of the complexity around mempool acceptance logic, and seems
particularly unavoidable given the mempool's own anti-DoS limits.

The existing mempool acceptance logic attempts to prevent or limit the effect
of these kinds of DoS attacks.  Transactions don't have their signatures
checked until just before mempool acceptance, after all other transaction
policy rules have been met, to avoid CPU exhaustion attacks.  Preventing
bandwidth attacks is more involved:

transactions are only relayed after being accepted to our own mempool
if our mempool fills up (it is a memory-limited data structure), then we can
evict low feerate transactions to make room for new transactions, but new
transactions are subject to a higher minimum relay fee, designed to offset/pay
the relay fee for transactions which were evicted from the
mempool (and will thus no longer be mined until they relay again).

In short, there's quite a bit of complexity in the mempool acceptance logic to
prevent DoS.  So in my view, the questions around a Dandelion implementation are:

(a) Do we need something as complex as the current mempool logic in order to
avoid DoS vectors with Dandelion, or can we do something simpler?

(b) Are there acceptable modifications to the Dandelion protocol that would
simplify the DoS analysis and allow for a simpler implementation while still
providing a significant privacy boost to the network?  As an example: would it
be acceptable to implement Dandelion in such a way that under DoS scenarios, we
just fall back to the current relay model?

(c) If we don't have simpler solutions that work, is it worth implementing
something akin to the current mempool logic (called a "stempool" in some of the
discussions) in order to introduce Dandelion into Bitcoin Core?  Is the code
complexity worth the privacy benefit that Dandelion would confer?  While
improving privacy on the network is obviously a good thing, the privacy
benefits of Dandelion are limited, so is this the kind of thing that's worth
spending a lot of energy to implement and maintain, or should we focus our
mental energy elsewhere?


Who does the work in proof of stake (POS)? I heard about proof of stake lately, and people are saying you don't need GPU or any mining power, as long as you have the coins, they will generate you more coins (more coins you have, more earnings you get?). So I'm wondering, 1. doesn't that make the rich richer, and poor still poor? 2. If no GPU or mining power needed, what was done? Is there no algorithm to be solved? If yes, who does it in that case since people are not mining in POS?

In PoS each node is submitting hashes in a similar way to PoW, if a hash is found that is less than the target then the block is created by that node, sent to it's peers, and if they agree, pass it to their peers.
What is different is that in PoW each node iterates through as many hashes as possible, using data from past blocks and a random number called a nonce.  The more nonces and hashes per second a PoW miner makes, the better chance they have of finding a block.
In PoS there is no nonce, the miner (minter) is only allowed to use the data from the past blocks, and use that combined with the number of coins in each UTXO in their wallet.  So if you have 10 UTXOs then you can only produce unique 10 hashes per second.  To prevent people just making more UTXOs, UTXOs with a larger number of coins have a better chance of finding a valid hash, so there is no benefit in having 1 UTXO of 10 coins, or 10 UTXOs of 1 coin each.
A PoS minter could make more than 1 hash per UTXO per second, but the actual hashes would just be duplicates as there is no variance in the inputs.  So there is no reason to do so as its just a waste of energy to create duplicate hashes.

Theoretically the rich get richer in pure PoS, but this is easily avoided by using other mechanisms to assign coins, like work done on scientific computations (Curecoin/Gridcoin).  In PoW those with more money to invest in hardware and energy get richer, which leads to them getting more hardware, it's the same problem.


What Value does mining provide? After reading the O'Reilly book and perusing online resources, I'm still confused about the value that the actual mathematical mining provides to Network (I understand it does provide value, but not clear how).

It seems like once a miner has verified transactions, the really valuable work for the network has been done. And when it starts hashing to win a competition for 25 btc, it's just playing a game that has the sole purpose of adding currency to the network (which I understand is important, no central govt. etc). I don't see how this hashing to find a value less than the difficulty actually provides a real service to the network such as verifying transactions.

Before I jumped into learning about bitcoin, I just assumed the math problems the miners were solving related to detangling or decrypting transactions, but I see now that's not the case. If the competition was a race to verify transactions, that too would make more sense.

Can anyone explain the value of this mathematical race?

As you mentioned, bringing coins into the network is one of the main purposes of mining. But this reward is just an incentive to do the other more important part of mining: 'processing' transactions.

Immutability

As detailed here, when a block has been solved, not a single bit can be changed without invalidating it.

This means that all of the transactions in the block have been processed, and are 'final' in the sense that they are in the blockchain and will not change (assuming that block is a part of the best/longest blockchain). Imagine how bad it would be if you could change the transaction ledger to mark someone no longer being paid, or not being paid the amount that you said you paid them.

Security

Requiring billions of mathematical steps to be taken to solve a block means that it is very hard to accomplish. Honest miners that mine on the tip of the blockchain get rewarded for this in the form of bitcoins. But attackers who try to go back in history and replace old blocks with new blocks are at a disadvantage because doing so requires an enormous amount of hash power.

While the attacker was going back and trying to re-mine old blocks, the rest of the network continued mining on the tip of the blockchain, making it even harder for the attacker to catch up. Hence, for someone to create blocks faster than the rest of the network they have to be in control of >50% of the network hash power. This would take millions of dollars, currently.


How to get the balance of a wallet using only bash interface? I need to get the balance of specifics wallets only by using bash terminal tools without installing anything new to the OS (An old customized Ubuntu Server)

Any idea how to do it? Thanks in advance.

you can do it by using blockchain.info and common bash tools that you already have in your system like wget, grep and awk, printf for formatting

For example by using (replace ADDRESS with the actual address you want to query):

wget -qO- blockchain.info/rawaddr/ADDRESS 2>&1 | grep -Po '"final_balance":\K[0-9]+'

And if you want to format the output from satoshi to btc you can use:

wget -qO- blockchain.info/rawaddr/ADDRESS 2>&1 | grep -Po '"final_balance":\K[0-9]+' | awk '{s=$1/100000000} END {printf "%0.8f\n", s}'


Why do you have to search for TXIDs in little-endian? I understand that when you double-sha256 some transaction data, it will give you the TXID for that transaction. This can then be used in future transaction data when you want to reference an existing transaction.

However, if you want to search for a TXID using bitcoin-cli or a blockexplorer, you have to convert this TXID to little-endian.

TXID (original):  B0570984EA35E417A20327D72414CDA0EB8200418772FA3E1A28D76EF4977CF2
TXID (searching): F27C97F46ED7281A3EFA7287410082EBA0CD1424D72703A217E435EA840957B0

What's the reason for this?

Because Bitcoin in general uses little-endian while most hashing libraries use big-endian.

For more details and links see here.


bitcoin multisig address I am struggling to find a simple explanation for how to create a multisig address. For single sig, it's clear: double hash function applied to the single pubic key in base code 59. I just can't find any clear explanation for the multisig. Help please.

A multisig address is simply a redeem script of the form m <keys> n OP_CHECKMULTISIG.

This redeem script is then wrapped in a P2SH address, which is the HASH_160 of the redeem script presented in the format standardised in BIP16

For instance, a common multisig address is 2of2 (2of3 is also very common). An example redeem script is 522103c9078b8d06d83347b2e7e8cbbdfc24bd50e09ca1a4e5d90d70485a8c4094e5672102d52317afd128305d6fca7bd30b839e821564990c88581ebb432b478cfa95602f52ae, which decodes to:

2 03c9078b8d06d83347b2e7e8cbbdfc24bd50e09ca1a4e5d90d70485a8c4094e567 02d52317afd128305d6fca7bd30b839e821564990c88581ebb432b478cfa95602f 2 OP_CHECKMULTISIG

Producing a HASH_160 for the above redeem script gives us 4aef67ed61d391d6f3d9903ead92386c1efc9925, which when put in the P2SH form is a914(4aef67ed61d391d6f3d9903ead92386c1efc9925)87 (brackets mine).

This finally gives us the address 38XEixUj1QpcqxTWbxvqdbv4Mjre4imw9Z after a Base58Check encode.


Limit wallet to sending funds to a list of addresses Imagine a scenario. There are 3 parties: Party A, Party B and a mediator party C. A and B transfer each 1 BTC to a newly created wallet W owned by C. The function of C is to distribute the entire 2 BTC to either A or B depending on some condition (think a bet). Now imagine C gets compromised and it's private key is stolen by a hacker. The hacker can now send 2 BTC to any address he wants. Is it possible to limit wallet W to sending funds to only A or B? So that even if it's compromised, the hacker can only send funds to A or B and not any arbitrary address.

Absolutely.

The mediator, C, creates an address.

After the bet payment(s) have been made, C creates two transactions. One pays to A, and the other pays to B. He keeps both of these transactions secret. Then, he destroys the private key for the address.

Depending on who wins, the mediator publishes one of the transactions.

An attacker can't send the Bitcoins to himself, but he can choose who wins the bet, or destroy both transactions.
Downsides
If additional payments are made to C's address after he destroys its private key, those Bitcoins are lost. This could be mitigated by having the address be a 1-of-2 multisignature account, where one of the keys is an offline key held by the operator of the service.
The service is vulnerable between the time that it publishes the address and the time it creates and signs the transactions. You can't create the transactions in step two before you see the incoming transactions, either, because they will depend on the txid you're trying to spend.


Accountability with Bitcoin transactions In one of the comments to this question Highly Irregular pointed out an interesting legal issue that might arise with Bitcoin. Mainly, if some organisations use Bitcoin (say, Wikileaks) and are deemed illegal by some authority (say, the government of USA), and subsequently sending money to them could be deemed illegal, how would issues with unintentional donations be handled?

Say, someone convinces a person to send "them" Bitcoins, instead of providing them with an address of the illegal organisation. The victim performs the donation, and their support of the organisation is later revealed.

How would such a case be handled in court at the current date? Do you know of any relevant laws in say, USA, that would apply to such a situation?

I am no lawyer, but as far as I know there is no specific precedent for this, or none that I could find anyway. Due to this, if you could reasonably prove that you had no intent in supporting that illegal organisation or group I don't see a strong case for any prosecution. Obviously there is a huge amount of grey area here, so what is "reasonable" would be up to interpretation. Also each country would have its own individual laws, which makes this even harder to give a specific answer.

If you are worried, I would recommend that you do two things. 1) Cover your ass by keeping all emails or any correspondence relating to your BTC transactions in a secure place. 2) You can also use tools like PGP, Hushmail, Cryptocat, Zfone, TrueCrypt and Tor to help protect your online anonymity.


Clarification of BIP32 hierarchical deterministic multisig scripts As everyone is aware, I'm a huge proponent of Vitalik Buterin's pybitcointools Python 2.7/3.x library. I am having a some trouble understanding the BIP32 concepts, which are coded in the deterministic/composite modules.

In particular, this code:

# BIP32 hierarchical deterministic multisig script
def bip32_hdm_script(*args):
    if len(args) == 3:
        keys, req, path = args
    else:
        i, keys, path = 0, [], []
        while len(args[i]) > 40:
            keys.append(args[i])
            i += 1
        req = int(args[i])
        path = map(int, args[i+1:])
    pubs = sorted(map(lambda x: bip32_descend(x, path), keys))  #
    return mk_multisig_script(pubs, req)    # (req = required sigs) ... returns redeemScript hex

# BIP32 hierarchical deterministic multisig address
def bip32_hdm_addr(*args):
    return scriptaddr(bip32_hdm_script(*args))   # returns P2SH address

I've had issues signing 2-of-2 P2SH/HD Txs with Electrum which I could only successfully sign using createrawtransaction \ signrawtransaction in Bitcoin-CLI.

How exactly is P2SH in combination with HD wallets implemented (preferably in terms of the aforementioned Python code)?

OK, I got it working with pybitcointools.

The command, bip32_hdm_script, as one can infer, returns hex of the P2SH redeemscript using the specified BIP32 master public/private keys (which is no different to using mk_multisig_script(pubkey1 pubkey2 pubkey3 2) for a 2-of-3 P2SH). Likewise, bip32_hdm_addr returns the P2SH address one gets from the redeemscript.

The catch is we're dealing with paths and such, and the function has issues with object types.

Let's use master private keys seeded with 0,1 and 2, respectively...

b32mprivkeys = [ bip32_master_key(str(x)) for x in range(3)]
gives ['xprv9s21ZrQH143K2FsoUgfptxnkXbTjWSyu7oPKz2BtJm5yWC8pZMtxbx66FhZoY2e6Fwz2rZ4zPZrgpNJHRd68RtQNcFFVbwGf7Vapo4spoqL',
 'xprv9s21ZrQH143K2r9LvVthYjmsCLwZGpAc4uAAeovjhf7vaAbiunLgRdp8DAo4fSGUMuYQzzGfNGkdsR9xq6vcaKQSTa2VQx7o31N3kxcZi9k',
 'xprv9s21ZrQH143K2AV64RkNhLQEHTphnaGZqrGBhXTw9gBTMfvDAPiKFWpkBmt9otxA2X14bRS6mPdxohX4QCP3PMi8TG7KvCriGcsQHwDHVfT']

Signing with master private keys won't work directly, let's get the master pubkeys:

b32mpubs = map(bip32_privtopub, b32mprivs)

Now, in this example, we want to descend to path 0/1, in a 2-of-3 multisig. This is represented by an int, 2, and a tuple (only!) of the path, so (0, 1).

redeemscript = bip32_hdm_script(b32mpubss, 2, (0, 1)) = 5221029057ffd5c48f95c46c5e12b837cd0e4a7538dfa8ab9eb3479593724a6109ffb4210316776496822873767c6a91efe85a55871fc4a944c1d1ccab52cebd386cef29d4210318ae5429f67dbf61f54ae947f38637f4bffa1e252922b431eeed397cac49a22953ae

Now, we use bip32_hdm_addr to get the P2SH address.

>>> bip32_hdm_addr(redeemscript)
5221029057ffd5c48f95c46c5e12b837cd0e4a7538dfa8ab9eb3479593724a6109ffb4210316776496822873767c6a91efe85a55871fc4a944c1d1ccab52cebd386cef29d4210318ae5429f67dbf61f54ae947f38637f4bffa1e252922b431eeed397cac49a22953ae

Note, FWIW,
>>> bip32_hdm_addr(redeemscript) == scriptaddr(redeemscript)
     True

AGAIN: Do not try signing with master private keys using bip32_hdm_script, lest you return a redeemscript, which when deserialised, gives:

slice(            # we want the privkeys only
       deserialize_script(bip32_hdm_script(b32mprivkeys, 2, (0, 1))),
       1, 4)

See how the keys from the redeemscript are 33 bytes long? And don't start with 02/03/04? That'll make an unusable P2SH address, so beware this pitfall!


Bitcoin trade to money you receive at Neteller to your Neteller creditcard? So can I trade Bitcoin at a site like localbitcoins.com to receive money in my Neteller account and add the money I received at this Neteller account to my Neteller creditcard?

LocalBitcoins.com itself actually supports Neteller: https://localbitcoins.com/buy-bitcoins-online/neteller/


Which mining pools use custom mining software? Which mining pools use custom mining software? Do those pools require the users to use their software, or just encourage their users?

BitMinter offers its own mining software, but also gives the option of using other programs by connecting to mint.bitminter.com:8332 .


Electrum Error Message "22" When I try to send BTC from my Electrum wallet address to one of my unused addresses in Electrum, just as a test, it comes up with an error message (U'message':u'TX rejected, U'code':-22).
I'm using electrum-1.6.2 Install version on my Windows 7 64-bit PC.

I changed the Electrum server and then the transmission worked, so I guess it was an error transmitting data to the server.

Can someone confirm that Error "22" refers to a transmission error to the server?
Also, is there a list of error message numbers, so in future I can refer to the list?

I've been reading the source code of Electrum, and it turns out that the reason why you can't find anything about this is that it's not an Electrum error-it's an error generated by the Bitcoin client, and Electrum is just passing it along.

Now, what causes the error?

There are a bunch of ways it can happen (like trying to send a coinbase transaction), but the number one way that this can happen is if you send the same transaction twice. Unfortunatly, the current implementation of sendrawtransaction doesn't really give you any information about why.

(For those that are interested, the relevant error is on line 555 of rpcrawtransaction.cpp.


Where do I include my wallet address after finding the hash less than target - bitcoin Please help me understand the logic behind mining a bitcoin from scratch. I want to create a bitcoin miner, it will not receive any blocks from any pools. All should be done inside the miner.

So, I have made some progress, I've coded with vb.net and successfully got a result of a hash (old example)

Version 2
Prev. Block 00000000000000000A2940884E0C3BC96510CAD11912A527E9D15DF42F0E1D67
Merkle Root 2E99F445C007A9158207CC30CEBAD2B3D26C45FDAB2EBDF50D261335FC00D92C
Time    12/16/14 18:05:40
Bits    404454260
Nonce   3225483075

Block Hash  000000000000000015A8D88216918C8DE090268A5E7F53FEEF72CD111F7F27FF

So, suppose old example is a real one, so, I want to know where do I include my bitcoin wallet address if I want to get the block reward to my wallet address? Should I have hashed the wallet address with the above and hash with the wallet and come up with a hash which is less than the target? Or after getting a good hash, just send data to blockchain with the wallet address to receive the block reward? or should I create some other hash with my wallet address? what should I do to include my wallet address in this?

pseudo code would also be nice If you can provide for me to understand how to include my wallet address.

my pseudo code upto now

**Step 1**
version -> convert to hex

Prev. Block -> convert to hex

Merkle Root -> convert to hex

Time  -> get unix time and convert to hex

Bits -> convert to hex

Nonce -> convert to hex

**step 2**
Add hex values of all the above and then hash it with Double SHA256 to receive the hash value.

**step3**
Check if the final hash value is less than the target

**step 4?** what should I do with the above hash? where should I include my wallet address?

Mining a valid block involves multiple steps.

To begin with, you must know which block you are mining on top of, which is specified by the previous block hash.

Then, you must obtain a merkle root that locks in a valid set of transactions. Usually, this is a set of transactions from the mempool + the coinbase transaction, such that there are no double spends or invalid transactions. These transactions are assembled into a merkle tree, from which the merkle root is placed into the block header.

The coinbase transaction in particular is important, as it must follow the coinbase transaction rules (inclusion of block height, correct output for the block reward, extraNonce). It must be placed as the first transaction in the block, and contains the output that sends the BTC to your wallet.

Finally, you must add in the other fields such as block version, time, nonce, etc.

This complete block header of 80 bytes is the payload that is hashed and compared against the target value. If your resulting hash does not meet the target requirements, you must change the nonce in the block header, the extraNonce in the coinbase transaction, or any of the transactions in your merkle tree to obtain a new merkle root, and hash the new block header. This process is repeated until you find a valid hash for the target.

In order, your approach would be like:

Get a list of transactions you'd like to include (this can be an empty list)
Select your wallet address to receive the block reward
Build a coinbase transaction that pays this reward to your selected address (plus any transaction fees)
Make the coinbase tx the first one in your list
Build a merkle tree from this list
Select the merkle root from this tree
Proceed as you're doing already


Tiny 1-block forks in blk.dat files I just completed parsing the Testnet3 Bitcoin blockchain stored in the blk.dat files into a database. Since I was using multi-processing to parse several files at the same time, I didn't add the height to the blockchain while parsing it. Instead, I did this after the whole blockchain was parsed.
Everything was going smoothly while adding the height to the blocks for the most part. However, approaching the end of the blockchain (the last 7%), my code started to crash because it started to find 2 different blocks that had the same previous block (basically, a fork), and I had already constrained my database to avoid having 2 blocks with the same height. All these tiny forks I have been finding are just one block long, and it looks like the closer I get to the end, the most common it is to find these tiny forks.
I have had to look both block-ids up in a block explorer to find out which one is the official block and which one is the fork ("fake" block). One of them is always non-existent for which I know it is not an ID misplacing. I have been manually deleting the link of the "fake" block so my code can keep adding the height, but as I said before, it becomes more and more common to find these tiny forks the more I approach the end of the blockchain.
I was just wondering if this is normal, or if there is something really wrong with my blk.dat files.

This is normal, especially on testnet. What you are seeing are known as stale blocks (or also incorrectly as orphan blocks). These occur when miners complete a block at around the same time so some nodes receive the two blocks in a different order. The conflict resolves when the next block is found.
You will commonly see stale blocks on testnet due to testnet's low difficulty. Furthermore, you see these towards the chain tip because it is only possible to receive these when you are not attempting to do the initial sync. So you won't receive stale blocks during the initial sync, but once you exit that and begin normal operation and your node receives new blocks, you will end up receiving stale blocks (but they aren't necessarily stale yet).
You will need to modify your code to handle stale blocks.


Where can the private key from a bitaddress.org paper wallet be redeemed? I recently got started by creating a single wallet using bitaddress.org. This contains the public bitcoin address and the private key in the wallet import format.

I now have some coins in there, but don't really understand how to use them.

How can I access/use my bitcoins? How is it possible to make a payment? What are the different options?

Any advice is greatly appreciated!

A paper wallet has a private key ("Redeem") and a Bitcoin address ("Load & Verify").

You can import the private key in the Bitcoin-Qt/bitcoind client using the Debug console or the command line API.
You can import the private key into Mt. Gox (Funding, then Redeem, Private key) and it will sweep the funds to your exchange E-Wallet account.
You can import the private key into Blockchain.info/wallet
You can import the private key from a mobile by scanning using EasyWallet.org
(fee applies)
You can import a private key into the Multibit client and possibly with other clients.
You can spend using a private key with Brainwallet.org <-- Be careful with this.


Are there estimates on the geographical distribution of the bitcoin supply? There are two similar question on the site:

Is there data on the geographic distribution of bitcoin users?
I am eager to know details about distribution of bitcoin

The first is asking where the users of Bitcoin are located. The second is asking about percentage distributions among those users. Interesting data.

What I want to know is the geographic distribution of the bitcoins themselves. For example, what percentage of the bitcoin supply is held by North Americans (or North American companies)?

http://fiatleak.com/

This tool supposedly gets data from "Mt. Gox, Bitstamp and BTC China to show you which countries and which currencies are moving in and out of bitcoin in real time."  I'm assuming it's just Mt. Gox and Bitstamp now and possibly others.

-http://www.zerohedge.com/news/2013-11-11/meet-fiatleakcom-%E2%80%93-real-time-map-bitcoin-transactions-country

UPDATE

As of September 2019, the exchanges from which the data seem to come are listed under "exchange" in the bottom left of the tool. Perhaps take it with a grain of salt, as there's some obvious errors, such as gdax still being listed along with coinbase pro. Gdax was rebranded as coinbase pro about two years ago. The listed exchanges are:

bitfinex
bitflyer
bitmex
bitstamp
bittrex
cex.io
coinbase pro
exmo
gdax
gemini
itbit
kraken
livecoin
neraex
quoine
yobit


getbalance and listaddressgroupings inconsistent I imported a private key from my electrum wallet (testnet) to bitcoincore (testnet) as follow:

In my electrum wallet, I copy the private key associated to the address mmUToPM2vBb2F1ZNcR86J12GxqAbUJtFCr (balance of 0.06 BTC)
Then I import it into bitcoincore:

~# bitcoin-cli importprivkey "the 52 characters private key here" "From Electrum Wallet"

Rescan should be automatic but I ask for a reindex and rescan:

~# bitcoind -rescan -reindex

After a while, I can issue:

~# bitcoin-cli listaddressgroupings

And I successfully get:

[
 [
   [
     "mmUToPM2vBb2F1ZNcR86J12GxqAbUJtFCr",
     0.06000000,
     "From Electrum Wallet"
   ]
 ],
 [
   [
     "2MwBERpNv7JJaW4nVUbQncXjFjG1nFKLYEp",
     0.05000000,
     "test"
   ],
   [
     "2N4AMdXitdYhNdjafzHG61uUdrErExSdhKs",
     0.00498305
   ]
 ],
 [
   [
     "2N6xTkaeuKsQSHCortgxiNvsVXj2Gv1Qy85",
     0.05000000,
     "test2"
   ]
 ]
]

But when I ask for the balance, it returns 0:

~# bitcoin-cli getbalance mmUToPM2vBb2F1ZNcR86J12GxqAbUJtFCr

0.00000000

How possible is that, considering that the rescan has been performed and that the balance is correct in listaddressgroupings? As a result, I am not able to spend bitcoins from this address.

Thank you for you input/insight!

My bitcoin.conf:

txindex=1
addrindex=1
listen=1
server=1
daemon=1
testnet=1

You are using getbalance incorrectly. You have specified an account name of the address that you want the balance for. However this is not how getbalance works. Bitcoin does not use accounts and addresses are not accounts. An account here means an account in Bitcoin Core's internal accounts system which has since been removed.

So your command getbalance mmUToPM2vBb2F1ZNcR86J12GxqAbUJtFCr is asking for the balance of the account named mmUToPM2vBb2F1ZNcR86J12GxqAbUJtFCr, but no such account exists. The account that has the address mmUToPM2vBb2F1ZNcR86J12GxqAbUJtFCr is named From Electrum Wallet. Thus the command you should be using is

getbalance "From Electrum Wallet"


Sending P2SH transaction with non-standard script I'm trying to send transaction with script:

ScriptSig: OP_PUSHDATA<Sig> OP_PUSHDATA<Data1> OP_PUSHDATA<Data2> OP_PUSHDATA<Data3> OP_PUSHDATA<RedeemScript>

Since the data is less than 75 bytes in the raw transaction performed direct pushes.

RedeemScript: 2OP_DROP OP_2DROP OP_PUSHDATA<PubKey> OP_CHECKSIG

RedeemScriptHash160 of 6d6d2202ada9884dbd1e8bd90968ba66256f017cd77d83595027f7929ae3537f98c92d4aac=738292fc46dd7af803bd56035d0988af96a31681

ScriptPubKey: OP_HASH160 <redeemScriptHash> OP_EQUAL

But I get error when sending raw transaction:

  code=-26, message=16: mandatory-script-verify-flag-failed (Script
  evaluated without error but finished with a false/empty top stack
  element)

Could someone help to understand what is wrong with that script?
This this my transaction:

020000000001012f15356f4dfb7f48a91a72f5ff1071f72cb5fe4acc29e98ff5ae17a008a01dba000000007C160014ac09dd336a6fc10034fc44dcb706855668921ce7141f8b0800ffc1765400038d78055c545df3ff5d4a141f8b0800ffc1765400038d78055c545df3ff5d4a141f8b0800ffc1765400038d78055c545df3ff5d4a246d6d2202ada9884dbd1e8bd90968ba66246f017cd77d83595027f7929ae3537f98c92d4aacffffffff01c005d9010000000017a914738292fc46dd7af803bd56035d0988af96a3168187024830450221009108d4e65a34fb50cd3283b6386a679f0dfc2b5fe97e3b3c3f6b8320814b3a2902204631daf2bb93605c9e079750092f304966b69fe28ce7701f4bc677714bca23af012102ada9884dbd1e8bd90968ba66256f017cd77d83595027f7929ae3537f98c92d4a00000000

{
  "result": {
    "txid": "441cf52028ee0acc8b4076681c7fd46dad03501be62c6b0050ca59090fa52973",
    "hash": "dad2b4c56556b74d87243149ca3384ce04584d3bd8d21d80e291c4f9eed7e3f8",
    "version": 2,
    "size": 317,
    "vsize": 235,
    "locktime": 0,
    "vin": [
      {
        "txid": "ba1da008a017aef58fe929cc4afeb52cf77110fff5721aa9487ffb4d6f35152f",
        "vout": 0,
        "scriptSig": {
          "asm": "0014ac09dd336a6fc10034fc44dcb706855668921ce7 1f8b0800ffc1765400038d78055c545df3ff5d4a 1f8b0800ffc1765400038d78055c545df3ff5d4a 1f8b0800ffc1765400038d78055c545df3ff5d4a 6d6d2202ada9884dbd1e8bd90968ba66246f017cd77d83595027f7929ae3537f98c92d4a OP_CHECKSIG",
          "hex": "160014ac09dd336a6fc10034fc44dcb706855668921ce7141f8b0800ffc1765400038d78055c545df3ff5d4a141f8b0800ffc1765400038d78055c545df3ff5d4a141f8b0800ffc1765400038d78055c545df3ff5d4a246d6d2202ada9884dbd1e8bd90968ba66246f017cd77d83595027f7929ae3537f98c92d4aac"
        },
        "txinwitness": [
          "30450221009108d4e65a34fb50cd3283b6386a679f0dfc2b5fe97e3b3c3f6b8320814b3a2902204631daf2bb93605c9e079750092f304966b69fe28ce7701f4bc677714bca23af01",
          "02ada9884dbd1e8bd90968ba66256f017cd77d83595027f7929ae3537f98c92d4a"
        ],
        "sequence": 4294967295
      }
    ],
    "vout": [
      {
        "value": 0.31,
        "n": 0,
        "scriptPubKey": {
          "asm": "OP_HASH160 738292fc46dd7af803bd56035d0988af96a31681 OP_EQUAL",
          "hex": "a914738292fc46dd7af803bd56035d0988af96a3168187",
          "reqSigs": 1,
          "type": "scripthash",
          "addresses": [
            "2N3mz7o8v3YT4arXdQ5p8So6q3FUGjhUpEE"
          ]
        }
      }
    ]
  },
  "error": null,
  "id": "curltext"
}

Before the redeem script is executed, the stack looks like this (from top to bottom): TRUE, Data3, Data2, Data1, Sig. The TRUE on top of the stack comes from OP_EQUAL.

Now the redeem script runs and you drop the top three elements from the stack and then add PubKey, leaving you with PubKey, Data1, Sig. When OP_CHECKSIG runs now it uses Data1 as Signature instead of Sig which makes it fail. At the end the stack is FALSE, Sig. The top element of the stack is FALSE which makes the transaction fail.


Can't use Bittrex Exchange python-bittrex api call: no output I'm completely new to python (and programming), and I know this question will sound very dumb to most of you people. I'm experimenting on getting datas from the cryptocurrencies exchenge bittrex and put it into variables into my script for further calculations. I'm trying to make this unofficial repository working to fetch datas from their api. While I have no problems with the public datas (fetching with curl), I can't get this piece of python to work, and thus I can't fetch balances nor any other private datas.

In order to install it I made the following:

wget https://github.com/ericsomdahl/python-bittrex/archive/master.zip
unzip master.zip
cd python-bittrex-master
python setup.py install

The following files were created:

ls -la /usr/local/lib/python2.7/dist-packages/bittrex/
total 48
drwxr-sr-x 2 root staff  4096 Sep 30 15:04 .
drwxrwsr-x 3 root staff  4096 Sep 30 15:04 ..
-rw-rw-r-- 1 root staff 15357 Sep 12 18:34 bittrex.py
-rw-r--r-- 1 root staff 17302 Sep 30 15:04 bittrex.pyc
-rw-rw-r-- 1 root staff     0 Sep 12 18:34 __init__.py
-rw-r--r-- 1 root staff   145 Sep 30 15:04 __init__.pyc

Then I created this test files, but they are both producing no output:

cat get_balances.py
#!/usr/bin/env python
from bittrex.bittrex import Bittrex
api = Bittrex('fXXXXXXXXXXXXXXXXXXXXXXXXXd', '1XXXXXXXXXXXXXXXXXXXXXXXXX0')
api.get_balances()

and

cat get_markets.py
#!/usr/bin/env python
from bittrex.bittrex import Bittrex
api = Bittrex('fXXXXXXXXXXXXXXXXXXXXXXXXXd', '1XXXXXXXXXXXXXXXXXXXXXXXXX0')
api.get_markets()

Before I did python setup.py install the output was: ImportError: cannot import name Bittrex

I tried to troubleshoot it running with python -v in front but it did produce 500 lines of output that I didn't manage to understand, I'd share it of course if someone asks for it.

While I'm writing I'm sure I'm missing something very trivial, sorry if it's a dumb question, but documentation is lacking any principle, it's very few and it assumes that who is integrating this code is a developer; and I'm not.

Following suggestions from another forum I did:

root@my:/home/me/test/python-bittrex-master# pip install bittrex
Downloading/unpacking bittrex
  Downloading bittrex-0.1.4.tar.gz
  Running setup.py (path:/tmp/pip_build_root/bittrex/setup.py) egg_info for package bittrex

Downloading/unpacking requests==2.7.0 (from bittrex)
  Downloading requests-2.7.0-py2.py3-none-any.whl (470kB): 470kB downloaded
Installing collected packages: bittrex, requests
  Running setup.py install for bittrex

  Found existing installation: requests 2.2.1
    Not uninstalling requests at /usr/lib/python2.7/dist-packages, owned by OS
Successfully installed bittrex requests
Cleaning up...

python get_balances.py
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning

So there is a warning, but still no output.

If you try the code I pasted as is, it should return "invalid api", while it throws no output on my system. How to troubleshoot this?

Try...

balance = api.get_balances()
print balance


bitcoin-cli "error: couldn't connect to server" I'm trying to connect to a Bitcoin Core on Windows 10. I start it with this command:

.\bitcoin-qt.exe --server --rest --rpcport=54352 --rpcuser=admin --rpcpassword=admin123

Using netstat -an I see that it indeed is listening on requested port

TCP    127.0.0.1:54352        0.0.0.0:0              LISTENING

However, trying to connect with bitcoin-cli using this command:

.\bitcoin-cli.exe getinfo --rpcport=54352 --rpcuser=admin --rpcpassword=admin123

results in this error:

error: couldn't connect to server

What am I doing wrong?

The --* arguments to bitcoin-cli should come before the RPC command. Those arguments are for bitcoin-cli itself. However the position you put them in are positions for the getinfo RPC command and not bitcoin-cli. You should instead be using the following command:

.\bitcoin-cli.exe --rpcport=54352 --rpcuser=admin --rpcpassword=admin123 getinfo


Is there a way to determine the difference between a BTC prefix 3 address and a LTC prefix 3 address? I am trying to determine if there is a way to tell the difference between a BTC prefix 3 address and a LTC prefix 3 address, for validation purpose.

Example if given this public key address:
3HpwVq6zSd3wxSrAypFYJGKE2JTm3fvuC9

Would there be a way to definitively say it is a BTC or LTC address?

No, there is not. There isn't anything network specific about an address. Such addresses can be used on both Bitcoin and Litecoin. You could also spend both the Bitcoin and Litecoin associated with that address so long as you have the private key. Because Bitcoin and Litecoin use the same Elliptic Curve and the same scripting system, all you would need to do is to export the private key from one wallet and import it into the other.


What is the difference between a electrum server type F and P As I am trying my first steps with Bitcoin, I ask you to ignore my potential ignorance.

With Electrum I have to choose a server of which there seem to be F and P type servers. What is their difference?

F: Full servers

P: Pruned servers

This is an old question, Electrum server are not F or P anymore.


What does the sum column in Ripple.com order book mean? Look at this entry:

Sum BTC     Size BTC    Bid Price XRP
3.77987104  2.77987104  22,999.9999

How is the sum of 3.77987104 calculated?

The sum is the total value of all orders up to and including this one.


how recover my money in Coinbase Wallet? I just wanna ask if there is possibility to recover my money in coinbase wallet. I forgot my recovery phrase but i remembered my btc wallet address and TXID. thanks

According to coinbase

  Wallet is a user-custodied digital currency wallet and DApp browser. This means that with Wallet, the private keys (that represent ownership of the cryptocurrency) are stored directly on your device and not with a centralized exchange like Coinbase Consumer. You do not need a Coinbase Consumer account to use Wallet and you can download Wallet from anywhere in the world.

You cannot recover control over money in a user-custodied wallet using only a Bitcoin-address and a Transaction ID.

If you have somehow lost your wallet (e.g. phone dropped into ocean) - without the recovery phrase or some other equivalent sort of backup, your money is gone forever.

If by "Coinbase Wallet" you actually mean "Coinbase Consumer" - that is a custodial-wallet (or equivalent service) and your only possible way to recover control over your money is to communicate with the help-desk of Coinbase.


How can an output be spent while the transaction is in mempool I have seen transactions on a block explorer where the transaction is in  mempool (unconfirmed) but one of the outputs already appears as spent, I am curious how this works. This question is a duplicate of this question, but the answer there doesn't quite satisfy my confusion. I am thinking about how this process is permissible in conjunction with the protocol rules for 'tx' messages listed here, particularly rule 9, 10, 12.

For each input, if the referenced output exists in any other tx in the pool, reject this transaction.

For each input, look in the main branch and the transaction pool to find the referenced output transaction. If the output transaction
is missing for any input, this will be an orphan transaction. Add to
the orphan transactions, if a matching transaction is not in there
already.

For each input, if the referenced output does not exist (e.g. never existed or has already been spent), reject this transaction

Questions:

Part of what might be causing confusion is the definition of "spent" on the block explorer - when it claims an output is spent does this equate to "there exists a transaction at least in mempool that uses the output as an input"?
The ability to broadcast a tx message that uses the output of an unconfirmed tx as an input seems to explicitly violate rule 9. Does it not?
Rule 9 & 10 seem to be at odds with each other. Rule 9 says to reject if the output is in a tx in mempool, rule 10 says to check mempool for the output (as though it is permissible). Are they not?
It is my belief that full nodes keep a "UTXO" set for validating some of these criterium - is the UTXO set updated once a transaction hits mempool (i.e not waiting for a confirmation)?
Is mempool relative to one node? I.e, if I broadcast a transaction and a node accepts it as valid does it then pass the transaction around so that other nodes can add it to "their" mempool, or is there somehow a "central mempool" that any validated transaction can get sent to.
Is it possible to cancel a tx message that has been added to mempool? I am not asking if typical software has this feature - but is it theoretically possible for a power user or is it "permissible behavior" within the bitcoin protocol.

There is no rule requiring a transaction to have a confirmation before being spent.

Yes, the mempool matters. That's also how double-spends are detected. So it's crucial nodes check the mempool and not just previous blocks.
No it does not violate the rule, they are referring to double-spends being rejected if the SAME output exists in the mempool.
IDK, maybe ask the original poster what they meant?
Yes, no need for any confirmations to become an unspent transaction output.
Mempools from node-to-node are not always identical. For example, some nodes have different minimum relay rules that may include extremely low fee transactions. There is no central mempool.
Not really. I haven't done it recently but lets say you broadcast a transaction with a 0 fee. The transaction would likely get stuck in the mempool and not get confirmed. After 14 days if it doesn't get included in a block it "expires". Once expired/dropped I could craft a new transaction using the same UTXOs that I used in the original.

Here's a related question that you will probably find interesting:
What happens to transactions in the mempool when their parent transaction expires?


What does the mining difficulty number really mean? I'm new to bitcoin; please bear with me.

I'm looking into mining, how it works, and how to get started. I see a "mining difficulty" from many sources and list a 3 billion something number without units.

What exactly does this number mean and how does it relate to the processing speed of the hardware used? For example, what predictions can be made on the number blocks you will solve with a 100 Gh/s ASIC at any given difficulty?

I assume Gh/s is giga hashes per second, though I don't know what a hash is either.

I found this related question, but I don't understand the answer.

As an extension question, how might this relate to mining in a pool? Bitminter says it has 424 Th/s, so my 100 Gh/s is a drop in the bucket.

(If I may repeat myself a bit...) Mining is like having a lot of people throwing weighted coins (such that 1 millionth of the time it comes up heads) and telling you when they hit a heads. If one such "heads" is reported every 10 minutes (600 seconds), you can make a very accurate estimation of how many times per second the coins are being flipped. In this example:

(1,000,000 flips/heads) / (600 seconds/heads) ~=
1,667 flips/second

The network difficulty is how you adjust this 1,000,000 figure so that the 600 figure stays consistent as the network's total hash power (1,667) changes.

To see real-world calculations of how the difficulty affects the coins discovered per time spent, see any mining profitability calculator, and change the "difficulty" figure. The Bitcoin wiki has details on difficulty, as well.

  I don't know what a hash is either.

When mining, your computer creates a block of data, which has a list of all of the transactions it knows about, includes a transaction that pays you the mining bonus, and then hashes that. If the hash happens to be a small enough number (as defined by the difficulty), the block is valid. If it's not, you increment a random number called a "nonce" that's in the block, so that the block has the same meaning but different data, and hashes the block again. Lather, rinse, repeat. (the nonce is included from the start, of course, but I didn't mention it to avoid being confusing)

The details of the block hash are explained in more detail at Bitcoin wiki's Block hashing algorithm.

Gigahashes per second, then, are how many billion times your hardware can do this hash per second.

If the pool you're in has 424 Th/s and you have 100 Gh/s, then you are about 1/4000th of your pool's total power. You can expect to be the one to solve about 1/4000th of the blocks (on average) that your pool finds.

(technical details intentionally omitted; those are available at my various links, and your link)