Failed to start lightningd.service: Unit bitcoind.service not found I followed the tutorial https://medium.com/@meeDamian/c-lightning-node-on-rbp3-b950660fb835 without error.
When I type:
 sudo systemctl start lightningd
I get
 Failed to start lightningd.service: Unit bitcoind.service not found.

Note: Blockchain syncronization is not finished

Any idea?
thank you

At the top of this tutorial they say: This guide assumes you’re on MacOS, comfortable with terminal, already have a Bitcoin Full Node running on Raspberry Pi 3 (optionally with Tor) and now you want to also add a c-lightning node to it.

bitcoind.service not found means that you don't have bitcoin-core installed.


Setting up and running multiple C-lightning nodes on same machine I have successfully setup a C-lightning node on ubuntu using the tutorial.  The problem I am having is trying to setup a second node that DOESN'T utilize the same .lightning hidden directory to run which means I can only run 1 node at a time.  How do I clone and setup a second c-lightning node on the same machine and run it in it's own hidden directory?  I am aware that both nodes need to direct to their own config files located in different paths.

you can run lightningd --help and get a list of arguments you can use to start lightning from the output there ist:

--lightning-dir=<dir>                Set working directory. All other files are
                                     relative to this
                                      (default: "/home/user/.lightning")

this means that you can set your own lightning-dir by calling lightningd --lightning-dir=/some/path/to/some/directory

now you can either put all the config values as additional arguments to your call or you put a config file into /some/path/to/some/directory/ which sets everything. the default is to call it config but you can also use the command line argument --conf=/path/to/some/conffile from lightningd to set a different one in a different location.

One thing you need to remember that both lightning nodes need to run on different tcp/ip ports. you do this by setting the port in your accounce addr in the config  file announce-addr=IP-ADDR:PORT you need to replacei IP-ADDR with your address and the port with the port.

obviously when interacting with each of the nodes you need to tell lightning-cli which one. again the --help command helps (:

lightning-cli --help
Usage: lightning-cli <command> [<params>...]
--lightning-dir=<dir>  Set working directory. All other files are relative to this (default: "/home/user/.lightning")
...

this means you can for example do lightning-cli --lightning-dir=/some/path/to/somedir/ getinfo


Why don't any of the SHA-256 vulnerabilities matter for mining? Wikipedia lists several vulnerabilities in SHA-256. Presumably, none of them can be used to mine faster, or it would be done already. Why don't these vulnerabilities lead to a problem for mining?

The attacks are against a "poor man's" version of SHA-256, where less rounds are performed than in the real SHA-256. They are useless for breaking SHA-256 itself, and more so for the double SHA-256 used in Bitcoin mining.

Also, what would be most useful for mining is a preimage attack, and those are much harder than collision attacks. You can see in the table on Wikipedia that the proposed preimage attacks, though faster than pure brute force, are still impossibly complex.


How is a transaction created? ( I have almost no background of coding, so please explain this in relatively easy words :) )

I want to know what are pubkey script, signature, full public key and the roles of these.

Specifically, I want to understand this diagram:

Here is how I understand this diagram;

Say, A wants to send 1btc to B.

Then, A gets something called Pubkey script from the most recent block in a block chain (Let’s call it PubkeyScript 1). Again, A uses something which is also called Pubkey script using the public key of B. (Let’s call it PubkeyScript 2) After that, A types a message “A sends 1btc to B”. Now, using A’s private key, convert the PubkeyScript1 to something called signature. Now, a chunk of signature and A’s public key and PubkeyScipt2 and the message “A sends 1btc to B” is called a transaction.

Am I understanding it correctly?

I try to explain it, that no coding is required :-) Taking more of a process view...
Assembly and sending of a tx:
the wallet software of A looks up it's internal database, if there is a transaction with required amount of 1 BTC on it. If yes, it then looks up this transaction's details in the blockchain, and finds in this transaction the pk script (spending condition), and assembles a new transaction, which shall move the funds to B's address. The wallet software then signs a hash of this transaction. The signature of this hash and the public key are placed in the [scriptsig] field of the transaction. So the final transaction contains the previous tx hash, signature and pubkey, and also an output section, with a pub key script (for B's  target address) and the amount. That's what the picture shows.
The transaction is then sent to the network.
Transaction Verification:
In the network are verifying nodes, that check for validity of the tx. Amongst others, these nodes check that you have the right to spend the funds. They take the current tx' sigscript (<signature> and <public key>), and from the previous tx the output script (pubkey script). Then basically two comparisons take place:

1.) can the public key of the previous tx' sigscript be hashed to the same value as the presented hash in the current tx' pubkey script?
2.) is the signature a valid signature for the public key

With the first check, it is assured, that the current transaction moves the funds to the previously defined target address. And with the second check it is verified, if the signature aligns to the presented public key.
For the second test: the wallet software creates a signature, which requires the private key of the owner of the public address. The private key is used to sign the hash of the current transaction.
The picture you provided has a presentation of the parts to create the spending tx. Not the verifying part. That makes it a bit more complex to derive functionality... I had a very good reading with Ken Shirrif's article here:
http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html
and also (of course) Andreas' book "Mastering Bitcoin" (Second Edition), which is also online available.


How long would it take to crack an 8-word brain wallet? Assuming my private key for a bitcoin wallet is derived from SHA256(passphrase) and the passphrase is 8 words long, how long would it take the average attacker to crack my bitcoin wallet through a bruteforce dictionary attack?

Assume there are no other characters besides letters.

A very, very long time.

Oxford English Dictionary contains full entries for 171,476 words in current use.

If you use only lower case letters and they are mostly random words (no phrases - "four score and seven years ago" is like having your password be "secret"), there are about 7.47e41 possibilities.

At 50 million attempts per second, it'll be about 4.74e26 years.

The current estimate for the age of the universe is 1.2e12 years.

If you reduce it to just the most commonly used 1000 words, at 50m gueses a second, it's reduced to 634,195,839 years.

That's pretty secure for a password.


I have a txt file labelled private key, inside is what i assume to be base64 string ending with = I have a txt file labelled private key, inside is what i assume to be base64 string ending with =, is there any way I can access the wallet I assume this is the private key for?

Presuming you are in possession of an actual private key and not a random Base64 string, consider this answer to convert it manually yourself or use an external program like this or this to convert it to the Wallet Import Format (WIF).
It would be preferred if you do this in a virtual machine disconnected from the internet for security reasons.


Blockchain growth projections and risks What is the projected block chain growth over time and could an attack on Bitcoin be lauched that creating an enourmous number of micro-transations to fracture the currency (e.g. spamming the system with valid nuisance transactions)

I cannot believe the pruning the blockchain makes any sense (ultimate source of the bitcoins would be obscured requiring use of post-pruned bitcoins to be trusted as if these were mined at the time of the pruning)... and I cannot see using some sort of distributed storage working (trust and centralization of information concerns).

But even if pruning were possible - it seems to me that a concerted attack would still be able to overwhelm the system in a relatively short time... because transaction generation is cheap as compared to validating these spamish transactions.

Is there an overall implied governance on the system for the number of transactions that can be processed in any period? e.g. the number of systems solving transaction validation problems versus the number of transactions injected into the system... and as the volume of transactions that are needed to for validation, some (many?) systems might become overwhelmed and unable to store / process the blockchain... but even in the case of legitimate growth in utilization I think about large international retailers who process billions of transactions per day what would the breaking point be should a sudden shift to bitcoin occur? e.g. what are the on-boarding costs for the bitcoin network for new retailers?

There's a maximum block size (in bytes). So growth is limited to a linear growth and pretty predictable.

Spamming the network is very expensive because the spammer would be paying a lot of fees.

The current blockchain size is not that bad: it fits on a simple SD card if you want. And storing it on a harddisk costs cents.

Pruning can be done in such a way that there is very (very!) little room for manipulation. Everything is cryptographically provable. And there will always be full nodes around that do keep the full history and can check everything. Others would probably be able to query those nodes to provably check the complete path of particular coins. If you can do that on a even a random subset of coins, you can be pretty darn sure there was no manipulation.

Your last paragraph indicates that you don't fully understand the block validation and mining process (like the maximum block size and only 1 block every ten minutes on average). Maybe you need to look into that some more.

Regarding scaling the network up: there's still quite a bit of room in the current block size configuration, but the developers can fairly easily increase that maximum.


How to start pool mining in Linux I have read numerous how-to and tutorials (most of them outdated) on how to simply start mining on a pool and I wasn't be able to do it.

Could someone simply describe/enumerate how can someone start pool-mining in a Linux OS (on any distribution) command-line (shell) ?

BitMinter is an attempt at making just this sort of thing easier and a more pleasant experience.

Install Java if you don't have it, e.g. on Ubuntu sudo apt-get install openjdk-6-jre icedtea-netx (the icedtea-netx is for Java WebStart)

If you will mine in GPUs, install the latest drivers (e.g. from amd.com)

If you will mine on FPGA/ASIC, give yourself access to serial ports. On Ubuntu sudo usermod -a -G dialout USERNAME then log out and back in.

Start the miner from bitminter.com website or commandline:
javaws http://bitminter.com/client/bitminter.jnlp


Can two parties accidentally pay the same lightning network invoice simultaneously? If multiple Lightning nodes attempt to pay the same invoice (using the same payment request), is it absolutely necessary that no more than one of the attempts will succeed (that is, only one payer will learn the preimage)?

I'd expect that clients try to not make multiple payments happen. What I'm willing to learn is whether it's actually impossible by protocol design.

As far as I know It can and did happen.

On a protocol level 2 seperate nodes (or the same node) can construct two different (or the same) onions and initiate the routing process.

On a protocol level I am not aware of any mechanics to prevent two htlcs on the same channel with the same payment hash and on different channels this is obviously not encoded to the protocol. In particular while there might be a rule that the recipient SHOULD NOT release the preimage more than once I don't see any way to detect or prevent such a behavior without drastic protocol changes.

The situation becomes worse, once we implement base AMP in which a recipient node expect several htlcs anyway and overpayment is also part of the expected protocol behavior.

A little off topic: AMP also allows a denial of service attack vector by just denying the second onion with the same payment hash to be forwarded.


How to look about transtion is complated? I'm trying to build my own blockexplorer, and to this i need to update a single transtion with confrims, my problems is i can't see how meny confrims there shut be and when my transtion is 100% complated.

i'm using RPC and bitcoin logic but what i'm working on is a multi-currency explorer based on bitcoin rpc syntax.

i use gettransaction (hash) and in this i can only se how many confrims, what do i wrong here?

i know i can say 6 confirms+ will be 100% complated, but the confirms still get bigger after 6 confirms, so i need to know when i shut stop to update my transtion on my blockexplorer project.

Let your explorer display the number of blocks confirmed.

As satoshi explains in section 11 of the whitepaper, a bitcoin transaction is never 100% final, but only the probability of it being not-final decreases with every confirmation. What probability of non-finality is good enough?

People could have any use-case so let people decide for themselves. Most want 6 confirmations safety to buy a car, some want 1 confirmation to buy coffee (and there are people like Roger Ver who want no confirmation!).


Include checksum in a transaction Is it possible to include a file's checksum in a transaction?

Not necessarily in Bitcoin's current blockchain due to the now limited OP_RETURN feature, but just in the blockchain/transaction concept in general.

Yes you can. You can use OP_RETURN of course but there are also other ways, some "hacks" like adding an transaction output that refers to an Bitcoin address that instead of being the hash of your public key is the hash of your file.

Here is what Garvin Aderson said about OP_RETURN

  Why 80 bytes? Because we imagine that most uses will be to hash some larger data (perhaps a contract of some sort) and then embed the hash plus maybe a little bit of metadata into the output. But it is not large enough to do something silly like embed images or tweets.
  Why allow any bytes at all? Because we can’t stop people from adding one or more ordinary-looking-but-unspendable outputs to their transactions to embed arbitrary data in the blockchain.
  What do I mean by “immediately prune-able?”  The form of the up-to-80-byte transaction output (“OP_RETURN ”) is such that it can never be used as an input for another transaction– so it can theoretically be forgotten by everybody except for machines that want to keep a full record of every single transaction (“archive nodes”). That is a big improvement over the various hacks people are using today to associate data with their transactions, and will be more important in the future when we implement code that saves disk space by keeping only unspent transaction outputs and not every old block.

Source Gavin Andresen talks about the 0.9 release


How are different Addresses generated from the same Private key? I was reading in the "Technical background of version 1 Bitcoin addresses" that addresses are a function of the private key. More or less:

Private Key -> Public Key -> Address

If the Public Key is the only input needed to generate an Address, how come a wallet generates a different address every time? What is changing?

Private and public key correspond to a point on the secp256k1 curve. They have a one-to-one relationship.

The address is derived from the public key by performing a ripemd160 hash after a sha256 hash on the public key. Multiple public keys hash to the same address, as the address space is only 160 bit, while the public key space is 256 bit.

Since both derivations (private key > public key > address) are deterministic, you cannot derive more than one address from one private key.*

What you can do, is derive additional private keys from a "master private key" with a given derivation rule. These additional private keys obviously correspond to new addresses. This type of address management is called "hierarchical deterministic wallet".

*Strictly speaking, you can create multiple addresses by differentiating between compressed and uncompressed keys. See Sven's and skaht's answers for details.


how to transmit commitment transaction (unilateral close) from lightning network channel How would you transmit a commitment transaction from a lightning network channel instead of closing the channel? I am working on implementing a watchtower and I first need to simulate a double spend attempt. When I close a channel with $ lncli closechannel, both nodes have the bitcoin available and neither has to wait for the time lock. Is there a command to get the node to submit a unilateral close commitment transaction where one of them has to wait for the time lock?

Generally it is preferable to collaboratively close a channel as it is faster for both sides and saves onchain fees and space. As far as I know implementations do not provide an api to the close command by which you can enforce a certain type of close. In order to achieve what you want you have 2 options:

You Patch your lightning node to provide that api yourself
You run two lightning nodes with a channel between them. Then you turn off one node and run the close command on the other. As the first node is not peered the nodes can't close collaboratively so there will happen a force close.


Why are zero fee transactions not being included in blocks that are not full? Today, I sent a Bitcoin payment but it has not been included in a block for about 10 hours now. The payment had the following characteristics:

~0.1 BTC
222 bytes
One UTXO as an input (I used coin control)
The UTXO was approximately 1 year old

Currently, blocks are not always full (in fact there are blocks that are only 8% full). For that reason I attempted to save the fee.

(https://bitcoinfees.github.io/#1m)

(https://blockchain.info/ 2016-08-08 20:42 UTC).

What policy do miners currently have regarding zero fee transactions? I have sent many zero fee transactions in the past (>1 year ago) and the block inclusion time was really quick (~5 blocks maybe). Did the policy of miners change?

It likely has to do with the minimum relay fee set on the nodes that are mining. There's also coin age that is taken into consideration on low or no fee transactions.

Relay and Mining: Priority transactions

Bitcoin Core has a heuristic ‘priority’ based on coin value and age. This calculation is used for relaying of transactions which do not pay the minimum relay fee, and can be used as an alternative way of sorting transactions for mined blocks. Bitcoin Core will relay transactions with insufficient fees depending on the setting of -limitfreerelay= (default: r=15 kB per minute) and -blockprioritysize=.

Soure


What's the difference between the Bitcoin's peer to peer protocol and the RPC API? Bitcoin implements both a peer-to-peer synchronization protocol (normally on port 8333) and a JSON-RPC API (normally on port 8332).

What are these designed to accomplish?
If I'm trying to implement a wallet that doesn't need bitcoind to be installed to work, which one should I use?
What existing libraries implement the low-level details of these protocols?

Related:

What is the difference between the rpc port 8332 and port 8333?

The Peer to Peer protocol (using version, verack, getdata, ... etc. messages) is used by all clients communicating on the network. This protocol is how data is spread through the network. This is done directly over TCP/IP. Messages have their own format (not JSON) and allow the spread of transactions and blocks through the network. Read more at: https://bitcoin.org/en/developer-reference#protocol-versions.

After a Bitcoin Core full node has received the block and transaction data via this P2P protocol, then a user can use the RPC interface to query the node about the data it has received. The JSON-RPC interface used is specific to Bitcoin Core, although other clients may introduce similar interfaces for ease of use. Nodes do not typically communicate with each other using the RPC interface at all, the RPC calls are more like tools that Bitcoin Core provides for developers to give them access to the blockchain data.


Why is last channel's expiry different in Lightning Network Routes? Both in the Basic of Lightning Technology (BOLT) documents, and in the specification of lnd, there is a different treatment for the last channel in a route. In BOLT#2 it refers to a variable min_final_cltv_expiry:

  min_final_cltv_expiry is the minimum difference between HTLC CLTV timeout and the current
  block height, for the terminal case (C).

This value is 9, as opposed to 144 for cltv_expiry_delta.

This is most likely related with the output of a route when querying lnd, for example, suppose the route Alice -> Bob -> Carol -> Dave, routed from Alice:
the output is:

$> lncli-alice queryroutes --dest=<Carol_pubkey> --amt=5 --num_max_routes=1
total_time_lock: 1443640
total_fees: 1
total_amt: 6
hops {
  chan_id: <id_chan_alice_bob>
  chan_capacity: <cap>
  amt_to_forward: 6
  expiry: 1443610
  amt_to_forward_msat: 6000
  fee_msat: 1
}
hops {
  chan_id: <id_chan_bob_carol>
  chan_capacity: <cap>
  amt_to_forward: 5
  fee: 1
  expiry: 1443466
  amt_to_forward_msat: 5000
  fee_msat: 1000
}
hops {
  chan_id: <id_chan_carol_dave>
  chan_capacity: <cap>
  amt_to_forward: 5
  expiry: 1443466
  amt_to_forward_msat: 5000
}
total_fees_msat: 1001
total_amt_msat: 6001

Notice the last two hops have the same expiry value. Why is the last hop different with regard to the expiry?

After some searching through the BOLT documents and talking with the lnd slack community, I found an answer:

  B->C. If B were to send 4,999,999 millisatoshi directly to C, it would
  neither charge itself a fee nor add its own cltv_expiry_delta, so it
  would use C's requested min_final_cltv_expiry of 9. Presumably it
  would also add a shadow route to give an extra CLTV of 42.
  Additionally, it could add extra CLTV deltas at other hops, as these
  values represent a minimum, but chooses not to do so here, for the
  sake of simplicity:

Also, although cltv_expiry_delta is default to 9 in BOLT, in lnd they use 144, but without checking for the final hop. That is, they do not add the final_cltv_expiry because they have already a big cltv_expiry (I presume). Olaoluwa said in the slack
that they plan to reduce the value of cltv_expiry_delta to get closer to the default value listed in BOLT. However, if they do this, I hope they take care of adding the additional cltv_expiry_delta, as it will be important to add in this case. For an example of what I mean, check the above-linked link for BOLT #007


cant see bitcoin after restore of backup I made a backup of my Qt wallet. The blockchain never got completely downloaded and i was sent a bitcoin that i never saw in my wallet as the downloading of the blockchain never caught up with the transaction. I placed this backup file into another Qt wallet that was fully up to date with the blockchain, thinking that i would see the bitcoin but I only see my bitcoin address.
Can anyone please tell me how this is?

Try running bitcoin-qt with the -rescan argument.


What RPCs can I use to transform an address to a paying script? What RPC(s) can I use to transform an address to a paying script (0014<addr>)?

Try validateaddress, note the scriptPubKey in the output of these examples:
$ bitcoin-cli validateaddress bc1q7ckr2hlws6ku4mlaggvmfqwgs42zjm4qf3s7hy
{
  "isvalid": true,
  "address": "bc1q7ckr2hlws6ku4mlaggvmfqwgs42zjm4qf3s7hy",
  "scriptPubKey": "0014f62c355fee86adcaeffd4219b481c88554296ea0",
  "isscript": false,
  "iswitness": true,
  "witness_version": 0,
  "witness_program": "f62c355fee86adcaeffd4219b481c88554296ea0"
}

$ bitcoin-cli validateaddress 1MWrgo4rm1aoPYFjCCMXgr1e564xVyHCqM
{
  "isvalid": true,
  "address": "1MWrgo4rm1aoPYFjCCMXgr1e564xVyHCqM",
  "scriptPubKey": "76a914e1080defe0aa086f1d5f698faf614e8f67af6e3b88ac",
  "isscript": false,
  "iswitness": false
}

Update: RPC getaddressinfo will also return the matching output script.


Does sending from a green address improve my anonymity? If I am interested in improving my anonymity when dealing with a merchant, does sending from a Green Address help?

My proposed steps for buying from a merchant as anonymously as possible would be:

1) Send coins to InstaWallet (connecting to InstaWallet through Tor)

2) Send coins from InstaWallet to merchant using InstaWallet's Green Address feature.

My theory is that the Green Address would make it much more difficult for the merchant to determine my identity, compared to sending the coins directly from my personal wallet. If I send the coins directly from my wallet, the merchant could likely trace the coins back to the exchange where I originally purchased them, and possibly issue a subpoena to the exchange (which likely knows my identity). Whereas, if I send the coins via a Green Address, the merchant could not trace the coins upstream at all - even if they issued a subpoena to InstaWallet, there should be no way to determine the original source of the coins.

Is my theory correct? Do Green Addresses help improve anonymity?

No, your theory is incorrect. If anything, the green address makes it easier to trace.

If I see a transaction from an Instawallet green address, I subpoena Instawallet and ask them who commanded them to make that transaction. Boom, they found me.

If I don't use a green address, how can they tell the coins came from Instalwallet at all? How would they even know who to subpoena?

  If I send the coins directly from my wallet, the merchant could likely trace the coins back to the exchange where I originally purchased them, and possibly issue a subpoena to the exchange (which likely knows my identity).

So what? If some dollar bills were used to buy drugs that I withdrew from an ATM machine, what does that tell you? And how would they trace the coins to the exchange exactly?

  Whereas, if I send the coins via a Green Address, the merchant could not trace the coins upstream at all - even if they issued a subpoena to InstaWallet, there should be no way to determine the original source of the coins.

I don't follow your reasoning. They subpoena Instawallet and ask them which user commanded that transaction through their green address. They identify you. They're just saved the hard work of trying to trace the coins to an exchange.

It's pretty much academic anyway. There's no good way to tell a sham transaction (where the sender and recipient accounts are controlled by the same party) from a real one.


btcchina how to deposit with mastercard? https://vip.btcchina.com

I'm trying to "Fund CNY" to use in my bitcoin trades.
The problem is, whichever bank I choose, it redirects to a login page asking for a password or mobile payment option which I don't know how to use.

I only have the mastercard payment option. How can I fund?

you need to make a wire transfer to a china bank or fund your account with bitcoins


What trust am I placing where when I use Electrum? I have read that Electrum never is given your private keys (which makes sense), but I'm still unsure what sacrifices it makes in order to not require you to not store the entire ~14GB blockchain.

So is the gist of it "you make transactions on your own using your information, but we watch the blockchain and tell you anything relevant that happens"?  Am I understanding this at all correctly?

If so, who is "we" in that?  And can't whoever I am trusting lie to me about how many bitcoins I have?

"We" are volunteers running Electrum servers. There's almost no trust in them, the absolute worst they can do is feed you false negatives about the balance of your wallet, or they can also choose not to broadcast your transactions and pretend that they have. You trade some privacy in that they can see the contents of your entire wallet and associate it with your IP address. The client supports Tor connections if this is an issue for you.

The blockchain is 22Gb now, actually.


Public key from private key generation problem I met some problems, when I was trying to write function able to create Bitcoin public key from private key. I was using the tutorial: http://procbits.com/2013/08/27/generating-a-bitcoin-address-with-javascript ---> "Public key" part is most important.

Part of my code looks like this:

public String generatePublicKey(String privateKey)
{
    BigInteger privKey = new BigInteger(privateKey,16);
    X9ECParameters ecp = SECNamedCurves.getByName("secp256k1");
    ECPoint curvePt = ecp.getG().multiply(privKey);
    BigInteger x = curvePt.getXCoord().toBigInteger();
    BigInteger y = curvePt.getYCoord().toBigInteger();
    byte[] xBytes = this.removeSignByte(x.toByteArray());
    byte[] yBytes = this.removeSignByte(y.toByteArray());
    byte[] pubKeyBytes = new byte[65];
    pubKeyBytes[0] = new Byte("04");
    System.arraycopy(xBytes,0, pubKeyBytes, 1, xBytes.length);
    System.arraycopy(yBytes, 0, pubKeyBytes, 33, yBytes.length);
    return this.bytesToHex(pubKeyBytes);}

There are also two functions:

final protected static char[] hexArray = "0123456789ABCDEF".toCharArray();
public String bytesToHex(byte[] bytes) {
    char[] hexChars = new char[bytes.length * 2];
    int v;
    for ( int j = 0; j < bytes.length; j++ ) {
        v = bytes[j] & 0xFF;
        hexChars[j * 2] = hexArray[v >>> 4];
        hexChars[j * 2 + 1] = hexArray[v & 0x0F];
    }
    return new String(hexChars);
}

private byte[] removeSignByte(byte[] arr)
{
    if(arr.length==33)
    {
        byte[] newArr = new byte[32];
        System.arraycopy(arr, 1, newArr, 0, newArr.length);
        return newArr;
    }
    return arr;
}

However I used bytesToHex() earlier and there weren't any problems. So the thing is that generatePublicKey() does not work properly. I tried to insert private key known from bitcoin wiki:

18E14A7B6A307F426A94F8114701E7C8E774E7F9A47E2C2035DB29A206321725

(from https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses)

It should create long public key (even before all hashing) - step 2 on wiki:

0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6

Unfortunately the answer is wrong. Could you Guys look at this and point my mistakes?

Ofc, programming language is Java and cryptographic provider was Bouncy Castle.

EDIT:
I accidentally solved my problem. When I was writing this function, Eclipse told me function getX() (and getY()) is depracated. So I used getXCoord(), because I thought its result is the same. In feeling hopeless I used getX() instead getXCoord() and whole function magically worked!

What's the difference between getX() and getXCoord() ?


a question on bitcoin transaction I would like to know whether these statements are true.

"Say a Bitcoin market participant should choose to sell a large volume of the currency. Because each transaction is broadcast to a network that is — by design and necessity — public and publicly observable, the entire market could become privy to such an event."

The public network would see only that a transaction occurred - that a large amount of Bitcoin was transferred from one address (or set of addresses) to another.  There wouldn't be any way to be sure, from that information alone, that the transaction was actually a sale, rather than the same owner just moving the coins to a different address (e.g. for cold storage).  One also couldn't necessarily know who the owner or recipient of the coins was.  If the coins were spread across many addresses, you couldn't even be sure they all belonged to the same person.

So I'd say that statement is false.


Bitcoin-cli how to createrawtransaction without spending entire input? Is there any possible way to create a raw transaction using Bitcoin-cli createrawtransaction API that doesn't require spending the entire input?

What I'm doing now is consuming that entire input sending 0.01 to the address specified and sending the change back to the address I'm withdrawing from.

If I deposit 0.5 BTC to my wallet and withdraw 0.01 is there any method to be able to work with my 0.49 BTC I have remaining without having it consumed entirely and being sent to the change address because then I'm stuck waiting for it to confirm and it gives off the impression my wallet balance is 0 when it's really 0.49 BTC.

Is there any possible way to create a raw transaction using Bitcoin-cli createrawtransaction API that doesn't require spending the entire input?

No.  It's an inherent feature of the Bitcoin protocol that inputs must be spent entirely or not at all.  It's a binary state: spent or unspent.  There is no "partially spent".

  What I'm doing now is consuming that entire input sending 0.01 to the address specified and sending the change back to the address I'm withdrawing from.

Yes, that's what you have to do (though for privacy reasons it is better to send the change to a freshly generated address instead).

  If I deposit 0.5 BTC to my wallet and withdraw 0.01 is there any method to be able to work with my 0.49 BTC I have remaining without having it consumed entirely and being sent to the change address

Nope.

  because then I'm stuck waiting for it to confirm and it gives off the impression my wallet balance is 0 when it's really 0.49 BTC.

Yes, that's something you just have to live with.  However, you don't necessarily have to wait for the transaction to confirm before spending the change.  But the second transaction won't confirm until after the first one does.


SHA256 vs RIPEMD160 in SegWit In Pay-To-Witness-Public-Key-Hash (P2WPKH), the RIPEMD160 hash function is used to hash the public key of the recipient in the locking script.
On the contrary, Pay-To-Witness-Script-Hash (P2WSH) uses the SHA256 for hashing the redeem script.
Why has this difference been made?
Just to differentiate the two types of witness programs?

The P2WPKH actually uses the HASH160 hashing algorithm, which is just RIPEMD160(SHA256(pubkey)).

The reason for using SHA256 is mentioned in BIP141:

  The increased size improves security against possible collision
  attacks, as 2^80 work is not infeasible anymore (By the end of 2015,
  2^84 hashes have been calculated in Bitcoin mining since the creation
  of Bitcoin). - BIP141

And yes, like you said, the witness program is determined not only by the version 0x00 byte, but also the length of the program. See BIP141 - P2SH


Is SegWit similar to/ derived from Hyperledger Fabric? Segregating the witness (signature) data from the transactional data is similar to the structure used in Hyperledger Fabric.
Curious about the derivation of SegWit?

OP clearly felt his question was adequately answered by Pieter Wuille's comment:

  Segregated Witness (on a Bitcoin-like system) was first deployed in Elements Alpha, released in May 2015, while the Hyperledger project only started in December 2015. It's also a very straightforward design (and arguably Bitcoin's legacy one was the weird one), several from scratch projects never considered anything else

  Is SegWit derived from Hyperledger Fabric?

No, the dates above make this very unlikely.


Recover bitcoin wallet with old Private Key about 3 years ago I created my bit coin  wallet and purchased few bit coins. I have done couple transactions with my wallet paying for things I bought in the internet.

I have no record of my wallet

I do have my private key

Recently I tried to import my private key in blockchain.info and got the message Invalid private key encoding

I know for sure that this is my private key

I will appreciate any helpin explaining  what could be the reason for this error message

Also, how I can see transactions done with this private key

..and ofcourse any ideas to recover will be greatly appreciated

The problem might be that blockchain.info wants the WIF (wallet import format) instead of the private key. You might try to find some tools for converting the keys you have in WIF and then try to import them.

Make sure not to give away your keys in the process of converting (I wouldn't trust online tools)


Why is it harder to compute nonce for a hash with a certain number zero prefixes than it is for any other hash? Based on my rudimentary understanding of Bitcoins and altcoins, network difficulty is adjusted by asking the network to target a hash smaller than a specific number, which translates to calculating nonce for a hash with a certain number of zeros prefixed to it.

Since hash values are supposed to be uniformly distributed, I don't understand why targeting a hash value with a specific number of zeroes is any more easy/difficult than targeting any other hash (not the hash value of the content without nonce obviously). I think targeting any of the possible hash values, except what the content already hashes to, should be equally difficult. Why is that not the case?

It's very likely that my understanding of Bitcoin network difficulty itself is wrong, in which case, could you please explain that to me?

A hash is 256 bits long, so there are 2^256 possible hashes in the hash space. But if you assert that the hash has to begin with a 0, that halves the number of hashes that are allowed (and thus doubles the average number of hashes you need to test), and if you say it must start with two 0's, that's now only quarter of the hash space that is valid. The difficulty of finding a valid hash thus grows exponentially with the number of 0's you require at the start.

But as you said, because the hashes are uniformly distributed, there is nothing unique about requiring the hash start with x number of 0's. Requiring the hash to start with x number of 1's would be the same, as would any specific sequence of 1's and 0's be. 0's are just a nice choice and make sense in practice, because like you said, you are then computing a hash less than a specific number.

Just to point out the terminology difference by the way, it's not targeting a specific hash, it's targeting a specific subset of the possible hashes. To find a specific hash would mean SHA-256 is broken, because you are basically reversing the hashing operation.


Blockchain transaction change output I'm very new to this.
It’s hard to know for sure, but what’s most likely the case with the below transaction:

Someone sent 25.99 bitcoin to another person/organization
Someone sent 1 bitcoin to another person/organization
Someone sent 26.99 bitcoin to another person/organization

You cannot say for sure.
The three options are potentially true.
However, many clients build transactions with the change output as the last output.
So, following this convention, I would say option 2 is the most likely.


Someon offered me btc mine trough his mining device Someone from the social network offered me a btc mine through his mining device. He asked me for an email address so he could create a mining wallet address for me. I gave it to him. I don't know what he did, but very soon after that I received an email from Blockchain informing me that my wallet address had been created and that I could connect it directly to the mining stream.
After this I should deposit a certain amount of btc to this wallet address, which is now, supposedly connected to this gentleman’s mining device.
is this a scam attack or ..

Yes, it's a scam. Don't send them anything.


How did anyone buy bitcoins before exchanges? How did the first bitcoins get bought by anyone?

I understand how miners got them, but what did they do with them?

On messageboards like bitcointalk and chatrooms. People would use Paypal or other digital payment systems to send dollars. You could also trade in person through meetups and localbitcoins.com which still happens today.


Openssl magic values? Secp256k1 and ECDSA similarities? What makes secp256k1 special? Part 1:

Running this command seems to be a reliable way to produce a pubkey from a valid private key that for Bitcoin. Is this a correct assumption?

openssl ec -inform DER -text -noout -in <(cat <(echo -n "302e0201010420") <(echo -n "PRIVATE_KEY_HEX_STRING") <(echo -n "a00706052b8104000a") | xxd -r -p) 2>/dev/null | tail -6 | head -5 | sed 's/[ :]//g' | tr -d '\n' && echo

These magic values:

302e0201010420

a00706052b8104000a

Openssl seems to use these values for DER encoding rules, and it doesn't seem to have anything to do with secp256k1 or Bitcoin specifically. Is this a correct assumption?

Part 2:

It doesn't seem like the y^2 = x^3 + 7 formula / secp256k1 is used anywhere explicitly when deriving the pubkey from the private key in the above openssl command.

Are all public keys for Elliptical Cryptography practically derived the same way.. meaning there is a ton of overlap between these ECDSA curves?

Seems like the only thing specific to Bitcoin compared to another ECDSA curve is the maximum upper limit for a private key of FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE BAAEDCE6 AF48A03B BFD25E8C D0364141.. is this a correct assumption? How is it that I'm able to produce the private and public keys without having to use the formula? It's like Satoshi lied to us and this formula has no meaning!

A bit confused here would love if someone could clear this up for me and the 2 other people who can't sleep at night because of this.

You are using the eliptic curve function of openssl and providing a serialized bytestring as an input. DER (Distinguished Encoding Rules) is a restricted variant of BER for producing unequivocal transfer syntax for data structures described by ASN.1.

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

See also:
Signing transaction with SSL - private key to PEM


How do the JavaScript SecureRandom() vulnerabilities affect me? A recent post on the Bitcoin-dev mailing list talks about multiple vulnerabilities in JavaScript SecureRandom() class. Apparently this class has been used in multiple cryptocurrency wallets that use JavaScript to generate private keys.

What products are affected by these vulnerabilities? As a user of these products, what should I do to make myself no longer vulnerable?

What products are effected by these vulnerabilties?

-- Not Sure specific products, but watch out for products(wallets) using javascript lib to generate private keys.

As a user of these products, what should I do to make myself no longer vulnerable?

-- you should immediately move your funds to new addresses, make sure new wallet does not suffer from this known vulnerability.


How to build a bitcoinj checkpoint file How can I build a bitcoinj checkpoint file
like the Bitcoin-wallet checkpoints?

From this discussion: How to create a checkpoint file

Run mvn exec:java -Dexec.mainClass=com.google.bitcoin.tools.BuildCheckpoints in the tools/ directory from the bitcoinj repository.

BuildCheckpoints expects you to have a fully synced local Bitcoin-Qt/bitcoind instance running.


Must my wallet be connected to the internet to receive payments? (This question applies to private wallets, stored in a local computer. Not so much for online wallets, which are supposed to always be connected to the internet)

Let's say I have a wallet with several addresses. Somebody (maybe even myself) makes a transfer to one of my addresses. My impression is that my bitcoin client (the one managing the wallet to which the address is associated) must be running and connected to the internet in order for this transfer to be executed.

I say this because, since a wallet has real money, the bitcoins (those unique bitcoins that have been transferred) must arrive to the wallet somehow. But if my wallet is not connected, this is impossible.

So here my questions:

what happens if the wallet is not connected to the internet? Where are the bitcoins? Are they in a "bitcoin limbo" until they are transferred to my wallet?
How is this managed from the blockchain point of view? Are transfers marked as "done" when the money has been transferred to a wallet?
is there any kind of timeout? What happens if I do not connect my client for a day / month / year / ever? Are the bitcoins lost, or is the transfer cancelled?

Maybe I am misunderstanding what an address / wallet really represents.

No, the transactions are weaved into the blockchain by the p2p network of miners. That's what counts. Your address is only a keypair that proves you ownership. The concept of cold storage is exactly the idea to not connect to the internet so nobody can steal your coins (or rather, the key to access your wallet).


Why do both Mt. Gox and Intersango use Polish banks? Since their previous France and UK accounts were closed, both Mt. Gox and Intersango set up accounts in Poland.

Is there a specific reason why they chose Poland?

As for Mt. Gox, they got their polish account when they bought up bitomat.pl, after it lost its private keys. They continue to support accounts from that other website, so they allow easy money transfers to that account (although it takes them a couple days to credit the account).

As for Intersango, I presume they might want to cater to that part of the market (bitomat was dealing solely in PLN and it was the third largest Bitcoin exchange at a time). It could also be related to the fact that poles often work in UK (where the exchange is located) and transfer their money back to Poland - wire transfers between countries are quite expensive, while sending Bitcoins is cheap.


Displaying the bitcoin wallet on the internet I was wondering, is it a security risk if you display your bitcoin wallet on the internet? Let's say my bitcoin address is 123abc. This is linked to my wallet which stores several bitcoins. It is adviced to place the address 123abc openly on the internet? Or is it a security risk?

First, do not mix up the words "wallet" and "address".  A wallet is a file or computer program which stores the private keys corresponding to one or more Bitcoin addresses.  Sharing the address is very different from sharing the private keys.

Sharing the address is not a security risk, in the sense that knowing the address does not give anyone the ability to spend your bitcoins.  They would have to know the private key.  Indeed, since Bitcoin uses a public transaction register, you can assume everyone in the world already knows the address 123abc exists, and knows how many bitcoins are credited to that address.

However, sharing the address can be a privacy risk.  Everybody knows that the address 123abc exists; what they don't know is who it belongs to.  If you post the address on your personal website, or from an account that can be connected to you, now they do know that.

For instance, suppose you made a transaction from that address to an address that's known to belong to EmbarrassingSexToys.com.  The transaction is public, so everyone can see that it was made.  If you hadn't posted your address on the Internet, then everybody knows that somebody bought an embarrassing sex toy, but nobody knows who it was.  If you did post your address, then everyone knows that Adnan bought an embarrassing sex toy.


JSON-RPC get full nodes information Is there any way to get all full nodes by RPC call?

Afaik full node contains information of other full nodes in the network and was wondering how to request that.

I red the documentation on Bitcoin Core Apis and all I found is getpeerinfo which returns a list of connected nodes but the JSON it gave me seem to not contain that information.

Does anyone know if this data is accessable and how to get it?

You cannot request this information, because it does not exist.

There is no central registry of nodes, nor do they have identities to begin with. Full nodes do maintain a database of IP addresses of peers they now about, but that is not, and is not intended to be, a comprehensive list of all nodes on the network.

The closest that exists are network crawlers who ask around for IP addresses and try connecting to them (some DNS seed report results based on crawler information), but even that is only an approximation, and can only discover nodes that are reachable. The vast majority of full nodes only make outgoing connections.


When I use InstaWallet.org, do I get my own Bitcoin address? InstaWallet is an online Bitcoin wallet service.  When I visit it for the first time, it generates a Bitcoin address that I can use to deposit to.

I'm wondering whether that address is only ever used for my account, or whether all the coins that InstaWallet receive end up in a single large wallet.

If it's only ever used for my account, I should be able to use blockexplorer to monitor my balance.  That's the case with MyWallet, since they don't even have access to the address' private key.
On the other hand, if everything goes into a single wallet, it's possible that other users' withdrawals may be paid with funds from my deposit address.  That's what happens at MtGox and other exchanges.

So which is it?

That address only receives deposits to your account. Otherwise, they'd have no idea what account to credit when funds wound up in that address.

But you can't use blockexplorer to monitor your balance, only to monitor the total amount of deposits you've made. InstaWallet will remove funds from that account as they wish to aggregate your funds with other deposits and service withdrawals.

Also, when you make a payment, even if InstaWallet uses your coins to make the payment, the "change" will be sent to a different address. For example, if you deposit 20 bitcoins and then withdraw 10, even if InstaWallet did use your 20 bitcoins to fund the withdrawal, the remaining 10 bitcoins would go to a different bitcoin address even though it's still in your InstaWallet account.

If, say, you're expecting someone to send you some Bitcoins, you could use blockexplorer to see if they've made that payment. But the balance you see won't really mean anything, it's just some number equal to or less than the total amount you've ever deposited through that address.


Where to advertise new bitcoin service? i created new service which is using bitcoin for payment. I am bit struggling with Bitcoin community and don't know what to do next.

Recently i
- i added service to bitcoin.it wiki
- created announcement on bitcointalk.org
- added link to reddit /r/Bitcoin

Is there any other possibilities to let the Bitcoin community know about my service?

You've already made a post on reddit, made a thread on bitcointalk and added it to the wiki, but if you want to advertise it (as in paid advertising) then you can try the following sites:

coinurl.com - banner and text advertising, fairly cheap

bitads.net - you choose which sites you want to advertise on. can be quite cheap too

a-ads.net - no account system, just create a campaign and deposit. again, fairly cheap.

Bitcoin advertising are generally much cheaper than traditional advertising. If you accept Inputs.io, you can also get a free ad slot on Inputs' wallet page, and an instant payment button sounds perfect for selling digital files :)


I sent bitcoin from my BitcoinQt wallet while it was unsynced to another wallet, do I have to wait for it to sync? The wallet shows that the transaction has not been broadcasted yet with 0 of 6 confirmations. My wallet is stuck on a block right now.

Yes, you have to wait. Otherwise you would be able to pay things with money you don't have in your wallet.

You could have spent all your bitcoins, but since your wallet is not synced you may be able to spend money you have already spent but has not been synced, thus it is not allowed to do that.


Sudden Drop in Hash Rate GeForce 650 GPU Card I'm running on a 15" Retina MBP and have just been playing around with mining on it a little bit.  I realize GPU mining is almost dead at the moment, but bear with me.

Overnight last night I was running the BitMinter Java client and getting around ~20Mh/s.  I fired it up again this evening, and for some reason, am now only getting around 5Mh/s.  I'm seeing the same rate on both the BitMinter java client as well as with cgminer.  Nothing has changed on my system over the last day other than having to reboot it a few times for other reasons.  Does anyone have any idea why my Mh/s output rate has fallen so much?

I think I figured out my own issue here.  I reset the SMC on the macbook (http://support.apple.com/kb/HT3964) and my GPU performance is back to normal.


What does "PROOF OF WORK RESULT: false (booooo)" mean when mining? I'm mining (Litecoin miner, shouldn't matter) with minerd, and got this in the output:

[2011-10-13 07:12:02] thread 1: 5524 hashes, 0.96 khash/sec
[2011-10-13 07:12:02] thread 0: 5415 hashes, 0.95 khash/sec
[2011-10-13 07:12:04] thread 0: 1588 hashes, 0.94 khash/sec
[2011-10-13 07:12:04] PROOF OF WORK RESULT: false (booooo)
[2011-10-13 07:12:04] thread 6: 5319 hashes, 0.95 khash/sec
[2011-10-13 07:12:04] thread 5: 6026 hashes, 0.96 khash/sec

What does the "Proof of work result: false" mean? Is it a stale block, meaning a block I just solved, but someone else beat me to it and published it first?

You're solo mining. So there's nothing useful you can do with a share -- there's nothing for you to share in. Every share you find will be rejected, unless you actually mine a block.


What is the point of keeping transactions if they are hashed? In the blockchain people keep saying that all of the transactions are listed. Then why are they hashed? What's the point of hashing them if you can't check the blockchain afterwards.

There are some misunderstandings here. First, transactions are hashed in several ways for different purposes, but actually they are kept in the original in the blockchain: As you said, this is needed to check the blockchain later, or to provide the information to other participants for them to catch up with the network.

So, when and to what purpose are they hashed, then?

Transaction Identifier (txid)

Standard transactions range in size from roughly 192 bytes to 100,000 bytes, although the smallest possible transaction is 61
   bytes, and the largest one ever seen was 999,657 bytes. Anyway, I think we can agree that some of them can be unwieldy to send around in full, just to reference them. ;)

This is where transaction IDs come in. The transaction ID is the digest of performing the SHA-256 hashing function twice on the serialized transaction. The resulting digest or hash is always 256 bits (hence the name), which can be represented with 32 bytes. Using the txid to reference transactions is obviously much less bandwidth intensive which is why this is how peers exchange information about transactions: when a peer learns about a new transaction, this will be in form of an INVENTORY message that presents him a list of txids, to which the node may respond by requesting the unseen transactions with the corresponding txids.

Merkle tree

Transactions in a block have a fixed order. This can be used to create a Merkle tree from the transactions. Merkle trees are useful in that they allow lightweight nodes to confirm the membership of a transaction in a block without having full knowledge of the block's content. The Merkle tree is created by hashing transactions pairwise iteratively until only a single hash results. This Merkle root can be used to represent all transactions in a block and prevents anyone from changing the block's content.

Proof of work

A third  application of hashing in Bitcoin is the consensus mechanism 'proof of work'. Bitcoin's central innovation is using the blockchain to create consensus about the order of transactions in the system. To that end, miners collect unconfirmed transactions into block templates for which they then evaluate whether they resolve to a valid block. These block templates consist of a block header (which among other information collects the aforementioned Merkle root) that is subjected to a doubly applied SHA-256 function. If the result surpasses the difficulty, a new valid block has been found.

Sighashes

We need to make sure that only the owner of funds may spend them. This is solved by the owner signing a transaction with the corresponding private key for each input that they are spending. However, there's another application for hashes in there as well (hat tip to Pieter for pointing it out): for each input a "signature hash" is produced which is a digest of all inputs and outputs of the transaction. As this is what the sender signs, they not only authenticate themselves as the rightful owner, but also commit the signature to exactly this transaction. Thus the signature is useless even to spend another transaction output from the same address, and it is impossible for third parties to redirect payments.

Addresses

While private key and public key together make a point on an ECDSA curve, the address is actually also derived by hashing: It is a RIPEMD-160 hash of the public key. This allows the public key to remain unknown until received money is spent from an address for the first time.

The point of hashing

As we can see, while addresses are indeed kept in full in the blockchain, hashing allows us to:

Save bandwidth in transaction relay
Verify transaction confirmations without knowing full blocks
Limit block discovery and introduce digital scarcity
Protect transactions from being altered by third parties
Protect sensible information, while proving our possession of it


Cannot open dump wallet file (code-8) Is anybody familiar with this problem using btc qt debug console?

Would like to dump wallet and sweep into electrum.

You need to enclose the filename in quotes.
eg:
dumpwallet "C:\output.txt"

As opposed to:
dumpwallet C:\output.txt      (wrong)


Can Bitcoin help people commit money laundering? I don't have enough knowledge pertaining to the Bitcoin mechanism. Can Bitcoin help people commit money laundering?

Since the vast majority of money launderers seem to prefer cash, I'd say the answer is no. At least, not yet. The way money laundering works is that you hide illegitimate transactions in a sea of legitimate transactions. There are a vast sea of legitimate cash transactions which makes money laundering in cash work well. Until there are some high-volume Bitcoin businesses, there will be nothing to hide illegitimate transactions with.

Even if the idea is to buy Bitcoins with dirty cash, sell them at an exchange, and claim you bought them really cheap and held them for a long time -- where can you buy large numbers of Bitcoins anonymously for cash?


Callback not working in program using the blockchain api I am trying to create automated receive Bitcoin payments via Blockchain API.
I have my API key, xpub, everything. I'm using PHP.

Here is the part of my code for generating wallet address:

$scrt = my_super_secret_code_60_chars_long;
$my_callback_url = "http://mysite.com/lib/payment.php?secret={$scrt}";
$my_xpub = "my_xpub_key";
$my_api_key = "my_secret_api_key";

$root_url = "https://api.blockchain.info/v2/receive";
$parameters = "xpub=" .$my_xpub. "&callback=" .urlencode($my_callback_url). "&key=" .$my_api_key;

$qry= "SELECT ID,RECEIVE_ADDR FROM MY_TABLE WHERE WALLET = '{$_GET['wallet']}' ";
$result = mysqli_query($conn,$qry);
$row = mysqli_fetch_row($result);
$reci = $row[1];
$uid = $row[0];
if ($reci=='none') {
//if the user does not have generated receive address, triggering this
$response = file_get_contents($root_url . '?' . $parameters);
$object = json_decode($response);

echo 'Send Payment To : ' . $object->address;

$qry= "UPDATE MY_TABLE SET RECEIVE_ADDR='". $object->address ."' WHERE WALLET = '{$_GET['wallet']}' ";
mysqli_query($conn,$qry);
 }

This code works, but I have a problem with the callback to payment.php.
It's not triggering when the payment is received, however manually, I can simulate the received payment by calling PHP with correct parameters.

Here is the relevant part of payment.php:

<?php
$scrtt = $_GET['secret']; //password is passed back to the callback URL
$transaction_hash = $_GET['transaction_hash'];
$value_in_satoshi = $_GET['value'];
$value_in_btc = $value_in_satoshi / 100000000;

$gt='CALLBACK CALLED - TXID:'.$transaction_hash.' VALUE '.$value_in_satoshi.' SCRT:'.$scrtt.' CONFIRMS:'.$_GET['confirmations'];
$qry= "INSERT INTO DEBUG (TE) VALUES ('{$gt}')";
mysqli_query($conn,$qry);
//code above is for debugging - but not triggered however payment is received
if ($scrtt== my_super_secret_code) {
if ($_GET['confirmations'] >= 2) {
$confirms=$_GET['confirmations'];
$qry= "SELECT ID FROM MY_TABLE WHERE RECEIVE_ADDR = '{$_GET['address']}'";

$result = mysqli_query($conn,$qry);
$row = mysqli_fetch_row($result);
$uid = $row[0];

$qry= "SELECT TXHASH FROM PAYMENTS WHERE TXHASH = '{$_GET['transaction_hash']}' ";

$result = mysqli_query($conn,$qry);
$row = mysqli_fetch_row($result);
$tx = $row[0];

if ($tx <> $transaction_hash) {

    $qry="INSERT INTO PAYMENTS (TXHASH,USER_ID,SATS,CONFIRMS) VALUES ('{$transaction_hash}',{$uid},{$value_in_satoshi},{$confirms})";
mysqli_query($conn,$qry);

//new tx - insert
}

//Insert into confirmed payments

}
}
echo '*ok*';
?>

My problem is, the callback is never called— can anyone check my code and tell me where I the problem is?

thanks

UPDATE:

I investigated a little and here is my result (however it's still not working)

I found the url to check a callback log directly on the blockchain:
https://api.blockchain.info/v2/receive/callback_log?callback=http-urlencoded_my_website/callback.php?parameters&key=my-api-key

The log shows me something like that:

callback":"http://mysite.com/callback.php?param=myparam","called_at":"2017-03-10T13:05:39Z","response_code":403,"raw_response":"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n\n<title>403 Forbidden</title>\n\n
Forbidden
\n
You don't have permission to access /callback.php\non this server.
\n
\n
Additionally, a 403 Forbidden\nerror was encountered while trying to use an ErrorDocument to handle the request.
\n\n"}]

Can someone help me with that?
I am an owner of this domain and I can access this page with all of my browsers.

SOLUTION:

It started to work, after removing .htaccess file from /public_html on my webpage..  so simple solution..

i think it can be done with some reconfiguration too, but i am not using .htaccess, so it was the simpliest solution for me :)


Any plans for Bitcoin Core app to integrate Hardware Wallet support? So I could use the full node and wallet easily integrated with a HW wallet and avoid security exploits?
Recently had a case of someone that had all his wallet stolen probably because of a keylogger - not a good experience for a noob that was just starting and was trusting the "best" full(complete) node Bitcoin (don't trust, verify) experience.

We know the key creation is flawed from the user perspective and this is something that already has a solution but still not implemented into the full node wallet client. Any plans for adding this extra layer of security for non-technical end-users?

There currently are no plans to support hardware wallets in Core. However this does not mean that it will not happen, it just means that no one is currently working on supporting them. Unfortunately there are no full node wallets which support hardware wallets. But I am working on hardware wallet support in Armory so you can look forward to that coming out in a few months (probably).


In the future, if I pay a coffee with a very low fee, will it ever be paid? So this is the thing, I am just learning about feedrates and how the miners pick their transactions with higher fees, so they can get more money. But, what will happen in the future when people pay really small things in the daily basis and the fees are insignificant, does this mean that I would get my coffee but it will be never paid?

No, ofc not.

In future, if the fees are insignificant, there will be a lot of transactions and miners will get the proper rewards for their work by all those small fees together.

New blocks are coming with new transactions every 10 minutes. Any transaction with fee superior to 1sat/byte will eventually gets confirmed.


How to capture c-lightining logs? Where does c-lightning save its debug.log file? I know you can run the lightning daemon with --log-level=debug and access the logs in the terminal. But, I run my node on a remote server and I access it via SSH and sometimes when my internet connection goes off for a second on the machine which I am accessing through, my SSH client times out. I was wondering if there is a location where c-lightning saves all these logs just like how Bitcoin-core saves its debug.log file in ~/.bitcoin folder.

C-lightning does not save logs by default. One can ensure that the logs are saved to the drive by including log-file=<file_name>.log in the config file. When staring lightningd you can include the level of logs that the file has to capture by including --log-level=LEVEL, where LEVEL can be io, debug, info, unusual, or broken.


Which mobile apps allow me to redeem a private key from a QR code? Which mobile apps will let me scan a QR code of a private key (such as the one created by BitAddress) and then spend the funds from that coin?

Please specify Android, iPhone (iOS), etc.

Mt. Gox mobile, available from Google Play and on jailbroken iPhones using Cydia allows you to redeem private key QR codes into your Mt. Gox account.

As a bonus, if any payments are made to that address in the future, Mt. Gox will automatically sweep those funds as well.


Finding a transaction in the blockchain I wanna understand how can a user find a certain transaction he created on the blockchain without him knowing on which block it belongs ? does he have to go over all the blocks using bloom filters to find his transaction ? narrow the search to an interval of timestamps ? there must be a special mechanism ...

I searched on google but all i found were websites to find them for u, i want to understand the actual mechanism used in the bitcoin protocol?

Block Explorers seems to be storing those transactions in special databases and they use their own approach to find transactions ... My question is about how full nodes find those transactions ? do they go over the whole chain trying to find them ?

After searching about this, i found out that each full node maintains a database with the set of unspent transaction outputs (UTXOs) in the memory. So When a new transaction is added, its UTXOs get updated accordingly (source). Also, a full node keeps track of all transactions that ever happened (source) and offer this:

Filtering transactions and blocks on behalf of lightweight nodes so that lightweight nodes do not need to download every transaction ever made on the network in order to find their own transactions.
Serving historical full blocks to nodes that have been offline for a while.
Transmitting new transactions from users to miners.
Broadcasting new blocks from miners to other nodes.

The RPC used for this call getrawtransaction that takes as an argument a TxID which is hashing twice the transaction data and gives you back the transaction you are searching for.


how can i get back money from my electronic wallet I am new to bitcoin and someone (the account manager) call me to buy and i made it last week. However, when i asked the account manager to transfer the money back to my credit card account. They said they have to make it to a mirror transaction first and then need to debit my credit card again. Now, i am no more money in my saving and credit card account and just saw my electronic wallet with money. How can i cash those out from it and transfer back to my credit card account? please help. In fact, i dont know how to operation my electronic wallet.

This definitely sounds like a scam.

I am new to bitcoin and someone (the account manager) call me to buy and i made it last week

Bitcoin does not have 'account managers'. There is a well-known scam though, where the scammer will message/contact you pretending to be an investor/manager/miner/etc, offering amazing returns on your investment in BTC. If someone is offering large guaranteed profits, it is almost certainly a scam.

They said they have to make it to a mirror transaction first and then need to debit my credit card again

Bitcoin does not work this way, and neither do credit cards. There is no such thing as a bitcoin 'mirror transaction'. The scammer simply wants you to send them more money. Do not send them more money.

just saw my electronic wallet with money

This is part of the scam. The bitcoin blockchain is a public record, anyone can view and verify the apparent balance of an address, but only the person with the private keys for that address actually owns those coins (ie, can spend them). "Watch-only wallets" let you track the balance of any address of your choosing. The scammer will often show their victim a "watch-only" wallet to trick the victim into thinking they own that bitcoin. They do not own that bitcoin. The scammer may not even own that bitcoin. It is a mirage.
Also, there are no fees related in obtaining private keys. That is another tactic used by the scammers (eg. "please pay us a fee so that we can activate the private key").

How can i cash those out from it and transfer back to my credit card account? please help.

Your money is likely gone. You can report the crime to the relevant authorities if you so desire.

In fact, i dont know how to operation my electronic wallet.

Bitcoin is a really interesting and revolutionary thing, but you should take some time to learn about it before you start investing in it. This question is a good place to start: I am new to Bitcoin, how can I get started?


Question about getblocktemplate I'm having trouble understanding getblocktemplate.

From https://en.bitcoin.it/wiki/Getblocktemplate,

I see how to build the block header and then begin hashing by incrementing the nonce, the same as I would perform work on the result of a getwork call.

What I don't understand is the following

  Since you're making all the blocks yourself, you really don't ever need to get another template... until it's invalid.

After I construct my merkle root and then my block header, and hash away by incrementing the nonce, then what? How do I "create" a block? Surely I will overflow the nonce quickly with an ASIC - so what else am I varying while hashing?

I feel like I am missing a very important step.

Thanks in advance!

Once a client has the template it can modify it to make the header different, giving you a new nonce range to search. In modern miners this happens thousands or tens of thousands of times a second.

The timestamp in the header can be updated if needed, this is known in old software as nRollTime. This method is generally not used anymore because you only get one new range per second.
The "extraNonce" can be updated, the random data in the coinbase transaction is altered and the merkle tree is re-hashed up to the root, which changes the header. This technique is used by Stratum miners as well.
Transactions can be added or removed from the tree.

GBT and Stratum are distinct from an old system called GetWork which simply gave out just a partially hashed header, every time the nonce range was exhausted the client would need to make a new request to the server they were mining from. This is what your quote is alluding to.


How do you configure the Antminer S1 to mine Dash? Does someone mine Dash with an Antminer S1? How do you configure it? What pools can I use?

The Antminer S1 produces SHA-256d hashes, but Dash uses the X11 hashing algorithm for its proof of work. The Antminer S1 cannot be used to mine Dash.


The probability of block generation by two miners in a special case? If network would include 2 mining pools (pool_1 and pool_2) with the hashpower of 49% and 51%,respectively, then wo want to calculate the probability that in 10 minutes, exactly 2 blocks would be generated such that two blocks are not generated at the same time and the first block is generated by pool_1 with hashpower of 49% and second block is generated by pool_2 with hashpower of 51% ?

(1) It is important for us to know which pool generates the first block and which one generates the second block, so, we want to know the probability that the first block is generated by which pool (regarding to their hashpower)

(2) we assume that pool_2 is honest and pool_1 is selfish
and

(3) We know that Bitcoin network on average generates one block per 10 minutes.)

(According to solution that is proposed by Murch here : How can we be sure that a new block will be found?)

Thanks

In your example the two pools have very similar hash power, so for simplicity let's assume they are both exactly 50%.  The difference between 49%, 50%, and 51% will not significantly affect  the answers.

The probability that the first pool finds at least one block in 10 minutes is roughly 1 - exp(-1/2), about 39%, and the same for the second pool.  The two pools operate independently, so the probability that both events happen is simply the product of their probabilities, i.e. (1 - exp(-1/2))^2, which is about 15.5%.  By symmetry, it's about equally likely for either pool to find the first block.  So the probability that this happens and moreover Pool 1 finds the first block, is half of this: 7.75%.


How can I fix this: (Non-canonical signature: S value is unnecessarily high) I've written a small script that will create a bitcoin transaction from scratch, using an ECDSA library. It works, but sometimes I get this error:

64: non-mandatory-script-verify-flag (Non-canonical signature: S value is unnecessarily high)

I found this reply answer on bitcoin talk:

  The signature is composed of two values, the r value and the s value.
  In your third input, the s value is greater than N/2, which is not
  allowed.  Just add in some code that if s is greater than N/2, then s
  = N - s.

But what exactly is N?

It seems as though N is the order of the elliptic curve.

Or in other words, the number of possible points on the secp256k1 curve.

N = 115792089237316195423570985008687907852837564279074904382605163141518161494337


Asic Miners adding up? If you were to get multiple miners that do 7.3TH/s do they add up. for example if i had 3 of them would it give me 21.9TH/s? Also What is the coversion rate for TH like how much is 1TH worth in usd?

Possible duplicate:- Does mining power of different miners add up in mining pools?

Mining is a lottery, not a race.

The fastest miner doesn't always win. In general, if you have X% of the hashrate, you will find X% of the blocks.

This is because not just all pools, but every every, every chip, ... is attempting to solve a different block proposal. Every attempt has an independent chance of winning. There are an infinite number of potentially valid blocks, but they're still only a tiny fraction of all possible blocks. Everyone is not trying to find the next block - they're trying to find a next block.

So:

Can I add up my hashpower and make it work like a single processor of 1000H/s

Yes. You can't distinguish the different processors - more hashpower just tries more block proposals at the same time.

Both both miners would be acting independently?

Yes. Everything always acts independently.

So this means a mining pool has combined power of all the associated miners and working on one block?

Yes.

All miner are working on different block of their own ??

Yes.


Spend BTCs from a paper wallet So, I want to create a cold storage bitcoin address to store incoming BTCs from donations and payments (I'm a freelance developer so I'm getting used being payed with BTC). Since this address has to be spread among lots of different people, I can't change it so frequently, it's like my gpg public key, it would be a pain to change this address.

This means that I need a way to spend the BTCs stored on my paper wallet in a safe but fast way. The most obvious solution is using the Blockchain.info app, scanning the private key when required (I do not care about privacy in that case, I know I can be traced and such, but I'm ok that change goes back to the same paper wallet).

My question is, how much should I be worried about my private key being compromised by scanning it with my phone? Are there any known reports about this happening? Are there same safe ROMs that could prevent this?

If this is a serious concern, how can I spend the BTCs on my paper wallet in a same way whitout changing the public address everytime?

The Blockchain.info Android Wallet app is open-source and has been heavily peer-reviewed by the community. Your private key is stored on the device once scanned, but it is encrypted with a password so even if you lose your phone they won't be able to access the key.

As for the using safe ROMs, Android is a very secure sandboxed virtual machine that has been rarely compromised. The encryption of your keys is based on powerful and heavily tested Java libraries which run on an open-source platform called Dalvik, which is based on the Java Virtual Machine (JVM).

In other words, you really couldn't ask for a more secure environment.


Bitcoin information data protocol Obviously for the Bitcoin system to work, we need an information network on a global scale such as the Internet.

I am sorry if this is a stupid question.

What exact information protocol is being used? Obviously something that sits on top of TCP/IP, but what exactly?

It is these first levels of software that on top of TCP/IP that I am interested...

Bitcoin uses its own wire protocol, which is based on TCP. It's quite simple, with each packet type having strict rules for conformity and a checksum. New objects (transactions and blocks) are flooded through the network to all peers with a flag indicating they want that information, along with auxiliary messages like peer addresses and pings. No encryption is used for any connection.

https://bitcoin.org/en/developer-reference#p2p-network


How to use BIP39 test vectors? On the page of BIP39 specs there's test vector array from Trezor link. It looks like this:

["ffffffffffffffffffffffffffffffff",

 "zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong",

 "ac27495480225222079d7be181583751e86f571027b0497b5b5d11218e0a8a13332572917f0f8e5a589620c6f15b11c61dee327651a14c34e18231052e48c069",

 "xprv9s21ZrQH143K2V4oox4M8Zmhi2Fjx5XK4Lf7GKRvPSgydU3mjZuKGCTg7UPiBUD7ydVPvSLtg9hjp7MQTYsW67rZHAXeccqYqrsx8LcXnyd"
],

When I try to use any of these mnemonic phrases I can't get matching xpriv... form any of these samples using Bip39 JS lib.

For example:

const MNEMONIC = "zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo zoo wrong";
const seed = Bip39.mnemonicToSeed(MNEMONIC);
console.log("Seed =", seed.toString("hex"));

const rootNode = Bip32.fromSeed(seed, Bitcoin.networks.bitcoin);
console.log("Bip32 Root key =", rootNode.toBase58());

returns totally different results

Seed = b6a6d8921942dd9806607ebc2750416b289adea669198769f2e15ed926c3aa92bf88ece232317b4ea463e84b0fcd3b53577812ee449ccc448eb45e6f544e25b6
Bip32 Root key = xprv9s21ZrQH143K2PfMvkNViFc1fgumGqBew45JD8SxA59Jc5M66n3diqb92JjvaR61zT9P89Grys12kdtV4EFVo6tMwER7U2hcUmZ9VfMYPLC

How can I get these c5525... and xpriv... and what is it exactly?

UPDATE:

as user3074620 suggested, I tried to use 'TREZOR' password, as it's works!

here's code to play someone is interested.

You must add 'TREZOR' to your second line:

const seed = Bip39.mnemonicToSeed(MNEMONIC, 'TREZOR');

Then it should work.

You can see this in the BIP39 test cases in the BitcoinJS repo:

https://github.com/bitcoinjs/bip39/blob/4fce199e73f7ab68bdf9f7382dc10f7e1adaa499/test/index.js#L13-L33

function testVector (description, wordlist, password, v, i) {
  var ventropy = v[0]
  var vmnemonic = v[1]
  var vseedHex = v[2]

  test('for ' + description + '(' + i + '), ' + ventropy, function (t) {
    t.plan(5)

    t.equal(bip39.mnemonicToEntropy(vmnemonic, wordlist), ventropy, 'mnemonicToEntropy returns ' + ventropy.slice(0, 40) + '...')
    t.equal(bip39.mnemonicToSeedHex(vmnemonic, password), vseedHex, 'mnemonicToSeedHex returns ' + vseedHex.slice(0, 40) + '...')
    t.equal(bip39.entropyToMnemonic(ventropy, wordlist), vmnemonic, 'entropyToMnemonic returns ' + vmnemonic.slice(0, 40) + '...')

    function rng () { return Buffer.from(ventropy, 'hex') }
    t.equal(bip39.generateMnemonic(undefined, rng, wordlist), vmnemonic, 'generateMnemonic returns RNG entropy unmodified')
    t.equal(bip39.validateMnemonic(vmnemonic, wordlist), true, 'validateMnemonic returns true')
  })
}

vectors.english.forEach(function (v, i) { testVector('English', undefined, 'TREZOR', v, i) })
vectors.japanese.forEach(function (v, i) { testVector('Japanese', WORDLISTS.japanese, '㍍ガバヴァぱばぐゞちぢ十人十色', v, i) })
vectors.custom.forEach(function (v, i) { testVector('Custom', WORDLISTS.custom, undefined, v, i) })


Bitcoin Transfer Not Done I send 0.043 bitcoin to the 1Fhpf5bA95zBPzsPezozDYf9h2jCYD31TA address. But it didn't reach to this address. When I click the address on TX page you can view the pic that Sent : 0 BTC
What's the problem? Thanks.

Just wait for the 6 confirmations. It looks like it is there: https://blockstream.info/address/1Fhpf5bA95zBPzsPezozDYf9h2jCYD31TA
Just a bit patience.


How safe is it to use a Linux live CD to access my savings wallet? It's clearly safe to create a savings wallet offline with a live CD, as no data can be sent to an attacker even if the live CD image is compromised (which seems unlikely).

However, when it comes to sending a transaction from a savings wallet, the client must be connected to the internet, so the risk increases. If you create a live linux CD, with an OS such as Ubuntu, it is out of date within a fairly short time of it being created as the live CD does not receive the latest patches that a permanent installation normally receives.

Presumably this means there's a chance (however small) that when you use the live CD and connect to the internet a security hole will exist that can be exploited to steal your wallet and wallet passphrase next time you enter it. How big is this risk? (Am I just being totally paranoid?!)

The severity of the risk is obviously a difficult thing to determine in the context of all possible live CDs, so perhaps a better question is this, if the first one is too difficult: have there previously been any security holes in live CD releases that allow an attacker to remotely control the computer?

Security is always an issue and complex systems like operating systems are prone to attacks. However, it is possible to use an offline machine to create the signed transactions and then export them to another machine.

For example a soft copy of those signed transactions could be copied on to a fresh USB stick, or printed out on paper as plain text or QR codes and so on. These transactions could then be imported into an online Bitcoin client that does not have the private keys, but can just transmit the transactions to the network.

Your private keys are always held offline and thus only exposed to physical attack vectors which should be sufficient to relieve your concerns.


How to specify testnet via curl against json-rpc? The testnet=1 option can be (not) specified in the bitcoin.conf file (thus causing it to be on mainnet by default), and this can be over-ridden in bitcoin-cli with the -testnet command-line option.

But, when using the json-rpc interface via curl, I can't figure out how to specify I want testnet in this case. I can put the testnet port 18332 in the url, but I don't know how to use any other "command line" switches when using curl?

Can I do it with curl?

The port 18332 is the specification you speak of.
When the testnet bitcoind is running on your system, port 18332 is open to accept rpc's. In case of mainnet, that port changes to 8332.

Every thing that you can do from the commandline is accessible via curl on that port.


How to generate a native Segwit address and P2SH Segwit address from a standard WIF? Can I have the steps to generate a native Segwit address from a standard WIF? And the steps to generate a P2SH Segwit address from the same WIF?

How do these two formats differ and why are there two? I've seen that the P2SH version is compatible with older clients, are native Segwit addresses not?

wif -> private key

Use base58-decode to convert the base58 string to bytes
Strip the first byte (network byte) and the last 4 bytes (checksum). The remainder is the key
Verify that the first 4 bytes of the sha256(sha256(network byte || key)) are equal to the checksum
If the key ends with 0x01 (compressed) remove the last byte. You are left with the private key

  private key -> public key

Cast the private key as an integer
Multiply with the secp256k1 generator point to get a Point(x,y) on the curve. This is your public key
Encode your public key in a compressed format. Byte 0x03 (if y is odd) or 0x02 (if y even) followed by x as 256-bit integer

  Public key -> P2WPKH address

Create the witness program = ripemd160(sha256(public key))
Encode into bech32 by providing the witness program, bc as the human readable part and 0 as witness version

  Public key -> P2SH-P2WPKH address

Create the witness program = ripemd160(sha256(public key))
Create the redeem script = 0x0014<witness program> = witness version + push20 + witness program
Calculate the hash160 = ripemd160(sha256(script))
Prepend the hash with the version byte 0x05
Calculate the checksum = sha256(sha256(version byte || scripthash ))
Base58-encode(version byte || scripthash || first 4 bytes of checksum)

  How do these two formats differ and why are there two? I've seen that
  the P2SH version is compatible with older clients, are native Segwit
  addresses not?

Old clients cannot send to segwit addresses but they can send to P2SH addresses and by extension to P2SH-P2WPKH


Why are my profitability calculations for Litecoin mining with an Antminer off the chart? Not exactly a Bitcoin question but it's about mining.

I wanted to step into crypto mining, but on a rather low budget. Unfortunately, it is hard to start with Bitcoin when you have a low budget, so I thought about going into Litecoin mining.

I looked up the current exchange rate, the current difficulty and found an affordable S5 Miner with 1155GH for about 250Euro. To calculate the expected reward I used the bitcoinwisdom.com calculator, who told me, with the current exchange rate and difficulty I could mine 46340USD a day, the calculator at litecoinpool.org said it's 23753.54USD a day.

Even though those number are completely different, I cannot trust any of them. What am I calculating wrong?

Thanks in advance!

The Antminer S5 mines SHA-256d hashes as used by Bitcoin.

However, Litecoin uses Scrypt as its hashing algorithm instead of SHA-256d. That means that the S5 cannot be used to mine Litecoin and the numbers are not comparable.


How i can create new wallet I want to create new own wallet without using ready wallet. But there are random generator that create random number and then private key builds from it. How I can realize that there is no two equal private key in the world?

If I was writing wallet software I would use BIP 39 for generating private keys from seed phrases.

Generally I would use standard algorithms (as defined in the BIPs) and standard libraries rather than invent my own.

You avoid generating duplicate keys by using sufficient numbers of words from carefully prepared lists of words and using publicly vetted algorithms carefully designed for the purpose. For example hashing algorithms are designed to minimise the chance of "collisions" (two different sources producing same result).

Choosing a large number of seed words using a properly initialized random number generator should minimise the chances of two users generating the same seed phrase.


Why is Ethereum total network hashrate still increasing if there are no GPUS to buy? The total Ethereum network hashrate is close to doubling relative to its December level. Mining difficulty is also increasing proportionally of course as the total reward per block stays the same.

However, it is impossible to buy new GPUs in large quantity anywhere. So, where does the computational power comes from? I can't believe that there was enough capacity used to mine other coins to double the ethereum global hashrate, but I may be wrong. So, where do all the new mining rigs get their power from?

People who already owned GPU before Ethereum became popular are joining mining now.
People with piles of money (companies mostly) buy GPUs directly from manufacturer or big seller (that's why GPU's don't reach retail markets mostly)


Why is the supply of Bitcoin not pegged to its demand? If it's supposed to be a decentralized currency, then why is it set to be capped at 21 million? What if that demand for Bitcoins exceeds 21 million but all of them are already purchased? Wouldn't it make more sense to peg the amount of Bitcoins to the Bitcoin's "GDP," that way the money supply would grow and shrink according to the total demand?

GDP (and most other stats you would think to use for this) can't be accurately determined by the network without trusting someone. The network can only see the movement of BTC; it has no information about non-BTC currencies, goods, or services. For GDP, some centralized organization would need to figure out the the real amount of spending in the BTC economy. The network can't just look at the total BTC transaction volume to figure this out, since someone could send BTC to himself in an undetectable way in order to inflate the volume stat.

One of Bitcoin's primary goals is to be decentralized, so it can't rely on a central authority. Therefore, the money supply needs to be set according to some algorithm that looks only at raw Bitcoin transactions and blocks. Satoshi chose to make the supply asymptotic because he thought that this was basically how gold worked, and gold has thousands of years of history as good money.

By the way, GDP would be a poor statistic to use for determining the demand for BTC. You'd want to use the price of BTC relative to a currency or good. If it could be done without changing any of Bitcoin's other excellent properties, I think that Bitcoin would be better if 1 BTC was guaranteed to buy you 1 oz of silver. But this is probably impossible for any decentralized currency that's even remotely similar to Bitcoin.


Were one or more machines required to be running 24/7 on the network after the first block was mined? After mining the genesis block, did Satochi have to leave his computer running to mine the subsequente empty blocks?

Was he running the whole network on a single node or did he require multiple nodes to test the transaction verifications?

What would happen if at some point all nodes were off and no transactions or blocks were being generated?

At some point the whole net work were probably a couple of personal computers. Did they run 24/7?

After mining the genesis block, did Satochi have to leave his computer running to mine the subsequente empty blocks?

You can be sure that he had to leave his computer for a while because the hash of the genesis block did already start with 10 zeros. That's a lot for an average computer.

  Was he running the whole network on a single node or did he require multiple nodes to test the transaction verifications?

I think, it's obvious that he wanted to test his own idea in a "almost real scenario" and so I think that he used more than 1 node.

  What would happen if at some point all nodes were off and no transactions or blocks were being generated?

Nothing happens. The nodes do this have the blockchain(s) in their memory. That Satoshi could not make transactions but the transaction history was still there.

  At some point the whole net work were probably a couple of personal computers. Did they run 24/7?

Probably a couple of them did do that to experiment.

But: We don't even know who Satoshi Nakamoto is. So we do also not know how he did it exactly.


I want my website to accept bitcoins without dealing with security issues I want my site to accept bitcoins (and automatically reward users with it), but do not want to deal with the security issues that would entail.
Is there a SaaS (Software as a Service) which could handle all the hassle for me?

I would suggest integrating https://bitpay.com/
They charge you like any other service but they do all the payment stuff. Also they have plugins for most open source shopping carts Bitpay plugins
Also keep you wallet offline to avoid problems.


If I wanted to print my bitcoins? Suppose I wanted to print my bitcoins to paper for safekeeping.  It would be impossible for a hacker to get at my computer.  To do so I need to know where to find the private keys.  Is there only one private key and many public keys?   Does it make sense to carry a printed bitcoin in my pocket and type it in someplace else?  Your thoughts on this matter, please.

There are many pairs of private-public keys. The usual wallet.dat starts with 100 keypairs, although usually you use only a few. To get your keys you can use Pywallet. Then you can print them as they are, or as QR codes.

You should note however, you are not printing Bitcoins, but the keys you use to get to them. This is more like printing username and password to your paypal account, rather than printing money.

Carrying your printed keys is only useful if you intend on paying with them (and only as much as you need in case you loose your printed key). As not many people accept Bitcoins nowadays, it is not too useful.


Do all UTXO get moved to the newest change address? There is one thing I do not understand about unspent outputs and change addresses. For example, let's say a person has 5BTC in a wallet, and they have 2 unspent outputs of 3BTC and 2BTC.

They one day need to pay 2.5BTC for something. I know about the coin selection algorithm but lets just say the Bitcoin wallet select 2.5BTC out of the 3btc unspent output. This would leave 0.5BTC to send to the change address.

Now here is my question. Let's say they make the change address to a new wallet. Will the new wallet have 0.5BTC and the old wallet have 2BTC or will the new wallet have 2.5BTC and the old wallet 0BTC

Basically the 2BTC unspent output that was never touched, does it go with the change address or does it stay in the old wallet?

If you send 2.5 BTC to one address and 0.5 BTC to another wallet, that is a transaction with two recipients. Change addresses are new addresses in the same wallet.

If the 3BTC UTXO were selected, there would be no reason for the 2BTC UTXO to move. If you want to move all your money to the new wallet, send 2.5BTC to the recipient and the remaining money to your new wallet.

If you want to find out more about the Coinselection Algorithm check out What is the coin selection algorithm?.


Faking blockchain data in bitcoin-core Let's say I found a tarball with blockchain data files which I load to my datadir and start my Bitcoin Core client, what sort of attacks am I vulnerable to? Could the files contain fake balances? If yes, what will happen if another peer requests a block which has altered data in it, how will that other peer handle this situation?

Let's say I found a tarball with blockchain data files which I load to my datadir and start my Bitcoin Core client, what sort of attacks am I vulnerable to? Could the files contain fake balances?

It depends. If you're just importing blocks (so no chainstate/ subdirectory with UTXO set), there should not be any possible attack. The client will validate those blocks at startup time, just as if they were being received from the network, to rebuild the chainstate. If one of the blocks was modified, it would be rejected as an invalid block at this time, and the correct blocks would be requested from the network instead.

However, if you accept a chainstate from someone, anything is possible. They can convince you they have unlimited amounts of money, or convince you they have paid you in the past. For any future transactions relying on such faked funds, getting to confirm them would require cooperation from a miner that is willing to build an invalid chain to defraud you (or others, in case many people used that chainstate "backup").

  If yes, what will happen if another peer requests a block which has altered data in it, how will that other peer handle this situation?

Blocks can't be altered without invalidating them, so other peers downloading blocks from you can't be affected. Similarly, a -reindex would fix any problems for yourself as well.


Clightning with BTCpay server failed I have setup WooCommerce and BTCpayserver in Google cloud, and synced. Test to buy with BTC seems to work.

Adding Lightning fails:
I modified in BTCpay Lightning nodes in the Store management
"clicking here" added the connection string:

Type=clightning;server=unix://etc/lightning_bitcoin/lightning-rpc

I submit and came back to test connection, it fails:

Error: Error while connecting to the lightning node via 34.73.111.47:9735 (The operation was canceled.)operation was canceled.)

I used during setup the following Exports:

 export BTCPAY_HOST="btcpay.elmit.com"
 export NBITCOIN_NETWORK="mainnet"
 export BTCPAYGEN_CRYPTO1="btc"
 export BTCPAYGEN_REVERSEPROXY="nginx"
 export BTCPAYGEN_LIGHTNING="clightning"
 export BTCPAYGEN_ADDITIONAL_FRAGMENTS="opt-save-storage-xs;opt-save-memory"
 export BTCPAYGEN_ADDITIONAL_FRAGMENTS="$BTCPAYGEN_ADDITIONAL_FRAGMENTS;opt-add-woocommerce"
 export WOOCOMMERCE_HOST="store.elmit.com"

Did I miss something?

I found it. The port 9735 is not open to the public.

Go to google cloud console

Home -> VPC network -> Firewall rules

+ Create firewall rule:

Name      Type    Targets   Filters          Protocols / ports  Action  Priority    Network
lightning Ingress Apply to all  IP ranges: 0.0.0.0/0 tcp:9735       Allow   1000        default