Being offline: when do other nodes close channels? If my lightning node goes offline, how long will it take until my counterparty nodes close the channels they co-own with me?

This is obviously up to the counterparty nodes, as they can choose individually when they want to close channels, but what are the default settings for the main implementations?

A Lightning Channel does not have any requirement as to when to close the channel, as specified by BOLT. It is entirely decided by the user, and the implementation. For the case of lnd, whenever the user wants to close the channel, he will call
closechannel trying first to perform a cooperative close, unless specified otherwise:

Name:     "closechannel",
Category: "Channels",
Usage:    "Close an existing channel.",
Description: `
Close an existing channel. The channel can be closed either cooperatively,
or unilaterally (--force).

A unilateral channel closure means that the latest commitment
transaction will be broadcast to the network. As a result, any settled
funds will be time locked for a few blocks before they can be spent.

In the case of a cooperative closure, One can manually set the fee to
be used for the closing transaction via either the --conf_target or
--sat_per_byte arguments. This will be the starting value used during
fee negotiation. This is optional.

To view which funding_txids/output_indexes can be used for a channel close,
see the channel_point values within the listchannels command output.
The format for a channel_point is 'funding_txid:output_index'.`,

Even when calling closeAllChannels , being that counterparty node offline, the shell prompts to the user before unilaterally closing the channel:

        // If the channel is inactive, we'll attempt to
        // unilaterally close the channel, so we should prompt
        // the user for confirmation beforehand.
        if !channel.GetActive() {
            msg := fmt.Sprintf("Unilaterally close channel "+
                "with node %s and channel point %s? "+
                "The closing transaction will need %d "+
                "confirmations before the funds can be "+
                "spent. (yes/no): ", channel.RemotePubkey,
                channel.ChannelPoint, channel.CsvDelay)


How can I extract my bitcoin public address from my bitcoin private key using PHP for Nodejs? I'm building out an application, but I need to verify if the bitcoin private keys have a positive balance. Is there a PHP script or some type of service that I can pass in a private key and outputs all the bitcoin public keys in 1... and 3... formats? From there I'll just pass those addresses to a block explorer.

Private Key is a 32 bytes data
Apply ECDSA or Elliptic Curve Digital Signature Algorithm to the private key.
The above step dervies the public key,.
(Legacy)Now append 0x04 to the start of the public key.
(Current Practise)  Take X from derived public key. Now add  byte 0x03 if the last byte of Y is odd or 0x02 if the last byte is even.
Now, apply SHA-256 to the above public key, and then apply RIPEMD-160.
Add Network Byte at the start of key:
Mainnet : 0x00
Testnet: 0x6f
Calculate the checksum: Apply SHA-256 twice and then take starting 4 bytes of the result.
Finally to get the address concatenate the key from Step7 and checksum.


How to get value of incoming transactions from Blockchain.info API I'm looking at the blockchain.info API and I'm having a difficult time finding the value of incoming transactions. That and the number of incoming transactions are the only things I'm interested in.

As an example here: https://blockchain.info/rawaddr/15wsV4TYvGPrJnhoyCed6kWcNUuSo5ykRi

or here: https://blockexplorer.com/api/txs/?address=15wsV4TYvGPrJnhoyCed6kWcNUuSo5ykRi

It lists both incoming and ougoing transactions, and with transactions with several inputs, they are all listed individually. So I can't just have a script search for "value" which was my first idea. Is there a better way to do it?

Check to see how many outputs total for the tx using .length and then do a for loop and run through every output for each transaction. Use an if statement to check if that particular output has your desired address in the 'addr' field. If it does match then print that value to the screen.

I made a fiddle that I think should work, I didn't test it though... http://jsfiddle.net/nmgus1fa/

var btcs = new WebSocket('wss://ws.blockchain.info/inv');

btcs.onopen = function()
{
btcs.send( JSON.stringify( {"op":"addr_sub", "addr":"15wsV4TYvGPrJnhoyCed6kWcNUuSo5ykRi"} ) );
};

btcs.onmessage = function(onmsg)
{
  var response = JSON.parse(onmsg.data);
  var getOuts = response.x.out;
  var countOuts = getOuts.length;
  for(i = 0; i < countOuts; i++)
  {
    //check every output to see if it matches specified address
    var outAdd = response.x.out[i].addr;
    var specAdd = "15wsV4TYvGPrJnhoyCed6kWcNUuSo5ykRi";
       if (outAdd == specAdd )
       {
       var amount = response.x.out[i].value;
       var calAmount = amount / 100000000;
       $('#messages').prepend("<p>" + calAmount + "</p>");
       }
  }
}


Why does Bitcoin use two rounds of SHA256? Each blocked is hashed twice. Why isn't one application of SHA256 enough?

From Zooko's answer provided in Crypto StackExchange:

  SHA-256(SHA-256(x)) was proposed by Ferguson and Schneier in their
  excellent book "Practical Cryptography" (later updated by Ferguson,
  Schneier, and Kohno and renamed "Cryptography Engineering") as a way
  to make SHA-256 invulnerable to "length-extension" attack. They called
  it "SHA-256d".


When is the bitcoin reward provided to the miner? The rewards are provided to the miner if the miner finds a valid block. So Is the rewards(new bitcoin 12.5 + transaction reward) provided to the miner as soon as the new block is found by miner or reward is provided only when validated by other miners?

If reward is provided as soon as block is found, what happens in case of fork created. ?

The reward is just a transaction which payers the miner, called a Coinbase transaction. Thus it only pays the miner if that transaction is in the accepted blockchain, i.e. if it was invalid or if another block was found first that block would not be included so the miner would not be paid. In fact coinbase transactions only mature after 100 blocks have been mined on top of them, to avoid miners spending coins straight away and then a reorg happens and the block becomes a fork


How do I detect a double-spend in real-time, like Bitpay? By Bitpay to pay only take 10 seconds to complete.

How do they do it?

If you want to detect a double spend, you need to listen to all transactions broadcasted to the network, and write some code to detect if the address that sent you Bitcoins also sends a transaction to another address (until 1+ confirmations).

To answer your other question, Bitpay cannot guarantee the transactions not to be double spent. In an effort to promote usage of Bitcoin as a payment solution, they take on the risk of a potential double spend, and if one happens, they eat the balance (no risk to the merchant). This is a vanishingly small occurrence in practice, so any fees (or venture capital) paid to them more than cover that possibility.


How to run dns seeder? Are there any tutorials on how to setup dnsseeder for a new altcoin. I am struggling with this for past couple of days.

I am modifying dogecoin seeder and i just cant setup on my server. My coin daemon is running on the same AWS server. I did open the ports 53 and for daemon and rpc.  I only have one ip running both daemon and dnsseed. My understanding is that the more nodes connect to dnsseed, it will auto add the nodes to its dns list.

i have set this on godaddy records

dnsseed.example.com -> IP

and IP is running dnsseeder.

Here i run

./dnsseed -h dnsseed.example.com -n IP

and i see this

Supporting whitelisted filters: 0x1,0x5,0x9,0xd
No e-mail address set. Please use -m.

When i check whether dnsseed is running,

netstat -anp

I could not find any process listening on port 53.

How do i check if dnsseed is running? Thank you for your time as i find this topic confusing.

I realize this question is a couple years old, but a proper tutorial has never been written until now. The tutorial is somewhat large, so I won't re-post it here, but I wrote a step-by-step guide for setting up a DNS seeder that you can find permanently hosted here: https://github.com/team-exor/generic-seeder/blob/master/SETUP.md.

The instructions are written for a clone of the original bitcoin-seeder called the generic-seeder, which is a modified clone of the bitcoin-seeder that makes it easier to set up a DNS seed for virtually any alt coin by using a config file.

As far as why your seeder isn't working, part of it seems to be because you may not have created the proper DNS records. You say that you created:

dnsseed.example.com -> IP

but it should look more like this:

dnsseed.example.com -> vps.example.com -> IP

vps.example.com: "A" record that points to your server IP address
dnsseed.example.com: NS record that points to your "A" record (vps.example.com)

Once your two DNS entries are created, you can run the seeder app like this:

./dnsseed -h dnsseed.example.com -n vps.example.com -m test@example.com

test@example.com: this can be any email address and is only used to serve SOA record data from the local DNS server that the DNS seeder app is creating.

Full disclosure if it wasn't already obvious: I am the author of the generic-seeder.


Where is the bitcoin wedding transaction? There has been some buzz in the news about a wedding that put a statement in the blockchain declaring their message. Here is one source that reported on the news.

Can anyone provide a link to the actual transaction in a block explorer such as blockchain.info?

I'm looking for a link to an actual transaction in a block chain explorer that has the ASCII text in it that was described in the article, or an explanation of why one doesn't exist.

I think I found it, although it doesn't have the text as advertised.

History was made today when David Mondrus and Joyce Bayo tied the knot on the blockchain. The transaction took place through Eric Grill’s CoinOutlet ATM at Disney World. The couple ‘burned’ 0.1 Bitcoin, committing their marriage to the network. Jeffrey Tucker officiated the wedding with one of the most moving speeches you’ll ever hear.
Here is the historic transaction ID: https://blockchain.info/tx/ad2e849f1de6d48dce1b671fe9b4ef6aee9c50710daccce3c0195087233ef2f6

Looking at the transaction history, it appears that they repeatedly made transactions until they spent 0.1 BTC. Ick.


What advantages and disadvantages does Ethereum have over Bitcoin? What advantages and disadvantages does Ethereum have over Bitcoin? What can you do with Ethereum that you simply cannot with Bitcoin? What price do you pay for these additional functionalities?

I'll answer the middle question from the White Paper. Bitcoin can allow simple scripting and a weak version of smart contracts. The scripting that you can do has these limitations (quoting from the white paper, where UTXO means "unspent transaction outputs")

  Lack of Turing-completeness - that is to say, while there is a large subset of computation that the Bitcoin scripting language
  supports, it does not nearly support everything. The main category
  that is missing is loops. This is done to avoid infinite loops during
  transaction verification; theoretically it is a surmountable obstacle
  for script programmers, since any loop can be simulated by simply
  repeating the underlying code many times with an if statement, but it
  does lead to scripts that are very space-inefficient. For example,
  implementing an alternative elliptic curve signature algorithm would
  likely require 256 repeated multiplication rounds all individually
  included in the code.

  Value-blindness - there is no way for a UTXO script to provide fine-grained control over the amount that can be withdrawn. For
  example, one powerful use case of an oracle contract would be a
  hedging contract, where A and B put in $1000 worth of BTC and after 30
  days the script sends $1000 worth of BTC to A and the rest to B. This
  would require an oracle to determine the value of 1 BTC in USD, but
  even then it is a massive improvement in terms of trust and
  infrastructure requirement over the fully centralized solutions that
  are available now. However, because UTXO are all-or-nothing, the only
  way to achieve this is through the very inefficient hack of having
  many UTXO of varying denominations (eg. one UTXO of 2k for every k up
  to 30) and having O pick which UTXO to send to A and which to B.

  Lack of state - UTXO can either be spent or unspent; there is no opportunity for multi-stage contracts or scripts which keep any other
  internal state beyond that. This makes it hard to make multi-stage
  options contracts, decentralized exchange offers or two-stage
  cryptographic commitment protocols (necessary for secure computational
  bounties). It also means that UTXO can only be used to build simple,
  one-off contracts and not more complex "stateful" contracts such as
  decentralized organizations, and makes meta-protocols difficult to
  implement. Binary state combined with value-blindness also mean that
  another important application, withdrawal limits, is impossible.

  Blockchain-blindness - UTXO are blind to blockchain data such as the nonce, the timestamp and previous block hash. This severely limits
  applications in gambling, and several other categories, by depriving
  the scripting language of a potentially valuable source of randomness.

Ethereum is designed for contracts and in fact implements a Turing-complete virtual machine on the blockchain.


Do I need to hire miners if I don't know how to mine? I am studying Blockchain technology and found out that miners are the ones that provide Proof of Work and verify the transactions on the Blockchain. If I were to build an app that would involve the release of verified documents, would the verifying authorities need to have hired miners to be able to provide verification or are verification and mining 2 separate processes?

Mining and verification are different. Miners verify blocks, and verify what they're mining on before they mine it. Users also verify blocks, but do not mine them.

Mining and verification solve different problems. Verification makes sure that a transaction doesn't spend more than a person has. In this context, verification doesn't mean looking at official documents. Mining is used to determine what order two transactions happened in.


Won't ripples run out in time? If there are a finite number of ripples, and ripple transaction fees get destroyed with each transaction, then wont they eventually run out?

The fee is variable over time.  As the supply dwindles, the relative value of each XRP will be higher, so the transaction fee will get lower.  They'll never really run out.

https://ripple.com/wiki/Transaction_Fee


How to get the list of transactions that has gone into an address with the amount and date? How to get the list of transactions that has deposited funds in an address, including information about the amount that has been deposited (sent towards my address not sent away from it), and the date when the transaction occurred.

For example here is address A (my address) :

TX 1)  from address B , 2   bitcoins , 2014 1 january 12:12 pm
TX 2)  from address C , 1   bitcoins , 2014 2 january 7:51 am
TX 3)  from address D , 4   bitcoins , 2014 5 january 3:22 am
TX 4)  from address E , 0.5 bitcoins , 2014 6 january 1:42 pm

Also, I want it to use an API that is online, so that I don't need to download the whole block chain.

Preferably blockchain.info API or blockexporer.com API would be nice.

A link to a tutorial would also be helpful. I have an specific application in mind that needs this info for an address.

You could achieve this by getting the transactions an address has been involved in and filtering on the outputs with that address hash.
We've just released our own free API called Blocktrail and provide SDKs for PHP, Python and NodeJS which make getting blockchain data trivial.
Assuming PHP you could do the following:

Initialise the Blocktrail SDK
use \Blocktrail\SDK\BlocktrailSDK;
$client = new BlocktrailSDK("MY_APIKEY", "MY_APISECRET", "BTC", false);

Get the address' transactions
$address = "1A4NfSJDzxzKgRrgfjxSAQ8hCPJJWKcmzX";
$page = 1;
$limit = 500;
$sortDir = "desc";
$transactions = $client->addressTransactions($address, $page, $limit, $sortDir);

For each transaction get the amount sent to this address from the outputs
$deposits = array();
foreach($transactions as $tx) {
    foreach($tx['outputs'] as $txout) {
      if($txout['address'] == $address) {
        $deposits[] = $txout['value'];
      }
    }
}

Tutorials and Examples
We'll be creating in-depth tutorials really soon, but for now you can check the API documentation for code examples and descriptions of the data returned.
There is also an example project on github: A Simple Block Explorer


Is there a way to buy bitcoin immediately? I want to use PHP to write a script to buy bitcoins and my bitcoin balance will be updated immediately (i'm NOT in US).

For example, I use my credit cart to purchase bitcoins. less than 1 min later, I can see my new bitcoins in my address.

As I know, normally, it will take few hours / days to get bitcoin from some bitcoin sellers. It is not safe to get bitcoin immediately because banks allow charge back.

So is there a safe, automatic and immediate way to get / buy bitcoins?

Coinbase offers instant buys, you need to enter your credit card info and go through the verification process, but it takes less than a minute to update my balance.  The max amount for instant buy/sell is 1000usd/day.


Why do merchants accept Bitcoin as valid currency? I suppose one could ask the same question about any form of currency, but I am curious how bitcoin became an accepted currency with no government backing it.

I think the best reasons right now are:

Marketing: being the first to do something attract a lot of interest and media.
No chargebacks: Bitcoins does not allow any kind of chargeback, which is not true for main payment systems (Paypal, Stripe, Credit Card).
Lower fees or no fees, just depends on how you use it.
Investment some people wants to hoard some BTCs and offering their services in BTC is the easiest way to get some.


need help in recovering my BCH i mistakenly transferred 2.0 BCH from a BTC(blockchain.info) address to a Segwit address(Greenaddress)... I need help in recovering my BCH. I'm will to part with 20% if you can help retrieve it. I'm not really an IT inclined person so i'm ready to send whatever infos needed in retrieving to whoever is willing to help.

You will not be able to do that easily even if you have the private key Since bitcoin cash doesn't support Segwit, so you have to edit source code and mine that transaction by yourself.

Helpful links:

Bitcoin Cash SegWit hack

Recovering BCH sent to Segwit addresses


As an Ardor bundler, can you filter out which transactions you wish to bundle based on a specific criteria? In the Ardor blockchain, as a bundler you currently bundle all child chain transactions by the set fees your willing to accept on a child chain. But how can you bundle only transactions by a user that holds a specific asset or have a specific account property set under their account?

I want to be able to bundle all transactions with a fee of 0 only if that specific user holds my asset or that I have set an account property on their account. How can this be done?

You can specify a bundler filter using the nxt.bundlingFilter property.  This is a Java class that is loaded by the bundler and will be called for each transaction to be processed.  The filter returns 'true' if the transaction should be bundled and 'false' otherwise.  Note that the filter executes as part of the server and thus can use any of the internal public methods to decide whether a transaction should be included.

Update: Ardor 2.0.13 now provides a custom bundler filter that allows you to select transactions based on an account property. See https://nxtforum.org/nrs-releases/ardor-v2-0-13/ for more information.


My Bitcoin transaction is lost When I enter the deposit address of where I sent my bitcoin, the Blockchain says that the transaction is "Spent" What does this mean? It's been like this for 3-days now. Please help!

the Blockchain says that the transaction is "Spent" What does this mean?

It means that the outputs of the transaction have been used as inputs in a further transaction.

Which, in simpler terms, means that the recipient has subsequently spent the received money.

If you were the recipient, have a conventional (non-custodial) wallet and didn't knowingly spend the money it probably means you have lost control of your wallet as a result of hacking or social engineering or some other hostile act by a third party. For example where an online "friend" helped set up your wallet or where you clicked an "update" notice in an old Electrum wallet.


Is there bitcoin algorithms flowcharts or any other diagrams available? To make those who not familiar with C++ to understand the algorithms.

Forum user and Armory client developer etotheipi put together a few nice images covering some aspects of the Bitcoin protocol, mostly related to transaction construction and verification; see this forum thread.

Other than that, though, most of the documentation is in code only. If you're comfortable with another language, you could try looking at BitcoinJ, a Java implementation of Bitcoin (client node functionality only), BitcoinSharp, a C# port of BitcoinJ, CBitcoin, a C99 Bitcoin library (also partial), Bitcoin-Ruby, BitcoinJS, and/or PyWallet.

In the end, though, currently the only complete reference implementation of Bitcoin is the original C++ code, so biting the bullet might be the only option.


Can a Bitcoin wallet be identified as belonging to an exchange? Ethereum wallets can be associated with Exchanges (e.g. Etherscan.io will tell you if an address is a Poloniex one).

Is this possible for Bitcoin addresses?

Yes, in theory is possible to guess the ownership of an address to an Exchange.

Notice that I said in theory and I also mentioned that it's a guess. That's because per design each address is anonymous. However, since the blockchain is public, you can analyze the type and amount of transactions getting in and out a specific address and make assumptions based on patterns.

An exchange has generally a large amount of transactions. If they use a finite amount of addresses, eventually transactions will reuse existing addresses.

If you provide a tool or a way for people to publicly share/associate specific addresses with Exchanges, then eventually you will build an archive of matches. I believe this is what Etherscan does.


The documentation is incorrect. confirmations, time and blocktime are not fields in the output of the rest API. You aren't doing anything wrong; those fields don't exist.


How is time encoded (BIP65) in scripts? BIP65 has several examples where OP_CHECKLOCKTIMEVERIFY interprets the time value underneath it in the stack, for example:

<expiry time> CHECKLOCKTIMEVERIFY DROP DUP HASH160 <pubKeyHash> EQUALVERIFY CHECKSIG

How is the time value encoded in this script? It's a CScriptNum object, but I'm unsure if that equates to little endian bytes

From the bitcoin wiki:

  The stacks hold byte vectors. When used as numbers, byte vectors are interpreted as little-endian variable-length integers with the most significant bit determining the sign of the integer. Thus 0x81 represents -1. 0x80 is another representation of zero (so called negative 0). Positive 0 is represented by a null-length vector. Byte vectors are interpreted as Booleans where False is represented by any representation of zero, and True is represented by any representation of non-zero.

What this doesn't say is how more than one byte is combined into an integer. For example, to represent the integer 278, the stack would have:

0x02 0x1601

And to represent the integer -278:

0x02 0x1681

The most significant byte (0x01) was just XORed with (0x80) to change the sign to negative.

Now that we know how script integers are encoded, we just have to understand how they are interpreted. This is shown in the BIP65 code:

// There are two types of nLockTime: lock-by-blockheight
// and lock-by-blocktime, distinguished by whether
// nLockTime < LOCKTIME_THRESHOLD.
//
// We want to compare apples to apples, so fail the script
// unless the type of nLockTime being tested is the same as
// the nLockTime in the transaction.
if (!(
      (txTo.nLockTime <  LOCKTIME_THRESHOLD && nLockTime <  LOCKTIME_THRESHOLD) ||
      (txTo.nLockTime >= LOCKTIME_THRESHOLD && nLockTime >= LOCKTIME_THRESHOLD)
     ))
    return false;

Where LOCKTIME_THRESHOLD is the UTC time:

LOCKTIME_THRESHOLD = 500000000; // Tue Nov  5 00:53:20 1985 UTC

So, basically, you can set the time that OP_CLTV will verify against in the scriptPubKey. If it is below LOCKTIME_THRESHOLD, then it is compared based on block number of the block containing the transaction. If it is above LOCKTIME_THRESHOLD, then it is compared based on block time of the block containing the transaction. Note that this relies on the consensus rule that transactions cannot be included into a block with a lock-time (nLockTime) in the future.


How easy is finding related vanity addresses? Is it easy to find out related vanity address '1googlex' if we already know '1google' vanity address pair, than through usual vanitygen iteration process? if yes, can this be extended further, like, '1googlexx', without exponentially increasing difficulty?

Zero. They are completely unrelated.

And if you think about that, it is quite obvious... otherwise it would be very easy to steal known addresses: you would just have to find a similar one.


What's the maximum possible utxo growth rate now? Can that be turned into an attack? Now bitcoin unspent transaction output growth rate (not total size) can be, 260k utxo/day (3×60×60×24). With 8MB blocks, that's 2.8 million.

Single 1 bitcoin output can be split into 1000 x 1 mBTC outputs, within 100 minutes (10 blocks). Then, those 1000 outputs can be moved individually, as required..

Does this kind of utxo bloat attack work? Anything wrong with my calculations?

There is no limit on the size of the UTXO other than the block size as you've described, but your reasoning isn't correct. There is no minimum size of a transaction output, nor maximum number of outputs per transaction. The bulk is limited by the Bitcoin block size of 1MB, or about 50GB per year total additions if the only thing being added was spam outputs.

Volume of outputs is another matter entirely. The smallest possible output is 0 BTC (8 bytes), 0 length (1 byte), null scriptPubKey. If we make a maximum sized transaction (1MB) of these it will have somewhere in realm of 110,000 outputs, with some loss included for inputs and structure. 6 blocks per hour, 24 hours gives 15.8M outputs per day. Note this does not include any indexing overhead, which would be non-negligible for this many entries.

Some of the proposed solutions include expiring unspent outputs after a particular amount of time, or significantly moving the cost towards creation and incentivising removal of entries. Changes in core operation like this however aren't fast to implement or uncontroversial, and are not a complete solution against an attacker.

It's one of the drawbacks of the system as implemented and something that needs to be seriously considered before making alterations which could make the problem even worse.  Lots of things become unpalatable in Bitcoin when you change the constants, this is one which is already pretty terrible to begin with.


Bitcoin qt won't update I installed Bitcoin Qt, and it began updating the blocks extremely slowly. After several hours, I restarted the program, thinking it might speed it up. Now, it appears completely stagnant; the icon in the bottom right is now two monitors and an X, rather than the previous icons which denoted the rate of the update.

How can I get it to update the blocks? I'm waiting on some transferred funds, and this is starting to be a real hassle.

It is going to be slow when you first install. I'd recommend downloading the bootstrap.dat file. If there is an X and two monitors, you're either not connected to the internet or something like your firewall are preventing you from updating it.


I've downloaded a Bitcoin Core, why it's recommended to use a new address for a new transaction? I'm a bit new to Bitcoin.

I just downloaded a Bitcoin wallet "bitcoin core". And I have downloaded all the nodes (a lot of data, I believe it's the complete one).

When I click the "Receive", I can request money.

But I noticed that every request, I'm assigned a different address. Then I noticed that it's an official recommendation by the software.

Is there any reason for that? How many addresses can I have? What do I need to be prepared if I have a lot of address? (for instance, to backup something)

Refreshing address with every transaction keeps your identity more intact as It can't be refereed with any other transaction as the address is new.And it is good for future perspective as when coins are sent to an address, they're sent to RIPEMD-160 of sha-256 of the public key. In order to spend it, you reveal the public key, and then sign with the corresponding private key. Thus, if at some point in the future someone discovered a weakness in ECDSA that allows deriving the private key from the public key.It will be safe as you address is changing so the new public key will not be in the blockchain and it will be not vulnerable.


How does change work in a bitcoin transaction? It seems that when you send a bitcoin transaction, all the coins in the sending address are spent in that transaction, divided into the amount that you intended to send, and "change", which goes back to you, but at another (newly created) receiving address.

That makes it a bit difficult to track your balance on block explorer (especially since the new receiving address does not seem to be displayed in the Bitcoin client anywhere).

Does it have it have to work like this, or is this a specific implementation detail of the client software?

Also, do you have to wait for change to be confirmed before you can spend it again?

First, let's clarify the difference between accounts and addresses.

"Accounts" are used for the convenience of people to track their funds. This is primarily used to track the source of funds. Since this is just for your tracking, you can move Bitcoins from one account to another just by moving a number from one column to another. No transactions are needed. (This is like when you know you owe your son $25 for allowance, and you have $200 budgeted for groceries.)

"Addresses" are used to receive Bitcoins in transactions. The coins are sent to an address. The client associates each address with an account and adds received funds to that account. This is simply done for convenience to allow people to track indirectly which address funds were sent to. But you can have any number of addresses associated with the same account.

Change comes from the way Bitcoins are spent. To spend a certain number of Bitcoins, you must pull in Bitcoins from transaction outputs to accounts you control. Note that in the spending part, it doesn't matter what address this is or what account that address is associated with. When you spend Bitcoins from a particular account, that just means you debit that account for the amount you send. It doesn't mean the funds come from addresses associated with that account. Remember, the association between addresses and accounts is for receiving only, not sending. (Like when you spend money on groceries, it's not like you have specific bills for groceries. You just have an amount budgeted.)

So when you pull in transaction outputs, you form a pile of Bitcoins big enough for the number you are trying to send. Usually, it won't be exact since you must claim an entire output. So the excess forms the 'change'.

Since there is no address associated with sending Bitcoins, there is no particular address the change should be sent to. So, to preserve anonymity, the client creates a new one just to receive the change from this transaction. Since this address isn't really associated with an account and shouldn't be used to receive any more Bitcoins (because that would senselessly tell people the same recipient got the coins as got this change) the client does not display it.

Because the client manages coins in a particular way, it doesn't make sense to try to view coins it is managing with any kind of explorer. It's specifically trying to obscure the fact that all the coins are related. Those kinds of services are intended to monitor recieved funds, not managed funds.


bitcoind getrawtransaction returning numbers and letters I’m not sure how to get this data in a format I can use and consume? I was expecting some kind of JSON structure, hopefully there’s a way to get this info easily?


How is the Ripple cilent bootstrapped? When the Ripple client starts, it connects to some initial servers.

How does its find the initial list of servers it should connect to?
Is the initial list hardcoded?

The client is configured with the server or servers it should connect to in a configuration stored on the web server that serves the client and retrieved by the client using HTTP. In the current version of the client, this can be changed from the Options screen. I believe this change is currently not saved but there are plans to store a list of servers in the wallet.


How much bitcoin can be mined with intel core i5 pc with external graphic card? I know ant miner is required to earn some cash, but am curious to know that how much bitcoin can be mined per day with a pc if it has the configuration like :

processor= Intel Core i5 6600K 3.50GHz 6th Gen. Processor

motherboard= MSI B150M Mortar DDR4 6th Gen. LGA1151 Socket Mainboard

ram= Twinmos 8GB DDR4 2400 BUS

graphics card= MSI GTX 950 2GB

-Thanks.

Less than the money that it will cost to you for sure.

I think It would take you a bunch of nights to get the minimun to get paid by the mining pool so you could even earn 0 Bitcoins.


Reason for Mininig a block without transaction I came to know that there are people who mine a new block without any transaction. I understand that this is just to get the block reward.

Reference   https://www.blockchain.com/btc/block/0000000000000000004e9b0f16eccf2462eaea0023e842e9c5f17ea6d404b74c

Question .

What is the problem if they include the transactions in it.
Why does the Bitcoin client protocol allow empty blocks?

Generally, if you'd like to know why a miner mined an empty block, you would have to ask them. They could do so for any reason, really.

For a more specific example of a technical example of why a miner may mine an empty block:

As a miner, you'll want to include transactions that pay fees in your blocks, in order to maximize your profits when a valid block is found.

But also, you need to ensure you are always working on valid blocks, because any time spent mining on what may be an invalid block is likely just a waste of your resources.

With this in mind, consider what happens when you hear about a new block on the network. You can validate the header of the block quite quickly, and begin mining on it, in order to not waste resources mining at the height of (chaintip - 1). The catch is that downloading and validating every transaction in the block takes a tiny bit of time, and until that validation is finished, you will not have a clear picture of which transactions are included, and not. So until you have finished validating the new block, the safest play is to begin mining an empty block on the new chaintip. Otherwise if you include an already-confirmed transaction, your block will be invalid! Once your node has a clear picture of which transactions were included in the new block, you can resume mining on a full block, in order to maximize profits.

In reality, the time between hearing about a new block, and updating your mempool accordingly is quite small, but nonetheless on occasion a block is found during this time.

I do not know if that is what happened with this block, but it serves as an example of a technical reason why an empty block may be published to the network.


Bitcoin Address Workflow on Spend Leftovers I need to understand the correct Bitcoin address workflow for transactions. I created an address a while back with a common wallet and sent some coin there. The address is at segwit m/49'/0'/0'/0/0. I then spent some coin from that. When I looked up the address on the blockchain, I noticed that the balance was 0. The transaction that occurred had two output addresses. The funds were sent to two addresses. The second is the non-segwit address of the person of who I sent the funds to. The first was segwit m/49'/0'/0'/1/0 (address from my wallet). It appears that the wallet moved my funds to a new address in my wallet. I.e. m/49'/0'/0'/0/0 -> m/49'/0'/0'/1/0.

Should a wallet always move the left over from m/49'/0'/0'/0/x to m/49'/0'/0'/x/0? Is this logic standard practice? Or is this specific to the wallet I used? Is there a recommended practice? I need to know because I am developing a wallet, and I need to follow standard practice.

What should happen when I transfer the funds from m/49'/0'/0'/x/0 to another address, and there are leftovers? Where should the new address for the leftovers be moved to? m/49'/0'/x'/0/0?

It appears that the wallet moved my funds to a new address in my wallet.

That is normal and desirable behavior.  See How does change work in a bitcoin transaction?

  Should a wallet always move the left over from m/49'/0'/0'/0/x to m/49'/0'/0'/x/0?

This wallet is using BIP 49, which extends the hierarchical wallet organization described in BIP 44.  General standards for hierarchical deterministic wallets are described in BIP 32.  You'll want to read these carefully if you are implementing your own wallet.

Under BIP 44, the fourth level of the derivation path is to be 0 for "external" keypairs (those presented to the user as a receive address which she may send to a payer), and 1 for "internal" keypairs (to be used as change addresses).

  Constant 0 is used for external chain and constant 1 for internal chain (also known as change addresses). External chain is used for addresses that are meant to be visible outside of the wallet (e.g. for receiving payments). Internal chain is used for addresses which are not meant to be visible outside of the wallet and is used for return transaction change.

BIP 32 specifies something similar:

  Each account is composed of two keypair chains: an internal and an external one. The external keychain is used to generate new public addresses, while the internal keychain is used for all other operations (change addresses, generation addresses, ..., anything that doesn't need to be communicated). Clients that do not support separate keychains for these should use the external one for everything.

So it is in keeping with this standard that an external keychain address .../0/x was used to receive your coins initially, while the internal keychain address .../1/y was used for the change from your outgoing transaction.  (It's just a coincidence that x and y were both 0 in this case; it would normally just be the next unused value on each chain, but since you hadn't done anything else with the wallet, you got the first keypair on each chain.)


Ardor: How to decide if an asset can be send? My (Javascript) frontend needs to decide whether the user can send an Ardor/Ignis asset in his account. My code checked for:

quantityQNT >= amount_to_send

But I realise that this doesn't work if the user has the asset offered on the asset exchange.

So just checking for unconfirmedQuantityQNT wouldnt be clever either, as it might want to send an asset which ownership never confirms (phasing or fork).

Would it be safe to check this way:

min(quantityQNT,unconfirmedQuantity) >= amount_to_send

Thanks for your opinions

In most cases you should use the unconfirmedBalanceNQT. Think about it as spendable balance i.e. your total balance minus coins/asset shares/currency units locked for various reasons such unfulfilled coin exchange orders.


Are all the *coin networks consistent in which script actions are permitted and disabled? The reference Bitcoin client disables several script commands (the programming within a transaction) due to possible implementation issues in the network.  I think it's possible that a forked client may actually enable such commands.

Do any of the other networks (namecoin, litecoin, test or prod, etc) enable disabled script commands?

I'd like to test and compare my implementation against others.

Short version
Yes.
Long version
Bitcoin
The bitcoin implementation of banned opcodes is in script.cpp:
        if (opcode == OP_CAT ||
            opcode == OP_SUBSTR ||
            opcode == OP_LEFT ||
            opcode == OP_RIGHT ||
            opcode == OP_INVERT ||
            opcode == OP_AND ||
            opcode == OP_OR ||
            opcode == OP_XOR ||
            opcode == OP_2MUL ||
            opcode == OP_2DIV ||
            opcode == OP_MUL ||
            opcode == OP_DIV ||
            opcode == OP_MOD ||
            opcode == OP_LSHIFT ||
            opcode == OP_RSHIFT)
            return false;

Note that this is not a complete list - OP_NOTEQUAL is also disabled. This code struck me oddly because it appears to create a fork with transactions that use OP_NOTEQUAL. (Perhaps it wasn't being used.)
                // OP_NOTEQUAL is disabled because it would be too easy to say
                // something like n != 1 and have some wiseguy pass in 1 with extra
                // zero bytes after it (numerically, 0x01 == 0x0001 == 0x000001)
                //if (opcode == OP_NOTEQUAL)
                //    fEqual = !fEqual;

Source.
Namecoin
Same.
LiteCoin
Same.
SolidCoin
You didn't ask about it, but it's also the same.


Connecting a Hardware wallet to a full node I'm trying to connect my hardware wallet to my personal full node for the sake of privacy. I need to know the node's IP, port, and RPC credentials. The first two are easy, I can see my full node in bitcodes.io that's up and running. I added the
rpcuser=xxx
rpcpassword=****

to the bitcoin.conf file. But When I try to connect through my hardware wallet application, it says: The node is not reachable. I'm not sure whether the bitcoind is reading the rpc inputs from the config file or not. Is there anyway that I could try to reach to my node to make sure it's reachable using the rpc credentials.
Here is the content in the bitcoin.conf file:
prune=0
txindex=1
server=1
daemon=1
rpcuser=letsbegin
rpcpassword=*****
externalip=xx.xx.xx.xx

How to connect your hardware wallet to a full node depends heavily on what wallet software you're using. But assuming your software connects to a full node via the bitcoind RPC interface:
By default, the RPC listener only listens on localhost. If you want to connect to the RPC service from another computer, you'll have to allow other connections by including these lines in your bitcoin.conf (replace:
server=1
rpcallowip=<add the IP you are connecting from here, or rpcallowip=* to allow all IPs>
rpcport=8332

If you want to simply test whether your bitcoind RPC is accessible, you can simply make an HTTP request to the RPC host at port 8332 from the computer you're trying to connect from.


Funds disapprearance I stored 0.0154 BTC in my blockchain for mining purposes and next morning I found my balance to be 000, what does that mean? Are my coins lost or stored somewhere else?

I STORED 0.0154 BTC IN MY BLOCKCHAIN WALLET FOR MINING PURPOSE

Mining bitcoin does not require putting bitcoin into a wallet you own.

Asking people to link their wallets to a miner is a favourite trick of conmen / scammers.

  IN THE NEXT MORNING I FOUND MY BALANCE TO BE 000 , WHAT DOES THAT MEAN?

If someone else knows the password to your online wallet, they can extract from it the "private key" which gives control over any bitcoin already sent to addresses in that wallet as well as any future amounts sent to addresses in that wallet (even after you change wallet passwords).

It is likely you are the victim of a conman and your money has been stolen.

Related questions with useful answers:

BTC Stolen from Blockchain

  A guy ... told me that I can mine for bitcoin ... Within half an hour my wallet was empty.

Bitcoin Mining as a Newbie (link wallet to another person's miner)
I've been asked to share wallet credentials to participate in mining. Is that a scam?
I NEED YOUR HELP URGENTLY Bitcoins


How do you build a Ripple gateway without rippled? I've noticed that several Ripple gateways now exist, most notably Bitstamp. However, the only documentation I can find on how to create an automated gateway seems to imply that you must have OpenCoin's rippled program.

Can anyone build a Ripple Gateway, or is this ability limited to OpenCoin's inner circle?

The documentation does assume you will run a local server. But anyone can build a gateway, with or without the server. To operate a gateway, you really only need to be able to process transactions just like a client does. When a transaction happens you need to know. When you need to perform a transaction, you need to perform it.

Probably the easiest way to do it is to implement the gateway's interface to the Ripple network using JavaScript and node.js -- this lets you use ripple-lib which is a supported, open source interface to the Ripple network.

If you do decide to run your own server, nothing really needs to change. Just point your gateway interface to your local server instead of the public server pool.

Whatever you do, please don't send your secrets to the public server pool. If you use ripple-lib, make sure local signing is on. If you use anything else, use ripple-lib's rsign.js program to sign transactions for you.


Are there any _severe_ drawbacks of bitcoin justifying all the alternatives? There exist quite some alternatives to bitcoin that are partially based on it, and I'm sure their creators all are convinced they improve upon something. But are there any serious drawbacks in bitcoin that can or will probably never be fixed?

I don't think there are severe drawbacks of Bitcoin. Certainly none that other coins are solving.

However, Bitcoin has certain properties that could be replaced with some other. Most altcoins to just that. Popular properties that altcoins change are:

replace PoW with something else

Some altcoins do not use a PoW mechanism or use a hybrid mechanism. PeerCoin (originally named PPCoin) was the first altcoin to use the Proof-of-Stake mechanism, which basically requires miners to hold a certain amount of currency in order to mine new. PeerCoin uses a hybrid of PoS and PoW. Nxt is an altcoin that uses pure PoS.

the PoW algorithm

Bitcoin uses SHA-256, which is a hash algorithms that almost entirely requires CPU cycles to calculate. This means that it is easy to create custom hardware to perform this calculations. There are many altcoins that use Scrypt as the PoW algorithm. Scrypt is more memory-intensive and therefore harder to implement in custom hardware. The first altcoin to implement Scrypt is Litecoin. Primecoin requires miners to calculate large prime numbers as a PoW mechanism.

the total amount of coins that can be mined

Bitcoin has a 21 million coin limit. Some altcoins raise this limit, such as Dogecoin, others lower it, such as 42.

the rate at which new blocks are created

Bitcoin blocks are mined at an average rate of one block every 10 minutes. Many merchants require that a transaction has been confirmed by several blocks before they accept it. With a confirmation time of 10 minutes (in fact, the recommended amount of confirmations to wait for is 6) can be quite cumbersome in certain use cases. Litecoin has a confirmation time of 2.5 minutes.

the time it takes before the maximum amount of coins is created

Block rewards usually have a halving time. Every halving time the block reward halves until it is too low to represent using the maximum precision and it becomes zero. With Bitcoin it will take until 2140 until the block reward becomes zero. Some coins shorten this period. Sometimes they shorten it so much that the creator (who mines first, of course) is accused of pre-mining because he can mine very fast and easy in the beginning of the existence of the coin.


Where do I find the *actual* blockchain size? Okay, my hard drive is a bit cramped, and the Blockchain for my Bitcoin client is completely sucking up my free space. I want to know how much room I need to be prepared to lose.

This isn't a duplicate of the other questions - those had answers that were highly impractical - I'm not sure if they dealt more with the theory of the blockchain or what, but the filesizes were way off.

For example, right now, http://blockchain.info/charts/blocks-size says that the current blockchain size is 6073 MB, which is complete BS - the cumulative size of ~/.bitcoin/blocks/*.dat is 6970 MB, and it's not even done yet.

Basically, what I want is a realistic, down-to-earth estimate of how much hard disk space the blockchain is going to cost me. Not the theory, not the "data minus overhead", the actual cost of the .dat files.

The blockchain sizes of Bitcoin, Litecoin, Dash, Dogecoin, Peercoin and Namecoin are listed here at https://bitinfocharts.com/
(scroll down to Blockchain Size)

As of today (2015-07-12) the sizes are (sorted by market capitalization):

Bitcoin             Litecoin          Dash              Dogecoin          Peercoin          Namecoin
44.73 GB            4.64 GB           1.01 GB           11.41 GB          0.4191 GB         2.64 GB
$4,477,078,707 USD  $209,054,841 USD  $23,217,866 USD   $20,686,200 USD   $15,897,328 USD   $9,888,883 USD

Note that Dogecoin, although very new, has a very big chain already, where Peercoin has by far the smallest.

Your question

On my hard disk the .bitcoin directory uses 45 GiB = 48 GB.


How to add support for segwit address and legacy with bitcoin core 0.16? I've been running bitcoin core 0.15 as regtest, and had X bitcoin in my balance all are from legacy output addresses, As I upgraded to 0.16 core version check in debug the legacy addresses are still validated as mine. but no balance. I wonder will this happen as I will upgrade my wallet at the mainnet as well ?
I wish to be able and support creation of legacy address and SegWit on the same wallet and as of comments on How to generate SegWit address I see I will need to run bitcoin core each time with a new param "-addresstype=legacy" to enable it, so is there a better way ?

[edit 1] - I should/need to run with same "-datadir" arg ?
[edit 2] - I run it under same -datadir.
[edit 3] - I’ve opened issue
https://github.com/bitcoin/bitcoin/issues/12872

Quoting Suhas Daftuar's response to the issue you opened:

  In 0.16, we changed the consensus parameters for regtest so that segwit was always active. This was mentioned briefly in the release notes https://github.com/bitcoin/bitcoin/blob/v0.16.0/doc/release-notes.md#testing-changes, along with a workaround to replicate the old behavior.

  I am surprised that you're not seeing the assertion failure mentioned in the release notes, but I suspect this is the cause of what you're seeing.

So this is expected, but only affects regtest.


How is Bech32 based on BCH codes? The Bech32 BIP declares that Bech32 is "based on BCH codes". But if you look at the wikipedia page on BCH codes, you see a lot of mathematical equations, but none of those equations seems to be similar to the code that calculates a bech32 checksum.

Can someone explain what parts of BCH codes that bech32 is based on?

The math in the wikipedia article is primarily concerned with generating a BCH code-- which is something that was done for the design of Bech32 but obviously isn't part of the implementation itself-- and with correcting errors which isn't done with Bech32.  The article's section on encoding is blank, which is too bad because that is the one thing that's done in the Bech32 code. Even bech32 validation just works by re-encoding and checking if the new encoding matches.

Bech32 is a BCH code constructed with a characteristic-2 field. This allows its symbols to be an integer number of bit's long (5 in the case of bech32).  In this kind of field the numbers are treated as coefficients of a binary polynomial, addition is accomplished via xor, and multiplication is accomplished by shifted xors reduced mod a polynomial. As a result the workings look pretty different from what you'd expect from an algebraic description.

A fancy bech32 decoder that finds the error positions also ends up not looking too much like the algebraic decoder in wikipedia, because bech32 has performance better than guaranteed by the fact that it is a BCH code but to exploit that you must go beyond the plain algebraic decoder.  When we designed bech32 we also found a non-BCH cyclic code that had somewhat better error detection-- and would have used the same encode/validation code with different constants-- but preferred to stick with the BCH code since proving a lower bound on its performance is much simpler and there are more options for constructing fancy decoders since BCH codes can be decoded algebraically (as described in Wikipedia).

The implementation in the Bitcoin code of bech32 has an extensive description of the mathematics of it and how the mathematics relates to the implementation.


What is a softchain? What is softchain and how is it different from drivechain? What are associated tradeoffs and feedback from community?

What is softchain

Softchains: Sidechains as a Soft Fork via Proof-of-Work Fraud Proofs. Decentralized two-way peg sidechain design. Activating new sidechains requires a soft fork, hence the name softchains.
Ruben Somsen shared about a new concept "Softchain" on Twitter and Bitcoin Dev mailing list:
https://web.archive.org/web/20210101153139/https://twitter.com/SomsenRuben/status/1344770107017457664
https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2020-December/018331.html

how is it different from drivechain?

It's similar to drivechains, but without the major downside of having to rely on miners, since all Bitcoin full node users can efficiently validate each sidechain.

What are associated tradeoffs and feedback from community?

You can find few in the replies to the tweet shared above, Paul Sztorc's tweet and below links (mailing list):
ZmnSCPxj: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2020-December/018332.html
Sergio Demian Lerner: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2020-December/018333.html


What happens if I send small amount of btc lesser than fee? I tried to deposit a small amount of btc in localbitcoins.com, but it was smaller than their deposit fee so it was not processed by them, now what will happen to that chunk? and can I get back the btc?

The money has been placed under the control of the recipient.
There is no way to undo a transaction. Even when the recipient declines to perform the service being paid for.
If you overlooked or misunderstood their terms and conditions, they may feel it is for you to bear the costs of rectifying your mistake.
You cannot get back the money directly yourself, but the recipient could choose to make a payment to you of an equivalent amount after deducting the costs your mistake has caused them. It would cost them money in people's time and in transaction fees to do so. For example, no one will want to spend 2 mBTC of their own money just to send 0.1 mBTC back to someone who made a mistake.
Maybe you could ask them whether, if you make a separate payment that itself exceeds their minimum, they will credit your localbitcoins account with the sum of both amounts? Don't be too surprised if they decline.
Alternatively, perhaps you could consider it a donation to a good cause?


Must I have an account with every gateway I use as an issuer? In the Ripple Client, in order to convert to BTC, I need to select a Base Currency (it currently says BTC ???.)

I searched for a Base Currency Issuer address and found how to grant trust to BitStamp, which lists what is supposedly BitStamp's address.  I realize, however, that I cannot trust this address because it comes from http://www.nofiatcoin.com/ instead of https://www.bitstamp.net/.

I assume BitStamp requires signing up for an account before showing an address.

Is having an account just BitStamp's policy? Say I had a secure way of getting BitStamp's address without signing up for an account and I added this address as a BTC issuer. Couldn't I just buy/sell BitStamp-IOU's over the Ripple Network, even without an account at BitStamp? If so, why would BitStamp only divulge its issuer address if the user has an account?

Where can I find the address?

The address you need to trust to hold Bitstamp issued currencies is available from the Bitstamp website, but as you noted, you must be logged in to see the relevant page.

You can also find the address at https://www.bitstamp.net/ripple.txt under the [accounts] key. The ripple.txt file is documented here: https://ripple.com/wiki/Ripple.txt

Do I need an account?

You do not need to have an account with Bitsamp to be able to hold Bitstamp-issued assets. All you need is to trust their address. You can then buy Bitstamp-issued BTC, or USD or EUR or whatever else purely on the Ripple network.

Of course, having a Bitstamp account will allow you to redeem those IOUs through Bitstamp. Without such an account, you can still trade them on the Ripple network for either XRP or other assets, likely issued by another gateway.

You may find this primer to be of help: https://ripple.com/guide-to-ripple-gateways/


What does "Activating Best Chain" mean? What does "Activating Best Chain" mean? My Bitcoin Core doesn't freeze, it just takes a while. I'm curious as to what it's doing.

Bitcoin Core maintains two databases:

The block index
The chain state (or UTXO set)

The first one just contains a list of all blocks we know about, valid and invalid. It contains all forks we have ever heard about, and all branches that result from it. It also contains information about where on disk these are stored. It does however not contain any information about which blocks we consider part of the "best chain".

The second one contains a snapshot of all existing unspent transaction outputs up to one particular block (and it also stores the hash of this block it is "synchronized" to). The process of validating blocks consists of "applying" the effects of blocks to this state, and possibly undoing those effects when the block turns out to be invalid, or we need to reorganize to another branch.

At startup, it is possible that the first database contains blocks that could be valid but aren't part of the snapshot the second database represents. This can happen when you manually overwrite the block index (restoring from a backup, for example), but more commonly: because Bitcoin crashed after downloading some blocks that ended up being written to the block index, but the resulting chain state was never dumped to disk. When this happens, we will activate the best chain, loading blocks from the second database and applying them to the first (while doing full validation on them in the process).

Since Bitcoin Core heavily caches the chain state in memory, it is possible that there are hundreds or thousands of blocks missing from the chain state after an unclean shutdown. It can take a while to validate them again.

TL;DR: It's verifying blocks that were downloaded already but not processed yet (because the result of processing wasn't properly written to disk, most likely).


What is JSON-RPC and do i need it? I have recently finished installing the Bitcoin client. One site i was using to help guide me is called http://www.weusecoins.com/en/. On the mining guide section of that site it says, If you're mining on your own you need to start by setting up your Bitcoin client and set it up for JSON-RPC. I was trying to figure out what it is and how to set it up if i need it but i could not figure it out. My questions then are what is JSON-RPC and do i need it ? Is it set up by default in the original Bitcoin client ?

The JSON-RPC interface is a way for other programs to interact with Bitcoin-Qt or bitcoind while it's running. It's useful for doing things like mining or building a web site that needs to talk to the Bitcoin network directly. Most users don't need to worry about it or set it up.


How does Trezor's wallet recovery work if the private key never leaves the device? If the private keys never leave the TREZOR, how can they be restored if I lose it?  I am assuming that maybe the private key is generated on the TREZOR and then encrypted before being sent to SatoshiLabs where they only have encrypted data that requires a few of the 24 words to unencrypt.  Can anyone validate this or tell me how it is actually done.  I guess my concern is that I don't have control over my private key...

The Trezor generates a seed offline on your device. Neither the private key nor this seed are ever shared with SatoshiLabs.

In fact, you're in sole control of your private key: when you first set up your Trezor, you're being shown the 24 words that encode your seed. You have to write these words down and keep them as a backup. When you lose your Trezor, you can use these 24 words to regenerate your wallet by putting them into another Trezor, or using compatible software that performs the same key derivation.


Bitstamp order book history The current state of Bitstamps order book is available here:
https://www.bitstamp.net/api/order_book/

I want to analyze the history of the order book.

Do someone know if its available?

Bitcoincharts.com has the "market depth" for Bitstamp, which is just what you are asking for. It is presented both as a graph and a table with actual bid and ask volumes. There is a free API for much of their data, but (added in edit) to my surprise, the orderbook data does not seem available that way. If it will help you will depend on your application: There is a 15 minute delay.

There are many other sites presenting visualizations of the orderbooks of exchanges; one example is Bitcoinity.org's Bitstamp page. But I   am not aware of any other than Bitcoincharts.com that provides a public API.

UPDATE:

The question has been changed from asking if this data is available "at a third party" to whether it is available at all. Yes, it is available, from the first party (Bitstamp), via the API link provided in the question itself.


What is Mt. Gox's YubiKeys' "configuration protection access code"? Does anyone know if Mt. Gox, now that they're bankrupt, has released their YubiKey's "configuration protection access code" (cf. this)? If so, we could reprogram the free YubiKeys they sent us and use them for other purposes.

Does anyone know their contact information?

thanks

the unlock codes were leaked:

  https://bitcointalk.org/index.php?topic=631044

(source)


How doesn't the most powerful miner get the block reward everytime? My understanding is that miners try several values for a nonce until the hash of the nonce and the data is of a certain format. However assuming that all miners start the nonce counter from the same number then that would mean the miner that is going to find the correct nonce is simply the one that can hash the fastest. Which should always be the same miner. What am I missing here?

You need to build a valid block. That means that you need a valid nonce. If you start searching from 0, 1, 2, 3... or wheather you try random numbers is irrelevant.

The hash is also not only dependant from the nonce. If you start at 0 and another miner starts at 0 and you both have a different set of transactions in the block, you need to finde different nonces.


-SOLVED- I was Making a new genesis block and i got this error following this guide i solved my problem
my psztime was so long so i had to make it short and all were solved :) it successfully compiled and run pretty well

I was making a new genesis block, all was successfully but when I launch the new

 main.cpp:2747: bool LoadBlockIndex(bool): Assertion
 `block.CheckBlock()' failed. Aborted

I don't know what that means. I replaced the block.GetHash(), the hashMerkleRoot and also the block.nNonce in to the corresponding files but it won't work.

Anyone knows what is wrong?

This is my dump

CBlock(hash=000008d24b2b4473cf5ceb4c858b31dbd4d812c20cb5a6d60002e55a88cf6bf3, ver=1, hashPrevBlock=0000000000000000000000000000000000000000000000000000000000000000, hashMerkleRoot=00a51fca8509df84304bc58ee4da87b67552829d83c19faaea3358dc9a582cc6, nTime=1508815578, nBits=1e0fffff, nNonce=80207, vtx=1, vchBlockSig=)
  Coinbase(hash=00a51fca85, nTime=1508815578, ver=1, vin.size=1, vout.size=1, nLockTime=0)
    CTxIn(COutPoint(0000000000, 4294967295), coinbase 00012a4c8a4f6e65206772657920656c657068616e742062616c616e63696e6720537465702062792073746570206f6e2061207069656365206f6620737472696e672048652074686f75676874206974207761732073756368206120776f6e64657266756c207374756e7420546861742068652063616c6c656420666f7220616e6f7468657220656c657068616e74)
    CTxOut(empty)
  vMerkleTree: 00a51fca85
block.GetHash() == 000008d24b2b4473cf5ceb4c858b31dbd4d812c20cb5a6d60002e55a88cf6bf3
block.hashMerkleRoot == 00a51fca8509df84304bc58ee4da87b67552829d83c19faaea3358dc9a582cc6
block.nTime = 1508815578
block.nNonce = 80207

What to do?

Following this guide solved my problem my psztime was so long, so I had to make it short and they all were solved :) It successfully compiled and ran pretty well.


What is the best way to facilitate bitcoin transfers between users of mobile and web applications? Curious how an application would exchange bitcoin between users. Can an application send funds directly from sender to receiver or sender to app-owner to receiver?

If the service controls the private keys (i.e. they are holding Bitcoin for their users), then they can maintain an internal database with each users balance and just update that database. The Bitcoin is only sent when users wish to transact with people who are not using that service.

If the private keys are held by the user, then the most efficient thing to do would be to have the users transact directly with each other. This reduces transaction fees.


How does a non-upgraded node read a SegWit transaction? I'm trying to understand how my node would interperet a SegWit transaction if I do not upgrade.

Even if I do not upgrade, I should be receiving the exact same block data as everyone else, correct?

If so, let's say my node receives a block that contains a segwit transaction (i.e. one with a [marker][flag] and some [witness] data). I'm not sure how my node is going to interpret the data...

If the [marker][flag] is [00][01], does my node read this as being 0 inputs and 1 output, and still consider this transaction valid?
If so, how can it go about recreating the TXID from the [version][txins][txouts][locktime] if the transaction data is of the format [version][marker][flag][txins][txouts][witness][locktime]?

Basically, I don't understand how my node could receive transactions with [witness] data and still consider those blocks to be valid.

Segwit node will convert transactions and blocks "on-the-fly" while sending them to your non-upgraded node. You will see anyone-can-spend outputs and redeems from such outputs. You will not see any additional flags, witness data and any other segwit stuff.


What is the reasoning behind the choice of 2^256-2^32-977 for the prime on the secp256k1 curve? In Bitcoin's elliptic curve (secp256k1),

the prime

p = 2^256 - 2^32 - 2^9 -2^8 - 2^7 - 2^6 - 2^4 - 1

the generator point

Gx =
0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798

Gy =
0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8

and the order of the group generated by G

n = 0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141

are predefined.

What is the reasoning behind this? Why are these values more secure or efficient than any other ones?

Secp256k1 was designed to be a 256-bit size elliptic curve without cofactor and admitting an efficient endomorphism for optimization purposes. The choices of the relevant parameters are derived from these criteria.

P is selected allow a more efficient implementation on general purpose computers. See Solinas' paper on Generalized Mersenne Numbers.  We don't know the exact search procedure Certicom used to select P, but it is the first prime you get if you search 2^256 - 2^32 - (1024 - x).

We know, however, that this may not be the exact procedure they would have needed because the presence of the endomorpism requires a cube root of unity. See this answer on crypto stack exchange.  But they could have searched this way and got lucky.

The generator could be just any point on the curve and it is trivial to prove that the choice of generator is irrelevant to the security of any scheme that doesn't involve coercing values into curvepoints, and pretty narrowly relevant otherwise.

We haven't been able to uncover how G was selected, but I did discover that it a value that was likely obtained by doubling a point with a very small (166 bit) x coordinate. The same value was used in several other ECC standards. (I wouldn't be surprised if it was the hash of someone's name of something silly like that, but it seems that this trivia might have followed Scott Vanstone to his grave).

Since the curve order is prime the order of G isn't a parameter so much as the result of the selection of the field and the curve equation. 'b' in the curve equation being 7 was almost certainly just because it was the first value that gives a secure curve. 'a' being 0 is a necessary condition for the endomorphism.

You might also find this old thread on bitcointalk interesting.


Why P2Pool fails to attract more users and other pools surpassed it? Some people say that mining pool are going to violate the distributed principle of Bitcoin and make it more centralize. So why totally distributed pools such as P2Pool have not attract more users?

I read about the important factor of choosing a pool in here and here. As I know, P2Pool have many important factor including "not having pool fee", "sharing transaction fees", "being hopping proof (see here)", and more importantly conforming the distributed spirit of Bitcoin. So why it has much less computation power (and users) rather than other pools such as AntPool and BW.COM?? Is there something else I didn't considered?

Many of these are irrational, but this is the summation of feelings from the P2Pool thread on Bitcointalk. P2Pool would be preferable for decentralization, but without a larger share of the global hashrate it seems doomed to obscurity.

P2Pool has high latency, high variance payouts. You get paid as much on average as any other pool, but people generally appear to be uncomfortable about not getting a payout for many days. Centralized pools have more consistent payouts and lower variance.
P2Pool requires more than a bare minimum of support hardware. Miners usually have their own computers on board but they do not have enough power to run a Bitcoin node and P2Pool client, so miners need an external computer to run this software on. Regular pools are more convenient and do not require additional hardware.
P2Pool is actively hampered by bitcoin mining hardware that throw away valid blocks. The high announce rate of new work (30 seconds) means that a lot of common configurations throw away valid blocks that just happen to be stale P2Pool share chain blocks, effectively performing a block withholding attack against the network and lowering its productivity.
P2Pool is perceived to have lower luck.


How can I pick the data directory of Bitcoin Core on Windows 10? I'm using Bitcoin Core on Windows 10.  Despite setting it up in a folder on my larger drive, it's eating all the space on my SSD. How do I direct the blockchain to the drive I want?

You'll want to set the option -datadir=<path-to-your-drive> either when starting bitcoind, or in your bitcoin.conf file. If you add it to bitcoin.conf, you'll need to restart your node for the change to take effect.


Why is it so difficult to track & recover stolen Bitcoins? I have to admit I don't fully understand the Bitcoin protocol. But from what I do understand, transactions are traceable -- it is the main reason decentralization works: the world can watch and confirm that a transaction is legit.

Why then can't we observe when a thief tries to cash out or otherwise exchange a Bitcoin that we know to have been stolen?

As Robert Wagner writes:

  1 out of every 14 Bitcoins is now stolen property, and there are
  plenty of laws governing stolen property.

What am I missing here? With so many Bitcoins identified as "stolen," why can't they be traced, recovered and returned to their rightful owner?

Transactions can occur very quickly and the stolen coins can exchange hands, split up and be mixed with other coins multiple times before the theft is discovered. Many innocent parties (whether it is merchants, exchanges or other individuals) could be affected. Who is going to be holding the bag?


Does P2PKH substitute P2PK in any circumstances? Why? Does P2PKH substitute P2PK in any circumstances? Why? I know address(public key hash) was invented later than the official implementation released. Is it the reason?

Both P2PK and P2PKH were part of the first bitcoin 0.1 release, so that second point isn't true.

P2PKH is theoretically safer because the pubKeyScript only reveals the hash of the public key rather than the public key itself (which only matters in the case that the elliptic curve crypto involved is broken). So as long as you don't reuse the address, no-one else will know the public key before the money is spent.

All bitcoin addresses encode public key hashes so only P2PKH can be used with an address, as the public key is not known. P2PK were mainly designed for IP-to-IP payments, which is no longer possible in Bitcoin Core since version 0.8.0


Bitcoin Core internal Electrum Server Is there a technical reason for which there isn't an option in Bitcoin Core that would deploy an internal Electrum Server, or something similar so that a software wallet can fetch addresses and balances?

Electrum servers are simply not compatible with Bitcoin Core on a development or operational level. They require a vast amount of indexes created which the node does not have, and must be created by an external tool. With the state of the art electrs Electrum server, it needs upwards of a day of time to create these indexes, and more than 50GB of additional data stored on disk. For the server to be performant, forks of the software use over 1TB of additional storage for these indexes.


Bitcoin core setup how to prune without downloading? I want to play around with code to learn about Bitcoin such as synchronizing the chain locally, verifying the Merkle tree, creating a new wallet programmatically.

from what i've researched I will need to prune the initial blockchain, but i don't see the option in setup.

is there some other way i can install it [with prune] given my low available storage?

update

i pressed ok, and added the config file afterwards.

I am not sure if this config is used, and the GUI is giving me an error when i try to open it.

Yes you can run in prune mode, set prune=550 (or a number >=550, which is a size in MB). As blocks are downloaded others will be pruned to free up space as needed so you'll be fine with 17GB.

You can set the prune values in bitcoin.conf or as a startup parameter.

More details here https://coinguides.org/bitcoin-blockchain-pruning/


Techniques or proposais to require transactions to be included in a block? As it stands now, a miner (or mining pool) can discriminate any transaction for any reason if they are running a custom version of code.

Suppose an evil and powerful mining pool decided to hash blocks, but not include any transactions even if a fee was included.  This would slow down the rate a block would be included in the chain.. effectively causing a DOS against certain transactions.

This is intended behavior to encourage transactions to include fees (or soon will be the behavior).  But suppose a pool operator (or powerful mining consortium) decide that they want to kill off Bitcoin and not include any transactions ... at all.

Question

What technical solutions are there to require blocks to have transactions?

Challenge

We don't want the attacker to only include transactions the evil mining pool themselves create, but also transactions that others create as well.
I don't want to encourage too many low-fee transactions in this model, thus de-incentivising mining activity

Is there any solution that addresses these goals in a fair and balanced way?

If the attacker has minority hashrate, I don't think this is much of a problem. If he excludes all transactions in his blocks but doesn't try to orphan other blocks, the worst thing that can happen is a x2 increase in the average time until first confirmation (no effect on subsequent confirmations). This is fairly minor.

If the attacker has majority hashrate, he can orphan all other blocks and exclude all transactions, and then transactions will never be confirmed. This is a problem and the main variant of the >50% attack. Possible solutions include modifying the branch selection mechanism to prefer blocks with more high-priority transactions - meaning that even with majority hashrate, if you try to deny transaction you're not guaranteed to beat the honest branch.

Incidentally, if the attacker has >40% hashrate, there is a technique to amplify his hashrate and get more than his fair share of blocks. So if, say, he has 49% hashrate and used this technique, he can get close to 100% of blocks, significantly delaying tx confirmation.


How can my NXT client/server send to multiple addresses paying one 1 transaction fee? I know bitcoind lets you have multiple outputs (sending to multiple address) via the command line. Does NXT support this feature? I want to create a faucet application where I can send to multiple addresses via a cron while only paying 1 transaction fee only.

Also what is the max number of addresses you can send to via NXT if this is possible?

At the protocol level Nxt doesn't support sending multiple payments with one transaction. Future versions may have this feature added.


Running multiple BTC nodes on separate VMs on the same host machine? I've got a server running 24/7 with lots of resources left. I want to run a full Bitcoin node, but actually, I thought of running a few virtual machines on it (using virtualbox) and running a full Bitcoin node in each of them.

Obviously they'd all need to use different ports (which are to be forwarded to the particular VM LAN IPs by my router).

Will that work, i.e. would they be on different 'metric locations' in the Bitcoin network? (even though they have the same physical location and same IP of course)

Reason for this endeavour: being 'as connected as possible' to different parts of the network simultaneously, just as if I had multiple nodes running on different physical locations throughout the world.

Having multiple nodes running will help you get connected to more peers. The algorithm behind finding peers takes into consideration a variety of variables, such as the success rate of previous connections, and the IP addresses that get relayed by other nodes. Therefore, the more nodes you have running, the better the chances of connecting to different peers.

This means that it doesn't really matter that they're running on different operating systems. You can run different nodes on the same OS, on different ports. This would effectively be the same as running them on different virtual machines.

What matters here is the high peer connection rate, which can be accomplished by running many nodes on different ports.


What encoding is "pubkey" from the JSONRPC validateaddress command? I need to convert a public key into a form suitable for use with BouncyCastle.

To do this I open the debugger and write:

ListAddressGroupings

I then pick an address and write

validateaddress 1HQCZTfr7V7WAMUcVHM21TLfLoeQWEtNmS

And I get the result:

{
"isvalid" : true,
"address" : "1HQCZTfr7V7WAMUcVHM21TLfLoeQWEtNmS",
"ismine" : true,
"isscript" : false,
"pubkey" : "020ba3ebc2f55152df5653bb7aba6548f0615d67b072379bdd19e72bc63c052c50",
"iscompressed" : true,
"account" : "testDONOTUSE"
}

However I'm not sure what format this is in.

What is the encoding of JSON-RPC's validateaddress value named pubkey?

I am asking this question so that I can determine the "recId" value needed for signature recovery when a UTF8 message is signed.  In other words, I need convert the public key below into an array that I can use for that purpose.

Is there an easier or better way to get the pubkey from a given wallet?

Sample data

Base58: 1HQCZTfr7V7WAMUcVHM21TLfLoeQWEtNmS
Public: 020ba3ebc2f55152df5653bb7aba6548f0615d67b072379bdd19e72bc63c052c50

SignMessage: Test
Output: IITRv4NdcaIgXP7DDNOkOrShBiJkBFoBqjXJXozKNClHnwSmNK3+QbT7ypKTkcc0F5UPsUCef5+gqhTb8sBZLuQ=

Further attempts:

When I convert public value "020ba3ebc2f55152df5653bb7aba6548f0615d67b072379bdd19e72bc63c052c50" as hex to bytes using this method on SO, I get the column below on the left.  This is incorrect.  However when I extract the public key from the private key, I get a similar but different result on the right.

public static byte[] publicKeyFromPrivate(BigInteger privKey, bool compressed)
{
    X9ECParameters ecParams = Org.BouncyCastle.Asn1.Sec.SecNamedCurves.GetByName("secp256k1");
    ECPoint point1 = ecParams.G.Multiply(privKey);
    return point1.GetEncoded(compressed);
}

The public key is in the format returned by OpenSSL and is a straight hex-encoding of the bytes.  If the first byte is 0x04, then it is a 65-byte uncompressed key (32-byte X and 32-byte Y).  If the first byte is 0x02 or 0x03, it is a 33-byte compressed key (32-byte X and one bit for Y sign).

The recID is encoded as part of the signed message.  Check the verifyMessage() method in the ECKey class to see how it is extracted.

The column on the right is correct and it matches what you got from validateaddress.


How to use the BIP-32 keys I am trying to built an application that uses the BIP-32. But I am not sure on how to use it.

I have a passphrase with which I generate the Derived Private Key and Derived Public Key. If I share my Derived Public Key with a second wallet will the wallet be able to generate others Derived Public Key from it ? Is it possible ?

And since I have the original Derived Private Key with me, can I see what is happening in the second wallet ?

Also if I loose both the Derived Private Key and Derived Public Key, will I be able to recover my wallets using only the Passphrase ?

1) You should not derive a master private key from a "passphrase". You need a secure PRNG (/dev/urandom) to generate 32byte of entropy. This 32bytes (256 random bits) is your master seed which can be "turned" into your "extended master private key".

You can later encrypt the 32byte entropy with a AES256 key derived from the passphrase (use a proper KDF).

2) Public keys can be calculated form the private keys.

3) If you have a private key, you can always calculate the public key

4) You cannot calculate the private key out of a public key (discreet logarithm)

5) The same applies to "extended" private/public keys (bip32 keys starting with xpriv, xpub, etc.)

6) You can give someone your extended public key which would allow him/her to watch your balance, watch your transaction


Transaction Confirmation between Users I'm reading this paper [1] that explain what happens when a user B wants to send money to the user A. The example says:

  When the miner finds a hash value with the correct number of zeros
  (i.e., the discovered value is lower than target value), the discovery
  is announced in the network, and both the Bob and the Alice will also
  receive a confirmation about the successful transaction.

After that:

  The Bitcoin protocol rewards the winning miner with the set of newly
  minted bitcoins as incentive, and the hashed block is published in the
  public ledger. Once Bob's transaction has been added in the
  blockchain, he and Alice each receive the first confirmation stating
  that the Bitcoin has been signed over to Alice.

Now I want understand some points:

It's true that B receives the transaction confirmation?
It's always true?
Apart Bitcoin, if we talk about Blockchain, every user that
sends a transaction towards another user, will receive the confirmation?

[1] - https://arxiv.org/pdf/1706.00916.pdf

The first confirmation is simply the fact that your transaction was included in a block. Any confirmations after that are simply new blocks that extend the chain on top of the history that includes the block with your tx.

To be notified about transaction confirmations, all one has to do is listen for the broadcasts of new blocks, and check if their tx is in it, or if the block extends the chain after their tx has been mined. If either of those hold true, the number of confirmations is incremented.

Due to this, it doesn't really matter who sent coins to whom. Every participant on the network is notified of which transactions are being confirmed, since they all receive new blocks.


In a private blockchain network, can we delete the first N blocks and reassign the N+1th block as the genesis block? I am aware of the data loss caused by deleting the first N blocks. But I am curious to know whether such a task is possible or not. If so, how to practically implement it?

With blockchains, you can basically do anything with a hard fork.  In the case of private blockchains, you will have a much easier time getting consensus for a hard fork, perhaps as easy as the authority running the blockchain dictating that everyone must accept an upgrade.

The genesis block is hard-coded into the software.  To re-assign a later block to be the new genesis block, you would need to hard-code that block into a newer version of the software.  This will only be recognized as valid by nodes running the newer version of the software.  Assuming gaining consensus isn't an issue, this is possible.

Another thing to be concerned with is block height, and all calculations based on it.  It's easy to modify the client to start counting at N+1, but this also may need to be taken into consideration when calculations are made.  This will effect things such as difficulty targets and halvings.  If you modify all relevant code to take this into account, you should be able to keep things working correctly.


error code: -26 error message: 16: mandatory-script-verify-flag-failed (Signature is found in scriptCode) I am building a simple p2pkh transaction using libbitcoin. Trying to pass it through my regtest node. I am getting the following error message.

error code: -26
error message:
16: mandatory-script-verify-flag-failed (Signature is found in scriptCode)

my transaction hash is as below:

01000000018df8ae6050992976497b63349c281bd05666842a6a82d6d8b26dc51812d58201000000006b483045022100c4befe583a3bc22eeaf1516c6d26fb3e1240bdfdf25db266494d82c77ccb36100220108ad79c4a34115eec23f5b0202d492dd88ec637df17a1982d4a63382e457599012102a018e21c743a4b67dcf38f9b693e807b1fbb833dfe705aa513abbf177b04adc2ffffffff01c0a6b9290100000017a91450628702abb40cc5fee219b9c834f4126c4198848700000000

Can anyone suggest what is happening here??

Please let me know if more information is required to understand the problem.

Thank you.

Even though this question is a bit old by now, it might be useful to add a couple of things for future readers who might encounter the same Signature is found in scriptCode error.

First, the error appears when the policy change introduced in commit 9dabfe49c0 is triggered.  Specifically, the error will fire when FindAndDelete() detects the signature being passed to a CHECK(MULTI)SIG(VERIFY) operation to exist in the scriptCode itself.
This will never (actually, with neglible probability) happen when a simple p2pkh script is being redeemed.

Secondly, the spending transaction and signature in the original question is in fact valid :

printf '%s\n' 01000000018df8ae6050992976497b63349c281bd05666842a6a82d6d8b26dc51812d58201000000006B483045022100c4befe583a3bc22eeaf1516c6d26fb3e1240bdfdf25db266494d82c77ccb36100220108ad79c4a34115eec23f5b0202d492dd88ec637df17a1982d4a63382e457599012102a018e21c743a4b67dcf38f9b693e807b1fbb833dfe705aa513abbf177b04adc2ffffffff01c0a6b9290100000017a91450628702abb40cc5fee219b9c834f4126c4198848700000000 '[{"txid":"0182D51218C56DB2D8D6826A2A846656D01B289C34637B497629995060AEF88D","vout":0,"scriptPubKey":"76A914E08E0B7AF54A0A5B4CA39ECC5430AB2730ECC2A188AC"}]' | regtest-cli -stdin signrawtransactionwithwallet
{
  "hex": "01000000018df8ae6050992976497b63349c281bd05666842a6a82d6d8b26dc51812d58201000000006b483045022100c4befe583a3bc22eeaf1516c6d26fb3e1240bdfdf25db266494d82c77ccb36100220108ad79c4a34115eec23f5b0202d492dd88ec637df17a1982d4a63382e457599012102a018e21c743a4b67dcf38f9b693e807b1fbb833dfe705aa513abbf177b04adc2ffffffff01c0a6b9290100000017a91450628702abb40cc5fee219b9c834f4126c4198848700000000",
  "complete": true
}


importing all blkXXXXXX.dat I've moved my bitcoind process to a new server, I made a backup of my .bitcoin folder (I'm using linux). I would really like to avoid downloading the whole blockchain again.

What's the right way to import all the blk00000.dat files? Is it enough to move the .bitcoin folder over the new one?

EDIT: I see the Loadblock option but I suppose I should run it after move the file outside.Anyone can confirm this? Is there a better way?

Copy these files to a exact Bitcoin Data folder on your Ubuntu (~/.bitcoin/) and then run client to download the latest blocks available. To synchronize with the blockchain run bitcoind with command -reindex bitcoind -reindex.


why block minning not interrupted when block found? I am working with bitcion version < ver. 0.13.0 which contains the setgenerate true functionallity.
I could see in some situations during minning process that when I find a solution, but the other miner has found it already before (and its already published),  I get the message: "ERROR: BitcoinMiner: generated block is stale".
My question is: why the minning process on a specific block not interrupted at the moment when a solution found by one of the other miners?

A realistic bitcoin miner finishes a work unit in less than a second and blocks are only found every ten minutes. So interrupting a work unit would increase mining efficiency by something like 0.1% at best. The additional hardware required to support such interruption on a realistic mining platform would not justify the small performance improvement you might get.

However, it is still beneficial to switch to a new work unit as quickly as possible when a new block is found. But in modern mining systems, this is implemented at a higher level, typically somewhere between the miner's end of the connection to the mining pool and the mining hardware itself.

You can think of it as the software controlling the actual mining hardware having a "big" work unit and, from it, doling out "smaller" work units to individual mining hardware units. When a new block is found, the software gets a new "big" work unit from the mining pool and when the mining hardware needs a new smaller work unit, it gets one from the new big work unit. It's counterproductive, because the small work units are already so small (typically only a few billion hash operations) to try to interrupt them.


How should I safely buy/sell a preorder for Bitcoin mining equipment? Suppose I need to buy/sell a preorder for Bitcoin mining equipment.  What is the safest approach (for both the buyer and seller) to conduct this transaction?

Does it matter if this transaction is done over BTC vs Dollars?

I'm assuming an escrow is needed, but not sure where to find such an arbitrator.  If multisig transactions are used, I'd like to see how this would be set up.

They do it all the time over at the 'Group Buys' section of the bitcointalk forum. Have a look at how they have theirs arranged.

https://bitcointalk.org/index.php?board=137.0


Why do large blocks increase the probability of chain reorgs? After the recent two chain reorgs taking place in Bitcoin Cash SV, I am finding a number of developers stating that large blocks are the reason for the reorgs:

"Almost each time someone is trying to produce a very large block on the $BSV chain, there’s a reorg." Nikita Zhavoronkov, lead developer at Blockchair

“This is basically exactly the problem the BU gigabock testnet identified. At sizes > 100mb the mempools were so out of sync that blocks were basically transmitted as full blocks.

"BSV had ONE 128mb block and it caused a six block reorg. On the BU testnet sustained 128mb blocks caused a total breakdown of the chain where there were so many reorgs that every node had a different view of the state of the blockchain. And would you believe barely a day goes by where the BSV supporters don’t mock me pointing this out as if it’s sooooo obvious how wrong I was.” Chris Pacia, CEO of OpenBazaar

What is it about the nature of large blocks that makes it more likely that the blockchain will reorganise itself?

This shows the inherent flaw with the idea of increasing block sizes if the network cannot handle them propagating in a timely manner.

If the block sizes are huge and the mempools of the connected nodes are way out of sync, the full node will basically have to download almost entire block before adding to its chain and then transmitting this block to the nodes that are connected to it. This can consume a lot of time. If a miner mines a block h, they will generally try to build block h+1 on top of the block that they found. It is only after they receive block h+1 (before they mined it) will it know that they lost the 'race' for h+1. The miners will then reorganize its chain to the best height h+1 that they just received and mine on top of that.

When block sizes are huge, the miner in above example, might receive block h+1 only after he has mined h+1. So the miner will start building on top of the block he has mined, being deceived that he was the first to find the solution to the block h+1. If block sizes are huge, this can extend for multiple heights, until the miner receives say a block at height h+6 before he mined the block at that height. So the miner will now have his chain reorganized based on the blocks he has received in the past. The full nodes that are closely connected to the miners, will also have to reorganize their chain for that to happen.


How to run Bitcoin Core behind corporate proxy? I'm want to run Bitcoin Core client on TestNet and I need to config it for using under corporate proxy.
Since I'm using Squid to set proxy for my system I should set "localhost:3128" somewhere... but bitcoin-qt options seems to have only SOCK5 proxy field.

I also tried to set the proxy using the command line:

./bitcoin-qt --testnet -proxy=localhost:3298

...but it doesn't work.

How can I solve? Can I run Bitcoin Core using setting a http proxy?

Bitcoin doesn't use HTTP for its communications - it has its own specific protocol that runs directly on top of TCP.  So an HTTP proxy like squid won't help.

If you aren't able to make outgoing TCP connections through your firewall (mainly to destination port 8333) then you'll have to contact your corporate IT people about adding appropriate firewall rules.  The same if you want to be able to enable listening.


How to find all UTXOs? It is known, that UTXOs stored in chainstate database.

But how to get them in simple txt view? Not ballances, but each UTXO.

With vanilla Bitcoin Core, there is no efficient way to do this.

I see two options:

a) Slow and very inefficient RPC loop (not recommended)

Get the genesis block hash (RPC getblockhash 0)
Get the block with all transaction (RPC getblock <hash> 2, 2 stands for verbosity with transaction)
Loop through all transactions and all its outputs, call gettxout <txid> <n> (where n is the outputs index)
If gettxout returns an object, the output is unspent (UTXO), dump it to a text file

This may take a couple of hours or days (depending on your machine).

b) Fast way by patching Core (0.17.1)

Change the code of the function call GetUTXOStats(), apply a text file dump in the utxo set loop (while (pcursor->Valid()) {)
Compile
Call RPC gettxoutsetinfo and let your added code dump data per UTXO to a file (or similar)