Why is it important for individuals to be able to run their own nodes? I understand that the more people that can run their own node supports decentralization, but if miners are sufficiently decentralized what is the threat of users not being able to run their own nodes?

Every time you check your wallet, your wallet is displaying information that it fetched from a bitcoin node (usually with other software running on top of it, like ElectrumX). If you absolutely trust the server behind your wallet, then as an end-user, it's not necessary to run your node. However, you might still want to run it, because you care about bitcoin and want to help new users/companies download the blockchain, make the network more resistant to DDoS attacks or, if you live in an authoritarian nation like North Korea, you might want to make it harder for the government to censor bitcoin.

Running a node is especially important if you run a bitcoin-related company. In this situation, you shouldn't be relying on an external service as you don't know if it will be down, hacked or have bad intentions.

Also, if you receive a large payment in bitcoin, you want to make sure you received it. You can check seven different bitcoin explorers but, depending on your level of paranoia, you might want to check your own node and verify that it has at least two to six confirmations.

Check out Andreas's video about this.


How do I restore the public key? Let say, I create wallet and have two public key and one private key.
And I remove the first public key from the wallet.
Can I restore and use my first key again? Or it's removed at all.
Sorry for the maybe a silly question I'm a newbie.

When you create a new wallet (in any recent software) a new seed is generated, from which all the private key / address pairs are generated (there cannot be an address without its specific private key); usually Bitcoin clients don't let you remove addresses from wallet, but even if you manually delete one or all of them, if you backed up your seed, you can re-generate all addresses you have used (and in the same order), since all modern wallet are hierarchical deterministic.

Here a more detailed description of how the HD wallet work: learnmeabitcoin.com/technical/hd-wallets


How can multifactor authentication be used when there needs to be two people with access? For a business account at a Bitcoin exchange, either of two people need to be able to send bitcoins or withdraw.  This account will be configured with two-factor authentication.

How can two of the business' staff, located in different offices, each have access to the account?

The exchange specifically will be with BitFloor using Google Authenticator OTP, but the same question would apply for using Mt. Gox, with Yubikey, for instance.

With Google Authenticator, you scan a barcode into your phone and it generates a temporary 6-digit key every minute, regardless of whether the app is open or not. It is not limited to one person, just to one account. These codes rely on times being in sync so that when an authenticator code expires, it expires on the site as well. Most use two protocols - HOTP and TOTP.

Highlights from this answer: https://security.stackexchange.com/a/35159

HOTP = Client and server share a counter, when code generated, timer increments, producing a new one-time login code.

TOTP = HOTP except the counter is replaced by the current time. So long as the system times are in sync, both the client and the server will be on the same page as far as what 2FA code is currently the correct one.

If multiple people scan this barcode, they will all generate the same keys. Thus, all you need to do is have both people present when setting up two-step authentication (or save the barcode if they have incompatible schedules, but be sure to shred it later), and they will both be able to access the account whenever they want.

Due to best OpSec practices, it is best to have separate 2FA keys, or use an alternative method, such as key-pair authentication where each user has their own key to access the server. This is better for auditing purposes where you can determine more easily the difference between different users, especially if one user decides to do something malicious using a shared authentication code.


How are transaction fees claimed from a technical point of view? A typical transaction has one or more inputs and one or more outputs. Since there is no amount specified for inputs, the rule is that ALL of the inputs is always transferred. Any discrepancy between the value contained in the inputs and the total value of the outputs is lost forever.

When a transaction is first submitted there may be a discrepancy between the values of the inputs and outputs. The miner assembling the block may redirect that unaccounted for difference to themselves or any address they wish, called a "transaction fee", however my question is how do they do this?

It would seem the only way to do this would be to add new output to the transaction and new script to send the value to the output. So in other words the miner would change the transaction from the form submitted by the original poster, to a new form including the fee transmittal.

However, isn't the transaction hashed to prevent someone from altering it? If a miner can alter it, why not alter it to just direct all the input to themselves?

A typical transaction has one or more inputs and one or more outputs. Since there is no amount specified for inputs, the rule is that ALL of the inputs is always transferred. Any discrepancy between the value contained in the inputs and the total value of the outputs is lost forever.

This is not correct. The difference between the input amount and the output amount is exactly what we call fee. It is not lost.

  It would seem the only way to do this would be to add new output to the transaction and new script to send the value to the output. So in other words the miner would change the transaction from the form submitted by the original poster, to a new form including the fee transmittal.

That is not possible. Miners cannot modify transactions.

Instead, there is simply a rule that the coinbase transaction (the first transaction in each block, created by the miner) is allowed to have outputs whose summed amount is up to the subsidy value (currently 25 BTC, soon 12.5 BTC) plus the sum of all the fees of the other transactions in the block.


Implement website payment solution I want to implement a bitcoin paying system to my website. I came up with this http://bitfreak.info/?page=tools&t=bitsci but I am unable to understand how it's working.

I looked up into the sourcecode but I don't get where I can get the bitcoins after the user has paid. The term WIF is used a lot; what is that?

Is there any simpler solution? I don't want to use a third-party service

If you want to create your own implementation using the Bitcoin Client, you ought to look into Accounts. This concept would allow you to have complete control over your users' payments, but it would also mean that you have to implement your own solution that would be communicating with Bitcoind.

There is also a more complete solution from StrongCoin in PHP, but I have no experience with it.


How to mine a genesis block? Following this guide, I'm trying to learn how to mine a genesis block, not to launch another altcoin or anything, blockchain databases are going to be important and I want to be ahead of the curve.

I'm using this script and working with the litecoin source. I have only changed the following:

find LoadBlockIndex() function, inside, change:
    - paraphrase (pszTimestamp) to any recent news phase.
    - get the latest unix time (do a google), and put in block.nTime.
    - set any nNonce (doesn't really matter)
you can change the time/nonce for testnet too, if you want to use it.

Those variables are now found in chainparams.cpp and I didn't change the testnet time/nonce.

After compiling when I try to run litecoind I get the following error:

litecoind: chainparams.cpp:220: CTestNetParams::CTestNetParams(): Assertion `hashGenesisBlock == uint256("0xf5ae71e26c74beacc88382716aced69cddf3dffff24f384e1808905e0188f68f")' failed.
Aborted

If anyone can help or point me in the direction of some modern documentation I'd me most grateful :)


Can I trace Website Addresses that a Bitcoin wallet has passed through? first time posting here.

Please help. I have a BTC wallet address, and I would like to know to which websites/IP addresses this BTC wallet has been used to. Something like If I use this BTC wallet address on a certain website, can it be traced?

Thank you in advanced!

Your bitcoin address and private key are created locally from a random seed and because there are so many possible addresses you can be very very very much sure that it hasn't been used by anyone else.

IP adresses or websites that have used a specific bitcoin address aren't recorded in the blockchain

Hope this answers your question!


Tracking inventory messages I am trying to connect to different nodes and keep track of the inventory messages that they send to me. I tried to do this with bitcoinj and libbitcoin, but I didn't make it. The goal is to connect to much nodes as possible and listen to inv messages.

Any help? I am sure there must be a straightforward solution.

Thanks!

Using Bitcoin Core, if you start it with -debug=net (or add debug=net to your bitcoin.conf file), every single network message will be included in the debug.log file along with the node it came from. You can then parse the debug.log file to get the information you want.


BlockNotify not working Hi my configured jsonrpc is following

maxconnections=200
maxuploadtarget=20
rpcuser=someusername
rpcpassword=somepassword
daemon=1
keypool=10000
walletnotify=curl "https://someurl.com/walletnotify?transaction_hash=%s"
blocknotify=curl "https://someurl.com/blocknotify?transaction_hash=%s"

I am getting notified on both wallet notify and block notify but the problem is the transaction is not the same for both. For Example I get f793d590bacffce8efd37c1b1e3db254950e925dd5bbd7f3a92c1db142f4dc37
from wallet notify and

00000000000000000038ffec8f035d54558a78e94ae1138ac5bdf1470fb0863f

from block notify. Please help what have I missed or done wrong here?

-blocknotify notifies you about a block, not a transaction. The hash you see is a block hash
 You'll have to call an RPC like listtransactions or getreceivedbyaddress on payments you expect.

Alternatively, you can also call getblock with the hash you were notified about to see all the transactions in it. I don't recommend that though, as you'll need to deal with the case where your node was down or your system restarted, and you won't get notifications for things that happened during downtime.


Blockchain MySql Implementation - Updating Database I know there are similar posts here about utilizing MySQL as the basis for an application which contains the contents of the blockchain, but i have not seen any on-point answers to the issue of updating the database after the initial dump.

Assuming i move forward with blockparser or ABE (or another application which you believe works better), how do i update the database after the initial dump? I have not implemented any solution yet as i would like to have this piece figured out before diving in.

My goal is to have my local blockchain inserted into MySQL, and then have periodic updates occur to keep the database up to date.

Several options:

Connect to the bitcoin network directly, parse all messages, verify the blocks and insert all the transactions contained within it into the MySQL db. This is going to be a bit hard since you have to write code to connect to the network.
Run bitcoind side-by-side with the MySQL db and use some combination of the getblockcount, getblockhash, getblock, gettransaction RPC commands and insert the transaction data into the MySQL db. You can run a cron on this every 5 minutes or so and you should have a fairly up-to-date MySQL db. This comes at the cost of considerable disk space since you'll need to have the entire blockchain for bitcoind (30 gigs and growing).
Connect to some other service and get the data that way. Blockchain.info is the obvious one and they have a wonderful API for getting all the new data you need. Unfortunately, you'll have to trust them to provide the right data. There's also electrum servers which provide data using stratum and ABE and some others. Heck, if you can get someone to open up their RPC port (8333) on bitcoind, you can connect to their bitcoind and use the same commands as #2. The drawback here is that you have to trust a third party in some way, shape or form, though, of course, you can write your own verification code.

Regardless of which thing you choose, you'll need to handle some difficult things like orphaned blocks when trying to keep this db up-to-date.


Was Base58 invented for Bitcoin? Base58 is very useful whenever data needs to be written down, but I've never seen it mentioned in any context other than Bitcoin.

Was it invented by Satoshi specifically for use in Bitcoin?

I believe flickr uses a base 58 scheme for encoding picture IDs in URLs, though Bitcoin's Base58 isn't compatible with flickr's.


bitcoind cannot keep up with the blockchain My Bitcoin full node worked in the past, but some time ago, it stopped synchronizing properly. The blockcount increases but stays far behind the blockchain:

% bitcoin-cli getblockcount
457842

(The chain is at 493006 at the same time)

bitcoin-cli getpeerinfo shows that I have only two peers (I kept old results and, when it worked, it was several dozens of peers). Network seems OK on this machine, I can find no connectivity problem (tested with RIPE Atlas probes).

Log shows:

2017-11-04 06:58:01 UpdateTip: new best=000000000000000001605913d6d8dcf9ba337d613fc78a269f6c1ac0bc1a3e1e height=457868 version=0x20000002 log2_work=86.145812 tx=205962119 date='2017-03-18 20:33:31' progress=0.767130 cache=553.1MiB(4251353txo)
2017-11-04 06:58:58 UpdateTip: new best=000000000000000001be0ed9edf7d9bce998acf5019833624b929df320544df7 height=457869 version=0x20000002 log2_work=86.145846 tx=205963787 date='2017-03-18 20:46:52' progress=0.767136 cache=553.5MiB(4254813txo)
2017-11-04 06:59:21 UpdateTip: new best=0000000000000000024e01c470375adb787205320c094dccb5e5177b71381fab height=457870 version=0x20000002 log2_work=86.14588 tx=205965243 date='2017-03-18 20:49:17' progress=0.767141 cache=553.5MiB(4254630txo)
2017-11-04 06:59:32 UpdateTip: new best=0000000000000000017f1f8cc3a3adb4117563f4da24e0e8bf84eefc27689a87 height=457871 version=0x20000000 log2_work=86.145915 tx=205967793 date='2017-03-18 21:02:50' progress=0.767150 cache=553.8MiB(4256794txo)
2017-11-04 06:59:34 UpdateTip: new best=000000000000000000dddeee9c69bc6801414576d3d1f2f386077d72782f15f8 height=457872 version=0x20000000 log2_work=86.145949 tx=205968320 date='2017-03-18 21:07:23' progress=0.767152 cache=553.8MiB(4257262txo)

Version seems to be the latest one:

% bitcoind -version
Bitcoin Core Daemon version v0.15.0.0-g3751912e8e

Running on Ubuntu "xenial" (16.04)

OK, apparently, the problem was with the Ethereum daemon running on the same machine and that I had forgotten. top and free showed there was still CPU and RAM available but, when I stopped the Ethereum daemon, Bitcoin was able to get up to date. A bit strange.

% bitcoin-cli getblockcount
493316


What is the difference between these two "instruments" ICBIT charts Sorry for the vague question, I will improve it once I get an answer...

In the picture bellow I marked two "Instruments" that are being used for trading on ICBIT. I don't understand what the difference is and why the value of one is so much higher than the other.

Any help understanding what that means would be great

The number after the BTC/USD is the settlement date of that particular futures contract.

You can find a list of all ICBIT futures in this page, and clicking on one will show you all the details, for example: BTC/USD-12.13

As for why the prices are different, it's somewhat outside the scope of a Bitcoin discussion. I really suggest you read up on Futures Contracts. Make sure to fully understand the nature of Futures trading before investing in it.


Lightning Wallet (lnd) - Export Private/Public Keys? Is it possible to export keys from a Lightning Wallet, specifically lnd? I started opening my first channels, and most of what I'm reading says that you want to monitor your wallet balance (in the absence of watchtowers, which aren't implemented yet). I was looking to get the public key for my Lightning wallet so I can have a watching-only copy. I suppose I can do that by just having the address with some wallets, but it would also be nice to have the raw private keys for backup.

I know how to get the keys out of a normal bitcoin wallet, but not sure how to do that with lnd, since they're stored in wallet.db.

I think is not possible. They are still working on it.

https://github.com/lightningnetwork/lnd/issues/732


Why would someone use a BTC faucet if it pays 200 satoshi every 15 minutes? I've seen many people talking about faucets but why would a sane person do it to get less than 1 cent every 15 minutes???

There are a lot of reasons. First, you may simply want to test some functionality with some faucet coins. Second, you may think it's an excellent investment. Third, you may want to pay for some micro-transaction.


Bitcoin client which doesn't use wallet.dat? Is it possible to use Bitcoin client without wallet.dat file, by entering your addresses and being able to see the balance, but without the ability to spend bitcoins? I know that it's possible to backup wallet.dat and use another wallet.dat, but in that way you don't see your transactions and balance and can't label your addresses etc.

If it's not possible in official client (I believe it isn't), are there alternate clients that allow this? The point is to be able to backup wallet.dat and plug it in only when spending bitcoins, but not lose the ability to see your transactions in the meantime.

This is not exactly what you're asking for, but might be helpful. Bitcoin v0.4 supports encrypting wallet.dat, so you cannot spend without entering the password. Basically you would do something like:

make a copy of wallet.dat
encrypt your copy with Bitcoin client v0.4 and set a long random password (one you will easily forget)

Voila, you have just created your read-only wallet. Because of 100 keypool you will even see some new transactions made with original unencrypted wallet.dat

You can download Bitcoin v0.4rc2 here.


How to tell if I have been hacked? Lately, I had a synchronization problem using bitcoin core, and I asked in this forum how to solve it.
 Here is the link of the forum post.

I resigned trying to make bitcoin core work again, and connected today on a browser based wallet (blockchain.info).

I imported my private key, and the wallet showed I had exactly 0 BTC...

Option 1) I did the transfer between the 2 wallets wrong.

Option 2) I have been hacked, and lost 350 USD.

What do you think ?

Thank you.
(UPDATE : I did the import with a desktop based wallet and the result was te same : two transactions (that I did myslef 2 moths ago) and a balance of 0 BTC...).

Bitcoin is completely transparent, with all transaction visible on the public ledger. Your statement “I imported my private key, and the wallet showed I had exactly…” suggests that you're making some incorrect assumptions about how Bitcoin works.

You don't need a private key to find out where payments have gone from your address — just look it up on a blockchain explorer web site to find what was paid to where and when. Incoming payments are also visible and traceable. Also, if you've made incoming payments yourself, you could use the same blockchain explorer web site to look up (i) the sending addresses and (ii) the addresses to which bitcoins were sent from the sending addresses.

Once you've tracked down all relevant incoming and outgoing addresses, you need to see which of them are in one of your wallets. If someone else has made an outgoing transaction from any of your addresses, then that person has gained illicit access to one or more of your private keys.

You will not get a definite answer until you've checked all of the sending addresses and destination addresses.

EDIT: You should avoid exposing any of your private keys to the internet until you're clear about how Bitcoin works. For large sums, it's advisable to keep the private keys permanently off internet-connected computers, and to learn about cold storage techniques that allow offline signing.


How can I delete an address (private key) in the list of received Bitcoins? For every transaction I wanted to get, I was creating a new address, but soon I realized that there is just no way to delete all these addresses from the UI.

To make it clear, here is a picture:

I am using Bitcoin-Qt

Is there an easy way to delete all these addresses?

I don't think it's possible to delete addresses from just the UI.

You can delete addresses completely using Pywallet. However, unless you back up the key first, this means that you will not have access to any coins sent to these addresses (either future coins or existing coins which have not moved elsewhere).

The many addresses will be more manageable if you label them. You can even simply label each as "Z" to put them at the end of the list when sorted by label.


The bitcoind 'gen=0' setting - implications? I have read that when running a simple standalone instance of 'bitcoind', you should generally use 'gen=0', since it's highly unlikely you'll ever mine a block on your own.

What I don't fully understand is how this relates to transaction procssing.

If I use 'gen=0', does that mean I have no hope of getting transaction fees, either?

In other words, with 'gen=0', is my client not really participating in processing transactions at all?

Is block mining (to generate new bitcoins) a somehow separate process from processing transactions?

"gen" is by default 0 (off), so you should not really need to specify "gen=0" anywhere.

"gen" will generate bitcoins (mining), but you should only do this if you know what you are doing (you probably want to mine in a pool, and use proper tuned hardware/software).

And yes, you will only get transaction fees if you mine a block.


Can the sender of a MtGox code see which account the code is redeemed to? In other words, if I receive a MtGox code and redeem it to my account, can the person who gave me the bitcoins, via the code, see that my account was the account that redeemed it?

Nope.  Or, at least, unless you are law enforcement and have a subpoena.

Or, unless you redeemed it yourself (which would list in your deposit history).

You can tell if it has been redeemed by redeeming it yourself and seeing if it had funds, but that's about it.


Active workers vs Active users In a mining pool, it says that there are active workers and active users. What is the difference between them? And does the block get divided per worker or per user?

worker is analogous to the number of connections.

username is just a way of identifying specific miners in the list of connections and
to which account on the pool they belong to. They don't have any
impact on the work given.


Relationship of Bitcoin address and Public Key I am trying to understand relationship between your Public Key and bitcoin address. After reading few blogs my understanding was that after generating your Master Key pair, in HD wallet. One should not share any part of it (neither public nor private) but create child keys and use those child key pair to create address but later when reading on Atmoic Wallet came across following

Now confused: is it must to share Public Key. Isnt it privacy risk. I thought one will create unique addresses for each transaction and avoid any privacy leaks.

ps. noob in BlockChain and Bitcoin

Addresses are textually encoded public key hashes, which means that somebody in possession of only the address cannot read the public key - but eventually the public key must be revealed in order to spend the funds which are locked by an address - so it may become a privacy concern if addresses are reused, which is discouraged anyway.

With a HD wallet, we have what are known as extended public keys, which, as well as a regular secp256k1 public key, also contain a chaining code and an index, and a fingerprint of the parent key. They usually begin with xpub. These should never be publicly shared as it is not necessary for anybody to know more than the secp256k1 public key in order to verify information from the blockchain. The purpose of the extended key is to allow you to create more child keys from a given key pair.

In the case of non-hardeded extended public keys, it is possible for anybody with the xpub to create the extended child public keys, which could reveal a lot more information linking your transaction activity. These kind of keys are useful for auditing purposes as you do not need to reveal private keys, but should not be shared otherwise.

Also note that, even if you never share extended public keys and you never reuse addresses, this does not give any guarantee of privacy. It may still be possible to link your transactions if multiple inputs are used, or if you transact with KYC services which relate them to other identity documents. You should never assume that any KYC service is not sharing that information with other parties, or that they won't at some point be hacked and have all of the data dumped on the web.

In regards to the way addresses are created from public keys, this is nicely illustrated by the diagram below, taken from the bitcoin wiki


How will the 2mb hard fork be implemented? With regards to SegWit2x/BIP 91. If SegWit is successfully implemented around Aug 1 what is required from the miners in November to implement the 2mb hard fork successfully? Is it also a minimum 80% signalling via blocks on predetermined dates?

August 1st has nothing to do with BIP 91, nor will segwit become active on August 1st due to either of BIP 148 or BIP 91. The current projected date for segwit to become active (assuming that BIP 91 is enforced) is August 24th.

The segwit2x hard fork to 8 MB block weight is currently implemented as occurring 12960 blocks following the activation of segwit. For this to happen successfully, all nodes and miners must upgrade to software that implements segwit2x. The activation will be by flag block; there is no miner signaling.


Help------ -dumpprivkey gives key connected to different address So I bought my first bitcoin yesterday and I generated my first address which is the one I used to receive the bitcoins. Now since I am still trying to sync, I have no idea if I received these coins as I cannot access the address using the directory. I checked blockchain and it says the address received the money but I can only view it as a spectator as Bitcoin Core is giving me the wrong private key. When i bounce between commands it always comes back to this random address that it has now added to my list of receiving address'. I find this very odd as the address that received the money is part of the address' connected to my wallet, but its as if the first address was overridden or something. Do you guys think there is any hope? Any insight is much appreciated thanks

You can install a lightweight wallet to your phone, this will work much faster than since it doesn't need to download the full blockchain and verify it.
Then you can import the private key and you will be able to use your bitcoins.

Some options:

electrum.org
exodus.io
Mycelium
GreenAddress

Not all of them support all operating systems but together they cover Windows, Mac, Linux, Android and iOS.


Proof of Work: email versus bitcoin I have read

"Hashcash is a proof-of-work algorithm that requires a selectable amount of work to compute, but the proof can be verified efficiently. For email uses, a textual encoding of a hashcash stamp is added to the header of an email to prove the sender has expended a modest amount of CPU time calculating the stamp prior to sending the email. In other words, as the sender has taken a certain amount of time to generate the stamp and send the email, it is unlikely that they are a spammer. " (https://en.wikipedia.org/wiki/Hashcash)

Then, in bitcoin, it seems natural that the senders engage in the proof of work instead of miners. Why it is not so?

Proof of work helps to solve the issue of transaction ordering: miners must create blocks that contain an order of transactions, and each block builds upon the last. Thus all bitcoin transactions are ordered, and this is required in order to resolve any potential transaction conflicts.

As an example: in the case of a double spend, which transaction is actually valid, and which should be discarded? A simple way to resolve this question is to say "the first transaction is valid, the second is not", but this solution requires the network to be in consensus regarding the ordering of all transactions.

In the case of email, ordering of messages is not critically important, so the inclusion of a POW has a slightly different primary function: to increase the cost of sending an email, in order to discourage spam messages.

    Then, in bitcoin, it seems natural that the senders engage in the proof of work instead of miners. Why it is not so?

Transaction ordering is important, but keep in mind that it is not trivial to reliably keep a decentralized network in consensus. Each transaction could include a proof-of-work, but this alone is not enough to give the transactions a well-defined order. Proof-of-work establishes a way to ensure resources were spent, but on it's own is not sufficient to establish an ordering of data.

Bitcoin solves this by grouping transactions into blocks, and each block references the one before it. You can imagine this as a sort of 'decentralized clock', where the smallest increment of time is one block. For transactions to function similarly, each transaction would have to reference the one before it, thus establishing an order. This would lead to a whole host of latency issues, higher rates of 'orphan transactions', potential for spam and DOS attacks, etc.


Transaction created, but txid not found on blockchain explorers Transaction created as same others, but status - 0/unconfirmed
And txid nod found in block explorers
Transaction ID: e9c858f852a1de7c70e6f8377f2147f3def1d4b1d85a5947d028bb9c13450318

How to succefuly complete this?

After opening the RPC debug menu, you can do getrawtransaction e9c858f852a1de7c70e6f8377f2147f3def1d4b1d85a5947d028bb9c13450318, and then paste the raw hex transaction to https://www.blockchain.com/btc/pushtx.


Transaction in orphaned block question This is a theoretical question. Assuming that a transaction (TX_A) with me on the receiving end gets added to the blockchain, I should be able to spend the amount I received. So I go on and spend it on another transaction (TX_B). What if TX_A gets orphaned due to forks? What happens to TX_B?

What if TX_A gets orphaned due to forks? What happens to TX_B?

It will be considered invalid, and your Bitcoin will not be spent. It will only be considered valid on the other forks, assuming they don't also invalidate the block. Usually the forks, if they are trying to play by the rules of the Bitcoin network, will also invalidate the block because the longest chain is always the valid chain.

Also, this should be referred to as an extinct block, see https://bitcoin.stackexchange.com/a/5869/60443


How is 6 LTC blocks "more secure" than 6 BTC blocks? This video claims that Litecoin is more secure than Bitcoin.

If the only differentiator between LTC and BTC is SCrypt, then I don't see how a merkle chain of 6 blocks would be more secure than the other.

Can someone explain the details of why he thinks this the case?

TL;DR: He compares one hour worth of transaction blocks, not six blocks. I.e. he compares the security of 6 blocks in the bitcoin network opposed to 24 blocks in the litecoin network.

In the video the host reads from a sheet with calculations that is supposed to prove that Litecoin is more secure than bitcoin. The calculation is based on the assumption that a 51% attacker wants to mine one hour worth of blocks with 35% of the mining power. Finally, he concludes that 8 transaction blocks in the litecoin network offer a similar security as 6 blocks in the bitcoin network. I.e. block to block litecoin isn't securer than bitcoin, however it reaches the same level of security in less time.

I can't comment in how far the presented numbers are factual (I didn't repeat the calculation), however I am not convinced of the conclusion "litecoin is magnitudes more secure than bitcoin". A 51% attack does not require an hour worth of blocks, but rather a specific number of blocks, in which even the host tells us that Bitcoin is more secure.


A read only balance tracker Is there an app where I could add my public keys for several alt-coins that I have, to see the current balances. Kind of like a multi-currency wallet/tracker, but read-only.

several approaches, just wondering about the public keys, that you mention... wouldn't you have "amounts", that should be multiplied by current value (in Euro or Dollars) per currency? Then this:

http://www.coindetail.com/

alternativly the el-cheapo version at the command line, which I cut&paste into an ods (xls) or similiar:

#!/bin/sh
####################################################################
### an 'el cheapo' approach to fetch data from coinmarketcap.com ###
####################################################################

log_fn=ccy_values.log

echo "`date '+%Y-%B-%d'`"                       > $log_fn
echo "`date '+%H:%M'`"                         >> $log_fn
echo "running ccy_values.sh on `hostname -s`"  >> $log_fn
echo " " >> $log_fn

today="`date '+%y%m%d%H%M'`"

wget -q -O - https://api.coinmarketcap.com/v1/ticker/bitcoin/?convert=EUR   > /Data/tmp/tmp_$today.tmp
wget -q -O - https://api.coinmarketcap.com/v1/ticker/ethereum/?convert=EUR >> /Data/tmp/tmp_$today.tmp
wget -q -O - https://api.coinmarketcap.com/v1/ticker/aeon/?convert=EUR     >> /Data/tmp/tmp_$today.tmp
wget -q -O - https://api.coinmarketcap.com/v1/ticker/siacoin/?convert=EUR  >> /Data/tmp/tmp_$today.tmp
wget -q -O - https://api.coinmarketcap.com/v1/ticker/storj/?convert=EUR    >> /Data/tmp/tmp_$today.tmp
wget -q -O - https://api.coinmarketcap.com/v1/ticker/storjcoin-x/?convert=EUR    >> /Data/tmp/tmp_$today.tmp
cat /Data/tmp/tmp_$today.tmp | grep -e "id" -e "price_btc" -e "price_eur" | sed -e 's/"//g' -e 's/,/ /g' > $log_fn

# create terminal output
tail -n 18 $log_fn | awk 'BEGIN { print "Currency (source: coinmarketcap.com)\tConversion Rate (Bitcoin)\tin EUR"} { ORS=""; print $2; if( NR % 3 == 0) print "\n"; else print "\t";}'


How do I receive the payment? And the payment request, if i have not been paid.
Do what it is to have not come still pay?
How do I receive the payment?

If you have not received the Bitcoin payment you are expecting, contact the sender and ask for the transaction ID.

You can copy the transaction ID into a blockchain explorer like blockchain.info or https://www.blocktrail.com/ to track the payment. If you cannot see the transaction ID, the send never sucessfully broadcast the transaction to the Bitcoin network.

If you can see the payment but it has not confirmed you will be able to tell if the problem is related to the transaction fee being too low, the BTC being sent to the wrong address or something else.


Why isn't the price of BTC rapidly growing due to WannaCry? This occurred to me today: the ongoing ransomware attack (started on May 12) caused by the WannaCry virus infected over 230 000 computers so far (source: Wikipedia). This probably means that a lot of these people (and/or companies) will pay the demanded price in Bitcoin, which, intuitively, should lead to a rapid growth of BTC value.

However, as it can be seen in the image below (BTC-USD chart taken from Kraken), this isn't happening. This is slightly confusing, so I'm looking for an explanation.

I've read somewhere that around $6000 had been paid in total; at roughly $500 per ransom that's 12 people who actually paid. That's a speck in the ocean.


Is it possible to get a service provider , which provide stable, not-changeable BTC address. My new employer prefers Bitcoin as the way of salary payment, but the address keeps changing, is it possible to get a non-changeable on, or is there is any other way to transfer bitcoins from one person without entering new address every time?

With most providers, an address should remain valid indefinitely.  This would certainly be true if you use your own software wallet, instead of relying on an online provider.  If you give your employer one address, they can make transactions to that address as many times as they want, and you'll receive those coins.

It is usually recommended to use fresh addresses for each transaction, because it is better for privacy, and makes it harder for other people to track your activity.  But it isn't required by the Bitcoin protocol.

If your employer (or their payment processor) insists on being given a fresh address for each payment, that is their decision, not a technical requirement of Bitcoin itself; you'd have to take it up with them.


Unable to get private key for Blockchain wallet I am new to BTC and I have a question: How to get private key from Blockchain wallet for a "Watch only" address? I have been trying for days with no positive results. Thanks.

You have to have that private key already. You cannot derive it from the public address. A watch-only address is an imported address.

If you've imported it from a paper wallet, check for the private key that should be printed on the same paper. You can scan the private key and upgrade the watch-only address to one that you can spend from as well.

If you imported some address you do not have the private key of, it will remain a watch-only address for you forever.


Why does P2Pool show up on BitcoinWatch.com if it's P2P? I was wondering if P2Pool is decentralized why does it show up on the BitcoinWatch pool distribution graph?

I thought it would show up under "Unknown" but I guess this is only solo miners? Or some dark pool?

And "Other Known" I assume is a selection of small pools whose hash rate is too small to have a visible slice on the graph?

EDIT: It's currently not visible on the graph on BitcoinWatch but I'm certain I saw it on there not long ago so I will upload an image when I see it again.

All miners in P2Pool mine "solo" but distributing the reward between all its peers, hence having both advantages of solo mining and pooled mining. The reward distribution is build into the block itself, you can't mine such a block to change it later to give yourself all the reward, nor will the P2Pool accept shares that don't contain reward redistribution.

If it doesn't show as a pool it's encased into "other known".


First bitcoin payment, sent X BTC, but transaction amount on blockchain.info shows as more than 2X? I sent 0.01047 BTC through coinpayments.net using electrum.

First I selected minimum fee option, then I went back and selected one level higher as the fee tier.

My electrum wallet and blockexplorer.com show different wallet balances after the transaction. This is how the transaction and wallet look like in electrum:

However online blockchain explorers tell otherwise:

Wallet: https://blockexplorer.com/address/1HNN4AZkeupaTT5675k8s7XT4YCLUDpybK
Transaction: https://blockexplorer.com/tx/3437ff74196c8f5b4b348c636a88f84773577c47979a6941ef378b79044abe76

I also recognized at the above transaction link that one of the outputs is "unspent" and the other one "spent".

Also under blockchain.info link (https://blockchain.info/tx/3437ff74196c8f5b4b348c636a88f84773577c47979a6941ef378b79044abe76) it says "Estimated BTC Transacted     0.01047 BTC" although a few lines above the transaction amount shows as: 0.02217459 BTC

Can someone explain to me what this is? Have I lost some of my bitcoins?

The amount you sent (0.01047) plus transaction fee (0.00054597) totals 0.01101597. This is how much was spent from your wallet balance (0.09079308) leaving you with 0.07977711.

You wallet balance consists of multiple bitcoin addresses. What you are seeing on Block Explorer is that one of the addresses in your wallet containing 0.02272056 was used, from which the transaction amount 0.01101597 was deducted, leaving 0.01170459, which was transferred to a different address back into your wallet. 1Gntc8EwpUXEhc7yAJsD25Y9YEBYTn6TnQ is a change address for your wallet - that balance is still yours.

The main difference is that Electrum is showing you the total balance of your wallet, but Block Explorer is showing you only the balance of the individual bitcoin addresses from your wallet that were used to make the transaction, including the change going back into your wallet.


Given the recent <0.8 bug, when can we safely have larger block sizes? Given the <0.8 bug and subsequent fork happened because of a particularly large block, does this mean that large blocks can not be used until the large majority of the community switches to 0.8?

Also why was the solution to push the 0.7 chain instead of 0.8?

I don't think anyone known exactly what the problem is, yet (note to future readers: the flaw was discovered just few moments ago).

I found this on the #bitcoin-dev IRC channel:

  sipa:  Diablo-D3: just saying that the breaking block had 1700
  transactions, but affected over 5000 block index entries

It's probably is a problem with "Berkeley DB" (0.8 use LevelDB and this is could be why 0.8 isn't affected).

Also why was the solution to push the 0.7 chain instead of 0.8?

The 0.7 chain is accepted by both 0.7 and 0.8 clients/miners. The 0.8 chain is only accepted by 0.8 clients/miners. So to avoid creating a (larger) fork, most 0.8 mining pools have downgraded to 0.7


How does bitcoin work from a technical computer science cryptography perspective? How does the cryptography science behind bitcoins work to make it robust(reliable , scalable).
I am interested in technical explanation with cryptography math and not just conceptual explanation.

Take a look at this Whitepaper by Satoshi Nakamoto: http://bitcoin.org/bitcoin.pdf


Bitcoin - Technical difference between P2PKH and P2SH address generation? I  was convinced that the only difference between the generation of addresses starting with '1' and '3' was simply changing the prefix added to the digest from 0x00 to 0x05 after the ripemd160 part.

Although the addresses that i get do not match the addresses from Bitcoin Core wallet, when import the same private key, and also from the https://segwitaddress.org/.
Does the prefix 04 remains the same or also changes?
There's something i am missing. Could you please help? Thank you.

[EDIT]

This is the method i have at the moment and still does not work. I am surely misinterpreting something..

def getPublicAddress(self, digest):

    oSk = ecdsa.SigningKey.from_string(digest, curve=ecdsa.SECP256k1)
    oVk = oSk.get_verifying_key()

    hexlify = codecs.getencoder('hex')
    self.pubkey = str(hexlify(b'\04' + oVk.to_string())[0].decode('utf-8'))

    ripemd160 = hashlib.new('ripemd160')
    keyhash = hashlib.sha256(codecs.decode(self.pubkey, "hex")).digest()
    ripemd160.update(keyhash)

    redeem_script = hashlib.new('ripemd160')
    redeem_script.update(b'\x00\x14' + ripemd160.digest())

    prefix = b'\x05'
    m = prefix + redeem_script.digest()
    checksum = hashlib.sha256(hashlib.sha256(m).digest()).digest()[:4]

    return base58.b58encode(m + checksum)

P2PKH, P2SH, and Segwit are all different address types. Segwit and P2SH addresses are not the same.

P2PKH and P2SH addresses are generated in a similar way. P2PKH takes the hash160 of a public key (RIPMED160 of the SHA256 of the public key), appends the version byte of 0x00 to the hash160, and Base58 Check encodes it.

P2SH addresses are the Base58 Check encoding of the hash160 of a script (known as the redeemScript). It uses a version byte of 0x05 instead. The rest of the encoding is the same, just Base58 Check encoding.

For Segwit addresses, there are multiple types. There are native segwit addresses which follow the Bech32 standard. There are also P2SH wrapped segwit addresses.

For a P2WPKH (pay to witness pubkey hash) wrapped in a P2SH address, the redeemScript is 0x0014 <hash 160 of the pubkey>. That redeemScript is hashed  and encoded in the typical P2SH way.

For a P2WSH (pay to witness script hash) wrapped in a P2SH address, the witnessScript (redeemScript but for segwit addresses) is first hashed with SHA256. Then the P2SH redeemScript is 0x0020 <SHA256 of witnessScript>. The hash160 of this redeemScript is then encoded in the typical P2SH way.

As for your code, you are appending 0x04 to your public key which is simply incorrect. The 0x04 is not part of the address encoding, it is part of the public key encoding itself. Your public key generator should already be doing this for you. Note that if the public key is compressed that the prefix byte will be either 0x02 or 0x03 (depends on the Y value of the public key) instead of 0x04 which is for uncompressed public keys.

[Technical difference - Example solution]

`

    def hash160(self, v):
        r = hashlib.new('ripemd160')
        r.update(hashlib.sha256(v).digest())
        return r

    def doublehash256(self, v):
        return hashlib.sha256(hashlib.sha256(v).digest())

    def ecdsaSECP256k1(self, digest):
        # SECP256k1 - Bitcoin elliptic curve
        sk = ecdsa.SigningKey.from_string(digest, curve=ecdsa.SECP256k1)
        return sk.get_verifying_key()

   def publicaddress1(self):

        prefix_a = b'\x04'
        prefix_b = b'\x00'

        digest = self.privkeyhex.digest()

        p = prefix_a + self.ecdsaSECP256k1(digest).to_string() # 1 + 32 bytes + 32 bytes
        self.pubkey = str(binascii.hexlify(p).decode('utf-8'))

        hash160 = self.hash160(p)

        m = prefix_b + hash160.digest()
        checksum = self.doublehash256(m).digest()[:4]

        self.pubaddr1 = base58.b58encode(m + checksum)

    def publicaddress3(self):

        prefix_even = b'\x02'
        prefix_odd = b'\x03'
        prefix_a = prefix_odd
        prefix_b = b'\x05'
        prefix_redeem = b'\x00\x14'

        digest = self.privkeyhex.digest()

        ecdsa_digest = self.ecdsaSECP256k1(digest).to_string()

        x_coord = ecdsa_digest[:int(len(ecdsa_digest)/2)]
        y_coord = ecdsa_digest[int(len(ecdsa_digest)/2):]

        if (int(binascii.hexlify(y_coord),16) % 2 == 0): prefix_a = prefix_even

        p = prefix_a + x_coord

        self.pubkeycompressed = str(binascii.hexlify(p).decode('utf-8'))

        redeem_script = self.hash160(prefix_redeem + self.hash160(p).digest()).digest() # 20 bytes

        m = prefix_b + redeem_script
        checksum = self.doublehash256(m).digest()[:4]

        self.pubaddr3 = base58.b58encode(m + checksum)`


Script - OP_IF etc. clarifications Description of the OP IF is a bit vague on the wiki. Where does one get statements for the op for? Are they coming from the stack, or from somewhere else? Are there any available examples of how a script using that op code looks like?

The statements are not on the stack, they're in the script. They start immediately after the OP_IF. They end at the first OP_ELSE or OP_ENDIF, assuming there isn't a nested OP_IF or OP_NOTIF. So it looks like this

// script to put a number on the stack
OP_IF
// script that runs only if the number isn't zero
OP_ENDIF
// script that runs no matter what

or:

// script to put a number on the stack
OP_IF
// script that runs only if the number isn't zero
OP_ELSE
// script that runs only if the number is zero
OP_ENDIF
// script that runs no matter what

You can read a bit more about in this chat transcript.


How much should I spend when I send BitCoin to other people using electrum wallet? The fee displays "Target: Within 10 blocks, Current rate: 2.5 sat/byte" when I use electrum wallet to send BitCoin to other people.

I can't understand completely the means of "Target: Within 10 blocks, Current rate: 2.5 sat/byte" ?

How much should I spend if I send one BitCoin to other people ? Thanks!

I hope you give me the details about how to calculate the fee!

Added Content

To Abdussamad: Thanks!

1: The sat is 0.00000001 BTC , right?

2: I send one BTC to other people, how can I know the byte?
   If I know the byte, I can calculate the fee= byte * 2.5* 0.00000001 BTC

Does this make sense to you?

---------|-------------------

low/slow........high/fast

The further left you move the slider the lower the fee you pay and the longer it'll take to confirm. The further to the right you move the slider the higher the fee and the faster it'll confirm. If you still don't get it go to tools > preferences > fees tab and check edit fees manually. Now on the send tab you'll be able to see the whole calculation including the absolute amount of fees you will pay for a particular transaction.


How is pool hashrate share name known? Since it’s not possible to know mining pools nodes addresses, how do we know the that a specific node owing 15% of share belongs to btc.com for example ?

The only way to know which pool has mined a particular block is by identifying data that miners include in the coinbase transaction. However care must be taken as this data can be faked. Also many mining pools omits this, which is why there are many blocks that are from "unknown" miners.

Let us take the last block mined by BTC.com, which is #572639. To look at the coinbase data, you will need to look at the first transaction included in the block which is 806e80560f7c87059b9103d8bd4fca7be14810af47940c40464276d971fd2625. After you decode this transaction you will get the following input:

"vin": [
        {
            "coinbase": "03dfbc080479b0bc5c672f4254432e434f4d2ffabe6d6d6b01cdd5d0aa44ffa14f158f90119afef5e5440b5f6ff324e74a988e6db4294d0100000000000000cb2b382f00005a2197460000",
            "sequence": 4294967295
        }

In the coinbase data, pay close attention to the part 5c672f4254432e434f4d2f. This data is included in all blocks mined by BTC.com pool. If you decode this you get '\\g/BTC.com':

>>> pool_data = '5c672f4254432e434f4d2f'
>>> bytes.fromhex(pool_data).decode()
'\\g/BTC.COM/'


What is needed to generate a bech32 address? So I wrote a vanity address generator in c# with the NBitcoin lib. When I use the private key used to generate the address and input it in Mycelium it outputs a different address. This does not occur when working with legacy addresses, so I'm guessing I need something more than just a private key in order to generate a segwit address. Was it a redeem script or something? How can I make sure I get the same address in a wallet when I input the privkey?

var bitcoinPrivateKey = new BitcoinSecret("cPof7e5g6xfgB6AZrc6XVTVwA4efLJurh9kVxa6FRChbr8Jyqaon", Network.TestNet);

            var legacy_address = bitcoinPrivateKey.GetAddress(ScriptPubKeyType.Legacy);
            var segwitp2sh_address = bitcoinPrivateKey.GetAddress(ScriptPubKeyType.SegwitP2SH);
            var nativesegwit_address = bitcoinPrivateKey.GetAddress(ScriptPubKeyType.Segwit);

            Console.WriteLine("Private Key :" + bitcoinPrivateKey);
            Console.WriteLine("Legacy Address :" + legacy_address);
            Console.WriteLine("Segwit-P2SH Address :" + segwitp2sh_address);
            Console.WriteLine("Bech32 Address :" + nativesegwit_address);

Mycelium testnet bitcoin wallet:


bitcoind rpc interface, generate method deprecated in version 0.19.0 (latest) How to generate a block in the new version of bitcoind.

  bitcoin-cli -regtest generate 1

The above command no longer works with the latest bitcoind package

I want to confirm a transaction I have executed under the regtest mode for bitcoind, hence generating a block to confirm the tx.

generate was deprecated and removed in favor of generatetoaddress.


What is the cause of "version handshake timeout"? This keeps happening over and over and results in me disconnecting from peers.

You’re connecting to peers that aren’t responding to you in a sensible time period so you disconnect them and try somewhere else. This isn’t really indicative of anything other than some nodes not being particularly useful to connect to.


Multisig refund transaction flaw in Lightning Network talk I was watching Tadje Dryja's talk at SF Bitcoin Devs conference on transaction malleability, which formed part of the basis behind the Lightning Network.

At 17'45", I saw this example. Prior to SegWit and even before considering malleability, how is it possible to even sign a refund txn without knowing the TX-fund signatures? The funding signatures from both parties are required to create the txid that is referenced in the TX-refund input. However, if this information is known, one of the parties can send the funding txn to the network before a refund txn is ever signed, thus forcing the other party's funds into the multi-sig contract. Am I missing something?

(I think SIGHASH_NOINPUT was introduced to get around this exact limitation.)

Yes, you are correct. Joseph Poon and Tadje Dryja in their Lightning Network whitepaper proposed the SIGHASH_NOINPUT flag to prevent transaction malleability flaw hampering the creation of commitment transaction prior to funding transaction. However, with the deployment of SegWit in 2017, NOINPUT was not longer needed as signatures are not part of the txid construction in a SegWit transaction. Since signatures did not form the part of the txid calculation, it solved the ECDSA signature malleability issue that NOINPUT was trying to solve. Thus SegWit deployment allowed us to create the commitment transaction even before signing the funding transaction.

Lightning Network specs have gone a sea change since that paper was published way back in early 2016. I have tried to highlight below how the parties communicate the signing of the transactions as is today and proposals of the future when opening up a channel with each other.

In the current specs (BOLT 1.0), only one party is allowed to contribute bitcoins to the channel. This simplifies the process of exchanging signatures and creating the commitment transaction prior to the funding transaction. Let us say Alice and Bob wants to open a channel. Alice will broadcast the funding transaction only when she has received Bob's signature for the commitment transaction that she holds. Since Alice is the sole funder over here, she has all ammunition to create the funding transaction after Bob exchanges his funding pub key. She creates and signs the transaction, calculates the txid and then shares it with Bob along with her commitment transaction signature that Bob is holding.

Currently there is a proposal (BOLT 1.1) for allowing both parties to contribute funds to the channel. Both parties help each other to build the funding transaction by sharing the inputs and outputs of the funding transaction with each other that they plan to use to fund the channel. It is important to note that they share all information apart from the signatures for those inputs. Once both of them have shared all the inputs and outputs, the parties have enough information to calculate the funding txid. This is because SegWit transactions signatures are not included in calculation of the txid (as mentioned before). This allows us to build the first commitment transaction even before the funding transaction has been created.

Note: Currently, as is, Lightning Network implementation does not require the NOINPUT flag. But to implement the Eltoo payment construction there is a proposal to introduce SIGHASH_NOINPUT. In a nutshell, Eltoo allows us to get rid of the penalty transactions and reduce a lot of overhead on maintaining the channel states. If you are interested you can read the discussion of this proposal on the Lightning mailing list.


How can I find out if a transaction used a specific vout as its input? I want to know if a certain output is spent. I am not using bitcoind, I do not have a gettxout RPC call available. How can I learn if a vout is referenced as an input somewhere in the blockchain or accepted mempool?

I don't mean just for my wallet, I want to know if an output has been spent on the network somewhere.

You need a way of querying the unspent pool in order to do this. A workaround is to lookup the transaction that is being referenced via some public api, blockchain etc, and check the referenced output as they usually mark them as spent/unspent. You can do this programatically by querying for all unspents for the addresses referenced by the output in question and filtering it for the one you want.


How can I create a multi signature 2-of-3 transaction? Can somebody help me with step-by-step list of how to create a multi signature 2-of-3 transaction?

Actually, both receiving funds at and spending funds from a multi-sig address is already supported.

You can find the code to do so, plus comments, by Gavin:

TwoOfThree.sh


How to get output linked to input in SPV node? We're working on bitcoin SPV wallet. After setting bloom filter, we only get merkle blocks, and transactions that match the hashes we set plus some false positives.

If a transaction is where we SEND coins, we can calculate a fee of that transaction, because we also HAVE previous transaction holding an output we spent.

But, if a transaction is where we RECEIVE coins, then we can't calculate the fee. Because, we DON'T HAVE previous transaction holding someone's output which he spent.

As far as I know, there's no way to request single transaction from peers.

How can we get previous transaction or at least it's output's value?

You can't get a previous transaction via the p2p network based on the txid.

If you use BIP37, fees for received transactions are difficult to calculate in a decentralised way.

Have a look at BIP158 which will probably be available on the network soon.
It has a feature to find the block of your previous txout as well as it doesn't have the privacy problem of BIP37.


How do exchanges use cold bitcoin wallet while still able to automate transfers? Some exchanges mentions they use a cold wallet to keep the private key. As far as I understand cold wallet is a wallet either in an offline machine or kept in hardware.

However, it appears that transfers can still be made online on these exchanges and the underlying system will automate the signing of transaction.

How do exchanges able to maintain a cold wallet while still able to automate the process? Is it by setting up local network with limited access or by other means?

The exchanges that use cold storage keep most of their coins offline, but do have a small percentage of funds that is necessary for normal business in online wallets.


The cost of restarting a lightning channel I have some questions about the cost of maintaining a lightning channel between two people. For this question, let's assume that the blockchain mining fee is $1 per transaction.

Question 1: Suppose Alice wants to send Bob 1 mBTC per day, for 100 days. Without lightning, this would have cost $100. With lightning, she has to open a channel to Bob, and after 100 days, close the channel. Is it true that opening the channel and closing the channel each costs $1, so that the total cost is $2?

Question 2: Suppose Alice wants to send Bob 1 mBTC per day, for 200 days, but, she does not have all 200 mBTC now - she only has 100 mBTC (she will get the additional 100 mBTC after 100 days). So, she has to open a channel to Bob, after 100 days close the channel, open a new channel, and after additional 100 days, close the second channel. Is it true that the total cost now is $4?

Question 3: Suppose Alice from question 2 wants to reduce the cost of channel restart, so she says to Bob: "Instead of closing and re-opening the channel, I'll send you 100 mBTC through the blockchain, and you will send me 100 mBTC through the lightning channel. So the restart will only cost us $1 and the total cost will be only $3". Can this trick be done securely, so that neither Alice nor Bob can cheat?

Question 1

  Is it true that opening the channel and closing the channel each costs $1, so that the total cost is $2?

Yes.  You will still need opening and closing transactions for the channel, and will have to pay the network fee for each transaction.

Question 2

  So, she has to open a channel to Bob, after 100 days close the channel, open a new channel, and after additional 100 days, close the second channel. Is it true that the total cost now is $4?

Maybe.  If you were talking about a single direction payment channel, the answer would be yes, but lightning channels are bi-directional.  A channel only has so much money in it to begin with.  In your situations, we are assuming that Alice is fronting all upfront money for the channel, but this doesn't have to be.  It could just as easily be both Alice and Bob who split the funds that are tied up in their channel.  Let's say they both put 100 mBTC into opening the channel.  Now the most that can ever travel in either direction is 100 mBTC, so if money only ever flows from Alice to Bob, then a new channel will have to be opened when Alice's upfront money is all sent.

What you have forgotten is that in the lightning network, Alice and Bob aren't just terminal nodes...they are also hubs.  Other transactions from other parties can be routed over their channel.  So let's say that during this time period, Dave wants to pay Charlie.  Dave has a channel with Bob, and Charlie has a channel with Alice.  Now our network looks like this:

Charlie <----> Alice <----> Bob <----> Dave

Because the payments from Dave to Charlie put money back on Alice's side of the channel, Alice could very well pay Bob the full 200 mBTC without having to close and re-open the channel.  This is effectively how the traditional banking system clears transactions using deferred net settlement.

It's also important to note that if the channel is getting lopsided, Alice and Bob can incentivize routing in one direction by lowering the fee they charge to use their channel.  As you can see, it is often even in their best interest to charge a negative fee rather than incur the costs of re-opening a channel.

Question 3:

  "Instead of closing and re-opening the channel, I'll send you 100 mBTC through the blockchain, and you will send me 100 mBTC through the lightning channel. So the restart will only cost us $1 and the total cost will be only $3". Can this trick be done securely, so that neither Alice nor Bob can cheat?

Hopefully, you could avoid this situation as illustrated above.  If not, it sounds like Alice and Bob will have to have either 1) trust in each other, or 2) have some other sort of smart contract in place (which would likely lead to even more transaction fees, not less).  I don't see this as a viable or cost effective solution.  It would be best to incentivize others to use the channel to restore funds on Alice's side of the channel.


How does difficulty is defined for block '55798'? I know that the formula for calculating the difficulty is below -

Difficulty = T (max) / T
Where T (max) = 1d00ffff in decimal it is 486604799.

As you can see in the above screenshot the difficulty of block '55798' is 12.85. I'm trying to calculate this value using formula but getting the different result.

D = T (max) / T

When I put the correct values in the formula, It becomes like -

D = (486604799 / 471067731) = 1.03

I don't know why I'm getting the different difficulty. The correct value is 12.85. Can you please let me know the reason of this?

How to calculate difficulty from Bits fields (which is stored in block).

Convert value to hex: bits=471067731 -> 0x1c13ec53
Split hex value, take 8 high bits (0x1c), and 24 low (0x13ec53)
Use formula to get 256-bit target value: T = low * 2 ^ (8 * (high - 3)). In our case it will be: T = 0x13ec53 * 2 ^ (8 * (0x1c - 3)) = 0x0000000013ec5300000000000000000000000000000000000000000000000000
Divide highest possible target Tmax (0x00000000ffff0000000000000000000000000000000000000000000000000000) by our T. If we truncate zeros, it will be: 0x13ec53 / 0xffff00 = 12.849

Network recalculates difficulty every 2016 blocks (2 weeks). This is how 12.85 is getting recalculated from block timestamps:

block -  diff - time stamp
...
52415 -  7.82 (2010-04-21 21:50:53)
52416 - 11.46 (2010-04-21 21:52:52) <- difficulty update
...
54430 - 11.46 (2010-05-04 09:39:19)
54431 - 11.46 (2010-05-04 09:40:03)
54432 - 12.85 (2010-05-04 09:46:16) <- difficulty update
...
55798 - 12.85 (2010-05-14 16:21:05) <- your block

When network recalculates difficulty, it takes time to mine the latest 2015 blocks (due to bug in code, it should take 2016). In our example, it would be:

2010-05-04 09:40:03 - 2010-04-21 21:52:52 = 12.491 days

In normal scenario 2016 block should be mined in 14 days. So, new difficulty:

11.46 * 14 / 12.491 = 12.844


What is the minimum investment for Bitcoin? I'm interested in how much money do I have to invest if I want to buy Bitcoins? Is there any minimum?

On the whole, there is no minimum investment for Bitcoin, as it is not a security such as an ETF or mutual fund purchased through a brokerage or management firm.

What minimum purchases exist on Bitcoin exchanges are merely requirements set by each individual exchange to reflect the minimum purchase/sale that they feel is necessary to cover their overhead for each transaction.

Purchasing from an individual trader, you'll find that there is generally no such minimum, aside from whatever minimum they set to make it worth the time and travel expense for a rendezvous.


Creating an OP_CSV transaction with bitcoinjs I'm working on a tool for timelocked contract generation. My redeem script looks like so:

OP_HASH160 <revocationHash> OP_EQUAL
OP_IF
    <bobPubKey>
OP_ELSE
    <timeDelay> OP_CHECKSEQUENCEVERIFY OP_DROP
    <alicePubKey>
OP_ENDIF
OP_CHECKSIG

The goal is that Alice can spend the funds after a time delay, while Bob can spend them at any time by proving knowledge of the hash preimage.

Spending through the revocation hash is easy enough. However, I'm having trouble constructing a transaction that spends based on the timelock is proving more difficult. Essentially, my questions are:

What does the <timeDelay> value represent? How can I e.g. lock the funds for 2 blocks?
From what I've read, the sequence number on the spend transaction needs to be set. But what should it be set to?
How do I practically implement this using bitcoinjs-lib or another library?

In bitcoin-js you could do something like this

aliceToBobRedeemScript =  bitcoin.script.compile([,
bitcoin.opcodes.OP_IF,
  bitcoin.opcodes.OP_HASH160,
  aliceSecretHash,
  bitcoin.opcodes.OP_EQUALVERIFY,
  bobPrivKey.getPublicKeyBuffer(),
bitcoin.opcodes.OP_ELSE,
  bitcoin.script.number.encode(10),
  bitcoin.opcodes.OP_NOP3,
  bitcoin.opcodes.OP_DROP,
  alicePrivKey.getPublicKeyBuffer(),
bitcoin.opcodes.OP_ENDIF,
bitcoin.opcodes.OP_CHECKSIG
]);

there is some sample code on an old atomicswap demo, it doesnt have csv but shows other things such as how to sign custom transactions etc

https://github.com/rubensayshi/counterparty-p2sh-demo/blob/master/atomic-swap.js#L163-L185


How does a miner get selected in Proof Of Stake? I am trying to understand POS. I get that POS uses currency held analogous to the hash power held in POW system. More the stake we have, more are our chances of mining the block. At various sources I read that, a miner is chosen deterministically.

Can someone please explain, how miner selection takes place. And how everyone agree on the same miner, there has to be some algorithm involved.

Quite a lot is mentioned here: https://github.com/ethereum/wiki/wiki/Proof-of-Stake-FAQ
but, I can't seem to find the answer to my query.

The minting algorithm for staking is different for various coins; for example, it is different in BlackCoin from Cardano.

There are several approaches to staking, but most of them are susceptible to "grinding attacks" and almost none of them are proven secure against every attack (only argued secure intuitively by showing that certain specific attacks do not work).

To give a concrete answer to your question, I will describe a specific case of a proof-of-stake protocol which is proven secure: the Ouroboros Praos protocol.

In the Praos protocol, you can imagine each satoshi corresponds to a public/private key pair. The Praos protocol for staking works as follows: If you are an honest staker, you look at the current date and time and round it to the nearest second (the time unit you round it to is configurable in general and corresponds to the synchronous "slots" of the protocol). Say, for example, that you get d = "2018-07-01 00:19:24". You take that date and time as input, and you sign it with your private key corresponding to your satoshi, obtaining a signature s. You then compare that signature against the difficulty target T to see if s <= T, similar to how bitcoin compares block hashes against the difficulty. If it is, then you have been "elected leader" and you are allowed to generate a block. You first generate the block contents x which consist of the transactions in your mempool as well as a pointer to the previous block. You then sign x using your public key, and produce another signature s'. You then broadcast to the network your signature s illustrating that you have been elected; the current date and time d for election confirmation; the confirmed transactions x which also include the reference to the previous block; and your signature over the block contents s'. The tuple (s, d, x, s') is the block.

Now, other validators can check that you are the rightfully elected leader. They check that s is a signature for d, that s' is a signature for x, that x contains valid transactions and points to the tip of a previous blockchain (with an older timestamp and non-conflicting transactions). Finally they must verify that you meet the target: s must be below T.

This is quite a simple protocol, but, perhaps surprisingly, it can be proven secure. This is what makes it elegant. It's also quite similar to how bitcoin generates blocks. If you are intrigued about why this protocol is secure, I encourage you to read the paper.

A few details:

It is possible for bad actors to generate multiple block contents for the same datetime that they have been elected leader. This doesn't cause a problem because honest parties will only generate blocks committing to one older block, thereby breaking ties.
It's possible that two honest parties generate a block at the same time. This is not a problem and can also happen in bitcoin. Such ties will be resolved, as long as the protocol parameters are tweaked to not allow blocks to occur very often among slots (the exact parameters are specified in the paper)
I said above that s is a "signature" on the current time d, but a technical point is that it's not a signature but actually what we call a VRF - Verifiable Random Function. This is like a signature, except it has the assurance that the output behaves like a random output (such as a perfect hash behaving like a "random oracle").


Where did https://launchpad.net/~bitcoin/+archive/bitcoin just install to? I just ran the following three commands:

sudo add-apt-repository ppa:bitcoin/bitcoin
sudo apt-get update
sudo su bitcoinuser
sudo apt-get install bitcoind

and I believe bitcoind has been installed on my Ubuntu 12.10 64Bit ec2 box, but the problem is I can't find it anywhere.

Where does bitcoin download to when installed via the ppa?

Just as all applications you install using Aptitude (apt-get), it is installed somewhere in a /usr subdirectory. However, where exactly doesn't matter because you can run those programs just by typing them in the command line.

Thus, you can launch them by typing in your Terminal either bitcoind for the server daemon or bitcoin-qt for the GUI Wallet. Also, most desktop manager automatically place a shortcut for all apps in their app menu; for Ubuntu Unity, you can just type "bitcoin" in your Dash to find Bitcoin-Qt GUI wallet app.

Just as most apps, it makes a folder in your home directory to save the data it uses. Both bitcoind and bitcoin-qt save all the block chain data in a ~/.bitcoin/ folder. You wallet is thus saved in ~/.bitcoin/wallet.dat.


How does a client decide which is the longest block chain if there is a fork? Is it only the block height or is it the effort that went into the forks? In other words: does this decision account for different difficulties?

Gary's answer is not entirely correct. When comparing two chains, their total "scores" are compared.
Each block counts as (2^256 / block_target); this is the expected/average number of attempts that were necessary to create it.

Obviously, within one series of 2016 blocks, the difficulties are all equal, so for most small reorganizations, the score will tell you the same thing as just counting the number of blocks. However, as an attacker may well try to rewrite blocks that cross the multiple-of-2016-boundary, you need to take this into account. The actual rule always favors the chains which required the most "work".


HD wallet implementation I want to create public addresses in offline browser from master public key so that owner of master private can access the funds available in child address.
but I am not able to understand how to use this bitcoinjs-lib. how to create master private key, master public key and every time i click on button it generate new child bitcoin address.

Help is appreciated

I'm doing something similar but using segwit addresses (BIP49). If you are using BIP32 with a standard derivation of m/0'/0/0 you could do something like this - See: https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/bip32.js#L35

//get a mnemonic, then seed, then root.
var mnemonic = bip39.generateMnemonic();
var seed = bip39.mnemonicToSeed(mnemonic);
var root = bitcoin.HDNode.fromSeedBuffer(seed);

//root can be transformed to your xpub and xprv
var xprv = root.toBase58();
var xpub = root.neutered().toBase58();

//You can then create the address with a derivation of m/0'/0/0
var change = 0; //0 for external (receive), 1 for internal (change)
var index = 0; //the index of the address you want to generate
var keypair = root.deriveHardened(0).derive(change).derive(index);
//or keypair = root.derivePath("m/0'/" + change + "/" + index);
var address = keypair.getAddress();

If your derivation for your addresses is m/0' (then external, then the index) Then you have the xpub for the parent m and can store xpub of m/0'/0 on the server. On the server when a user clicks the button it generates the address n/0, where n = your xpub of m/0'/0.


How to actively measure mempool? For research purposes, I want to send transactions to the Bitcoin network and measure when they are received (yes, I am aware of existing websites which have statistics about these averages, but they can't provide me with more detailed statistics).

Specifically, I want to:

Send transactions through multiple nodes that should have different outbound neighbors (I don't want all my transactions to be tunneled through the same neighbors).
Receive the transactions at other nodes under my control (for measurements), but I would like to avoid having these nodes validate the entire blockchain first.
Avoid unintended spam attack.

Should I use full nodes, half nodes, or something else? Is there a well documented and easy to read implementation that I might find useful for my purpose (C++ isn't usually my go-to tool)? Any sort of advice will be highly appreciated.

If I am not mistaken, this should not cause a spam attack since the transactions will all come from newly created coins (if that is the right term) and should be prioritized below almost all the real transactions, but please correct me if I got this wrong.

P.S. please assume I am an idiot, so spell out stuff like "oh, just use RPC"... thanks!

You should use full nodes on both sending and receiving end

Sending Tx

Use the -connect option to broadcast your tx through selected neighbours. Use https://bitnodes.21.co/ to find neighbours. Use the wallet commands in bitcoind and send a transaction to address in your own wallet

Receiving Tx

Use -walletnotify option in bitcoind to get notifcation of incoming wallet transaction. I don't think it is easy to receive mempool tx without validating the blockchain first. Anyway this is one time effort, once you have it synced on one node you can easily copy the whole .bitcoin directory to other nodes.

About language you don't need to use C++ at all. For sending tx you need to do RPC calls. This can be easily done using bash commands or you can use https://github.com/jgarzik/python-bitcoinrpc in python. For receiving, the notify script can be any language php/python, it will just get your tx id as parameter and then you can do whatever you want.

Don't worry about spam. Its difficult to spam the network unless you have lots of bitcoins to waste in tx fees. Just make sure you put enough tx fees so that it get relayed through the network. For your experiment, you can actually try with different tx fees to observe the propagation time through the network.

Let me know when your research is over. Curious to see the results :D


Bitcoin halving conflict? Is this a rumor Is there a conflict as to when the halving will occur and Bitcoin miner rewards become 12.5? Is is set in stone to happen this July or is it after a certain amount of blocks?

It is exactly at block 420000.

When block 420000 will be mined is not certain, as the block mining process is random and influenced by hashrate variation.


HASH160 to address - What am I doing wrong? I am running this code and nothing happens.

I am trying to hash160 a  script with OP_HASH160 {scriptHash} OP_EQUAL and get a P2SH address as output but not sure this is the right script to achieve this.

// OP_HASH160 {scriptHash} OP_EQUAL
var bitcoin = require('bitcoinjs-lib')
var bscript = require('./src/script')
var types = require('./src/types')
var typeforce = require('typeforce')
var OPS = require('bitcoin-ops')

function check (script) {
  var buffer = bscript.compile(script)

  return buffer.length === 23 &&
    buffer[0] === OPS.OP_HASH160 &&
    buffer[1] === 0x14 &&
    buffer[22] === OPS.OP_EQUAL
}
check.toJSON = function () { return 'scriptHash output' }

function encode (scriptHash) {
  typeforce(types.Hash160bit, scriptHash)

  return bscript.compile([OPS.OP_HASH160, f1b914051eaabf34c22d354053698e512b36, OPS.OP_EQUAL])
}

function decode (buffer) {
  typeforce(check, buffer)

  return buffer.slice(2, 22)
}

module.exports = {
  check: check,
  decode: decode,
  encode: encode
}

What am I doing wrong?
Thanks

You don't hash the OP_HASH160 {scriptHash} OP_EQUAL, that's just a template associated with P2SH addresses. You need to hash the redeem script, add version byte and checksum and then encode into base58.

Sample Python code:

def p2sh(script):
    scripthash = hash160(script)
    data = b'\x05' + scripthash
    checksum = sha256(sha256(data))[:4]
    address = data + checksum
    return base58.encode(address)


How or why "a Bitcoin address is a single-use token"? In the address wiki page it says that "a Bitcoin address is a single-use token". Do I have to understand one address is (or should be) used only once?

More over, the Address reuse page seems to confirm that. But when reading some information here, this address 1F1tAaz5x1HUXrCNLbtMDqcw6o5GNn4xqX has 641 transactions. Could you please tell the points I misunderstand.

The bitcoin addresses are permanent addresses. You can re-use the addresses if you want. But when reusing it causes privacy issue as any one will be able to find out the number of transactions or the total balance that address has. (you found out that there are 641 transactions in that address).

To avoid this, its better not to reuse address and use separate address for each transactions, so that no one will be able to see your balance in the wallet or transactions.


Variables in Coinbase Transaction & Decoding I/O Scripts I just have a few questions to help better my understanding of the coinbase transaction.

Example:

01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000

From what I know currently, the format of the coinbase transaction typically looks something like this when decoded:

TX Version:         01000000
# of Inputs:        01
Previous TX Hash:   0000000000000000000000000000000000000000000000000000000000000000
Previous Index:     FFFFFFFF
Input Script Len:   4D
Input Script:       04FFFF001D0104455468652054696D65732030332F4A616E2F32303039204368616E63656C6C6F72206F6E206272696E6B206F66207365636F6E64206261696C6F757420666F722062616E6B73
Input Sequence:     FFFFFFFF
# of Outputs:       01
Output Value (Sat): 00F2052A01000000
Output Script Len:  43
Output Script:      4104678AFDB0FE5548271967F1A67130B7105CD6A828E03909A67962E0EA1F61DEB649F6BC3F4CEF38C4F35504E51EC112DE5C384DF7BA0B8D578A4C702B6BF11D5FAC
Lock Time:          00000000

My first question:

What exactly is the "Previous Index" and why is the value of it FFFFFFFF and not 00000000? Since the previous transaction doesn't exist, shouldn't it be 0 just like the previous hash?

Second question:

From my understanding, the input script contains arbitrary data chosen by the miner when constructing the coinbase transaction and can typically be decoded into ASCII.

For example, this example input script (genesis block) decodes into ASCII as:

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

Is this correct? And is this also used when the nonce overflows as an 'extraNonce'?

Third question:

What is the input sequence? Why is it always 0xFFFFFFFF when the locktime is 0x00000000?

Final question (I promise):

What data is stored in the output script, and how can it be broken down to be decoded?

Thank you!

What exactly is the "Previous Index" and why is the value of it FFFFFFFF and not 00000000? Since the previous transaction doesn't exist, shouldn't it be 0 just like the previous hash?

Coinbase transactions must have index FFFFFFFF, which is -1.

  From my understanding, the input script contains arbitrary data chosen by the miner when constructing the coinbase transaction and can typically be decoded into ASCII.

  For example, this example input script (genesis block) decodes into ASCII as:

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

  Is this correct? And is this also used when the nonce overflows as an 'extraNonce'?

Yes, it is exactly ÿÿEThe Times 03/Jan/2009 Chancellor on brink of second bailout for banks. Any part of coinbase can be used as the extranonce.

  What is the input sequence? Why is it always 0xFFFFFFFF when the locktime is 0x00000000?

See this for details

  What data is stored in the output script, and how can it be broken down to be decoded?

It is a pay-to-pubkey output.

41 Push 65 bytes

04678AFDB0FE5548271967F1A67130B7105CD6A828E03909A67962E0EA1F61DEB649F6BC3F4CEF38C4F35504E51EC112DE5C384DF7BA0B8D578A4C702B6BF11D5F Satoshi's public key

AC OP_CHECKSIG


I created my own crypto coin. Do I have to keep my node running all the time? I created my own crypto coin.  I have two questions:

Do I have to keep my node running all the time?
Is it better to have more than one node running?

You really should not be using your own altcoin if you don't know the answers to these questions.  If you just want to experiment, you're welcome to use Bitcoin's testnet or regtest mode.  However, here are the answers anyway:

Somebody has to keep a node running all the time or new users of your altcoin won't be able to download its block chain.
The more nodes you have running (on different computers), the more capacity your altcoin will have to grow its userbase.  By default, each Bitcoin Core node can handle 125 connections (normally 8 of which will be outbound).  I assume you didn't change that part of the code, so unless you expect more than about 100 users to suddenly start using your altcoin, running one node should be sufficient.

Again, running an altcoin is not something a newbie should be doing.


Understanding the Hash Function Can someone please explain in detail the components of the final hash that determines the winner of the block?

My understanding is that the miners are taking

The Merkle Root,
The time stamp,
The prior block's hash,
Some other components??, along with
A nonce that the miner's have to guess in order for the hash of all these components, using Sha256, to have at least 18 leading zeros.

My questions are:

Am I right in my understanding so far?
Can someone explain what the other components are and what order they are input into the hash function?
Using the data available on blockchain.info about each block, can I recreate the winning hash by inputing the same data into a Sha256 calculator?

Thanks.

From the Bitcoin.org Developer Documentation, a block header consists of a:

Version
Previous block header hash
merkle root
timestamp
nBits field
nonce

In that order. So as you say, the only component missing from your list is the version and the nBits field. The version is self explanatory, but the nBits field is not. What the nBits field does is encode the current target for the difficulty algorithm:

  to have at least 18 leading zeros.

Not always 18 zeroes. The number of leading zeros changes based on how quickly blocks have been found recently, in order to keep the block time at roughly 10 minutes average despite varying hashpower on the network. As more miners join, the hashrate increases, so the difficulty does too (i.e. more zeroes are required). Another way to think about the 0's, is that the output of the SHA256, as a number, must be less than some target number. That target is encoded in the nBits field. And yes, anyone can verify that the block header hashes to a number below the target, that is how other clients verify blocks are valid, because SHA256 always produces the same output from the same input - it is deterministic, a property of all useful hash functions.


What's p2sh in decodescript RPC method ouput? Every time i call decodescript method with any input it returns p2sh

bitcoin-cli decodescript 1234
{
    "asm" : "[error]",
    "type" : "nonstandard",
    "p2sh" : "2NBbRKQ1VhLw8xeL82ynK4VUUJs9z2pj7Ca"
}

i know that p2sh is pay to script hash address, but address of what ? the given script ?

It is the address you would have to give to someone in order for them to pay to that script.


What happens to my bitcoins when I die? What happens to my bitcoins when I die?
Are they lost in the network?

This depends a lot on how you handle your wallet. If you are careful about it and make sure you have an off-site backup of your wallet (or use a deterministic or paper wallet, etc) then you can easily pass your wallet and all the coins it contains to anyone you choose in the same ways that you can pass on other property.

Of course if you're the only person with access to the wallet and have not planned anything then yes, your bitcoins will be "lost in the network."


Uses of computing power by bitcoin miners How much of what this article says is true?  I thought I had read that bitcoin miners are the ones who maintain the blockchain.  Do they also do something other than maintaining the blockchain?  In particular, things that no one would otherwise want done?

http://gizmodo.com/the-worlds-most-powerful-computer-network-is-being-was-504503726

YES.
1)They help maintain the reputation of bitcoin by showing how it "works" and demonstrating that you can make money AND THEREFORE
2)They help encourage the developement of more powerful mining rigs and the business sector that makes them AND
3)They encourage more mining activity AND
4)They increase the difficulty.

GO TO 2).

Oh, just forgot one..

5)They help keep the planet nice and warm with all the electricity converted to heat by the mining rigs (I do hate being cold !).

6)AND ALSO (see my previously posted question): The may(or may not) be effectively working for the NSA (or someone) by helping to crack and/or obtain hash results of SHA256 which may (or may not) be useful (for someone to do something) such as constructing a larger look up table for SHA256 (e.g. crack longer length passwords.).

I suppose if you own a nice big mining rig (or otherwise have "control" of someone else's) it might be more cost effective to use it to hack into something rather than mine coins so I think one answer to the question would be "Yes, but not bitcoin mining if you choose to use the rig for something else more profitable and are dishonest/criminally minded".


How can I make MultiBit go one year back and then replay the blockchain? Like a year ago, I got a some bitcoins. I was using Bitcoin-Qt back then. Because reading the whole blockchain since then takes a lot of time, I got MultiBit, created a new wallet and imported my private keys from Bitcoin-Qt.

The problem is that MultiBit only goes back a few days (looks like one day before I created my wallet in MultiBit) to replay the blockchain. So the balance shown is wrong. The function "Reset Blockchain and Transactions" doesn't help.

How can I make it go one year back and then replay the blockchain? At least I think that's what I need, I just don't know how.

Thanks in advance.

EDIT:

Thanks for the help. Yes, I have imported them all. I've just reset again. I see that MultiBit goes back to November 2013 and starts replaying the blockchain from there. But that's just too late. It should go back to January 2013 instead. I just double checked one of the receiving addresses on blockchain.info. The transaction took place on 16th of January 2013 and the money from that address hasn't been spent yet.

When you import private keys, you specify a replay date for each private key. This should be before the earliest transaction involving that address. In your case, it appears that this is not the case. (Or maybe you just need to reset again - their site says it might take up to 3 resets for the balance to be corrected.)

You should reimport your private key with the correct date specified to have the balance appear. Note that having your private key(s) in plaintext on your hard drive makes them an easier target for attackers. To be most secure, you should consider those keys compromised afterwards: securely delete the file when you're done with it, and transfer the coins to a new address and avoid using those old addresses again.

Another way of transferring the balance is to send it from your out-of-date Bitcoin-QT wallet to an address generated by MultiBit. I'm not sure if that's complicated, the wiki makes it appear simple.


cpuminer - what command line tools are required? I'm trying to run cpuminer on my Mac, though cpuminer requires a lot of command line tools - such as curl, libidn, etc. What are all of the tools required, and what is the minimum version of each I must obtain (e.g. curl 6)?

Compiled it on Linux. These are the dependencies once compiled :

$ readelf -d minerd

Dynamic section at offset 0x1c178 contains 22 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libcurl.so.4]
 0x0000000000000001 (NEEDED)             Shared library: [libpthread.so.0]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
...

That's only libcurl and glibc. Since glibc is just a standard C library, and Mac probably has its own equivalent, you can ignore that one. The only runtime requirement is libcurl.

Judging by the source code the minimum required version of libcurl is 7.10.1. You'll also need yasm for 64-bit SSE2 code generation. And of course a C compiler that can handle C99.


How do you derive the lambda and beta values for endomorphism on the secp256k1 curve? You can see a little background about this on this bitcointalk post by the late Hal Finney.

Beta and lambda are the values on the secp256k1 curve where:

λ^3 (mod N) = 1

β^3 (mod P) = 1

As seen here, in hex, N and P are:

N = FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE BAAEDCE6 AF48A03B BFD25E8C D0364141

P = FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE FFFFFC2F

The actual values of lambda and beta are easily verifiable and are:

λ = 5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72

β = 7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee

The question for me is, how do you derive this? Can someone show me step-by-step how you can figure out these values?

Also posted to the Cryptography Stack Exchange

With a bit of reverse engineering, I think I was able to see how Hal was able to get to these results.

First, it's a pretty well known result of Fermat's little theorem that if p is a prime number and g is a generator for the field Z/pZ, then:

g ^ (p - 1) = 1

Note, don't confuse this abstract generator g with the generator for the secp256k1 group G. Now, given the above equation, it's not a big leap to see that:

(g ^ ((p - 1)/3)^3 = g ^ (p - 1) = 1

Thus, we can find λ and β by first finding generators for Z/NZ and Z/PZ (N and P being the parameters given in the original question), and then raising them to the (N-1)/3 and (P-1)/3 powers, respectively. You can check that both N-1 and P-1 are divisible by 3.

The generator that it seems Hal used for λ is 3, and for β is 2. I'm not sure why he picked those, there are plenty of other good generators to choose from. It was probably on a trial and error basis.

Using sage mathematics notebook, I was able to produce the same values for λ and β.


Format of a block key's contents in bitcoind's LevelDB? I am trying to use bitcoind's LevelDB block index files (that are stored in blocks/index) to find the file (e.g. blk00029.dat) and byte position of specfic blocks.

Thanks to questions What is the database for? and What are the keys used in the blockchain levelDB (ie what are the key:value pairs)? I know where to look, however the contents of the database key for a block puzzles me. Even with the help of the source code I cannot figure out it's format.

For example for the block at height 100,000, which resides under database key b\x06\xe53\xfd\x1a\xda\x869\x1f?l42\x04\xb0\xd2x\xd4\xaa\xec\x1c\x0b \xaa'\xba\x03\x00\x00\x00\x00\x00 (block's hash string converted to bytes in  little endian order), I am getting the following content which I hexlified for readability:

87c628858c201d04009be99e5883d1e92c0100000050120119172a610421a6c3011dd330d9df07b63616c2cc1f1cd00200000000006657a9252aacd5c0b2940996ecff952228c3067cc38d4885efb5a4ac4247e9f337221b4d4c86041b0f2b5710

The first 3 bytes (87c628) seem to be the same for every block that I get from the database. I'm guessing it is some version identifier?

The last 80 bytes (or 160 characters in hex) are the block header: 010000005 ... f2b5710. They match what you get by executing bitcoin-cli getblock 000000000003ba27aa200b1cecaad478d2b00432346c3f1f3986da1afd33e506 false.

The rest is a mystery to me. I know that block 100,000 had 4 transactions, but the byte that holds the value 4 has 129 for block #1, which had only a single transaction.

Where can I find out about the format of, at least, the block keys in LevelDB?

Could it be that the format of each key depends on the version of bitcoind that serialized the contents? If so, how do I figure out which format to use?

This is the Bitcoin Core v0.15.1 source code snippet that defines the serialization of CDiskBlockIndex. The various fields are:

A varint version number of the client who wrote the record (for future extensibility). This is the 87c628 you're seeing.
A varint block height.
A varint status with various flags.
A varint determining the number of transactions in the block.
If the status field has bits 8 or 16 set, a varint determining which file (blk*.dat and rev*.dat) the block is stored in.
If the status field has bit 8 set, a varint determining the offset into the blk*.dat file where the start of the block is.
if the status field has bit 16 set, a varint determining the offset into the rev*.dat file where the start of the block's undo data is.
The block header


One node accessible under several ip-addresses? Is it possible to make one core-node accessible under several ip-addresses? (with the result that other nodes can not recognize that it is the same node under two different ip-addresses)
If this is not possible: Why?

Yes, it is possible.

You simply need to listen on the different IP addresses. What is necessary to do that and the steps required depend on your network configuration and hardware capabilities.

The trick is then to get your node to advertise all of the different IP's, which on some node software I think (from practical experience but, without going back actually to confirm) that you can just specify multiple external IP's.

I am not sure that this accomplishes much, however. If you have the bandwidth you can just modify the node to allow a high number of incoming connections and use a single IP.

Also, I suspect, others may confirm, that the default connection rules have subnet spacing integrated so that the same node will not connect outgoing to all connections in the one subnet.

If you control traffic and DNS on your network it is trivial to ruin Bitcoin via a number of methods as you could the operation of any application.


How do I create a Namecoin address? My mining pool has merged with Namecoin, and I need a Namecoin address. How do I create one ? Do I need to install another client ?

You can either install a client, or use some Namecoin-Bitcoin exchange (like BTC-E) to obtain an address. It`s generally the same as getting a Bitcoin address really, only a bit less popular.


Monitoring BIP125 transactions in the mempool Let's say I have a transaction with txid=A which has bip125-replaceable=True. If I bump the fee the original transaction will be removed from the mempool and replaced by the new one, so how do I know that the new transaction is, in fact, the same as the old one just with a higher fee? Does the txid stay the same? If so, than the answer is obvious. But if it changes, e.g. txid=B, then this is a completely new transaction. How can I establish the link to the old one?

The txid will change, because the transaction has a different effect. It will have more/larger inputs or less/smaller outputs, possibly combined with other changes.

The link between the two transactions is that they conflict. This means that they directly or indirectly depend on spending the same predecessor output. As every output can be spent exactly once, both cannot end up in the same chain.