From where does the 2 hours limitation on bitcoin time stamp come? Bitcoin wiki says that:

  A timestamp is accepted as valid if it is greater than the median timestamp of previous 11 blocks, and less than the network-adjusted time + 2 hours

My question is why 2 hours? WHy not 1 or 3? Is there any calculation behind it?

I don't ever recall seeing an actual calculation for it, and I strongly suspect the reason is that it is "good enough".

The original, primary use of block timestamps is in difficulty calculations. They now also adjust the time for locktime transactions, but that's a newer addition.

A block's timestamps must:

Be greater than the median of the past 11 blocks (11 also seems to be a number chosen because it's good enough)
Within 2 hours of the network adjusted time

The network adjusted time is calculated by asking all your peers for their UTC timestamps, and if it's within 70 minutes of your own node, updating a network adjusted time median calculation over all the node times.

This imposes limits on how much a single node or miner can influence the time related parameters. Since difficulty adjustments look at the time between blocks and adjust to bring the mean down or up to 10 minutes, allowing for a very large variance may be counterproductive. 2 hours (to me) seems like a reasonable amount, since even if someone confuses DST time settings and has a bad clock, they would still be off in the range of 1-2 hours, on a reasonable system.

Of course, with ntp and other timekeeping services these days, nodes should be off a lot less. I've never heard of the 2 hour limit being insufficient, or of it being too large and causing issues with difficulty readjustment.

There are several things in the Bitcoin spec that exist because that's the way it was set up in the original implementation, and no pressing reason exists to change it.


Would it be possible for a cryptocurrency to have a price before its first block? For example, the cryptocurrency Kin had a price in 2017 according to coinmarketcap.com, but according to its block explorer, its first block launched in 2019 (I got this by typing in "2" in the search bar. Since typing in "1" gave a timestamp in 1970, which is from the start of the Unix timestamp.).
Is the timestamp from the block explorer wrong? If that is not the case, how could such phenomena happen? (The price on coinmarketcap.com must be calculated from trading data (reference), which should be included in the blocks.)

It's actually pretty common for new cryptocurrencies to have a "pre-mine" meaning that some part of the future coin issuance is assigned to public keys in advance. Investors pay the development team before the miners start generating blocks at a fixed price (that is not determined by market forces) and provide a public key. Then when the genesis block is released, all these coins are finally "real".
Ethereum was launched with such a premine. You can see all the coins generated in their genesis block that were paid for in advance.


Using BTC to receive currency donations How can Bitcoin be used by a charity in the Congo to receive donations from people around the world paying in different currencies?

You customers can exhange any currency to Bitcoin and pay via Bitcoin with no fees.
So, you need to support traditional payment methods and Bitcoin as well, as a new way of payment over Internet. It's the future of payment.

Some day, you will kick-off VISA and Paypal from your website ;)


How to generate specific private keys from 12-word backup and wallet address? A single seed can lead to billions of addresses. Some wallets are unable to scan and find all used addresses.

Is it a way to infer the private key from 12-word backup and wallet ID / (public key).

It seems the only way to restore my balance is based on private key.

Mnemonic seeds are based on the BIP39 (seeds) and BIP44 (accounts/multiple currencies).

When deriving addresses, one uses a derivation path to get to a specific addresses. The default paths are defined in the BIP specs, but some wallets may use different ones due to an error or intentionally (for instance, Ledger's Vertcoin derivation uses Monero's derivation path due to a coding error).

You can use tools such as Ian Coleman's BIP39 tool (preferably offline) to play around with your seed and derivation paths until you see your addresses. The tool has preloaded the common paths, so you should usually be able to access your wallet pretty easily, unless you were using an extremely unusual client.

Many wallets also publish their derivation paths in their support pages, and you could pull your original wallet's path from there.

Wallets such as Electrum will also let you import a seed and specify the derivation path, saving you from having to generate and import individual keys.

As long as your seed was generated by a wallet that complies with BIP44, and you are importing it into another wallet that also complies with BIP44, you should be able to recover all your keys with no additional work.


Why do people claim that governments cannot confiscate Bitcoins? Let's say that I practice impeccable data security processes using dedicated devices, encryption, and no clear-text backups. Even if they cannot find all of my backups, this doesn't protect me from criminals or government agents threatening violence to steal or confiscate my assets.
Please explain how having Bitcoin is any different in practice from having a bunch of gold bars that they can just steal?

While it is true that Bitcoin can still be physically taken away from you, it is still much harder to do that than it is for a government to confiscate your fiat stored in a bank account (as most fiat is). With fiat in a bank account, the government can simply go to your bank and order them to freeze your account and lock you out of it. There is no need for them to track you down, no need to go to your physical location, and no need to beat you up. It is very simple for the government to just freeze your bank account and thus confiscate your money.
But with Bitcoin, as you say, they need to go to your house, find your Bitcoin, and forcibly take it from you. It is much more work to do that as it involves people physically going to your home in order to physically seize the devices holding the keys to your Bitcoin.
And yes, this is not any different from having a bunch of gold or a bunch of cash. As with anything which is physically in your possession, the government can confiscate it by physical force. But those physical currencies and valuables are much less convenient to transact with, particularly online.
Furthermore, many countries have regulations regarding the amount of cash that you can be carrying across the border. They often will require you to declare it, and in some instances, the money can be seized by customs. Even when you are not crossing borders, simply having a large amount of cash or other valuables in your possession may raise the suspicion of police who may confiscate them. Bitcoin does not have similar problems (with the exception of novelty physical Bitcoin coins).
With Bitcoin, you can have all of the keys for your Bitcoin stored on a flash drive, a laptop, paper, or something else. It won't be extremely obvious that you are transporting large amounts of money. Even hardware wallets just look like random electronics and flash drives so they don't raise much suspicion. So if you are carrying some Bitcoin on your laptop, it is unlikely to be seized by customs agents or police where carrying similar amounts of cash or gold bars might be.
Lastly, there is also a philosophical form of confiscation that governments partake in - inflation. Central banks nowadays routinely issue more and more fiat currency leading to some amount of inflation. Over time, any cash that you have will have less purchasing power. If you simply save money, then over time, the government is effectively confiscating some of your money through inflation. On the other hand, Bitcoin has a known supply that eventually becomes fixed. While there is some inflation, because of the eventual fixed supply, Bitcoin largely becomes deflationary thus allowing your saved Bitcoin to actually have a greater purchasing power in the future. While precious metals currently have a fairly fixed supply, theoretically it would be possible to find large quantities of them somewhere else in the universe which would then cause the value of those precious metals to go down. With Bitcoin, that is not possible.


How long to earn fractions of bitcoin I started mining today, and I'm using the bitcoin GUI miner, along with rpc2013-cuda. I'm running algorithms on the CPU(completely maxed out - It's a core i7 quad-core/Hyperthreaded at 2.3GHz) and the GPU(98% Load - GT 650M at 1GHz Core/ 2GHz Memory don't Know the shader speed. I think it is the same as core) and got no share of bitcoins so far.
How much do you guys think that i'll be able to get a fraction of a bitcoin. I say fraction because I'm mining in a pool. That is Eligius. Should I start to mine in another pool? Maybe forget about CPU/GPU mining and try to buys a FPGA or dedicated miner?

edit 1: On total I'm having a hashRate of 40MHash/s

It depends by the machine, of course, but keep in mind that difficulty changes as time goes on. You should look at that specific index in order to aknowledge it correctly. By now, it takes about 1 year to get 1 BTC with your hardware, supposing no difficulty increases. I do advise you to mine other currencies (BTB or others) and then convert them into BTC... that's easier this way!


How to block certain IP address from bitcoind or using ufw Certain IP is brute forcing my node for rpc access. I tried ufw to deny that IP but did not work.
Looked for any black list conf entry or param to bitcoind and found none.
Any suggestions?

You can use the rpcallowip feature in your bitcoin.conf to whitelist IP addresses.
https://bitcoin.org/en/release/v0.10.0#rpc-access-control-changes


Basic bittrex api question I read the api documentation but I could not find anythin related to market buy and sell commands. Where do I find this information?

Moreover, I read the following from the api site

https://bittrex.com/api/v1.1/market/selllimit?apikey=API_KEY&market=BTC-LTC&quantity=1.2&rate=1.3

My understand of this statement is that I use my 1.2 Bitcoin to buy 1.3X1.2 Litecoin. Is this correct?

If I want to use my Litecoin to buy Bitcoin, do I need to change the market from BTC-LTC to LTC-BTC??

My understand of this statement is that I use my 1.2 Bitcoin to buy
  1.3X1.2 Litecoin. Is this correct?

The quantity parameter refers to how many of the coin you want to buy, and the rate parameter as to the limit price you want to buy/sell those coins at.

Example, buy 100 dogecoin at 0.00000400 BTC each.

https://bittrex.com/api/v1.1/market/buylimit?apikey=api_key&market=BTC-DOGE&quantity=100&rate=0.000004&nonce=nonce

  If I want to use my Litecoin to buy Bitcoin, do I need to change the
  market from BTC-LTC to LTC-BTC??

No, the market stays the same, just change part of the URI from /buylimit? to /selllimit? or vice-versa. Selling your litecoin for bitcion is the same as buying bitcoin with litecoin.

You can make it act like a market order by checking the current bid/ask and making your rate equal to the side your trading. For example if you want to market buy you can query the best ask price and then make that the rate.

function fetchPairPrice($pair){
    $pair = strtoupper($pair);
    $uri = "https://bittrex.com/api/v1.1/public/getticker?market=BTC-".$pair;
    $ch = curl_init($uri);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $execResult = curl_exec($ch);
    $obj = json_decode($execResult, true);
    return $obj;
}

function bittrexbuy($apikey, $apisecret, $symbol, $quant, $rate){
    $nonce=time();
    $uri='https://bittrex.com/api/v1.1/market/buylimit?apikey='.$apikey.'&market=BTC-'.$symbol.'&quantity='.$quant.'&rate='.$rate.'&nonce='.$nonce;
    $sign=hash_hmac('sha512',$uri,$apisecret);
    $ch = curl_init($uri);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('apisign:'.$sign));
    $execResult = curl_exec($ch);
    $obj = json_decode($execResult, true);
    return $obj;
}

    $symbolRate = fetchPairPrice("DOGE");
    $fetchPrice = $symbolRate["result"]["Ask"];
    $amountToBuy = 100;
    bittrexbuy($apikey, $apisecret, $symbol, $amountToBuy, $fetchPrice);

    //response
    //{"success":true,"message":"","result":{"uuid":"b5f891ab-a7b4-44aa-9488-94986d1d9551"}}


How to convert fee_estimates.dat into a human-readable format? I would like to take a look inside fee_estimates.dat to understand a bit better how the RPC command estimatesmartfee works. However, when I open the file in a text editor, the content is not readable.

Is there a way to read the information inside fee_estimates.dat?

You need to take a look at how fee_estimates.dat is written and interpreted. It is a binary file composed of:
MIN_VERSION
CURRENT_VERSION
CURRENT_TIP
TIP_AT_LAST_START
TIP_AT_LAST_STOP
[ESTIMATES]
[STATS]

With CURRENT being "when writing", i.e. when stopping bitcoind.
Here is the method writing the file, and here is the method reading this file (at startup). I think the latter can help you to parse it.


What is the impact of Bitcoin XT fork on current Bitcoin holders? I was reading that there was disagreement on the block size limit and Bitcoin has been forked to Bitcoin XT? With two different flavors of the software running, which might result in two different longest blockchains, what is the impact on the current existing Bitcoin holders? Are they handled by Bitcoin Core or by both?

Bitcoin has not been forked yet. Once XT nodes mine 75% of all bitcoin blocks, XT will support a larger block size that will be incompatible with current bitcoin client. At that time, the blockchain is forked and the bitcoin currency would be divided into two, Bitcoin and BitcoinXT.

  what is the impact on the current existing Bitcoin holders?

A transaction would be mined twice, XT miner puts this transaction on XT's fork; Core miner puts it on the core's fork. Then, you can run two clients, one of them spends Bitcoin, the other one spends BitcoinXT. Cool!An SPV client always follows the one with largest proof-of-work, which means it can only spend coins from stronger chain.

  Are they handled by Bitcoin Core or by both?

Both. You can double spend your coin now. One is bitcoin, the other one is bitcoinXT.


Have I lost my Bitcoins? I'm really new to bitcoins so being naive I've jumped in downloading a wallet (bitcoin core), got my address and set off buying 1 bitcoin.

Now I bought the bitcoin and it all went fine, I went to my wallet to find nothing there, I got a little concerned thinking it sent them elsewhere but after a check on blockchain it said they were sent to my address. After some googling I realised I hadn't let bitcoin core download the full blockchain data and read that all I had to was wait for my blockchain to download and my bitcoins would appear in my wallet. So I went to sleep. I checked my laptop in the morning to see it was sailing through the block chain and only had 1 year to go.

I've came in from work and my Portable HDD is making all sorts of noises but still being read and written to. My bitcoin core has frozen though, not long after the time I checked it this morning, I closed it and tried to reopen but it has asked me to create a path to download the blockchain? I've also gotten a new bitcoin address! I'm seriously flapping now!

So exited it and tried to open the wallet.dat file I saved the previous night but it never saved after I bought the bitcoin! This has been opened and my bitcoin address is now the same but now bitcoin core says indexing blockchain or something.

The main question is: Have I lost my bitcoins or do I just need to wait on the indexing and they will appear? The blockchain says they are still registered to that wallet.

If you saved a copy of your wallet, I don't think you have lost your bitcoins. The bitcoin core client makes 100 addresses ahead of time (you don't have just 1 address!), and they are all stored in the wallet.dat file.

Just wait until you client has finished downloading the blockchain, or follow the steps here to get them out without waiting!


How is RonPaulCoin different from Bitcoin/Litecoin? Is RonPaulCoin a clone of Bitcoin/Litecoin or are there differences beyond the specifications such as coin limit and difficulty algorithm?

RonPaulCoin uses Scrypt (like Litecoin). It is a Litecoin clone that only differs in the specifications:

Limit: 2.1 Million
Block time: 2 minutes
Reward schedule: 1 RPC per block, halving every four years.
Difficulty retargeting: Every 48 blocks (~96 minutes) with a maximum difficulty shift of 11%.


Are there any feasible methods of maliciously reversing transactions? How can transactions be maliciously reversed? What resources are required?

This is not a possible thing to do at all without having over 51% of the network. All transaction are irreversable.

With 51% of the network hash power, it is really easy to reverse transactions.

Anyone with that kind of power would make a better profit just mining as attacking the network would cause a collapse in confidence and drop the value (with that kind of power its safe to assume you have a hoard of BTC)


I have/had 31 bitcoins on MtGox; What are my options now? After reading the joint-statement on blockchain, and the fact MtGox is down now, I am scared, what are my options? Is there anyone who can help me in my situation? I purchased those coins for 800$.

Edit:
MtGox files for bankruptcy protection. What is the difference between bankruptcy and bankruptcy protection? I don't know, but I don't think that I am going to see anything from there...

This is generally called counterparty risk - if your resources are in custody of someone else, there is a risk that they go bankrupt and you lose it. And in that case it is too late and your options are limited to making a sadface :( and writing it off as a loss - do note that you can get x% of the loss back from your income tax in most places.

There are options to limit that risk before it materializes - it might be too late for MtGox, but important for the future. All the lessons are pretty the same as historically for 'normal' banks before modern regulation.

Diversify the risk - if your funds are spread out among multiple institutions, then there is less chance in losing it all than putting it all in one basket;
Insure the risk - your bank deposits are insured in most countries, i.e., if the bank can't return them then the insurer pays up to a certain amount. Bitcoin companies currently aren't insured that way, however it means that when some of them get deposit insurance then that would be a serious selling point for their trustworthiness; and if (when?) regulated banks start offering bitcoin services, then you'd get that protection as well. Also, you can purchase insurance for yourself, although it might be unpleasantly expensive.
Reduce the risk - choose the company properly. Reputation certainly didn't help in MtGox case and it's not a guarantee, however, you should be looking at solid evidence that the company is solvent. I.e., you want periodic, publicly visible financial statements that are seen and analyzed by many people and that show that they really can afford to pay all the depositors back even if they have a bad day or a bad year. At the very minimum you need this to be (a) according to common accounting standards; (b) expressed by a company officer in a manner that means jail for him if (s)he lies in these statements; (c) audited by a third party - otherwise these statements are worthless, as if there will be real problems, then they will lie always. Regulators of financial institutions do much of that job for banks; not eliminating those problems but reducing them - for unregulated entities you'll have to check everything yourself.


Conditional based Crypto based on Smart Contracts Is it possible to store an encrypted message in the blockchain that reveals itself only when a particular condition is met?

I think that the conditional disclosure can be done with Smart Contracts, but I don’t know if it would be securely encrypted until the condition to disclosure is met.

No, you can't.

There is no secret information anywhere in a blockchain. It is exactly the log of all information the public has to verify correctness of the system.


What prevents DoS based on near-valid block timestamps? Upon receiving a newly mined block, the block timestamp validation is performed here:

https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp#L3263-L3270

Q1: As for the second check (block timestamp too far in the future), what prevents a miner broadcasting a block that's near the limit in the future and having some of the nodes accept the block, while some other nodes reject the block?

Q2: If a part of the network accepts a block and the other part of the network rejects a block (i.e., not record the block it in its blocktree due to invalid time stamp), can the network recover from this in any way?

I'm answering both questions at once. It's not uncommon for the network to split i.e. different nodes accepting different blocks as chain tip. In fact this happens from time to time as two or more blocks are found at the same time by different miners. This gets resolved when the next block is found on top one of the previous blocks. The longest chain is valid.

And a miner can't simply set the timestamp when broadcasting. The timestamp needs to be set before finding a valid nonce. Thus a miner is incentivised to mine with a valid timestamp. If the block doesn't get accepted by the network, the hashrate (and electricity) used isn't compensated.


Unconfirmed transaction why My transaction stays unconfirmed. I've paid a normal fee I quess. The transaction is here:

https://blockchain.info/nl/tx/b8cacc71fba15b4dfee234cd037ba4729a15e573243440257777044f7ed8f101

What can I do to let it through?

Thanks in advance!

Rick

This is because miners are spaming the network, stay calmed, maybe cancel it and try it later.


How to determine EUR (or USD) price from Poloniex Ticker? Poloniex has for me a strange ticker content.

Rest API URL: https://poloniex.com/public?command=returnTicker

I have no problem with other plateforms to determine an immediate price, for example EUR / BTC price.

But with Poloniex, there is no EUR_BTC pair... only crypto to crypto pairs.

Example (actual BTC price = 1170€):

BTC_ETH
id  148
last    "0.07956500"
lowestAsk   "0.07977149"
highestBid  "0.07956501"
percentChange   "-0.00406771"
baseVolume  "2206.78596466"
quoteVolume "28048.32458745"
isFrozen    "0"
high24hr    "0.08127295"
low24hr "0.07676536"

With tickers, a volume is usally a Dollar amount... here, I don't know.

How to calculate a Euro or Dollar price with such info?

BTC_ETH is the exchange information between Bitcoin and Ethereum. In your example, 1 Ether buys about 8% of a Bitcoin.

The volume is given in both BTC and ETH terms.
baseVolume says 2206 BTC have been traded against ETH (last 24h I think)
quoteVolume says 28000 ETH have been traded against BTC

If you want a price in USD you can check the BTC_TUSD ticker, as the Tether-USD price is similar to the real USD price.


Long term BTC investing my question is, what is the safest way of buying and holding bitcoin for the long term?
And I mean 10-20 years, either a lump sum or through dollar cost averaging, is a paper wallet the answer? Or maybe a cold wallet? I am looking for something very safe that will likely still be around in 20 years time

Recommendations for how or where to buy Bitcoin are generally off-topic here, but long-term storage is a fair question.

First, understand what owning Bitcoin really boils down to: having knowledge of the private key that allows you to spend the Bitcoin stored at that key's address. You aren't storing the bitcoins themselves persay, you just need to store the private key (a 256 bit number).

These days, there is an industry standard that is known as 'hierarchical deterministic (HD) wallets' (BIP32) that allows more efficient wallet backups, and there is also a related standard (BIP39) that allows you to create a mnemonic seed phrase that works as a human-readable master backup of your wallet. So rather than storing a single private key, you can opt to store a seed phrase instead. Since it is a standard, most wallet software is compatible.

Whether you are storing a private key, or a seed phrase, it is probably a good idea to make multiple copies, in case something unexpected happens (fire, theft, etc). By storing them in geographically diverse locations, you can avoid having a single point of failure. The medium of storage can be important too: just writing it down on a piece of paper isn't as permanent as stamping it into a piece of titanium. How involved a solution you choose will depend on your personal situation. Generally, I would recommend a physical storage solution for the length of time you've mentioned (10-20 years), as a digital storage solution may experience data degradation within that time.

One issue with the paragraph above is that if you create multiple copies, and one of them is found, then whoever finds it could spend your coins. So (as Raghav mentioned) BIP38 is a standard that will allow you to encrypt the key with a passphrase (note: BIP38 is less commonly implemented than BIP32/39, but it is still available). Keep in mind that now you will need to store the encrypted private key, and also the decryption passphrase, so this adds additional consideration.

There is also the option of using a multisig address, which can only be spent from if m-of-n keys are used. So you could, for example, create 3 keys, but only require 2 of them in order to spend the funds. If you disperse the keys geographically and one of them is found, the finder will not be able to spend your coins (as they'll still need one more key). You can create all sorts of interesting custody setups using multisig addresses, and there are even Bitcoin storage services that offer solutions using such constructions.

It is up to you as an individual to decide which sort of construction you are comfortable with, there really isn't a 'one-size-fits-all' when it comes to long term storage.

So a related question is: what is the best way to generate a private key (and its related address)?

Generally, you will want to use a device that you are certain is clean (not infected with any sort malware). A 'cold wallet' just refers to a wallet whose private keys have never existed on an internet connected device, thus removing many attack vectors by which someone could steal your private key(s). For high-security storage, it is definitely recommended that you generate keys on a machine that does not connect to the internet. This could just be a special-purpose laptop, or a hardware wallet, etc. Again, there is no 'perfect solution', what you choose will depend on your situation.


Understanding default bitcoin wallet in bitcoind I am new to block-chain, so please bear with my questions. I need to understand the basics of a bitcoin-wallet.
So I have setup a bitcoin full node using bitcoind in running in testnet mode. As I understand that by default a wallet is created. Now when I am trying to get the address of the wallet by this command bitcoin-cli -testnet getaccount "", I am geeting an empty list.
So is there no default wallet as such, also how do I create a new wallet? As I understand that a bitcoin wallet is basically a pot which holds several child addresses?

getaccount command was deprecated in Bitcoin Core 0.18, the wallet uses "labels" now.

When the wallet was created, it created a seed for you. This is used to generate the addresses in a BIP32 heirarchy. To generate the first address, you can use the getnewaddress command, followed by an optional label (to save the address in the address book), and an optional address type. E.g.

$ bitcoin-cli -testnet getnewaddress my_first_address

  As I understand that a bitcoin wallet is basically a pot which holds several child addresses?

A Bitcoin wallet is generally considered software that manages your Bitcoin addresses and transactions, as well as your private keys to those addresses. In Bitcoin Core it is also used to describe a heirarchy of addresses with their own unique seed. Addresses used within a "wallet" on Bitcoin core are all derived from the same master key and seed. In fact you can have multiple wallets using the same installation of Bitcoin core, see createwallet


How sign the first transaction's signature? In bitcoin, each transaction's signature is signed with previous owner's private key. Then, how sign the first transaction's signature?

See Bitcoin Wiki.
Above image illustrates a byte-map of transaction with each type of TxIn and TxOut.

We should attention at "Coinbase/Generation" (Coinbase means the first transaction in a block).
Codebase's script is a arbitary data.
Yep, it is random.

Therefore the signature of first transaction of a block is not used.


Lightning Network : Pay a Bolt11 Invoice in multiple Payments Is there a way to pay one Bolt 11 Invoice in multiple payments with Lightning Network?

For instance this invoice total amount to pay is 5000 satoshi:

lnbc50u1pwsyhx9pp57ppqvzwex3qapu0wn63v06jzxqdtt46qypks4pnexwrr2ansz9msdqcgejhxctzd9kxjare23jhxap3cqzysxqy2ljqd47a9cdlnj84cy0a0zg7frd8jnera8fen2du6d2g500wzs7mpsmpqe0c3ddhrrxpehyhj4c9fwj3cfr5mvyxcyaaq98fw39jketl89cq0j9hy2

In this case can we pay 2 times 2500 satoshi and then get the secret (preimage) Only after the Full Payment is received?

I did notice that in LND client with lncli sendpayment and c-lightning client with lightning-cli pay commands there is an amount parameter in satoshi?

Currently, no. The receiver will reject an attempt for less than the requested amount and fail with incorrect_or_unknown_payment_details.

Each invoice has a payment_hash which a payment corresponds to, and the payment hash is generated from a random payment_preimage. This preimage must be unique for each payment, else it may be possible for any party along the route of a payment to take money without forwarding the payment on.

When the payee receives the full amount for a payment, they release the payment_preimage to the penultimate hop in the route, who then removes the HTLC from their channel and the payment completes. The penultimate hop then forwards the payment_preimage to the hop before them, and so on, until it reaches to payer.

You can see that, if only half of the payment was done, then every participant along the route would already have knowledge of the payment_preimage. If you attempted to pay again with the same payment_hash, then any hop in that route could instantly remove the HTLC and take the payment by using the payment_preimage they already know, without forwarding the payment to the next hop.

There is work in progress to allow payments to be broken up and send along multiple routes, with the payee only surrendering the payment_preimage if the full amount from all routes is received. This is known as AMP (Atomic Multi-path Payments). There are multiple proposals for this which have been discussed on the mailing list.


How can I verify the the PGP signature of bitaddress.org? bitaddress.org appears to have a versioning system and a PGP signature to confirm the source code hasn't been hacked.

If I save the source code for the page (so I can run it on an offline computer), what steps do I need to take to verify the version I've downloaded matches the signature?

This assumes that the signed version of bitaddress.org is not malicious as answered in this question.

who has actually verified the code is not malicious in the first place?

There are many eyes on it from cryptographers, javascript programmers and more.  But there has been no commercial party or individual who claims to have vetted the page to assure that there is nothing malicious.

As far as verifying that the website is serving the same release as the version control repository shows, that can be verified as follow:

Verify that the BitAddress.org website has been updated and returns the same HTML from the commit with the description vx.x in github:

https://github.com/pointbiz/bitaddress.org

Here's an example of verifying in which the version was v2.4:

First check the sha1sum hash of the html returned by a request to http://bitaddress.org:

$ wget --quiet -O - http://bitaddress.org|sha1sum
1d5951f6a04dd5a287ac925da4e626870ee58d60  -

$ GET -eSd bitaddress.org|grep -i "200 OK"
GET https://www.bitaddress.org/bitaddress.org-v2.4-SHA1-1d5951f6a04dd5a287ac925da4e626870ee58d60.html --> 200 OK

Then from my bitaddress.org repo:

$ git checkout master
$ git pull
$ git log --pretty=oneline|grep "v2.4"
eeed4db91edd9eda5eb4277a61aa16ad80bdcdcb v2.4 French translations

$ git checkout eeed4db91edd9eda5eb4277a61aa16ad80bdcdcb
$ git rev-list --max-count=1 HEAD
eeed4db91edd9eda5eb4277a61aa16ad80bdcdcb

$ sha1sum bitaddress.org.html
1d5951f6a04dd5a287ac925da4e626870ee58d60  bitaddress.org.html

As long as that sh1sum matches the filename and also matches from github, then you can you know have the exact same version as was distributed from github.


How to run Bitcoin Core as onion service on Windows, Ubuntu and Android? Have you tried running Bitcoin Core listening on Tor on different platforms? What are your experiences, issues that you faced, hacks, workarounds etc.?

Windows
You can follow one of the steps from 2 and 3. Step 2 uses cookie for authentication and Step 3 uses password.

Download and Install Bitcoin Core from https://bitcoincore.org/bin/bitcoin-core-0.20.1/bitcoin-0.20.1-win64-setup.exe

Edit the bitcoin.conf file, enter the below things and save it. Default location of the file is %UserProfile%\AppData\Roaming\Bitcoin\bitcoin.conf

listen=1

debug=1

logips=1

testnet=1

listenonion=1

onlynet=onion

proxy=127.0.0.1:9150

torcontrol=127.0.0.1:9151

How to setup cookie auth for Tor control?

Open C:\Users\Prayank\Desktop\Tor Browser\Browser\TorBrowser\Data\Tor\torrc and add below line:
HCookieAuthentication 1

IGNORE THIS STEP IF YOU ALREADY DID STEP 2. Edit the bitcoin.conf file, enter the below things and save it. Default location of the file is %UserProfile%\AppData\Roaming\Bitcoin\bitcoin.conf

listen=1

debug=1

logips=1

testnet=1

listenonion=1

onlynet=onion

proxy=127.0.0.1:9150

torcontrol=127.0.0.1:9151

torpassword=XYZ
XYZ: Replace it with your password in plain text

How to setup password for Tor control?

Open command prompt/PowerShell and run the below commands:
cd "C:\Users\Prayank\Desktop\Tor Browser\Browser\TorBrowser\Tor"
tor --hash-password "XYZ" >torhash.txt
Open torhash.txt file, copy the last line which has below content, paste in C:\Users\Prayank\Desktop\Tor Browser\Browser\TorBrowser\Data\Tor\torrc and save it:
HashedControlPassword 16:1CEDITEDOMERANDOMSHITCF8EBCD9A50CLOLCDACF
Run the below commands in command prompt or PowerShell to ensure connection with Tor control works:
telnet 127.0.0.1 9151
AUTHENTICATE "XYZ"

Launch Tor Browser

Launch Bitcoin Core Wallet (Testnet) using the shortcut with a green icon or run "C:\Program Files\Bitcoin\bitcoin-qt.exe" -testnet in command prompt or PowerShell and change the path accordingly

Run getnetworkinfo in console window and check the localaddresses. Check if testnet3/onion_private_key file is created and analyze the logs in debug.log file.

Ubuntu
You can follow one of the steps from 2 and 3. Step 2 uses cookie for authentication and Step 3 uses password.

Download Bitcoin Core and run the below commands:

tar xzf bitcoin-0.20.0-x86_64-linux-gnu.tar.gz
sudo install -m 0755 -o root -g root -t /usr/local/bin bitcoin-0.20.0/bin/*
/usr/local/bin/bitcoin-qt

Edit the .bitcoin/bitcoin.conf file, enter the below things and save it.

listen=1

debug=1

logips=1

testnet=1

listenonion=1

onlynet=onion

proxy=127.0.0.1:9050

How to setup Tor?

sudo apt install tor
Open /etc/tor/torrc and add below lines:
ControlPort 9051
CookieAuthentication 1
CookieAuthFileGroupReadable 1
Restarts Tor: sudo /etc/init.d/tor restart
Add user to Tor group: sudo usermod -a -G debian-tor <username>
Run Bitcoin Core: /usr/local/bin/bitcoin-qt

IGNORE THIS STEP IF YOU ALREADY DID STEP 2. Edit the bitcoin.conf file, enter the below things and save it.

listen=1

debug=1

logips=1

testnet=1

listenonion=1

onlynet=onion

proxy=127.0.0.1:9150

torpassword=XYZ
XYZ: Replace it with your password in plain text

How to setup password for Tor control?

Open command terminal and run the below commands:
torpass=$(tor --hash-password "my-tor-password")
printf "HashedControlPassword $torpass\nControlPort 9051\n" | sudo tee -a /etc/tor/torrc

Run getnetworkinfo in console window and check the localaddresses. Check if testnet3/onion_private_key file is created and analyze the logs in debug.log file.

Android
Download, Install and Run either ABCore or Nayuta Core.

I have selected Bitcoin Knots in the settings of ABCore however there is an option to use Bitcoin Core as well.


Which rate is the best rate to go by for Bitcoin prices There are so many exchanges and local exchanges out there. If I want to buy a bitcoin, how do you decide which value to go by? Some of these exchanges vary from few dollars to $200 difference. I know that it is always fluctuating and many times eventually balances out but how do you determine the price that should be paid?

Mtgox's price is high because it is difficult (if paying a 5% "emergency withdraw" fee) to impossible (if not paying a fee) to withdraw USD.  This makes USD on Mtgox less valuable than cash in hand, and therefore bitcoins are worth more in terms of "Mtgox USD" than real USD.

BTCChina's price has been high recently due to huge demand in China and capital controls that make it difficult for arbitrageurs to move USD or CNY out of the country.

When deciding on a fair price, it is best to use the price someone would get if they used the most convenient exchange in their country.  In the US, Coinbase or Bitstamp's rate makes sense.  In Europe, Bitstamp is the best option, and in China, a Chinese exchange would be more appropriate.


What cryptographic operations are performed on the 3 public keys to produce a multisig (2 of 3) address? I'm just getting a handle on multisig, so sorry about that. I don't really get how, (what operations are performed) on the inputs (3 public keys, right?) to generate a multisig address. Or is it some simple concatenation operation?

To better understand multisig addresses and transactions, it's useful to read BIP 0013 and create a multisig address using https://coinb.in/multisig/

If I want to create a multisig that requires signatures from 2 of the 3 following pubkeys:

04c96a8b79aff49f36766b7827308bb5d6dc031e4e9112b785201a9a61821d2a336dbb7fa69f44c2dc76dee8fa7ed8fee2958f4a86a3dbb7ebf3eeb790cd464db9
04fd6c4db8841f7370a0cdc464a58b3e2a0da5b6566e0502a9cf583360bcdd16e8453a0a8da0fba0ff26e40c1f8c55f8cd0ad61988b7d4418b504264be8a9cef59
04c41b31403f24ef79e9c7dcfb67ea0341fcb986e9555123b022258a92d2bade3674574bf3de7affe93706399d9eb76d04f05213cda8b8e8bb8541533c39f244a9

The resulting multisig script is this: (broken down by OP code)

52 OP_2, meaning you need two signatures
41 push 65 bytes
04c96a8b79aff49f36766b7827308bb5d6dc031e4e9112b785201a9a61821d2a336dbb7fa69f44c2dc76dee8fa7ed8fee2958f4a86a3dbb7ebf3eeb790cd464db9
41 push 65 bytes
04fd6c4db8841f7370a0cdc464a58b3e2a0da5b6566e0502a9cf583360bcdd16e8453a0a8da0fba0ff26e40c1f8c55f8cd0ad61988b7d4418b504264be8a9cef59
41 push 65 bytes
04c41b31403f24ef79e9c7dcfb67ea0341fcb986e9555123b022258a92d2bade3674574bf3de7affe93706399d9eb76d04f05213cda8b8e8bb8541533c39f244a9
53 OP_3, meaning there are three public keys
ae OP_CHECKMULTISIG described at https://en.bitcoin.it/wiki/Script

And the page tells me the address for it is 3K6sEDqXaSFKjcq8PUKNsGbxXjBR8QmBWr

The hash of this script, along with a version number (to make the starting character 3) and checksum (to ensure that a misentering of data is not likely to go through) is what makes up the multisig address:

base58-encode: [one-byte version][20-byte hash][4-byte checksum]

You can verify this by comparing the hash160 value shown at https://blockchain.info/address/3K6sEDqXaSFKjcq8PUKNsGbxXjBR8QmBWr and the result of the following short C# program: they are both befcdceed8cbf0d74d9d58bf8e30ce027e8a9b56

var data = new byte[] { 0x52, 0x41, 0x04, 0xc9, 0x6a, 0x8b, 0x79, 0xaf, 0xf4, 0x9f, 0x36, 0x76, 0x6b, 0x78, 0x27, 0x30, 0x8b, 0xb5, 0xd6, 0xdc, 0x03, 0x1e, 0x4e, 0x91, 0x12, 0xb7, 0x85, 0x20, 0x1a, 0x9a, 0x61, 0x82, 0x1d, 0x2a, 0x33, 0x6d, 0xbb, 0x7f, 0xa6, 0x9f, 0x44, 0xc2, 0xdc, 0x76, 0xde, 0xe8, 0xfa, 0x7e, 0xd8, 0xfe, 0xe2, 0x95, 0x8f, 0x4a, 0x86, 0xa3, 0xdb, 0xb7, 0xeb, 0xf3, 0xee, 0xb7, 0x90, 0xcd, 0x46, 0x4d, 0xb9, 0x41, 0x04, 0xfd, 0x6c, 0x4d, 0xb8, 0x84, 0x1f, 0x73, 0x70, 0xa0, 0xcd, 0xc4, 0x64, 0xa5, 0x8b, 0x3e, 0x2a, 0x0d, 0xa5, 0xb6, 0x56, 0x6e, 0x05, 0x02, 0xa9, 0xcf, 0x58, 0x33, 0x60, 0xbc, 0xdd, 0x16, 0xe8, 0x45, 0x3a, 0x0a, 0x8d, 0xa0, 0xfb, 0xa0, 0xff, 0x26, 0xe4, 0x0c, 0x1f, 0x8c, 0x55, 0xf8, 0xcd, 0x0a, 0xd6, 0x19, 0x88, 0xb7, 0xd4, 0x41, 0x8b, 0x50, 0x42, 0x64, 0xbe, 0x8a, 0x9c, 0xef, 0x59, 0x41, 0x04, 0xc4, 0x1b, 0x31, 0x40, 0x3f, 0x24, 0xef, 0x79, 0xe9, 0xc7, 0xdc, 0xfb, 0x67, 0xea, 0x03, 0x41, 0xfc, 0xb9, 0x86, 0xe9, 0x55, 0x51, 0x23, 0xb0, 0x22, 0x25, 0x8a, 0x92, 0xd2, 0xba, 0xde, 0x36, 0x74, 0x57, 0x4b, 0xf3, 0xde, 0x7a, 0xff, 0xe9, 0x37, 0x06, 0x39, 0x9d, 0x9e, 0xb7, 0x6d, 0x04, 0xf0, 0x52, 0x13, 0xcd, 0xa8, 0xb8, 0xe8, 0xbb, 0x85, 0x41, 0x53, 0x3c, 0x39, 0xf2, 0x44, 0xa9, 0x53, 0xae, };
var sha256 = System.Security.Cryptography.HashAlgorithm.Create("SHA256");
var ripe = System.Security.Cryptography.HashAlgorithm.Create("RIPEMD160");
Console.WriteLine(string.Join("", ripe.ComputeHash(sha256.ComputeHash(data)).Select(x=>x.ToString("X2"))).ToLower());

Then when you want to pay that address, you use pay-to-script-hash output instead of a pay-to-pubkey-hash.


Estimatefee value not corresponding to actual fee When I call estimatefee 1 in testnet it returns: 0.00044444

Then when I call sendtoaddress xxxxxx 0,1 (which got the first confirmation within a couple of minutes after sending) I see that the fee included is: 0.00001662 BTC, which is about 27 times smaller that the original estimate.

What am I missing?

estimatefee 1 will return the approx. fee per kilobyte.

Because sendtoaddress could use multiple of your unspent coins, the size of your transaction is not know until it is created (until the coin selection ran).

Example: Fresh wallet. You did receive 10 times 1 BTC. Now you create a transaction with sendtoaddress <ard> 9.5. This will produce a transaction with 10 inputs (your received 10 x 1BTC). Therefor the transaction size is bigger than if you would have received 1 x 10BTC.

At the moment there is no easy way of getting the transaction fee before sending the tx (on RPC level). You could use Bitcoin-Qt (there you will see the fee before sending within the confirmation dialog).

There is a pull request for bitcoin-core that would allow fee calculation before sending the tx: https://github.com/bitcoin/bitcoin/pull/6088


How was a pay to ip transaction created? How can you create a pay to ip transaction or is this not possible with the current client?

If so why was it disabled?

Pay-to-IP transactions were removed in 0.8.0.

Such transactions worked by essentially contacting the IP address you were sending to, seeing if it was running Bitcoin, and receiving a public key from the Bitcoin node there to pay to.

However, this wasn't very secure. There was no way to prove that the response was coming from the IP address you tried to contact - It was trivial for a man-in-the-middle attack to simply hijack your request and reply with their own bitcoin public key, effectively stealing the payment.

Here is the BitcoinTalk discussion discussing the PR linked above and the removal, with the thought process at play.


how does one map a transaction number to a block with just the bitcoind client? I realize this can be done at blockchain.info, but would like to find a way to do this with just the bitcoind client. if all I have is the receiving address and the transaction number, I can't figure out what command or set of commands to use. I can get and decode the raw transaction (bitcoind decoderawtransaction $(bitcoind getrawtransaction 3dd264f603f75871c5a36b61db8e137d8cee6b019a8d5bdfdabd7383ccc47068) | less), but that doesn't give me the block number.

note that I can't use gettransaction because my local box (netbook) isn't the origin nor the destination of the transaction; I get error: {"code":-5,"message":"Invalid or non-wallet transaction id"}. I also can't use listreceivedbyaddress for the same reason, although I don't get an error in this case because I did once send to the address in question from my netbook.

figured it out after finding my own previous post about how I found out this info with americancoind, coin seems to have gone to a duplicate address, by its error message on attempting to resend the raw transaction. but bitcoind doesn't tell you what block it's in, merely stating error: {"code":-5,"message":"transaction already in block chain"}. however, on searching through the source (rpcrawtransaction.cpp) I noticed that getrawtransaction takes an extra arg, verbose, which if greater than 0 gives the blockhash:

jcomeau@aspire:~/rentacoder/jcomeau/bitcoin/src$ bitcoind getrawtransaction 3dd264f603f75871c5a36b61db8e137d8cee6b019a8d5bdfdabd7383ccc47068 1 | grep block
    "blockhash" : "000000000000000116f3abab7d0f620f620eae189de29ddb06fe8baae566467a",
    "blocktime" : 1393013064

and with the blockhash you can use getblock:

jcomeau@aspire:~/rentacoder/jcomeau/bitcoin/src$ bitcoind getblock 000000000000000116f3abab7d0f620f620eae189de29ddb06fe8baae566467a
{
    "hash" : "000000000000000116f3abab7d0f620f620eae189de29ddb06fe8baae566467a",
    "confirmations" : 255,
    "size" : 341358,
    "height" : 287092,
    "version" : 2,
    "merkleroot" : "d0fd6154ba64682b48c9c15600ee7c8594336cf4c0a2917b5cbcf1f5a74d2096",

so, 287092 is the block number that contains the transaction.


ASIC resistant PoW mechanism that generates new hash functions. How does that work? From Vitalik Buterin's post regarding "On Mining", he mentions:

  The second approach is somewhat different: create a mechanism for
  generating new hash functions, and make the space of functions that it
  generates so large that the kind of computer best suited to processing
  them is by definition completely generalized, ie. a CPU. This approach
  gets close to being “provably ASIC resistant” and thus more
  future-proof, rather than focusing on specific aspects like memory...

My question is how would such a mechanism work and how might it be implemented or realized?

What's unclear to me is how can you have a PoW mechanism that's able to just create new never-before-seen hash functions on its own and somehow have all the nodes on the network derive this hashing algorithm in an independent, trustless manner? A second major concern is how can you be sure that this derived algorithm is even cryptographically secure?

Note, I found a similar question here. But there is a crucial difference: that question is in regards to picking from a finite set of predefined cryptographically vetted hash functions and changing their call orders dynamically. The method Vitalik is suggesting, the mechanism is deriving a new hash function that never existed before and using that as the PoW function for a given block at that point in time.

Even though i'm a beginner in everything that concerns cryptocurrencies, please let me propose a guess, that others more prepared will correct. The idea is that an ASIC is a very specialized piece of hardware, dedicated to a single algorithm. If you keep changing the algorithm, there will be no way to create an ASIC that will mimick it; to implement such an algorithm, you'd have to use a piece of hardware so generalized that it would have to be a CPU.


What prevents miners from inserting fake transactions given SegWit? If I'm understanding segwit correctly, miners have to verify signatures in order to include a transaction into a block that they are mining. However, miners are not required to verify signatures in order to decide that a block a different miner mined is valid. Is this correct? It sounds to me like most do still verify though?
Are signatures discarded eventually?
Should a mining pool temporarily gain 51% control of the blockchain, can they insert transactions, and not include the segwit for a block or two because, by the time other miners are allowed to mine, those signatures will have expired?

If I'm understanding segwit correctly, miners have to verify signatures in order to include a transaction into a block that they are mining. However, miners are not required to verify signatures in order to decide that a block a different miner mined is valid. Is this correct?

Miners can do what they want to construct blocks, including creating blocks with invalid signatures. They can even try construct blocks by just creating random data, and hoping it's valid.
However, blocks without valid signatures (or other validity problems) will not be accepted by the network. All full nodes verify all signatures in all blocks, so if a miner constructs a block with an invalid signature, they've just wasted a enormous amount of effort to produce something everyone will just ignore, and forgone the ability to be paid for that block. The same is true for building on top of an invalid block; thus miners are incentivized to validate the blocks they build on top of too - but they don't have if they like losing money.
None of this has anything to do with segwit. Segwit moved signatures to a different place, where they don't affect txids, and can be stripped cleanly so pre-segwit nodes can ignore them, but doesn't mean nodes don't validate anything less (except old nodes, which don't care about the segregated area).

It sounds to me like most do still verify though?

Definitely.

Are signatures discarded eventually?

Not in any current full node implementation that I know of.
Bitcoin Core supports pruning old block data, which deletes both witness and non-witness data equally. That also means other nodes can't synchronize off a pruned node anymore.
In theory it's possible to implement a pruning mode that deletes just the witnesses. That would also prevent other (post-segwit) nodes from synchronizing off them, but they could still serve some light clients. This is not implemented.

Should a mining pool temporarily gain 51% control of the blockchain, can they insert transactions, and not include the segwit for a block or two because, by the time other miners are allowed to mine, those signatures will have expired?

I don't understand what you mean here, but signatures don't "expire".


Where can I buy Litecoins in Canada? I'm looking for a good place to buy and sell litecoins in Canada. Does anyone have a good list for reference? I know of Vault of Satoshi and a newer service Harborly, but that's about it.

If you're OK to exchange Bitcoin for Litecoin, then you have a few more options such as:

https://btc-e.com/
https://vircurex.com/
https://www.cryptsy.com/


Issue with bitcoin client 0.4.0 - stop populating My bitcoin client stops populating at 8 connections and 112949 blocks, event I left it running for over 12 hours now. I checked my internet connection and firewall, all seem OK. Restart it a few times still make no different.

Appreciate any suggestion.

Try deleting your blkindex.dat and blk0001.dat files (do NOT delete wallet.dat, even better make a backup), and let bitcoin re-download the chain. The exists a rare situation where the block chain files become corrupted, and bitcoin does not accept any new blocks.


Calculate transaction fee from getrawtransaction Is there an easier way than substracting vout to previous vin's transaction vout to calculate the fee paid for a transaction?

No, there is not. That is how the transaction is set and calculated in the first place.


Sending coins without wallet just address My wallet is not working and is not showing I have any amount of money in my account. I have the wallet address and the transaction record showing that the money is in my account. How can I send this money to another wallet to save it?

By wallet i am assuming its not on exchange. And by coin i am assuming you are talking of Bitcoin. So if your coins is stored in bitcoin core qt wallet then you can reuse the private key to sign the transaction.
So if my assumptions is correct than you can go to debug console in your QT wallet and type

dumpprivkey XYZ

where xyz is your address which you are saying you know it.
Once you have your private key with you you can use API

1) createrawtransaction [{"txid":txid,"vout":n},...] {address:amount,...}
2)signrawtransaction  <hexstring> [{"txid":txid,"vout":n,"scriptPubKey":hex},...] [<privatekey1>,...]
3)sendrawtransaction <hexstring>

checkout apis available in Bitcoin to know more.


Who maintains list of bitcoin nodes and aren't they a weak link in the security of the system? I understand that between the people who run Bitcoin nodes, and therefore the Bitcoin protocol, the system is trust-less and secure.

However, there seems to be a weak link - the official list of bitcoin nodes.

Whoever maintains the official list however, can theoretically conspire to ensure that 51% of the nodes are under its control and can perform nefarious operations such as double spending and/or changing transactions.

How is this issue handled?

First of all, there isn't really an "official" list of DNS seeds.  You're probably thinking of the list used by Bitcoin Core.  But other clients are free to choose a different list, or to discover peers in an entirely different way.  Users of Bitcoin Core are also free to reconfigure their software to use a different list.  So this list is merely the default for one particular client.

This list is chosen by the Bitcoin Core developers, just like everything else in the Bitcoin Core source code.  You can read here about the criteria they (claim to) use when selecting nodes for this list.

It's true that if the Bitcoin Core developers decided to be evil, they could modify this list to only have DNS seeds that will only return addresses for malicious nodes controlled by them.  That would allow them to mount a Sibyl attack on any user of Bitcoin Core.

But if you think about it, if the Bitcoin Core developers decided to be evil, they could do things that were much worse, much more easily.  They could just put in some code that would immediately send all coins in the wallet straight to them, as soon as the software is run.  Why bother messing around with DNS seeds and all that?

And if you think some more, this same sort of risk exists with every piece of software you ever use: you are trusting that  the software doesn't contain something evil.

So what's our protection against this?  Bitcoin Core is open source.  You, and everyone else, can see all the changes that have been made up till now, and you can judge for yourself whether any of those changes have been evil.  You, and everyone else, can test the DNS seeds provided in the list, and see whether they appear to be returning well-behaved nodes.  If they didn't, there's a good chance that you'd find warnings about it elsewhere on the Internet, just like you probably would if the Bitcoin Core developers had made any other evil change.

If all the currently listed DNS seed operators suddenly decide to conspire to be evil, the situation is similar: people will probably notice rather fast, and you'll hear about it.  But the Bitcoin Core developers choose seeds that, as far as they can tell, are operated by independent people who seem to be individually honest and have no particular reason to conspire.

If, on the other hand, an individual DNS seed operator decided to turn evil, without the cooperation of the Bitcoin Core developers, the risks are much lower.    As long as at least honest seed remains, you'll likely connect to some honest nodes in addition to the dishonest ones.  And if you successfully connect to at least one honest node, a Sibyl attack doesn't work: the honest node will send you the proper blockchain, and you'll know from its higher difficulty that it is the right one and the others are fake.

In general, you want to be careful throwing around terms like "trustless and secure".  These terms are never absolutes.  You always have to trust somebody for something, and there are always ways for security to be violated.  The best you can do is to try to understand exactly who you are trusting, what you are trusting them to do, and what evidence you can use to decide whether they are worthy of that trust.


How to verify virgin bitcoin I am willing to acquire bitcoin without transaction history (virgin bitcoin) at a premium. How do I tell that the bitcoins I receive do not have any prior transactions (except of the mining one)? What proof would the counterparty need to provide?

There is only way way to acquire Bitcoin without a previous utxo associated with them: Mine them.

You could pay a miner to mine directly to an address that you control, if you don't have the hashpower yourself.

If you pay someone else who transfers such coins to you, you've already destroyed the value as the act of transferring them will move then from the coinbase (mining output) utxo to your own address, which will be a regular utxo just like any other on the chain.

Verification is easy - just look at the transaction that sends the Bitcoin to you, and verify that it has only one input referencing a 0-hash previous output. When verifying with Bitcoin Core, this will be parsed as a coinbase input. For example, for the latest coinbase tx at time of writing, Bitcoin Core produces the following output (truncated for :

{
  "txid": "21429071642d1838aaaa24b0b5cd5868934952424c9dacd5f63f7f900a416755",
  "hash": "9985102431de97ee3b0cf4e9631daa85a48b84e6476d38998018b268ab27cf99",
  ....
  "vin": [
    {
      "coinbase": "03c13109049f73c25d434e2f54545454545431313131fabe6d6da23d1eb317523b78d2e61f76e493dde0a8f87cd83c585f8bce158d107bf5047c010000004204cb9a8102498456268a5d0aec1c00",
      "sequence": 4294967295
    }
  ],
  "vout": [
   ...
  ],
  "hex": "020000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff4e03c13109049f73c25d434e2f54545454545431313131fabe6d6da23d1eb317523b78d2e61f76e493dde0a8f87cd83c585f8bce158d107bf5047c010000004204cb9a8102498456268a5d0aec1c00ffffffff036f65524b0000000017a914f870b7fbb0ce391d9ddc16ad98479d8cbbbd5c41870000000000000000266a24aa21a9ed70b3372921878104277c3e0697fc079b2152d4c2aab2a1c653387f93f416b3290000000000000000266a24b9e11b6da4a898ffc213ffe4708753951bcafa58fcd7d1b9149f39b5c74dc1e1a48b21100120000000000000000000000000000000000000000000000000000000000000000000000000",
  "blockhash": "00000000000000000006d147b5ecfc60100ca2b206240929ffa3f594dae95e08",
  "confirmations": 1,
  "time": 1573024670,
  "blocktime": 1573024670
}


Even if transaction fee is set to BTC 0.00001, transactions remain unconfirmed I'm testing an application based on bitcoinj so I've been sending small amounts for days and it worked fine – transaction fees are set by default to BTC 0.00001. As of yesterday, these small transactions just remain unconfirmed... I guess because the Bitcoin network also considers volumes. Is that assumption correct? What is a reasonable fee to prevent this inconvenient? And last but not least, how do I recover my unconfirmed transactions?

CoinWallet began a different kind of stress test within the past several days.  After concerns about the method in which it conducts stress tests being a violation of laws in the UK, it decided to stress test the system by giving away 200 BTC for free to the public in a manner which will have the same effect without being a criminal act.

CoinWallet is giving away private keys that have (cumulatively) up to 200 BTC in them.  The BTC community is raising to load the wallets and send the transactions to their own private addresses so that they can get to the free money.  The result of this competitive fight for the 200 BTC is that the memory pools of full nodes are being filled with double spends and transactions that will never be verified.  Eventually, the double spends will be dropped as one of the spends makes it into a block and the remaining spends become invalid, but until then, all the nodes and all the miners are overwhelmed with a lot of extra data, which places small transactions especially those with low or no fees at the back of the priority list.

The good news is that the priority function increases the priority of all transactions as a function of time, so that even no-fee transactions will eventually have a high enough priority to be forced into the next block.  However, there is no way to predict how long that will be.

You will get your test transactions back.  They will confirm eventually.  During this stress test however, it may take as much as several days if you are unlucky.

After all the BTC that have been given away have been fully processed and all the double spends have been cleared from the mem pool, you should see normal confirmation times return to the network.

Example: Five private keys made available
Article: An article describing CoinWallet's plan
Public Release: Coinbase addresses the Backlog for its concerned customers (Graph included of Mem Pool)


Bitcoin and Litecoin wallets with push notification API? I am working on a project which includes btc and ltc transactions. I need Bitcoin and Litecoin wallets with APIs that could create Push notification on newly received transactions. With API I mean any kind of communication (Interface, REST API etc.). Can anybody show me the way or name the wallets? Wallet needs to be local not remote website with service.

You can run bitcoind/litecoind with the -walletnotify flag, which runs a script when a transaction is received.  The script could then send a notification.

./bitcoind -walletnotify=<your script name> %s

The %s is replaced with the hash of the incoming transaction.


How many bitcoins will there eventually be? Since bitcoins are being regularly rewarded to miners, will the number of bitcoins continue to grow indefinitely, or will there be a maximum total number of bitcoins in existence?  And if there is some kind of limit, what is it and how is it enforced?

Every block introduces 50 new coins in the system. This quantity (50) halves every 210,000 blocks. So, getting the limit of coins it is possible to generate is quite easy : it's the sum of a geometric series.

Also, note that this is an upper bound ; the actual quantity will probably be a bit lower due to rounding issues (BTC has a finite number of decimals, 8).


Could you use ASICBOOST on Bitcoin Cash? Can you use ASICBOOST on the Bitcoin Cash blockchain or would it not work.

Yes, ASICBoost works on the Bitcoin Cash blockchain because the block header format of Bitcoin Cash blocks are the same as the block header format of Bitcoin blocks. ASICBoost operates on the block headers. Furthermore, both overt and covert ASICBoost work on Bitcoin Cash.


How to generate the hash of public key in Bitcoin I'm trying to hash the public key with SHA256 and then ripemed160 and get the hash. but it gives the wrong hash

Public key:  2b4632d08485ff1df2db55b9dafd23347d1c47a457072a1e87be26896549a8737

Hash should be: 93ce48570b55c42c2af816aeaba06cfee1224fae

Imports System.Security.Cryptography
Imports System.Text
Imports System.Globalization
Imports System.Numerics

Private Function HexStringToByteArray(ByVal shex As String) As Byte()
    Dim B As Byte() = Enumerable.Range(0, shex.Length).Where(Function(x) x Mod 2 = 0).[Select](Function(x) Convert.ToByte(shex.Substring(x, 2), 16)).ToArray()
    Return Enumerable.Range(0, shex.Length).Where(Function(x) x Mod 2 = 0).[Select](Function(x) Convert.ToByte(shex.Substring(x, 2), 16)).ToArray()
End Function

Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click

Dim public_key as String = "2b4632d08485ff1df2db55b9dafd23347d1c47a457072a1e87be26896549a8737"
   Dim pubkey_hash As String

    Dim sha256 As SHA256 = SHA256Managed.Create()
    Dim bytes As Byte() = System.Text.Encoding.Unicode.GetBytes(public_key)
    Dim hash As Byte() = sha256.ComputeHash(bytes)
    Dim stringBuilder1 As New StringBuilder()

    For i As Integer = 0 To hash.Length - 1
        stringBuilder1.Append(hash(i).ToString("X2"))
    Next

    bytes = HexStringToByteArray(stringBuilder1.ToString())

    Dim ripemd160 As RIPEMD160 = RIPEMD160Managed.Create()
    Dim hash_160 As Byte() = ripemd160.ComputeHash(bytes)

    Dim stringBuilder2 As New StringBuilder()

    For i As Integer = 0 To hash_160.Length - 1
        stringBuilder2.Append(hash_160(i).ToString("X2"))
    Next

    Dim arr() As Char = stringBuilder2.ToString

    pubkey_hash = arr.tostring
    TextBox14.Text = pubkey_hash

   End Sub

and is there any way I can shorten this code? loops & if statements etc

I'm starting to wonder how difficult it is to find people who are helping others in this site

I don't have your same idea, but sorry for the delay in the answer but in Italy exist at the moment the alert "coronavirus".

My test to resolve your problem

I don't know the language of the code that you have public in the question but I have a project to decompiler script bitcoin but is in the start phases.

I'm answering with C++ code.

Exist two types of Public key, that is compressed and uncompressed, the difference is:

Compressed public key started with a flag "02" (I think this is your cases)
Uncompressed start with the flag "03"
If the you key start with "04" doesn't is the public key but is a P2PK script.

But a good reference that explains the compressed public key is this What is a compressed Bitcoin key?

So, I think your error is the public key input,your public key is 02b4632d08485ff1df2db55b9dafd23347d1c47a457072a1e87be26896549a8737 and not 2b4632d08485ff1df2db55b9dafd23347d1c47a457072a1e87be26896549a8737, you have lose the the part of flag of the compressed public key.

So, my C++ code to test my idea is this:

    cout << "Test for Bitcoin.stack question" << endl;
    cout << "Public Key: " << "02b4632d08485ff1df2db55b9dafd23347d1c47a457072a1e87be26896549a8737\n";
    string keyTmp = "02b4632d08485ff1df2db55b9dafd23347d1c47a457072a1e87be26896549a8737";
    string flag = keyTmp.substr(0, 2);
    if(flag == "02"){
          cout << "Compressed with y event";
    }else if(flag == "03"){
      cout << "Compressed with y odd";
    }else{
      assert(flag == "04");
    }
    Bytes bytesTmp = hexBytes(keyTmp.c_str());

    //SHA256
    Sha256Hash shaHash = Sha256::getHash(bytesTmp.data(), bytesTmp.size());
    uint8_t result[Ripemd160::HASH_LEN];
    Ripemd160::getHash(shaHash.value, sizeof(shaHash), result);

    cout << "Hash Public key: " << ToString(result);

The hash public key ofter run this code is: 93ce48570b55c42c2af816aeaba06cfee1224fae

References

The reference of the project are off-topics here but I think without it this post can be fake, so I'm adding the reference of the library used to implement my code in this answer.

Bitcoin-Cryptography-Library
decompiler-bitcoin-script: this is my start project to undestend how bitcoin script work, so you can found the idea if you want implement other feature inside your work.
Github gits code


Should block height or MTP or a mixture of both be used in a soft fork activation mechanism? Should block height or MTP (median time past defined in BIP 113) or a mixture of both be used in an activation mechanism like BIP 8 or BIP 9 for defining the timings of the state transitions?
What are the advantages and disadvantages of both and how do they compare?

Should block height or MTP (median time past [...]) or a mixture of both be used in an activation mechanism like BIP 8 or BIP 9 for defining the timings of the state transitions?  What are the advantages and disadvantages of both and how do they compare?

The main advantage of MTP is that it usually roughly corresponds to wall time, so it's easy to communicate what a number means to humans.  For example, BIP141 says: "the BIP9 starttime will be midnight 15 november 2016 UTC [...] and BIP9 timeout will be midnight 15 november 2017 UTC".  When both of those MTP values were reached on the actual network, they were within three hours of actual UTC.
The main disadvantage of MTP is that it can be manipulated by miners.  MTP is the median of the value recorded in the nTime field of the current block header and the previous 10 blocks.  Miners can set their nTime values to any value greater than the current MTP and less than two hours in the future.  This makes it possible for a majority of miners working for an extended amount of time to hold MTP to an old value (say 3 months ago) and then, in the space of a single block, move to a much later time (say 1 month ago).  This can allow them to jump over MTP-based mandatory signaling periods such as specified in BIP148.
The main advantage of block heights is that there's no way to skip over a height-based threshold, so they make sense for flag day activations, mandatory signaling requirements, and other transitions we want to ensure happen (such as from BIP9 LOCKED_IN to ACTIVE, which happens using a relative height-based threshold of 2,016 blocks).
The main disadvantage of block heights is that they're not particularly consistent.  In an average year, we expect there to be 52,596 blocks, but it would not be extraordinary for there to be 58,440 blocks---reducing an intended 12-month deployment to 10.8 months.
There's no harm in mixing MTP times and heights, and there can be significant advantages if you can take advantage of both strengths at the same time without losing too much to their weaknesses.


Is PoW and consensus unnecessary without double spending? Satoshi's whitepaper claims that the reason there must be a consensus on all transactions is to solve the problem of double spend. I'm curious then, how would a non-consensus based system work if double spend were not a problem?
If a coin is still represented as a series of transactions, each of which is verifiable, and these are submitted as proof of ownership during transactions, then how can one prove that the entire coin is valid? While no one can fake a spend from an unwilling party, it seems you could fake the entire coin altogether.
The only solution I see to above is that each coin is initially issued and signed by a trusted party. Once these coins are in existence the trusted party is removed.

The only solution I see to above is that each coin is initially issued and signed by a trusted party. Once these coins are in existence the trusted party is removed.

This is not correct. Why would that party need to be trusted?
Is the issue that they might sign more coins than they said they would sign? But that's a double spend problem. Right?
A double spend is when a party is only supposed to transfer X coins but they sign valid transactions to transfer Y coins where Y is more than X. The assumption we started with is that double spend isn't a problem. So there is no need to trust the "trusted party" since the only problem would be if they double spend and the starting assumption was that double spend wasn't a problem.
At every point in the system's existence, there has to be some set of future transactions that are valid and some set of future transactions that aren't and everyone has to agree on which transactions go in which set if they know the system's state. The system's initial state is also a system state, and so part of the system's rules have to be to see which transactions are valid from the initial state.
So simply a rule that there exists spendable tokens in the system's initial state is sufficient. The party that can spend those initial tokens doesn't need any special trust -- they are no different from any party that can spend any tokens in any other state.


How to get the number of the confirmed transactions from Bitcoin QT Rpc We are building a generic wrapper around Bitcoin-Qt. I wonder if there is way to get the information about the confirmation count of a transaction from a Bitcoin-QT having an empty wallet using the RPC command.

You can use the RPC command "getrawtransaction" to receive a JSON response with information for that transaction including a "confirmations" field if that transaction has been included in a block (if there are 0 confirmations the confirmations field will not be there). You should note though that if you are looking for transactions that are not actually a part of your wallet (from or to an address you don't have the private keys for) bitcoin-qt by default won't keep track of these transactions and will have to be run with the "txindex=1" flag set to keep a full transaction index.


Using only Javascript and JS related Bitcoin Libraries. How do you extract the Bitcoin Address from a private key? I'm building an js related application that only stores my user's bitcoin private keys, but not the public key or bitcoin address to save space.

Is there a javascript library that can output the bitcoin address by only providing the bitcoin private key as an input?

Try bitcoinjs-lib

The following will generate a P2SH(P2WPKH) address

const bitcoin = require('bitcoinjs-lib')

let ecpair = bitcoin.ECPair.fromWIF('L34XqVbrw1VSHsiavdpm4QGTRrFyH7RKAp7SFYf36gYcyLX2ieWi')
let address = bitcoin.payments.p2sh({redeem: bitcoin.payments.p2wpkh({ pubkey: ecpair.publicKey })}).address

> '3F1JMjuxgNFuK4kBxv4JXMEdQ2yvjuz939'


Can Bitcoin Days Destroyed be a better resolution mechanism for competing blocks? I've been looking at selfish mining and empty blocks.  In all cases, the selfish miner profits by keeping block solutions private until their value to his own pool is maximized, rather than releasing them ASAP which is the honest way to do it.

If the protocol were changed to make holding back a block far riskier than it is currently, I think this would go a long way to solving the problem presented by selfish mining.  A selfish pool holds a solved block until someone else solves a block at the same height.  The selfish pool then releases its pre-solved block (having had time to privately seed the global network so that as many honest miners as possible will see the selfish block first) to orphan the honest miner's block.  Currently, the risk is that enough honest miners might choose the honest block with the result that the selfish miner loses both the reward for having solved it first and the advantage of being one block ahead. The papers on selfish mining show that this risk is not great enough to prevent selfish mining.

The protocol currently expects a miner to use the first block that adds to the chain.  If this rule (actually a suggestion) were changed to expect a miner to use the block that destroys the most bitcoin days, selfish miners would risk far more by holding back their solutions.  It would still be relatively easy for a selfish miner who has gotten ahead to exploit his position by saving the solution until it can be used (if it destroys more bitcoin days) to orphan someone else's solution, but the risk that the other solution might destroy more bitcoin days would be significant.  Even if the selfish miner seeded his solution with his own very old UTXOs, he would be wasting some of his ammunition (bitcoin days).

Additionally, the rule that a miner use the first seen block or any other rule to resolve conflicts when two blocks show up as possible extensions to the current chain is not enforceable.  So perhaps what is needed is not for the protocol to change, but for miners (who would like to prevent the selfish mining attack) trying to decide between two new block heads to use bitcoin days destroyed to decide.  Publishing this idea, however, is not warranted until it has been criticized for flaws.

So have at it!

Thanks to Murch, I'm answering my own question; Yes!

Murch made the point that using BTCDD enables a selfish miner to mine a non-broadcast transaction that spends old coins rather than having to rely on a network propagation advantage.  I understand this objection.  That advantage is easily removed by excluding from your BTCDD calculation transactions that you didn't see until you got this new block.  Now the selfish miner has to broadcast his old-coin transaction.

(edit due to comment:) While it is true that some BTCDD-heavy transactions will have gotten to one miner and not another, making the tie-breaking strategy arbitrary, because neither will have the BTCDD-heavy transaction privately mined by the selfish miner, it is still more effective at discouraging selfish mining than letting the network choose randomly, if and when you can assume that most miners will have seen both blocks around the same time.  BTCDD is arbitrary because of incomplete propagation of transactions, but because of fully propagated transactions, it is less arbitrary than first-seen.

Also, you can't spend just a part of an input.  I submit that it's harder to have (enough) old coins than it is to set up a global network of tightly connected nodes for cheating.  I suppose I could be wrong, but old coins is always a dwindling resource and global nodes willing to help cheat is probably a growing one.

The only purpose for orphaning a block is that you've already been mining on top of your replacement for it. This point was made soon after Sirer and Eyal described their selfish mining vulnerability, though quite indirectly.  Using a "later block" to do that would severely diminish the advantage.  The point is to discourage sitting on solutions by making the later block more likely to be accepted.  Would you consider throwing away any seconds of your own mining when you see an alternate solution?  To discourage selfish mining, I'd do a few seconds, I guess.

I also very much like discouraging empty blocks, but who mines empty blocks just to do a selfish mining attack?  Oh wait, that's probably the best way to do it!  Hmm...


To what extent does asymmetric cryptography secure bitcoin transactions? Is there a specific attack or bug which asymmetric cryptography prevents during bitcoin transactions?

Is there a specific attack or bug which asymmetric cryptography prevents during bitcoin transactions?

asymmetric cryptography is not really something that was added on top of Bitcoin in order to prevent some specific attack or fix some specific bug.

asymmetric cryptography is one of two fundamental foundation stones, one of the two primary building blocks on which the Bitcoin concept is based. Without asymmetric cryptography and one-way hash-functions the whole idea of Bitcoin would not have got started at all.

asymmetric cryptography underlies almost everything that is important in Bitcoin. Without asymmetric cryptography there could be no Bitcoin.

If I had to identify one thing that asymmetric cryptography provides it is that it prevents 7 billion other people being able to remove money from your wallet whenever they want and you being powerless to stop them. Its the difference between putting your cash in a safe only you know the combination for and leaving your cash on a park bench in the center of a crowded city while you go elsewhere for a year.

You might enjoy watching the two videos at https://anders.com/blockchain/ (watch both and in the right order) They are very easy to follow and reasonably brief. The first sets the scene, the second builds on that to answer your question (but you have to watch the first before the second)


How are the assets locked and unlocked trustlessly using sidechains? I am reading sidechains white paper and in section 3.2 Symmetric two-way peg they mention that:

"The parent chain coins are sent to a special output on the parent chain that can only be unlocked by an SPV proof of possession on the sidechain. I dont get how the coins can be locked on a blockchain.

Are they referring to locking it in a multisig address or something?
Who has the private key of that locked address?

This is my conceptual understanding, which will hopefully be useful here, but I'm sure there are technical subtleties that I am not including, which some more experienced with the side-chains project would be able to give more insight into.

First, we need to have a clear definition of an SPV proof. I will use SPV proof to mean: A bit sequence that proves that a transaction has a substantial amount of work committing to it. It is desirable for this proof to be as small as possible.

Essentially, you start by sending some coins on the main chain to an output that has a scriptPubKey that says

OP_SPVPROOFVERIFY

Then wait until it has sufficient confirmations (1-days worth, I think), and you take this UTXO, represented by the pair (txid, n), and go over to a sidechain make a transaction that uses an SPV proof of the output being in the confirmed blockchain to issue new coins. This is essentially like moving coins from one blockchain to another.

Then when you're done using them on the side-chain, you make a new output with the same number of coins, maybe sending them to OP_RETURN. Thus, you've given up your coins on the side-chain, allowing them to be re-claimed on the main chain. Before you can re-claim them, though, you have to wait for 1-days worth of confirmations on the sidechain, and then construct an SPV proof that the coins have been destroyed in the sidechain. This SPV proof is what lets you unlock your coins from the OP_SPVPROOFVERIFY output that they were locked in before.

For more info on compact SPV proofs, see:

Appendix B of the Sidechains white paper.
This post on the bitcoin-dev mailing list
Is there a PoW system that shows cumulative work without an ever-increasing proof size?


Worries about ability I have never been the best at math. However I am pretty good with computers. If I buy the gear to mine the coin how hard is it to work the machinery and do the work to make the coin?

Based on this question, it seems like you did not research bitcoin mining enough.

At this point, mining bitcoin is not profitable for the average user unless you have close to zero electricity fees and a pretty powerful computer to start with.

The bitcoin difficulty is always going up, making any investment into hardware obsolete. Most mining farms are in China due to these reasons.

You yourself do not solve math problems when mining, instead you computer will solve mathematical puzzles that the bitcoin network gives it. The faster you find the key to the puzzle (you need a fast computer) the more coins you may mine. At this point, the profitability for bitcoin mining is close to zero for the average user.


Transfer different currencies between wallets I had SCOTCOIN in a counterwallet.io address and I transferred it to a Coinbase BTC wallet. I wouldn't have thought the transaction would have worked but it did. The amount of BTC in the Coinbase wallet in no way reflects the going exchange rate.

What's gone wrong and can it be fixed?

You can send one kind of cryptocurrency to another cryptocurrency's wallet. The transaction will complete but the coin will be lost.


What happens if the commitment tx fee is too low? How often are commitment tx fees negotiated?
Is it every time a payment is made and a new commitment transaction is formed?
What about if there are no payments but both nodes see that the on chain tx fees are rising, do they renegotiate and update their previous commitment txs?
If Bob goes offline and never returns, but the latest commitment tx is very old and the tx fee is too small to be included in a block, is there anything Alice can do to force close the channel? (anything other than getting directly involved with mining).
I believe "Child Pays for Parent" wouldn't work to help a force-close situation because the local output is encumbered by a to_self_delay relative to the time of it being mined, so the same miner couldn't include the "Child" in the same block. Is that correct?

Only if the state changes fees are negotiated (and for mutual closing the channel) so in case the onchain fees change and the channel is not used for a long time just send a fake payment hash to adapt to onchain fees.

Regarding 2 and 3. Nothing Alice can do. She just has to wait until the traffic on chain decreases. There are some ideas to include a dust level anyone can spend output to the commitment tx without timelock which could use cpfp


How to set the sequence number in a coinbase transaction? The sequence number seems to be used for locking a transaction in mempool. However, the coinbase transaction is not part of the mempool and thus the sequence number does not make sense.
Is it just an "extra nonce"? Or is there any constraint on the sequence number in a coinbase transaction?

There are no special requirements for the sequence number in coinbase transactions. It is subject to the normal sequence number rules, but for coinbases, those largely don't matter. While it can be set to anything, miners generally just leave it as the maximum sequence number rather than using it as another nonce.


The scope of lightning channel fee For the following setup:

         A   ----(HIGH Fee rate) ----  B  ----------------  C

B want to charge A for more fee, he raises the fee of the channel between AB

A pays to C
A pays to B
C pays to A

Does high fee rate only affects case 1 only??

No, only the third case is affected. And the reason for that is that channels are actually bi-directional and have two fee policies depending on the direction they are used.

For example, channel AB has a policy from node A, and a policy from node B. If B increases the fee - it will only affect the payments going from B to A, not the other way around.

That means that scenario 2 in your case is always controlled only by node A. Scenario 3 includes the payment from B to A, so fees will be higher. Scenario 1 can also be affected by node B, but it will need to increase fees on the channel BC, not AB.


Got a malware and need help Someone sent me 1000$ but when I pasted my adress this happen:

15nTPsVp3EGk78FUGcmAyqCnFCsfv6shLb (mine)
15QrWeM7HcJz8haNQUtq6KU23GDSHn8xxx (hacker)

It's been 6 hours and still unconfirmed on blockchain and it's not on blockexplorer.

Is there anything i can do or sender to cancel the trade?

I've watched videos about how to double spend but I'm afraid it will help the transanction go through.

It's not clear what you mean since your address has no transactions and the address of the hacker is censored but I assume that someone transferred the money to that addresses instead.

The sender can send the money someone else with a high fee. It's really important to do this as soon as possible because once the transaction is included in a block, you cannot undo it. It might be necessary to back up the wallet and re-import it because this is double spending and wallets usually prevent it so all your payments can go through and you don't try to spend more than you have (which will not work out for all payments anyway).

However, in this case you want to double spend so the first transaction doesn't go through and the second transaction does. For this, include a relatively high fee in the second transaction so it will be picked by the miners, not the one the hacker made.

Edit: I just saw that you posted this 12 hours ago, so this answer is probably too late. Sorry for your money. But it might be that the sender is trying to rip you off by sending the money to one of their own addresses and claiming they tried to send it to you. Don't pay!


BItcoind/P2Pool What am I doing wrong? I am running latest bitcoind and p2pool releases (default port settings) on Fedora 21 with ports open for 3332-3333, 8332-8333, and 9332-9333.  Everything appears to be well when connecting to the BC net, but when one of my miners (Antminer S5) connects to http://myhostname/IP port 3333 p2pool will not respond.  When I try to connect with port http://myhostname/IP port 9333, I get a twisted error complaining about authentication, but when I try to connect to port myhostname/IP (stratum+tcp??) port 9333 it looks like the miner is trying to connect and get work, but after several seconds p2pool reports a "handshake timeout" for the miner IP address.

This is the error I get:

2015-02-25 18:05:35.107254 Got peer connection from: IPv4Address(TCP, '192.168.0.21', 45024)
2015-02-25 18:05:45.108525 Handshake timed out, disconnecting from 192.168.0.21:45024
2015-02-25 18:05:45.109817 Peer connection lost: ('192.168.0.21', 45024) [Failure instance: Traceback (failure with no frames): <class  twisted.internet.error.ConnectionAborted'>: Connection was aborted locally, using.
2015-02-25 18:05:45.110143

What am I doing wrong?

The p2pool node communicates on more than one port. By default, miners connect to the node on port 9332 and other p2pool nodes ("peers") connect on port 9333.

So just switch your miner to port 9332, that should fix your issue.


I have a question. Can the price change if your transaction remain unconfirmed for a couple of hrs I had to make a payment with bitcion to a wallet with specific amt. I made exact payment, but price bitcoin was going up. But my transaction was still unconfirmed till the evening. They rejected my payment bc the payment was a $3 more when they confirmed it.Can the price change if your transaction remain unconfirmed for a couple of hrs. It

In terms of value, the Bitcoin network knows only about satoshis and has no awareness of what other currencies (JPY, AUD, GBP, EUR, USD) peg to against it.
So when you create a bitcoin tx to send value to another party, that's always denominated in satoshis on the network; that doesn't change at all.
As you've observed, the dollar value may change if you paid a low tx fee, or the network was busy for the fee you paid, and therefore by the time it is mined, more dollar value may arrive, or less.
You've got a few options to avoid this - one is to pay a higher fee to reduce the time you're waiting for the tx (make sense on large valuable purchases), or to use the Lightning Network where fees are lower and settlement is near-instant.


Why does Bitcoin-QT not seem to be catching up on my Mac? I've had Bitcoin-QT running for about six total hours, and the rate at which it's catching up is glacial at best. It takes about an hour to advance a week, which would make the process take about 4 days to complete. It didn't take nearly this long on my PC; I started and finished the process while my Mac was still running. I'm running Bitcoin-Qt v.0.10.1 64-bit on a 2011 MBP, 8 GB of RAM, on 10.10.4. Is this normal, or is there something wrong?

Sadly Bitcoin-Qt's (and bitcoind's) default DB cache size is very small for systems like yours.

You should definitively add -dbcache=4000 (use 4GB of RAM for UTXO-set-database [etc.] cache).
This should speedup your sync significant.


bitcoin-cli "getbalance" always returns 0 I have bitcoind running on windows and currently it's syncing the blockchain. Nevertheless, command getbalance always returns zero as value. Even if I seach for an address which has bitcoin.

E.g.
C:\Program Files\Bitcoin\daemon>bitcoin-cli.exe getbalance "[address...]"
0.00000000

Why does it always return 0? I would like to get the address balance of a specific address. I used an address from blockchain.info which had a balance before the current downloaded block.

getbalance only applies to addresses you own (and are in your wallet.dat).


Tendermint consensus: Are validators "known" and "pre-selected"? What are similarities and differences between Tendermint consensus and Proof-of-Stak?

For example, in both consensus, a validator is selected randomly (I think in Tendermint consensus they are selected in a round robin process).

And I think in Tendermint consensus, validators are known and pre-selected, unlike Proof-of-Stake consensus. Is it true? and if yes, what entity does confirm a known validator?

Yes they are known. They are selected via a round-robin fashion. The Tendermint team intend to add a VRF to randomly select validators:

https://github.com/tendermint/tendermint/issues/763


Bitcoind returning "Invalid JSON-RPC 2.0 response"? I am starting to use a basic implementation of Bitcoin JSON RPC (dzhuvinov library), and I am getting a strange result. Here is my code:

public static void main(String[] args)
{
    URL serverURL = null;

    final String rpcuser ="user";
      final String rpcpassword ="pass";

      Authenticator.setDefault(new Authenticator() {
          protected PasswordAuthentication getPasswordAuthentication() {
              return new PasswordAuthentication (rpcuser, rpcpassword.toCharArray());
          }
      });
    try {
        serverURL = new URL("http://127.0.0.1:18332/");

    } catch (MalformedURLException e) {
        System.err.println(e.getMessage());
        return;
    }
     JSONRPC2Session mySession = new JSONRPC2Session(serverURL);
     String method = "getinfo";
     int requestID = 0;
     JSONRPC2Request request = new JSONRPC2Request(method, requestID);
     JSONRPC2Response response = null;
     try {
             response = mySession.send(request);

     } catch (JSONRPC2SessionException e) {
             System.err.println(e.getMessage());
             return;
     }
     if (response.indicatesSuccess())
        System.out.println(response.getResult());
    else
        System.out.println(response.getError().getMessage());
}

And the response I am getting is:

Invalid JSON-RPC 2.0 response

Just to note - when executing this Python script:

access = jsonrpc.ServiceProxy("http://user:pass@127.0.0.1:18332/")
print access.getinfo()

I get a proper results.

What might be causing this problem and how should I go about fixing it?

As it turns out, the library I am using does not like JSON responses that contain both the field "error" and "response", even if the "error" field is set to null. I have already notified the creator of the library to possibly fix that issue and I have patched it myself as well:

In the private Map<String,Object> parseJSONObject(final String jsonString) function, one needs to add this at the end:

    Map<String,Object> answer = (Map<String,Object>)json;

    if (answer.containsKey("error")){
        if (answer.get("error")==null){
            answer.remove("error");
        }
    }
    if (answer.containsKey("result")){
        if (answer.get("result")==null){
            answer.remove("result");
        }
    }

    return answer;


How to Sync Main Net together with Test3 Net After I install the bitcoin core, it just sync the main net.

Is there a way that I can also sync the test3 net for testing/developing purpose?

Start another instance of Bitcoin Core with the -testnet option to run it in testnet mode.


Is there a way to automatically send bitcoins from one wallet to another? Say I have 2 wallets, an older non-encrypted one and a fresh new encrypted wallet with all new addresses. If I have an address in the older wallet that may receive some bitcoins in the future is there away to set it up so that these bitcoins will automatically be sent to an address in the new encrypted wallet. Or do I have to keep my old wallet for ever in case an address in it receives some bitcoins and then manually send them on to the new wallet.

You may use /etc/crontab on your Ubuntu:

* * * * * root /usr/local/bin/bitcoin_resender

And script shall looks like:

$ cat /usr/local/bin/bitcoin_resender
#!/bin/bash
if [ $(echo "$(bitcoind getbalance) > 0" | bc) -eq 1 ];then
      bitcoind sendtoaddress YOUR_NEW_ADDRESS $(bitcoind getbalance) "Comment for resender"
fi

It will check every minutes your bitcoind balance and resend each bitcoins to YOUR_NEW_ADDRESS.


I made a Bitcoin Core deposit and don't have a big enough HDD to download data Wondering if anyone can help me. I downloaded bitcoin core (not realising you have to download all bitcoin data with it) and I am on a mac so I don't have enough disk space to complete the download (even if my disk was empty). I therefore have BTC in the account but will never be able to spend it, is there anything I can do?

Or you can buy a cheap USB 1Tb harddisk. Plug that in and then at startup elect to put the datadir (AND THE WALLET) on that.

If you do this and then send any coins make sure you backup the wallet.