Non-obfuscated chainstate data I'm wondering if there is a flag that allows running bitcoind without using an obfuscation key for the chainstate. I haven't been able to find it.

There’s no way of easily disabling obfuscation, but you could build a version that sets the keys to zero, resulting in no change when the XOR is used. Generally it has no impact on anything, so it’s left enabled even on non-windows systems where it’s generally not useful.


Is a mining program necessary for mining, or can bitcoind mine by itself? I'm having a hard time understanding the relationship between daemons (such as bitcoind or litecoind) and mining.  Some things I read make it seem that you need a separate mining app and some things seem to suggest that the daemon itself does mining.  Which is it?  I'm thinking maybe the daemon can do mining but it needs to be enabled and if you don't enable it you can use a separate app instead?  I'm confused.

The daemon can do mining using the -gen command line option, but it's CPU mining and is impractical nowadays.

Using a separate mining app is practical. That separate mining app connects to a running bitcoind via its JSON-RPC API in order to facilitate getwork or getblocktemplate requests necessary for hashing.

The JSON-RPC API is configured in bitcoin.conf or at the command line using these arguments:

-rpcuser=<user>        Username for JSON-RPC connections
-rpcpassword=<pw>      Password for JSON-RPC connections
-rpcport=<port>        Listen for JSON-RPC connections on <port> (default: 8332 or testnet: 18332)
-rpcallowip=<ip>       Allow JSON-RPC connections from specified IP address


"Fork choice rule" : A general term? or a specific algorithm? Is "Fork choice rule" a general term including all the algorithms used for choosing a branch among other branches in a fork (including longest chain rule in Bitcoin etc) ?
Or is it a specific algorithm designed for Casper Ethereum ?

A fork choice rule is a general term.

For some history I've found, one of the early written descriptions of the term is from March 2017
https://medium.com/@VitalikButerin/minimal-slashing-conditions-20f0b500fc6c

  A fork choice rule is a function, evaluated by the client, that takes
  as input the set of blocks and other messages that have been produced,
  and outputs to the client what the “canonical chain” is.

August 2015 may be the first time "fork-choice rule" was written in a blog post.
https://blog.ethereum.org/2015/08/01/introducing-casper-friendly-ghost

The 2013 GHOST paper is one of the earliest, prominent publications of a fork choice rule different from Bitcoin's, but it did not specifically mention the term.


What factors affect the value of a Bitcoin? Obviously the number of existing Bitcoins affects the value, but what else?  What are some of the primary factors for a rise or fall in a Bitcoin's worth?

The price for a bitcoin, e.g. for trading with other currencies, derives as usual from the interaction of supply and demand.

The supply of bitcoins increases over time, as determined by the rules in the software which is run by the majority of miners, and increases regularly over time, in decreasing increments.  It can also decrease when people lose access to the private keys which are needed to spend bitcoins.

The demand is driven by a variety of factors:

Bitcoin's utility as a flexible medium of exchange, with low transaction costs, efficient micropayments, little effective regulation, ease of becoming a merchant, pseudonymous accounts, and a worldwide market.
Impediments to the bitcoin economy caused by the friction and inconvenience of using bitcoins due to idiosyncratic software, difficulties obtaining bitcoins, relative lack of people who have bitcoins to spend, the risks of a new experimental currency, lack of understanding, etc.
Demand from new users, derived from recent publicity or new uses.
Speculation as to the future of bitcoins as an investment, over the long-term as well as the short term
Competition from related transactional or investment options such as Paypal, gold, etc.

Update Note that as long at the overall exchange market is relatively small, the market price can be manipulated by sufficiently well-funded investors who can expand the supply of available bitcoins, or increase demand, to meet their own goals.

See also the question and answers at What economics/finance methods and tools can be used to analyze and predict the Bitcoin market?.  (Previously I linked to this, which is now deleted:
What technical indicators might be appropriate for analyzing Bitcoin currency trading? - Personal Finance and Money - Stack Exchange)


How do I recover Bitcoins from a Change address that is in a corrupted wallet? I am running Bitcoin-Qt for Mac 0.8.1 beta

I received a "wallet.dat corrupt salvage failed" error and the client refused to launch.

I replaced the wallet.dat with a backup made a few hours earlier and on launching the client, I found that almost all my Bitcoins had been transferred to an alien address which I did not recognise, and had certainly not initiated.

One possible explanation is that these Bitcoins have been transferred to a Change address. But how can I access this?

If that really was a change address, its private key is included in your backup of the wallet, even if you can't see it in the client GUI; this is because Bitcoin-QT always keeps some (a hundred, IIRC) precomputed addresses ready, and uses them whenever you request a new address or it needs a change one. However, change addresses are never shown in your address list, so you couldn't see them even if this was your original wallet.

If those Bitcoins have really been sent to a change address, you'll still see them in your balance, and you'll be able to spend them. However, if your balance is actually less than before, then they'we been transferred somewhere else, thus the trojan hypothesis sadly applies.


Is SegWit a blocksize increase or more efficient use of blockspace? This question gets asked frequently on reddit, and I think it would be beneficial to have a canonical answer here:

Is SegWit a blocksize increase or more efficient use of blockspace?

Yes and no. It depends on how you frame the question.

It is a block size increase, because you can fit a larger number of
useful transactions into a block.

If you want to make a useful Bitcoin transaction, it has to be signed so that nobody else can change it. If you can find a way to make the block size limit not count the signature, then you can fit more transactions into a block. Therefore, segwit is a block size increase.
It isn't a block size increase, because increasing the block size
would be a hard fork, which segwit isn't.

There's a constant within Bitcoin:

static const unsigned int MAX_BLOCK_SIZE = 1000000;

If you raise this, even by a little, it becomes possible to create a block which new clients will accept, but old ones will not. This is commonly called a hard fork.

Segwit is not a hard fork. It does not amend or remove any rules; it only adds new rules. Increasing the block size requires modifying a rule, and segwit does not modify a rule, therefore segwit is not a block size increase.
It is a block size increase, because a block requires more space to
store and send.

You have a segwit block with 800KB of transaction data, and 800KB of witness data. This is 1.6MB, which is bigger than the previous limit. Since segwit full nodes must have this data to validate a block, segwit is a block size increase.
It isn't a block size increase, because a node requires less or the same amount of space to store and send blocks if it doesn't understand segwit.

You have the same block as the previous example, but it's sent to a node that doesn't understand segwit. It only receives the 800KB of transaction data. This is all it needs to store. Since that isn't larger than 1MB, segwit is not a block size increase. However, if it does not store the witness data, it cannot meaningfully validate the block.


What happened to the original Ripple Project? Today, Ripple is the third-largest cryptocurrency by market cap. It uses a consensus algorithm and its only clients seem to be large banks. They open sourced the code on github, but nodes have to be approved to join the network.

However, the original Ripple project was conceived by Ryan Fugger in 2004. It has to deal with IOUs between people, and that's why it was called ripple, as each transaction is implemented by shifting around IOUs in chains, like ripples in a pond.

I want to understand whether the original protocol had any serious flaws. unlike Bitcoin and other cryptocurrencies, it seems to NOT require a global ledger and global consensus to pay people. Instead it uses a "Network of Trust", similar to PGP vs DNS. Each person only deals with a few nodes. That makes it an extremely awesome fit for our own open source platform, which we built to allow any community to host their own social network the same way Wordpress hosts blogs. Basically, an African village, or a Cruise ship, or a Classroom in a university could have a social network for their community, possibly running on the local network without having to contact a remote server. Everyone has their own identities that persist as they join various communities.

Here are some videos on the original Ripple protocol, note they are all from 2010 and 2011:

https://www.youtube.com/watch?v=xgGcVv04unM
https://www.youtube.com/watch?v=ySzqM5dpF7s

We wanted to implement money inside these communities, and the idea of IOUs between people seems great. My questions are:

Was this abandoned, or is the current Ripple source code able to implement this on a local level?
Are there any serious downsides, like sybil attacks and ability to issue unlimited amounts of credit, that necessitated a shift to a global consensus protocol?
Why does the current Ripple protocol require a global consensus?
Can someone use the old Ripple design to make money between people actually work in a local community without a global singleton ledger?

Why does the current Ripple protocol require a global consensus?
  Can someone use the old Ripple design to make money between people actually work in a local community without a global singleton ledger?
  Wait a sec! WHY DOES RIPPLE EVEN NEED A GLOBAL LEDGER AND CONSENSUS? Each person extends a credit line to their friends, whom they trust. All you need is two sides to sign every transaction, and a routing algorithm. You don't need a global ledger to hold every transaction!

Short answer: That wouldn't be Ripple; it would be Open Transactions.

Longer answer: Imagine Alice wants to make a payment to Eve. She opens Ripple, and it finds a path from Alice -> Bob -> Charlie -> David -> Eve. She starts exchanging IOU's until her payment reaches Eve. However, David's node goes down partway through this, leaving Alice with an IOU from Charlie, which is worthless to her.

(There are ways of dealing with this without a consensus sytem by making transactions that are contingent upon knowing a preimage that only Alice knows, but there's not enough space in this answer to elaborate on that. Alternately, you can send the payment through in tiny chunks, so that only a small amount of money is trapped if the payment fails.)

In contrast, if you have a global consensus system, you can make this entire process atomic and uninterruptable.

  Was this abandoned, or is the current Ripple source code able to implement this on a local level?

Don't know; haven't been following Ripple lately.

  which we built to allow any community to host their own social network the same way Wordpress hosts blogs

It doesn't sound like you need global consensus. That's a good thing, because implementing something like that is almost always a huge pain in the ass.


Bitcoin wallet - why do i need it for cold storage? Why do I need a bitcoin wallet for cold storage?  Can I just write down randomly generated public address and private key pairs, and keep these on paper?  I am confused by the apparent need for a wallet stored on a thumb drive or some other data storage device that may become corrupt.  So why do I need the wallet?

You can indeed do this. It has multiple environmental factors though which make this a bad idea.

Paper is easily damaged and very degradable.
You could make a mistake. If you do intend to do this maybe its best to quadruple check it.
Lack of extra security - unless you have it locked away in a safety deposit back in the city undergrounds, someone who knows it is there could steal it. Data drives give you extra level of security with wallet encryption.

There are probably other reasons but these are the main three, if you do decide to just do this there are a few techniques you could use to improve these factors..

Try laminating it, will give the paper exponentially longer lifepan.

Miss out a character that only you will remember, replacing a single character of a private key is easy if you know where it goes but hard if your not you, obviously just don't forget it!


Best way to get the entire bitcoin transaction history From my understanding that the entire bitcoin transaction history is stored in every client. I'm looking into ways to get this information out and get them into databases or simply csv files.

I have checked out this repository on github:
https://github.com/bitcoin-abe/bitcoin-abe

But it seems it has not been updated for a while, and it mentions

  Prior to Bitcoin v0.8, this assumption seemed safe. Abe may need some fixes to >avoid skipping blocks while current and future Bitcoin versions run.

I'm wondering if there is other tools for getting the entire transaction history out?

Thanks in advance!

There are two ways of doing that.
You can read blocks directly from the disk and process them or you can ask a Bitcoin client (like Bitcoin Core, for example) for the info via RPC calls.
The second way is easier but it may be slower.

For each block get all the hashes
 For each hash get details and write to your choice of storage

There are RPC call for each of the actions.
Just type help into the console in a Bitcoin client and you can see them all.


Why does bitcoind use a fork of LevelDB for key-value storage? Since 0.8 bitcoind uses LevelDB for the storage of the UTXO set in chainstate/ and the block index in blocks/index/. On github special branch of LevelDB can be found:

https://github.com/bitcoin/leveldb

What reasons made LevelDB the best choice for key-value storage compared to other embedded database solutions? How does bitcoind's own LevelDB fork differ from the official version?

The fork serves two purposes:

Local modifications that are hard to bring upstream:

Windows support (which is partially based on the existing Windows port, but needed changes for building in MinGW)
Removal of compression support, as it doesn't help, and complicates the build.

Strict control over changes. Given the previous experience with the BDB to LevelDB changeover that caused a fork in the network, it is wise to not use system-wide installed versions of the library. Hypothetically, even if a change is a bug fix from the point of view of LevelDB, we may want to maintain the buggy behaviour to prevent a fork in the network, depending on the bug.


How to Connect already running bitcoind in AWS to Insight API in different AWS Server Need to create a bitcoin explorer using bitcoind. I am using bitcore and insight API for this purpose.

Currently running bitcoind in AWS Server with all port open. Need to connect this running bitcoind with bitcore and use insight-api and UI in different server.

This my bitcore-node.json file:

    var configuration = {
 datadir: '/home/.bitcoin',
 network: 'testnet',
 services: [
   {
     name: 'bitcoind',
     module: Bitcoin,
     config: {
       spawn: {
         datadir: '/home/.bitcoin',
         exec: '/home/Downloads/bitcoin-0.16.1/bin/bitcoind'
       }
     }
   },
   {
       name: 'web',
       module: Web,
       config: {
           port: 4001
       }
   }
 ]
};

This is my bitcoin.conf

server=1
testnet=1
whitelist=127.0.0.1
txindex=1
addressindex=1
timestampindex=1
spentindex=1
zmqpubrawtx=tcp://127.0.0.1:28332
zmqpubhashblock=tcp://127.0.0.1:28332
rpcallowip=127.0.0.1
uacomment=bitcore

Need to Connect the Insight API to in the A server to Bitcoin in B server.

Follow the instructions on this README. It should install bitcore (the bitcoin full node implementation by Bitpay), insight-api, and insight-ui. The instructions are:

npm install -g bitcore@latest
bitcore create mynode
cd mynode
bitcore install insight-api
bitcore install insight-ui
bitcore start

If that doesn't sync with the bitcoin network and start showing blocks, then please share some logs/errors and we can help you further.


How to broadcast transaction through Bitcoin-cli on public node I have my Bitcoin WIF on a mobile application, and I want to use a Bitcoin-cli node running externally on a server to broadcast my transaction request from my mobile device. I cannot use SendToAddress because that CLI command can only be run on a node when the Bitcoins are on that node.

What Bitcoin-cli command do I use, to send coins from my mobile application's wallet, to another address?

The 'wallet import format' (WIF) is a standardized way of encoding a private key so that other wallets can recognize it. You could use it to import the private key to your node's wallet, and then sign and send the transaction from there, but I think thats different than what you want to do: keep the private keys on the mobile, but broadcast signed transactions from your node.

The bitcoin-cli command you'll want is sendrawtransaction, but in order to make this work you'll need to get a signed raw transaction hex to use as input. So you'll need a mobile wallet that can provide you with the signed raw transaction, and do so without broadcasting it to the network.

Use bitcoin-cli help sendrawtransaction for more detail on the command.

As another option, you could use a mobile wallet which allows you to manually connect to the desired node. This would accomplish a similar result.


If I buy crypto on a third party site, such as Coinbase or any other sites, how do I safely transfer my wallet into an external 'cold wallet'? By cold wallet, I mean any type of encrypted USB etc. If this isn't possible how would I buy crypto and then be able to store it on a USB in the first place? This may be a stupid question but I'm kind of new to this stuff.

The coins are not stored on the USB drive, they keys that can spend the coins are.
An 'encrypted USB' would likely not constitute a 'cold storage' device, that term is usually used to describe keys which have never existed on an online device. If you use your (online) computer to generate keys, and then store them on a USB drive, that would not constitute 'cold storage'. Generating and storing keys offline is a best practise, because it reduces the risk of an attacker stealing your keys over-the-wire.
So a lot of your security comes from how the keys are generated, as well as how they're stored. 'Hardware wallets' are devices that are built to provide a mix of security and convenience that many users find appealing, if you are new to all of this, they might be a good choice. For the more technical user seeking extreme security, there are more advanced setups possible (sanitized general-purpose hardware, multi-sig using multiple devices, etc).
Once you've purchased coins, you should be able to initiate a withdrawal from the exchange service, by copy/pasting your 'receiving address' from your wallet software, into the 'send/withdraw/etc' field on the exchange service's website.
Note that some services do not allow you to withdraw your bitcoin (eg, paypal, robinhood), so these are obviously terrible places to purchase bitcoin, that should be avoided at all costs.


is there a way to download my bitcoins to a pc wallet? i have .000313 in bitcoin in paxful wallet to start off.
id like to download it to my bitcoin wallet on my pc.

I just need some help.

That's definitely a good idea, it's always safer to store your bitcoin where you control the private keys instead of a custodial wallet like the one on Paxful. The first step would be to follow the instructions at bitcoin.org on setting up a full node.

If you don't have the storage space to run a full node on your PC, make sure and read the section on reducing storage requirements that will allow you to run a full node without the massive storage requirements.

Once you have your node setup, you should follow this Paxful faq on sending bitcoin to an external wallet.

There is a caveat though: the fees are going to make transferring .000313 BTC on chain pretty much pointless. If you check out estimatefee.com currently, the average fee costs about 309 satoshi per byte which works out to an average of 0.00115566 BTC, which is more than your balance. You might want to wait to send your BTC from Paxful when you have a larger balance, or the fees go down.


How can I force estimatesmartfee to return estimates on regtest? Creating an app that utilizes estimatesmartfee, and it works in production, but I use regtest for automated testing and can't get it to return a value.

Looking at bitcoind tests it is splitting UTXOs in a loop etc.

What is the bare minimum I need to do as far as dummy transactions and mining blocks in order to get estimatesmartfee to work like it does on mainnet.

Thanks.

You need to fill up the mempool of your regtest nodes and mine blocks (this means creating transactions --eg by using sendtoaddress-- and generating blocks --with generatoaddress).
For reference here is how it's done to test estimatesmartfee.


How much data traffic does participating in P2Pool mining cause? In an earlier question we learned some rough numbers about how much data does regular pool mining use. However, I wonder how much data is typically used when one is mining in a P2Pool?

According to Greg Maxwell:

4.14kB/sec in, 10.7kb/s out; averaged over the last 30 days. 38GB in transfer total.
Significantly less than the full node that goes with it... p2pool used to be fairly large relative to the node; but greater amounts of load on the Bitcoin network have shifted the balance.


Noob Question: Trading Fluctuating Currencies My 1 bitcoin was originally worth $16,000 USD but is now worth $17,000 USD. Ignoring fees and the fluctuation on XRP, does this mean my 1 BTC will get $17,000 USD worth of XRP or $16,000?

I ask because I'm hearing that the smart thing to do would be to keep my appreciated BTC instead of changing it for XRP, but I want to make sure the "loss" would only take place if XRP did not appreciate at the rate BTC will and not at the point of trade.

You have one BTC which worth $17,000 so you have $17,000. Now you can sell this BTC for $17,000 and buy whatever you want.


Can you put additional data in the payload? It seems to me like you could put arbitrary data into a transaction payload, since it is JSON. Is this true, can a sender add additional fields to the transaction JSON? Or if thats not possible, could a sender put an arbitrary program into the scriptPubKey?

For example, ScriptPubKey could be OP_DUP <myArbitraryData> OP_DROP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG, which would put some arbitrary data on the stack and then pop it off the stack right away again, which wouldn't influence the result of the script but would let the sender include arbitrary data in the transaction.

The JSON that you see is only a nice way to look at a transaction, provided by the API you're using. The actual raw transaction, as it is transmitted on the network, is binary data that looks quite different.

The only place in the transaction that you can insert arbitrary data is the transaction script. This script is normally used to specify the address that the money can be paid to, but can contain arbitrary data. Note that if this data happens to be a program, it won't be executed by any (typical) client, it's just data.


How to set syncnode of a peer to true? I have a testnet connection with 3 clients. When I am doing getpeerinfo on 1 I am getting

[

    {
        "addr" : "172.20.61.111:63379",
        "services" : "00000001",
        "lastsend" : 1403246741,
        "lastrecv" : 1403246743,
        "bytessent" : 1074,
        "bytesrecv" : 1098,
        "conntime" : 1403246741,
        "pingtime" : 0.00000000,
        "version" : 70002,
        "subver" : "/Satoshi:0.9.2/",
        "inbound" : true,
        "startingheight" : 56114,
        "banscore" : 0,
        "syncnode" : true
    },
    {
        "addr" : "172.20.53.82:63416",
        "services" : "00000001",
        "lastsend" : 1403246741,
        "lastrecv" : 1403246743,
        "bytessent" : 149,
        "bytesrecv" : 1098,
        "conntime" : 1403246741,
        "pingtime" : 0.00000000,
        "version" : 70002,
        "subver" : "/Satoshi:0.9.2/",
        "inbound" : true,
        "startingheight" : 56114,
        "banscore" : 0,
        "syncnode" : false
    }
]

as a result of syncnode false this node is not syncing. How do I fix this?

The syncnode concept was added in v0.8.2, to make sure we always have at least one connected peer from which we have at least once asked what their current blocks are. The name was pretty confusing, as it does not actually correspond to which peer we're downloading blocks from - just through which peer we actively seek to learn about blocks' existence.

v0.10.0 has a completely different synchronization mechanism (called headers-first), which does no longer have a syncnode. In fact, it downloads from all outgoing peers simultaneously.


balance of sub-wallet not in main wallet address (blockchain.com) I'm quite new to bitcoins so apologies if i'm being a noob, but I'm very confused!

I have many sub-wallet which created with pycoin command line.

for example, I created subwallet like this:

ku -a xpub -s 0/77 -a

my main bitcoin address and xpub is in blockchain.com.

after someone send BTC to my sub-wallet. I can check that is really confirmed (wallet and transaction in blockchain.com).

But when i go to my wallet in blockchain.com i can'nt see this balance. where is my mistake and how can I solve that?

A wallet service or application will not be watching all possible derivation paths.  Yours at 0/77 is definitely not a standard derivation and you should not expect any wallet to pick up on transactions sent to addresses under that path.


Generate new .onion address for bitcoind over tor Been following this guide just to tinker around with bitcoind over tor. According to the guide, when bitcoind controls the tor daemon using controlport=9051 whenever you restart bitcoind tor should generate a new .onion address. This is not happening. If I restart bitcoind, tor or both, it always uses the same old .onion address. A fully system restart doesn't work either.

how do I generate a new .onion address?

Note: I am NOT using /blah/var/hidden_service and cannot just delete the private key in that folder. When using controlport there doesn't seem to be a private key anywhere. Or is there?

bitcoind will cache the private key used. It is located at in the onion_private_key file in your bitcoind data directory (default will be ~/.bitcoin/onion_private_key). Delete that file and you should get a new onion private key and thus a new onion URL.


Easiest way to control a remote bitcoind instance? What's the easiest way to control bitcoind running on a remote machine?

I'd like to make transfers, manage my wallet, etc, and ideally I'd like to do it using a UI such as bitcoin-qt.  Unfortunately I don't see how to get bitcoin-qt to connect to a remote bitcoind.  Is there a different piece of software that can do this?

I know I can use bitcoind itself to send commands to a remote instance, but I'm hoping for UI.

--

The reason I'm interested is that I'm happy to leave bitcoind running and stay synchronised on one machine, but this is not the same machine that I want to run the UI on.

Assuming you're using a Linux-based system, Xpra is a great tool for running GUI apps headless and attaching to them on a remote system. Make sure you install a recent version from one of the Winswitch repositories.

I haven't tried the Winswitch front-end since command line usage is so simple. Just do this on your server:

xpra start :7
DISPLAY=:7 bitcoin-qt

And this on the client:

xpra attach ssh:my.server.ip:7


Reduce Wallet Sync Time So I am new to Bitcoin and I run the Bitcoin Core on my computer. I know that you need to wait for your wallet to sync before you can make transactions, but it says it won't finish syncing for 4 years.

I'm not sure if this is a problem and if there is a way to fix it, or I just need to suck it up and wait  for it to finish syncing. I am trying to learn how to mine and I know that I can't use a lite wallet (sorry if that's not what it is called) because large transactions will clog it up. Is there a way that I can fix this or should I just use an online wallet? Thanks for your help

The "four years" is a description of how far back in time the current synchronization progress is, it won't literally take four years to complete. For most people it will take under a day to completely sync from cold, and there's not really any way of speeding it up.


Where do I find my Blockchain wallet's change address? Six days ago, I sent some bitcoin and it hasn't been confirmed. In an attempt to execute a Child-pays-for-parent transaction, I used my mnemonic seed to derive addresses from my blockchain wallet(in order to access my private keys), but I can't seem to find the change address on the list of derived addresses. Where can I find it?

Go to https://iancoleman.io/bip39/ and download the page to use it offline (you should never enter private keys into a website).

Scroll down and choose the BIP 44 tab. In the text box next to "External / Internal", change the 0 to 1. You should then get all of your change addresses derived below.


Speeding up confirmation by double-spending a transaction stuck in mempool In the context of no-fee transactions that can take a long time to get their first confirmation, is it possible to use raw transactions and double-spend the original transaction by broadcasting another transaction but this time including a miner fee? Or does it otherwise get ignored by every miner that already has the original no-fee tx in their mempool?

Yes, it is quite possible to successfully double-spend an unconfirmed transaction.  Only about 20% of hash power today strictly mines the first transaction seen.

Here is a chart showing the convergence to 80% success when the time gap between the two transactions is 15 seconds or more.

I'll leave it to other resources to give details on how to use the rawtransaction API to do this.  Be very careful, as you can easily end up sending much more to fees than you intended.

Edit: Core Dev Peter Todd actually wrote a tool to do exactly this:

  Increases the fee on a transaction by double-spending it with a second
  transaction paying the original recipients.


How can I convert Bitcoins for withdrawal to PLN For years we've been paying exorbitant fees just to transfer our own hard-earned money from one country to another.  I'm in Poland at the moment and find I need to transfer funds from my US checking account to a local one (mBank) regularly to pay family bills etc.

Citibank for instance quietly dings me over 2.5% lower exchange rate than the current central bank rates, and about an additional 3% for "foreign transfer fee" against my account.  No credit card--That's just using my ATM/debit card at a "local" Citibank S.A. teller.  I would prefer a bank-to-bank xfer (not an expensive wire xfer) rather than have to drive to the city anyway, only during that one ATM's operating hours etc.
  Paypal is not much better.

Can Bitcoin be used as an intermediary?

USD --> BTC --> PLN

I like the idea of going through two exchanges ACH'd to my bank accounts on each side, but do their transaction fees and currency conversion rates make it worth the while?

Also, apparently last year 2011 there was still one online service able transfer PLN to/from your Bitcoin address, now they are shut down.  Anyone know others methods to cash out of BTC in PL?

Intersango trades BTC/PLN and offers free domestic withdrawal as PLN.

https://intersango.com/fees.php
https://intersango.com/orderbook.php?currency_pair_id=4


How does the New York subpoena of important people in Bitcoin affect the currency? Forbes: Every Important Person In Bitcoin Just Got Subpoenaed By New York's Financial Regulator.  Quote:

  The department is starting out by subpoenaing 22 digital-currency companies and investors to get a lay of the Bitcoin land. They sent letters to the major Bitcoin players asking them to hand over information regarding their money laundering controls, consumer protection practices, source of funding, pitch books (for Bitcoin start-ups) and investment strategies (for Bitcoin investors).  The recipients of the subpoenas are nationwide and include everyone on the “people making real money on Bitcoin” list, such as Bitcoin exchanges and processors, “ mining equipment” maker Butterfly Labs, and major investors, such as the Winklevosses, Marc Andreessen & Ben Horowitz, and Google’s venture fund.

There are many, discussions on many Reddit forums going on and some commentors seem to describe it as the end of Bitcoin.  I don't understand.

What does this legal action mean for Bitcoin as a currency, in practice?

It certainly doesn't mean the end of Bitcoin it just means the the authorities are taking it seriously and making an attempt to understand how the currency works.

It might mean the end of money laundering and evasive techniques to disguise where your money is coming from as the feds will be pushing to regulate it

I dont think it's a bad thing and I also dont think it should be a surprise to anyone, if you millions of dollars of unregulated currency floating about, of cause it's going to be regulated at some point


I need details explaination about " BLOCKCHAIN BITCOIN ADDER BOT" I saw this file titled "
BLOCKCHAIN BITCOIN ADDER" on facebook and i tried to follow the process by importing the wallet that was given. On doing that I received a lots of bitcoin that i never dream i can earn. At the end of the file the private key was given without the password. Payment was asked in order to give the password. As per me i don't have upto 2dollar worth of bitcoin not to talk of the 20 dollar that was asking.

I want to know if this method of earning of bitcoin is possible. More than 3BTC is sucked in blockchain wallet. Another curiosity is that payment is keeping on entering the wallet. There is no day i won't received a payment to the wallet.

Is this possible, real and genuine  ? Is it possible to get the password? If not, how can I remove those balances from my account?

Thank

It's a scam. They are showing you addresses that they don't actually have private keys for in order to trick you into thinking that you will be able to make money. It's practically the same thing as the traditional Nigerian Prince scam.

Think about it: if someone had all of that money and could give you the private key, why wouldn't they just take it themselves? Why would they give it to someone else in exchange for a small payment?

TL;DR IT'S A SCAM


What's the difference between `z-addr` and `t-addr` type addresses? I was playing with the zcash testnet and figured there are two different types of addresses available: z and t. Is this a privacy feature?

What's the difference between z-addr and t-addr type addresses?

This is now explained in the current Beta Guide:

  Zcash has two kinds of address: a z-addr is a fully private address
  that uses the zero-knowledge proving system to shield a transaction
  and balance privacy. A t-addr (aka "transparent address") is similar
  to a Bitcoin address.

An address can be created using:

zcash-cli getnewaddress    # t-addr, or
zcash-cli z_getnewaddress  # z-addr

t-addr is a 36 characters long string beginning with t.

z-addr has 96 characters and starts with z.


Using bitcoins JSON RPC, how can I confirm a transaction I published? I have created, signed and sent a raw transaction via bitcoind RPC. Now I want to wait for it to have n confirmations.

Considering transaction malleability, I can't just check the "confirmations" field returned by gettransaction, because the transaction with that particular txid may never be accepted, in case an equivalent transaction with some other txid was accepted instead.

So, what is the canonical way, using bitcoind JSON-RPC, to check if an equivalent transaction was accepted in place of mine? What calls are better suited for the task?

You can use the listtransactions JSON-RPC call to get the complete list of transactions that have to do with your addresses. This includes both sends and receives. You can filter for the transaction you're looking for by the category (should be "send"), address, amount and time. The txid and confirmations in this RPC call should be what's actually included in the blockchain and can be relied upon.

For reference, here's what the RPC call looks like:

[
{
    "account" : "",
    "address" : "1ENnzep2ivWYqXjAodTueiZscT6kunAyYs",
    "category" : "send",
    "amount" : -0.00040000,
    "fee" : -0.00010000,
    "confirmations" : 34055,
    "blockhash" : "000000000000000019313300fa20943b3974a97c1da2de6de13ea1281f77097f",
    "blockindex" : 414,
    "blocktime" : 1404861981,
    "txid" : "8a1f0f07fb397b2aa0e77995723f2dac9aee7df63a6f05a7db7d168d62a60f94",
    "walletconflicts" : [
    ],
    "time" : 1404861981,
    "timereceived" : 1412296394
}
]


Can I use a passphrase as a private key? Is there a way to use a long (and possibly hashed) passphrase as a private key, so that all I need to recover my Bitcoins would be that password?

I was thinking of buying Bitcoins using a private key that's generated from a passphrase, and then deleting the Bitcoins software entirely. When I want to use my Bitcoins in the future, I will re-create the key using the password. This will eliminate the possibility of stealing my Bitcoins by hacking to my computer.

The simplest and most common way of doing this is to do SHA256(passphrase) and to use the result as your private key. You can e.g. use the "Brain wallet" tab on www.bitaddress.org which is all javascript so that you can download it and do everything offline for increased security.

Be aware though that your pass phrase must be really long and truly unique since if someone would use the same pass phrase they would have access to your money. The comment from Pieter Wuille above is worth repeating:

  Be aware that when you do this, you expose your wallet to the entire
  world to do a brute-force attack on your password. If many people
  start doing this, it may become very profitable to try to find their
  passwords. Software like Armory and Electrum have the ability to
  generate a determinsitic wallet from a 'seed', but this seed is still
  randomly generated, in order to be sure that it is hard to attack


Why does Bitcoin Core take up so much space? I have downloaded Bitcoin Core and the blockchain has nearly filled my local storage. Can i move the wallet to a hard drive and then delete Core from my computer?
I'm a newbie lol

It's not Bitcoin Core that's taking up all the space, but the Bitcoin blockchain that Core needs to download, validate, and reference.  This is because Bitcoin Core is what's called a full node.  There is another type of wallet, called an SPV client, that does not require the full blockchain to operate, but relies on the trustworthiness of other peers in order to validate transactions.  I get the feeling that an SPV client is probably what you're looking for.

Alternatively, if you really want to run Core, you can store the downloaded blockchain on a separate hard drive so long as that drive is mounted when you want to run core.  You can learn more about that here:  How do I relocate my bitcoin data in bitcoin-qt to save space?


Zcash wallet generation How to generate Zcash address and private key by a mnemonic seed, in nodejs or python?
Is there some lib like bitcore-lib or ethereum-bip44?

Zcash transparent addresses can be generated in the usual BIP 44 way. There is a Zcash coin_type defined in SLIP 44, which can be used with any standard Bitcoin library. The resulting transparent addresses just need to be re-encoded with the Zcash transparent address prefix for mainnet.

There is currently no library for generating Zcash shielded addresses deterministically. We are working on ZIP 32 which will define how to generate Sprout and Sapling shielded addresses from a seed. In practice, this will be the same seed used for transparent addresses.


What is needed to make a bitcoin exchange? What do I need to setup a bitcoin exchange website like:

BTC China
Mt Gox
Bitstamp

I have my own web development team and we can code pretty much anything so that is not a problem.

I'm at a loss when it comes to know-how of this bitcoin business.
How do these exchanges even work? What would I as a provider need? Money (bitcoins)?

Is there space for me on your team?

I have spent most of this year trying to answer the same question, starting with the recognition that I could solve all the technical aspects (web programming, Bitcoin handling, trading engine, server security, etc.).

Technically, you need a website and a trading engine that matches buyers and sellers. Whilst there are lots of pitfalls---I cannot imagine a better target for cybercriminals than a bitcoin exchange storing lots of online withdraw-able virtual and real currency---all of this has adequate solutions. Not easy ones, as the technical problems occasionally seen at competitors appear to include layer 7 DDOS attacks and some have fallen pray to not storing their clients' bitcoin securely offline (and with adequate internal handling protocols), but this is really not the part I'd consider difficult to do better. To give pointers: Bitfloor is a company that fell victim to this (going out of business over it), whilst MtGox experienced it yet was able to stay in business.

The key problem is the legal aspect of your operation. The bitcoin exchanges you mention work slightly different then, say, an online stock market exchange. The later will basically negotiate contracts, leaving the participating financial institutions to settle these. It all needs lots of regulation to work, and even so the regulators (e.g. the SEC in the U.S.) are needed all the time to settle and fine disputes. Bitcoin exchanges usually require customers to make deposits. This avoids the settlement risk, but, in the eyes of many regulators (not just the SEC, but, so far and in the U.S., FinCEN and state agencies) puts them in a category with money transmitting companies like Western Union, for which there exists alot of costly and time-consuming licensing requirements. The basic idea is to safeguard customers from mishaps at the company, guaranteeing that there is money to pay them from. Today's law enforcement appears to go significantly beyond this rationale behind the law; in the case of MtGox, a US-bank account associated with them was seized for forfeiture to the government for unlicensed operation. You might think this perverts the idea of protecting the customer from a loss of those funds. I've looked into legislation in the U.S., Germany, and the U.K., and it seems that out of these, only with customers from the U.K. at least the national regulator for the money transmitting aspect does not jump to the view that you need a nearly unobtainable license (status as of this spring, with a warning that this view might change if Bitcoin were to grow so much that it would start being used "as money").

Next, you are potentially exposed to alot of fraud. Bitcoin works so well in being final and potentially anonymous that it seems to attract criminals who manage to make banks transfer money but need a way to launder such funds. You can expect that banks will start to notice a statistical association of your business with frequently disputed or outright illicit transactions. Several bitcoin exchanges have lost their bank accounts, presumably over this kind of issue, including MtGox' original EU bank account, Intersango's UK banking, and bitcoin-24's German banking. Fortunately, I think I have read articles claiming that three banks (in Silion Valley, NY, and Munich) have come out as supporting bitcoin exchange businesses if they implement rigorous anti-money laundering rules. I don't have links ready but could probably find them quickly.

Finally, you'll need someone to understand and deal with anti-money-laundering rules and anti-terrorism financing. When I read the laws about these, it sounds to me that you have to do just about everything that you'd think any democratic constitution would prohibit, like spying on your customers, acting on suspicion, keeping parts of the government well-informed and lying to other parts of the government. I'm not joking; see another answer from me. However, these rules obviously have a good reason, and that is not to allow any terrorist, criminal, UN-sanctioned person or entity, etc., to move money or related things of value. I suspect with a bit of guesswork they also explain some of the beef some banks have had with bitcoin exchanges in the past, and their tight-lipped attitude about it.

If it needs spelling out: Following anti-money laundering rules includes identifying your customers (often in the UK way of requiring photo ID and a utility bill), making sure they come from places you are licensed to do business in, checking that they are not on a blacklist, ensuring that data you could be expected to look at do not make them look suspicious. This, and the change of perception of Bitcoin by regulators from something not worth noticing to something to keep an eye on seems to be reason why the existing bitcoin exchanges now all require ID.

I still want to build a bitcoin exchange or a functionally similar alternative. But I need support in dealing with all the legal aspects; getting it right or raising the large sums of money and having the 2 years or so patience for getting licensed in larger US states is beyond what I can do on my own. Again, is there room for one more in your team?


Timed Out Payment Still Unconfirmed After 2 Days? On Friday night I tried making a payment of 0.08244000 BTC to a website for some things I had bought, the website used CoinPayments.net for their BTC payments.

I had never used BTC to buy things online before and therefore I didn't realise that I needed to pay miners tax (rookie mistake, I know) and it's now been 2 days and the payment has timed out but is still unconfirmed which means I can't get a refund for my coins.

Can anyone help me out?

Can anyone help me out?

nobody can help you. bitcoin is decentralized and no one is responsible for anything.

live with it and try to spend the rest of your life with a principle that first is learning and the second is using something.


Where can I find a Bitcoin-related job? Say I want to use a Bitcoin expertise I have and turn that into a career. Is there any website listing job offers related to Bitcoin that I could use? Alternatively, if I am someone looking for Bitcoin-savvy people to employ, where should I start looking?

You are describing, the new cottage industry -- that of The Bitcoin Specialist.

There are a lot of skills that can be combined to become self employed providing Bitcoin-related services.

There is profit that can be made when trading bitcoins in-person.  There are hundreds of individuals who are signed up with LocalBitcoins and offer this personal buying and/or selling service.  Adding a fee or offering an exchange rate in your favor from five to fifteen percent versus the market rate is not uncommon, though that is temporary as competition will bring the rates more in line with market prices over the long run.

http://www.LocalBitcoins.com

There is the need for IT security assistance.  It could be as simple as helping a person understand two-factor authentication and setting up Google Authenticator to secure access to the user's exchange account.

Individuals who don't know what an "air gap" is might be willing to pay to be shown how to create an offline paper wallet using a LiveOS on a system that has no network connectivity -- purposely disabled for security purposes.  Or set up an Armory offline wallet and demonstrate how it is used:

http://www.BitAddress.org
http://bitcoinarmory.com/index.php/using-offline-wallets-in-armory

More and more Bitcoin-related services, including #bitcoin-otc marketplace, MPEx, and FastCash4Bitcoins.com for example, require GPG. Setting that up for people (and showing how to back up the GPG private key) is a needed support service.

Online there are people who simply want to move their funds from their own wallet to an EWallet and can't be bothered with updating the software and/or waiting for the blockchain to finish downloading.   But they might be willing to attach their wallet.dat (if encrypted) or upload it (via https) to someone offering wallet transfer services.

There are people locally who might be interested in speculative trading who would pay for the education -- not just market-timing trading on the exchanges but perhaps investing on MPEX, or ICBit.se (futures) as well.

There may be individuals who would love to play BitLotto, bitZino and SatoshiDICE but don't know what "provably fair" means.  So being able to demonstrate why these can be considered "provably fair" and explain how they can be used is a service that gamblers might pay for.

Bitcoin is just one of the components in the tool chest.  Just as knowing Bitcoin very well opens some doors, knowing other privacy-enhancing technologies can be valuable as well.   Tor and to a lesser extent mesh networking are two other skills a Bitcoin technology consultant will want to have expertise in.

There may be people willing to transact on the dark net but they don't already have the technical ability to do so.  Having someone local who is familiar with the steps (e.g., install Tor, install GPG, coin mixing, etc.) and can perform assistance in getting set up, in-person, is a valued service.  [Though be careful, and don't offer this service unless you really know your stuff.]  Consider joining or starting a CryptoParty:

http://www.CryptoParty.org

Local escrow is another service.  A person might not trust an online escrow but if they already know who you are, in real life, they might be more willing to use you as escrow for a trade.

Somewhat related to escrow is to act as a buyer's agent.  For instance, someone is buying something from a seller in your town and wishes to ensure a good transaction.   So you accept the buyer's payment and then you meet the seller to inspect the goods before shipment. If the items are in working order you settle up (paying cash to the seller), and the shipment goes out.

Additionally, now that ASICs are just about to ship, a person can provide tech services to non-technical people.  The BFL equipment will still need a host, whether it is a Raspberry Pi or a desktop computer.  Unlike GPU and to a lesser extent FPGAs, the ASIC equipment does not require strong technical skills.  A miner can be set up in minutes, with only periodic maintenance.  Because there is not much heat produced nor any extraordinary connectivity requirements, ASIC mining is once again putting mining back in the range of capabilities of a typical slightly ambitious person.

Just look at all the ways bitcoins are used and there are unmet needs all over the place.


Where can I find an average transaction value chart? I'm curious on what is the average amount of BTC transacted per transaction. I'd basically like to combine blockchain.info's Estimated Transaction Value and Number of Transactions Per Day charts.

I'm writing my own script locally, but I wonder if this kind of info is already available online somewhere (googling for "bitcoin average transaction value" didn't help).

This chart can answer that question for any period you choose:

https://tradeblock.com/bitcoin/historical/1w-f-txval_per_avg-11101

Measured in BTC, the average transaction value was naturally the highest in the early days of bitcoin when its value was much less in fiat terms


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

01000000013a1b3a9209583a8fd345fdf73c80bb22fdf8a0bf1e4fc48252151f6d18b2822901000000020151ffffffff0160a59e7d5100000017a9143dbbda49ccc09591516be148dd966610f254e4bc8700000000

Your raw transaction is just completely wrong. Just pushing OP_TRUE to the stack does not make any output spendable; you still need to execute the output script. The combined script (input script and output script together) results in a failure/OP_FALSE so the input is invalid. Thus the transaction is invalid.

Looking at the output you are trying to spend from, it looks like it is a 3 of 5 multisig, so unless you have 3 of the 5 keys, you can't spend from that output.


Bitcoin's error (debug file) Bitcoin synchronized approximately on 60% and today in the morning I saw this error: "Error: a fatal error occured (see details in the debug.log)". Here's my debug log: debug log
Kindly help me to solve this problem.

Bitcoin was installed on DataD. But I also see Bitcoin folder on Sys C.
Today in the morning there really was lack of space on Sys C.
I cleaned some space, and you can see the screenshots - free space underlined in green, the capacity of disks - in blue.

So when there was 3Gb free space on Sys C, everything worked. Now I have the same error. Kindly tell me what else it's possible to do? 60% synchronization it's not everything, but a lot of time was spent on it.

This is the critical error:

2018-01-07 10:22:45 ERROR: ReadBlockFromDisk: Deserialize or I/O error - CAutoFile::read: fread failed at CBlockDiskPos(nFile=693, nPos=38137925)
2018-01-07 10:22:57 *** Failed to read block

I would 1st check if you have run out of disk space?


What will cause BTC/USD to shift substantially? Possible Duplicate:
  What factors affect the value of a Bitcoin?

It's been hovering at about $5/BTC for a few months now, slowly eeking upwards. What would cause a significant spike or drop?

Hacking and theft will, presumably, come down as more players get stable. As exchanges rise, liquidity should grow.

Major hacks or attacks on key exchanges or Bitcoin services can cause Bitcoin's price to fall quite dramatically.

Increase in popularity will slowly make the price rise. Another speculation bubble can cause the price to go up quickly.

Major investments made to Bitcoin can greatly increase the price.

All of those quick changes don't appear too likely at the moment. However, it is possible that the decrease in block reward that should happen roughly around the end of the year can double the price of Bitcoin, or make a lot of smaller miners drop out of the system.


Is it true that two thirds of available bitcoins have already been mined? The following commentator writes:

  More than two-thirds of all available bitcoin have already been mined, with the majority going to early miners.

My question is: Is it true that two thirds of available bitcoins have already been mined?

Indeed it is true, as seen here: http://www.bitcoinblockhalf.com/

As of writing this answer, just over 16.6 million BTC has been mined, out of a total of just under 21 million, which is around 79% of the total amount of bitcoin ever going to be created.


Total Bitcoins in circulation on any given day? I'm creating a spreadsheet to track total bitcoins in circulation from day 1.
This would be to add up each Bitcoin per day created and add to an accumulating total.
For example, if we picked any day we could then see what the total amount of Bitcoins created was.
If we picked the 1st January 2014 we could say the total Bitcoins mined equals X.
If we pick today (3rd June 2019) we could say the total Bitcoins mined equals X.
By definition, that would also mean we could calculate how many Bitcoins are left to be mined on any given day.
Could some one assist me to find the way to create this spreadsheet?
Thanks.

From command line the piping to date command needs a 2nd eye.  Bit late for me here, but it's a unix timestamp conversion to whatever format you want.

You can find out by:

getting the hash of each block at height X using the RPC or bitcoin-cli getblockhash X
using the blockhash to get information about that block using RPC or bitcoin-cli getblock <HASH>
get the timestamp of that block
convert timestamp into the date format you want
get the first transaction of the block (coinbase transaction) for the amount of newly mined coins using RPC or bitcoin-cli gettransaction <TX>

And run it through every block in a loop.

e.g.

bitcoin-cli getblockhash 1
00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048

 bitcoin-cli getblock 00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048 | jq '.time' | date
Mon Jun  3 18:54:45 UTC 2019

bitcoin-cli getrawtransaction `bitcoin-cli getblock 00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048 | jq -r '.tx[0]'` true | jq '.vout[0].value'
50

Here is block #1 on a btc explorer showing the same data, 50 new coins.

You can loop like that on command line but probably better to do with RPC and a real programming language.


What might cause the Bitcoin client to take a long time to see a new, unconfirmed transaction? I've noticed that sometimes, when I send Bitcoins from one client to another, the recipient client might not see the transaction, sometimes until it already has one or more confirmations. Both clients are connected to 30-40 nodes.

Is one of the clients disconnected when you send payment with the other? This often happens to me when I send a transaction to the other OS on a dual-boot system, meaning the receiving client is down when the transaction is broadcast.

I'm guessing this happens because all nodes the client connects to when he comes online have already broadcast the transaction, so they won't send it again to him. He'll only get it as part of a block when it is found.


To create a channel on the Lightning Network, do you have to execute an actual transaction? I'm trying to better understand the Lightning Network.  I was reading this article -- https://medium.com/coinmonks/lightning-network-how-does-it-work-ceeeda8ad21e .  My question is, when two parties create a channel and one or both commit funds to that channel, is the committing of those funds an actual transaction on the Bitcoin network?  That is, can the two parties involved only start using the channel when that transaction has been settled on the Bitcoin network?

Yes, a channel opening involves creating and signing 3 transactions, and broadcasting just one.

The transaction to be broadcast funds the channel, and spends to a multisig output. It is signed by whomever chooses to fund the channel. When this funding tx receives sufficient confirmation, the channel is considered open.

This multisig output is spent by two commitment transactions signed by both payment channel peers, but not broadcast. Each peer stores its own commitment transaction and only broadcasts it if it decides to unilaterally close the channel.


If there is a block-size hard fork, will the old chain have an advantage? On his blog, Mircea Popescu claims the old chain will have an advantage:

The situation here is aggravated by the fact that the fork proposed is not simply nondeterministic behaviour, and so the holdings on the two chains aren't notionally equivalent. Instead, all the holdings on the Bitcoin chain are accepted as valid on both Bitcoin and Gavincoin, but holdings on Gavincoin are rejected by Bitcoin. Consequently, everyone involved with the fork is writing options to everyone in Bitcoin, free of charge.

He makes similar claims here:

    mircea_popescu: ben_vulpes if one block's large and the other small, all i need a tx that's included in the large block but not the small one. then doublespend it on the small one, which will be rejected necessarily by the large block blockchain.

    mircea_popescu: now i have bitcoin separated in two addresses, one for each chain.

    mircea_popescu: the attempt may fail, but the cost to me of this failure is not significant, so i can keep on trying until it succeeds.

    mircea_popescu: the only way to guard against it is, obviously,for the ."large" chain to maintain 1:1 identity with the "small" one. because you don't just fork bitcoin.,

    ben_vulpes: i still fail to see how you're going to make a txn that gets included in the large block chain and not the small block chain.

    artifexd: ben_vulpes: You don't. You keep sending money to yourself until it happens.

    mircea_popescu: ben_vulpes what do you mean ? it necessarily will occur.

    mircea_popescu: since one contains more txn than the other by definition.

    mircea_popescu: suppose i make 50k 1btc txn. they don't fit in a 1mn block. they do fit in a 10mb block. what now ?

I'm skeptical of these claims -- but how exactly is he wrong?

If there is a block-size hard fork, will the old chain have an advantage?

This is partially true, but it is not as grave a problem as the writer would have us believe. It would be much more problematic if the implementation of increasing the block size were done very poorly and discretely (such as just putting out a new client with the MAX_BLOCK_SIZE parameter changed), but there will be a more continuous process to switch over to using larger block sizes.

In Gavin's proposal, nodes that aim to eventually allow larger block sizes will start using blocks with nVersion set to 4. When a supermajority is obtained, in this case meaning that 800 of the last 1000 blocks signal support for the larger block size limit proposal by using nVersion = 4, then the network will start actually relaxing the 1 MB limit to somewhere around 16 MB. From there, every 2 years the block size limit will double.

(Aside: I think it would be beneficial to have a grace period after the supermajority is obtained to allow miners in the losing side of the hard fork to update their software. I have commented on Gavin's blog post but haven't heard back, I'm sure he is very busy)

This proposal essentially puts the decision to use a higher block size limit to a vote on the network. However, until the supermajority is obtained, all nodes will still enforce the 1 MB block size limit. Thus, nodes that embrace the hard fork will not be at a disadvantage at all before the network supermajority is obtained.

After the network supermajority is obtained, technically blocks < 1MB will be accepted by all nodes, and blocks with size 1MB < size < 16MB will only be accepted by 80%. But by this point 80% of the network has already committed to allowing larger block sizes. If the nodes with the old rule don't update, they will be on the losing side of the fork and will be working on a slower-growing chain than the main chain. The old network's chain could be accepted by the new network (if they could create block fast enough to overtake the new chain), while the main network's chain could not be accepted by the old network because it breaks consensus rules.

It is also possible that the supermajority will never be obtained due to lack of support among the mining community. I would hope this does not happen. My personal opinion is that miners who are rationally trying to make a profit should make using Bitcoin as easy as possible (while still preventing spam) so that new people who want to join the ecosystem can do so painlessly and without having to wait hours for their transaction to be confirmed. More users bringing in buying pressure means the bitcoins mined will be worth more.

Coincidentally, according to a recent survey, Gavin has about 80% support among the community for his proposal.

Related: What are the arguments for and against the increase of the block size limit?


Papers/Books on how bitcoin works from a mathematical perspective? I'm a math student interested in Cryptography. Is there any paper or book which explains, in mathematics and cryptography terms, how bitcoin (more general, a digital cryptocurrency system) works? In my course book there is only about 4 pages on how cryptocurrencies work, but I'm hungry for more.

www.springer.com catalog is worth checking out - technical and well respected.

Andreas Antonopolous has a book out from O'Reilly (it is also available on github).

https://bitcoin.org/en/resources - check out the Developer Guide here, it's great.

Your school library will probably have loads of journals or access to them online (eg IEEE or local equiv).

Satoshi's original whitepaper is very readable: https://bitcoin.org/bitcoin.pdf

The bitcoin wiki.


What will a miner do when a high-fee transaction comes but he has constructed his block and is solving the puzzle? As far as I have known, the mining process is as follows,

step 1: collect a series of transactions and construct a block by filling required information like hash of the previous block and the Merkle tree root, etc.

step 2: solving a puzzle by constantly changing the 'nonce' field of the block to make the hash of the block header less than a target.

When a miner have constructed a block (step 1) and is trying to solve the puzzle (step 2), a very attractive transaction with high fee comes, will the miner give up the work he has done, reconstruct the block and restart solving the puzzle?

A modern mining system will do both.

Today, miners and mining pools have more hashpower than required to check all iterations of a nonce and extraNonce for a single block template. They get around this by consecutively operating on multiple block templates, usually varying on the block timestamp, data in the Coinbase transaction, and the list of selected transactions.

These updated block templates are constantly generated in parallel to the actual hashing operations - as more attractive transactions are discovered, the next set of block templates generated will be updated to contain those transactions. As soon as the mining hardware finishes with its current block template, it will grab a new, likely optimal template from the pool.

If a single worked discovers a valid block with a suboptimal template, miners will broadcast that block - there is little sense in discarding a block over a relatively small fee increase and giving up the entire block reward.


Bitcoin Protocol OP_RETURN + Omni USDT Tether + CoPay Multisig Help I have been asked to recover some tether that have been sent to the wrong address... Sitting on the blockchain in a multisig copay account.

I have written small php command line tools to reproduce the case and learn more about how Bitcoin works. I am a software developer working mostly with NEM where the blockchain is very different. I have learned a lot about multisig on Bitcoin, OP_RETURNs used in omni (usdt being a smartproperty on the omni layer), and many more awesome things about hierarchical key generation, key derivation functions, and many more subjects.

Script are written in PHP with laravel/zero and can be found here:

BIP32+44 HD Addresses Generation Tool on Github
BIP39 Seed Derivation (get Private Keys) on Github
My P2SH Colored Transaction creation on Github

But I struggle getting back those tether to another address. Of course, I own the 3 cosigners configured with copay, but I am too much of a noob to get those tether back. Fact is, the NEM blockchain is very different when it comes to multisig and custom assets. So I went through the learning process for HD keys and XPRV and XPUBs. Which I also built a command for. A command that, provided with the right derivation path and xpubs or mnemonics, will generate the same cosigners xpubs as copay displays in the multisig wallet information page.

Here is a link to the BitcoinTalk thread where you will find a screenshot and more details about the transaction i am trying to create. Maybe someone here might help as this requires deep understanding of Bitcoin Multisig, HD Key Derivations, OP_RETURN and Colored Coins.

The challenge is quite amazing and let me learn tons of things, but watching serialized data I think I am getting crazy, I can't get it done, please hAlp ! x:)

PS: <3 Bitcoin

I have solved my problem with a lot of debugging and help from the community on IRC irc.freenode.net #bitcoin-dev and also from people on the bitcointalk thread I started about this Topic.

I invite anyone having similar Copay Multisig Omni Colored Coins Recovery Issues to have a look at the bitcointalk thread here: https://bitcointalk.org/index.php?topic=2500531

The Problem is hereby solved, Details about how Copay derives keys can be found in the linked thread as well as more detail about what was implemented to apply the recovery (command line tool "omni:copay-recovery" on Github).


Can two private keys generate the same (public) Bitcoin address? I know that private key is generated randomly by wallet. Is it possible that wallet generate the same address which is used in Bitcoin?

In other words:
Given two private keys ka ≠ kb, is it possible that they both generate the same public Bitcoin address?

Yes, you can have two keys generate the same address.

There are 2^160 possible addresses, and 2^256 possible private keys, so each address corresponds to roughly 2^(256-160)=2^96 private keys. Any of these will generate the same address and thus be able to spend the money owned by that address. Since 2^160 is so large, however, it would take a near-eternity to find any collisions.

Whether two private keys can generate the same public key is another question. I think the answer is yes, but I am not sure on that. The public key in uncompressed form consists of two 256-bit numbers, which are X and Y coordinates on an elliptic curve. However, the compressed form is just the X coordinate plus a bit, from which you can calculate the whole public key. This means the space is (at most) 2^257. Unless there is a one-to-one mapping due to the mathematical properties of the cryptography used, each compressed public key corresponds to roughly 0.5 private keys (with the same distribution you'd get from picking a random number from 1 to 2^257, 2^256 times), so some private keys will collide, while others will not.

Actually finding any pair of different private keys that generate the same public key or address would be quite difficult. Either it would involve a huge amount of computation and/or luck, or it would be due to finding a serious vulnerability in the algorithm(s) used.


Clarification on the script P2SH, how is executed to Bitcoin core? This question is a continuation of the my post yesterday.

Today I have a question on P2SH execution so, an example of the script should be this

OP_0 <A Signature> <B Signature> OP_2 <Public key A> <Public key B>
<Public key C> OP_3 OP_CHECKMULTISIG
OP_HASH160 <ScriptSig Hash> OP_EQUAL

or if used the P2SH key should be is this (I think in this script left-hand something to convert the hash160 inside the P2SH key, right?)

OP_0 <A Signature> <B Signature> OP_2 <Public key A> <Public key B>
<Public key C> OP_3 OP_CHECKMULTISIG
OP_HASH160 <P2SH key> OP_EQUAL

Now if I have understood well the simulation of the execution is divided into two phases

The hash scriptSig is equal to hash inside the scriptPubKey

Simulation

Put on the scriptSig on the stack, so the stack now is <A sig> <B sig> <A pubkey> <B pubkey> <C pubkey>
Calculate the hash160 with the data inside the stack, so now the stack status is <scriptSig hash>
Put on the scriptSig hash expected, now the stack status is <hash scriptsig> <hash scriptsigexpected>
return the result of the operator OP_EQUAL (true or false)

the scriptSig will execute such as the script multi-signature

Simulation

put on the stack the scriptSig, the stack status is <A Signature> <B Signature>
push the public keys, that stack status is <A Signature> <B Signature> <Public key A> <Public key B> <Public key C>
apply the OP_CHECKMULTISIG operator and get the result

My questions are:

With the P2SH key, the execution is the same? if not, what is the form of the P2SH with the P2SH key?

Also, I read this post but I don't think contains this answer.

If my example script is wrong, I'm sorry to give me a corrections

Let's go over this step by step. Suppose say you want to lock some bitcoins in a 2-of-3 multi-sig.

Locking steps

Create a multi-sig script: OP_2 <pub_key 1> <pub_key2> <pub_key3> OP_3 OP_CHECKMULTISIG.
Hash the multi-sig script with HASH160 which gives you multi-sig_scripthash.
Base58Check the multi-sig_scripthash with version 0x05 giving you an address starting with 3....
The scriptPubKey will be OP_HASH160 <multi-sig_scripthash> OP_EQUAL.

Unlocking Steps

Your stack will start at <signatures><redeemScript>. The signature is OP_0 <sig_A> <sig_B> and redeemScript is OP_2 <pub_key 1> <pub_key2> <pub_key3> OP_3 OP_CHECKMULTISIG.
Since v0.3.7, Bitcoin Core executes the unlocking script first and looks at the resulting stack. So your <signatures> and <redeemScript> are evaluated together first. This would result in a multi-signature evaluation.
In normal cases the above step should just return 1 as signatures satisfy the redeemScript. But with P2SH there is a caveat added by BIP-16. Whenever you have a OP_HASH160 <hash> OP_EQUAL locking script, it serves as a P2SH identifier. So before the evaluation of <signatures> with <redeemScript> the redeemScript is copied from the stack to another one. Then the evaluation is done with what is on stack (<signatures><redeemScript> in our case). If successful, replace the current stack with the just redeemScript. Hence, instead of 1 you have <redeemScript> at the top of the stack.
You run OP_HASH160 on the redeemScript. Stack is now <hash160_of_redeemScript>
You push <expectedredeemScripthash>. Stack is now <hash160_of_redeemScript><expectedredeemScripthash>
You run OP_EQUAL resulting in evaluation and returning 1 to the top of the stack.


How should I send my bitcoins to my wallet from coinbase I just bought Bitcoins with Coinbase site, and as I read about bitcoin, everybody say I shouldn't let my bitcoins in Coinbase, as I don't have the private keys.

So I opened a bitGo Wallet, and try to send some bitcoins there, but If I want to send 10 euros, it cost me 31.22 euros to send it...

I don't understand it. Can anyone help me understand why ?

If you only have 10 euros in Bitcoin, it is currently not worth sending to your wallet. The current Bitcoin transaction fees average around $50 USD today. You can see the chart here. This is because there is an enormous amount of Bitcoin transaction, but only a few transactions can fit in the 1mb block.

If you had much more money, you should definitely send them in a wallet you own the private keys. Some exchanges like Mt. Gox closed and millions worth of Bitcoins were lost. There's a lot of fire right now in the Bitcoin community, so owning your coins is a good start.


Is it possible to edit Bitcoin Core to broadcast non-standard transactions? Is it possible to edit Bitcoin Core to remove the IsStandard function and broadcast non-standard transactions?

Also is there a version like this available already?

Is it possible to edit bitcoin core to remove the IsStandard function and broadcast non standard transactions?

Yes, it is definitely possible. But I suggest not to patch core client, but create a small separate program for this task.


Leading zeros and numbers of hashes before arriving to solution Had been reading a post written by Adam Back a couple years back (no pun intended) with regards to calculating bitcoin difficulty in bits (so we could arrive to the number of hashes roughly needed before a solution to a block is found).

The equation being log2(difficulty)+32.

Link: https://bitcointalk.org/index.php?topic=192886.0

From his post I also understood we could also find the difficulty in bits via the block hash in hex, i.e. each leading zero * 4, then check the next hex char with the following rule: >7=+0bits, >3=+1bit, >1=+2bits, 1=+3bits.

Question being:

What is the intuition to Adam's elaboration of >7=+0bits, >3=+1bit, >1=+2bits, 1=+3bits? Maybe there is something with regards to hex conversion that I need to catch up on?
With log2(difficulty)+32, we could arrive to a fractional bit (e.g. 54.8713). Would it be possible to derive the same fractional bit given the leading block hash values, or are we at best left with an approximation?

Thanks in advance!

Look at these numbers in binary.  A hex digit is 4 bits, so 7 in hex is 0111 binary, 3 is 0011, 1 is 0001.  You can see that 7 is the largest hex digit in which the most significant bit is 0; 3 is the largest hex digit in which the two most significant bits are 0; and so on.
Yes, you can get this same value by taking the log2 of the hash value and subtracting from 256 (which is the total number of bits in the hash).  Note that the number of leading zero bits of the hash (including "fractional bits") is required to be less than or equal to the target difficulty, but in general is much more likely to be less.


How to import bitcoins from one wallet to another wallet? I have purchased some fractional bitcoins from a website zebpay.com in india. I want to transfer those bitcoins to a wallet name jaxx so that i can buy ethereuem and other cryptocurrencies from jaxx wallet.

I can send bitcoin from zebpay to jaxx by pasting jaxx's bitcoin address in zebpay, but i have to pay transaction commission fee to zebpay for that. Is there any other way that i can just open my bitcoin in jaxx without giving any type of transaction fees?

Well you want to make a transaction from one wallet to another, and for someone to bother mine that transaction they should get paid that small fee.


What is wallet? How is it uniquely identified? What is wallet?
How is it uniquely identified?

What is a wallet?

Its software that stores your cryptocurrency, manages the keys to your wallet, and watches for transactions.

  How is it uniquely identified?

As jakob said above, it is made unique by the keys and addresses.

With the Bitcoin wallet addresses being 26-35 numerals and characters long, you can see how it is unique.

Hope this helped!


jsonRPCClient.php states its served a 401 error response When I execute my php file from the command line I get this:

PHP Warning:  fopen(http://...@127.0.0.1:8332/): failed to open stream: HTTP request failed! HTTP/1.0 401 Authorization Required
 in /home/brian/Desktop/VH2_apache2/host02/btc16/jsonRPCClient.php on line 132
PHP Fatal error:  Uncaught exception 'Exception' with message 'Unable to connect to http://b:a@127.0.0.1:8332/' in /home/brian/Desktop/VH2_apache2/host02/btc16/jsonRPCClient.php:140
Stack trace:
#0 /home/brian/Desktop/VH2_apache2/host02/btc16/index1.php(12): jsonRPCClient->__call('getinfo', Array)
#1 /home/brian/Desktop/VH2_apache2/host02/btc16/index1.php(12): jsonRPCClient->getinfo()
#2 {main}
  thrown in /home/brian/Desktop/VH2_apache2/host02/btc16/jsonRPCClient.php on line 140

My php file looks like this:

<?php
  require_once 'jsonRPCClient.php';

  $bitcoin = new jsonRPCClient('http://user:password@127.0.0.1:8332/',true);
  #$param = array(
  #'c418518d5ffccd947e377ab7e589f684d83e6df1af8f397cc11848ac8a78f0dd',
  #'1');

  #$return1 = $bitcoin->getrawtransaction('c418518d5ffccd947e377ab7e589f684d83e6df1af8f397cc11848ac8a78f0dd','1')

  echo "
\n";
  print_r($bitcoin->getinfo()); echo "\n";
  #print_r($return1['0']); echo "\n";
  #echo "Received: ".$bitcoin->getreceivedbylabel("Your Address")."\n";
  echo "
";
?>

My webpage with apache2 appears blank that uses the php file I made.
I am using the -txindex parameter when I launch bitcoind.

But I am able to use bitcoin-cli to interact with bitcoind

Iv'e used:
bitcoin-cli getrawtransaction c418518d5ffccd947e377ab7e589f684d83e6df1af8f397cc11848ac8a78f0dd 1

and:
bitcoin-cli getinfo

Also my bitcoin.conf looks like this:

rpcuser=user
rpcpassword=pass
txindex=1
server=1

Also note that I substituted the usernames and passwords to hide them.

My question is why can I use bitcoin-cli and get no error, but when I try to use the jsonRPCClient.php I get the error 401 Authorization Required and how do I fix the error?

I think this is related to this open issue.

https://github.com/bitcoin/bitcoin/issues/9661

I was running bitcoind on Ubuntu 16.

I had the similar issue when I had rpcuser and rpcpassword in the config file. All I got is 401 error when I called the jaon-rpc api.

I found a workaround by providing -rpcuser=REPLACED -rpcpassword=REPLACED when I launched the bitcoind.

Hope this is useful.

One more thing, instead of debug from your rpc client in PHP. Maybe try it with curl first. HTTP 401 clearly is an authentication issue, using curl is much easier for debugging.


Accidentally send BCH to my CashApp wallet! I accidentally had my Forex broker send BCH instead of BTC to my CashApp (I chose the wrong option for withdrawal) It ended up at a Bitcoin address which only lists the transaction meaninig on the "explorer" site). I don't have a wallet with Bitcoin.com .
How can I get my funds to my cashapp? I have been chasing Cashapp for 5 days now and they are not responding to my request properly. Is there a way? Or do I have to wait on cashapp to recover the funds and put it my cash app wallet? $1600 is a lot of money to lose!
Please someone help me.

The only one that can help you is CashApp, since you locked your funds to a key they control. AFAIK, CashApp uses segwit addresses, and BCH does not support segwit, so recovery would require a bunch of additional (likely manual) intervention. You'll have to negotiate with them.


What would happen to people's money if the Bitcoin project was discontinued? Here in the Arabic world the biggest problem with online trading is the absence of a good, secure, and flexible money transfer tool or solution. I think Bitcoin is a great solution for this. I have an idea to start a payment processing service using Bitcoin in the Arab world.

I need to know what would happen if the Bitcoin project was discontinued for any reason.
What would happen to people's money?

Bitcoin exists on a few levels. One is the protocol which evolves through a proposal process. Second is the Bitcoin client and bitcoind project which is an implementation of the protocol. Third is the currency managed by what's referred to as the Satoshi-blockchain. All of the above are available under free software licenses or are, at the very least, public information (in the case of the blockchain and protocol). It is therefore unlikely for any part of Bitcoin to be meaningfully discontinued.

Should everyone in the world stop using Bitcoin, the transactions and private keys to spend again would still exist so you could say the money will stay right where it is. The exchange rate wouldn't fare well but the Bitcoins would all just be there in deep freeze until someone started mining again. Once you know more, you'll see how unlikely any kind of discontinuation would be.


How does one document Bitcoin investments for tax and other legal issues? If Bitcoins are used as a store of value or investment vehicle, what legal documents should the investor require/keep? To date, no jurisdiction has special laws concerning cryptocurrencies, but investors may want to implemented best-practices to avoid later hassle.

Personally, I'd expect a receipt for any fiat-BTC transaction indicating

full name and address of the other party or exchange,
amount in BTC and fiat currency, and
any fees and taxes incurred.

Is this reasonable? Do larger exchanges, Mt.Gox or Bitcoin-central, issue a printable document with this information?

What legal documents to keep?  That's really a question for your accountant and/or attorney. One could reasonably expect to need about the same level of documentation as would be required for an investment in stamps or coins.

Most likely the exchanges comply with AML (Anti-Money-Laundering) statutes in their own jurisdictions, but the onus is probably on the individual to obtain documentation of all transactions.


Do bitcoin exchanges own the bitcoins they trade with? If I have a balance in USD with any exchange, and I placed an order to buy bitcoins, how does it work for the exchange? do they need to hold enough bitcoins to cover all the "buy" transactions and sell those bitcoins to me from their wallet? or, they will find someone on their platform who wants to sell that amount at that price and withdraw his bitcoins to my bitcoins?

Traditional Bitcoin exchanges hold their customers' funds, both Bitcoins and counter-currencies. So when a trade is actually made, the exchange just adjusts their own balance numbers. Prior to being able to buy Bitcoins, you must deposit some other currency into your account at the exchange. Prior to being able to sell Bitcoins, you must deposit Bitcoins into your account at the exchange.


How to build my own bitcoin system? I want to know whether there exists any software that can let people create their own private personal Bitcoin, and mine their own Bitcoin.

Or any other software that can let people issue their own digital currency.

Because Bitcoin is open source, the source code is the software for creating new crypto coins.  Depending on what you want out of a new coin, and why you want it, the things you modify will be different.  However, the simple recipe is this:

Fork Bitcoin Core
Change the hard-coded genesis block in the source code
Change the port number that the protocol runs on
Recompile
Start mining, and convince others to join

There are other things you can change as well, such as hashing algorithm, block time, difficulty increase frequency, etc.  It all depends on your goal.


What is "If ghash.io hits 51% people would just leave them?" referring to? I am watching video that explains original Bitcoin whitepaper by Satoshi Nakomoto.

I totally understand that as long as 51% of the CPU power is legitimate then using bitcoins is safe.

But then the person says, "If ghash.io hits 51% [hashing power], people would just leave them".

I listened to this part so many times, but don't understand what it means.

Does it mean if one entity has over 51% CPU power, the network would disconnect them?

No, the network wouldn't disconnect them.  There's no way for that to happen.

Recall that a pool is an association of miners who agree to share the proceeds of their mining; whenever anyone mines a block, the other members of the pool get a share.  But miners are free to leave at any time, simply by stopping mining blocks for that pool and joining another one, or switching to solo mining.

There is a general belief that it is not good for the Bitcoin community for any one miner or pool to control more than 50% of all mining capacity.  The speaker in that video believes that if ghash.io miners were to eventually constitute 51% of all mining power, then some of those miners would choose to leave the pool.  It could be argued that it would be in their self-interest to do so; they'll make approximately the same mining profits no matter which pool they use, but since their profits are in Bitcoin, they have an incentive to ensure that the currency stays stable and usable.

The sentence you quote might sound like a statement of fact, but it's really just the speaker's prediction as to what he thinks would happen in that situation.  He might be wrong, but many other people have made the same prediction.


Will a recursive sha256 run over all 2^256 inputs before a collision? Will a recursive sha256 run over all 2^256 inputs before a collision?
Here'a a python program showing my question - will this loop for 2^256 times - given endless memory or will it terminate before - if so when?
import hashlib

# start with 0
input = (0).to_bytes(32, byteorder="little", signed=False)

# dictionary to detect hash collisions - yes, this will eat up ALL memory
hit = {}

print ("first input:" + input.hex())

while (1):
    hash = hashlib.sha256(input).digest()

    # do we have a collision?
    assert (hash not in hit), "Collision!"

    # store current hash
    hit[hash]=1

    print ("Hash: " + hash.hex())

    # try again with the hash output as input
    input=hash

Short answer: you will "probably" find a collision after 2^128 attempts.
The concept you are looking for is called the birthday problem, explained also very well in this video by Professor Christoph Parr.
One of the approximations from The Birthday Problem is that given a random output space of size n, the probability of an input collision approaches 50% after approximately √n attempts. (2^256)^1/2 = 2^128


What is a good way for someone to purchase Mining Bonds? GLBSE is down, and so is PureMining, which used to give deterministic hash rate yields.

What are the alternatives? If someone wants to invest in Bitcoin mining, but doesn't want to own & operate a mining rig, what is a good way for him to do this?

You could use https://btct.co/ which is a virtual stock exchange similar to GLBSE.


What do you want from bitcoin faucets? I operate a very high potential bitcoin faucet. Currently it is the highest paying faucet (only available for mobile). I know faucets are considered passe, but many people still use them. Im curious, what features would you like the most from faucets?

Privacy and security are important to Bitcoin users, so I would like to see more faucets that do not:

Use Flash
Use JavaScript
Contain any advertisements
Require the collection of any personal data to use the faucet


What is the O(n^2) signature hashing problem and how does SegWit solves it? One of the many benefits of SegWit is that it solves the O(n^2) signature hashing problem. What exactly is the O(n^2) hashing problem and how segregating signatures to separate witness field solve it?

Moving signatures to a separate field does not actually solve it. However one of the things that segwit did was to redefine the message that is hashed and signed. This is specified in BIP 143.

Signature verification requires three things: the public key, the signature, and the message that was signed. In Bitcoin, the public key and the signature are provided by the person spending an output (or in some cases the public key is provided in the output itself). What is missing is the message. Instead of having a user provided message, the message is actually the spending transaction itself or some variation of it. How this message is constructed is known as the signature hashing algorithm.

For non-segwit signatures, the message is typically the entire spending transaction with all scriptSigs empty except for the input that the signature will belong to. That input will contain the scriptPubKey of the output being spent. The important thing to note here is that the message contains all of the prevouts that are specified. And every single signature signs a similar message, but still has all of the inputs in each one.

If you were to add another input, this not only adds another signature that must be done, but also it increases the size of the data that must be hashed for every single signature in the transaction. This means that if a transaction has n inputs each requiring 1 signature (thus n signatures required), for every signature, n inputs must be hashed. This is done n times so every input is hashed n*n = n^2 times. Thus it is quadratic.

However segwit defines a new signature hashing algorithm for segwit inputs. The message that is signed is not the spending transaction with modifications, rather it is a completely different structure which contains data pulled from the transaction.

From BIP 143, the data that is serialized and then hashed is:

     1. nVersion of the transaction (4-byte little endian)
     2. hashPrevouts (32-byte hash)
     3. hashSequence (32-byte hash)
     4. outpoint (32-byte hash + 4-byte little endian)
     5. scriptCode of the input (serialized as scripts inside CTxOuts)
     6. value of the output spent by this input (8-byte little endian)
     7. nSequence of the input (4-byte little endian)
     8. hashOutputs (32-byte hash)
     9. nLocktime of the transaction (4-byte little endian)
    10. sighash type of the signature (4-byte little endian)

The important thing to see here is that this by itself does not increase in size when more inputs are added. Almost everything has a fixed size, with the only thing having variable size being the scriptCode.

Now you may notice that this does contain hashPrevouts and hashSequence which are the hash of the prevouts and the hash of all of the sequence numbers, respectively. The amount of data that is hashed for these hashes will grow as more inputs are added. If implemented naively, signing and verifying segwit inputs would still be quadratic.

But by specifying the hash of the prevouts and the hash of the sequence numbers separately instead of interspersed throughout the message as non-segwit does, these hashes can be precomputed once and then reused for every signing and verifying operation in a transaction. Thus this allows for an optimization which makes this linear.

At signing or verifying time, the signer or verifier can first compute hashPrevouts, hashSequence, and hashOutputs once. These values remain the same for all inputs. Then for every signature, they compute the sighash which does not end up re-hashing the majority of the data and does not typically change in size from input to input. Thus since the amount of data being hashed really only changes when the transaction gains an input, and it only changes by a relatively fixed amount, segwit sighashing is linear.


Lightning Network LND - Retrieve payment by hash How do I get an outgoing Payment by paymentHash using LND REST API? I know that GET /v1/payments returns all payments, but I would like to get one in particular, not all as there may be thousands. Thanks.

I don't think you can look up payments by their paymentHash but you can look up invoices which contain a lot of the same information using a paymentHash: https://api.lightning.community/rest/index.html#v1-invoice


What is the easiest way to programmatically obtain the current USD-BTC spot price? E.g., if I wanted to create a cron script that would grab the latest spot price every hour and store it in a local file or database, what would be the place to "scrape" that information from?

(Actually writing the script is not the problem, in my case.)

You could use the JSON encoded ticker data available from MtGox at: https://mtgox.com/api/0/data/ticker.php

Just use whatever your language's equivalent to cURL or wGet is and parse as appropriate.


How can I determine the reason for a failed routing on c-lightning I am running a c-lightning node (v0.8.2). I am routing a payment every few days. However, I realized that dozens of payments every day fail, many of them fail locally (I see the status 'local_failed' on RTL). Apparently, this is due to insufficient funds in the channel that was tried to route out. I tried to figure out how I can become a better hub and accommodate more of those of those payments.
My investigations where not really prosperous, as I could not determine the next channel that caused the payment to fail. I tried to inspect the logs with lightning-cli listforwards. But it does not list the out_channel.
Any ideas or recommendations how I can improve my job as a router, i.e. finding out which channels to improve / balance?
Kind regards

I believe if you c-lightning implementation does not tell you the out_channel it means that onion was sent to you. The local failure can be explained by you not knowing the payment hash. Most likely people send out onions with random payment hashes so that they can probe other peoples channels. You can set log level debug and check your logfile to confirm if it was missing preimages.
In general you cannot expect to successfully settle every forwarding. Even if you have been able to forward it there might be remote errors. In order to increase your reliability as a routing node you can do two thinks.

make sure that your channels have enough balance on either side so that they can support incoming or outgoing payments
activate JIT routing. In case your node cannot forward a payment along a channel it will not send an error back but try to rebalance your channels to provide yourself liquidity on the requested channel

Both options will probably cost you money to begin with and remember: even if - with these measures - you have been able to forward the payment it does not mean that you get paid because the next hops could yield local errors


How to derive public child keys from public parent keys with bip39-libs.js? I red this doc: https://howieliux.github.io/assets/others/Mastering_bitcoin/Mastering_Bitcoin.html
and found:

As mentioned previously, a very useful characteristic of HD wallets is the ability to derive public child keys from public parent keys, without having the private keys. This gives us two ways to derive a child public key: either from the child private key, or directly from the parent public key.

An extended public key can be used, therefore, to derive all of the public keys (and only the public keys) in that branch of the HD wallet structure.

Which method of bip39-lib.js I need to call to derive address from public parent keys? I haven't found any reference in the doc.
https://github.com/bitcoinjs/bip39

bip39-lib.js works along with bip32-lib.js AND bitcoinjs-lib.
BIP39 is strictly regarding the mnemonic phrase and HD seed.
In order to derive child keys from an HD seed you'll also need to use BIP32.
BUT... BIP32 has no concept of addresses either so ultimately you'll also need bitcoinjs-lib.
In other words you need to use all three libraries to go from mnemonic to a usable address.


Seed for bitcoin-core qt I have a bitcoin core -qt Wallet (on linux). Tell me, can I encrypt it?
 For example, there is the electrum wallet!
It has words for deciphering.
For example, i installed the electrum and the  phrase was generated.
"I'm a fan of the  https://bitcoin.stackexchange.com"
Knowing this phrase you can install electrum on any computer,  and when you enter this phrase you get access to your balance and btc.
But what about bitcoin-core-qt? because it is characterized by the fact that the it must download all the transaction history after installing.(~200gb).
Is there such a "magic phrase:" for this wallet bitcoin-qt?
This is a very useful option if you have lost access to the server or host where you hadthis wallet

You can export private keys from Electrum and BitcoinCore. You can export private keys from Electrum as "words" format (There's a website to convert it to private key(s): https://iancoleman.github.io/bip39/), while Core doesn't have this feature. See the steps in question Using dumpprivkey to make a paper backup to use dumpprivkey in Core to export the private key.