In Ethereum smart contracts is it cheaper to keep all the data, or delete old data? As I understand, Ethereum smart contracts can store data internally. I am wondering - is it cheaper for a smart contract to keep all of its data forever if it is keeping the data for any length of time, or does deleting unnecessary data from the contract after it has been used better (even though you have to pay for the operations)?

For example, if I have a contract that keeps a record of everyone that triggered it in the last day, does it make sense for me to remove that data the following day when it is no longer needed, or since the storage was already paid for, there is no point in deleting the old data?

You get a gas refund of 15000 for resetting a storage slot to zero, but you have to use this gas during the current transaction (more specifically, you get at most one half of the total spent gas as a refund). This means you can trade some cleanup with other operations, but you will never be returned such refunded gas in ether.

So the general idea is that if you e.g. have a crowdfunding contract, the function that checks whether its goal has been reached is cheap to execute even if it clears all the data and sends funds around.

But if all you do is to delete the data, you are probably better off just leaving it there, as the transaction that deletes the data will never be free.


How to get private key from dogecoin wallet android app As title, I've got an encrypted string, which gives me .org.dogecoin.production.blabla (or something like this) after I use openssl enc -d -aes-256-cbc -md md5 -a -in ENCRYPTEDFILE -out dogecoin-wallet-decrypted
After browsing, some gives me the idea to go through BIP39. Anyway, actually I don't understand it, though I did find a 12 words Mnemonic code.
So what's next ? Thanks for any help.

You'd need to name the wallet specifically. https://play.google.com/store/apps/details?id=org.dogecoin.production.blabla doesn't exist.
Assuming you were using a fork of the schildbach wallet, the general procedure based on the most likely fork is:
https://github.com/langerhans/dogecoin-wallet-new/blob/1ee32cc/wallet/README.recover.md
Your trouble will arrive when you try to use bitcoinj to decode your protobuf.  You will want to find a fork that supports dogecoin.


Analysing the raw block Hex file but I can not find the expected information My goal is to understand better, how transactions and blocks are built raw. For that, I found several questions and answer here on StackExchange, but the best for me was this post:
Download single and specific block for study purposes

Then I followed the information in this answer and had a look at this block.

Raw HEX file of the block here.

Now my question is:
Why do I not find transaction hash in the raw hex file?

When I am looking for a specific transaction hash (e.g. "909374f0cc117...) I do not find it. I thought each transaction is added to the block. Maybe not the hash of the transaction?

Each transaction is indeed added to the block, but only its contents, the hash is then derived by hashing the transaction data twice with SHA-256.

This image explains how a block is laid out in hex.


What multi-sig wallets are there for Android/Jolla? TL;DR: What wallet apps are there for android (or sailfishOS) that has "true" support for multisig?

Requirements/rationale

Thinking a bit, if I'm to possess serious amounts of bitcoins, I want a well-secured savings wallet - or, eventually just a well-secured savings address.  After some thinking, the requirements seems to be:

1) it should not be easy to withdraw funds, withdrawing should either involve multiple people or the passing of a time window.

2) the bitcoins must be secured against my death

3) the bitcoins must be secured against loss/theft of a private key

Solution: multisig

One stupid-simple solution would be to generate a single private key, write parts of it down on 5 papers in such a manner that any three out of five papers needs to be recovered to learn the full private key, seal the papers in envelopes, and then distribute those envelopes to people/locations I trust, instructing them to keep them in a safe place and hand them over to my next in kin in case of my death.  It actually seems like a decent way to solve this.

Anyway - why bother with such obscurity when bitcoin supports multi-sig transactions out of the box.  Even for daily usage patterns multi-sig seems like a good idea.  As for a savings wallet, I think that in the start it would suffice with 2-of-3 - me and my wife, plus a third arbitrator that can help us out in case of death or divorce.  Armory seems to be the go-to-wallet for the Linux desktop - but I'd like access from mobile devices as well.

Apps tested so far

copay - it could do the trick, but it seems to be a "lock-in platform" - all signing parties needs to have copay installed.  That's not acceptable.  For one thing, I want a platform neutral solution, like a savings wallet I'd mainly access from a "proper" laptop/desktop.
"bitx smart wallet" - what kind of beast is this, requiring me to verify my email before use?
greenbits/greenaddress - seems like their "multisig support" is very narrow; only 2-of-2, with their servers acting as one of the signing parties, and offering to sign against 2f-authentication.  Totally not what I want.
yet another android wallet that came up when searching for "multisig" - but it apparently had no support for multisig.

If I go slightly of topic I will recomend you to incorporate a solution using a law of trusts if your law system has it incorporated.

I am still about to recommend you Copay wallet as it is open-source. You can even rebrand it to your own company.

You have to remember that you can use HD wallet with Copay. You can use Bitcoin Trezor with copay so you have strong security. And all of this could be saved to a secure place.


Imported address:private key Please I want to ask how can I get the private key so to withdraw from my imported address and is it possible that you get to pay a certain amount of btc to get the private key..thanks in anticipation

You are the victim of a scam. Please don't send anymore money to the scammers and in future read about how bitcoin works before you put your money into it.


How old do you need to be to buy bitcoins in a atm? I've read all the others Q&A and I haven't found the answer to my question or I haven't noticed. I live in Spain and is there an age restriction to use an btc atm (I'm 16)?

I know for age limits when buying alcohol, cigarets.....but for using ATM (normal usage or buying BTC)? Never heard for this....maybe you should first learn, how ic/is not BTC regulated in Spain (is it recognized as a curency, comodity ext...) and start from there?


Sent bitcoins to a suspicious address! I just may have been scammed via a phishing link. The transaction is verified but not confirmed, I'm new to bitcoins, as you can probably tell. From the quick bit of research I've done there is nothing I can do. It was only $20.

Here's my question, Is there anyway to make sure the transaction doesn't confirm or send the bitcoins out of my wallet before it confirms?

I think Opt-in Replace By Fee is what you are looking for. The wallets implementing RBF lets you mark your transactions as unfinished and that let's you replace it with more fees than the previous one. But merchants are advised to wait for at least one confirmation before accepting optin rbf transactions (to avoid a double spending risk).

The only wallet I know that have implemented RBF is Electrum.

Below you have some useful links:

https://bitcoincore.org/en/faq/optin_rbf/

https://petertodd.org/2016/are-wallets-ready-for-rbf

https://electrum.org/#home


Encoding my Bitcoin Address with Base58 encoding I am trying to convert my Bitcoin Address with BitcoinJ in order to look like a normal address such as this:
1J7mdg5rbQyUHENYdx39WVWK7fsLpEoXZy.

I haven't found anything exept for the Base58.encode() which takes the getPubkeyHash() of my ECKey and returns something like this:
5ahorsFsHTcG3f662evowc5c9zf.

Which means that encodes the given bytes in base58,no checksum is appended according to the API.But i want my address to look like the above one.

Is there any algorithm in java  for encoding address_byte_string (consisting of 1-byte_version + hash_or_other_data + 4-byte_check_code)?

according to this:https://en.bitcoin.it/wiki/Base58Check_encoding

Yes.

ECKey key = ...;
String addr = key.toAddress(MainNetParams.get()).toString();

https://bitcoinj.github.io/javadoc/0.12/org/bitcoinj/core/ECKey.html#toAddress-org.bitcoinj.core.NetworkParameters-


Fetch UTXO Bitcoin to address created by rpc importprivkey without rescan like other api For few reasons, I must use rpc node to handle wallet at this time. In the near future, I will change the flow to use library to create addreses, store privatekey at database and create raw transaction. That means I will use rpc node for broadcasting only, not depend on it too much. But I need time to do, so I will divide this period to few parts, firstly, I will start at creating and store address:
I have both hex private key and wif key, then I use importprivkey to import wif key to rpc node without rescan because I have a large request contacting to rpc. If those addresses are fresh, it's very nice scenario, each new input to them will automatically fetch UTXO by using listunspent command to check.
In other case, the very worst scenario, for maintenance or backup, I import an address which contains old UTXO and wanna fetch these UTXOs to addresses without using rescan command (it takes a long time to complete), like other api just put address and get UTXOs in a blink.
https://testnet.blockexplorer.com/api/addr/myzhMVXT39L7nnco6TtJ2a7sYaEo8ixT4Q/utxo
Is there any ways to fetch old UTXO to address in rpc node without rescan? Because these api are very fast response, I think they're not using rescan. For long term, using other api is not good for my project, I'm using version 0.16 (I know it's very old but the project need time to change it slowly and carefully), thanks for help so much.

Because these api are very fast response, I think they're not using rescan.

No, they maintain massive databases that index every transaction and transaction output and their associated addresses. Bitcoin Core does not need this for normal function, and the vast majority of users do not need access to such information. Bitcoin Core does not and cannot build such databases.

  I'm using version 0.16

Then there is nothing you can do.

If you were using 0.18, then you could use the scantxoutset command to just scan the UTXO set for UTXOs. This is very quick, and you can specify multiple addresses to do it as single batch scan. scantxoutset will give you all of the UTXOs for the specified addresses but will not add them to any wallets loaded in Bitcoin Core. However, it does not sound like you are using the wallet so that should be fine.


Bitcoin raw transaction with manually created redeem script I am running bitcoin in regtest mode with 2 nodes bitcoinNode1 and bitcoinNode2.I have created a redeem script by writing the opcodes and converted into hex form using btcc.

HP-ProBook-440-G4:~$ btcc OP_IF OP_SHA256 a967bf5e8ca09e059d6bb7a3efa8f62190284649d3eab773518827164ac481fb OP_EQUALVERIFY OP_DUP OP_HASH160 f5fb6147ff889a392211d0f0831a71137bedbff1 OP_ELSE OP_200 OP_CSV OP_DROP OP_DUP OP_HASH160 cac5d03956494ffc17f78ea7b71189abf7f3593d OP_ENDIF OP_EQUALVERIFY OP_CHECKSIG

O/p: 63a820a967bf5e8ca09e059d6bb7a3efa8f62190284649d3eab773518827164ac481fb8876a914f5fb6147ff889a392211d0f0831a71137bedbff167064f505f323030064f505f4353567576a914cac5d03956494ffc17f78ea7b71189abf7f3593d6888ac

Now i am trying to create a raw transaction using the redeem script.

HP-ProBook-440-G4:~$ bitcoin-cli -regtest -datadir=./bitcoinNode1 -conf=./bitcoinNode1/bitcoin.conf -rpcuser=user1 -rpcport=19001 createrawtransaction "[{\"txid\":\"818978d31bf63158612d080c4a934a78a52f52f7bc797cc1f84f6ca8cc4b2dea\",\"vout\":0}]" "[{\"63a820a967bf5e8ca09e059d6bb7a3efa8f62190284649d3eab773518827164ac481fb8876a914f5fb6147ff889a392211d0f0831a71137bedbff167064f505f323030064f505f4353567576a914cac5d03956494ffc17f78ea7b71189abf7f3593d6888ac\":0.01}]"

But i am not able to create as it says invalid bitcoin address.

Should i convert the redeem script into p2sh? If yes can you please suggest how to create p2sh and do raw transaction with that p2sh?

You can't just give Bitcoin Core the redeemScript, it won't know what to do with it. The only valid thing to give it is an address, but you have not given it an address. You need to convert your redeemScript into a P2SH address first, then you give it that address.

You can use the decodescript command to get both the p2sh and p2wsh addresses for your redeemScript:

$ bitcoin-cli decodescript 63a820a967bf5e8ca09e059d6bb7a3efa8f62190284649d3eab773518827164ac481fb8876a914f5fb6147ff889a392211d0f0831a71137bedbff167064f505f323030064f505f4353567576a914cac5d03956494ffc17f78ea7b71189abf7f3593d6888ac
{
  "asm": "OP_IF OP_SHA256 a967bf5e8ca09e059d6bb7a3efa8f62190284649d3eab773518827164ac481fb OP_EQUALVERIFY OP_DUP OP_HASH160 f5fb6147ff889a392211d0f0831a71137bedbff1 OP_ELSE 4f505f323030 4f505f435356 OP_DROP OP_DUP OP_HASH160 cac5d03956494ffc17f78ea7b71189abf7f3593d OP_ENDIF OP_EQUALVERIFY OP_CHECKSIG",
  "type": "nonstandard",
  "p2sh": "33bzAemHYJdN1XciQGqj4v48F5YFinQGcY",
  "segwit": {
    "asm": "0 6b2b3b1c6a0f8c15b5cdac185339555ec0d537304b367f73ab615d55c9719607",
    "hex": "00206b2b3b1c6a0f8c15b5cdac185339555ec0d537304b367f73ab615d55c9719607",
    "reqSigs": 1,
    "type": "witness_v0_scripthash",
    "addresses": [
      "bc1qdv4nk8r2p7xptdwd4sv9xw24tmqd2desfvm87uatv9w4tjt3jcrs2a06tv"
    ],
    "p2sh-segwit": "3Erd7hDtmrGxvyEjcaqsARh8wfBfM9m4N5"
  }
}

As you can see, you can use the address 33bzAemHYJdN1XciQGqj4v48F5YFinQGcY in your transaction. If you would like to use segwit, you can use bc1qdv4nk8r2p7xptdwd4sv9xw24tmqd2desfvm87uatv9w4tjt3jcrs2a06tv.


Can you use an external PCI expansion box for mining? I'm wondering if plugging cards into something this external pci expansion box would be effective in a mining setup.

I guess it depends on how much bandwidth is used, but I don't know how bandwidth intensive the mining process is. Has anyone here used a setup like this for mining?

The amount of bandwidth used for mining is absolutely trivial, so bandwidth won't hurt you much here. Of course you would have to use something like this box because this one doesn't appear to be nearly deep enough for a full-length video card. Using the backplane from this box in a custom enclosure might be worthwhile.

The secondary problem you'll run into is power. This unit appears to have just enough power supply to power the communications between ports. An additional PSU will be needed for the GPUs themselves which, conveniently, typically draw most of their power from four or six pin connectors.

So in short, using this backplane in a separate enclosure with an external power supply (and a lot more airflow) seems pretty viable to me. Of course I haven't personally done this so I make no guarantees, but if someone has actually attempted this I'd love to hear about it.


What is a Bitcoin wallet? What is a wallet in the context of Bitcoin?

What are wallets used for?
What relation do wallets have to other concepts such as addresses, private-keys, client-software, and Bitcoin balances?

Bitcoin is like digital cash.
A bitcoin address is like an email account but for cash.
A bitcoin address has a private key and a public key.
The public key is like your email (joesmith@gmail.com)
The private key is like your password to access your email (mypassword)
The main difference here is that a bitcoin private key holds all the information to access the account. So with a private key you can get the public key.

A bitcoin wallet holds the private keys to bitcoin addresses - so instead of a wallet, think of it as a key chain with keys to different safes.
Wallets are used as an interface where you can access the bitcoins in your addresses without having to enter the private key in each time.
It makes the user experience a lot easier. So instead of entering in your private key each time you just might enter in a pin code instead.
Wallets also let you easily see the balance of each address, add and remove accounts (addresses) and send and receive bitcoin.
This is a very basic explanation but a good one to start with.
Hope this helps.


How long does it take to validate a full block? I'm interested to know how long does it take to validate a Bitcoin block on average home pc.
I'm less interested in a precise number. I'm fully aware that it can be different between different machines.
I'm more interested in an estimation.
Previous answers didn't provide a number or even rough calculation.

Your question doesn't actually provide enough context even with the proviso that you don't care about which machine specifically.

Do you mean cold-cache during initial block download or do you mean at the tip of the chain on a running node? The difference on this point is probably two orders of magnitude in speed.

Usually, at the tip almost no transaction validation is done at all except for double-spend consistency at the time a block is accepted: all the transactions have already been received and validated.

Do you want a time for processing just a single block without the necessary database writing that is usually batched across many blocks? The difference here is perhaps a factor of two in speed in the uncached case, much more in the cached case.

You can run bitcoin core with -debug=bench to cause it to log detailed timings for the various parts of validation to see validation on your own system.

Order of magnitude numbers are on the order of a couple milliseconds for the common at-tip fully cached case to a couple seconds for cold caches and flushing. Potentially minutes if the block were adversarially constructed.


Did P2SH (BIP 16) get accepted? Based on this, it seems like it did http://blockchain.info/p2sh but it seems I can't find a definitive answer.

Yes it did, on April 1, 2012.

[removed link to chain of orphaned blocks]


How to make a "Donate" function with bitcoins? I understand my bitcoin wallet generates a new receiving adress everytime i received a transaction. I would like to add an adress to my website for donations. How can i get an adress that doesnt change?

You can just take any existing receiving address or create new one. Any address can accept unlimited transactions count.

Bitcoin clients generate new address every time you want to receive for anonymity reasons. In case with donations you don't need this.


Using Transaction with multiple outputs Since the output can be spend only once, I am confused by transactions containing multiple recipients. For example, if Alice transfers 5 BTC to Bob and 5 BTC to David in the same transactions. In the future, Bob refers to the Alice's transaction, also David can refer to the same transaction. I understand that outputs are numbered in Alice's transaction to Bob and Eve. Therefore the output number and transaction id Tx id uniquely determines whether there is double spend happening or not.

Am I correct? Is the UTXO associated with output and Tx id?

Each transaction draws on a set of [1..n] Unspent Transaction Outputs to spend. These we call the inputs of a transaction.
The transaction then assigns the total value of the inputs to [0..n] new Unspent Transaction Outputs. Each UTXO is associated with the creating transaction and uniquely numbered among that set. The most common script that makes up a UTXO is "pay-to-pubkeyhash", where an UTXO can only be spent in combination with a valid signature by it's recipient.

The value of the outputs must be smaller or equal to the value of the inputs. The difference of those two totals can be claimed by the miner as transaction fee.

To come back to your example:

Transaction A1:
Alice -> 5BTC -> Bob (Transaction A1, output 0)
Alice -> 5BTC -> David (Transaction A1, output 1)

(Alice needs to put in at least 10BTC for that transaction.)

Bob wants to spend his money:
Bob -> spend(Transaction A1, output 0, signature) -> new recipient.

Since each UTXO is uniquely identifiable, they cannot both try to access the same UTXO.


How to secure one's Bitcoin Client from packet sniffing? Potential packet sniffing weakness has been described on the Weakness Wiki page. It states that an attacker that can see all of our internet traffic can pick up which transactions originate from our machine, thus figure out what Addresses we have in our Wallet. What are the ways one can secure one's Bitcoin Client from such an attack?

A hacker that has physical access to your network and computers can always find a way to abuse that access but SSL is a very good deterrent and is supported by bitcoind.  Click here to see a guide on enabling SSL for bitcoind.

For securing the communication between nodes you might want to try tor.  It basically makes sure that all traffic on your network is encrypted but still allows you to connect to an encryption-less service.


How can I import public keys into armory? I have a wallet on my phone and second, Armory wallet on my computer.  How can I import the public keys from my phone into Armory so that Armory can watch the balance.  I don't want to import the private keys, just the public ones.

It's currently not possible with Armory.

Here is the issue for the feature request. The main developer of Armory is currently preparing a big change to the whole backbone of the client. The new backbone should make this possible.

  etotheipi told me this will be possible with the new wallets format.

  (comment on issue)


Without side chains will transaction fees rise as block rewards fall? Transaction fees are currently minuscule when compared to block rewards. Even if transaction volume was 10x higher than it is now, this would be the case.

Is there any realistic scenario where transaction fees will not rise substantially to compensate miners for the effort as block rewards continue to fall over the next decade?

You are correct that transaction fees per block are much smaller than block reward, but they are still significant and rising:

https://www.smartbit.com.au/charts/transaction-fees-per-block

Recently the average has passed 0.5 BTC per block. With a 50x rise (easily obtainable if bitcoin use becomes mainstream in certain sectors) the reward would be 25BTC per block based on current fees staying the same.

This would be possible on chain with the combination of SegWit and a higher block size.

Side chains can help slow the growth of the blockchain but how much that is needed and its impact on Bitcoin miner fees remains unclear.


Investing in cryptocurrency in India Question: My friend in India wants to start investing in cryptocurrency such as bitcoin. I have a few questions. What is the current legality of cryptocurrency in India? What exchange should he use? What wallet app should he use (should support main popular coins)?

Crypto was declared legal in India, earlier this year by the Supreme Court. That being said there are no legal frameworks/regulations right now by the government.
WazirX is one popular exchange in India. Haven't used it though.


With Miniscript why is it not possible to invert conditions with something like not()? This question was asked by Luke Childs (@lukechilds) on Twitter.

In Miniscript would it be possible to invert conditions with something like not()? Could you essentially create a younger() out of not(older())?

e.g. or(and(pk(Alice),not(older(12960))),and(pk(Bob),older(12960)))

The UTXO ownership transfers from Alice to Bob after 90 days.

I see that that won't work because CHECKSEQUENCEVERIFY doesn't return a boolean. But why is being able to invalidate a condition or completely change the conditions after a certain point in time bad?

e.g.
X can only happen before N, Y can only happen after N

This answer was provided by Pieter Wuille (@pwuille) on Twitter.

Conceptually it doesn't make sense, because script conditions are monotonic. What would and(pk(A),not(pk(B))) mean? "B does not sign" is trivially satisfied; B would just never bother signing.

Similarly, not(older(N)) would not mean younger(N). There (intentionally) does not exist a way in script to express a younger-than condition (because it would mean a tx that invalidates itself). "not(older(N))" would just be "do not prove time is past N", also trivial.

For example, Miniscript l:older(N) translates to IF 0 ELSE <N> CHECKSEQUENCEVERIFY.

CSV and CLTV don't actually observe the time; they observe the nLocktime/nSequence field in the transaction. There wouldn't be any problems with having an ability in Script to make arbitrary (including less than, negation, ...) statements about them.

However, it would likely be pointless. The nSequence and nLocktime fields themselves do observe time, and can only express larger-than constraints. Bitcoin transaction validity should be monotonic: once valid, absent double-spend, they remain valid.

The alternative would be a logistical nightmare. All mempool transactions would need to be reevaluated every block. Reasoning about validity of unconfirmed transactions would be a pain (e.g. what if you're paid using a tx spending the output of a soon-to-be expired tx?)


Is there a way to change Bitcoin Open Source code to be more Environmentally friendly? If Bitcoin is open source as proponents mention, why can't make Bitcoin as environmentally friendly as Ripple, Dogecoin, Cardono etc? Elon Musk tanked the market by mentioning Dogecoin is More environmentally friendly. It apparently uses an algorithm that takes less computation and energy consumption.
Source Code reference:
https://github.com/bitcoin/bitcoin

Yes, there is a way, by creating a BIP, but an alternative to PoW would very likely not get consensus in the community, and thus its supporters would be forced (and are free to) to create a hard fork, creating a new coin altogether. It is then to be seen which coin the market will choose, but my sense is that the majority of bitcoin investors will still favour the coin with the original PoW mechanism.
Many coins have been created to set out to find a replacement for PoW, yet none of the coins have gained significant market share.
The monetary property that PoW provides for bitcoin is unforgeability, conceptually very similar to the unforgeability of gold. Other proof mechanisms of other coins are believed to be easier to forge/corrupt and more prone to centralisation of a coin. Buyers of bitcoin likely value the monetary property of unforgeability that PoW provides and this is likely the reason why bitcoin remains the most valued coin, despite its reliance on energy.
While bitcoins reliance on energy on the surface does not seem ideal, a currency that can be forged or centralised also has no (long term) value. Users will subjectively value whether the energy spent that safeguards their investments is ‘worth it’, by investing in it, or not. Some journalists or celebrities, like Elon Musk, may consider it ‘not worth it’ or ‘morally unjust’ from their vantage point, or still believe that PoW can be replaced, despite many failed altcoins and a large body of research on PoW. However, if you have suffered through many currency devaluations or disagree with how the ‘petro’-dollar is upheld and the effects it has on the world politics, the energy spent to safeguard the value of bitcoin may -subjectively!- be ‘worth it’ to you.


"scriptSig" for P2SH-P2WPKH I'm not sure I understand the fields of my input. I have a P2SH address (Testnet). This is the input of my transaction:

  "vin": [
    {
      "txid": "a61389ff9af670770182198a984a4c1785625c60795bd57645ecc78765b23679",
      "vout": 1,
      "scriptSig": {
        "asm": "0014778daf651b21684b572644b47d551fce0ff71c74",
        "hex": "160014778daf651b21684b572644b47d551fce0ff71c74"
      },
      "txinwitness": [
        "3044022034a07f088dd88396cd378912a4ed6a156701b075f0facbbae810677048c390e602205df07e13bf4d56feece791a1b5e4d94bec9c93aae14bb87a1b4c6c54ae9bf2f701",
        "032c27921f2d15e7eca768c0e8a8b1aeb863328c74d6c194d41dde2888d4b0e75b"
      ],
      "sequence": 4294967295
    }
  ],

  I understand that: in "asm" i have RedeemScript. In txinwitness i have
  my signature and the pubblic key. Correct?

Now, from the utxo used:

"txid": "a61389ff9af670770182198a984a4c1785625c60795bd57645ecc78765b23679",
    "vout": 1,
    "address": "2N7MaihNErbNH8XTkuZWtJYPzMQAWMPVKHd",
    "label": "",
    "redeemScript": "0014778daf651b21684b572644b47d551fce0ff71c74",
    "scriptPubKey": "a9149ac58ff47e27214b158b38da04bc8cbf72def14387",
    "amount": 0.01944571,
    "confirmations": 116,
    "spendable": true,
    "solvable": true,
    "desc": "sh(wpkh([7de694b7/0'/0'/7']032c27921f2d15e7eca768c0e8a8b1aeb863328c74d6c194d41dde2888d4b0e75b))#6z7uwusp",
    "safe": true

I deduce that I have used a P2SH-P2WPKH output. So in the ScriptPubkey I find the unlock condition (HASH160 of the public key of my address). In the redeem script I find HASH160 of the compressed public key 032c27921f2d15...

  is it correct to say that, as an additional condition, to unlock a
  UTXO P2SH-P2WPKH, compared to a P2PKH, you need the HASH of an
  additional public key?

I understand that: in "asm" i have RedeemScript. In txinwitness i have my signature and the pubblic key. Correct?

Correct. in a P2SH-P2WPKH the witness contains the signature and the public key, and the script signature contains the redeem script.

  is it correct to say that, as an additional condition, to unlock a UTXO P2SH-P2WPKH, compared to a P2PKH, you need the HASH of an additional public key?

This is where you are kind of wrong.

The address of a P2SH-P2WPKH is the hash160 of the serialized redeem script of the P2WPKH, which has to be OP_0 <hash160_of_public_key> according to BIP0141. So it looks like you need an extra public key, but in reality you are just using the same public key twice. One that goes inside a redeem script to the script_signature, and another for the witness field that goes naked alongside the signature.

In other words, there is no extra public key. It's the same public key that is wrapped inside a smart contract (redeem script) defined by BIP0141, serialized, and then hashed. Now, this hash is the same hash used for the public keys (hash160), therefore the outputs of these smart-contract hashes have the same length of those public-key hashes, and that's why they can be confused with public keys when in reality they are smart contracts. This is done on purpose to make P2SH backward compatible .


Bitcoin Chainstate Leveldb sst I'm trying to read the chainstate, and wrote a small Leveldb client to do so.  When I run leveldb, it tells me Corruption: 960 missing files; e.g.: /opt/bitcoin/chainstate/890787.sst.  Googling shows that Leveldb uses .sst files, but, I don't see a single one on my machine.

How do I generate these files / repair the chainstate leveldb / access it from a leveldb client?

the default extension is now ldb https://groups.google.com/forum/#!topic/leveldb/u9izbG-pDis

Which library are you using to read leveldb? I suggest you use plyvel. It will be able to read chainstate


Generating Bitcoin Public and Private Keys I managed to write the below code which will create public and private keys

Private Key

$input = "satoshinakamoto";
$sha256 = hash("sha256", ($input));
echo "Private Key: ".$sha256."
";

Public Key

    $step1 = hexStringToByteString("0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6");
    echo "
Step 1: ".$step1."
";
    $step2 = hash("sha256", $step1);
    echo "
Step 2: ".$step2."
";
    $step3 = hash('ripemd160', hexStringToByteString($step2));
    echo "
Step 3: ".$step3."
";
    $step4 = '00'.$step3;
    echo "
Step 4: ".$step4."
";
    $step5 = hash("sha256", hexStringToByteString($step4));
    echo "
Step 5: ".$step5."
";
    $step6 = hash("sha256",hexStringToByteString($step5));
    echo "
Step 6: ".$step6."
";
    $step7 = substr($step6,0,8);
    echo "
Step 7: ".$step7."
";
    $step8 = $step4.$step7;
    echo "
Step 8: ".$step8."
";
    $step9 = bc_hexdec($step8);
    echo "
Step 9: ".$step9."
";
    $step10 = bc_base58_encode($step9);
    echo "
Step 10: 1".$step10."
";
    return $step10;

To generate public key I took reference from https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses

In that link they provided Step by Step process and I followed the same and if
I input from Step 1 in the link then I am able to convert the code to public key but I am not sure how to convert Step 0 to Step 1

i.e.

From:

18E14A7B6A307F426A94F8114701E7C8E774E7F9A47E2C2035DB29A206321725

To

0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6

Document says

Take the corresponding public key generated with it (65 bytes, 1 byte 0x04, 32 bytes corresponding to X coordinate, 32 bytes corresponding to Y coordinate)

What does that mean? How can I generate this value from Private Key.

Edit 1

This question says https://stackoverflow.com/questions/17672696/generating-bitcoin-address-from-ecdsa-public-key

Joining the Elliptic Public Key and I still don't understand what are they.

Bitcoin uses point multiplication on the Elliptic Curve secp256k1 to generate a public key from a private key. Basically, this curve has a defined Generator point G, and a method for 'adding' two points together in a way to get a new point (EC Point Addition).

Your private key is just a number, aka a Scalar, so to get your public key you just add the generator point to itself privkey number of times - basically scalar multiplication on the Elliptic curve. At the end, you'll end up with a point on the curve, with an X and Y coordinate, and this point is your public key. Those two coordinates of your point are what is referred to by the document you quoted, using 32 bytes for each coordinate plus a prefix.

The 0x04 prefix used is to denote the fact this is an uncompressed private key. You can also form a compressed version, by just using the X coordinate with either 0x02 or 0x03 prefix, because the Elliptic curve has only 2 values for Y coordinate for each X coordinate (one positive and one negative), so it's trivial to recover the Y coordinate if you know the X coordinate and the sign (based on your choice of prefix).


solo mining payout maturity vs pool mining When I mine in pools there are unconfirmed coins, but it seems unconfirmed times are far less than immature status in *coind wallet app... Any advice how I can get my coins quicker instead of waiting for 100 blocks to pass?

I'm still not completely sure that I am understanding your question correctly, but let me take a guess.

As you know, when a block is first mined, the coins from its block reward are considered "immature".  They may not be spent until 100 blocks later, or in other words, until the coinbase transaction has 100 confirmations.

Now, there are a couple of ways a pool can make payouts to its miners.

When creating the block template for mining, include a coinbase transaction that pays appropriate amounts to all pool members who are due to receive payouts.
Include a coinbase transaction that pays its coins directly to a wallet controlled by the pool operator.  The operator then makes additional transactions for payments from that wallet (or another wallet he controls) to the pool members.

For a pool that uses method 1, members will receive payouts that are immature, and they will have to wait 100 blocks to spend them.

For a pool that uses method 2, if the pool operator has a sufficient balance in his wallet, he can make the payouts right away by using coins that have been in the wallet for a long time already, long enough that they have become mature.  In this case, the payouts are ordinary transactions; they confirm like any other, and the miner can spend them immediately (or perhaps after 1 confirmation, depending on the requirements imposed by her wallet software).

Method 2 is certainly more convenient for the miner members if all goes well, but it has some other problems.  In order to maintain a sufficient balance, the pool operator has to keep some of his own coins in the wallet at all times.  These coins are then tied up there, which may be inconvenient or costly for the operator.  Also, if the block reward is paid directly to the operator's wallet, there is a chance he will decide not to make the payout to members, but instead will keep the coins himself.


How do you exactly earn bitcoins... ive been confused frankly I get the concept of it just dont know how.

You acquire Bitcoin one of two ways. You either buy it or earn it.

If you want to earn Bitcoin you are looking for Bitcoin mining unless your boss wants to pay your salary in BTC.

There are also websites where you can earn Bitcoin for completing tasks.


Inner working of OP_IF and OP_ELSE How does OP_ELSE work exactly? Is there an else if in Script?

According to https://en.bitcoin.it/wiki/Script#Flow_control, the statements after an OP_ELSE are executed in three cases. It says:

If the preceding OP_IF or OP_NOTIF or OP_ELSE was not executed then these statements are.

I'd like to understand how the 3rd case works, i.e. when there's a preceding OP_ELSE that is not followed. Consider this script and a True at the top of the stack:
OP_IF
    <foo>
OP_ELSE
    <bar>
OP_ELSE
    <baz>
OP_ENDIF

If we follow the explanation of the quote to the letter, then that means that <foo> and <baz> are executed. This however is quite counter-intuitive. If this is the case, then the second OP_ELSE is redundant, as <baz> can simply go after <foo> to the same effect and with less opcodes.
Is there some other interpretation I'm missing?
I stumbled upon this detail while trying to write a script with 3 different branches, something like
OP_IF top stack item is 0
    <foo>
OP_ELSEIF top stack item is 1
   <bar>
OP_ELSE
   <baz>
OP_ENDIF

I know the above isn't valid Script, but can something to this effect be achieved without resorting to the following?
OP_IF
    <foo>
OP_ELSE
    OP_IF
        <bar>
    OP_ELSE
        <baz>
    OP_ENDIF
OP_ENDIF

Note that this is more expensive not only because it has more opcodes, but because two stack items are needed in the witness in order to execute <bar> or <baz>.

Inner working of conditionals in Bitcoin Script
The conditionals in Bitcoin Script are conceptually implemented using a stack of booleans, each boolean indicating whether to execute the current opcode when iterating through the Script for each depth of the conditional (nested IF / ELSE).
To grasp the functioning, let's first consider a single-boolean conditioned execution of opcodes. The interpreter will iterate through the Script by setting the boolean to true (do execute ops) at the beginning. When encountering an IF it will set the boolean to the value of the pushed data preceding the IF, casted to a boolean (CastToBool in the reference implementation).
If this was true it will continue the execution of the following opcodes, effectively executing "the if {} branch".
If it was false, it will suspend execution until .... It encounters an ELSE! Encountering an ELSE will toggle the global boolean suspending execution. If it was previously false, it will become true and effectively execute "the else {} branch".  To the contrary if it was true, it will become false and suspend execution of "the else {} branch".
With a bit of ASCII art (fExec is the global boolean telling whether to actually execute the OPs):
Value of fExec:  true    true      true         true  true    true         false      false            ???

Script        : |start| OP_BLABLA OP_DOSOMETHING <1> OP_IF OP_DOSOMESTUFF OP_ELSE OP_DOANOTHERSTUFF OP_ENDIF

Value of fExec:  true    true      true         true  false    false       true      true             ???

Script        : |start| OP_BLABLA OP_DOSOMETHING <0> OP_IF OP_DOSOMESTUFF OP_ELSE OP_DOANOTHERSTUFF OP_ENDIF

Note how i marked the value of fExec as ??? when encountering OP_ENDIF. That's because the real implementation is slightly more complicated: in order to support nested conditionals, this is not a single boolean but a vector of booleans that are used to determine execution. That is:

OP_IF will push a new boolean to the vector
OP_ELSE will toggle the last boolean of the vector
OP_ENDIF will pop the last element of the vector

Going further
Multiple ELSE for a single IF
Note that the implementation of the ELSE being a single toggle it means that nothing prevents to toggle two times in a row. That is, you can have many following ELSE opcodes before the ENDIF. Two following ELSEs would effectively toggle the last boolean twice, hence executing the following opcodes as it would for "the if {} branch".
Therefore in the example from your question:
OP_IF <foo> OP_ELSE <bar> OP_ELSE <baz> OP_ENDIF

That's indeed <foo> and <baz> that will be executed.
Quadratic behaviour when computing fExec from the vector of booleans
The implementation of the conditional logic was modified in 2020 by Pieter Wuille to fix a quadratic behaviour found by Segio Demian Lerner.
Therefore the actual implementation does not actually use a stack for the booleans anymore, rather it stores the "top boolean" in a dedicated data structure imitating the previous implementation.
Slightly related Tapscript rule
The proposed new addition to the Script rules as part of the proposed Taproot soft fork (Tapscript) lifts the limit of 201 OP codes. This was made possible by the elimination of the aforementioned quadratic behaviour.


How do I open my RPC console? Someone just asked me to open the RPC console, as part of debugging something else. How do I do that?

I'm using Bitcoin-Qt.

Click Help > Debug window, then click on the Console tab.


Is transactions in bitcoin blockchain always coin transaction? I'm new to crypto currencies correct me if I am wrong, when I checked the block explorer I found a single block contains nearly 2300 transaction in it and I think at an average every 10 minutes a new block is created. My question is, Is all the transaction in the block is, one sending bitcoins to some other or Is there any other application running in bitcoin block chain like in etherium. Because with this much of demand in bitcoin and that many transactions happening even inside 10 minutes is quite unbelievable (sometimes this question might sound stupid).

All transactions are "sending bitcoins to somewhere".

Some of these transactions are "sending bitcoins to nowhere". Some others are "sending bitcoins to the same place". And some transactions are "sending zero bitcoins to somewhere"

So, there are no other data structures in bitcoin blockchain except of moving bitcoins from one place to another. But the transactions can handle portions of arbitrary data.


Your rendition is longer if nothing else, the entire header is only 80 bytes long. The encoding of "bits" is historical and is left over from the pre-release 0.1.0 client. There's other things in the header which could have been encoded better (the nonce should have been longer, and the version read as a bitfield not an int, and an aux merkle root would have been nice), but as it is there's no really great reason to change anything due to the amount of inertia behind the current formation.


Why I don't need to specify public key to import paper wallet I created a paper wallet on coinbase and wanted to import it to coinbase.com. It allowed me to import it by specifying private key only. I was surprised that I didn't have to specify public key as well... is it secure?

I am surely missing here something but the analogy that comes to my mind is ability to log in into someone's gmail account by providing only password and not email. I mean, if that would be possible we could specify "P@ssword" and I'm sure someones has this kind of password to their email, that would let us log in to that account.

Similarily, I could specify some random private key and hope that it's associated with some public address...

Could you please clarify why my reasoning is not correct and why importing bitcoins by specifying private key only is safe?

Thanks!

The analogy that you suggest isn't quite accurate because a private/public key pair have a very exact mathematical relation, whereas a username/password have no real relation (except maybe an entry in a database somewhere).

A private key is essentially a 256 bit number. Using this private key, and an Elliptic Curve library that supports the use of the secp256k1 curve, you can deterministically calculate what the associated public key is. Since a bitcoin address is a hash of the public key, all you really need is the private key and you can calculate everything else to be able to see what transactions resulted in the address being credited/debited coins. That's why coinbase only has you give your private key.


What is the maximum size of a DER encoded ECDSA signature? I've been told by a seasoned Bitcoin contributor that signatures in Bitcoin could be up to 75 bytes. I'm curious to find out how that maximum comes to pass.

According to this answer on Why the signature is always 65 (1+32+32) bytes long?, the signature is always 6 bytes plus the length of R and S, where the latter two can be up to 33 bytes (Is that accurate?). In the worst case that would result in a length of 72 bytes.

Can signatures be longer than 72 bytes? Under what circumstances does that happen and what is the maximum?

A signature in Bitcoin (as used to sign transactions inside scriptSigs and scriptWitnesses), consists of a DER encoding of an ECDSA signature, plus a sighash type byte.

Overall, this means they consist of:

DER encoded signature data, consisting of:

1-byte type 0x30 "Compound object" (the tuple of (R,S) values)
1-byte length of the compound object
The signature's R value, consisting of:

1-byte type 0x02 "Integer"
1-byte length of the integer
variable-length R value's bytes

The signature's S value, consisting of:

1-byte type 0x02 "Integer"
1-byte length of the integer
variable-length S value's bytes

The sighash type byte

Summing this all up, we have 7 bytes (compound header, compound length, R value header, R value length, S value header, S value length, sighash type byte) excluding the actual R and S data bytes.

So we have reduced the question to wondering what the size of the R and S data bytes are. These encode 256-bit values, which ordinarily means 32 bytes. However, integers in DER are signed, which means that if their highest bit is set, they are interpreted as negative. For that reason, if the value being encoded is 2128, a 33rd byte is added in front.

There is a standardness rule on the network that requires the S value to be below N/2 (N being secp256k1 curve order) ("Low S"), but no such rule exists for R. Furthermore, it is only a standardness rule which miners are allowed to bypass.

So ignoring the Low S rule, signatures (including the sighash type byte) can be up to 7+33+33 = 73 bytes.

Perhaps the number you're citing also includes the push opcode used in scriptSig to push the signature onto the stack, but that still only gets us to 74.

Perhaps the 75th byte is the length of the scriptSig itself? But that would only be relevant for scriptSigs which consists of just a signature - for example P2PK spends.


What would cause the price of Bitcoin to flatline for several hours on Bitstamp? Last night I observed the following flatline of BTC/USD prices for several hours on Bitstamp:

What would cause this ?

I think this was "Bitcoin Sell Wall of Death" at Bitstamp. Somebody sold 31 000 BTC at 300 USD. The wall was eaten over Sunday-Monday night.

https://www.cryptocoinsnews.com/bitcoin-sell-wall-death-chomped/


Rolled out my own no-fiat service. What will the tax man need? Background:

I have programmed my own service using https://bitcore.io and I have a limited company set up in the Uk! My company's original intention was to deal with Paypal transactions. (but we are now going to only use Bitcoin!)

We plan to only accept BTC ,only pay and make trades in BTC (never converting money within the company to pounds or any other fiat currency).

  Additionally I am recording every transaction and payment in my database - for the record and in case the tax man would need to take a look at what is going on.

To put it very simply; my company has two instances of dealing with Bitcoin:

A user buys my product with Bitcoin and I collect it in my own private key
A user requests a payment from me. I pay them in bitcoin to a public address of their choice using another private key of mine

My question is:

If my company is never dealing with any fiat money; what information should I be sending to the tax man?

It is a registered company after all (dealing with international clients) and I want to comply with the law.

What are my tax obligations?

From https://www.gov.uk/government/publications/revenue-and-customs-brief-9-2014-bitcoin-and-other-cryptocurrencies/revenue-and-customs-brief-9-2014-bitcoin-and-other-cryptocurrencies

when Bitcoin is exchanged for Sterling or for foreign currencies,
such as Euros or Dollars, no VAT will be due on the value of the
Bitcoins themselves
charges (in whatever form) made over and above
the value of the Bitcoin for arranging or carrying out any
transactions in Bitcoin will be exempt from VAT under Article
135(1)(d) as outlined at 2 above

However, in all instances, VAT will
   be due in the normal way from suppliers of any goods or services sold
   in exchange for Bitcoin or other similar cryptocurrency. The value of
   the supply of goods or services on which VAT is due will be the
   sterling value of the cryptocurrency at the point the transaction
   takes place

So I am to say nothing?? O.o

If you receive 500 EUR as a payment, how do you declare it?

Easy, you declare it as however much GBP it was at the time. If you receive it as a wire transfer your bank will even make this conversion for you!

So with BTC if you receive 2.5 BTC you have to see what the GBP value is and declare that as your receipts, and pay VAT and whatever other taxes on it.

Of course you can choose to lie to the tax man, but remember that Bitcoin is a lot easier for them to track than even your bank account, unless you are very good at operational security and you use something like Monero to separate your transactions. Obviously this is not worth it if you end up having to turn most of it into fiat to pay suppliers anyway.


PSBT (BIP-174, Partially Signed Bitcoin Transaction) Ordering of keys When serializing a PSBT (BIP-174, Partially Signed Bitcoin Transaction), I cannot find any information if the keys should be ordered when serializing the PSBT?

Under the "Test Vectors" section for the BIP-174 in the last example it is only mentioned that:

  A combiner which orders keys lexicographically must produce the
  following PSBT[...]

But it does nowhere say that it is mandatory to order the keys. What is expected?

I am implementing test cases for a PSBT library and would like to know this to decide if I should compare the serialized PSBTs (where ordering does matter) or the objects themselves (regardless of ordering of keys).

There is no mandatory ordering. If you assume your parser is correct, then it is fine to compare the objects themselves. However, to be sure everything is correct, I would suggest that you compare the serialized PSBTs themselves.


Are there any Python modules that decode raw transaction data? I'm currently doing RPC calls to bitcoin-cli within python to get raw block data:

bitcoin-cli getblock BLOCKHASH False

I've already written a function that cuts off the block header and splits the transaction block into individual transactions, resulting in the same result as:

bitcoin-cli getrawblock TXID

I'm now trying to convert this data into the same result as

bitcoin-cli getrawblock TXID 1

without doing another RPC call to bitcoind. Would prefer to use pre-existing modules if possible.

Python packages would be appreciated.

Yes, Pybitcointools (or this fork which has BIP39, file embedding and mk_opreturn) can do this.

Install either version of pybitcointools using setup.py install, as usual.

Then, with a raw hex transaction, rawtx, simply use txo = deserialize(rawtx). rawtx can be either a signed or unsigned hex transaction. The returned txo is deserialized as a dict object. Use serialize(txo) to get back to rawtx.

You can fetch TxIDs using fetchtx(hex_txid, source="blockr") and send signed Txs with pushtx(signed_hex_tx, source="bci").


getaddressesbyaccount RPC alternative? I'm using Bitcoin Core v0.15.1. when I use getaddressesbyaccount in the debug console I can see the "account" is DEPRECATED. in fact all methods that uses "account" mark this parameter as DEPRECATED.

I realize that the whole "Accounts" feature is being deprecated, but
there is no getaddressesbylabel.

How can I replace this method to get the address by the label? what does DEPRECATED means for future versions? will the parameter be ignored or removed or will the whole getaddressesbyaccount be removed?

in fact I'm not sure how to handle other methods with "account" parameter. this label is essential to my application. (I want to lookup address by a unique label/id I will give for each user that uses my wallet).

Thanks.

I realize that the whole "Accounts" feature is being deprecated, but there is no getaddressesbylabel.

It looks like there actually will be a getaddressesbylabel API call in a future version. Along with a handful of other methods that replace the accounts feature. Check out this PR.

  what does DEPRECATED means for future versions? will the parameter be ignored or removed or will the whole getaddressesbyaccount be removed?

When a feature is deprecated it will usually stick around for a while reporting that it will be removed in future versions of the software.


Do i have to delete/clear anything in Firefox after creating offline keys using Bitaddress? If i use Bitaddress in Firefox offline to create key pairs, will any info remain in Firefox/anywhere else that i will have to delete  - i mean, if i then use that Firefox to connect to the internet after making the keypairs, could somebody potentially obtain any of the keypair info?

The whole idea of bitaddress is that your addresses are dynamically generated. As such, the only place it would be is in the browser cache or RAM. Rebooting the computer will clear the RAM and deleting the browser history (preferences->privacy->clear your recent history) should clear the cache.


I need a few lines of python to make WIF addresses I have code which generates WIF keys from hex keys.  It just need a few more lines to generate WIF addresses.

------------------------

import binascii, hashlib, base58, sys

def convert(z):

private_key_static = z

extended_key = "80"+private_key_static+"01"

first_sha256 = hashlib.sha256(binascii.unhexlify(extended_key)).hexdigest()

second_sha256 = hashlib.sha256(binascii.unhexlify(first_sha256)).hexdigest()

final_key = extended_key+second_sha256[:8]

WIF = base58.b58encode(binascii.unhexlify(final_key)).decode ('ascii')

print (WIF)

with open("HEX.txt") as file:
    for line in file:
       convert(str.strip(line))

Note: WIF is a format for private keys, not addresses.  There are multiple address formats, but the most common is P2PKH (hash of a public key).

I recommend looking that the code for Electrum to learn about how to work with public keys and addresses in Python, (check out bitcoin.py).  It contains everything you need and is reliable code used by many thousands of users to secure their bitcoin.


Bitcoin transaction failed to broadcast (code 66) I am using bitcoind. I got this error while trying to send a transaction:
CommitTransaction(): Transaction cannot be broadcast immediately, mempool min fee not met, 6835 < 7865 (code 66)
The balance was removed from my wallet and yet the node does not seem to retry sending this txid again. How do i fix it?

It will be rebroadcast by your wallet automatically. However, you may want to bump the fee (bumpfee RPC command) if it's urgent as you are paying so low fees that you got evicted from your mempool.


Minimal but profitable miner setup with solar energy Im looking for 20W/h (at 5V) consuming system for running with solar panel. Is it possible with current miners? If you say it will never be profitable I say 5$ for a month is big target for me. The currency can be different than bitcoin. Im so beginner.

While there were a few USB stick miners very early in the game, rigs have rather gotten bigger than smaller since then.

According to Mining Hardware Comparison the smallest rig that is still shipping,  Antminer U3 Batch 2, needs 63W.

Its energy efficiency is only one tenth of the current best equipment though, and you'd have to invest at least $40 which you likely would never make back:
In the ASIC-age, is it worth starting mining Bitcoin at home?


How do I fix GUI Miner stuck at connecting? GUI Miner v2011-08-24 just shows "connecting..." when trying to connect to slush's pool. The console shows:

2011-12-31 14:00:49: Running command: poclbm.exe smithd98@gmail.com.macbookpro:4fuqPtrI@api2.bitcoin.cz:8332 --device=0 --platform=0 --verbose
2011-12-31 14:00:49: Listener for "Default" started
2011-12-31 14:06:53: Listener for "Default": api2.bitcoin.cz:8332 31/12/2011 14:06:53, long poll: new block 0000028fd540f91b
2011-12-31 14:07:33: Listener for "Default": api2.bitcoin.cz:8332 31/12/2011 14:07:33, long poll: new block 0000079641b6608b

where xxxxxx is my correct password.

I've tried uninstalling (removing the directory, ensuring the process isn't running, and unzipping again) as suggested in this post: https://bitcointalk.org/index.php?action=printpage;topic=28886.0 but it hasn't worked.

you're using api2.bitcoincz.com:8332 but that's not listed on the pool's site:

Run your own GPU/FPGA/ASIC miner with the worker credentials you gave earlier, and connect it to following URL:

http://api.bitcoin.cz:8332
(Main pool URL)

or
stratum.bitcoin.cz:3333
(If you have Stratum-compatible miner)


Calculating fee rate of tx returned by fundrawtransaction I'm passing an unfunded proposed tx and feeRate param to fundrawtransaction which gives me back the hex of the tx with inputs selected and its fee. I'm not passing a conf_target or estimate_mode. I pass the resulting hex to decoderawtransaction to get the size/vsize of the tx.

I'm trying to check the actual fee rate of the tx by calculating fee * 1000 / vsize but it doesn't seem to match the rate that I passed in as a parameter.

I've tried with a few different values but the actual rate always seems to come out higher than the requested rate by a factor of about 1.59, give or take a little bit.

So am I calculating the observed rate improperly? Is it even possible to have the resulting fee rate exactly match the one provided by the feeRate parameter?

Here's an example of constructing a tx with amount 0.00073749 and feeRate 0.00001000. Proposed tx from createrawtransaction:

{
  "txid": "de380dec00d86611bab1cfa825a7069ffde31d7fb0c5b91e381ef79b94d927e0",
  "hash": "de380dec00d86611bab1cfa825a7069ffde31d7fb0c5b91e381ef79b94d927e0",
  "version": 2,
  "size": 41,
  "vsize": 41,
  "weight": 164,
  "locktime": 0,
  "vin": [
  ],
  "vout": [
    {
      "value": 0.00073749,
      "n": 0,
      "scriptPubKey": {
        "asm": "0 de525f12f17a495b7903c2c5b306ee07ccad309f",
        "hex": "0014de525f12f17a495b7903c2c5b306ee07ccad309f",
        "reqSigs": 1,
        "type": "witness_v0_keyhash",
        "addresses": [
          "bc1qmef97yh30fy4k7grctzmxphwqlx26vyl5lve86"
        ]
      }
    }
  ]
}

And the full tx with inputs returned by fundrawtransaction:

{
  "txid": "f78b268f9386ab47dd5c0d36caf3aaff5fa719c7a2b5658ff08132159cb6b8cd",
  "hash": "f78b268f9386ab47dd5c0d36caf3aaff5fa719c7a2b5658ff08132159cb6b8cd",
  "version": 2,
  "size": 369,
  "vsize": 369,
  "weight": 1476,
  "locktime": 0,
  "vin": [
    {
      "txid": "ca6f25d4484ab525fdb907cbce81d3dc9d1974695fcc80639fddfff4b6bca268",
      "vout": 1,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "sequence": 4294967294
    },
    {
      "txid": "9b39ee5637d7b0783715be6ce566283024ee2bea33a9d3bd6f415ae5d8f24e5f",
      "vout": 0,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "sequence": 4294967294
    },
    {
      "txid": "2f2b7eaccc06ea3856cd5b4666a15161d0fac9053ab2bcbb94a490593c969246",
      "vout": 0,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "sequence": 4294967294
    },
    {
      "txid": "b5b2e4e1287438fd8193e1409cdf87181061ab4a3d95f50d2bf1bc2534b2d49c",
      "vout": 0,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "sequence": 4294967294
    },
    {
      "txid": "3de9c3690c77f544b0d953c70d97f50bb9790a847bed9972caca960218c6c8f6",
      "vout": 0,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "sequence": 4294967294
    },
    {
      "txid": "5e0021645a37473afdff1720da902f0abe183fb48719169e96b5235bb6b09e25",
      "vout": 0,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "sequence": 4294967294
    },
    {
      "txid": "f92dbcf77c13d887d8aa77404dc78120c90d055a32b4d51196849affc3866ade",
      "vout": 0,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "sequence": 4294967294
    },
    {
      "txid": "e425c6e84bc671bfb3a80bd95d1925007e12483fdcf3a19094bde8a36ae0d9fd",
      "vout": 0,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "sequence": 4294967294
    }
  ],
  "vout": [
    {
      "value": 0.00073749,
      "n": 0,
      "scriptPubKey": {
        "asm": "0 de525f12f17a495b7903c2c5b306ee07ccad309f",
        "hex": "0014de525f12f17a495b7903c2c5b306ee07ccad309f",
        "reqSigs": 1,
        "type": "witness_v0_keyhash",
        "addresses": [
          "bc1qmef97yh30fy4k7grctzmxphwqlx26vyl5lve86"
        ]
      }
    }
  ]
}

In this case the fee is 0.00000668 so the rate I calculate is 0.0000668 * 1000 / 369 = 0.00001810 as opposed to the requested 0.00001000

You're seeing two things here: the exact match coin selection algorithm, and the fact that your vsize is computed before adding signatures.
Exact match
The coin selection algorithm in Bitcoin Core tries to find an "exact match" of UTXOs to spend in order to pay, without adding a change output back to you. If the input amount is a bit too large, it is turned into fee. Surprisingly, under certain circumstances this behavior is actually preferable over turning that excess into change.
The observation is that merely creating a change output costs money right now (in terms of fee needed to pay for it), and more money later (in terms of the marginal fee needed to pay for the additional space used by the transaction input that will spend it). That fee is wasteful: if it's possible to not create the change at all, this becomes a cost you never have to pay.
So the conclusion is: if it is possible to construct a transaction without change that overpays less than what it would cost to create and spend change, it is preferable. This is exactly what Bitcoin Core does, using a short-term fee estimation for the creation of the change, and a long-term fee estimation for spending it.
The concept and algorithm for doing this efficiently were first described by Mark Erhard in his master's thesis.
vsize before signatures
You're looking at the vsize of the unsigned raw transaction coming out of fundrawtransaction. For fee decision purposes, fundrawtransaction tries to predict the size of the transaction after it is signed.


Unable to bind to 0.0.0.0:8333 on this computer. Bitcoin is probably already running I installed bitcoin-qt and my wallet was all synced, everything working as it should. I sighed up for slush's pool and was trying to connect the 2 and I think I may have clicked the box to run SOCKS proxy (if I am remembering right)  Now my wallet will not show up on my desktop and when I click the icon I get 2 errors:

Unable to bind to 0.0.0.0:8333 on this computer. Bitcoin is probably already running.
Failed to listen on any port. Use -listen=0 if you want this.

I am running Fedora 18.  I tried to uninstall/reinstall and ended up with the same issue, i'm assuming I did not uninstall ALL of the initial package/program.

Can someone help PLEASE!!

Thank you!!

Are you sure that betcoind is not running?

Bitcoin is probably already running.

You can try to restart your computer...


What info do I need in a form where people can pay/donate with Bitcoin? I'm a developer and looking to create a form where people can pay/donate money in Bitcoin.  Many have suggested to just post the recipient wallet address and let folks take that and go off and pay on their own.  However, I don't want that.  I would like to create a form taht gathers the necessary information for settlement and then goes off does the payment collection, much as someone who accepts credit cards will collect a credit card number, security code, and expiration date before handing that off to a payment processor.

My question is, is it possible to gather such information for a payment?  If so, what is the information I'd need to collect?

If it simplifies things, we were thinking of using the Coinbase API to make this happen.

This model fundamentally won't work.

In the case of a credit card transaction, the funds are actually held by a third party: the customer's bank.  You collect information from the customer (their card number, etc) and present it to the bank (via the Visa network or similar), to convince them that their customer has authorized the transaction.  The bank then transfers the funds to you.

With Bitcoin, it is very different.  The funds are held by the customer herself.  There is nobody who can perform the transfer except her (that's what keeps her funds secure!).  You cannot do it unilaterally on her behalf, and there is no bank holding the funds who can do it.

Strictly speaking, the "necessary information" to execute a transfer is the customer's private key.  But the customer is the only one who has it, and she is not going to share it with you (don't even ask).  So she has to execute the transfer herself.

The only way to collect a payment via Bitcoin is to give an address to the customer and wait for her to make a transfer to that address, signed with her own private key via her own wallet software.  You can have a third-party processor like Coinbase handle that for you, but it doesn't change the fact that the customer actually has to do something besides giving you information.


How to sell bitcoins for cash money? I'm asking about how to turn bitcoins into cash (USD or EURO) that you hold in your hands, so I can use it in real life not on the internet.

I don't have a credit card, and I'm in a country (IRAQ) where banking services aren't so profound and people don't use credit cards.

What do I need to do this?

The only way to exchange Bitcoin for cash is to find someone willing to trade. In person, this can be slightly inconvenient, since verifying that the Bitcoin have been received involves waiting for confirmations from the Bitcoin network. This is true even if you exchange Bitcoin by sharing the private key to your Bitcoin address, since the recipient will still have to transfer the associated Bitcoin to be assured that nobody else has access to them. One way of possibly finding someone willing to trade is to attend a Bitcoin meeting or conference; at least I suspect that those attract enough people interested in buying more Bitcoin at a fair price that you could find someone willing to trade with you for cash.

There are lots of websites aimed at helping you find buyers or sellers of Bitcoin locally or online, ranging from classified ads, possibly including Bitcoin escrow, all the way to broker-like exchanges that may not even inform you of whom they matched you with for trading (but that will then typically require deposits, often through bank transfers). Especially on the extreme of classified ads, using them will typically not require you to have any banking. However, with Bitcoin users in Iraq being apparently even fewer than elsewhere in the Middle East, it is unclear if this will help you beyond giving you the opportunity to make yourself more visible to anyone who might one day become interested.

Finally, if you do trade Bitcoin in person without an established business as an intermediary, please make a conscious decision about how you do it. Apart from the possibility of fraud and disputes---what will you do if, after sending the Bitcoin, the other party claims to never have agreed to handing over money for it?---there is the question of what laws you may have to observe. In trading the private money or whatever your jurisdiction considers virtual currencies without any financial institution, you are doing something that does not necessarily fit into whatever laws, rules, written or unwritten, exist in surprisingly broad contexts. Don't by mistake set yourself up to be framed as a bad guy.


bc.info transactions with no timestamp The last transaction in blocks 219882, 219888, and 219892 don't have a timestamp.  And by last transaction I mean the last transaction shown in the json file.

219882
219888
219892

I find this to be a bit odd.  Does anyone know why this has occurred?

There is no timestamp field in bitcoin transactions. BC.I timestamps the transaction when it comes to this service for a very first time. You should not use this value, because it can be quite incorrect/irrelevant.

I think that the last transactions in these blocks have not seen by BC.I in "wild" form. BC.I discovered them when they come within a block. So, it is a small bug on BC.I - it does not shows you timestamp for some txs.

Just live with it.


How to make a new blockchain from scratch In the same vein as setting up a private DNS root server and using whatever domain names you want, how do you generate your own blockchain and mine your own coins?

P.S. I don't want any answers like "why would you want to?"  I want to do it because it can be done

I think I Found it.  Someone wrote a C program to generate a genesis block.  Code is on github here:

https://github.com/Gnaf/GenesisBlockZero

The original code was pulled from a discussion on the bitcoin developer forums:

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

Compile and run the program to generate the initial SHA256 hash, the time and nonce, then plug those into the bitcoin main.cpp source and recompile.  I think that's all you have to do to start a new blockchain.


Bitcoin Cold Storage Question I am ready to put some of my BTC holdings into a couple different cold storage wallets.  I went through the process already moving around a few mBits as tests, created the keys on an offline PC, sent real funds, then ran an import in bitcoin-qt, all good there!

My concern is this, If I move a few BTC into individual 1BTC wallets, do I have to worry about any Change Address issues if I simply ignore them completely for a long time?  Assuming my private keys are kept safe over time, is there any way I can lose funds this way?  I do not plan on making further deposits into any of these wallets, if my funds grow I will keep another hot wallet or setup more cold storage.  I also do not plan on withdrawing funds at any time, when I do it will be a full sweep per wallet.

Before I proceed with sending my hard earned mining BTC to each address, I want to make sure I take all the proper precautions, any help from you BTC pros is greatly appreciated.

There is no reason to use multiple cold storage wallets, but either way, offline-generated keys and a full sweep upon spending is enough to keep your funds completely safe. When the time comes, don't try to "test" moving funds out of cold storage. Do the full sweep.
Also see this
if my wallet is sufficiently secure, can I ever lose my coins?


Can the Lightning Network work on any other cryptocurrency? I believe Lightning can be used with other cryptos such as LTC, what needs to be implemented to make it compatible with other cryptos? How difficult is it to implement on those other cryptos if they are compatible?

The answer to this question depends on how broad you define the Lightning Network:

If you want to run the currently specified protocol (and any of the current implementations without having to modify them), you'll need to use either Bitcoin. Litecoin is partially supported by some of the implementations, but Lightning is being built first and foremost for Bitcoin.
If you are talking just about the specification, you'll need to have a Bitcoin derivative that also implements Segregated witnesses.
If you want to port Lightning onto a cryptocurrency, you need to at least support the UTXO model of accounting, and a malleability fix. In addition you need to have some form of knowledge contingent payment similar to HTLCs to perform multi-hop payments.
If you want to drop the UTXO model, you might get away by reworking the functionality in major ways, like the folks at raiden did for Ethereum.

So it's all in the eye of the beholder, but these are the requirements for various forms of payment channels and off-chain payment networks, from simple (and precise) to really hard (and fuzzy).


Options for accessing my BTC after host went down Years ago I had put BTC into a store wallet. The store went bust and I didn't get to transfer my BTC into another wallet before I lost access to it.
I can still see the balance on blockchain.info and I have the PIN code provided to me by the store to verify my ownership of the coin, but I don't know if I can access it, and if I can, how would I go about it?

I don't know if I can access it

You can't.

I can still see the balance on blockchain.info

That means you probably know the Bitcoin-address associated with some amount of money. However, knowing an address doesn't give you any control over that money.

There's a common phrase in the Bitcoin world:
Not your keys: not your Bitcoin
The only important information stored in a Bitcoin wallet is a secret number known as a private key. It is knowing that private key that makes it possible to spend Bitcoin money. Without that key you have no control over the money.
An account with a store is almost always a custodial wallet meaning the store has custody of the keys and you don't. Your PIN just tells the store who you are. That PIN is now useless.
This is why many people recommend non-custodial wallets, not custodial wallets (accounts). Especially for long term storage of money that isn't being actively traded.
You need the private key or the seed-phrase (also known as a recovery phrase or backup phrase) from which the private key can be derived. These phrases are typically made of 12, 18 or 24 words from a standard list of about two thousand words. It seems you don't have this.


How were the first coins spendable? Apologies for my limited understanding, still learning.

According to https://en.bitcoin.it/wiki/Genesis_block:

  The first 50 BTC block reward went to address
  1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa,[1] though this reward can't be
  spent due to a quirk in the way that the genesis block is expressed in
  the code.

I understand this to mean that the reward for mining the genesis block could not be spent.

To me this creates a catch-22 situation: If the first coins were not spendable, how was Satoshi be able to transfer the first 10 BTC for pizzas? Where did these first 10 BTC come from, if the first 50 BTC reward were not spendable? And how could then there be more coins, if you first need some transactions in order to fill the blocksize and mine the next block?

If the first coins were not spendable, how was Satoshi be able to transfer the first 10 BTC for pizzas?

It wasn't Satoshi (it was Laszlo Hanyecz, 1.5 years after the genesis block), it was 10000 BTC for 2 pizzas, and they were simply not the first coins.

  Where did these first 10 BTC come from, if the first 50 BTC reward were not spendable?

They were mined. Simply not in the first block.

  And how could then there be more coins, if you first need some transactions in order to fill the blocksize and mine the next block?

There is no such requirement. Blocks do not have to contain any transactions (apart from the coinbase transaction, which creates the new coins).


Why is pruning not considered already at the moment? I understand that Bitcoin scales in several meanings (Scalability), and pruning is one important concept of it (SE Question). I also understand that a "Simplified Payment Verification" (SPV) needs to trust a lot the peer he is obtaining the block chain from.

A very conservative pruning (e.g. transactions older than six month and spent) wouldn't do much harm, especially when it would be only a configuration option for bitcoin-qt. That way the default is the full node, but it's easy to have a "small node".

But I don't see it coming anyhow soon. Is there a reason? Is it so important to have full nodes at the moment that the devs say "either you go for all or nothing"? Or is the development effort the bottleneck? IMHO a large network of non-SPV nodes is more important than a small network of full nodes.

Edit: Let's put it more concrete: Is there a major security issue of not having the complete transaction history of the world back to the genesis block?

Pruning is being considered, in fact, it was taken into account when designing the 0.8 database format. The unspent transaction outputs (which is the only essential piece of data necessary for validation) are already kept in a separate database, so technically removing old blocks is perfectly possible. It'll likely require some small changes to make sure the code doesn't break when block data that doesn't exist anymore is requested, but this is easy.

The reason it's not implemented is because of the effect on the network as a whole. If a large amount of nodes starts pruning old block data away, it will become harder for new nodes starting up to find the historic data to verify. This is not a problem as such - I expect enough copies will remain that this is not a true problem - but we need a discovery mechanism so nodes don't need to arbitrarily try peers until they happen to reach one that has the blocks they need. In fact, there's a discussion going on on the bitcoin-development mailing list about this right.

EDIT: Pruning was implemented in Bitcoin Core 0.11, and is fully functional since 0.12.


How does Bitcoin divisibility work? I come from a programming background and I am trying to figure out how Bitcoin allows for divisibility.  An example using high level code would also be nice.

I understand the high level basics of transactions (Bitcoin Transaction Diagram), but I am interested in divisibility specifically.

A bitcoin is divisible to the eighth decimal. The smallest portion of Bitcoin has its own name: satoshi, whereas 1 BTC = 10^8 satoshis = 100,000,000 satoshis

To be completely correct, while in popular conversation the bitcoin is the predominant currency unit, in realitas the protocol uses satoshi. You can see this when looking at raw transactions or the ledger.

Whenever you send a Bitcoin transaction, the inputs are destroyed and new outputs are created. Essentially, what happens with Bitcoin works like this: Imagine you are paying for a $5 ice cream with a $10 bill, and the $10 bill is destroyed and replaced by two $5 bills, of which you get one $5 bill and one $5 bill goes to the ice cream vendor.

I was not able to deduce what you are trying to get code for, but if you want to split up bitcoins for transactions you might be looking for more information on how to create raw transactions, as dannypaz pointed out in the comments, the Bitcoin Wiki's page on transactions may also be illustrative.


Exact syntax for lightning-cli txprepare I have tried many different forms but I cannot prepare a transaction with lightning-cli txprepare from the Linux prompt.

lightning-cli txprepare [{\"bc1qvzr0mwps952d0cdmchyd2pe5rlee5tfces5dzf\":\"all\"}] slow 1 [c2ff...:1]
lightning-cli: Incorrect 'id' in response: null

lightning-cli txprepare "[{\"bc1qvzr0mwps952d0cdmchyd2pe5rlee5tfces5dzf\":\"all\"}]" slow 1 "[c2ff...:1]"
lightning-cli: Incorrect 'id' in response: null

and many other trials.

What is the correct syntax?
How is it possible to avoid the double quote issue in the shell?
Is it possible to have an actual example of what SHOULD work?

Thank you.

For readers, this issue has been resolved here.

Note that Gabriele's syntax was correct but that you currently cannot use unconfirmed UTXOs with txprepare [1] ! The documentation has been update accordingly.

[1] This caused lightningd to crash but has been fixed by now.


What is the most cost effective way to exchange USD for Litecoin? Also, what risks are involved? Do the service(s) have a long track record?

You could try looking for someone to trade you USD for litecoins in your local area in person, through Bitcoin OTC Exchange, or perhaps BTC-E or some other online exchanges.

In the first case the risk should be fairly small, although it might take a long time to find someone, get in contact with them and so forth. Not to mention the exchange rate might not be in your favour.

The second option should give you better results, but you'd have to make sure you are dealing with someone reputable enough for your trade. However, finding an exchange rate in your favour might not be too easy.

Third option is probably the safest and the exchange rate should be reasonable. The main problem you might face with established exchanges is possibly having to register on them with your documents to avoid your account and funds being suspended due to Anti-Money Laundering laws and regulations.


bitcoin-python API not receiving funds I've just started toying around with the bitcoind Python wrapper (bitcoin-python) and have run into some issues when trying to move funds around.

On the client side, I have generated a new address, via

new_addr = conn.getnewaddress(ACCT)

Upon calling

conn.getaddressesbyaccount(ACCT)

I see new_addr within the addresses listed.

I now send a test transaction (~1mBTC) on blockchain.info to new_addr, and have waited for some period of time, so that there is at least one confirmation in the chain.

However, upon calling

amount_received = btc_conn.getreceivedbyaddress(new_addr)

I have not received any coins at that address.

Furthermore, when attempting to find out more information about the transaction via

btc_conn.gettransaction(tx_id)

where tx_id is given in blockchain.info/tx/tx_id, I'm getting an InvalidAddressOrKey error.

Is there there anything I'm doing wrong?

There's also another possibility, that's that you haven't yet downloaded all the block chain with bitcoind.

If you haven't yet started the daemon you must use this command:

bitcoind -daemon

Then, you can use the command:

bitcoind getblockcount

To check the number of blocks that the daemon has already downloaded, and compare it with the lastest block number

Your transaction is on the lastest blocks, so you must wait it to be completed, and this can take many hours.


How to check relays of tx? I believe a tx is made of an output of previous tx.
So, I also believe that all tx are traced back to tx originally created (as a mining reward).
But, in blockchain.info and blockexplorer.com, I could not find relays of tx.
We can know only connection of addresses in tx page.

Then, I have three questions about relays of tx.
1. Is a id(hash) of tx included in next tx id?
2. Is there a way to get information of previous tx in these websites ?
3. Why do these websites hide connection of tx?

Thank you for helping me!

Block explorers dumb down information so that it is easier for the common person to read. In reality, Bitcoin is not actually how block explorers display information; addresses do not exist at the protocol level and coins are not sent from addresses to other addresses.

  Is a id(hash) of tx included in next tx id?

Yes.

  Is there a way to get information of previous tx in these websites ?

Yes. Most block explorers have an advanced mode that will display this information, or at least link back to the transaction outputs that are being spent. On blockchain.info, you will see a link labeled Show Scripts & Coinbase when you view a transaction, click that and you will see the advanced information about the transaction.

  Why do these websites hide connection of tx?

Because it isn't useful to most people and is confusing.


Accounting for currency destroyed in lost wallets? Bitcoin will eventually be capped at 21,000,000 Bitcoins, but what happens to all the wallets that are lost? I'm sure thousands of BTC are already as good as destroyed. Even if there weren't millions of USD being printed consistently, they would still print not only new money to replace the old, but also to account for destroyed bills. Would replenishing the supply of lost currency be possible in Bitcoin?

Bitcoins can be divided up infinitely. So if there was just one bitcoin left (the rest are lost) then there can still be a viable economy with fractions of bitoins.

Lost wallets are only a problem for the people who lost them, not for bitcoin. It would of course limit supply and push the the cost of bitcoins versus other currencies.


bitcoin-qt stops subsequent RPC calls, then won't shut down I am running latest bitcoin client,  0.9.2.1 - running on 64bit ubuntu..

I can start up the bitcoin client, via bitcoin-qt -server or bitcoind -daemon (both have the same behaviors)....
... once the client is running, my Railo app is making the RPC JSON calls.. The first couple work perfectly, but from that point on, the http calls will simply time out.

then I restart the client, well, try to.. upon restarting it, it tells me "cannot obtain a lock on data directory..  bitcoin core is probably already running".

so at this point, it's impossible to gracefully stop the client (I have tried waiting overnight for it to stop, and no go).   If i restart the computer, start the bitcoin client again, I will be able to process a couple commands and then it'll start timing out again.

2014-09-08 17:20:22 AddLocal(73.my.ip.addy:8333,4)
2014-09-08 17:20:22 ext-ip thread exit
2014-09-08 17:20:23 146 addresses found from DNS seeds
2014-09-08 17:20:23 dnsseed thread exit
2014-09-08 17:20:27 receive version message: /Satoshi:0.9.2.1/: version 70002, blocks=319733, us=73.my.ip.addy:50804, them=74.someone.else.240:8333, peer=74.someone.else.240:8333
2014-09-08 17:20:27 Added time data, samples 2, offset -1 (+0 minutes)
2014-09-08 17:20:27 receive version message: /Satoshi:0.9.1/: version 70002, blocks=319733, us=73.my.ip.addy:49165, them=74.someone.else.180:8333, peer=74.someone.else.180:8333
2014-09-08 17:20:27 Added time data, samples 3, offset -1 (+0 minutes)
2014-09-08 17:20:39 receive version message: /Satoshi:0.9.2.1/: version 70002, blocks=319733, us=73.my.ip.addy:54101, them=37.someone.else.27:8333, peer=37.someone.else.27:8333
2014-09-08 17:20:39 Added time data, samples 4, offset -1 (+0 minutes)
2014-09-08 17:20:43 UpdateTip: new best=0000000000000000092cd65c42a96763e0028edd607555  height=319734  log2_work=80.577054  tx=46257023  date=2014-09-08 17:20:32 progress=1.000000
2014-09-08 17:20:43 ProcessBlock: ACCEPTED
2014-09-08 17:20:45 receive version message: /Satoshi:0.9.1/: version 70002, blocks=319734, us=73.my.ip.addy:50345, them=61.someone.else.11:8333, peer=61.someone.else.11:8333
2014-09-08 17:20:45 Added time data, samples 5, offset +0 (+0 minutes)
2014-09-08 17:20:45 nTimeOffset = -1  (+0 minutes)
2014-09-08 17:21:08 receive version message: /mining.bitcoinaffiliatenetwork.com:0.9.2.1/: version 70002, blocks=319734, us=73.my.ip.addy:52554, them=74.soemone.else.12:8333, peer=74.soemone.else.12:8333
2014-09-08 17:21:08 Added time data, samples 6, offset -1 (+0 minutes)
2014-09-08 17:21:08 connect() to 173.soemone.else.82:8333 failed after select(): Connection refused (111)
2014-09-08 17:21:20 receive version message: /Satoshi:0.9.1/: version 70002, blocks=319734, us=73.my.ip.addy:35721, them=46.someone.else.134:8333, peer=46.someone.else.134:8333
2014-09-08 17:21:20 Added time data, samples 7, offset +0 (+0 minutes)
2014-09-08 17:21:20 nTimeOffset = -1  (+0 minutes)

at this point, i do my rpc calls again, and it starts to time out..  so I figure i'll restart the bitcoin client..

username@computer:~$ bitcoind -stop
: Cannot obtain a lock on data directory /home/username/.bitcoin. Bitcoin Core is probably already running.

after I type the above, the log file then shows:
2014-09-08 17:30:17 : Cannot obtain a lock on data directory /home/mrtom/.bitcoin. Bitcoin Core is probably already running.

2014-09-08 17:30:17 Shutdown : In progress...
2014-09-08 17:30:17 StopNode()
2014-09-08 17:30:17 Shutdown : done

Even after reading through the whole log, there are no strong error messages..

Maybe i'm hitting a connection limit or something really fast?

I was having a different somewhat related problem and stumbled across this thread. It seems that bitcoin-qt creates a .lock file to make sure no other program is using the same folder. If the app crashes, the lock file might not be deleted which could cause it to throw up an error about the program already being open. The .lock file is hidden, though, so you won't see it unless you have hidden files turned on. Deleting the .lock file might fix this for you.


Why are some transactions found on some chain explorers but not on others? This is something that has puzzled me for a while and I cannot think of a rational reason for it.
The transaction 3361d2484f0566ab13d32f2ab321319945f48eaea1ac2cc9f5a79b40528359c3 shows properly on blockchain.info and tradeblock.

However, I cannot find it either on blockr.io nor blocktrail.com.— I am also running a server to watch transactions and I cannot find this transaction either. Sometimes I can find transactions that do not appear on blockchain so it's quite random.

All servers have many connections so I wonder what could be the issue? Slow network?

Each node on the network has its own mempool. While they are filled with similar transactions, each may have a different size limit or perhaps even custom rules which transactions to retain.

In this particular case you can see (figure 1) that there is a (U) shown in both inputs of the transaction. The (U) means that the inputs are created by a transaction that is still unconfirmed.

In fact, when you look at the address that the two inputs were spent to before (figure 2), you'll see that both were created in transactions that only paid 4.4 satoshis per byte whereas the transaction you linked pays 65 satoshis per byte.

I would surmise that the first two transactions that created the inputs might have not been relayed to or were not kept in the mempool of the other blockexplorers. Then, the transaction that you linked would seem invalid to those blockexplorers, because the referenced inputs are not known to it.

You may find this related question interesting: "How do transactions leave the memory pool?"


What are the tangible benefits of decentralisation? What are the tangible benefits of decentralisation?

This question was posed to me by my parents. Under that this question might incur a lot of wrath from this community.

When my parents lose their ATM cards, they can go to the bank to queue up to get their ATM card if they provide their identification card.

Unlike the above scenario, when one loses his/her private key, one loses access all his BTC.

Hence this question -- Other than removing intermediaries, what are the tangible/immediate benefits of decentralisation? Frictionless commerce, etc.

Nathan Aw

I'm argentinian and in 2001, banks converted all USD money in the argentinian accounts to argentinian pesos. A lot of people lost money, because the peso plummeted in value after that. With a central authority things like this can happen at any time.

Descentralization is good because you remove a central authority that can modify the economic policy in an arbitrary way, it can seize or reduce your funds for arbitrary reasons, etc.

If Bitcoin had a centralized authority that would mean the policies that were set in the beginning (e.g. the quantity of coins that will be created, the fact that is a deflationary currency) could change. The fact that Bitcoin is descentralized means that the policies can't change, actually if they change it would not be Bitcoin anymore, it would be a new currency.

So from the beginning you know the "rules" in Bitcoin and you know they are not going to change because an arbitrary authority decided to change it. You are protected against arbitrary change in economic policies.

Also, being descentralized, you can do whathever with your money and hipotetically nobody can take it from you. A central authority could take your funds because arbitrary reasons (e.g. a new tax, etc.).

Also, being descentralized means it's really hard for a government to "shut down" Bitcoin.


Difficulty for hash (reversed function of "does hash met difficulty/target") What is an algorithm to determine what maximum difficulty already found hash meets?


Order books, matching exact price or closest price? After reading this How do buy and sell orders work?.

This says that closest price, so if someone is selling at 999, and someone offers a bid of 1000, that the 999 will get sold since its the two orders that match closest.

I trade on btce, my understanding was that orders have to match exactly in price. And I take it its considered a sell or buy depending on who goes first.

I haven't really looked at BTCE, yet, but for example on Bitcoin.de also, orders and offers have to match exactly. However, Bitcoin.de is not a real exchange, but more of an auctioning platform/escrow service: Money flows directly through wire transfer from buyer to seller, bitcoins are held by the platform and released as soon as the money transfer was confirmed by the seller.

On Exchanges though, the platform holds both money deposits and bitcoin deposits of the users. The situation there is slightly different: Let me illustrate with a real-life example:

Okay, imagine you want to buy a beard trimmer, because your old one broke. Before you leave the house you decide that you can afford to pay up to 40 € for one. When you get to the electronics store you find the beard trimmer you want for 35 €.

I'll go out on a limb here, but I imagine that you would not go to other stores trying to find it for 40 € because you decided that you wanted to pay that at most.

On the other hand, let's say when you get to the store, the beard trimmer's price is 45 €. There is three options then: Either wait until the price drops to 40 €, look at other stores, or pay more.

Exchanges work the same way:

When your order is higher than the current lowest offer, lucky you, you saved money compared to what you were ready to pay. Yet, when your order is lower than the current lowest offer. You'll have to wait for it to be fulfilled or take your business somewhere else.


What do I have to do after Segwit activates if I'm running Bitcoin Core 0.14.1? I have my bitcoins on a Linux Server. It runs Bitcoin Core 0.14.1.

What do I have to do after Segwit activates?

Bitcoin Core has had the code for segwit since 0.13.1, and your Bitcoin Core 0.14.1 is fully compatible with segwit blocks.

Note that the current release of Bitcoin Core does not create segwit addresses for the Bitcoin main network yet. Therefore, while BIP141 (Segwit) is expected to activate on the network late in August, only a later release of Bitcoin Core will allow you to receive bitcoins that you can spend making use of the witness space.


What is the estimated size of complete blockchain when all bitcoins are mined. i.e around 2140? By size, I mean how many GBs or TBs of data storage I would need to save entire blockchain starting from Genesis block when all bitcoins are mined?

The blockchain will not reach its maximum capacity by the year 2140, the only thing that is going to change is that all bitcoins (a little less than 21M bitcoins) will have been mined by then and the total number of blocks at that time will be around 6,929,999.

Assuming that a block's maximum size will remain 1 MB then we can estimate that the maximum blockchain size at that time will be ~6,6 terabytes.

Currently the average block size is 0,4 MB so if the usage remains in the same levels the estimated blockchain size will be around 2,64 terabytes.

A minimal block contains a single 1-input/1-output transaction. The tx size in this case is: 1 x 148 + 1 x 34 + 10 + 1 = 193 bytes. Adding 4 bytes for the magic number, 4 bytes for the blocksize indicator, 80 bytes for the block header and 1 byte for the transaction counter we come up with: 193 + 4 + 80 + 1 = 278 bytes or 0,0002651214599609375 MBs so if limits remain unchanged, the minimum blockchain size at that moment will be ~1,794 GB (~0,001752 TB).

For coinbase txs the tx size is ~233 bytes so the total size of the blockchain occupied by coinbase txs would be ~1,503 GB

So to sum up:

Min est. size: ~1,794 GB (~1,503 GB for coinbase-only txs)
Avg est. size: ~2,64 TB
Max est. size: ~6,6 TB

Note: The blockchain is currently ~36,5 GB so the above min value is only the theoretical limit, we already know that the blockchain size will be larger than today's ~36,5 GB.