Transaction unconfirmed for 5 days, and I don't think the fee is the problem? I sent a transaction of ~0.408 BTC February 20th through Electrum and my transaction is still showing up as unconfirmed. I also cannot resend my transaction through Electrum as the coins are still unconfirmed. Here is my Tx on the Blockchain

https://blockchain.info/tx/0a33becac294dd987f2374f3fcbba2b4a37cbca6807e8296e2d439f919cafe36

I included a fee as well. Any idea whats wrong or how I can retrieve my Bitcoins?

The fee you have set leads a "fee per byte" value of ~20 satoshi/byte, as you can see on the blockchain.info. It's too small currently, as transactions with fees lesser than 60 sat/B doesn't seem to be trusted to clear right now, as you may see here: bitcoinfees.21.co. I could help you with clearing it, but I'm pretty sure the thread about it already exists here. The problem is likely solvable, good luck.


Calculating the witness size of a transaction I want to calculate how many % of a block, and thus, transactions that are witness data. I need to calculate the size of the witness data in bytes in every transaction. And as I understand it, I cannot calculate this using existing size variables like vsize.

Will a loop through the "txinwitness" array of hex and do a byte length calculation on every one be enough? (Using NodeJS here)

Buffer.byteLength('03fbcc1c24903bc2fb1d73czef518b859232341c39e4515367653d80536d587b62d6', 'hex');

Will a loop through the "txinwitness" array of hex and do a byte length calculation on every one be enough?

That is not enough as there are extra data in witnesses that is not included in the txinwitness.

You can get the number of witness bytes and the number of non-witness bytes by solving a system of equations. The getrawtransaction RPC gives you two fields, size and weight. size is the total size in bytes as received over the wire. weight is the weight of the transaction as defined by BIP 141.

If you let x be the number of non-witness bytes, and y be the number of witness bytes, the definitions of size and weight gives you:

4x + 1y = weight
x + y = size

By plugging in the weight and size from the RPC, you can solve the system of equations for x and y to get the number of non-witness bytes and number of witness bytes respectively.


How does lnd make sure it does not reuse the same route twice for a retry after the first payment failed? Suppose LND node A wants to send a payment to another node D. The pathfind algorithm based on Dijkstra found a route through B and C and initiates the payment. It fails, as B -> C does not have sufficient balance/bandwidth.

Will LND just fail the payment or try another time with a different route? How does it remember the failed route?

Follow-up question: Can node A figure out, which edge failed?

Edit:
To be more clear, in my example, all channels have 0.5BTC as capacity, and all of them have an equal balance distribution of this capacity (0.25, 0.25), except for B -> C, which has (0, 0.5), so B currently cannot send any payments to C.

The balance state (here: (0, 0.5)) is private, but the capacity of all channels is public.

As the routing computation is done in A (source routing), the algorithm initially has no knowledge of the balances. If A just wants to send 0.001BTC, the routing algorithm will find the route, but it cannot reach the target.

So I went ahead and looked at the LND implementation here: https://github.com/lightningnetwork/lnd/blob/master/routing/pathfind.go and this is the comment block above the function findPath:

  findPath attempts to find a path from the source node within the ChannelGraph to the target node that's capable of supporting a payment of amt value. The current approach implemented is modified version of Dijkstra's algorithm to find a single shortest path between the source node and the destination. The distance metric used for edges is related to the time-lock+fee costs along a particular edge. If a path is found, this function returns a slice of ChannelHop structs which encoded the chosen path from the target to the source. The search is performed backwards from
  destination node back to source. This is to properly accumulate fees that need to be paid along the path and accurately check the amount to forward at every node against the available bandwidth.

If this is the case then I don't think your scenario would play out. It appears LND wouldn't return the path A --> B --> C --> D because it does not have sufficient balance/bandwidth.


Computing the bitcoins of any address What is the procedure to calculate the bitcoins owned by any address X?

do we have to search for every transaction in every block in the block chain, with recipient as X? But this will not give correct result, as X might have spend some amount? How is this recorded>?

Recall that transactions have inputs and outputs: when an output is listed as the input of another transaction, that output is spent.

So you go through the block chain from the beginning and make an index of unspent outputs.  For each transaction output you see, you add it to the index; for each input you see, you delete the corresponding output from the index, because it has been spent.

When you have an index of all unspent outputs, you look for those whose recipient is the address X.  Adding up the amounts of all those outputs gives you the "balance" of Bitcoins available to address X.


Need help recovering lost bitcoins from a crashed computer's wallet file Hi so a few years back I purchased 25 bitcoins, after I purchased them I placed them in a wallet, my computer crashed and I got a new one forgetting about the bitcoins, now seeing the high price for the coins I want to know if there is any way to recover them or if they are lost forever.

Is there anyway I could find the wallet I used?

Well, if you do not know the name and dont have your history from that device, your screwed.

  I want to know if there is any way to recover them or if they are lost forever.

Well, from what I have seen of this post, you do not have any information of the wallet whatsoever, you may have lost them forever if you dont have a backup.

However, if you have any of your old computers files, we may be able to recover it. If not, sorry mate.


Up to date list of exchanges that have been hacked? One key detail I'd like to consider when reviewing which exchange to do trading on, is how often, and recently have they been hacked?

I can see lots of random posts about this of course for various exchanges, but would love to find a chart that lists this type of information, with up to date information.

There are a few sources I found but obviously are not completely up to date or don't have the full history, as you probably found. Some great sources for the overall history of Bitcoin and hacks are:

historyofbitcoin.org
fastcompany.com
theguardian.com

Now, for the moment we've all been waiting for.... This source (bravenewcoin.com) I believe gives the best overview and history of all the hacks and even additional information, from 2007 to 2017.

Keep in mind the I posted the other sources above because it's always good to fact check, and each source has some different information.

And sadly, I do not believe that they have a chart or document listing who, when, and how much Bitcoin as hacked from exchanges... yet. I'd also ask around on bitcointalk.org, someone on there might have one or etc.

Happy Bitcoining


What will happen on November 15th 2017, when the Segwit proposal expires? The time duration for the BIP-148 UASF is from August 1st to November 15th. During this time, the BIP-148 nodes will reject blocks that do not signal for Segwit.

Now, after Nov. 15th, even the BIP-148 nodes would start accepting all the blocks, whether they signal for Segwit or not. So, just after Nov. 15th, what would happen:

Case I: If the BIP-148 block chain is longer than the Legacy block chain?
(My understanding is, this won't even happen. Because if the BIP-148 network hash rate gets higher than that of the Legacy network, the Legacy block chain will always be "in sync" with the BIP-148 block chain, and the two block chains will be exactly the same. Am I correct?)

Case II: If the Legacy block chain is longer than the BIP-148 block chain?
(Now, after Nov 15th, the BIP-148 nodes start accepting all the blocks. The next solved block will most probably be a Legacy block. So, will the BIP-148 nodes switch to the "longer chain" [which is the Legacy chain], and discard all the blocks since the fork happened?)

Case I: If the BIP-148 block chain is longer than the Legacy block chain?
  (My understanding is, this won't even happen. Because if the BIP-148 network hash rate gets higher than that of the Legacy network, the Legacy block chain will always be "in sync" with the BIP-148 block chain, and the two block chains will be exactly the same. Am I correct?)

That is correct. In this case, there is only one blockchain and that is the BIP 148 chain. Since the BIP 148 chain is valid under the non BIP 148 rules, if it is longer, it will be the accepted blockchain.

  Case II: If the Legacy block chain is longer than the BIP-148 block chain?
  (Now, after Nov 15th, the BIP-148 nodes start accepting all the blocks. The next solved block will most probably be a Legacy block. So, will the BIP-148 nodes switch to the "longer chain" [which is the Legacy chain], and discard all the blocks since the fork happened?)

No. BIP 148 nodes will continue to follow their own chain and not switch to the legacy chain. This is because blocks between August 1st and November 15th in the legacy chain do not follow the BIP 148 consensus rules. Those rules specify that all blocks between August 1st and November 15th must signal for segwit.


Best OS for cold storage I want an OS which can be easily disconnected from all hard drives (just uses USB) and can be booted from usb stick, also secure enough and disconnected from internet by default (or something I can easily disconnect from Internet forever).

Use TAILS Linux. From the website:

  Tails is a live operating system that you can start on almost any computer from a USB stick or a DVD.

  It aims at preserving your privacy and anonymity, and helps you to:

  use the Internet anonymously and circumvent censorship;
  all connections to the Internet are forced to go through the Tor network;
  leave no trace on the computer you are using unless you ask it explicitly;
  use state-of-the-art cryptographic tools to encrypt your files, emails and instant messaging.

Even Edward Snowden uses it.


`createpsbt` RPC call doesn't provide PSBT inputs & outputs I'm attempting to create a PSBT using RPC:

bitcoin-cli createpsbt [[{"txid": "1d76879500aecafde541770b5d44ccec5955b4c1a455fae446bf1df7b5ea43e9", "vout": 0}, {"txid": "e5a8dfa9459ac154fe62652e1d43049dae13f11815da36cc32881e27917a0dff", "vout": 1}], [{"bcrt1qnv3tl3z9cll9faqf79ppfn3rrp7pn9wwmq04p5gqgqtxg55xfxuslkyk94": "0.20000000"}, {"bcrt1qa4h6amsgyc878k094grqh6ktmgvp97dt6et9cy5hjmyxlgd9q63q3p6hch": "1.79900000"}], 0, true]

This is the PSBT I receive in return:

cHNidP8BALICAAAAAulD6rX3Hb9G5PpVpMG0VVnszERdC3dB5f3KrgCVh3YdAAAAAAD9/////w16kSceiDLMNtoVGPETrp0EQx0uZWL+VMGaRanfqOUBAAAAAP3///8CAC0xAQAAAAAiACCbIr/ERcf+VPQJ8UIUziMYfBmVztgfUNEAQBZkUoZJuWAOuQoAAAAAIgAg7W+u7ggmD+PZ5aoGC+rL2hgS+avWVlwSl5bIb6GlBqIAAAAAAAAAAAA=

When decoded, the inputs and outputs sections of the PSBT are empty. Why is this? Bitcoin Core should know everything necessary to fill these sections out. Why doesn't it?

bitcoin-cli -regtest decode <psbt>
{'inputs': [{}, {}],
 'outputs': [{}, {}],
 'tx': {'hash': 'fd88b50ec52948dcf04b0d802000b325f960f3333cff8bf7a274273c9d7e2ed7',
        'locktime': 0,
        'size': 178,
        'txid': 'fd88b50ec52948dcf04b0d802000b325f960f3333cff8bf7a274273c9d7e2ed7',
        'version': 2,
        'vin': [{'scriptSig': {'asm': '', 'hex': ''},
                 'sequence': 4294967293,
                 'txid': '1d76879500aecafde541770b5d44ccec5955b4c1a455fae446bf1df7b5ea43e9',
                 'vout': 0},
                {'scriptSig': {'asm': '', 'hex': ''},
                 'sequence': 4294967293,
                 'txid': 'e5a8dfa9459ac154fe62652e1d43049dae13f11815da36cc32881e27917a0dff',
                 'vout': 1}],
        'vout': [{'n': 0,
                  'scriptPubKey': {'addresses': ['bcrt1qnv3tl3z9cll9faqf79ppfn3rrp7pn9wwmq04p5gqgqtxg55xfxuslkyk94'],
                                   'asm': '0 '
                                          '9b22bfc445c7fe54f409f14214ce23187c1995ced81f50d100401664528649b9',
                                   'hex': '00209b22bfc445c7fe54f409f14214ce23187c1995ced81f50d100401664528649b9',
                                   'reqSigs': 1,
                                   'type': 'witness_v0_scripthash'},
                  'value': Decimal('0.20000000')},
                 {'n': 1,
                  'scriptPubKey': {'addresses': ['bcrt1qa4h6amsgyc878k094grqh6ktmgvp97dt6et9cy5hjmyxlgd9q63q3p6hch'],
                                   'asm': '0 '
                                          'ed6faeee08260fe3d9e5aa060beacbda1812f9abd6565c129796c86fa1a506a2',
                                   'hex': '0020ed6faeee08260fe3d9e5aa060beacbda1812f9abd6565c129796c86fa1a506a2',
                                   'reqSigs': 1,
                                   'type': 'witness_v0_scripthash'},
                  'value': Decimal('1.79900000')}],
        'vsize': 178,
        'weight': 712},
 'unknown': {}}

It's not supposed to. createpsbt does not have access to the wallet so it cannot fill in any input or output information. If you want those to be filled in, you can use walletcreatefundedpsbt.


Pros and Cons between Ripple payment verification and centralized authority's payment verification I want to know the advantages and disadvantages between Ripple payment verification system and centralized authority's payment verification system.

A centralized payment verification system, like Paypal or any number of financial institutions, only considers payments "valid" if they come from within the organization. A single organization is responsible for verifying the truth of statements (with a statement being "Bob sent Alice $50" and the like). This means that there is no mechanism of agreement on transactions required.

By contrast, decentralized systems like Bitcoin, Ripple and Stellar all must come to agreement on which transactions are valid, without a centralized authority to confirm their truth. Proof-of-Work, Proof-of-Stake, Tendermint and SCP (Stellar Consensus Protocol) are each different solutions to this problem.

Pros of a centralized system:

No need for a mechanism of agreement, such as mining or consensus
Lower operational costs

Cons of a centralized system:

There is a single point of failure. If the central authority goes down or offline, the entire network is compromised.
Centralization can post ethical issues of who controls information and money.It opposes the ethos of a neutral net.
Creates a closed network, meaning that entities can only join the system with the consent of the centralized authority
May only serve the interest of the centralized authority.
Does not allow for p2p interaction/payments


RPC command sendfrom is giving Transaction too large error I made discord bot for fun with tips, soak and rains of altcoin. When I try to send large amount through the same bot. It is giving me "Transaction too large" error. I found the reason here: transaction creation failed

I need help with solving this issue. Can someone help me?

Thanks in advance

Transaction too large

This is referring to the transaction size in bytes, not Bitcoin.

You need to send the Bitcoin in smaller chunks to yourself, or sweep the dust, as they say. This is because a transaction is made up of unspent outputs (UTXO) and since you are sending a large amount, you will likely have many small UTXO from all of the tips you're trying to spend. This increases the size of the transaction in bytes.

Bitcoin core will return that error if the transaction weight is greater than MAX_STANDARD_TX_WEIGHT, which as of v0.16.3 is 400,000, which also happens to be the maximum size of 1 block.

What is tx weight?

  Transaction weight is defined as Base transaction size * 3 + Total
  transaction size (ie. the same method as calculating Block weight from
  Base size and Total size).

  Virtual transaction size is defined as Transaction weight / 4 (rounded
  up to the next integer).

  Base transaction size is the size of the transaction serialised with
  the witness data stripped.

  Total transaction size is the transaction size in bytes serialized as
  described in BIP144, including base data and witness data.  See BIP
  141


Double-signature paper wallets? I believe it's possible to send money to an address that requires two signatures to spend.  But I am trying to figure out how this can be done with paper wallets.

My understanding of multi-signature transactions: I can generate two keypairs, using two different machines and saving them in two different places.  Then funds could be transferred to the combined address, where they could only be unlocked by the presence of both private keys.

My question is, can this be done with ordinary paper wallets, such as from bitaddress.org?  Can I print a paper wallet, and have a friend also print a paper wallet, and then send money to the combined address so that both papers are required to redeem?  Is it as simple as that?  (If so, do any clients support this now?)

Or is there some additional software needed to create the combined address?  Can it be done without bringing the two private keys together?

This is basically correct. Your main challenge is that the current way to do multisig transactions references the public keys rather than just the addresses. Therefore when you generate the paper wallets, you need to take note of the public keys. Then you can input those into the bitcoin-qt console to generate the multisig address (there's a worked example by Gavin).

Note that using the funds in the multisig does not require the two private keys to exist together in the same machine, rather you just need to generate a signature using each (on separate machine).


Legal question regarding rippling balances between Ripple gateways Let's say a ripple user were to extend trust to both Bitstamp and Snapswap to owe him 100 USD. He offers to trade USD-Bitstamp-IOU for USD-Snapswap-IOU at an exchange rate of 1:1.

Would he have to register this activity with a USGov institution? Would taxes on this transactions be due?

What if he did the same with an exchange rate of 1:1.01 and vice versa, i.e. taking an exchange commission of 1%?

In the U.S., FinCEN has specific rules regarding money transmitter laws for those providing money services.  Users who simply patronize a money service are almost never considered money transmitters or providers of a money service.  So, in your example, the answer is likely to be no -- no, a withdrawal from one service and a deposit to another would not likely cause you to need to report the transaction to the government.

As far as taxes, that too is jurisdiction-specific.  In the U.S., capital gains taxes may apply however in your example there was no gain so there would then likely be no need to report the transaction on the tax forms.

Disclosure: I am not a tax advisor.


Is it possible to create an address from a predefined private key? I was not sure how to formulate the question title. What I want to achieve is the same as VanityGen and many other tools do to create an address starting with a predefined part, but with private keys.

So basically I want to create a Bitcoin public/private key pair of which the private key begins with a string I define.

Are there tools that already do this? If not, is it possible? How should it be done theoretically?

You can choose the private key to be whatever you want, and calculate the corresponding public key and bitcoin address.
Adding to this answer, there is really no reason to want to do this. But if one really insisted, here is a way to do it with hal. First start with generating a random private key
$ hal key generate
{
  "raw_private_key": "7019c07716861030e9334b88c24ee595b6fd922514a13de812e36cf6f910a898",
  "wif_private_key": "KzycuDEqJaMyjHWJDD9cdyPeH1rtCTgE5m1EHfCdnTs4ng2D43Bt",
  "public_key": "02260106e42d7aef51b92c6c4aa2d0a5a6f3e0c6ad68ee9fadd8bd50d8cbe1a0b4",
  "uncompressed_public_key": "04260106e42d7aef51b92c6c4aa2d0a5a6f3e0c6ad68ee9fadd8bd50d8cbe1a0b4349d9106ee1724cf51c954e6aec9522febd7fcb46d7248a0ce390810fc0ac6a0",
  "addresses": {
    "p2pkh": "1J6wqBd7QVGt7vGCNfUShoDEwQg2LFTgRR",
    "p2wpkh": "bc1qhwvl6yyrtheep7rmsxmf536m45dzfz4wrxdacu",
    "p2shwpkh": "3QLdovvKokkyiyX3jTzgfaMCv9MiaoVW5C"
  }
}%

Then change the beginning of the raw private key to deadbeef or whatever you want
7019c07716861030e9334b88c24ee595b6fd922514a13de812e36cf6f910a898
->
deadbeef16861030e9334b88c24ee595b6fd922514a13de812e36cf6f910a898

Then get the address for it
$ hal key inspect deadbeef16861030e9334b88c24ee595b6fd922514a13de812e36cf6f910a898
{
  "raw_private_key": "deadbeef16861030e9334b88c24ee595b6fd922514a13de812e36cf6f910a898",
  "public_key": "02de9367c92d7a42953e1afdf74d509d3992ba78bfb93f448859a1557e2685ca60",
  "uncompressed_public_key": "04de9367c92d7a42953e1afdf74d509d3992ba78bfb93f448859a1557e2685ca60b142aa0a4f495e16f80f811ec4556e3d33be28c930fab6e6a051e9a5bdc91d52",
  "addresses": {
    "p2pkh": "1BhftRM4fNZRYdDYMUdujq9C84bRX84Qf8",
    "p2wpkh": "bc1qw439kmezxvdff0hnalmeqvfsnttd9gkjux5rct",
    "p2shwpkh": "34KVR36eoQrf48bmjQ46JU5dGVg1gqdUFg"
  }
}%


How can I measure the total hashing power of the Bitcoin network? Is there a way to measure what is the total hashing power of the Bitcoin network at a given time? For pooled mining it isn't a problem - one can rely on statistics provided by the pool (assuming one can trust them), but what about people solo-mining?

Network hashrate calculated using formula: H ~= h / t , where t is time that took to find X number of blocks and h is approximate number of hashes it should have taken to solve X number of blocks, h = X * (D * 2**256 / (0xffff * 2**208)) Wiki:Difficulty

Bitcoin network hashrate stats available at bitcoinwatch.com and bitcoincharts.com .


How Bitcoin avoids double spending? If someone is sending bitcoin with low transaction fees and then sends the same bitcoin with higher transaction fees before the previous one is confirmed, so it is obvious that miners will pick the second one, so ethereum has nonce value of each transaction which avoids this, but how does bitcoin avoid it?

If someone is sending bitcoin with low transaction fees and then sends the same bitcoin with higher transaction fees before the previous one is confirmed, so it is obvious that miners will pick the second one

By default, the miner won't pick the second one, except the previous one had Opt-in RBF enabled.

However, technically or theoritically speaking, a miner always has the ability to pick any transaction he likes into his block template, so that he could mine such transaction(s) into his block. It's just the matter of whether his block would be widely accepted by the network (including other miners, non-mining full nodes which the wallet relied on, etc).

  ethereum has nonce value of each transaction which avoids this, but how does bitcoin avoid it?

I don't know much about Ethereum. As far as I know, the UTXO model itself is the equivalent of the nonce value, since each UTXO (uniquely identified with TXID and output index) could be spent only once, otherwise it would be an invalid transaction or block.

Note that the nonce value/UTXO model and double spending by forking the chain are two distinct problems.

Without the nonce value/UTXO model, even an individual chain itself cannot rule out double spending or replayed transactions, which is actually inflation in bitcoin, or replay attack in ethereum (the replayed transaction would make the victim make another unexpected repeated payment, so he would lose money).

However, even with nonce value/UTXO model, the attacker can still produce forked chain to "rewrite the history" (in such case, the previous transaction would be actually discarded, which generally means the previous legitimate payment would be maliciously withdrawn), which is the reason why we need a consensus mechanism like proof-of-work.


What's the POST endpoint to broadcast a transaction in copay's server? AFAIU, copay's server implementation is bitcore-wallet-service.

From its README, I can deduce that a multi-sig wallet will use the /v1/txproposals/ endpoint to create a new transaction proposal that the other co-signers will receive.

But, if the wallet is not multi-sig, what's the endpoint for broadcasting a transaction?

Multisig and singlesig wallets use the same flow. A Tx proposal need to be created in singlesig wallets also. Copay syncronize across devices, so you can have a non-signing copayers in a 1-1 wallet that submit proposals, for later approval.

The flow is:

create => publish => sign => broadcast.

You can check the official client https://github.com/bitpay/bitcore-wallet-client for details, and also the CLI client should be useful to see examples:
https://github.com/bitpay/bitcore-wallet


How can using Bitcoin with Tor improve privacy? As far as I understand Bitcoin, user privacy and anonymity are hard to guarantee in the presence of multi-input transactions and shadow addresses. Some sites suggest using Tor to hide the source of a new user introducing an unconfirmed transaction into the network, but does this really help? It may hide the physical address from which the address was generated, but it doesn't help prevent linkability between Bitcoin addresses and single users due to the two aforementioned properties, right?

Using Tor doesn't help to prevent someone from linking addresses and guessing that they might be owned by the same person.

It may help to keep someone from finding out who that owner actually is, where they live, etc.


Maintaining Tor hidden service onion address over new hardware My bitcoin Tor node recently suffered a hard disk failure. After changing the hardware, re-installing Linux and bitcoind, setting up Tor for a hidden service, I realized (obviously !) that my external onion address had to change. So my question is: what do I need to do to ensure I keep the same onion address the next time my node suffers unrecoverable failure? Looking at the directory /var/lib/tor/bitcoin_service, I can see two files hostname and private_key where the former does contain my onion address (which I think is related to my private key). So I am guessing all I need to do is back up these files and restore them in my new system (while setting up /etc/tor/torrc and bitcoin.conf appropriately of course, as explained here). Do I need more?

EDIT: it seems that simply importing the files hostname and private_key into a new system (having properly defined /etc/tor/torrc and bitcoin.conf) does not work (the node fails to connect to Tor network). So Tor probably maintains additional state apart from these two files. So the question remains open: how to set up a new system so as to keep existing onion address.

Depending on the version of Bitcoin Core and Tor you are using, there is the possibility that your installation was actually making use of Tor control and not actually using the configuration from your torrc. Have a look in the /.bitcoin/ folder for onion_private_key and try exiting Bitcoin Core, putting that file back in place from your old HDD and, restart Bitcoin Core.

I do not know if you will also need to do the same for the Tor auth cookie /run/tor/control.authcookie?

There is an updated setup guide for running Bitcoin Core and Tor on Bitcoin.SE right here.


Given the current hashing powers, what do pools actually do in practice? Given the current hashing powers, what do pools actually do in practice to find a block?

Ok, so here is my thinking, please correct me if I'm wrong anywhere:

Here's the format of the block header, the thing which is actually hashed:

  version(4b) + prevBlockHash(32b) + merkleHash(32b) + ctimestamp(4b) +
  ctarget(4b) + nonce(4b);

So, canonically, what miners do is going through all the possible values of the last NONCE(4 bytes).
If we treat that as unsigned int, the range would be 0-4294967295.
Right now you can buy a 2Ghs miner for < $100.
Given that you have something that can hash 2GHs(very cheap solution, I'm not even talking about THs systems that pools reportedly have), you could bruteforce through the range of 0:4294967295 in less than 3 seconds.

So, the question is, what keeps mining in that ~10min period?

My suspicion is that its not that much of a problem to find a nonce anymore, its more a problem to find the proper block that will actually have a nonce.

If that is true:

a) what do miners do in practice, play around with the timestamp, or generate some transactions to change the merkle root?

b) is there any mathematical proof that such a block will ever be found? I mean, bitcoin not getting stuck, because of some unfortunate block having such a bad coincidence of bits that will endup blocking the result from getting enough zeros in the end to fit the target(I'm asking about mathematical proof that it is impossible).

For a given combination of

version(4b) + prevBlockHash(32b) + merkleHash(32b) + ctimestamp(4b) + ctarget(4b),

There is no guarantee that there will be a valid nonce. There usually isn't - the probability that there will be is 1 divided by the difficulty, which is currently 9 billion. So miners try different combinations, try the nonce range for each, until they find a valid solution.

a) The most general method is to change extraneous data in the generation transaction to change the Merkle root. Currently, to reduce communication overhead between the pool and miners, a method such as GBT is used, where the miner gets a block template and can fill in the generation transaction himself.

b) No; hashing, like much of the core cryptographic primitives, is kind of a "dark art" - there's little in the way of proof that it all works. Let's say you fix just the prevBlockHash, there is no proof that you can fill in the other details to obtain a valid hash. However, if hash functions behave more or less the way we think they do, it is extremely unlikely there will be no solution.


Single API Platform for multiple cryptocurrency? I am wondering for a single API platform where i will be able to trade for below 5 crypto currency :

1) Bitcoin
2) Litecoin
3) Ethereum
4) Dash
5) Monero

So, are you guys supporting all these in 1 packet ??

Hope your asap revert,

Kraken deals in all of these. You can find the API at api.kraken.com


How do Ledger Backups get stored? Scenario

Say you have configured a ledger wallet with 10 BTC and 10 ETH. You then lose this said wallet but you have the 24 unique words. You buy another ledger wallet enter the 24 words and BAM, your wallet is back.

Question
My question is where did the backup come from ? And how is it encrypted.

Thanks!

Using words to back up wallets is a process described in BIP 39.

Basically, the mnemonic is converted into a seed. This seed is then used as the seed to a Heirarchical Deterministic (HD) wallet, as laid out in BIP 32. The seed is used to generate a Master Extended Private Key, from which all other private keys can be generated. The child key generation follows the standard of BIP 44 so it is compatible with other wallets too.

Thus, by backing up your mnemonic words, any time you enter them in a wallet, it can recreate the seed, then the master private key, then all your other keys, so your wallet is back.

References:

http://support.ledgerwallet.com/knowledge_base/topics/how-to-restore-my-backup-without-a-ledger-wallet


Blockchain Receive Payments API Not Working I want to accept payments with the Blockchain Receive Payments API (https://blockchain.info/api/api_receive) but I can't seem to figure out how to work it. I cannot test it too much because there is a minimum amount of BTC that can be sent to the account for it to work and I just ran out from testing because there is no destination for the address but that's another story- I just need to know that it should work. This is what I have so far:

callback.php

$secret = "testSecret";
if (isset($_GET['secret'])) {
if ($_GET['secret'] != $secret) {
    die("Invalid secret");
} else {
    define("HOST", "localhost");
    define("USER", "root");
    define("PASSWORD", "DBPASS");
    define("DATABASE", "xeon.io");
    $mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE);
    $query = "INSERT INTO invoices (item_id, price_in_btc, bought_by, deliver_to, time) VALUES ('2', '001', '1', '1', '0')";
        if ($mysqli->query($query)) {
            echo "*ok*";
        } else {
            die("ERROR!!!!1");
        }
    }
} else {
    die("Blank secret");
}

receive.php

$secret = 'testSecret';
$my_address = '1339LGRGE44QMLYa4hTuyAsbKVjVAGXwHW';
$my_callback_url = 'http://example.com/pay?secret='.$secret;
$root_url = 'https://blockchain.info/api/receive';
$parameters = 'method=create&address=' . $my_address .'&callback='.     urlencode($my_callback_url);
$response = file_get_contents($root_url . '?' . $parameters);
$object = json_decode($response);
echo 'Send Payment To : ' . $object->input_address;

Generating new accounts works just fine but that's not the problem.
The test callback on their site works but when I actually test it, nothing gets written to the database and the BTC isn't returned to the original account nor sent to the destination account.
I basically just want to know if I am doing anything wrong with the above code.
Thanks for the help :)

Not an expert, but have I have an ecommerce site that relies on blockchain's API and the error log I have looked at seems to indicate that cloud flare is preventing the return of the info that I'm looking to populate my stores db (just checking balances, etc).

Are there error logs that you've looked at and do they confirm that cloud flare is not the issue?  Seems like it plagues everybody using their API for basic functions.


Possibility of broadcasting new block to only a fraction of honest nodes? Consider in a block-withholding attack (aka selfish mining attack), attacker after creating a new block decides to broadcast this new block only to a fraction of network, such that eventually only a part of nodes will receive this new block and the rest of network will not receive it.

In my opinion, it will not be possible, because when attacker sends new block to one or some of host nodes, they eventually broadcast this block to whole of network, meaning that eventually all honest nodes will receive this new block. Am I right? or this attacker is able to prevent a fraction of honest nodes from receiving this new block?

This will generally not work, because as you said, if an honest node receives the block, it will propagate it to all of its peers, who will do the same, and so on.

Even if the attacker controls a large number of nodes on the network, he/she will have to ban every honest node to have a guarantee of them not receiving the block. If that is done, the attack is basically operating on their own fork of the chain.

The fork may very well be valid, and if broadcasted to the rest of the network later on with more work, it will become the canonical chain. Such attacks of withholding and then broadcasting have been used in the past, usually as part of a double spend attack (like on the Bitcoin Gold chain recently).

If you want to prevent broadcast to a subset of honest nodes, but still broadcast to some honest nodes, you would likely have to use techniques such as BGP rerouting. In short, an attacker reroutes BGP such that two different real world networks cannot communicate. This results in all nodes in each network failing to talk to all nodes in the other one, regardless of if they are honest or not. This will then result in a chain split, since each section of the network will continue functioning as if it is the only version of the network.


Finding nonce resulting in more zeros than the target This might be a wrong question(I am new to understanding bitcoin details). But I want to ask this:
 What happens if one node finds nonce value that results in way more leading zeros than expected by the target?

Nothing special happens in this case.

If you find a nonce for which the hash has at least the necessary number of zeros (or more precisely, is numerically less than the target value), you have a valid block.  That's all.  As far as I know, the Bitcoin protocol pays no attention to whether there are "extra" zeros.

Of course, if someone submits a block header with a drastically large number of extra zeros, people might reasonably take this as evidence that they have broken the SHA256 hash function in some way, perhaps with some sort of preimage attack.  This might lead to developers wanting to phase out the use of SHA256.  But that's beyond the scope of the protocol or the software.


Phased transactions are very slow I am trying to send a message to another account with two confirmations using the Phasing options in a message to add two different accounts. The problem is the message takes from 1 minute to 2 minutes to be sent. On the other hand when one of the users tries to approve the transaction also takes from 2 minutes till 5 minutes sometimes or more, and very rare it's quicker.

I have tried these operations using the local NXT with Testnet: locahost:6876, and the online Tool using the following URL: demo.jelurida.com.

Is there another way to do this quickly? I have read about Ardor too do you think it's a better choice?

Thanks in Advance,

By default it takes roughly 1 minute to send a transaction and once that is confirmed, it requires the 2nd party to make an approval transaction so thats another 1 minute. so roughly 2+ minutes which is what you have. Ardor would have the same timing aswell. Your stuck with the roughly 1 minute confirmations.


Why is anonymity important in bitcoins? Before I get started I would like to say I am an advocate of a virtual, peer to peer currency and bitcoins to an extent. I think some of the worst aspects of capitalism as well as huge amounts of power have manifested themselves in the finance sector and it would take something as radical as bitcoin to take the power back.

I am interested in why anonymity is important in bitcoins. Some of the other "worst aspects of capitalism" are the tax dodging multinationals that lie and cheat and as a result prevent the fair distribution of wealth amongst the population. Surely if bitcoin was adopted widely as a currency this would only worsen matters as there could be no means of taxation and thus projects like public health, education and law would break down.

What is the problem with making transactions traceable. Would this not make a virtual peer to peer currency more likely to succeed?

Anonymity is part of the Bitcoin culture. It was created to circumvent the powers at be, and anonymity plays into that idea quite well.

However the nature of the block chain is that every transaction is totally traceable. You can look at the block chain and determine where every bitcoin has ever been. This seems to contradice most peoples conception of bitcoin as being an anonymous currency.

In some ways it is. If you mine your own bitcoins and generate your own wallet then, even if I can see every transaction, that particular bitcoin or wallet made, I can not know who is responsible for making it.

But in the new age of bitcoin, where the average user does not know anything about encryption, and contracts third party services such as mt. gox to manage their bitcoins for them, anonymity is lost.


Code sample to sign a transaction I have the 32-bytes double hash of a transaction, a 32-bytes private key, and I would like to sign the hash using the private key.

How do I do that using BouncyCastle (or anything, really), in C# or Java? Can somebody point me to a code sample?

The 32-byte double-SHA256 of a transaction (TxID) is not what gets signed.

Future-proofing note: The description herein of transactions, TxID calculation, signatures and signatures scripts, etc. don't apply to segregated witness.

Let's look at an example with a transaction I created earlier. I called:

createrawtransaction '[{"txid":"0c71ea829dfb117442c1c0d0c492725794d890bbcbcd8234b1108d1b1d4ca2e9","vout":1}]' '{"1PkCAVKjPz1YK7iJwT8xTLxBXR1av8dL98":0.004}'

which created an (unsigned) transaction:

0100000001e9a24c1d1b8d10b13482cdcbbb90d894577292c4d0c0c1427411fb9d82ea710c0100000000ffffffff01801a0600000000001976a914f97df8f593e0056d337c274fd81a163f47a17d3788ac00000000

And then I asked bitcoin-rpc to sign the transaction, and received:

0100000001e9a24c1d1b8d10b13482cdcbbb90d894577292c4d0c0c1427411fb9d82ea710c010000006b483045022100d9a5433c1381b39b7e02b0b0f042990e7c16cfea252b05ccfef2e85c2dab2a6f022057c7def782fe3b0d7e5e0eae277d2a5890844da7d72309817a2dac22a6307c6001210390d78cb0c1d34d4417db7e0a9a9f125a689dc29dc2197a01a5f827a20f870f62ffffffff01801a0600000000001976a914f97df8f593e0056d337c274fd81a163f47a17d3788ac00000000

Here is that signed transaction data again, with the signature and related script data bolded:
0100000001e9a24c1d1b8d10b13482cdcbbb90d894577292c4d0c0c1427411fb9d82ea710c010000006b483045022100d9a5433c1381b39b7e02b0b0f042990e7c16cfea252b05ccfef2e85c2dab2a6f022057c7def782fe3b0d7e5e0eae277d2a5890844da7d72309817a2dac22a6307c6001210390d78cb0c1d34d4417db7e0a9a9f125a689dc29dc2197a01a5f827a20f870f62ffffffff01801a0600000000001976a914f97df8f593e0056d337c274fd81a163f47a17d3788ac00000000

If you look at the unsigned transaction, all of the material before and after that bolded section is identical (aside from one padding byte which turned from 0x00 to 0x62), because only one signature (and associated script) was required to successfully spend the input.

Here's a visual diff between the decoded versions of the unsigned transaction (left) and the signed transaction (right):

You'll see that the unsigned transaction has a different txid (because the TxID is the hash of the full, signed transaction). Additionally, you'll see that the unsigned transaction does not have the scriptSig, whereas the signed transaction does. The scriptSig is the bolded inserted section from earlier.

To get back to your question, signing a transaction requires access to the actual transaction (rather than just the hash), because you need to sign the transaction data itself AND insert the signature into the transaction.

On a side-note, since the signature script is part of the data which is hashed to produce the TxID, the signature can actually be modified to still be a valid signature for the data. The signature signs a hash of other portions of the transaction so those can't be altered, but nothing protects the signature script itself from modifications. Any modification to the signature script which doesn't change the functionality of the signature script changes the TxID without invalidating the transaction.

Say you propagate a transaction to the network which sends Bob 2 BTC. Any peer (including block miners) could manipulate the script signature to appear differently while still validly signing the transaction. While this doesn't allow them to redirect those 2 BTC from Bob to anyone else, this modification does change the TxID of the transaction. If someone were waiting for the original TxID to be propagated across the network, it would appear that the transaction never executed if the modified transaction is included into a block instead.


How will bitcoin stay decentralized when mining becomes extremely expensive? My understanding of bitcoin is that the miners are the ones keeping bitcoin decentralized. What happens when only the richest of people can afford mining?

This is a valid concern and I think nobody can give you a clear answer here. We'll just have to wait how it evolves and how people react; it is an unclear future.

There are some ideas about changing the proof-of-work algorithm to make mining pools not that profitable, but the effects of such implementations could be various.

I highly recommend this article from Vitalik Buterin, where he walks through the history of Bitcoin mining, explains problems and solutions encountered in the past and describes the situation today. He also dares to predict the future development and provides some ideas to keep the mining decentralized.

It seems there's still a long path in the future of Bitcoin development.


Finding the address of a physical coin I have a physical bitcoin which has a 8 digit number. Is it possible to get the address of the coin without paperwork, as none accompanied the coin when a family member gave it to me.
I also have a Blockchain.info wallet and it says "Scan Pairing Code". When I do that, it shows little blue dots and takes a photo.
Can you tell me if I need the letter or address that comes in paper form?

The first step is to identify the specific type of coin and what company created it.

See Coindesk - 10 physical bitcoins - If your coin looks like any of those, you can find out whether it has any value and how to use it.

There are many variations:

Many physical bitcoins are novelty items and have no value.
A few may have some intrinsic value from the materials they are made of (gold, silver etc). I imagine most do not.
Some physical coins have an associated bitcoin value which can be redeemed if the company that issued the coins is still in business and honest. For example, Titan bitcoin say:

  If you ever want to spend or transfer a 2FA coin’s bitcoin value, simply peel back the coin’s security hologram and enter the redemption code on our website, along with your registration info.

Some physical bitcoins have a private key concealed inside them or under a tamper-evident sticker. You can probably type that into a bitcoin wallet to import the key. An example is the discontinued
series-1 Casascius Coin

  How they work: The "private key" is on a card embedded inside the coin and is protected by a tamper-evident hologram.  The hologram leaves behind a honeycomb pattern if it is peeled. If the hologram is intact, the bitcoin is good. If you have purchased a 2-factor item, the private key is encrypted and will need to be decrypted using your original preselected passphrase before you can redeem the funds.

  The 8-character code you see on the outside of the coin is the first eight characters of the Bitcoin address assigned specifically to that coin.  You can verify the coin's balance on Block Explorer.  There is a mathematical relationship between the Bitcoin address and the private key inside the coin. The digital bitcoin is actually located on the public "block chain" stored on the internet, but it is completely inaccessible to anyone unless the private key from the coin is loaded into a Bitcoin wallet.

My emphasis - I'd guess this may be the coin you have.

Note that the issuer may have records of those private keys. If the issuer went out of business or the records fell into the hands of others, it is possible that someone else will have subsequently removed any bitcoin value associated with the private key.

Useful references

Bitcoin Magazine - Physical bitcoins


Can somebody explain this privacy concern with Bitcoin once and for all? I have a wallet.dat in Bitcoin Core. I generate a new receive address. I give it to some random person who knows my identity. They send me 1 satoshi to that address. How exactly can they then "know my Bitcoin balance and exactly who I do business with"?

I have a wallet.dat in Bitcoin Core. Somebody gives me a Bitcoin receive address which I know nothing about. It could be fresh or reused. I send 1 satoshi to that address. How exactly can they then "know my Bitcoin balance and exactly who I do business with"?

In both cases, I'm not interested in what I can do to their privacy, but only what they can do to me.
I just don't get how either of those scenarios would make them know anything about me or learn my Bitcoin balance.
I've tried to ask this question regularly (in numerous variations) for a decade now. Not once have I got a satisfying or conclusive answer.
The reason I again ask is that I just watched a video where, once again, a Bitcoin expert said that this is how it works. Yet it doesn't add up to me, which probably means that I still don't understand Bitcoin.
I would highly appreciate a clear and unambiguous answer! Always in the past, I come away from this kind of discussion with more questions than before...

As an example, let's say that Alice is an attacker trying to learn Bob's wallet using this method. Alice sends 1 satoshi to some address that Bob owns.
At this point in time, Alice does not know anything about Bob's wallet, except that he has 1 sat that she sent him. But the problem is when Bob wants to send Bitcoin.
Now Bob sends some Bitcoin to a merchant, Carol. When he does this, his wallet will look at what UTXOs it can spend, construct a transaction, sign it, and send it. For this example, let's say that his wallet chooses the UTXO for the 1 sat that Alice sent him. Of course he is paying Carol more than 1 sat and he also has to pay transaction fees. So Bob's wallet chooses several other UTXOs to cover the amount being spent and the transaction fee.
When Bob broadcasts his transaction, Alice can see it too. This is where the privacy comes in. Alice can see the 1 sat she sent Bob in this transaction he made. Since that transaction includes other UTXOs from Bob's wallet, Alice learns that Bob had those UTXOs in his wallet. She can now check the addresses for those UTXOs and learn some addresses in Bob's wallet. If Bob was reusing addresses, she can now learn a lower bound to the amount in Bob's wallet.
Furthermore, because she knows those addresses belong to Bob, she can watch for other transactions that spend those address's UTXOs. With those transactions, she can do the same process of examining the inputs and learning additional addresses in Bob's wallet. Because Alice can see many of the transactions Bob makes, she can see who Bob is paying and who is paying Bob.
Bob can mitigate this part by not reusing addresses. If Bob doesn't reuse addresses, then Alice will learn less information because once she learns about some of Bob's addresses in a transaction, Bob will never use those again so there isn't any additional tracing that can be done.
However, there is still the change outputs that Bob's wallet likely made in his transaction. If Alice is able to identify the change outputs in any of Bob's transactions, she will also be able to do the above.
Now this kind of tracking is not unique to the dust spam attack. Anyone can do this kind of tracing with any amount of Bitcoin. It can be done by someone being malicious after having done a normal Bitcoin transaction.

The 1 satoshi spam attack becomes more interesting when Alice does it en masse. If Alice sends 1 satoshi to millions of addresses, Alice can learn a lot more.
Suppose Alice looks up every address that has ever been used and sends 1 sat to every single one of them. This will include Bob's addresses. She also sends 1 sat to an address ,Bobs_addr, that she knows belongs to Bob.
Bob has never reused an address. But Alice has now forced him to reuse addresses because she has sent 1 sat to all of his addresses. When Bob makes a transaction, his wallet may be unaware of this attack and may choose to include a couple of Alice's 1 sat UTXOs in a transaction, in addition to the 1 sat at Bobs_addr
Now Alice has a transaction that links Bobs_addr with several of Bob's other addresses. Furthermore, because the 1 sat UTXOs belong to addresses that have now been reused, Alice can look up what transactions those addresses were involved in and do the same analysis that I described earlier with the address reuse problem.

There are several mitigations to these privacy revealing attacks. These privacy revealing attacks all rely an assumption that all of the inputs in a transaction belong to the same person. This is known as the common input heuristic. To break this assumption, a sender can join up with other people sending money and they all create a transaction together. This is known as a Coinjoin. A Coinjoin transaction has inputs from multiple people, and outputs which go to multiple people. So this breaks the common input heuristic.
Wallets can also be made aware of such dust spam attacks. If the wallet developers know that this is something that occurs, they can program the wallet such that it will never spend reused addresses unless absolutely necessary. If Bob never reused an address and his wallet avoided address reuse, he could prevent Alice from learning anything more about his wallet with her spam attack because his wallet would choose to ignore Alice's 1 sat UTXOs sent to addresses he already used.
In addition to avoiding reuse, if reuse has occurred, the wallet can also choose to spend all UTXOs to the same address at the same time. This prevents being able to link addresses to additional transactions because all of the reuse is spent at the same time.
To prevent Alice from being able to trace Bob's wallet by trying to figure out his change addresses, Bob's wallet can also choose to not make change outputs. His wallet could be using a coin selection algorithm which searches for an input set which exactly matches the amount that Bob is trying to send. Combined with not reusing addresses, avoiding spending reused addresses, and spending reused addresses all at once, this could effectively prevent Alice from learning anything about Bob because the only lead she has into his wallet is where those coins never lead back to Bob.


Consider using Bitcoin but just heard the IRS is sending tax notices to 10k plus users article: https://www.cnn.com/2019/07/26/tech/irs-cryptocurrency-taxes/index.html

My background: Good understanding of RSA cryptography, some elliptic curve, Number Theory and I am a (real)programmer

Lets cut to the chase: How is the IRS doing this? Word on the street is ML, which sounds similar to IBM Watson's fraud detection capabilities. How come the IRS has been able to unmask people, while the NSA is helpless against RSA?

We all know from a fact that RSA is unbroken from data exposed by Snowden. They are forced to use workarounds.

Don't make me post in math.stackexchange....

Bitcoin doesn't use RSA and there is no encryption or cryptography that hides transaction details. Bitcoin is pseudonymous, not anonymous. There are unique identifers for every participant in Bitcoin, the somewhat hard part is tying those identifiers to actual people. So there is no RSA, number theory, or ECC involved in what the IRS is doing because none of that is involved in the details they are concerned about.

What observers like the IRS can do is follow transactions and see how money changes hands from some identifers to others. Some identifiers may be known, such as exchanges and other large services. Most are not and likely to be individuals. Using various software tools, you can try to work out how money is changing hands, but it is error prone, can have a lot of false positives, and is actively being counteracted with things like CoinJoins.

But the IRS probably isn't following those transactions. They are doing something much easier: subpoena the exchanges for customer information. By law, exchanges need to gather identifying information about their customers. This includes things like Social Security Number, passport numbers, driver's license numbers, etc. They have to store all of these personally identifying information and they are all tied to user accounts. Additionally, all of these user accounts have trade and transaction history tied to them as well.

So the IRS is basically just asking (or compelling) exchanges to hand over all of this information about their users and comparing the numbers that were filed in their tax returns to the numbers that they calculate based upon the trade and transaction data that they have gotten from the exchanges. No cryptography, machine learning, or even programming involved whatsoever.


BIP32 recommends a 256 bit seed. Why do most Bitcoin wallets only use a 128 bit seed? According to BIP32's "Master key generation" section, "256 bits is advised".

See https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#Master_key_generation

Why did BIP32 consider 256 bits to be the recommended seed size, and why did the authors of so many Bitcoin wallet implementations consider 256 bits unnecessary?

The reasons for the 3 numbers:

Bitcoin uses 256-bit ECDSA signatures. These require in the order of 2128 steps to find a private key from the public key is known. This is Bitcoin's security level: we aim to always require an attacker to perform 2128 steps. If the seed has less than 128 bits of entropy, this inevitably leads to a faster algorithm, where an attacker can simply iterate through all possible seeds in less than 2128 steps. Because of that, BIP32 requires at least 128 bits of entropy.
When the seed has less than 256 bits of entropy (but more than 128), the resulting keys will also have less than 256 bits of entropy. As elliptic curve cryptography uses keys with a full 256 bits (despite there being a faster attacker than breaks it in 2128 steps), BIP32 also recommends 256 bits of entropy.
The combination of private key and chaincode (the "extended private key") in BIP32 are 512 bits in size. Because of that, using a seed with more entropy than 512 bits cannot possibly increase security more - it's just information that gets thrown away. Because of that BIP32 limits the seed to at most 512 bits of entropy.


How to update index when payment is received with Blockchain PHP API? I want to start accepting Bitcoins payment on my site, I got the callback and the index working fine, the only thing is that it won't update the index once the payment is received, I'd like to give the user some kind of live feedback when the payment is received, how can I do that?

Below is what I got.

  Index.php

<?php

$api_key = "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx";

$xpub = "xpubxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

$secret = "xxxxxxxxxxxxxxxxxxxx";

$rootURL = "https://xxxxxxxxxx.org/BlockChain";

$orderID = uniqid();

$callback_url = $rootURL . "/callback.php?invoice=" . $orderID . "&secret=" . $secret . "&username=Teste" . "&password=qwerty123";
$receive_url = "https://api.blockchain.info/v2/receive?key=" . $api_key . "&xpub=" . $xpub . "&callback=" . urlencode($callback_url);

$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $receive_url);
$ccc = curl_exec($ch);

$json = json_decode($ccc, true);

$payTo = $json['address'];

 echo $payTo;

?>

Callback.php

    $secret = "xxxxxxxxxxxxxxxxxxxx";

    if ($_GET['secret'] != $secret) {
        die("Stop doing that!");
    }

    else {
        //Register new user, insert more days, etc...

        //# START DEBUG #
        $fff = fopen("text.txt", "w");
        $value = $_GET['value'] . " - ";
        $fw = fwrite($fff, $value);

        $txhash = $_GET['transaction_hash'] . " - ";
        $fw = fwrite($fff, $txhash);

        $invoice = $_GET['invoice'] . " - ";
        $fw = fwrite($fff, $invoice);

        $value_in_btc = $_GET['value'] / 100000000 . " - ";
        $fw = fwrite($fff, $value_in_btc);

        $username = $_GET['username'] . " - ";
        $fw = fwrite($fff, $username);

        $password = $_GET['password'] . " - ";
        $fw = fwrite($fff, $password);

        fclose($fff);
        //# END DEBUG #

        echo "*ok*"; //Tell blockchain everything is ok, so they stop.
    }

    ?>

Your callback will update your server but the user would have to refresh the page to see the change, or you could use AJAX (but that can be wasteful as it will send several requests until there's an update). I'd suggest you use their websocket API to monitor for a transaction so that you can notify the user live on the page.

Below is a simple example, just be sure you update the address variable with the address you want to monitor. You can put your PHP output in the javascript like     var address = <?php echo $payTo; ?>;

User Page

Waiting for Payment...


Processing bitcoins on my website completely by myself, with no third-party bitcoin SaaS services I want to be able to accept and process bitcoins on my website only by mysefl. With no 3rd party bitcoin services. How can I do that? One way is to use Electrum. But its documentation regarding merchant is really bad. Does anyone have experience with that?
It doesn't have to be Electrum, though, and any bitcoin software will.
I'm a programmer, I'm ok implementing a neccesary part, it if I have to, by myself.

First, Electrum relies on Electrum servers, which are essentially a third party SaaS for SPV proofs. It's a fine thing to use for most people and as long as you aren't concerned that the server may compromise your privacy, you should be fine. But that said, you can say that about any SaaS service, so Electrum is probably not the solution you're looking for.

If you want to do everything yourself, you will have to run a full node at a minimum. You can create a wallet using a library like pycoin (https://github.com/richardkiss/pycoin) but that's much more work than using a full-node wallet like Armory.

There's actually webshop code written for processing bitcoin payments yourself (https://github.com/goatpig/BitcoinArmory/tree/master/webshop). The main benefit here is that only the public key is on the server so even if you get hacked, your bitcoins can't move without your say-so. Full disclosure: I wrote that code.

Another option may be using bitcoind, but that will require you to keep your private key on the server (NOT A GOOD IDEA).


What is is minimum possible number for an ECDSA private key? Private keys are 256 bit numbers. I know the max. possible number is something around:
115792089237316195423570985008687907852837564279074904382605163141518161494336

What about the min. number possible?

Thanks.

The all-zero bitstring doesn't have a corresponding public key per the standard (according to "Are all possible EC private keys valid?" on Crypto.SE), so it's 000…001.


How do I backup wallet for first time I tried to send Crypto to my brand new digital wallet.  I was informed I must backup wallet first.  How do I back up my digital wallet for first use?

Just write down the 12 words and put them back in and its done.  never give out them words because that your passphrase or in other words your Backup


How can I interact with Eclair from Python? I want to write some scripts for experiments with Lightning. Python is the language I'm most comfortable with. From the three major implementations, LND has python-grpc and c-lightning has pylightning, but what about Eclair? How can I interact with an Eclair node from a Python script?

This might not be a satisfying answer but if you look at the eclair git repo and their Wiki you will find that the eclair API is a JSON API and is exposed via http and web sockets and can be queried with regular http requests.

If you look at the c-lightning python client it is a tool that talks via a unixDomainSocket to the exposed lightningd api. So I guess you could in a smilar way quickly create a python wrapper to be able to talk to eclair.

It seems to me that currently no one has bothered to do so.


Why is a double hash of the previous transaction included in Txin? In Txin, there is a double hash of the previous transaction.

Why?  What purpose does that serve?  How is this data used later?

I believe it is one of the principles of Bitcoin, to make transactions you first have to have a valid transaction it stems from. If the previous transaction is not valid than the first transaction isn't valid as well.


How much out of order are the blocks stored in the blk*.dat files? To be more exact: Given two blocks A and B, with heights A < B, but with positions in the blk file (we'll call them pA and pB) pA > pB.

What is the maximum amount of blocks that there could be stored in a blk*.dat file, between pB and pA?

For instance, let's say this is a blk*.dat file:

C D B E F G A H I

We can see here that block A is stored 3 blocks later than B, despite A having a lower height than B. Is there a maximum amount for this value (which in this case is 3)?

1024.

/** Size of the "block download window": how far ahead of our current height do we fetch?
 *  Larger windows tolerate larger download speed differences between peer, but increase the potential
 *  degree of disordering of blocks on disk (which make reindexing and in the future perhaps pruning
 *  harder). We'll probably want to make this a per-peer adaptive value at some point. */
static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024;

(Source.)


Difficulty set by pools Can we argue that, since the difficulty set by pools is lower than the actual one, "old" hardware remain profitable for longer and thus are used for more time. And this, indirectly, increases the actual hash rate of the entire network? (and thus difficulty as well?)

No, you see the difficulty of a pool is lower in order for the pool to be able to verify that the miners are actually working on a solution. The shares a miner obtains are mostly not valid blocks, which is what gets rewarded in Bitcoin, paid out to the pool and then paid to the miners.

The difficulty to create a block is not influenced by a pool's share difficulty, hence the total payouts the pool makes does not change, and old hardware is just as (un-)profitable.


Unable to remotely access lightning-charge My setup is a little bit complicated and I'm almost sure that my problem is port related.

So I'm running Mac OS X 10.13.4 with Parallels Desktop with a Ubuntu 14.04 VM. I managed to setup bitcoin core in the VM, on top of it I installed c-lightning and managed to fund it with btc (All is happening on the testnet) which I used to open one channel with some random other node. Everything is perfect for now.

Because I want to use the LApp for WordPress Lightning-Publisher I Installed lightning-charge and started an HTTP server running on the default port 9112. All of my ports are correctly forwarded and in my bitcoin.conf file I have allowed all ips. If I run Mozilla in my Ubuntu VM and go to http://api-token:mySecretToken@localhost:9112/info everything is fine, but when I try this on my Mac I get Can't open the page because the server unexpectedly dropped the connection. If I try using my external ip it's the same thing.

Using several sites to check if my ports are correctly forwarded I get that all corresponding ports are open (18332 for BTC core, 9735 for c-lightning and 9112 for lightning-charge).

Here is my bitcoin.conf

testnet=1
server=1
rpcallowip=0.0.0.0/0
rpcuser=someuser
rpcpassword=somepass

addnode=104.237.131.138
addnode=151.80.205.132
addnode=192.155.82.123
addnode=74.220.255.190
addnode=80.100.203.151

here is my lightning config

network=testnet
alias=IVCHOBIVCHO
port=9735
rgb=008000

Proof that 9112 is open:

Proof that lightning-charge opens from inside the VM:

And in Safari on my mac (using localhost:9112 returns the same error):

Neither Ubuntu, nor my Mac are under any kind of Firewall. My router is TP-Link

After a lot of research I found the solution to my problem.

I didn't know this, but in nodejs there's a huge difference if your server runs on 127.0.0.1 and on 0.0.0.0.

It isn't said in the lightning-charge docs, but except the --port attribute you also have --host which you can set.

Starting lightning-charge with this line charged --api-token mySecretToken --host 0.0.0.0 fixed all of my problems. Gosh was that an unpleasant journey!


Making peer connection in Python I'm trying to make a simple peer connection using Python.

If I understand correctly communication begins by sending a "version" packet to the receiving node. The node then sends back a "verack" packet, afterwards you may begin querying for data/pushing txs.

Ken Shirriff's blog has proved invaluable in getting me this far but I'm unable to get his code examples working, possibly because they're dated?

In particular, when running:

https://github.com/shirriff/bitcoin-code/blob/master/minimalPeerConnection.py

the socket closes immediately. I fail to receive back a "verack" and am unable to proceed with pushing my tx. Note that I've replaced his hard-coded IP with a currently operating node (124.248.237.178:8333).

I've attempted to construct a more "up to date" version packet (70002) referencing these docs but run into the same issue:

import struct
import socket
import time
import hashlib
import binascii

magic = 0xd9b4bef9

def makeMessage(magic,command,payload):
    checksum = hashlib.sha256(hashlib.sha256(payload).digest()).digest()[0:4]
    return struct.pack('L12sL4s',magic,command,len(payload),checksum).encode("hex")+payload
def makeVersionPayload():
    version = 70002
    services = 1
    timestamp = int(time.time())

    adr_u = "::ffff:127.0.0.1"
    services_u = 1
    port_u = 8333

    adr_me = "::ffff:127.0.0.1"
    services_me = 1
    port_me = 8333

    nonce = 0

    user_agent_bytes = 0
    start_height = 0
    relay = 0

    #https://bitcoin.org/en/developer-reference#version
    payload_hex = "";
    payload_hex += struct.pack("<L",version).encode("hex")
    payload_hex += struct.pack("<Q",services).encode("hex")
    payload_hex += struct.pack("<Q",timestamp).encode("hex")
    payload_hex += struct.pack("<Q",services_u).encode("hex")
    payload_hex += struct.pack(">16s",adr_u).encode("hex")
    payload_hex += struct.pack(">H",port_u).encode("hex")
    payload_hex += struct.pack("<Q",services_me).encode("hex")
    payload_hex += struct.pack(">16s",adr_me).encode("hex")
    payload_hex += struct.pack(">H",port_me).encode("hex")
    payload_hex += struct.pack("<Q",nonce).encode("hex")
    payload_hex += struct.pack("<B",user_agent_bytes).encode("hex")
    payload_hex += struct.pack("<L",start_height).encode("hex")
    payload_hex += struct.pack("<B",relay).encode("hex")
    return payload_hex

ip = socket.gethostbyname("124.248.237.178")
port = 8333
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print "connected to node..."
sock.connect((ip,port))

hex_msg = makeMessage(magic,"version",makeVersionPayload())
print "sending version packet"
sock.send(binascii.unhexlify(hex_msg))

while 1:
    msg = sock.recv(4096)
    if not msg:
        print "disconnected"
        exit()
    else:
        #expecting verack?
        print "response: ",msg

Can anyone point me in the right direction?

Got it working.

Ken's blog assumes a Windows environment, in 64-bit Linux the byte counts are different for certain datatypes so I had to change some of the "pack" formats.

Finally, I'd been doing everything in hex and converting to binary only for the socket send. When calculating the sha256 (twice) checksum however this must be on the BINARY payload.

Working code (for 64-bit Linux at least):

import struct
import socket
import time
import hashlib
import binascii

magic = "f9beb4d9"

def makeMessage(magic,command,payload):
    checksum = hashlib.sha256(hashlib.sha256(payload).digest()).digest()[0:4]
    return magic.decode("hex")+struct.pack('12sI4s',command,len(payload),checksum)+payload
def makeVersionPayload():
    version = 70002
    services = 0
    timestamp = int(time.time())

    addr_you = "127.0.0.1"
    services_you = 0
    port_you = 8333

    addr_me = "127.0.0.1"
    services_me = 0
    port_me = 8333

    nonce = 0

    user_agent_bytes = 0
    start_height = 0
    relay = 1

    #https://bitcoin.org/en/developer-reference#version
    payload = "";
    payload += struct.pack("i",version)
    payload += struct.pack("Q",services)
    payload += struct.pack("q",timestamp)
    payload += struct.pack("Q",services_you)
    payload += struct.pack(">16s",addr_you)
    payload += struct.pack(">H",port_you)
    payload += struct.pack("Q",services_me)
    payload += struct.pack(">16s",addr_me)
    payload += struct.pack(">H",port_me)
    payload += struct.pack("Q",nonce)
    payload += struct.pack("B",user_agent_bytes)
    payload += struct.pack("i",start_height)
    payload += struct.pack("B",relay)
    return payload

ip = socket.gethostbyname("124.248.237.178")
port = 8333
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print "connected to node..."
sock.connect((ip,port))

msg = makeMessage(magic,"version",makeVersionPayload())
print "sending version packet"
sock.send(msg)

while 1:
    msg = sock.recv(2**10)
    if not msg:
        print "done"
        exit()
    else:
        print msg.encode("hex")


How is mining profitable? The miner that creates a block gets the reward and all the fees that are in that block.

What happen with other nodes that does not create a block. In their case, will not they  get any reward and also any fees? How do they survive?
As I understand, when a block is created, all the miners start again finding the solution to create the next block. Can the miners choose which transactions validate? If it is like that, all the blocks in that time frame, are they the same?

Thanks!

What happen with other nodes that does not create a block. In their case, will not they get any reward and also any fees?

They will not get any reward for that block.

  How do they survive?

By finding other blocks. Blocks are mined, on average, every 10 minutes. That means that a miner has a chance to find the next block if they don't find the current one. Blocks are fairly frequent, and the miner who found one block is not necessarily going to find the next one.

  Can the miners choose which transactions validate?

Miners can choose which transactions they want to include a block. They do not get to choose which transactions are valid. It is not the miners' job to dictate what transactions are valid. All transactions that they include in a block must be valid, and they can choose any valid transaction to include.

  If it is like that, all the blocks in that time frame, are they the same?

No, they are not. Miners may choose different transactions. The transactions may be in different order. Miners also have full control over the coinbase transaction which is the first transaction in the block that pays them the block reward. This coinbase transaction can be modified by the miner, and typically is modified in order to have more possible blocks for them to try.

Furthermore, the coibnase transaction for different miners will always be different as they will want to pay themselves, not someone else. Thus the blocks will always be different.


Will a zero-fee transaction get processed faster if I send it straight to a miner I am running especially for that purpose? Is it possible to get a transaction with no fee attached processed faster by sending it directly to my own bitcoind running with mintxfee=0?

Does the speed of my hardware play a role?

Is there anything else I need to set in bitcoind?

Is there another way of achieving the same results (fast zero-fee transactions)?

Thanks!

This will let you include your own transaction in the next block you find yourself, without paying a fee (but the fee would be paid to yourself).  However, if you are a solo miner, it will probably be an extremely long time before you find a block yourself.  It won't have any effect on whether other miners will accept your transaction without a fee.

There's no free lunch as far as getting fast transactions without a fee.


Antminer s3 no ethernet setup So, Im the only tech savvy guy in my house unfortunately, and I live in the middle of nowhere, so my modem/ethernet data limit is limited to 10 gigs. My only way of feeding the internet to my computer is through my phones USB, cause thats all I can use to get unlimited data. Is there a possible way to set my antminer S3 to feed off of my computer while connected to my phone, and now to the modem?

You need to set your computer to bridge the connection from the interface that it is using to connect to your phone and the connection to the ethernet interface your Antminer is connected to. In this way, you share your phone's internet connection with your Antminer.

To do bridging, typically you open up whatever network interface settings are available for your OS. Then there is usually an option to create a bridge, and from there, you just follow the instructions.


Relocating Physical Node Location Are you able to relocate your node's physical location (i.e., move from Oregon to New York) and keep all the channels you've established intact?

Yes. Channels are associated with a node_id, which is just the public key of the node. The association of a node_id to an IP address (or Onion address) is dynamic and is broadcast over the P2P gossip network when your node connects to another. It only takes a few minutes after reconnection for your new IP to propagate through the entire network.
However, you should reconnect as timely as possible after turning your node offline. If parties you have open channels with find you unresponsive for so long, they may attempt to unilaterally close the channels they have open with you. If they also believe you are offline and not monitoring the channels, they may attempt to broadcast an expired channel state to take more of the balance than they currently have in the channel.


Upgrading Multibit (without losing wallet) I am using Multibit 0.4.23 but would like to install Multibit 0.5.9.  How would I move my coins from my current wallet? Is this done automatically?

Pretty much every single program allows you to upgrade it without losing data, and Multibit almost certainly isn't exception.

Just upgrade it.

In case you're worried, backup your wallet first.


Load a transaction with bitcoinj I am developing simple Bitcoin application using the bitcoinj library: The user enters the hash of a transaction and my application should return detailed information about that transaction.

How can I load that transaction? Is there a function like peer.getBlock() for transactions?

BitCoinJ is a Simplified Payment Verification (SPV) client library

This means that it only downloads the headers for transactions, and only those that are relevant to the private keys contained in its wallet only. This greatly reduces the blockchain download (very quick to get started), but at the cost of not seeing all the other transactions (reduced overall network security).

So, in short, you can't download an arbitrary transaction through BitCoinJ.

However, to answer your requirement have you considered just using the Blockchain.info API?


Mining when there is no transaction what happens when there is noone doing transactions and miners mine the blocks? Can they mine empty blocks? And how it works when there won't be any hash in empty block or there is a hash?

Thank you

Can they mine empty blocks?

The miner must include a coinbase transaction (which determines the mining reward), or the block will be rejected by the network. That way, the miner is awarded coins for solving a block (even if it contains no other transactions) and coins are distributed according to consensus rules.

  And how it works when there won't be any hash in empty block or there
  is a hash?

There is still other data that is hashed, including:

version, previous block hash, merkle root, unix epoch time, difficulty target (bits), and nonce.

The merkle root including only the coinbase transaction in this example.


How to find what is suitable transaction fee to send 10 mBTC? Using MultiBit Desktop Wallet, I can see that the default transaction fee is set to 0.5 mBTC per KB.

Usually that default rate worked fine. But yesterday, when I tried that and my transaction has not been confirmed for over 12 hours now.

So today I increased the fee to 1mBTC per KB and tried to send another 10mBTC to the same destination wallet. It is half an hour now and it has not confirmed either.

It is really frustrating. I'm wondering what is wrong here, and how can I choose a fee that make near instant transaction possible.

Bitcoin Fees is a useful site to see the current network status and pending transaction fees. According to that site as of now, a transaction fee of 4.11 - 4.20 mBTC/KB is required to clear within 1-12 blocks (i.e. within around 2 hours), 4.61+ to clear as soon as possible.


Does the original Bitcoin client scale to contain millions of addresses? We use the standard client in our business. The wallet already contains about 25k addresses. Will the wallet remain stable after the number reaches 100k or a million addresses? I was told that all major business have forked the client. Should we also fork and code our own wallet?

I've ran tests before on .5 million addresses generated in one afternoon. It fired walletnotify within the milliseconds, no noticeable delay when I sent an amount to a random address. Only noticeable thing was that the client took 30 minutes to start up, which I guess is fine if you run a larger service. Only thing that may trouble you is slow transaction creation time, but someone on here advised me to just move the funds into a new address monthly.


How long can my lightning node be safely offline? I am interested in setting up a full bitcoin and lightning node on my pi.  I want to open a few channels and be well connected in the network.  I intend to keep this machine on permanently, but may have to unplug it if I need to move it to a different socket or maintain it.  How long can my node safely be off the bitcoin network without risking loss of funds in my channels?

that depends on the locktime that is configured for your channels. taken from c lightning (c.f.: https://github.com/ElementsProject/lightning/blob/97118c558e84e0b3a12a8cbe60528ad5cfcb2fd6/doc/lightningd-config.5.txt )

  watchtime-blocks='BLOCKS'::
      How long we need to spot an outdated close attempt: on opening a channel
      we tell our peer that this is how long they'll have to wait if they perform
      a unilateral close.

  max-locktime-blocks='BLOCKS'::
      The longest our funds can be delayed (ie. the longest watchtime-blocks
      our peer can ask for, and also the longest HTLC timeout we will accept).
      If our peer asks for longer, we'll refuse to create a channel, and if an
      HTLC asks for longer, we'll refuse it.

I believe the standard setting should be 144 blocks which statistically should be 24 hours. of course you should consider a safety window to be able to get your breach remedy tx mined in case of a unilateral close.


need advice for Python interaction with bitcoin-core wallet I've read about a few Python libraries that performs JSON-RPC calls to bitcoind. However, not many are actively developed/maintained, nor are they widely used in production environment. Since bitcoind evolves over time, these hard-coded Python functions may not work well with all the different versions of bitcoid -- some new functions are added while others may get deprecated.

And for any general purpose JSON-RPC library, we basically need to write all the wrappers of the function calls. It shouldn't be hard, but itself is another project.

I could've just use bitcoin-cli and let Python do subprocess calls, then the problem comes with parsing those stdout. Most of the time, they are just JSON format, except when they are not ...

Question: can anyone recommend the best solution for Python program to interact with bitcoind?

Maybe you miss how these libraries are implemented, in fact, the standard implementation of python JSON-RPC library already discover RPC function and map to python function, here you can read the official wiki.

If you read the code of this library you cannot find the specific implementation for every method, it's a generic wrapper around the implementation of JSON-RPC standard library.

The feature of this wrapper in detail are specified in README.md file.


What happens when a node cannot find the base Block of a newly received Block This particular question has been bugging my mind for sometime now. Suppose there an adversary miner who mines a Block with one of his transactions. The miner would only send the updated Block to a known peer minor (Ma). And right after sending out the first Block to a known peer(Not to the whole network), the miner hits the jackpot and was able to generate another Block with the same transaction. It is highly unlike that the adversary could mine another block immediately after mining the previous block but it is doable.

Network --> [B1]->[B2]->[B3]->[S1]->[B4]  Ma --> [B1]->[B2]->[B3]->[S2],

Adversary -->[B1]->[B2]->[B3]->[S1]

As I've shown above, once Ma receives B4, it has no way of knowing what the predecessor Block (S1) of B4 is.

Could someone please explain how Bitcoin handles these sort of issues ?

Without knowing the parent, the node will hold onto the block and only do validation that can be done without context (i.e. the parent). It will also ask its peers for the parent block, and once it receives it, it will connect both blocks to its blockchain if they have more cumulative work than the node's current blockchain.

Otherwise the node ignores that block.

Keep in mind that this scenario is extremely unlikely, and not because a miner is unlikely to find two conflicting blocks nearly simultaneously. Rather nodes will relay blocks once they verify them, there is no such thing as "send to a peer but not the network". Sending a block to a peer sends it to the network as that peer will relay it to its peers and so on. So when Ma receives the block, unless it has been sybil attacked by the Adversary, it will relay that block to the network.

When Ma's peers receive S1 and B4, they will relay it to Ma and Ma will update its blockchain accordingly.


How do I run GUI on Raspbian? I had this running perfectly and the blockchain was synching and at about 80% completion. I came home from work to a power outage.

I keep seeing to run bitcoin-qt, it doesn't appear that I have that. In /src/ I have bitcoin-cli, bitcoind, and bitcoin-tx. Obviously d is daemon, and -tx isn't what I want either. So I try

bitcoin-cli -datadir=/pi/home/bitcoin/
error: too few parameters (need at least command)

It seems like you simply haven't installed bitcoin-qt, if you install that then you can run it :)

I'm unsure exactly how the power outage and the datadir command at the end relate to the question though


One dataset for many wallets... how? It takes a while to download and process the transaction log.
Doing that for dozens of wallets would be a big waste.
I want to run just one client full time as a log processor.
Then for each wallet, symlink the log processor's data
files into each wallet's homedir.
Even if I can't tell each client to NOT pull down new
logs and process them, I can still copy the processor's ones
in as needed and then start the client.

So what files in the homedir are wallet specific, wallet signed,
or in ANY way linked to your wallet and keys/ids, etc?

And what files are completely safe/anonymous to redistribute, crossplant,
etc.

How do I separate the identity files from the network data files?

What files are, and do, exactly what?
Thanks :)

Only the wallet.dat file is specific to the wallet. You can stop the client, swap out the wallet.dat file for a different wallet, and then launch the client again. You may need to start the client with the -rescan option -- the client will do the right thing automatically in most cases, but there are a few corner cases it mishandles without -rescan.


MtGox Daily Withdrawal Limit Simple question about Mt Gox's terms for "unverified" "level 0" accounts:
See this URL: https://support.mtgox.com/entries/20919111-AML-Account-Statuses

It says that the daily limit for USD "or equivalent" is 1000USD.
And daily limit for bitcoin is 100BTC.

So my question: if current exchange rate is 100USD/BTC, I can withdraw 100BTC from MtGox to my personal wallet in one day, and then exchange the 100BTC in my wallet for 10,000USD at another exchange, potentially, assuming that another exchaneg will offer me 100USD/BTC?

On other words, is the daily limit of 1000USD only for withdrawing directly to USD?  Or does it mean that the equivalent of 1000USD (10BTC) is the limit no matter whether I'm withdrawing USD or coins?

The USD limit is only for funds being removed as USD.  They do not value BTC in USD to see if it crosses the limit.


How to choose an exchange? Let's assume you want to exchange traditional currency for Bitcoins and choose to do so through and exchange.

What are the most important factors/features that you should keep into consideration for choosing an exchange?

Verification time: some exchanges take too much time for verification
Verification versus / not verification: some exchanges need verification and others not
Fees. In my opinion, you get the lowest fees on binance -> https://www.binance.com/?ref=16821839
Time: some exchanges take too much time to withdraw etc.
here's a guide to choose the best exchange (made by me) -> https://medium.com/@redqop89/trading-guide-for-bitcoin-ethereum-ripple-and-other-cryptocurrencies-6773ab4b6b2


Does 'Mixing' in bitcoins really add up protection to my bitcoins? I was researching on simple ways to protect bitcoins without using unknown/untrusted software or solutions. It took my attention to 'Mixing' in the bitcoins with a friend's bitcoins and transfer back the same amount of bitcoins back to my wallet. I understand that it will generate different set of inputs and outputs for my bitcoins transactions.

My question is, does this really add up considerable (or any) protection or privacy to my bitcoins in theft/backtracking or any other kind of so far known attacks?

Thank you.

do you mean "anonymize" insteadt of "protect"? if so:

in general: no

everybody can track your bitcoin-transfers on the blockchain. so everybody can theoretically comprehend that you have used a mixer-service. if your mixer-service does really mix your bitcoin, you must still trust your mixer-service that it will never provide some information about that mixing-process in future to anybody. (but maybe this service will be hacked in future or the service must provide some information to a prosecuting authority for example.)

hint: you can improve your anonymity a little bit by changing your bitcoins to a cryotocurrency which has a little bit more anonymity/privacy (for example monero) and then make some transactions and change it back to bitcoin.


Why was it chosen to adjust difficulty every 2 weeks (rather than 2 days or every few blocks)? Is there a benefit to adjusting the difficulty every so often (ie 2 weeks) vs adjusting the difficulty every block?

Yes, there is a risk with adjusting the difficulty every block. It entirely depends on the method of adjusting. With how Bitcoin does it, if you adjusted every block, the difficulty would vary wildly due to the variance in times between blocks. However other algorithms for determining the difficulty may be able to account for that.

Adjusting every 2 weeks allows for the average time between blocks to be close to the actual time between blocks (by the law of large numbers) so that the adjustment can happen without being effected by the variance in times between blocks. The method used by Satoshi is very simple and straightforward with its effects easy to see and model.

Like almost every other "magic number" used in Bitcoin, the 2 week interval appears to simply be an arbitrary number with no real reasoning behind it.


Can the Bitcoin protocol support very small transactions effectively? Say in a few years Bitcoin is where we hope it is, like $1000 or even $10000. In such a scenario one cent is about 1-10 microBitcoins (1 millionth or 0.000001 BTC).

In my experience, attempting to use bitcoins for small transactions (even of order 0.001 BTC) usually either takes a very long time, or just doesn't get processed at all. It thus worries me that BitCoins cannot be used for small transactions which correspond to a big and important part of the economy (e.g. a kid buying a Popsicle, or giving a $1 tip, or buying bigger stuff in third world countries, etc.)

Does anyone has a useful perspective on this issue?

The answer is multifaceted.

Microtransactions were not a design goal of Bitcoin. Even if they're not well supported, that's ok.
Off-chain transactions might be used if on-chain microtransactions are too expensive.
There are a few possibilities to implement microtransactions on the blockchain. One such implementation was recently added to bitcionj. Also see this interesting proposal for nondeterministic nanopayments.
Alt chains for microtransactions are a viable solution as well.

TL;DR - it's not a problem.


Wallet: how to generate public extended key? As far as I understand, when I want to create an HD Wallet, do I need a private key that is derived into an extended public key?

So, my question is, if I am coding a portfolio of bitcoin in java, how can I generate this public extended key from a private key (I assume that the private key is like a private password right?)?

Thanks for your help,

Generally the private key and chain code (these 2 parts make up the extended private key) are generated at the same time from a seed. The seed can be either a randomly generated number, or derived from a 12 word mnemonic like BIP 39 details. Once you have a seed, BIP 32 explains:

  Calculate I = HMAC-SHA512(Key = "Bitcoin seed", Data = yourSeed)
  Split I into two 32-byte sequences, IL and IR.
  Use parse256(IL) as master secret key, and IR as master chain code.

So basically you take the 512 bit hash of the seed, and split it into two 256 bit halves, one of which is the private key and the other is the chain code. And from the private key, you can obtain the public key.


Reserved Bitcoin address for examples? Is there a reserved Bitcoin address?

It should not be able to send bitcoins to it. But the address should be syntactically valid.

Such an address could be used for examples/documentation, without advantaging the author. Similar to example.com.

Wikipedia and bitcoin.it use bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W. Is this a reserved address or is it owned by someone? (resp.: could you send bitcoins to this address?)

If there is no reserved address, which should we use? Simply take a valid address and replace the first digit with, say, a "9"? (would this be future-proof?) Or use a testnet address?

The address is invalid because the checksum does not match the provided address. For more information see here: https://bitcoin.org/en/developer-reference#address-conversion


How to transfer BTC from desktop wallet to mobile wallet (without fees), say using Electrum or Bitcoin Core I have both Bitcoin Core & Electrum wallets installed on both my desktop & mobile.  How do I transfer BTCs from respective desktop to mobile wallets (& vice-versa) directly (i.e., not thru the blockchain) to avoid fees?

To accomplish this you will not 'transfer the bitcoin', you will just import the keys that can spend your bitcoin, into a new wallet.
Not all wallet software will support importing/exporting keys in every format, so you'll need to ensure that your current wallet software is capable of exporting keys in a format the the new wallet will accept. There are several formats for private keys, as well as other standards for backing up/recreating wallets, such as BIP32/39/44/84, etc. Be sure to familiarize yourself with these formats, and know which ones you'll need to use in order to accomplish your goal. Any wallet software worth using will allow you to export keys in some way or another, and hopefully provide some sort of documentation to help with this.
Very importantly, you need to understand that the private keys (or mnemonic seed phrase) that you'll be handling is the literal key to your bitcoin. If you store it on, or enter it into a compromised device, your bitcoin could be stolen.
Once you have the keys that control your bitcoins exported, you can import them to the new wallet, and (potentially after a rescan of the blockchain to locate your funds), your funds should appear in the new wallet.


About changing the endpoint in insight API (in bitcore) I am just trying to find docs on bitpay's bitcore node to change the endpoint of one of its services , which is insight-api

https://github.com/bitpay/bitcore-node

https://github.com/bitpay/insight-api

The API endpoints will be available by default at: http://localhost:3001/insight-api/

Question: Is there a way to change localhost:3001/insight-api/ to say localhost:3001/btcApi/ ? I understand the config file is like SomeNode/data/bitcoin.conf

You can change the bitcore-node.json configuration to include these items: https://github.com/bitpay/insight-api/issues/430


Pycoin: How to sign SegWit transaction via Pycoin? My target is to make transaction with unspent transaction outputs(UTXOS).
The information of UTXOs is as follow.

[
  {
    "pt_idx": 0,
    "subaccount": 37,
    "ga_asset_id": 1,
    "value": "92343",
    "block_height": 1288714,
    "txhash": "9e2d2d56632b609e9b5d0a1990cf0ffbd9865cec558b68ed106df352fd89cfb1",
    "pointer": 1083,
    "script_type": 14
  },
  {
    "pt_idx": 1,
    "subaccount": 37,
    "ga_asset_id": 1,
    "value": "9961066",
    "block_height": 1288718,
    "txhash": "b0e37f463aba4e3abb078eb77c472b29621cfdd17ed83ae41122b0b95df5e518",
    "pointer": 1096,
    "script_type": 14
  },
  {
    "pt_idx": 1,
    "subaccount": 37,
    "ga_asset_id": 1,
    "value": "315595",
    "block_height": 1288721,
    "txhash": "b062efcab010d436ca2f6bed0dc61b90d8cbced756e1ed7cc7593cac30d87326",
    "pointer": 1099,
    "script_type": 14
  },
  {
    "pt_idx": 1,
    "subaccount": 37,
    "ga_asset_id": 1,
    "value": "1872759",
    "block_height": 1288716,
    "txhash": "f88cfdb328f9d298b0ff8a641198d3e63ea7efaf6f98f5692ba3f88a03a73c2b",
    "pointer": 1088,
    "script_type": 14   }
]

From these I made transaction using pycoin library.
By the way, it is difficult to sign a SegWit transaction.
If anyone knows about this, please tell me.

For compatible segwit transactions, it is basically using p2sh transactions.
For pycoin specifically, you need to provide p2sh_lookup dict when sign the p2sh transaction.
I have a sample for bitcoin offline/paper transaction if you would like to check, the method spend_sh_fund may suit your need.