Is there actual consensus on the blockchain's tip or only until the next block? Using this scenario https://bitcoin.stackexchange.com/a/40435

  Let's say we have two competing blockchain tips: They both start from
  Block A as a parent, but then there are two different blocks found at
  the same time: Block B1 and Block B2. Both blocks have the same
  difficulty level, and as we learned above this is independent of when
  exactly they were found. Therefore, the total difficulty of Block A +
  Block B1 = Block A + Block B2. One of the two chains will have a
  greater total difficulty once either Block C1 or Block C2 will be
  found.

Is there consensus on the tip being B1 or B2, or only until C1 or C2 is found?  If 2 blockchain explorers have both B1 and B2, can they randomly choose either to be the tip of the blockchain and both would be deemed to be correct?

No, there is no consensus until the next block is found. The network is experiencing a blockchain-fork. It will only mend once one of the tips pulls ahead by adding another block. Then all nodes will reorganize to the longest chain and consensus is reestablished. The losing chain becomes an extinct branch – valid but not part of the longest chain.

There can't be consensus before because from a node's perspective there is no way to tell reliably which one of the two blocks is more popular in the network. They could ask around, but would get mixed answers and could be deceived through a sybil attack anyway. Therefore, nodes accept the first valid block they hear about as the current blockchain tip until proven otherwise – the only valid proof being to be shown a longer chain. They'd still keep the competing block though, and propagate if it is later needed for a reorganization.

In fact, such blockchain forks can even persist for several blocks when competing blocks are found subsequently. E.g. in 2012 there was a blockchain fork with four blocks.

During a blockchain fork, there is a higher risk of doublespends because the competing blocks at same height may confirm different transactions. However, if they occur from natural random chance (instead of an attack), they would be working from the same set of unconfirmed transactions and should contain a mostly matching set. As each blockchain tip considers the other not to be relevant, they do not split transactions to be confirmed, but both try to confirm the whole set.

So, yes. Both are valid blockchain tips, either may turn out to be part of the longest chain in the long run, but a good blockchain explorer should maybe show both until it is clear which one will remain part of the longest chain.


Why is the root seed of an HD wallet undergo an additional HMAC-SHA512 hash to generate the master private key and master chain code? From what I understand, the wallet seed is created by inputting into PBKDF2 (using HMAC-SHA512 of which 2048 rounds are applied) a bunch of mnemonic code words and an optional salt (defaulted to "mnemonic").  This generates a 512 bit-seed that is completely impractical to brute-force. This is a picture of the process that I am referring to taken from Mastering Bitcoin. Why, then, is it again hashed using HMAC-SHA512, besides for creating 512 bits of output (in the case where it originally might have been 128 or 256)? Why not just use a SHA512 hash alone (assuming the reason is just to create 512 bits)? What is the point of the HMAC here? Length-extension attacks should have been avoided from the previous iterations during PBKDF2, no?

It is because the root seed may not be 512 bits, it could be 128 bits or 256 bits for example as seen in the picture you linked. Thus the final SHA-512 is applied to the seed so that no matter what the seed is, 512 bits will always be generated.

The seed generation described in BIP 39 is independent of the seed -> extended private key step in BIP 32. I expect BIP 32 uses HMAC-SHA-512 instead of just SHA-512 because it makes no assumptions about how the seed was generated, and wants to ensure that the extended private key is uniquely generated for BIP 32 use rather than just using any old SHA-512 hash that could have come from elsewhere.


Confused by various apis scriptPubKey I am really confused and I am having trouble even asking this question in a coherent manner (as I am trying to describe things that other people have renamed multiple times in different instances) so please bear with me...

I am trying to build a transaction using each api I find so I am normalizing the structure of the response from each api call into

Bitcores expected format for the unspent outputs:

[
    {
      "address": "2Mwswt6Eih28xH8611fexpqKqJCLJMomveK",
      "scriptPubKey": "a91432d272ce8a9b482b363408a0b1dd28123d59c63387",
      "txid": "2ac165fa7a3a2b535d106a0041c7568d03b531e58aeccdd3199d7289ab12cfc1",
      "vout": 1,
      "amount": 1.0,
      "confirmations":7
    }
    , { ... }
]

from: https://blog.bitpay.com/transactionbuilder/

But different apis are returning different parts of data

webbtc.com/address api unspent has only scriptPubKey

"scriptPubKey": "OP_DUP OP_HASH160 cba5f746dc1e41a932a7d38be7aba95944619ee8 OP_EQUALVERIFY OP_CHECKSIG"

whereas toshi.io api unspent has

"script":"OP_DUP OP_HASH160 cba5f746dc1e41a932a7d38be7aba95944619ee8 OP_EQUALVERIFY OP_CHECKSIG",
"script_hex":"76a914cba5f746dc1e41a932a7d38be7aba95944619ee888ac",

smartbit api has

"script_pub_key":{
    "asm":"OP_DUP OP_HASH160 cba5f746dc1e41a932a7d38be7aba95944619ee8 OP_EQUALVERIFY OP_CHECKSIG",
    "hex":"76a914cba5f746dc1e41a932a7d38be7aba95944619ee888ac"}

All the apis call these two things by different names and some apis include both/one/or-the-other

It would only make sense to present useful information in these apis So does it mean can I use the one with all the OP_ stuff for scriptPubKey in bitpay.com/transactionbuilder if the other is missing?

Why would they sometimes give me one and not the other?

I would have thought that if different apis give different bits of this info that maybe ether one could be used to build a transaction!?

For example I could strip away OP_DUP OP_HASH160 OP_EQUALVERIFY... anything beginning with OP_ (If the one with only the alpha numerical string isn't on its own i mean)

The thing that really confused me and is the main reason:

bitpay in their above example "scriptPubKey": "a91432d272ce8a9b482b363408a0b1dd28123d59c63387" is just a hex sring whereas webbtc have the exact same name "scriptPubKey": "OP_DUP OP_HASH160 cba5f746dc1e41a932a7d38be7aba95944619ee8 OP_EQUALVERIFY OP_CHECKSIG" but it has all the OP_ stuff in there

These are API names and display scripts in their encoded and or decoded form. What you want to build a transaction is the encoded form like the one returned by toshi (script_hex) or smartbit (hex).

A script is a sequence of instructions beginning by OP_ (OP_DUP, etc...) and hex data. You can read more about the Script language here.

At the protocol level, all of the instructions and data are concatenated to form a single (encoded) hex blob of the script:

76a914cba5f746dc1e41a932a7d38be7aba95944619ee888ac

This is what is signed by the transaction builder. However, it's not really intelligible for us humans. That's why these APIs decode the hex into the sequence of instructions they encode:

OP_DUP (0x76)
OP_HASH160 (0xa9)
(0x14 means 20 bytes of data are next)
cba5f746dc1e41a932a7d38be7aba95944619ee8
OP_EQUALVERIFY (0x88)
OP_CHECKSIG (0xac)

The traditional way of showing this decoded script is :

OP_DUP OP_HASH160 cba5f746dc1e41a932a7d38be7aba95944619ee8 OP_EQUALVERIFY OP_CHECKSIG


Paper wallet creation, how safe is this approach? I would like to create several paper wallets for different crypto currencies. Now I've read through a lot of manuals and I tried to install this Ubuntu version on a USB stick which I wanted to boot on my Mac computer. However after several tries I was still unsuccessful. So how safe would it be to:

Download all key generators, so I can use them offline
Disconnect from the internet
Generate the keys offline (in the "private" mode of Safari)
Not saving anything but directly connecting my computer to my printer via cable and print out the paper wallet
Delete all temporary files on my computer and on the printer
Reboot Mac
Only then connect again to the internet

Is this anyhow unsafe? Can someone intercept anything like this? Or find still some cached file or something after I connect back to the internet?

Sounds pretty safe to me. You should always consider that any machine that is connected to the internet at any time (and some that are not) can be compromised. The questions are, are you a likely target? Do you download or browse sites with questionable items (eg are you infected by something, or COULD you be)

Personally, i just run a VM, it's not connected to any network, i use the vmware client to reach it, i follow your steps 3 & 4 (although I use chrome) and then i reset the vm to a snapshot.


Blockchain linking algorithm Why does new block include only parent's block hash instead of hash of it's all previous blocks calculated using e.g. merkle tree algorithm?

Because the parent hash is already based on the previous parent hash, and so on, it effectively does include all of them. A merkle tree is a commitment to all of them, this does the same thing. It would just make generating the block header harder before the miner can even start mining, so there would be no benefit.


Can I see the workings (console) of my bitcoin full node? I have just completed the IBD of my bitcoin full node on Bitcoin Core on Linux. When I open Bitcoin Core, i just get the basic wallet interface. It there anyway of seeing what the node is doing behind the scenes through some sort of console and interface where I can search through the blockchain too?
If not, Is it possible on Ethereum clients?
Thank you

You are running the Qt version of Bitcoin, which includes the GUI. If you have bitcoind, you can quit the Bitcoin application and type bitcoind into your terminal.
Otherwise, type tail -f ~/.bitcoin/debug.log in your terminal to see then end of the debug file, which will show you when new blocks arrive.
Alternatively, you can install bitcoind from Bitcoin.org. This is a different package than Bitcoin-Qt. Bitcoind only runs "in terminal" so there is no GUI.


How can i print out my bitcoin address that resides on my android phone? I run a repair shop and im thinking of taking bitcoins, but I want to get the QR image of my wallet address onto my site. The wallet address is on my phone, but I'm not sure how or where I can go to print out the QR image of my address. I did a google search, but everyone has a wallet generator. I just want to print out an existing address i have.

Here's a quick way to do it:

<img src="http://qrfree.kaywa.com/?l=1&s=8&d=$yourAddressHere" alt="QRCode"/>


Bitcoin Supporting Chargebacks I've heard there was a proposal to support some form of chargeback in an upcoming release of the Bitcoin Protocol. My first question is this rumor factually accurate and if so how will it be implemented?

QuantumQrack: the answer is no, it's supporting the "payment protocol", which is a way of attaching some extra data to a transaction, such as a refund address. however, the refund is still up to the merchant to agree to give you; once you've given money to the merchant, you can't take it back without them giving it back to you.

Asked in #bitcoin on freenode.  This is the reply.


How can I hide my bitcoin transactions to protect anonymity? I read many related questions about the pseudo-anonymity and bitcoin transaction tracking.

So if I understand correctly, bitcoins, or better, transactions can be tracked for their entire lifetime.

Example user case:

I buy bitcoins from Mt.Gox
I send some bitcoins here and there
Now I decide to send 50 BTC to a person (Bob) who did a job for me, in the hope that nobody finds out about my deal.
Bob changes the 50 BTC recently received in dollars through Mt.Gox

Now, if I'm right, it is possible to track back the transaction to me, since all transactions are public. And so everyone knows that part of the money changed by Mt.Gox was used to pay Bob and that he changed them back to dollars.

This is true as long as my address and Bob's address is also known.

Is there some way to break the transaction history of the bitcoins from Mt.Gox?
I mean, for example, would it be possible for Bob to transfer the 50 BTC to Mt.Gox from an unknown address that was never used, so it can't be associated to my address? Or is it possible to send bitcoins only from the reveicer address?

Situation when using the same address to receive and send bitcoins:

[Mt.Gox] ==> [Me] == [Bob] ==> [Mt.Gox]

Situation with new generated addresses:

1. [Mt.Gox] ==> [Me]
2. [Me] == [Bob]
3. [Bob] ==> [Mt.Gox]

In short, how to hide where bitcoins came from?
I read there is a way to generate new addresses and send through them. Is that true?

Thanks :)

It is possible to trace Bitcoins all the way back to the blocks they were mined, although it might be a hard task. Similarly, one can also trace them back to any withdrawal from MtGox, as long as we know which transaction to look for. No matter how many times you send them from one address to another, it is still possible to trace them back to that transaction, especially if you send the full amount each time.

If you want to make it way harder for someone to trace the transaction, you'd need some service that would take your Bitcoins, send them to some address that is used in many transactions and send them back to some other address you own. There have been many services like this started, but I don't know of any that had the traffic volume necessary to obscure anything. This option assumes that the service would not keep track of the finished transactions, thus not being able to reveal information about you.

You can also try "laundering" your Bitcoins by paying someone to send you Bitcoins from another address. Similarly, you could pay someone to mine a fresh block of Bitcoins for you. Similar as above, it only works if the person would not keep information about you.

Lastly, you could just order some physical Bitcoins. Trading them is completely offline, so nobody can trace who you gave the coins to. I'm not sure though if Casascius keeps any order data, which could be later linked to the person that redeemed the coins at some point in the future.


Would a dual-funded channel be a single UTXO? Would a dual-funded channel be a single tx? The peers would cooperatively create a single tx with at least 1 input each. Is this correctly understood?

Yes, this is correct: a dual funded lightning channel is still represented by a single UTXO.

Generally, we would expect each participant to contribute at least one input to the transaction that creates the dual-funded channel (each participant may also thus end up with a newly created change UTXO as well). This method allows two participants to interact trustlessly to create a dual funded channel.

Perhaps worth mentioning: with a slightly broader definition of ‘dual-funded’, we can imagine ways to create a dual-funded channel, without requiring inputs from both parties. These methods may require more trust between parties than the trustless setup mentioned above, but they may be of interest anyways. Examples:

two parties share ownership of the BTC stored in a certain UTXO, and decide to open a channel using it as the only input
one party contributes a UTXO, while the other party makes an external payment to them. The initial channel balance is then split accordingly, to reflect this payment.
one party contributes a UTXO, while the other party makes an on-chain payment to them. As above, the initial channel balance is then split accordingly. This could be done atomically, which means participants will not need to trust each other. See: splicing in / out of channels.

Those are just a few examples off the top of my head. I’m sure there are other ways to accomplish dual-funding as well.


Signing transaction with SSL - private key to PEM Given a private key: 3cd0560f5b27591916c643a0b7aa69d03839380a738d2e912990dcc573715d2c,
And a tx hash: 456f9e1b6184d770f1a240da9a3c4458e55b6b4ba2244dd21404db30b3131b94, I would like to sign, using SSL and PHP. Converting the private key to a pem format (so SSL can use it), I generate the following base64 string: PNBWD1snWRkWxkOgt6pp0Dg5OApzjS6RKZDcxXNxXSw=. So a valid pem format should be:

-----BEGIN EC PRIVATE KEY-----
PNBWD1snWRkWxkOgt6pp0Dg5OApzjS6RKZDcxXNxXSw=
-----END EC PRIVATE KEY-----

However, it does not seem to be working. I'm using the following function: openssl_sign($hash, $signature, $private_key, OPENSSL_ALGO_SHA256).

But when I generate a random private key using SSL, for example:

-----BEGIN EC PRIVATE KEY-----
MHcCAQEEINhhp8dYz31X+KWq3u/gutJthvW2puUbB9AOIul/v2SOoAoGCCqGSM49
AwEHoUQDQgAE0jE7TIszCklw//SGyYW0+z38PUxwfkip9WS4UUn68f7D78D6ZQ/O
dlPisC1fQZrUrFrik/wq7E4Xwrqs3n3b5w==
-----END EC PRIVATE KEY-----

The function does work. What is wrong with the pem format that I'm generating using an existing private key?

when I verify your self created privkey, I get this error:

  error:0D07207B:asn1 encoding routines:ASN1_get_object:header too long

I couldn't see how you created your privkey, but the way to go is through the ASN.1 structure, and then base64 it.
When using OpenSSL to sign, you must also make sure you are signing hex data, and not strings (this is explained in the answer of the link I provided in my comment).

The ASN1 structure for a privkey looks like this:

# ASN.1 STRUCTURE FOR PRIVATE KEY:
#   30  <-- declares the start of an ASN.1 sequence
#   74  <-- length of following sequence
#   02  <-- declares the start of an integer
#   01  <-- length of integer in bytes (1 byte)
#   01  <-- value of integer (1)
#   04  <-- declares the start of an "octet string"
#   20  <-- length of string to follow (32 bytes)
#           3cd0560f5b27591916c643 ... a738d2e912990dcc573715d2c
#           \--------------------------------------------------/
#            this is the private key
#   a0   <-- declares the start of context-specific tag 0
#   07   <-- length of context-specific tag
#   06   <-- declares the start of an object ID
#   05   <-- length of object ID to follow
#   2b 81 04 00 0a <-- the object ID of the curve secp256k1
#   a1   <-- declares the start of context-specific tag 1
#   44   <-- declares the length of context-sepcifc tag (68 bytes)
#   03   <-- declares the start of a bit string
#   42   <-- length of bit string to follow (66 bytes)
#   00   <-- ??
#            04 f1 44 f0 dc 00 80 af d2 b7 3f 13 37 6c ... 05 49 cd 83 f4 58 56 1e
#            \-------------------------------------------------------------------/
#             this is the public key

Using your privkey, I derived the pukey, and get this pem format:

### use pre defined ASN.1 strings to concatenate PEM privkey
  a pre_string : 30740201010420
  the privkey  : 3cd0560f5b27591916c643a0b7aa69d03839380a738d2e912990dcc573715d2c
  a mid_string : a00706052b8104000aa144034200
  the pubkey   : 04BF350D2821375158A608B51E3E898E507FE47F2D2E8C774DE4A9A7EDECF74ED
                 A24243CB992C5673A07FA5B3A66CD8E3ACEF2809D0E380A0C7929DAB1E5D5438B

### base64 privkey file and put some nice surroundings
-----BEGIN EC PRIVATE KEY-----
MHQCAQEEIDzQVg9bJ1kZFsZDoLeqadA4OTgKc40ukSmQ3MVzcV0soAcGBSuBBAAK
oUQDQgAEvzUNKCE3UVimCLUePomOUH/kfy0ujHdN5Kmn7ez3TtokJDy5ksVnOgf6
WzpmzY46zvKAnQ44Cgx5Kdqx5dVDiw==
-----END EC PRIVATE KEY-----

using asn1parse, the result looks like this:

openssl asn1parse -in privkey.pem
    0:d=0  hl=2 l= 116 cons: SEQUENCE
    2:d=1  hl=2 l=   1 prim: INTEGER           :01
    5:d=1  hl=2 l=  32 prim: OCTET STRING      [HEX DUMP]:3CD0560F5B27591916C643A0B7AA69D03839380A738D2E912990DCC573715D2C
   39:d=1  hl=2 l=   7 cons: cont [ 0 ]
   41:d=2  hl=2 l=   5 prim: OBJECT            :secp256k1
   48:d=1  hl=2 l=  68 cons: cont [ 1 ]
   50:d=2  hl=2 l=  66 prim: BIT STRING

putting all together:

#!/bin/sh
###############################################
# convert from chars to hex
printf $( echo 456f9e1b6184d770f1a240da9a3c4458e55b6b4ba2244dd21404db30b3131b94 | sed 's/[[:xdigit:]]\{2\}/\\x&/g' ) > tmp_utx.hex

echo "The private key in HEX format: "
echo 3cd0560f5b27591916c643a0b7aa69d03839380a738d2e912990dcc573715d2c
# The private key in PEM format:
echo "-----BEGIN EC PRIVATE KEY-----
MHQCAQEEIDzQVg9bJ1kZFsZDoLeqadA4OTgKc40ukSmQ3MVzcV0soAcGBSuBBAAK
oUQDQgAEvzUNKCE3UVimCLUePomOUH/kfy0ujHdN5Kmn7ez3TtokJDy5ksVnOgf6
WzpmzY46zvKAnQ44Cgx5Kdqx5dVDiw==
-----END EC PRIVATE KEY-----" > privkey.pem

# the signing process
#  prepare pubkey:
    openssl ec -in privkey.pem -pubout -out pubkey.pem
#  sign:
    openssl dgst -sign privkey.pem  -sha256 -hex tmp_utx.hex
    openssl dgst -sign privkey.pem  -sha256 tmp_utx.hex > tmp_sig.hex
#  verify:
    openssl dgst -verify pubkey.pem -sha256 -signature tmp_sig.hex tmp_utx.hex

echo " "

returns:

  Verified OK


Armory and segwit addresses I'm using Ledger wallet, and it recently prompted me to migrate to new Segwit address type. If I want to use Segwit transactions from Armory, do I have to do something similar (I have installed bitcoin 0.15)?

You must use Armory 0.96.2 and be in expert mode. When you go to request new addresses, there will be an option for you to choose P2SH-P2WPKH addresses. When you send Bitcoin, you can also choose to make your change P2SH-P2WPKH.


How can I send bitcoin from one address to another through the Bitcoin client/API? How can I send bitcoin from one address to another via Bitcoin client/API ?

There exist an API call called:

sendfrom   <fromaccount> <tobitcoinaddress> <amount> [minconf=1] [comment] [comment-to]

can I use it? And replace <fromaccount> with the <bitcoinaddress> to send bitcoin?

Editing:

i means i want transfer bitcoins from one address in my wallet to another address in my wallet ?

i used it in website each user have bitcoin address and balance so i want transfer just money exist in this address to another ?

i search for accounts in bitcoind but i found issue on it :

  The accounts code does not scale up to thousands of accounts with tens
  of thousands of transactions, because by-account (and
  by-account-by-time) indices are not implemented. So many operations
  (like computing an account balance) require accessing every wallet
  transaction.

how can i resolve this issue ?

I think you answered your own question in a way. That command will send from a specified account to an address, I'm sure you don't want to bother with accounts and just send bitcoins.

You can send from an address to another using a similar command.

sendtoaddress <bitcoinaddress> <amount> [comment] [comment-to]

Where <bitcoinaddress> is the address you want to send to and <amount> is amount of Bitcoins (up to 8 decimal places). The other two that are in brackets are optional and cosmetic.

You can issue these commands in a command line or using one of the many libraries for various languages. Check out the Bitcoin API reference.


How secure are the DNS servers for Bitcoin? With the version 0.6, Bitcoin introduced the DNS servers that populate the initial peers for new clients. How secure are those servers in terms of being immune to takedown attacks, or injection of malicious data?

There are some differences between DNS seeding and the IRC method. IRC used to function as a meeting point; essentially a centralized broadcast system to let (all) other nodes know about your existance, but it failed to answer the query "who is online now?". This means that when using IRC as a publically reachable node, you would often see a peak of incoming connections quickly, but little activity afterwards. Obviously, it was also vulnerable to DOS attacks as a centralized point of failure.

DNS seeds are much more intended to work as seeds: they provide nodes with a few reliable entry points into the network, but let the actual discovery of new nodes be done by the network itself (peers exchange other peer's IP addresses). Futhermore, the DNS system is capable of server much larger numbers of nodes.

To answer your actual question: the DNS servers themselves may be be vulnerable to attacks, but it is important to realize that they are far less essential to the network than IRC was. Also, the 4 active DNS seeds are operated by different people, and managed quite differently:

Jeff's node (bitseed.xf2.org), is currently a static list, updated mostly manually and infrequently, but hosted very reliably.
Matt's node (dnsseed.bluematt.me), is served by a BIND server (typical DNS server software), which is fed a fresh list of reliable nodes by a crawler every few minutes or seconds.
Luke's (dnsseed.bitcoin.dashjr.org) and my node (seed.bitcoin.sipa.be) run a custom DNS server+crawler system, which reports a random set of reliable nodes for each query.

One further remark on your question: the DNS seeding system was introduced in v0.3.21 (april 2011), and turned on by default in v0.3.24 (juli 2011). Since 0.6.0 (march 2012), IRC seeding is off by default. As of 0.8.2 (not yet released), IRC support will be removed entirely.


Can bitcoin and altcoin co-exist in sidechain? If Yes, strategy I have private block chain - tweaked  bitcoin blockchain with a private coin by creating a Genesis block. Lets call it "PrivateCoin"

I also have a sidechain elements/alpha instance, I effectively transferred  PrivateCoins to sidechain using the two way pegging. The transfer is successful and I am able to spend the "PrivateCoin" in Sidechain.
(Did some dirty hacks for address format, chainparams to accomplish it! Though no validation was compromised)

I see sidechain pegging is very Bitcoinish! Hope it will soon be clearly configurable for private coins.

Now the questions,

Can sidechain mint have its own asset such as a"SideCoin", so that
"SideCoin" and "PrivateCoin" can co-exist? If Yes, How to? Strategy?
Can we create "SideCoin" at a deterministic exchange rate for the
    "PrivateCoin"?

  Ex: If I peg transfer 10 "PrivateCoins" from the
          parent chain, I would like to create 200 "SideCoins" at a exchange
          rate of 1:20. If this is possible.

How to? Is it readily
    configurable in sidechain -or- should be coded in ?

No, you cannot set the exchange rate between your private coins and the pegged coins, because you cannot issue the pegged coins yourself.

The chain the pegged coins come from do still keeps track of how many coins were moved out, and there can't be more that come back. That would violate the sender chain's consensus rules.

So say your sidechain holds 100 pegged BTC, and 100000 private coins. If these were cheap to create, people would immediately convert them to 5000 pegged BTC using your 1:20 exchange rate, and try transferring them out. However, only 100 BTC can move back, because from Bitcoin's point of view, that's all what exists. You get effectively get a "run on the bank", and the peg mechanism fails afterwards, because you did not respect the rule that you can only have as much pegged BTC as there are real BTC backing it.


Benefits of Bech32 addresses? In Bitcoin core, when generating a new address for receiving a payment, you get this dialogue:

There is a tick-box for "Generate Bech32 address".

I understand that this is a relatively new feature not yet supported by all wallets. The tooltip help claims that

  Bech32 addresses ... are cheaper to spend from and offer better protection against typos"

How much cheaper than the "P2SH wrapped SegWit address"? (and why?)
Don't P2SH wrapped SegWit addresses include check-digits at the end?

I did find a 52-minute Youtube video where someone with a familiar name was giving a presentation on Bech32 but I'm hoping that it can be explained simply and concisely for the non-technical end-user wondering whether to click that check-box or not.

Native P2WPKH Unspent outputs save 22 bytes as their ScriptSigs are empty instead of 0x0014{20-byte-key-hash}.
2)
Yes, there's already a checksum of the same length.
The newer checksum algorithm is

Faster.

Very high probability of detection guaranteed..

Can find where the errors are: http://bitcoin.sipa.be/bech32/demo/demo.html (Press "address with errors")

Also, you might be interested in the list of Bech32 Advantages.


If everyone has a copy of the block chain, how much space does it take? Since every wallet program has the entire block chain info. How much space does the block chain take? And what prevents it from growing too big where we would run out of space?

I run a full node, and as of today, the blockchain is 10.1 GB.  Since the bitcoin network is active, the answer to your question about how big the blockchain is something that is quite time dependent.  If you were to come back in a month and ask the question, the answer would likely be 11 GB.

I was wondering a while back about the size of the blockchain and whether or not it would eventually consume my entire hard drive and I crunched some numbers and calculated that if I expect my computer to last another three years (it's two years old now), the blockchain would then be 60 GB.  I have a 250 GB hard drive and with the amount of free space on it (141 GB), even when it gets that big, I should still have plenty of free space.

Nothing really prevents the blockchains from growing so big that we would run out of space, but given that Moore's Law applies to hard drives as well as processors, I'm not all that concerned about this happening.  By the time the blockchain will be in danger of consuming my whole hard drive, my computer will be old enough that I'll likely need a new one anyway.

However, if this is something that you're concerned about, you always have the option of using a lite weight client like Electrum that does not require you storing the blockchain on your hard drive.  Electrum is available at http://electrum.org/

In any case, most people these days have enough storage space to store the blockchain.  The bigger bottleneck is that bitcoin-qt is a bandwidth hog and bandwidth tends to be a lot more precious than hard drive space so if you are using a relatively low bandwidth internet connection, this would be another reason to use a bitcoin client that does not require that you run as a full node and relay transactions such as Electrum.


How do i trade bitcoin with an altcoin if my wallet doesn't support that altcoin? Let's say i buy 1 bitcoin and i have it on my wallet. So let's say  bought that bitcoin to trade it for komodo. how do i trade it, i mean how will i get in the posession of the komodo if my current wallet doesn't support the komodo coin?

Your coins will be held on the exchange site itself until you choose to withdraw them to your own wallet. If you want to withdraw them, you will have to create a wallet for the currency you have purchased, and use it to generate an address to withdraw to.


Unable to transfer bitcoin from Multibit - need Satoshi When I am trying to transfer ALL my bitcoins from MultiBit wallet - It's giving error saying:

"The send transaction could not be created

The error was "Insufficient money, missing 49967 satoshis"

I am trying to send my bitcoins and I am entering the exact number of bitcoins which it is showing in my wallet for doing transaction. Can someone please help.

You will need to include a transaction fee as well, so you can't send the entire balance in your wallet. Decrease the amount you are trying to send by the amount it suggests and try again.


How can I create a raw transaction in hex format with Bitcoinj? How can I create a raw transaction when I'm given the input scripts, input indexes, input txids, output script, output address and output amount? The method below works but it requires the method Transaction setHash to be public which it is not. Can I get what I want without having to make any changes to Bitcoinj?

    NetworkParameters params = MainNetParams.get();
    Transaction tx = new Transaction(params);
    tx.addOutput(Coin.ZERO, new Script(HEX.decode(outputScript)));
    try {
        Address addr = new Address(params, toAddress);
        tx.addOutput(Coin.valueOf(toAmount), addr);
    } catch (AddressFormatException name) {
        return null;
    }

    Script script = new Script(HEX.decode(inputScript));
    Address addr = new Address(params, script.getPubKeyHash());

    Transaction parentTx = new Transaction(params);
    for (int j = 0; j < inputIndex; j++) {
        parentTx.addOutput(new TransactionOutput(params, parentTx, Coin.ZERO, addr));
    }
    parentTx.addOutput(new TransactionOutput(params, parentTx, Coin.ZERO, addr));
    parentTx.setHash(Sha256Hash.wrap(txid)); // requires setHash method to be public
    try {
        ECKey key = new DumpedPrivateKey(params, privateKey).getKey();
        tx.addSignedInput(parentTx.getOutput(inputIndex), key);
    } catch (AddressFormatException name) {
        return null;
    }
    return HEX.encode(tx.bitcoinSerialize());

Don't build the entire parent transaction, just build the outpoint, which is all that is relevant for encoding a transaction to hex. Specifically use this constructor

EDIT: More specifically, cannot recreate the parent transaction unless you have ALL relevant information for that transaction (inputs, locktime, outputs etc..). To use the constructor I linked below you will need to also provide the output index of the output you are spending on your parent transaction.


Are there any opensource PHP cryptocurrency exchange/marketplace As the title suggest, are there any opensource PHP cryptocurrency exchange/marketplace.

Most of the ones I found does not seem to work or are abandoned.

I'm not aware of any and I believe it's something hard to find, Because exposing PHP codes may lead to some critical exploits and vulnerabilities.


best way to generate btc wallet with mnemonic phrase Im fairly new to crypto but after some further exposure it seems like it should be possible to do what im trying to do
I want to gift a small amount of btc to my nieces and nephews. My idea was to laminate a small card with their wallet id and a mnemonic phrase; then transfer some btc to this wallet from my own accounts
then when they are all grown up they can withdraw these funds
what is the best way (or software) to create multiple btc accounts using mnemonic phrases?

You can click 'Generate' on this page (although I highly don't recommend using the online version, see below for more) to generate mnemonic phrases and use them. The site supports several languages, multiple currencies not just Bitcoin & more.
The site is also open source and I highly recommend using this offline than the online one for obvious security reasons: https://github.com/iancoleman/bip39


Full Bitcoin Node Download / Synchronization Takes very long I want run an Full Bitcoin Node on Ubuntu but it takes 3 Days to download all of the Bitcoin Blocks from 2009-2017. I have 8 MB/s Internet Speed. Why does it take so long, the blockchain is only 150GB max. I have also tried to copy the Node from my old Server to the new one but I get always an error and i must download it again. Why can't I copy it to an new server? I have copied only the blocks and chainstate folders. Can i download it faster?

next time try to make it several questions, there is too much to answer...

  Why takes so long ?? Its just 150GB Max the Blockchain size...

The full node verifies each transaction for its validity, so that your local copy of the blockchain is safe to be used. More information on bitcoin.org. So this is normal, it is not "just downloading".

  ... but i get always an error and i must downlaod it again, cant i
  copy it to an new server?

You didn't say s.th. on your error, we cannot guess! If you have the same software, it should be possible though. I have done it many times with core client. Need to sav wallet files before though, just to be sure!

  I have copy only the blocks and chainstate folder. Can i download it
  faster?

See, it is not downloading a file, it is connecting to peers asking for tx to assemble "the blockchain" locally. And therefor verification process happens. You can use a pruned mode, which will not store the whole blockchain on your drive, but also this would have to read once all tx. It is faster, but again not done within minutes. Try to read about it on bitcoin.org or the online book of Andreas ("Mastering Bitcoin"). This helps to understand.


Using xpub key derivation for user account balance? I want to accept payments, and to keep the wallet secure I believe using a xpub key would be the correct solution. The site uses Google Login, which gives me a user id.

My idea is that given the xpub on the server code, I can derive a unique payment address per user (using the Google user as the derivation seed), and then simply check the blockchain for new transactions. I would store the amount of used balance used on the server database, but since there are no physical products being sold, that shouldn't be of concern if hacked.

My question is if this would be secure, in case the server got hacked? If an hacker obtains the xpub and perhaps even some of the previously generated key derivations, is there anything bad the hacker could do?

(PS: Although I'm familiar with BTC inner-workings, this is my first project/implementation)

xpub is short for Extended Public Keys. Public keys, as their name suggests, are meant to be public. If the xpub is stolen, then all that will happen is that the thief will know how much money you have and public keys associated with those coins. All you lose is your privacy, no money is at risk.


How does bitcoin reward who find the block? After getting the getblocktemplate, hashing it, finding a solution and generating the proper message to submit to the blockchain, if i ever solve a block how does the network knows it was me and properly give the reward to my wallet?

i heard somewhere that i need to append a transaction sending 12.5 BTC to myself before generating the message, if that is true what does prevent anyone of generating more than one transaction and append before solving a block?

Does getblocktemplate coming from my bitcoin-cli already generates this transaction for me?

A miner will create a special type of transaction known as a Coinbase transaction, as the first transaction in the block. This special transaction pays the block reward (including transaction fees) to the miner (or anyone they choose). But the miner can only put one, valid coinbase transaction in a block because otherwise the block as a whole would be invalid, and all the full nodes would reject it, making the miners work wasted because the block doesn't get onto the valid blockchain and they receive nothing. So miners are forced to play by the rules.

And yes, getblocktemplate includes the coinbase transaction if coinbasetxn is included in the capabilities list


How to replicate getaccountaddress behaviour using getnewaddress and labels api The problem is getaccountaddress is getting deprecated and it has specific behaviour (not related to accounts) I'm relying heavily on. It gives you the same address between multiple calls as long as there are no incoming transactions…

What I'm doing essentially is calling getaccountaddress "" every time an address needs to be displayed.

The problem is getnewaddress is designed to always provide you with a new address, so I end up flooding wallet with meaningless amount of addresses that never receive anything.

I'm trying to replicate that old behaviour using labels API, but the best I've come up with is to combine getaddressesbylabel and parsing everything listtransactions outputs to find if there's an unused receive-typed address, and to generate new one if none found.

This seems both error prone and hardly scalable, because the number of addresses will potentially grow and may become very large very fast.

What are my options? Is there an API call that can be used as a replacement for getaccountaddress "" or a combination of calls?

It is possible to mimic the same functionality of getaccountaddress using a label.

This is an example in python:

#!/usr/bin/env python3

import bitcoin.rpc

bitcoin.SelectParams('regtest')
proxy = bitcoin.rpc.Proxy()

def get_unused_address():
    label = 'donations'
    unused = None
    try:
        addr_list = proxy.call('getaddressesbylabel', label)
    except bitcoin.rpc.JSONRPCError as err:
        if err.error['code'] == -11:
            # No addresses with label
            addr_list = None
    if addr_list:
        # Addresses with label found
        for addr in list(addr_list.keys()):
            # Check for tx received
            r = proxy.call('listreceivedbyaddress', 0, True, False, addr)
            if not len(r[0]['txids']):
                # Unused address found!
                unused = addr
                break
            else:
                # Used address found, remove label
                proxy.call('setlabel', addr, '')
    if not unused:
        # Address with label not found, generate a new one
        unused = proxy.getnewaddress(label)
    return unused

print("Unused address is: %s" % get_unused_address())


setup bitcoin miner on older hardware Hey my name is Philip and i would like to setup a bitcoin miner.

I am working on a school with loads of older pc's that i thought to be fun to set up for mining bitcoins, and i'm asking if it would be possible.

It is a lot of older hp pre built office pc's with no gpu's.

I want to do it for the experience of setting it up and don't expect to make any profit at all.

if it would be possible.

no. this would be wasting energy for heating the room

How much Bitcoin will I mine right now with hardware X?


How do you generate a receive address from a string? I already have a an address with Bitcoin and would like to generate a receive address using SHA256 hash which is based on a string.

I've found an example of creating an address using a SHA256 hash:

https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/addresses.js#L19

But I haven't found one to create a receive address from a base address using the same method.

I think there is some misconception, or we don't get your question right... One cannot create a "receive address" for an existing address. An address is based on a specific private/public key pair. I recommend looking up some fundamentals on wallets and the creation of addresses. A wallet is a collector of many keys, and one of the keys is used for (a generated) receive addresses. I think what you are asking might go into the direction of HD wallets... I provide some hints at the end.

In short, how to come from a string to an address: you have a private key (which can be your hexadecimal string), which is linked by ECDSA logic to a public key. This pubkey is hashed, some version bit and checksum logic, and finally base58 encoded. Look at this page here, it shows the different steps. Also here in stackexchange was a discussion specifically for compressed pubkeys, as the uncompressed keys aren't used widely anymore.

As long as you create many private/public keypairs (based on sha256 and "strings"), you can generate as many addresses as you like, and use one of them as receive address. However keep in mind, that if you generate yourself private/public keypairs, you are running into a trap! The keys need to be based on a certain randomness, and if you don't get it right, you will loose your funds. You have been warned :-)

Andreas' book "Mastering Bitcoin" is an amazing book that'll definitely get you some further insights. It's freely available online here. The chapter 4 on keys and 5 on wallets is what you'd be interested in :-)


P2P getHeaders message - how to get block locator hashes I'm trying to build my own block explorer
So that I need to use p2p bitcoin protocol. For that I'm using btcd (golang) lib.

According to bitcoin book I have to send version message (and receive verack message back) to init the connection, then I will send getheaders message in cycle.

Now, imagine I am a new peer and want to download all the blockchain (actually I want to receive block hashes with getheaders (2000 per tick) and for each block hash I want to receive a block itself to process it and put blocks data in my mongo database)

If I am new peer in the network, how should I send first (and next) getheaders message, I don't quite understand where should I get block locator hashes and how to form the message?

Block locator hashes are just the hashes of various blocks that you already have. As a new peer, the only block that you will have is the genesis block (the genesis block must be hard coded into your software). So you just send a getheaders message that only contains the hash of the genesis block.


What's the alternative to bitcoins that can be profitably mined by beginner? I have tons of CPU and a reasonably good GPU.

Should I used the CPU to mine namecoin and the GPU to mine litecoin? Or perhaps some other combination? Or what?

Namecoin is mergemined with Bitcoin, so the difficulty is near as high as bitcoin.
You may as well mine bitcoin and connect to a pool that allows Merged Mining Namecoins -- and you'll get uBTC bitcoins with no additional effort.

I recommend to leave the CPU alone especially if you're on windows, because i've noticed mining with both GPU and CPU is terrible because the CPU is required to submit and if the CPU is tied up with another application -- say NMC mining then the KH/s from litecoin will go down.


Does exist some library for decode/encode raw transaction? I want to parse raw transaction into JSON then change some values and encode back to hex. JSON like this:

{
"addresses": [
    "346vcZZ6QV4nr68fybMEuA7qxxQeyKWoPS"
],
"block_height": -1,
"block_index": -1,
"confirmations": 0,
"double_spend": false,
"fees": 0,
"hash": "e09c37cca11208a8c372a1e397dcff0382b4d78cdde157ce8824d028dc185a80",
"inputs": [
    {
        "age": 0,
        "output_index": 1,
        "prev_hash": "c15bb773cdd5bb63a65766f5680684ce991c126698db0aa020e3058081742874",
        "script_type": "empty",
        "sequence": 4294967295
    }
],
"outputs": [
    {
        "addresses": [
            "346vcZZ6QV4nr68fybMEuA7qxxQeyKWoPS"
        ],
        "script": "a9141a75cd53e9740caadbf83cbefdd087cdceb978a487",
        "script_type": "pay-to-script-hash",
        "value": 14000000
    }
],
"preference": "low",
"received": "2018-08-21T08:05:02.841875145Z",
"relayed_by": "54.160.159.32",
"size": 83,
"total": 14000000,
"ver": 2,
"vin_sz": 1,
"vout_sz": 1
}

I've tried to use bitcoinj but it returns very simple object without a lot of fields.


How do you output segwit bech32 (bc1...) / P2SH (3...) addresses from a bitcoin private key? I have a bitcoin private key and know that it can output a segwit addresses of bech32 bc1... and p2sh 3... formats. How can this be done easily?

Load up electrum 3.1.1+ and enable the "console" and in the console do the following to output the addresses you need by providing your private key:

bech32 format bc1...:

  bitcoin.address_from_private_key("p2wpkh:5Kkzs8XrJNAmf9......")

p2sh format 3...:

  bitcoin.address_from_private_key("p2wpkh-p2sh:5Kkzs8XrJNAmf9VQDFeG......")

you just need to prefix your private key with p2wpkh or p2wpkh-p2sh to get one of them.


Recent Bitcoin fork/why didnt I get credit? I am new to this crypto currency thing and am soooo confused but learn more and more everyday! What I am trying to figure out now is:

I own a fraction of a Bitcoin on Coinbase. I look at coin base as my “ETrade”. I can just buy and sell there, is there a better place and if so why is the other place better?
Recently, in November, Bitcoin had a fork. I was under the impression during a fork it is just like a “split”. I thought I would get equal “shares” of Bitcoin under a different symbol and/or Blockchain. I do not see where I received anything. Why?
Should I hold my coins elsewhere to take advantage of forks? If so, where?

Thank you so much for trying to clear up my spinning head!

If you had your coins in coinbase, you won't be credited as coinbase owns your private keys. To get your hard fork credits, you needed to have your funds in a external wallet with access to your private keys. After a fork happens, you can download a wallet that supports the new coin and import your private keys into it.


Would it be possible to create a mining pool service that specifically processed only certain transactions? I've seen that it's possible to encode custom data in the block chain.

I'm wondering if it's possible for someone to start a mining pool consisting of client that use some metadata in either wallets or their transactions to process only some transactions, possibly for zero fees, that offers a confirmation time service level.

If so how would one determine the amount of processing power required to honour a certain service level?

Would this service undermine some principal technical mechanisms of the bitcoin network?

From what I understand, you are asking whether one can customize a client running at a mining pool to favour some transactions based on factors like what metadata they contain or where they were sent from.

The answer is, yes, it would be pretty easy if you would be able to program a custom client or pool software.

Searching for a piece of information in a transaction is pretty easy and shouldn't require too much processing power (one could for example use OP_PUSHDATA and later OP_DROP to store some data without affecting the transaction). The downside is that anyone could see which transactions were potentially prepared like this.

If you wanted to discriminate based on where the data came from (for example, your own eWallet, or custom wallet running on a computer), you'd need to spend some more time coding, but one couldn't distinguish between your special transactions and the normal ones. You could for example encode the client to wrap the transaction up in some data packet and sign it using a specific key and algorithm before sending it to your server. You'd have to write some special code to check the signature and relay the information to the pool, but it shouldn't be too hard.

Such service would certainly go against the spirit of Bitcoin, and probably you'd get some backlash from the community if it found out, but it is possible none the less. Unless such a pool would hold a considerable amount of Bitcoin network's hashing power however, it would not disturb how the network works. However, if it was to reach 51+% percent of the hashing speed, as it is always with such an attack, it could control the entire network.


How do transactions in the blockchain work I'm trying to go through the whitepaper to get a better understanding of bitcoin but I don't understand the block and subsequent blockchain model to create a transaction. The problems that bitcoin seems like it is trying to address is verifying if person A actually has the money to send to person B, and ensuring person B can't alter the amount person A sends.

I get that if A is trying to send money to B, A should sign the transaction with his private key as B wants to ensure A is who is sending the money. What I don't understand is the need for the hashing of B's public key and the previous transaction, and what exactly is being verified/signed.

I read a bit about the problem of "double-spending" but I don't think I understand it entirely because I don't see how the above solves it. Double-spending as I understand it is A giving money to one person, then making the transaction seem like it didn't happen or is invalid in order to spend the same money to someone else.

If transaction i - 1 is being hashed in transaction i, that means only transaction i - 1 is known. It says nothing about transaction i - 2, where the same money that is being spent in transaction i could have already been spent. It doesn't seem like transaction i - 1 or i keeps a list of all previous transactions, so there's no way of verifying where the buyer in i actually has the money.

What is the purpose of hashing the recipients public key and the previous transaction, and what is being verified in the picture above

What I don't understand is the need for the hashing of B's public key

Hashing the public key is done for two reasons. It is a cost saving measure as it reduces the size of A's transaction. It also protects the actual public key so that, if Elliptic Curve Cryptography is broken, the private key cannot be reversed from the public key because the public key is not known until it is used in an input to a transaction.

  and the previous transaction,

Including the hashing of the previous transactions lets a transaction refer to the transactions it is spending from so that you can verify whether the money is legitimate.

  and what exactly is being verified/signed.

The message that is signed is the transaction (the one that is being created) itself. Of course it does not contain the signatures, but it contains everything else - the transactions being spent from and the outputs being created. This protects the other parts of the transaction from being modified by people not authorized to spend the money.

  If transaction i - 1 is being hashed in transaction i, that means only transaction i - 1 is known. It says nothing about transaction i - 2, where the same money that is being spent in transaction i could have already been spent. It doesn't seem like transaction i - 1 or i keeps a list of all previous transactions, so there's no way of verifying where the buyer in i actually has the money.

Transaction i - 1 contains the hash of transaction i - 2, which contains the hash of i - 3, and so on and so forth until you reach transaction i - i (the "first" transaction) which is a special transaction known as a coinbase. This is a coin generation transaction. Thus by following the entire chain of transactions backwards, you can verify if the money actually exists.


How do i retreive my bitcoins that I purchased but never receaved because of the dodgie bitcoin qt years ago? Hi guys I am seeking to retrieve my bitcoins I purchased years ago but my bitcoin qt never synced to receive them! I have now downloaded bitcoin core and I was advised that once I have done that it should automatically just transfer over but it hasn't! So what are my options to get hold of my bitcoins I purchased years ago????

The information needed for you to recover your coins is in the original bitcoin-qt you used to get the addresses to request the bitcoins. Did you back up its data folder?

The private key for your coins is in that backup. If you didn't back that up, you probably can't recover the coins.


Bitcoin has been unconfirmed for over 9 hours now am scared I don’t know what to fo I sent a total of about $540 worth of bTC to another account and it’s still unconfirmed for over 9 hours now the fee was about $0.29

Please what do I do am so sad

Just wait, your fee is low, so you have a low priority. It will eventually get trough.


My wallet doesn't show a confirmed transaction Someone sent me Bitcoin payment but when I check my wallet nothing appears. On the blockchain, the transaction is already confirmed.

I use archived address.

Open your btc wallet using app then go to addresses ! click on the address that you want to recover the and hope des :D


I have my 12 word bip39 phrase but not in the right order I have my 12 word phrase, but when i enter it in a wallet, it brings up an empty wallet, so i think i probably wrote it down in the wrong order. What can i do to recover my wallet?

I suspect that the words are in the right order, since BIP39 includes a checksum word - If they were out of order, it is unlikely that the wallet would have accepted them to even attempt a recovery.

It is more likely that the two wallets you used were using different derivation paths and/or address types.

A seed phrase can lead to many different addresses, such as regular addresses, P2SH-P2PKH addresses, and native segwit P2PKH addresses. Many wallets these days support multiple types of addresses, and you would need to point the wallet to the correct derivation path when restoring a seed.

Moreover, wallets such as electrum default to their own seed semantics, and must be told to use BIP39 explicitly, which can also lead to different addresses being derived.

Your best bet would be to look up the original wallet and see what type of addresses it was deriving, and the derivation path. Then, use another wallet that allows you to restore the same path and address type.


Could the standard pay to address script be simpler? e.g. no compare of the HASH160? What if I had a scriptPubKey of

<pubKey>OP_CHECKSIG

And an scriptSig of

<sig>

Question

Would that work in the standard client?
Why do we need to check the hash?

The only possible reason I could come up with is that it makes a DDOS much more difficult since people aren't flooding the network with invalid signatures that eats up the CPU, and a hash is relatively inexpensive.

If the explanation I have is correct, is it documented anywhere?

The wiki says that that the pay to pub key hash is to prevent a break in the ECDSA algorithm, but I wonder what the real answer might be.

This is the standard pay-to-pubkey script, which was the original "standard script" for a while, and is still used if you'd solo mine from within bitcoind.

Originally, Bitcoin transactions were intended to use pay-to-IP, where the "address" was an IP address, and the public key to pay to was computed on the fly when requested by the sender. These transactions used pay-to-pubkey scripts.

Pay-to-IP became deprecated and eventually removed quickly, mostly because of security reasons (man-in-the-middle), and the "workaround" (intended for when the recipient was offline) pay-to-pubkeyhash took over, with several unfortunate side effects (address reuse, no comments on transactions, ...). Hopefully the Payment Protocol (BIP 70-72) can bring these back.

There are other reasons for preferring pay-to-pubkeyhash instead of pay-to-pubkey, such as a very minor security advantage (before the pubkey is revealed, the attacker first needs a preimage attack on the hash, before starting to attack the EC key), and smaller effect on the UTXO set (the database every full node maintains in addition to the block chain).


is there any way to get derivative path from public key and xpub? I have an xpub derived from m/44'/0'/1' can I get that path again from generated xpub or pubkey?  something like
def get_path(xpub):

   return derivative_path

No, you can't, apart from trying various paths and re-deriving it.


How do extremely difficult vanity addresses get found in the first place? I haven't found a specific answer to my question so please excuse me when an answer is somewhere out there.
Regarding the '1BitcoinEaterAddressDontSendf59kuE' address. If it would take more than the universe's time to crack such address how did this address get found and by whoem in the first place? Not any and all combinations of characters is a legit address or am i wrong?
Really confused about this, hope someone can clear this out for me!
And are there more longer known messages in exsisting addresses? Love to know about them!
Source: https://miro.medium.com/max/700/0*cg3mwxEbN7vIKbDS.jpg
Edit: What I refer to is a burn (lost key) address instead of vanity (owned key)
Thanks in advance

Funds are spendable by public keys and addresses contain public key hashes. Vanity addresses are created by hashing lots of public keys until the hash is in an expected range. What you mentioned is an example of a burn address, not a vanity address. Burn addresses are crafted by manually editing the public key hash with a specific the corresponding address in mind. Burn addresses do have corresponding public key(s), but since we it is impossible to find the public key from the public key hash, burn addresses cannot spend their funds. They are similar to addresses whose owners mistakenly deleted their wallets, where the funds are in a locked state.
The last digits of burn addresses is random is because addresses also contain a checksum which is the hash of everything else encoded in the address.


Current block vs whole block chain attack If an evil computer network wanted to attack Bitcoin, would they need to have more computing power than the present Bitcoin network and then attack a current block, or would they need even more to go back and recalculate all the checksums in the block chain since day one?

I am thinking that as history continues the work required grows and therefore the need for more computing power makes an attack of this sort less feasible.

Changing the blockchain at a point earlier than the most recent checkpoint is impossible, at least with the main client. It won't be accepted by those clients.

One can fork the chain at any point, but the most current block is the easiest as it does not require to backtrack and solve the previous blocks. Unless you have some specific transactions you want to invalidate, you would start from the current block.


"No more backup pools left. Using primary and starting over." I am not using a pool, I am using my graphics cards mining with poclbm over rpc. i do not understand why I get these messages.

localhost:8332 15/08/2012 22:40:13, No more backup pools left. Using primary and starting over.
localhost:8332 15/08/2012 22:40:13, Setting server (MYUSERNAME @ localhost:8332)
localhost:8332 16/08/2012 13:15:35, No more backup pools left. Using primary and starting over.
localhost:8332 16/08/2012 13:15:35, Setting server (MYUSERNAME @ localhost:8332)

Is this something that is fixable? Should I bother (does it affect the mining in any significant way)?

Presumably, you have no backup pool configured. So if your server doesn't respond quickly enough, poclbm just fails over back to the primary pool. If these are only happening occasionally, I wouldn't worry about it. Anything that momentarily prevents the RPC call from getting a response can do this.


how to find p2sh/p2wsh in utxo set after wallet recovery i'm trying to understand how wallets remember a redeem script for p2sh/p2wsh for spending, after recovering from their seed, because the utxo set only has the hash in it, right? there are a nearly infinite number of script possibilities, aren't there? what do i miss?

It depends on what your scripts are. If you are for example talking about a single-sig wrapped segwit address, the redeemscript can be recalculated from the corresponding public key. The wallet would derive some number of keys from the backup, then derive the corresponding redeemscripts and addresses. As the wallet is scanning the blockchain, whenever it gets a hit for any of the addresses, it will backfill the wallet with more "unused addresses" beyond the used address. The count of the unused addresses to scan for is defined by something usually called the "gap limit".

To regenerate redeemscripts of multisig addresses, the backup needs to include the full set and order of the involved public keys! Even if you have a sufficient quorum of the keys to spend, you cannot craft a valid transaction without the remaining keys due to the missing redeemscript. Most wallets today are set up using hierarchical deterministic key derivation, so again, the wallet would be able to regenerate as many addresses as needed from the original tuple of extended pubkeys. Of course that also requires the backup to store which derivation path was used.

If you are talking about arbitrary scripts, the backup better have the full redeemscript, otherwise you'll likely be out of luck.


Goverment Hacking Bitcoin Most of the bitcoin community is aware that the U.S. Government "seized" 2 million USD worth of bitcoins at the times current exchange rates. How would the U.S. go about using these. Generally with seized property they set up auctions, but how would that occur.

Seized items that are not of obvious benefit to the thief eventually get sold at public auction. If they fall into a process that doesn't understand the technology or there are auctioneer agreements then it will be a traditional auction. Value is not likely to be understated or undersold as this will be a very marketable item to advertise.

Stolen goods are also used to attempt interdiction. The government would use the coins in sting operations and in attempts to undermine confidence.


Why does bitcoin sync inventories? I read the bitcoin docs describing how btc syncs. During IBD it gets the inventories up to the tip with getblock. Why does it not skip this step and get the blocks, generating the inventories as it gets each block? Surely getting inventories is slow, unneeded and inefficient?
I believe bitcoin daemon over version 0.10.0 now sync headers rather than inventories, i am talking about pre 0.10.0.

Pre 0.10 versions synced inventories as it was the way they composed a list of blocks that they then recursively request from the peer. It provides multiple benefits over just asking for all blocks since timestamp x (where is the timestamp of the last block we had).

The biggest one being that it allows you to check the peer is on the same chain as the checkpoint you are using, this means you can check the peer is on the correct chain (eg the one your checkpoints state is correct) before downloading blocks, which are considerably larger than just hashes.


How we decode output address from Bitcoin genesis transaction Accordingly to blockchain.info, the first bitcoin transaction ever spends 50 BTC to the address 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa.

The pubkey script of that transaction is

PUSHDATA(65)[04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f] CHECKSIG'

The hash160 of 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa is 62e907b15cbf27d5425399ebf6f0fb50ebb88f18, but I don't see any occurrences of it in pubkey script above (yes, I'm aware about endianness issues). How could Blockchain.info ever know that an output of that transaction is 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa?

This is a pay-to-pubkey (P2PK) script, where the transaction contains the destination public key itself. These were common in the early days of Bitcoin, and were originally the type of script that would be created by default by miners (see Why does the default miner implementation use pay-to-pubkey?), though nobody seems to know why this was chosen.

Nowadays the norm is to use a pay-to-pubkey-hash (P2PKH) script, which as you know contains the hash160 of the public key, rather than the key itself.  You can note that such a script looks different, e.g.

 DUP HASH160 PUSHDATA(20)[536ffa992491508dca0354e52f32a3a7a679a53a] EQUALVERIFY CHECKSIG

Blockchain.info is taking the pubkey from the transaction, computing its hash, and converting it to a base58 address.  This is just a convenience for the user, so that one can think of either P2PK or P2PKH transactions as crediting an "address".  So Satoshi could use the same private key to spend a P2PKH transaction sent to the address 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa, as to spend the genesis coinbase transaction (disregarding the fact that it actually can't be spent at all).


The input of every transaction refers to an output of a prior transaction.

An input can't be defined by only the transaction hash.  A transaction consists of 1 or more outputs if you only specify the transaction hash there is no way to know which output is being spent.**

Since these types of questions often come from a larger misunderstanding of how the network "really works" I am going to start with some "plain english" rules on transactions (tx):

1. A tx consists of one or more inputs and one or more outputs.
2. All tx inputs refer to an unspent output of a prior transaction.
3. The full value of an input is always spent; a tx can not spend part of the value.
4. Likewise all outputs are either spent or unspent, they can't be partially spent.
5. A tx "spends" the outputs which are referenced in the input portion of the tx.
6. A tx creates new spendable "unspent outputs" listed in the output portion of the tx.

Now that we got that out of the way, to define a tx input you need to refer to the hash of a prior transaction AND the output index.  The tx hash identifies the transaction, but the transaction may have more than one output so the index is used to identify which output is being "spent" here.

This may seem confusing because you will hear statements such as "I have 20 BTC stored at address 1XYZ..." or "My wallet had 100 BTC", but this is really an abstraction.  The client is merely showing you the sum of all the unspent outputs for an address or the entire wallet.

The Bitcoin network works on the concept of inputs and outputs

The Bitcoin network doesn't consider the "value" an address when validating txs.  When validating a tx, outputs are considered as independent entities.  Spending one output for a particular address has no effect on the other outputs (if any) for that address.  A transaction is valid (among other things)if all the inputs refer to valid unspent outputs of prior transactions (can't spend coins twice), the sum of the outputs is less than or equal to the sum of the inputs (can't counterfeit new coins), and the inputs are signed by the correct private key (only the "owner" of the private key can spend the coins).

Examples

To avoid a lot of excess detail we will look at a simplified version of the transactions used in the Bitcoin network.

Say an previous transaction exists (tx hash 1234567890).  In this transaction you have an input which referenced an unspent output of a previous transaction worth 100 BTC.  You send 50 BTC to one address, 10 BTC to another address, and the change (40 BTC) is sent to a new address in your wallet.  Remember we can't spend part of an unspent output so the change is necessary because we are spending a 100 BTC input but only need to "send" 60 BTC.

The simplified pseudo-transaction may look something like this.

In[0] <lets ignore the input for now but it does have a value of 100 BTC>
Out[0] Bitcoin address=1ABC... Value=50 BTC
Out[1] Bitcoin address=1DEF... Value=10 BTC
Out[2] Bitcoin address=1XYZ... Value=40 BTC

The tx has 1 input, 3 outputs, all in/out indexes are zero based, and the value of the outputs is equal to the value of the input.  If the output(s) are less than the input(s) then the difference is the fee paid to the miner.  If the outputs are more than the input(s) then the tx is invalid.

Now since the "change" address is 1XYZ is another address in our wallet we can use it in a new transactions. We will pay a merchant 1 BTC and give the miner a fee of 0.01 for fast inclusion in a block.  The change will be sent to yet another new address in the wallet (1ZZZ....). The resulting transaction may look like this:

In[0]  Tx hash=1234567890 OutputIndex=2
Out[0] Bitcoin Address=1HIJ... Value=1 BTC
Out[1] Bitcoin Address=1ZZZ... Value=38.99 BTC

The input refers to the 3rd (0 base array) output of the tx above.  Looking up the output index 2 of tx 123456789 we can see the value is 40.00 BTC.  The sum of the outputs are 39.99 meaning 0.01 BTC will be collected by the miner of the block.

Real txs deviate from the simplified version shown above

Note this isn't really important unless you want to dive deeper into the workings of the protocol.  The output of Bitcoin transactions are actually scripts instead of static addresses and values shown above.  Functionally for most outputs they work the same, although to save space the hash of the public key not the address is used in the output. All blocks have a required tx called the coinbase which has no input because the output is the block subsidy and the fees paid to miners.  All values in the Bitcoin network are integers in Satoshis (1E-8 BTC) so technically all the numbers in this post would be multiplied by 1E8.


Is it possible to create a transaction with 2txin and 2txout? Is it possible to create a transaction with 2txin and 2txout? If it is possible, then how does one sign this transaction?

Or do I have to create two separate transactions? 1txin 1txout and 1txin 2txout?

You can definitely do that. Generally speaking you can have any combination of n inputs and k outputs, both n and k being integers.

I'm assuming you want to know how to implement the signing process. The process to sign such a transaction is rather involved. You basically set the signatures on all inputs to an empty string and then iterate through the inputs, copying the transaction with empty signatures, inserting the script of the corresponding output in the signature's place and signing the resulting temporary transaction.

For the exact details see this very extensive explanation blog post.

If on the other hand you're using the Bitcon Core JSON RPC then it's a simple matter of calling signrawtransaction (API) and passing in a raw, i.e., unsigned transaction. Be careful though as there are no checks when signing this way and the resulting transaction does exactly what you told it to, e.g., it might claim 10 bitcoins and allocate only 1 on the outputs, leaving 9 bitcoins floating for transaction fees and you'll lose them.


how do miners verify transaction without identifying sender and receiver? I mean in satoshi paper we read sender and receiver have limited anonymity.

  By keeping public keys anonymous. The public can see that someone is sending an amount to someone else, but without information linking the transaction to anyone.

By keeping public keys anonymous how miners can verify that sender has enough money ?

by keeping public keys anonymous.

The whitepaper is referring to how, by default, it is not know which human or organisation controls a public key. ---The public key itself can be recovered from the signature on a Bitcoin transaction--- The public key is included as part of the scriptSig on a transaction input, and then hashed and validated against the public key used to create the address.

Since a signature can only be produced by the corresponding private key, you can validate that it is the correct key for the given address.

Thus, although you can see the amounts being moved around, you don't know who is spending them, or where they are going (without doing off chain analysis).

  By keeping public keys anonymous how miners can verify that sender has enough money

Now that we've established that the key itself is available, miners validate that the amounts are correct by referencing the chain of inputs. Each input in a transaction refers to a specific output created in the past. When validating, the node will look up all of the previous transactions referenced, add up all of their output values, and then check the current transaction's outputs. If the outputs created by the transaction are less than or equal to the input sum, it is valid.

In practice, outputs are less than the input currently, since 0 fee transactions are no longer allowed (they can still be mined, but you will find it quite difficult to broadcast them). The difference between the inputs and the outputs is claimed by the miner as the transaction fee.

The complete signature and address verification process involves:

Validating the signature over the transaction data
Hashing the public key from the scriptSig using HASH_160, and comparing it to the hash embedded in the address

This verifies that:

The transaction itself is signed
The public key matches the public key inside the address (by checking that the hashes are equal)


Can't connect to bitcoin lightning node Am trying to connect to https://1ml.com/node/02671251b5678771514df8f26cc01508606d697ae8cad38063f84becbd359b189f

From eclair app https://imgur.com/gallery/GoAMpjp   it keeps saying failed to open channel: Ask timed out on [Actor[akka://system/user/$i#-242463098

I also can't connect to that node. It simply seems like it is offline. Node explorers like 1ml don't keep track in Realtime if nodes are online. Did you talk to the owner of that node?


How can a government ban trading in bitcoin since the people can trade in overseas exchange? Recently, bitcoin fell because South Korean government threatened to ban trading. What I fail to understand is how can cryptocurrency trading be banned? Citizens can always trade anonymously in overseas exchange. What can governments do about it if they cannot track the anonymous trading that takes place?

https://www.reuters.com/article/us-southkorea-bitcoin/uproar-over-crackdown-on-cryptocurrencies-divides-south-korea-idUSKBN1F10YG?

They can't entirely ban trading for all of their citizens worldwide, but a government can ban trading within the country itself. This means that it will be much harder for people to trade and thus drastically reduce the number of people within the country that are trading.

However while you can trade anonymously, any earnings made from trading are usually taxed. Not paying your taxes (even for illegally earned money) is a good way to get a government coming down onto you.

Furthermore, in order for someone to even use the money that they earned, it must go through the banking system which governments usually have control over. Thus they can force banks to make it difficult, if not impossible, for people to deposit and withdraw their money from exchanges.

Without any way for people to get their money out of an exchange, most people won't change since trading anonymously just means that any earnings you get are almost entirely unusable to you.


Get simple BTC value to insert it in excel sheet I'm trying to so some maths calculations with Excel but I need to get the current btc value from any website that can provide it in any format but simple as possible.

Do you have any idea to get the current btc value (usd) and update it in real time in an excel sheet? Thanks.

This more of a question about excel than it is actually about Bitcoin. But the answer is actually pretty easy.

The first thing is that the data that you want to import from the web may not be easily isolated, so you might have to import much more data than you want into a second excel sheet, then link the cell with the data you are interested to a cell in your actual sheet.

Follow these steps:

Find a site that has the dynamic data you are looking for. Let's use Bitstamp.
Copy the data that you want and paste it into excel. You can't miss the current price right at the top.
After you paste it into excel the little paste options icon will popup next to it. Click it then select Refreshable Web Query.
A new window will popup that will load the whole page. You might get some script errors; you can ignore those.
The window directs you to click the arrow icon next to the table that you want to import. Unfortunately, with BitStamp, the only option is the whole page. Click the arrow then click import.
Excel will now import a load of data from the webpage. The second cell is the one we are looking for; that is the current Bitcoin price in USD. This is where have a separate sheet for this import data is convenient.
Go to the sheet where you want to use that data and link the cell you want to the other by first clicking = then clicking the cell in the sheet with all the data from bitstamp. You will see something like =Sheet1!A2 in the formula bar.

That's all there really is to it. Microsoft has an extensive article on the topic complete with all the technical details.


Where is the incentive to update the Merkle root I've just read the following question
Does block size effect Miner's Hashing speed?

and it appears that the answer is no - since miners only need to hash the Merkle root.

However, updating the Merkle root will take a lot of CPU power if/when bitcoin transactions reach a rate of 4000 tps.

What is the incentive for miners/pools to expend effort maintaining the merkle root at this rate?  Obviously if they do not expend this effort the result will be an ever growing backlog of unverified transactions.

The merkle root ensures that transactions were part of the block that is being found. It links the block header to the set of transactions in the block.

So if you don't update the merkle root you are not actually confirming the transactions, and you won't be able to collect the fee of the transactions. So the incentive to update the merkle root is the same as for including transactions into a block: you get transaction fees for doing so.


Transaction Maturity vs Block maturity I thought it was the same.

Block maturity - number of blocks created after.
Transaction maturity - maturity of block that contain transaction

Now I see that people use this terms as different. What is the difference?

As of Bitcoin Core 0.9.0 the block maturity is 101 blocks. This means that the reference bitcoin implementation considers it safe to spend bitcoins that were generated more than 101 blocks ago. The reason for the wait time is because soon after a block is generated there is the possibility that it will lose the race to become widely recognized as the next valid block by the network. (All miners are competing to add the next block to the blockchain, and sometimes two parties find the next block within a very short time. If this happens a race to propagate the block will ensue.) When a block loses the race, it is an "orphan" and the new bitcoins that were created (and awarded to a miner) become null and void. If these bitcoins had been spent, that transaction and all subsequent transactions based on those new bitcoins would be invalid. Bad news if you just mailed someone a new TV in exchange for these "immature" bitcoins.

Transaction maturity is different. Each time a transaction is included in a block, it has been confirmed to be valid by the network, and is then distributed to all the nodes on the network. Now would be the earliest you should ever mail the new TV. However, just like in the case of block maturity, this block could potentially lose the race to become widely recognized as the next valid block. If it were to be orphaned, the confirmation for a given transaction would be lost. Under normal circumstances, this is not a big deal - the next block (or next few blocks) will contain all of the transactions from the orphaned block. However, an attacking party could be actively trying to attach its own blocks to the blockchain which might contain double-spent coins or other non-kosher transactions. Conventional wisdom is that a transaction that is included in a block that has at least five more on top of it (6 confirmations) is not likely to be the result of an attacking party. This is because the hashing power required to rewrite a transaction that already happened and then consistently outpace the "honest" miners for 6 straight blocks would be too great.


Is it possible to write a transaction of bitcoins, having only pen, paper and a private key from the address with some unspent outputs? In my last answer I have done an allegation which I want to be proven or disproven. If this work possible, how much paper does it require? What kind of software needs Bob to send a transaction to miners?

The transaction digest alone would take around 2 days of non-stop work:

http://www.righto.com/2014/09/mining-bitcoin-with-pencil-and-paper.html

That's before you even start the 32-byte multiplication required to compute an ECDSA signature.

It might be humanly possible if the UTXO you are spending does not require a signature. An "anyone-can-spend" transaction would only take a few minutes to assemble since they require no input script. But then of course anyone could steal your coins before your TX got confirmed.


What's a Sybil attack? Can anyone please provide a clear definition for what a Sybil attack is?
I was asked how the cryptocurrency I am developing would prevent Sybil attacks.

A Sybil attack is an attack where a single adversary is controlling multiple nodes on a network. It is unknown to the network that the nodes are controlled by the same adversarial entity. For example, an adversary can spawn up multiple computers, virtual machines, and IP addresses. They can create multiple accounts with different usernames and e-mail addresses and pretend that they all exist in different countries.

Avoiding Sybil attacks is a difficult problem. In centralized systems they are typically avoided through heuristics that do not provide cryptographic assurance of Sybil resilience. For example, a centralized entity may try to avoid Sybil attacks by requiring that an individual IP cannot create more than a specific number of user accounts in a given time interval.

Sybil attacks are avoided in Bitcoin by requiring block generation ability to be proportional to computational power available through the proof-of-work mechanism. That way, an adversary is limited in how many blocks they can produce. This provides strong cryptographic guarantees of Sybil resilience.


wallet that does not abstract change addresses? I wanted a hands on approach to see change adresses myself instead of hiding away all the details.

I also want to see non-deterministic wallets just for education so that I can understand. When we need to make regular backups in non-deterministics wallets might apply actually making a back up of change adresses?

This type of question has not been asked before.

There are indeed wallets that allow a more manual and granular control of UTXOs, in my experience desktop wallets such as Electrum are more likely to have this feature. Mobile wallets are often more tuned for ease-of-use.

The best way to find something you like is to simply try a few and see what works best for you. Check out the Bitcoin.org wallet page, and always ensure you download wallet software from a trusted source, verify developer signatures, etc.

  I also want to see non-deterministic wallets just for education so that I can understand. When we need to make regular backups in non-deterministics wallets might apply actually making a back up of change adresses?

The backup of a non-deterministic wallet will include every address the wallet has used, including change addresses. This will be true whether or not the wallet shows the user the change addresses.


What currency do the antminer pools generate? Sorry to be a newbie, But I'm pretty lost. I just set up my first Antminer and don't understand very much. There are three pools suggested as the default. What am I generating as far as currency?

Antminer is good a a certain type of cryptographic hash: SHA256. So while you can technically hash any cryptocurrency that uses SHA256 (ie. http://www.coinwarz.com/miningprofitability/sha-256) most pools will be focused around Bitcoin and even those that don't mine Bitcoin directly, will give you the option to trade whatever they're mining, directly to Bitcoin.

Some pools can hash several similar cryptocurrencies at the same time but considering their relative values they are hardly worth the bother and admin taken to trade them and you can probably find a pool that does all of this automatically. Go ahead and visit the pools' websites and read their FAQ pages and ask for help on their forums!

Beware though - many, if not most, pools and Bitcoin services are run by Crooks out to steal your money or use your hashing power for their own gain. Look for pools that have been around for several years, and with lots of users and a friendly community!

Also beware! If you are paying for electricity, you are probably going to mine less Bitcoin than the cost of the electricity - so you might as well not mine at all and just spend the money that you would have spent on electricity, directly on buying Bitcoin at an exchange. For older hardware this holds true, even if Bitcoin should reach $3000 each.


Why are the fee value and modified fee value always the same? I do not see any transaction in the mempool having differing values for the fee and modified fee fields. Does nobody modify or accelerate their transactions?
How do transactions with modified fees show up in the mempool?

I can not see any transaction resting in Mempool having different values for Fee and Modified Fee fields?

That's probably because you haven't modified any.
The prioritisetransaction RPC exists for miners to signal that particular transactions are paid for out of band, or are the miner's own transactions that should prioritized for block construction over what is implied by their feerate.
If you're not a miner, there is no need to ever use this RPC, and the fee and modified fee will be identical for all transactions.


Pools combine power, but all focus on a block? How do they all earn? So,
As far as I understand, when you join a pool you help work on the block that they are currently trying to solve and get paid for. I understand that, and how it's all split up....

But with a ton of different pools working on the same blocks... They all seem to pay out EVERY block... How? Surely one is faster than another, and solves the block first, being paid all of the winnings?

How does everyone on different pools get paid for each block? I understand that if it's too slow they'll get nothing... but how?
Thanks.

Generally (in centralized mining pools), the block everyone is working on mining in the pool, is a block which pays the pool owner. When a valid block is found, the pool owner receives the reward and distributes it to the members in the pool. So every block found, each user receives a little bit of the total reward, generating a more steady income stream for the members who own their own would have very little chance of ever finding a block and getting paid the entire reward.

There is no way for a member of the pool to change who the block pays, without being excluded from the share of the rest of the pool, if they tried to change it to make it pay themselves they would just be solo-mining


Checking/polling a balance of an address in Electrum via the command line/RPC Suppose, I've dynamically -- via the command line/RPC -- created an address or payment_query in Electrum. And saved its details in a database along with the amount of bitcoins I expect to receive.

How can then check/poll if that amount of bitcoins has arrived to that address? Also via the command line/RPC.

I don't want to be notified by Electrum, rather I want to poll Electrum daemon myself. Hence an http request-callback which Electrum can send to a URL isn't an option I'm looking for. Also, at the moment, I don't have a blockchain locally. Maybe later I'll add it, though.

There are several ways depending on what you are using.  If you are wanting to query the daemon - one must assume you are running a Linux box or VPS

You do not want or need an " address balance " - you need YOUR wallet balance

This question has already been partially answered here =>  How would one monitor an address for a transaction and 1 confirmation in PHP?

The best way however is to use what the Electrum docs recommend - a curl call like this =>  curl --data-binary '{"id":"curltext","method":"getbalance","params":{"funded":true}}' http://127.0.0.1:7777

If you are using PHP - it would look something like this:

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "http://127.0.0.1:7777");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"id\":\"curltext\",\"method\":\"getbalance\",\"params\":{\"funded\":true}}");
curl_setopt($ch, CURLOPT_POST, 1);

$headers = array();
$headers[] = "Content-Type: application/x-www-form-urlencoded";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close ($ch);

You could make this inside a try-catch and trigger it by a cron job running at whatever interval you want to check

What comes back is a JSON-RPC file which you can decode into an array

$result =  json_decode($response, true);

and plug that into another variable for the single thing or things you want to work on from there

$wanted = $result["result"]["xxxxxxxxx"];

any of the parameters can be passed as a variable to the curl call

for instance to add a request it would go like this:

curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"id\":\"curltext\",\"method\":\"addrequest\",\"params\":{\"amount\":\"$how_much\",\"memo\":\"$your_memo->some_data_field\"}}");

You just need to run a  "getbalance " - or any - command see what it returns and adjust your code to pull the returned value from "result" - you just test for a greater than " 0 " and then empty the wallet by sending it to another wallet and wait for the next payment

You could then use that data to trigger a "do something" like the email example in the above link from the middle example there.


Check how many blocks dogecoind downloaded I just started to run dogecoind, and I am wondering how I am able to check how many blocks I have currently downloaded vs. how many total blocks need to be downloaded?

I found this handy script for bitcoind, but unfortunately, it does not work for dogecoind.

Using any cli-based daemon (dogecoind,bitcoind,etc.), you can use the cli getinfo command:

./dogecoin-cli getinfo

Will return something like:

{
"version" : 1080000,
"protocolversion" : 70003,
"walletversion" : 60000,
"balance" : 505658.00000000,
"blocks" : 399670,
"timeoffset" : -1,
"connections" : 7,
"proxy" : "",
"difficulty" : 9373.23745278,
"testnet" : false,
"keypoololdest" : 1404252263,
"keypoolsize" : 101,
"paytxfee" : 0.00000000,
"relayfee" : 1.00000000,
"errors" : ""
}


Is there a transaction propagation delay built in? When a node receives a transaction it verifies it and then sends it to its neighbors.
My question is: does the node broadcast the transaction right away or is there a delay built in (privacy concerns) and if there is a delay built in can anyone point me to the code where that happens?

Yes, there is what is called transaction trickling. This is a mechanism to select a random peer for immediate forwarding of all transactions, while others receive the transaction after a random timeout. This is done in order to reduce the chances of fingerprinting the origin of a transaction. Similar to the proposed dandelion paper, it forwards a transaction through a conduit of peers before spreading it widely in the network, and observers cannot identify the origin by simply timing the time peers announce the transaction's availability.


How to figure out litecoind has finished synching the chain? I’d like to know what is the latest block number,
with bitcoind i’m using the rpc blockchaininfo and can read the inititalblockdownload that tells me if it’s synched, and the block number is also in the message.
How to do that with litecoind ?

Try $ litecoin-cli getblockchaininfo

Note: "There is no way for checking whether syncing is done, simply because it isn't known." See https://bitcoin.stackexchange.com/a/10443/60443


Can someone explain to me how does PPLNS mining pool profit split in lay terms? I tried reading up on how PPLNS works for mining pools, but I'm still very lost. Can someone explain how does pay per last N shares work? Explain it as if I was a kid.

As you mine, you earn shares. The more hashes you do, the more shares you earn. PPLNS means that every time the pool mines a block, shares of the reward are distributed to the miners that mined the most recent shares. Often, N is chosen as twice the difficulty. So if, on average, a block will be found every one billion shares, the block reward is divided to those who submitted the last two billion shares when the block was found.


coinbase.com buying queue I am trying to buy bitcoins, and I have just recently got my bank account verfied on coinbase.com, and I am trying to buy bitcoins.

When browsing the buy page,  I got the following message

  Note! We've exceeded our normal buy limits for today. If you would
  still like to purchase you will receive the market price of bitcoin on
  Tuesday Apr 16, 2013 at 08:24AM PDT after your funds have arrived.
  read more

When I click read more, it just tells me

  Due to higher than normal buy volumes, we are unable to provide exact
  price quotes right now.

  Instead of pausing buys entirely, we decided to give people the option
  to purchase bitcoin at the market price in a few days. Once your USD
  funds arrive, we will exchange them to bitcoin at the market price at
  approximately Tuesday Apr 16, 2013 at 08:24AM PDT.

  Note that you can cancel your order at any time up until your bitcoin
  arrive from the transfer history page.

  The market price of bitcoin changes frequently. Below are some recent
  prices to give you an idea. These do not guarantee what the price will
  be in a few days.

It looks like it's allowing you to put yourself in a queue to buy bitcoin, but I have no idea how to take advantage of this feature.

Am I correct about what this feature is? and If I am, how do I take advantage of it?

As far as I can tell the queue itself is not actually functioning. The limit they have only exists for some hours during the day, and at some point they allow you to buy bitcoin and charge it to your bank account. You are then locked in at the rate which you purchased them at, however it takes about 5 days generally to receive your bitcoins.

I think this happens because they are fronting the money themselves to buy the bitcoins, and have a limited amount of funds per day which they can spare. Each day a new volley of bank transfers comes through and they can then afford to front more for people.


Is it possible to transfer BitCoins from BlockChain to CoinBase? I have BitCoins in BlockChain - is it possible to transfer these into my CoinBase account?

You can transfer bitcoin from anywhere to anywhere! Simply log in to coinbase and click "Request" and then submit the blank form (this is one way to find your bitcoin address) and then send the coins there. Historically, coinbase has allowed selling coins as soon as they see them, not requiring confirms like most exchanges do.

One note about using web wallets or other types of deposit withdraw accounts is that sending coins between them is bad practice. If there is any chance your coins will be sent back by the receiving wallet, you should always use your own client, such as any you find on bitcoin.org.

The reason so is that exchanges and other web wallets will not necessarily send the coins which you had sent to your address in order to withdraw your funds. So if a coin will be sent back, it will show up on an address not registered to you and you will not be credited the coins back.


Can a cryptocurrency be liquid while it is in its pre-sale, or even ICO I am planning to run a Coin's ICO for several years, not interested in the gains to be made from selling out ICO in 3 days NO, but interested in using the COin to end Global Poverty as i deem fit. So a lenghty ICO is one solution. That said I want to know if its possible for the coin to be liquid during the ICO of like 2-4 years. If it is possible for its liquidity then suggest how that can be done please.

It could, but liquidity during ICO (meaning you can buy and sell tokens before ICO ends) could lead to many economical problems. For instance, if people could buy your token on exchange - they will not buy it on ICO, so you will not get  funds you need for the project.