What are the risks of direct Bitcoin fraud, such as counterfeitting? I am being mocked by friends for not being on the Bitcoin train yet, so I am trying to understand it all. I get how btc blockchains basically works, but when someone says "if bitcoins are copied by splitting the blockchain" or something like that (I can't even quote it correctly...), what does it mean? Are there 'fake' bitcouns floating around out there? And what to do if you end up with some fake btc?

There are a lot of scammers but counterfeit bitcoin cannot exist. Scammers can try to trick inexperienced users with watch-only wallets, or fake software etc, but they can't actually counterfeit coins.
Since the bitcoin ledger is public anyone can check to confirm if a bitcoin address has funds on it. In most cases you just need a single private key to spend the funds associated with a bitcoin address, so simply verifying that you have that private key and the address associated with that key has funds you can be sure those funds are really there.
Never accept a wallet file or a private key in exchange from someone trying to sell you bitcoin, instead simply provide them an address you already know you control and have them send funds to you over the bitcoin network.
The "splitting the blockchain" reference you mention is related to what is called forking. As bitcoin is open source anyone can create and run network similar to bitcoin with the same or possibly different rules than bitcoin. There are also instances where developers will take the bitcoin blockchain and copy it to start a new coin, but uses the existing balances of all bitcoin addresses (Unspent Outputs). This is a forked chain where users that had funds on bitcoin, now also have funds on some new chain but usually at a much lower value than the original. These forked chains, created out of nothing, usually suffer economically as opposed to the original bitcoin. Although it is a copy, it is not counterfeit it's just another blockchain network.


Where can I get bigger amount of test BTC? We are conducting some testing with the end users of our application and I need a bigger amount of test BTC for it. Using faucets, I can get 0.1 or 0.01 per request with captcha, but I need something around 100. Is there any place, where I can get this amount at once?
Cheers.

If you need 100 coins, you should use regtest mode, this is a message from a faucet website:

  Please do not ask me to send a coin outside the faucet!
  My stocks of coins are shrinking and generation new coins is becoming more and more difficult.

  If you really need a lot of testing coins, try some other solution. For example:
  bitcoin-testnet-box
  bitcoin-regnet

Link


Is Bitcoin completely Open-Source? I am newbie in this area.

As I understand, Bitcoin was started as open-source project; But what about now?

I see on Github there is 'Bitcoin Core', is it bitcoin repository?
https://github.com/bitcoin/bitcoin

Or maybe government or corporations already bought it, like, for example, Github..

Bitcoin Core is open source under an MIT license, and is the original software implementation of a Bitcoin full node, though there are others. Most nodes run Bitcoin Core, but don't have to. Bitcoin could be defined as a network of users that agree to the same consensus rules, which means they don't all have to run the same exact software.

The MIT License (MIT)

Copyright (c) 2009-2018 The Bitcoin Core developers
Copyright (c) 2009-2018 Bitcoin Developers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

See COPYING


Different error messages under "Mandatory script verify flag failed." I've been playing with raw transactions and signed transaction and I've noticed that the error "Mandatory script verify flag failed" comes in two variations.

script failed on OP_EQUALVERIFY OP
Script evaluated without error but finished with a false/empty top stack element.

Now, it appears that error number one is given whenever I try to send a transaction with the wrong TXID or index number.
The second error can appear when I provide the wrong signature.

But aren't both errors just variant of a failure in executing the OP_EQUALVERIFY? At what step of the evaluation each error is thrown and what can we make out of it?

I'll highly appreciate any pointer you might have. I really struggle here to differentiate the two.

But aren't both errors just variant of a failure in executing the OP_EQUALVERIFY? At what step of the evaluation each error is thrown and what can we make out of it?

No, they're different errors. There are two rules that must be satisifed here:

The hash of the public key must match a certain value. (A failure here means you have the wrong key, or no key.)
The signature must be valid for the message and public key. (OP_CHECKSIG does not error immediately. It returns 0, which causes the script to fail.)

There are other script errors, too. See this list: https://github.com/bitcoin/bitcoin/blob/master/src/script/script_error.cpp


What can a dishonest node do (or try to do)? Except this kind of attacks: https://en.bitcoin.it/wiki/Double-spending

For example can he simply create a new block that includes some invented transactions that steal money from real address? Without possessing the private keys of those addresses?

just off the top of my head, here are some things a dishonest miner can do:

fail to include one or more transactions in the block. this is not technically 'dishonest', since the protocol does not require that all transmitted transactions be included in the current block. for example it would be considered perfectly ok for a miner to never include a transaction which does not include a mining fee in the current block. however if the transaction does have a fee (the standard behaviour) then a miner can still choose not to include any transaction it likes in a block. to do so would be to deliberately forgo a profit, and so its unlikely, but it is certainly possible. however other miners are unlikely to do the same, so they will include the transaction next time they mine a block.
appropriate unsigned funds for itself. bitcoin scripts are merely puzzles to be solved in order to spend funds. generally puzzles are signed by the sender's private key, but this is not a requirement (though all wallet software does this by default). if someone is silly enough to manually create an output script which does not contain either an OP_CHECKSIG or OP_CHECKMULTISIG opcode then anything in the transaction can be changed by the miner. for example, say someone creates a transaction with output script OP_1 OP_EQUAL then transmits this to a miner to include in the blockchain. the miner can easily complete the puzzle and appropriate these funds by creating another transaction with input script OP_1. (to verify these scripts, just put the txin and the txout in sequence OP_1 OP_1 OP_EQUAL - 1==1). and the most important thing here is that since there is no signature, anybody can modify the output script in the spending transaction, so the miner can direct the funds to the address of a private key it owns.
appropriate any SIGHASH_NONE funds. when signing a transaction, the user's wallet software will put a byte on the end of the signature in the txin script in the spending transaction. an 0x02 byte here corresponds to SIGHASH_NONE which means that all of the output scripts are ignored for the purposes of validation. so if someone sends a transaction like this then a miner can simply put their own address into all the txouts and include that modified transaction in a block, effectively sending funds to itself. however wallet software does not set signatures in this manner so someone would have to be deliberately foolish to loose funds to a miner in this manner.
alter certain transaction hashes via transaction malleability. certain bitcoin transactions are malleable. while a miner is not able to alter the amount of bitcoins you send, or the recipient of these funds, it can modify certain transaction scriptsigs (the txin script) and thereby alter the transaction hash. this occurs because the scriptsig is not signed by the private key. so the miner can alter this scriptsig as long as it does not alter the functionality. note that bip 62 (scheduled for release in bitcoin 0.11) will eliminate transaction malleability for standard scripts, however for certain non-standard scripts malleability will always be a problem. for example if the txout script being spent starts with OP_DROP then any prior stack value (set at the end of the scriptsig) is ignored and so can be altered by a miner without altering the functionality of the transaction. since transaction hashes do include the scriptsig this will alter the transaction hash. any other transactions which were expecting to spend from that hash will be temporarily frustrated and will have to figure out the new hash value to spend from (by following the transaction trail in the blockchain).


Bip32 bitcoin core wallet `hdseed` format from xprv master key I'm trying to use a mnemonic seed to generate a bitcoin-core wallet. I know core does not support bip39, but it does support bip32 and sethdseed should make it possible to use the seed generated by a given mnemonic.

What I'm trying to do is to generate a seed using https://github.com/iancoleman/bip39 and use that xprv to feed sethdseed on an empty wallet created on bitcoin core.

The main problem I'm facing is that the format required by the bitcoin core wallet is not available, and I'm not being able to generate it on any way:

I've just created a new wallet just for testing and make a dump, it reads something like:

# extended private masterkey: xprv9s21ZrQH143K3ndNedb7hus3kpzuUyAafU9zvKxgqgveg4623gViHrSrkiaweK2WfNNbdANyEa6D9GceWtiyWHPtSdyUCpVweg8A6wdqG7g

L5613pTNa7wks3DVt9HrPYDR1aBpMHn3qpxBLfQyDR4kKgaBrNRS 2019-07-14T21:57:10Z hdseed=1 # addr=32AoHsZ6AvTPxiqkACTMbMcdPhD4Xye1nM
KyAP4Jf5APLei25PbfeohPWaRNmCj2yQjwWtreqM4ixXJR23Dxo7 2019-07-14T21:57:11Z reserve=1 # addr=36DxZaj6JEXgSSdTtsN6yEdULgGrfc5A5W hdkeypath=m/0'/0'/9'
...

So it says that the masterkey given translate on the given hdseed

xprv = xprv9s21ZrQH143K3ndNedb7hus3kpzuUyAafU9zvKxgqgveg4623gViHrSrkiaweK2WfNNbdANyEa6D9GceWtiyWHPtSdyUCpVweg8A6wdqG7g
should translate in some way to:
hdseed = L5613pTNa7wks3DVt9HrPYDR1aBpMHn3qpxBLfQyDR4kKgaBrNRS

But I could not found any way to get from one to the other.

It seems that there is already an isssue on bip39, about this, without results.

I've tested using bitcoinjs-lib with the following code without luck:

const bip32 = require('bip32')
const bitcoin = require('bitcoinjs-lib')
const xpriv = 'xprv9s21ZrQH143K3ndNedb7hus3kpzuUyAafU9zvKxgqgveg4623gViHrSrkiaweK2WfNNbdANyEa6D9GceWtiyWHPtSdyUCpVweg8A6wdqG7g'

const node = bip32.fromBase58(xpriv, bitcoin.networks.bitcoin)

console.log(node.toWIF())

But it does generate 'L1UsWzEdexKrXmNaM8b4dyv4TsMHouVFgKhFANuhomHJjNbniWdx'.

You simply cannot. The HD seed is used to derive the master private key, not the other way around. This derivation uses a hash function so it only works in one direction: HD seed to master private key. Given the master private key, you cannot get the HD seed used to produce it.

BIP 39 mnemonics are used to create a HD seed which is then used to create the master private key. However BIP 39 specifies that the HD seed be created using SHA512 (within PBKDF2) so it will always output a 512 bit seed. But Bitcoin Core cannot take 512 bit seeds, so you cannot use a BIP 39 mnemonic with Bitcoin Core at all.


EasyBitcoin-PHP very slow I am trying to use bitcoins on my website. For this I use EasyBitcoin-PHP. It works good except that it is very slow. It takes about 5 seconds to load a simple script like this:

<?php
require_once 'easybitcoin.php';
$bitcoin = new Bitcoin('...', '...');
echo $bitcoin->getinfo();
?>

Is there a faster alternative than EasyBitcoin-PHP or is there a way to make it faster?

This is likely implementation specific. Bitcoind is an intensive application to run on a basic server, especially if the webapp lives on the same machine.

You should never directly connect a page's code with Bitcoin Core, for static information you should run a cronjob to update a cache every n seconds. If all you're showing is the last 10 blocks, maybe you shouldn't have every user at that moment triggering calls for the same data.

Update: It's worth mentioning that RPC responses suffer a delay whenever Bitcoin Core is syncing, whether syncing for the first time, or being switched on after a day. This is because the block verification functions block for a while.


Is there such a service as an unlimited Bitcoin wallet with an API? Well, I did tons of research and currently I'm using bitcoinlib for python to have a wallet which should be able to hold over one million addresses and occassionally broadcast transactions.

It has all the features you'd expect, but I'm concerned about performance when I use more than my current 10 addresses.

The thing is that I'm trying to make an online plattform which relies on the Bitcoin infrastructure and there could be millions of users. Also, I am concerned of how secure bitcoinlib actually is and I'm missing a neat Graphical User Interface.

Now, there are wallet services like Coinbase which also offer an API but I don't see any explanation on how many addresses they could hold or how many API requests I'm allowed to make. I've found many of those seemingly free services, so Coinbase just serves as an example.

Hence my question, is there any such thing as a free bitcoin wallet service (we're a free platform, so no budget there) which could scan let's say 100'000 addresses and notify our platform of incoming transactions within a few seconds and broadcast about 1000 transactions per minute ?

While I'm not sure of the technical requirements or limitations you have around building you platform. It sounds to me like your best option is simply running your own Bitcoin node itself. There are lots of online examples that could help you get started. I found bitcoin.org's guides particularly useful:

https://bitcoin.org/en/developer-examples
https://bitcoin.org/en/developer-reference

This will also give you benefit of actually holding the keys to the funds on your platform as well.

For monitor transaction sent to your node's wallet, I'd check out the ListTransactions RPC call, and for broadcasting transactions, you can use SendToAddress, or CreateRawTransaction, SignRawTransactionWithWallet and SendRawTransaction.

I should also add that running your node can be almost free (just need a computer running the server), and that you do not need to actually mine BTC on the node (which consumes a lot of energy & resources). Your node will just be monitoring the chain and broadcasting your transactions.


importmulti with BIP84 derivation always fails I have been trying to test importmulti with BIP84 derivation like so:

bitcoin-cli -rpcwallet=BIP84Test importmulti '[{ "desc": "wpkh([18734cbe/84'/0'/0']xpub6AC5B4KkrtMkXmzUWAiVVYWvhzwMJDX46ZJhm2tusm7SPc2KjeSqwEjLTaB8vAo7ev3zUFbGdWcX3EMy1ZQ9JxDgpc1pzBGLVpftq84naq5/0/*)#shfp59jm", "timestamp": "now", "range": [0, 99], "watchonly": true, "label": "Fully Noded Cold Storage", "keypool": true, "internal": false, "rescan": false }]'

But I always get an error:

-bash: syntax error near unexpected token `)'

I have tried replacing [18734cbe/84'/0'/0'] with [18734cbe/84h/0h/0h]

and [18734cbe/84\'/0\'/0\']

But it all returns errors. Is there anything obvious I am doing wrong?

I get the descriptor from getdescriptorinfo

EDIT:

Here is the fix which is working:

First get the descriptor using getdescriptorinfo then:

var descriptor = "\"\(result["descriptor"] as! String)\""

                descriptor = descriptor.replacingOccurrences(of: "4'", with: "4'\"'\"'")
                descriptor = descriptor.replacingOccurrences(of: "0'", with: "0'\"'\"'")

bitcoin-cli -rpcwallet=NewTest importmulti '[{ "desc": "wpkh([18734cbe/84'"'"'/0'"'"'/0'"'"']xpub6AC5B4KkrtMkXmzUWAiVVYWvhzwMJDX46ZJhm2tusm7SPc2KjeSqwEjLTaB8vAo7ev3zUFbGdWcX3EMy1ZQ9JxDgpc1pzBGLVpftq84naq5/0/*)#jun2ynxt", "timestamp": "now", "range": [0, 99], "watchonly": true, "label": "Fully Noded Cold Storage", "keypool": true, "internal": false }]' '{"rescan": false}'

result = (
        {
        success = 1;
    }
)

Very hacky but it works :)

The issue is that your hardened paths use the single quote notation which breaks the single quoting that surrounds the entire import command. You will need to escape those properly, and \' is not the way to do that. Instead, for every single quote within your import command, you need to do '"'"' - an explanation for why can be found here.

Alternatively, you can change those single quotes to h, but once you do so, you will need to recompute the descriptor checksum. But iff you give such a descriptor to getdescriptorinfo it will give you back the descriptor with single quotes (there is a pull request open to fix this) so you will need to use an external checksum tool to do this. I have a python script which can do this.

Running your descriptor with h instead of ' through that script, I get:

wpkh([18734cbe/84h/0h/0h]xpub6AC5B4KkrtMkXmzUWAiVVYWvhzwMJDX46ZJhm2tusm7SPc2KjeSqwEjLTaB8vAo7ev3zUFbGdWcX3EMy1ZQ9JxDgpc1pzBGLVpftq84naq5/0/*)#rxk7wl9c


Crashing problem when running 2 x 7950's on Corsair CX750 in mining rig I currently have 2 PC's with a Corsair CX750 PSU in both of them.  I bought 4 x Sapphire Radeon 7950's with the intention of having two in each PC. The cases are open and the GPU's have been mounted via PCI-e riser cables so they run a bit cooler away from the motherboard.

From everything I read before purchasing the components, the CX750 would have plenty of power to run 2 x 7950's at the same time, but I'm having problems running them together.

Currently I can only get a cgminer stable system (Windows 7) when running the two GPU's at intensity 16 together. Anything higher than that and the sytem crashes. However I can run individual cards at intensity 19/20 for a long time without crashing.

I've tried running GP0 at intensity 16 and GPU1 at 19, but the crashing still occurs.

I've tried swapping the cards but they don't seem to be the problem. And I've tried different combinations in each of the PC's (they use different motherboards), but the crashing still occurs.

So this IMO rules out the GPU's, the motherboards, the CPU and memory from causing any problems. Which leave the PSU and the riser cards as the possible cause.

The PC's are using Zalman cases and the wiring is nice and tidy, and the temperature are fine.

So what could be causing the problems here? I had BAMT running before I tried Windows, so I thought that might the problem. But alas not.

Surely the CX750 PSU's are up to the job? Any ideas?

PS. I'm running the mining rigs inside cases instead of an open frame because I want to use the components for actual work at a later date.  As they only have 2 GPU's in each there shouldn't be a heat issue, and the cards run at a steady 70c.

I eventually figured out this problem, and it was solved by lowering the voltage on the cards to 1100 or 1150.

Stock Sapphire 7950 boost cards are volted at 1250, and when running both cards concurrently it was making the system unstable and thus it would crash.  Even so, I would have expected a Corsair CX750 to still be able to handle them both, but it seems not.

Lowering the voltage through Sapphire Trixx makes the whole rig stable, and I can now run at 18/19 intensity without any problems. Heck I might even try 20 soon ;)

Hope this helps anybody out in the same situation.


How to push a raw transaction using BitcoinJS (and Request)? I'm using BitcoinJS to create a playground for Bitcoin transactions.
I have created the following Javascript file:

const request = require('request');
const proxiedRequest = request.defaults({proxy: "http://localhost:3128"});
const Btc = require('bitcoinjs-lib');
const TestNet = Btc.networks.testnet;
const apiUrl = 'https://testnet.blockexplorer.com/api/addr/';

let privateKey = <my private key>;
let wallet = new Btc.ECPair.fromWIF(privateKey, TestNet);
let publicKey = wallet.getAddress();
console.log("my public key:", publicKey);

let tx = new Btc.TransactionBuilder(TestNet);

let amountWeHave = 100000000; // 1.0 BTC
let amountToKeep = 90000000; // 0.9 BTC
let transactionFee = 1000; // 0.0001 BTC
let amountToSend = amountWeHave - amountToKeep - transactionFee; // ~0.1 (0.0999)

tx.addInput(<one of my input transactions>, 0);

tx.addOutput(<destination public key>, amountToSend);
tx.addOutput(publicKey, amountToKeep);
tx.sign(0, wallet);

let tx_hex = tx.build().toHex();

proxiedRequest.post({
    headers: {'content-type' : 'multipart/mixed'},
    url:     'https://testnet.blockexplorer.com/api/tx/send',
    body:    tx_hex
}, (error, response, body) => {
    console.log('error', error);
    console.log('body', body);
});

Here is my output:

my public key: <my public key>
error null
body TypeError: Cannot read property &#39;toString&#39; of undefined
 &nbsp; &nbsp;at Array.types.str (/home/bitcore/lib/bitcore-node/node_modules/bitcoind-rpc/lib/index.js:260:17)
 &nbsp; &nbsp;at RpcClient.&lt;anonymous&gt; (/home/bitcore/lib/bitcore-node/node_modules/bitcoind-rpc/lib/index.js:236:35)
 &nbsp; &nbsp;at Bitcoin.sendTransaction (/home/bitcore/lib/bitcore-node/lib/services/bitcoind.js:1791:15)
 &nbsp; &nbsp;at Node.self.(anonymous function) [as sendTransaction] (/home/bitcore/lib/bitcore-node/lib/node.js:223:27)
 &nbsp; &nbsp;at TxController.send (/home/bitcore/dev/insight-api/lib/transactions.js:290:13)
 &nbsp; &nbsp;at Layer.handle [as handle_request] (/home/bitcore/lib/bitcore-node/node_modules/express/lib/router/layer.js:95:5)
 &nbsp; &nbsp;at next (/home/bitcore/lib/bitcore-node/node_modules/express/lib/router/route.js:131:13)
 &nbsp; &nbsp;at Route.dispatch (/home/bitcore/lib/bitcore-node/node_modules/express/lib/router/route.js:112:3)
 &nbsp; &nbsp;at Layer.handle [as handle_request] (/home/bitcore/lib/bitcore-node/node_modules/express/lib/router/layer.js:95:5)
 &nbsp; &nbsp;at /home/bitcore/lib/bitcore-node/node_modules/express/lib/router/index.js:277:22

Can you tell me what's wrong with my code?
It seems to be a server problem...

Body must be a string.

You can use form instead of body.

Reference:
https://www.npmjs.com/package/request#forms


What prevents two miners from working on separate blocks which share transactions? I am just learning bitcoin and am confused on two issues.

What prevents one miner (Miner A) from creating a block including transaction X which has a transaction fee associated with it, and Miner B working on a separate block which also has the same transaction X in it. Clearly both of them cannot get the transaction fee. Does whoever solves it first get the bitcoins, and the loser gets nothing? Or are transactions "claimed" when you create a block, so others cannot also work on verifying them.
Is it possible for somebody to not have their transaction be verified in a long time? What if no miner picks up their transaction in their respective block they are working on? Or are the chances of that very low.

Thanks!

What prevents one miner (Miner A) from creating a block including transaction X which has a transaction fee associated with it, and Miner B working on a separate block which also has the same transaction X in it.

Nothing prevents that. That happens all the time.

  Clearly both of them cannot get the transaction fee.

Right.

  Does whoever solves it first get the bitcoins, and the loser gets nothing? Or are transactions "claimed" when you create a block, so others cannot also work on verifying them.

Whoever solves it and gets their block into the blockchain gets everything, and the loser gets nothing. This is not always the same as the person who solves it first.

  Is it possible for somebody to not have their transaction be verified in a long time? What if no miner picks up their transaction in their respective block they are working on? Or are the chances of that very low.

That happens all the time. The general advice on the site is to use a high transaction fee, rebroadcast your transaction if it isn't confirming, and to not depend on transactions confirming quickly.


Transfer bitcoins from one wallet to another We have started building a bitcoin exchange. Now we basically want to create and address that let users keep their bitcoin asset on that address and we will charge minimal fees to them when they withdraw it.

Now I have api key for my blockchain.info account now if we create an address for user let them deposit bitcoin and then transfer the assets to an address given by user, using api url below

http://localhost:3000/merchant/$guid/payment?password=$main_password&second_password=$second_password&to=$address&amount=$amount&from=$from&fee=$fee

Where will the fee be received?

Please suggest

The fee you are referring to is the fee paid to the miners (not to you) for the transaction.  The miner (or mining pool) who is lucky enough to solve the block is going to receive all the fees from all of the transactions on that block.  It will be unknown who will receive the fee it until the block is solved. For more information, see Bitcoin Transaction Fees.  If you want them to pay you a fee, then you have to create a separate transaction for that.


How a SegWit transaction is accepted without witness? I would like ask 2 questions.

First, as perspective of legacy node(doesn't upgrade software):
When SegWit transactions are transferred, witness data is stripped. It means that there are no signatures to proof the tx inputs in transaction propagated because there are no witness data as described above. How does the legacy node verify these transactions without the witness?

Lastly, as perspective of fresh node (did upgrade):
Regardless of SegWit, the block size can't exceed 1MB. But fresh nodes make a block which is consist of only 1MB transactions and NByte of witness(signature) data. This is very strange point because the block is already full with only transactions but there are some witness data.

Can you give point on my two questions?
I'd like to find which points are wrong in my knowledge.

How legacy node can verify them without the witness?

An example of a SegWit output is: scriptPubKey: 0 ab68025513c3dbd2f7b92a94e0581f5d50f654e7. For legacy nodes, this output looks like an anyone can spend output as there are no opcodes or verification. Such outputs do not require any signatures to spend. Thus when a legacy node sees a transaction spending a SegWit output, it does not go looking for any signatures and considers the transaction to be perfectly valid.

  Block size of 1MB

With the SegWit soft-fork, block size got redefined to 4,000,000 Weight Units (WU). In the WU calculation, transaction data (excluding segregated signatures) are multiplied by 4 while segregated signature data are multiplied by just 1. For example, if transaction data (excluding signatures) is 200 bytes and the witness data is 144 bytes, then the transaction has a WU of (200*4) + (144*1) = 944 WU. Blocks cannot breach this 4M WU criteria without getting invalidated. If there is a block with 1MB of non-signature data then it's size is 4M WU (1MB*4). Adding signature data on top of that will breach that threshold.

For legacy nodes, the block size continues to remain at 1 MB as these nodes do not query for the witness data for a SegWit transaction. If a block size exceeded 1MB with transaction data excluding signatures, then it would also exceed the 4M WU criteria as well.


How does a share help in the discovery of a new block? https://en.bitcoin.it/wiki/Pooled_mining:
A share is awarded by the mining pool to the clients who present a valid proof of work of the same type as the proof of work that is used for creating blocks, but of lesser difficulty, so that it requires less time on average to generate.

I would like to know how the proof of work with lesser difficulty will help in calculating the proof of work for a new block.

In other words, why would pools pay for shares? How do they help?

In order to find a Block, one needs to perform A LOT of tries - about 2^32 * the current difficulty. That number is so huge that solo miners rarely would be able to solve a block. A share on the other hand is a block of difficulty 1, which is at the moment a few million times easier to find.

Finding a share does not help in finding a block in any way - each hash is independent of all others. However, a share IS a proof of work done by the miner - they put in the effort to help the pool find the block. Once one miner finds a solution to the block problem, the pool earns money and can pay its miners - logically paying everyone for each share submitted. Those shares did not solve the block, but they were a proof that a miner was trying to solve a block. The more shares, the more work needed to be put.

Without shares, everyone would be essentially solo mining - there would be no way to prove that one put in the work, so there would be no reason to be paying the miners - they might be cheating after all.

A useful analogy would be lottery tickets - it is unlikely you will win, but if you live in a small town and decide to share the potential win with everyone that participates in lottery in proportion to how many tickets they bought, you would essentially have a mining pool. Every ticket, even if it does not win you anything, is worth a slice of the winnings - you had to pay for that ticket, so it's a proof that you put in the effort.


Is it possible to take advantage of FP16 for mining BTC or ALTs? I know mining uses mostly Integers, not Floating Point Ops... but still, is it possible to use Graphics Cards that support native 16bit Math for mining? Will it improve the performance in specific Algorithms?

My point is, you have DOUBLE the GFLOPS in FP16 compared to FP32, so..... computationally wise it is debatable....

No l, floating point operation are pointless, regardless of how fast they are or what precision they have.

Also, BTC is mined using ASICs since 5 years ago or so, using a GPU is a waste of time and money.


I have written a test for an open Bitcoin Core PR. Should I open a PR to the author's fork or wait for it to be merged? I have written an additional test for an open Bitcoin Core pull request (PR). Should I seek to extend the PR by forking the author's fork of Bitcoin Core and opening a pull request to his PR branch? Should I wait for it to be merged and then open a new PR? Or should I suggest it in the comments of the PR and allow the author to add it to the PR if the author is happy with the test code I have written.
This question was asked by brikk on IRC and has been paraphrased.

It depends on the situation. When the change is a few lines of code it is sufficient to show the author the patch and they will amend the pull request. You can do this using a ``` diff in the comments or link to your branch in the comments.
If it is a bigger change, to avoid the clutter of the GitHub UI you can surround it by <details><summary>patch to do foo</summary>```diff ... ```</details>.
However, if it is a really significant change you should probably open a PR to the author's fork of the Bitcoin Core repo asking to merge yourfork/yourbranch into PR-author/PR-branch.
One difference between posting the patch in the GitHub comments vs linking to your branch is that the former will continue to exist even after you delete your branch. Somebody may be curious to look at the patch years later.
This question was answered by vasild on IRC and has been paraphrased.
edit: Jon Atack adds that for commit sized proposals a reviewer generally provides a link to a commit in their fork of the Bitcoin Core repo (or even a link to a branch) and the PR author will then pull in the commit adding it to the PR. An example is here.

Rebased with four commits pulled in from @jnewbery's master...jnewbery:2020-07-split-already-have branch as well as the changes in #19611.


Transactions within orphaned blocks Scenario:

You are running a bitcoind node and listening to the incoming blocks/transactions.  You receive TX 1 which is put into your mempool.  Block A is mined, and includes TX 1, which is subsequently removed from your mempool.  Blocks B and C are mined, orphaning Block A.  Neither Block B, nor C include TX 1, so it is put back into the mempool to be included in a new Block

Question:

How exactly does the node find out that it needs to include TX1 in the mempool again?  Is TX 1 broadcast and received in the same way as when it was first broadcast to the node?  Or in other words, if I'm listening for receiving incoming blocks/transactions, will it be relayed to me a second time or does the client "know" just to put it back in the mempool?

Let me know if any of my understanding is incorrect or if you need any more clarification!

Bitcoin Core includes code which rolls back a block from the chain when it is orphaned.  All transactions from that block are checked against the new best block chain to see if they've already been added to a block or if they spend the same input as a transaction already added to a block; if they aren't---meaning they're valid transactions on the new best block chain---they're re-added to the memory pool.

The re-added transactions will not be automatically rebroadcast like a newly-received transaction, but if a remote peer sends the mempool message to the local peer, the local peer will tell the remote peer about the transaction (using a standard inventory).


Resources of a miner's reward in Bitcoin? To compensate the miner who could solve the PoW as the first one, they will receive some bitcoins as a reward for keeping  them motivated due to the costs related to mining process (electricity and hardware).

Does this reward include both following parts?

Newly minted bitcoins.
Transactions fees included in winner's block.

If yes, the second part seems logical and the coins can be provided simply through the account of the participants who submitted the transactions.

However, concerning the first part i.e. "newly minted bitcoins",

(a) What is the reason to add this complementary reward?

(b) How are those new coins minted? And how to calculate the amount of those new coins?

What is the reason to add this complementary reward?

The answer can be found in the original 2008 Bitcoin Whitepaper by Satoshi Nakamoto:

  6. Incentive

  By convention, the first transaction in a block is a special transaction that starts a new coin owned by the creator of the block. This adds an incentive for nodes to support the network, and provides a way to initially distribute coins into circulation, since there is no central authority to issue them. The steady addition of a constant of amount of new coins is analogous to gold miners expending resources to add gold to circulation. In our case, it is CPU time and electricity that is expended.

  The incentive can also be funded with transaction fees. If the output value of a transaction is less than its input value, the difference is a transaction fee that is added to the incentive value of the block containing the transaction. Once a predetermined number of coins have entered circulation, the incentive can transition entirely to transaction fees and be completely inflation free.

  The incentive may help encourage nodes to stay honest. If a greedy attacker is able to assemble more CPU power than all the honest nodes, he would have to choose between using it to defraud people by stealing back his payments, or using it to generate new coins. He ought to find it more profitable to play by the rules, such rules that favour him with more new coins than everyone else combined, than to undermine the system and the validity of his own wealth.

In the beginning, every Bitcoin wallet was a miner. Every active Bitcoin participant was financially rewarded in order get the Bitcoin community to quickly grow to a sustainable size. After some years, the difficulty of mining increases (deliberately) and mining has become a specialised activity.

  How are those new coins minted? And how to calculate the amount of those new coins?

ecavero's answer covers this well.

This reward is part of the network consensus rules. Miners follow these rules and every full node (including many wallets) verifies the correctness of published blocks, discarding blocks that don't follow the rules.

See also

https://www.mycryptopedia.com/coinbase-transaction-explained/

  is there any documentation for this information (ex. 210,000 blocks, after 100 confirmations etc)?

According to Bitcoin Wiki - Controlled Supply

  Satoshi has never really justified or explained many of these constants.

...

  Speculated justifications for the unintuitive value "21 million" are that it matches a 4-year reward halving schedule; or the ultimate total number of Satoshis that will be mined is close to the maximum capacity of a 64-bit floating point number.

...

  This decreasing-supply algorithm was chosen because it approximates the rate at which commodities like gold are mined.


How to spend from the "master_private_key": “df484533kf5mzv83892a234a44ae9z83m832987a82mqwmdkks018121204v95las9" I made a backup of an outdated command line interface BTC wallet, here is an example:
"master_private_key": “df484533kf5mzv83892a234a44ae9z83m832987a82mqwmdkks018121204v95las9"

How can I import this key into another wallet?

While you may be able to import the key into another wallet, it is better to create a new wallet with a new key and transfer all the bitcoin out of the old wallet and into the new one by making a regular bitcoin transaction on the blockchain. This eliminates all sorts of possible complications, including the security risk of disclosing the keys from your old wallet.


Is there a way to generate a brain wallet from the command line or console? Is there complete solution for console to generate brain wallet? Something like:

echo "sausage" | xxd -r -p | sha256sum | awk '{print $1}' | rmd160 -x | blablabla

I'm read this article: https://en.bitcoin.it/wiki/Technical_background_of_Bitcoin_addresses

0-1) I'm skip generation public key from private, and start with it like it was a brain wallet "sausage":

2) - Perform a sha256sum from pubkey:

# echo -n 0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6 \
| xxd -r -p | sha256sum | awk '{print $1}'
600FFE422B4E00731A59557A5CCA46CC183944191006324A447BDB2D98D4B408

3) - Perform RIPEMD-160 hashing on the result of SHA-256:

# echo -n 600FFE422B4E00731A59557A5CCA46CC183944191006324A447BDB2D98D4B408 \
| xxd -r -p | openssl rmd160
010966776006953d5567439e5e39f86a0d273bee

4) - Add version byte in front of RIPEMD-160 hash (0x00 for Main Network)

# echo 010966776006953d5567439e5e39f86a0d273bee \
| sed -e 's/^/00/'
00010966776006953d5567439e5e39f86a0d273bee

5) - Perform SHA-256 hash on the extended RIPEMD-160 result

# echo -n 00010966776006953D5567439E5E39F86A0D273BEE \
| xxd -r -p | sha256sum | awk '{print $1}'
445c7a8007a93d8733188288bb320a8fe2debd2ae1b47f0f50bc10bae845c094

6) - Perform SHA-256 hash on the result of the previous SHA-256 hash

# echo -n 445C7A8007A93D8733188288BB320A8FE2DEBD2AE1B47F0F50BC10BAE845C094 \
| xxd -r -p | sha256sum | awk '{print $1}'
d61967f63c7dd183914a4ae452c9f6ad5d462ce3d277798075b107615c1a8a30

7) - Take the first 4 bytes of the second SHA-256 hash. This is the address checksum

# echo d61967f63c7dd183914a4ae452c9f6ad5d462ce3d277798075b107615c1a8a30 \
| cut -b 1,2,3,4,5,6,7,8
d61967f6

Am I correct?

8) - Add the 4 checksum bytes from stage 7 at the end of extended RIPEMD-160 hash from stage 4. This is the 25-byte binary Bitcoin Address.

concatenate

9)  - Convert the result from a byte string into a base58 string using Base58Check encoding. This is the most commonly used Bitcoin Address form

I'm take base58 from here: https://github.com/grondilu/bitcoin-bash-tools/blob/master/bitcoin.sh

The result I have is:

declare -a base58=(
      1 2 3 4 5 6 7 8 9
    A B C D E F G H   J K L M N   P Q R S T U V W X Y Z
    a b c d e f g h i j k   m n o p q r s t u v w x y z
)

encodeBase58() {
    dc -e "16i ${1^^} [3A ~r d0<x]dsxx +f" |
    while read -r n; do echo -n "${base58[n]}"; done
}
stage24="$(echo -n 0450863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B23522CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6 \
    | xxd -r -p | sha256sum | awk '{print $1}' \
    | xxd -r -p | openssl rmd160 | awk '{print $2}' \
    | sed -e 's/^/00/')"

stage57="$(echo $stage24 | xxd -r -p | sha256sum | awk '{print $1}' \
    | xxd -r -p | sha256sum | awk '{print $1}' \
    | cut -b 1,2,3,4,5,6,7,8)"

# stage 89
echo "1$(encodeBase58 "${stage24}${stage57}")"

Bingo!

16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM

According to Wiki: en.bitcoin.it/wiki/Wallet_import_format

Private Key before importing must be converted the similar way:

declare -a base58=(
      1 2 3 4 5 6 7 8 9
    A B C D E F G H   J K L M N   P Q R S T U V W X Y Z
    a b c d e f g h i j k   m n o p q r s t u v w x y z
)

encodeBase58() {
    dc -e "16i ${1^^} [3A ~r d0<x]dsxx +f" |
    while read -r n; do echo -n "${base58[n]}"; done
}

stage12="$(echo -n "18E14A7B6A307F426A94F8114701E7C8E774E7F9A47E2C2035DB29A206321725" | sed -e 's/^/80/')"
stage35="$(echo $stage12 | xxd -r -p | sha256sum | awk '{print $1}' | xxd -r -p | sha256sum | awk '{print $1}'  | cut -b 1,2,3,4,5,6,7,8)"

echo "$(encodeBase58 "${stage12}${stage35}")"

Now, I still have an question: How to make brain wallet like "sausage"?

Answer was here: https://en.bitcoin.it/wiki/Wallet_import_format

To make brainwallet need to take a sha256 of password:

# echo -n 'yourbrainwalletpassword' | sha256sum
8abe468e0d5a814c644d9517ae35b36666d554b7bd682fa28c39e90d0cb5f91a

I've write a little bash script:

declare -a base58=(
      1 2 3 4 5 6 7 8 9
    A B C D E F G H   J K L M N   P Q R S T U V W X Y Z
    a b c d e f g h i j k   m n o p q r s t u v w x y z
)

encodeBase58() {
    dc -e "16i ${1^^} [3A ~r d0<x]dsxx +f" |
    while read -r n; do echo -n "${base58[n]}"; done
}

[ -z "$1" ] && echo "Usage: ./script.sh privkey" && exit 1

privkey="$1"

stage12="$(echo -n "$privkey" | sed -e 's/^/80/')"
stage35="$(echo $stage12 | xxd -r -p | sha256sum | awk '{print $1}' | xxd -r -p | sha256sum | awk '{print $1}'  | cut -b 1,2,3,4,5,6,7,8)"

echo "$(encodeBase58 "${stage12}${stage35}")"

Use this script against sha256 sum:

# bash script.sh 8abe468e0d5a814c644d9517ae35b36666d554b7bd682fa28c39e90d0cb5f91a
5JsPbHfVB7FeD6gGWoaQv6khRsasTJDK1tAiJ4TxgyWJLcjfgNa

Now, I can import privkey to the wallet.dat:

# bitcoind importprivkey 5JsPbHfVB7FeD6gGWoaQv6khRsasTJDK1tAiJ4TxgyWJLcjfgNa "yourbrainwalletpassword"
# bitcoind getaddressesbyaccount "yourbrainwalletpassword"
[
    "1Gu3HZDq6YEXfxwDC3A3EhDfEVAeCijbEt"
]

According to wiki, there are higher and lower borders.

  Nearly every 256-bit number is a valid private key. Specifically, any 256-bit number between 0x1 and 0xFFFF FFFF FFFF FFFF FFFF FFFF
  FFFF FFFE BAAE DCE6 AF48 A03B BFD2 5E8C D036 4141 is a valid private
  key.

However, I'm successfully import priv key

FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

After a while, bitcoind tell me:

error: {"code":-1,"message":"CKey::GetPrivKey() : i2d_ECPrivateKey failed"}

Hope it would be helpfull.

Thank you !


Bitcoin Script tutorial Are there any tutorials with examples on Bitcoin Script: from basics to complex scripts?


How do Lightning channels interact with the blockchain? Does opening a channel mean that a 2-to-2 multisig address (3xxxx) is created? And then both parties put money into the address? What if someone pays money to the address on main chain while the channel is open?
Does closing a channel mean that a transaction is made which splits the money based on agreement:

multisig: signature1,2(preTran) redeemscript

outputscript:  pay to A
               pay to B

Does opening a channel mean that a 2-to-2 multisig address (3xxxx) is created?

Yes. But it's not always a 3... address. Such addresses must be segwit, and there are two types: nested (3... address) and native (bech32 addresses, bc1..).

  And then both parties put money into the address?

For now, only one party puts money into the address. But ideally both will be able to in the future. This is only done for simplicity right now.

  What if someone pays money to the address on main chain while the channel is open?

It doesn't matter because Bitcoin does not use a balances or accounts system. Spending Bitcoin means that you are spending from a previous transaction output. So the commitment and closing transactions in a channel will refer to a specific transaction output. That output is completely unaffected by additional payments to an address. Likewise such payments will not effect the channel state.

  Does closing a channel mean that a transaction is made which splits the money based on agreement

Yes. The money is split according to the most recent channel state, i.e. the balance of each party.


How does the market bubble? Before the burst due to massive DDOS attacks on most Bitcoin trade sites, the market price rose from 30 USD in January 2013 to over 250 USD in April.

The mechanism of collapse - the DDOS attacks - is pretty clear and transparent. I wonder though, what mechanisms, machinations, influences or other external sources influenced the market that caused such bubble growth in the first place.

It appears the market is still vulnerable to such (or similar) mechanisms (currently we seem to observe a similar growth), and I'd really like to learn how such events work - how do such bubbles of price appear and grow? Are they natural element of the market, self-propelling machines of enthusiasm of masses, possibly following some global events/trends, or are they created by subtle, or less subtle manipulations?

The short answer is momentum.

Imagine for a second that you are a neutral observer and you see that the price of Bitcoin has been rising over the past few days. Even if you have no reason to think it will continue to rise over the long term, it makes sense for you to buy Bitcoins. After all, it's unlikely that the rise will end just as you buy, and if the price starts to drop, you can always sell. Your buying puts upward pressure on the price, maintaining the momentum.

Now imagine the price is falling. Even if you believe Bitcoins will go up over the long term, it makes sense to sell now. You can always buy your Bitcoins back for less if the price starts to rise. Your selling puts downward pressure on the price, maintaining the momentum.

So, essentially, if the price displays momentum, it's logical to assume it will continue to do so for at least a short period of time, and thus it's logical to perform a transaction that contributes to that momentum.

Negative publicity can start downward momentum. Positive publicity can start upward momentum. Momentum can't really be maintained forever though and when upward momentum stops, everyone fears that downward momentum will begin. They sell to take advantage of the high price and start downward momentum. The same is true when downward momentum ends -- everyone who is bullish over the long term wants to take advantage of the low price. This starts upward momentum.

Just be aware, trading on momentum is essentially a zero-sum game. Everyone's trading profit is someone else's loss. You are probably not "smarter" than everyone else and so are just as likely to be a winner as a loser.

However, the long term upward trend is not a zero-sum game and can mean that there are more winners than losers. Essentially, people who see Bitcoins as an investment are hoping that the Bitcoin system creates real value over the long term.


Is disclosing an index used for generating BIP32 addresses insecure? I'm writing an e-commerce system that uses BIP32 to generate addresses. I was thinking of using the order number (which is shown to the user) to as the index for generating the address to pay to.

Would doing this help someone trying to steal my money, or help someone trying to link my addresses together?

I wouldn't expect stealing to become easier. BIP32 uses low incremental integer numbers, which are easily brute forceable if not predictable.

Same reasoning for linking addresses i guess.

I'll leave a real answer up to someone more knowledgeable though.

One consideration I'm sure you thought about is that you need to make sure the order number is unique (no address reuse). Even over multiple years (unless you use the year as one of the other HD indexes, I guess).

One downside is that if you ever load the private key into another wallet it probably won't find your money as it doesn't know your numbering system. Maybe that's an upside actually as it ads a layer of obfuscation to protect you from theft. Slippery slope though.

(Meant to type this as a comment instead of an answer, but i guess I'll leave it unless a better answer says it actually is dangerous.)


Processing my own transactions I was reading this information regarding the MEMPOOL:
https://coinsutra.com/bitcoin-mempool/

Suppose I have a transaction that contains a certain number of entries (ex: 300). In addition, suppose I have 7 other transactions - each having 50 entries.

Suppose I offer $1 to the miner for each transaction to be processed.

When broadcasting a transaction, it goes to the MEMPOOL first (so that a miner can pick it up for processing)?

It is my understanding that the transaction would not be processed immediately because the fee is too low.

If that is the case, then can one have a bitcoind server of their own, pull out the transaction, process it (or the entries in it) and then create a block to be added to the blockchain?

It is my understanding that the transaction would not be processed immediately because the fee is too low.

That is roughly correct. Miners select transactions based on the fee per byte, and lower fees will take longer to be included in a block

  If that is the case, then can one have a bitcoind server of their own, pull out the transaction, process it (or the entries in it) and then create a block to be added to the blockchain?

Technically, you could mine your own transaction. Practically, this is no longer feasible. The mining process is too difficult for non-specialized hardware since the creation of ASIC miners, and even with ASICs, you would need thousands to mine at a speed where you could feasibly find a block all by yourself.

This approach is indeed taken by some mining pools for paying out their miners. They will not broadcast their payout tx, and include it when they mine their own block, either for a 0 fee, or an arbitrary fee (since they mine the block, they just get the fee back). However, it is not possible to do this as an individual user.


ELI5: How do I import keys from blockchain.info backup into MultiBit 0.5.18 So, blockchain.info is holding my account hostage. My phone with my 2FA was lost (and remotely wiped) and they refuse to remove the 2FA on my account to get access. I have a recent backup of my keys available but the file does not appear in the file browser (wallet.aes.json) when I select import keys. Everything I've found on the internet says to change the file filter, but there isn't a way to do that in version 0.5.18 that I can plainly see. Can someone please drop some instructions here, step-by-step so I can accomplish a recovery of my coin without the help of the ridiculous folks at blockchain.info?

Thanks in advance!

Support for importing blockchain.info wallets was removed in MultiBit 0.5.18. MultiBit still hosts their old releases, however, so you could simply download 0.5.17, import the blockchain.info wallet, and then upgrade to 0.5.18.

You could also import the backup into a new blockchain.info account. Once it's there, you could send it to a MultiBit address or make another backup in an easier-to-read format (e.g. unencrypted export). You could then follow the instructions here to import those private keys into MultiBit 0.5.18.


FirstBits address shortening algorithm Is the algorithm used by FirstBits to create their shortened addresses described anywhere, so that anyone wanting to automatically generate them could generate the same result as asking the website for each individual address?

For example, when a block explorer like http://blockchain.info/ wants to include FirstBits for every address, how does it generate them fast without overloading the FB website?

Obviously you would normally use a database with an efficient algorithm, but conceptually it goes like this:

1) You find the first instance of the account ID in the blockchain. If the account ID does not appear, stop. The account has no firstbits.

2) As a safety, make sure that there are at least six blocks after the block in which the account ID first appears. Otherwise, you risk having the firstbits change if that block is invalidated.

3) You search all previous transactions for the account ID that matches this account ID to as many characters as possible.

4) You output one more character from the account ID than the number of characters matched in step 3. This is the ID's firstbits.

So if the longest match prior to the first appearance of "13xdjsNsf5zJV9tpbxL6iirp1WdettzwyB" starts "13xdjq.." (and thus matches 5 characters), the firstbits for "13xdjsNsf5zJV9tpbxL6iirp1WdettzwyB" is "13xdjs" (the first 6 characters).

To go the other way, you search every account ID that appears in every transaction in the hash chain in appearance order. The first ID whose start matches all of the firstbits is the account ID for that firstbits.


Why isn't Bitcoin private by default? Bitcoin is not fungible...so why haven't the Bitcoin core devs upgraded the protocol to make it private by default?

They are trying to add new features that would help with privacy! There is an upgrade proposal known as Taproot that would come with features to enable additional transaction privacy in Bitcoin.
Note, however, that major changes like this to Bitcoin are much more difficult than they are in smaller altcoins, simply because a significant amount of infrastructure must be updated, and getting so many different people and organizations to agree to a major update is challenging, although necessary to avoid a fork in the network. Also, there is an effort to keep updates backwards compatible with existing infrastructure, which limits the extent to which major changes like this are possible.


Reusing bitcoin hw wallet infrastructure as a PGP replacement? A lot of people who own Bitcoin are already know how to securely generate, store and use their BIP32 + BIP39 wallets, and own hardware wallets.
Are there any existing projects/standards trying to bolt on PGP-like capabilities on top of this existing secure-key infrastructure?
I imagine, that in a perfect world people would just generate their 24 words once in their whole lifetime, and then export some applicatin/device specific derived keys to other (potentially less secure) devices and use these for things like git commit signing, encrypted communication, 2FA, etc. . When the keys get compromised, or it's time to simply cycle them, they could use the determinism to switch to new keys (by just bumping the sequence number in the derivation path) which were known well in advance, but which were never exposed to anything other than the devices handling the master key. Seems like it would simplify and unify a lot of secret-key management, by piggy-backing on what's already being done in Bitcoin.

While I'm not sure how far the development of hardware wallet support for Lightning is, there is an E2EE messaging protocol called "Sphinx chat" based on the Lightning Network. Some HWW also function as smart cards for PGP and general password manager. I'm not aware of a project that aims to provide an email encryption system.


ScriptSig - what am I signing exactly? So the scriptsig field in the transaction, is created with the signature and public key. In order to create the signature, we need the R and S values of a ECDSA signature. I figured how to sign a string with Secp256k1, but I haven't figured out exactly what am I signing.

You are signing a specially modified version of the transaction itself. The modified transaction involves replacing the scriptSig field temporarily with the scriptPubKey from the transaction output being spent, and leaving all other inputs' scriptSigs empty, and then appending a 4 byte signature type code. The transaction is then hashed twice with SHA256 and the final hash is signed.

See this question for more info: How to redeem a basic Tx?


Selling BTC from BitMinter I have started mining with BitMinter.com and am nearing a complete bitcoin. I have searched for hours for my account/wallet address so I can move bitcoins from BitMinter to an exchange. I can't seem to find that, or any way to sell any bitcoins I have worked for. How do I get my bitcoin from BitMinter to somewhere like fastcash4bitcoins.com?

Bitminter has an auto cash out function. On the Account homepage, you can set a Bitcoin address to which your coins are deposited as soon as you reach a certain amount.

I assume you already have a Bitcoin wallet somewhere that can give you an address to enter in the auto cash out form. If you don't, visit this page on the Bitcoin website and create a wallet. (I recommend you for simplicity and security considerations to choose a web wallet or a fast wallet like Multibit or Electrum.)

Once you set up auto cash out, you will receive your bitcoins in your wallet. They you can create an account on an exchange that allows you to sell bitcoins. They will give you a deposit address to which you will need to send your bitcoins using your wallet. As soon as the deposit arrives, you can sell your coins and withdraw the cash from the exchange site.


Why is my transaction not confirming after a month? My Bitcoin transaction 016a647fdb45d0f1a679ae7b3b4465ced76b817f63595c37e3214d63098ddd47

is still unconfirmed. Although I do realise this transaction was made with a low fee 10.044 sat/B, it is not as low that the transaction should not confirm. According to data provided on https://bitcoinfees.earn.com/, this transaction should still confirm within a day.

I tried everything already. I have heard a reset of the wallet may work, however I do not have an actual wallet, but only use the Blockchain.info wallet, where I believe a restart of the wallet is not an option. I also tried rebroadcasting the transaction with various websites, however none of it worked.

What am I supposed to do at this point, that my coins have been stuck in limbo for a month now?

The simplest thing you can try is to rebroadcast the transaction and see if you get lucky. You can search for a Bitcoin accelerator and use some of the free ones.

Failing that you can ask a mining pool for some help. For example ViaBTC offer a service described here https://www.cryptocompare.com/coins/guides/how-to-accelerate-your-bitcoin-transaction/

And failing that you can create a Child Pays For Parent (CPFP) transaction to increase the fee paid https://bitzuma.com/posts/how-to-clear-a-stuck-bitcoin-transaction/


With peerblockfilters=1 hundreds of "btcwire 0.5.0/neutrino" connections are downloading TB from my Bitcoin node I run Bitcoin Core 0.21.0 from a data center, unmetered, with compact block filters enabled (blockfilterindex=1 peerblockfilters=1).
Soon after the restart, I get a huge number (140-200) of connections identifying as btcwire 0.5.0/neutrino, from all over the world. They are responsible for vast majority of download bandwidth (90%+).
This only happens when node is signalling CBF support via peerblockfilters=1.
I am aware "Neutrino" is a proof-of-concept light wallet using CBF but it doesn't explain neither the vast dominance in terms of connections number (~75%), nor in terms of bandwidth (90%+).
Incidentally, "Neutrino" is also a surveillance company owned by Coinbase :)
Any guidance is welcome!

It appears that btcwire is the Bitcoin p2p module of btcd and neutrino is Lightning Labs's implementation of BIP157/158 (compact client-side block filters (CBF)). I suspect that the agent identifier btcwire 0.5.0/neutrino indicates LND (Lightning Network Daemon) instances which are configured to allow or prefer CBF for synchronization. Given your experience and since CBF support was only added to Bitcoin Core in 0.21.0, it looks like the demand for the CBF network service far outstrips the few listening nodes that provide the CBF network service at this time.
I expect that the load will be distributed better as more Bitcoin Core 0.21.0 listening nodes come online.


How can I create a private blockchain with my own transactions? I need to create a transaction where Alice can write a message and send it to Bob, for example: Alice sends a "Hello" message to Bob, to achieve this, Alice creates a transaction and sends all her interconnected blockchain nodes. Each node validates that transaction (with some policy) and if a valid transaction sends the transaction back to all its connected nodes. Then the mining nodes add it to a block and also add that block to the blockchain. To be able to achieve all this procedure I have to modify some code blockchain (a code poorly documented). Would you know if it is feasible to do? Would you know if there is a place that can help me achieve it? Regards!.

Here there is a repository that allows you to add all kinds of data to a blockchain.
If you look at the "Data" field of each block you can add your own transaction in JSON format.


What are the chances that Bitcoin changes its proof-concept one day? Is it realistic/possible that the bitcoin core team make a new Bitcoin Improvement Proposal (BIP) on day in which they propose to change Proof of Work (POW) with something else (proof of stake for example)?

And yes, I know that POW was already part of "Satoshi Nakamoto's" paper Bitcoin: A Peer-to-Peer Electronic Cash System.

POW takes already more energy than smaller countries and it's proved that there are cheeper solutions (the existence of many alt-coins proves that).

Do you think, it's realistic? Maybe far in the future? Maybe without a hardfork?

Chances of a replacement are very low. In fact, this is actually mentioned in the bitcoin community maintained wiki, which seems quite official.

See the "Prohibited Changes" list, where adding an alternative proof algorithm is listed under the "disputed" category.

  Disputed:
  Adding alternatives to Proof of Work such as Proof of Stake. This could change core bitcoin too much, but with widespread agreement of some sort might be possible.

Note that they talk of adding, not replacing.


Why do lightning invoices expire? I'm considering the development of a lightning app, and I'm trying to make it non custodial.

I was thinking on pre-generating invoices for all users every x time to make things simpler. To do that I'd need to extend the expiry date.

I tried to look up why do lightning invoices expire, and I couldn't find a clear answer.

Why do lightning invoices have an expiry date?

Is it to ensure that they are not kept forever in the receivers DB? or is there another reason?

The bolt 11 which specifies invoices does not give a rational for this design choice therefor - unless one of the people who build it come along - I can only give an educated guess:

So first of all if invoices were valid for an arbitrary time the recipient would have to keep an arbitrary amount of preimages running eventually into memory / Harddisk issues. I guess this is the single most important reason.

As another one lightning payments and routing with htlcs is an Atomic process it either works or it doesn't. Giving a constrained timebound you can decide afterwords for sure what the result was. If the expiry is arbitrary it could always be the case that the payment has just not been initiated yet.

Last I can imagine that sending nodes would eat up htlcs and the recipient might have already deleted the preimage (without expiry time) In this case the network also has unnecessary load.

Excited to see if other reasons pop up and excellent question


How exchanges generate transactions for all cryptocurrencies and send it to their network nodes? This is an important question for me, I know some Bitcoin wallets like blockchain.info are a Full Node, but exchanges which support so many coins, how do they create transactions per cryptocurrency? do they have a full node client for per cryptocurrency?

Just Bitcoin needs 170 GB space disk!

Are exchanges using third-party servers and apis?

For an exchange, 170GB is not a lot, at all. In fact, it's a laughably small amount. Even on an SSD (which is not necessary), the storage cost would be about $100. Big exchanges might make $1M in revenue every day. Operating a node (or ten) is a complete non-issue.
You seem to be thinking that if Bitcoin's blockchain is 170GB, then so are the others. But Bitcoin is the most popular cryptocurrency, and it has way more transactions than any other (with the possible exception of Ethereum, which is more wasteful and has high traffic due to the ICO hype). The blockchains for most cryptocurrencies are tiny in comparison, and the sum total storage shouldn't be more than, say, 1TB (again, tiny for any large business). A single machine could run nodes for all coins.
SPV clients (like Electrum for Bitcoin) offer a middle ground between running a full node, and relying completely on a 3rd party service.
Ultimately, every exchange decides how to set up its infrastructure. It might run a node. It might not. There's no real way to answer this in general, this is something which should be asked of each specific exchange.


What are the alternatives to downloading the 6GB block chain? I hail from a state where bandwidth is yet at a premium. Typical download speeds, in my experience as a dialup ADSL user, range from 10KBps up to 70KBps. Inclement weather may cause packet loss if not outright link failure. Over the last few months several ISP hereabouts have responded to service requests speaking of issues at the gateway.

Granted the issues I face are local but my intent here should be pretty clear - What are the alternatives to downloading the multi-GB (and growing!) block chain?

Alternatives to downloading the data yourself in reference client:

Take your computer to somewhere with Internet that you can be for several hours, perhaps a friend or relative's house, or a library or coffee shop.
You can employ bootstrap.dat by having someone else download it and give it to you somehow. Then you'd only have to get caught up and download ~ 2 GB. Alternatively, you can have that same person create for you a bootstrap.dat that is 100% up to date, as that bootstrap is behind by a few months.
Use a web wallet. You'll be sacrificing some security for the convenience, though.
Use an SPV client, such as Multibit or Bitcoin for Android, that only has to download data related to your addresses. You'll be sacrificing the ability to verify any payment. Many people find this acceptable.
Use a server-reliant client such as Electrum, where your client must download virtually no data. You'll always rely on a central server for transmission and verification of transactions, but your private keys will always be stored locally.


Bitcoind lose the latest blocks when synchronize I've the latest version of Bitcoin-qt (bitcoin.org 0.15.1). My problem is I lose info about latest blocks with delay about 3-5 minutes. When my GUI or bitcoind started sometimes for a short time I get this warning in debug.log:

  2017-12-26 19:42:52 Timeout downloading block
  000000000000000000594fca8fc2e2e6f7baff5ac96a10d94f33ae3b0f4e1971 from
  peer=12, disconnecting

After that I lose latest new blocks for a while, and the easier way is restart bitcoind.

Is it could be because of that my ports is not forwarding and I have only 8 connections? What means this warning, I can't google it?

My problem was I didn't configure nodes settings and use unhealthy default nodes. When I specified "addnode=closestnodesIP" my problem was solved.


Calculating "total received" and balance by an address This is something which I think should be simple but it's driving me crazy. See for example this list of transactions associated with an address:

https://blockchain.info/address/1EZK42jGEJVniyBn1wXrUx92wzyUkYB8kJ?format=json

What I want to do is simply arrive at the same total_received, total_sent and balance stats for the given data.

An obvious requirement is to not count the "change" as a new payment to the address. My idea was to simply sum all the outputs in transactions whose inputs are not from the same target address, e.g. if a transaction has an input (or multiple inputs) from A and outputs to B and A, treat this output as change and don't include it in the sum -- only this doesn't produce the same sum as blockchain.info! In this case, it produces 158.11536395 vs 251.24164662. It looks like I'm missing something?

The next step would be to take the list of outputs produced by the first step, and see which are spent and which are not. The sum of the unspent outputs is the current balance. Is this correct?

Anyone?

As the other answer has noted, balances don't technically exist for a specific address. This is because there may be many outputs that are addressed to an address you own, but you can only spend these outputs discretely (I.e. You can say deduct x from my account, you can only say deduct this output amount which was previously awarded to this address).

We can define a pseudo-notion of a balance, though, let's call it the address' unlock-able value (UV), because the owner of the private key for that address can unlock some # of coins by knowing the private key for that address.

Now, to calculate the UV balance, total received, and total sent of an address, you follow this pseudo-algorithm:

Address a;
Uv = 0;
Received = 0;
Sent = 0;
For each (output in blockchain):
    If (output is unlock-able by owner of address a):
        Received += output.amount;
        If (output has been spent):
            Sent += output.amount;
        Else:
            Uv += output.amount;

At the end of all the outputs in the blockchain, the Uv amount will have a value that is similar in concept to a balance. But here we can also see why this is a very tricky notion:

How do you know if an output is unlock-able by owner of address? Sometimes only the key holder themselves can know.
What if an output can be unlocked by, say, 1 of a set of 3 keys? Do you credit the balances of all three keys, or none?

I suspect the way blockchain.info does this is by basically running the above pseudo algorithm (although much more optimized and using a database), but only considering outputs in the Pay-to-Pubkey-Hash format.

Alright, through contacting the blockchain.info support team and some testing I've found that the problem was the API link given in the question is both paginated and rate limited. The following PHP code produces the same values that blockchain.info shows on their site, assuming you don't run into rate limiting problems.

<?php

// Method: POST, PUT, GET etc
// Data: array("param" => "value") ==> index.php?param=value

function CallAPI($method, $url, $data = false)
{
    $curl = curl_init();

    switch ($method)
    {
        case "POST":
            curl_setopt($curl, CURLOPT_POST, 1);

            if ($data)
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
            break;
        case "PUT":
            curl_setopt($curl, CURLOPT_PUT, 1);
            break;
        default:
            if ($data)
                $url = sprintf("%s?%s", $url, http_build_query($data));
    }

    // Optional Authentication:
    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    // curl_setopt($curl, CURLOPT_USERPWD, "username:password");

    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

    $result = curl_exec($curl);

    curl_close($curl);

    return $result;
}

$address = "1EZK42jGEJVniyBn1wXrUx92wzyUkYB8kJ";
$offset=0;
$txs = array();

while (true)
{
    $val = json_decode(CallAPI("GET", "https://blockchain.info/address/$address?format=json&limit=10&offset=$offset"), true);
    if (count($val["txs"]) == 0)
        break;
    else
        $txs = array_merge($txs, $val["txs"]);

    $offset += 10;
}

$uv       = 0;
$received = 0;
$sent     = 0;
$nrefs    = 0;

foreach ($txs as $tx)
{
    $ininputs = false;
    $totalin = 0;
    foreach ($tx["inputs"] as $input)
    {
        if ($input["prev_out"]["addr"] == $address)
        {
            $ininputs = true;
            $nrefs += 1;
            $totalin += $input["prev_out"]["value"];
        }
    }

    $inoutputs = false;
    $totalout = 0;
    foreach ($tx["out"] as $output)
    {
        if ($output["addr"] == $address)
        {
            $inoutputs = true;
            $nrefs += 1;
            $totalout += $output["value"];
        }
    }

    $uv       += ($totalout - $totalin);

    // $received += $totalout;
    // $sent     += $totalin;

    if ($ininputs && $inoutputs && $totalout >= $totalin)
    {
        $received += $totalout - $totalin;
    }
    else if ($ininputs && $inoutputs && $totalout < $totalin)
    {
        $sent += $totalin - $totalout;
    }
    else if ($inoutputs)
    {
        $received += $totalout;
    }
    else if ($ininputs)
    {
        $sent += $totalin;
    }
}
echo "\n";

echo "nrefs    : " . $nrefs . "\n";
echo "uv       : " . $uv . "\n";
echo "received : " . $received . "\n";
echo "sent     : " . $sent . "\n";


Anyone successfully mining bitcoins in Testnet3? I've been chugging away on multiple machines for days, and while I get a lot of 'unconfirmed' and 'orphaned' and 'immature' blocks, nothing lands in my wallet.

Anyone else having this problem?  From the blockexplorer site, I can see blocks being mined as recent as today - I wonder if some are mine, and they're somehow sent to /dev/null?

If anyone can point me towards a real solution here, I can repay you with some counterfiet BTC.  :D

"Immature" blocks should be valid, but they require 100-120 confirmations before they can be spent.  On testnet this may take up to 40 hours or so.  If you have the block hash (it should be in debug.log if not elsewhere), you ought to be able to find these blocks on http://blockexplorer.com/testnet and see them linked into the block chain.

"Orphaned" blocks can happen if you find a block, but unbeknown to you, someone else has already found a block linked to the same parent.  This seems to be more common on testnet, which doesn't seem to be very efficient at propagating newly found blocks.  (I don't know why, perhaps there are a lot of experimental clients which don't relay blocks properly.)  This can especially happen due to the 20-minute rule on testnet, whereby if no block is found within 20 minutes of the last one, the difficulty temporarily drops to 1.  When this happens, typically lots of people find a block within a few seconds, and there is a race to see whose will be propagated and accepted first.  So every time this happens, there's a good chance you'll find a block at difficulty 1, but an even better chance that someone beat you to it, and your block will be orphaned.


How to keep Bitcions when reinstalling OS from fresh I have the official Bitcoin wallet and I would like to do a fresh install of everything on the computer. How can I save my Bitcoins (and hopefully block chain)?

(I suppose you have the Bitcoin-Qt client.)

Taking a backup of the Bitcoin folder will do it.

Copy the folder to an external hard drive of a different partition.
Reinstall your system.
Install Bitcoin-Qt again.
Move the folder back.

Note that to keep your bitcoins, only the wallet.dat file is required. But when you copy the whole folder, you will probably not need to sync with the network again.


Nbitcoin's BitcoinPubKeyAddress not recognizing native segwit addresses I'm trying to build a transaction using Nbitcoin. When I run this line there is an error parsing the address. It runs fine with segwit addresses starting with a 1, but not native segwit.
Using System;
Using System.Text;
Using NBitcoin;

static void Main(string[] args) {

    var wallet = new BitcoinPubKeyAddress("bc1q....", Network.Main); //throws error
}

Error: System.FormatException: 'Invalid base58 data'
Is there a way to use native segwit with Nbitcoin? Thanks

It runs fine with segwit addresses starting with a 1, but not native segwit.

Prefix 1 is used by legacy addresses. You can check the other prefixes used here: https://en.bitcoin.it/wiki/List_of_address_prefixes

Is there a way to use native segwit with Nbitcoin?

Replace BitcoinPubKeyAddress with BitcoinWitPubKeyAddress in your code for using native segwit addresses


Best way to safely host a high volume online transactional wallet? I am looking at starting a business that will send and receive a large amount Bitcoins in a semi automated manner using API's. I was wondering what is the best way to do do this in a secure way to limit my exposure to hacking? My initial thoughts are as follows:

1) Clearing Wallet: have a clearing wallet that holds say 10% over my expected daily amount of bitcoins that will be used for sending and receiving bitcoins. Any time this wallet contains more than my 10% configured amount, a bot will move the excess bitcoins to another offline wallet.

This wallet will be backed up on 3 USB drives using double encryption and be hosted at blockchain.info (two factor authentication will be used to access this wallet at blockchain.info)

2) Emergency Paper Wallet: This is a paper wallet and will be used to hold an additional days worth of bitcoins. If for any reason I need to top up my Clearing Wallet this will be used and then discarded. (one time use only)

3) Cold Storage Wallet: This is were the excess coins from my clearing wallet will be forwarded to and keep offline. This wallet will be created using a bootable USB/CD OS to ensure the machine it is created on is not compromised. This wallet will then be used to make a number of Emergency Paper wallets that will be used to top up the clearing wallet if funds are ever running low. (this wallet will only ever be accessed using a fresh bootable OS)

Is this a good way of ensuring I have a low exposure to being hacked or is there a better way of doing this?

It seems to be a good approach. The fundamental is keep a little bit "hot" to high liquidity and keep the rest into USB stickers + papers and if possible keep it safe in a vault or bank. Also, keep the anonymity and security of who has the access to the Bitcoins. Remember: Bitcoin is real money, and if you are working with a lot of money, it can be dangerous, someone can try to extort you to reveal all secret.

Don't forget too that USB stickers are volatile in long term by definition, and are not 100% safe. CD and DVD can scratch or can degrade over time. So, the paper is fundamental; keep it in a clean and dry place. Remember also to generate the wallet keys in a offline computer (installed from zero if possible). Read this article: How to set up a secure offline savings wallet.

There is a nice article about it here: Coinbase now storing 87% of customer funds offline


How do I find out which wallet fits which client? I found a really old Bitcoin wallet, a wallet.dat file, and tried to open it. Bitcoin Core told me that the wallet is corrupted. But I also found out that different clients make different wallets, so they aren't supposed to be compatible with each other. How do I find out which client I need to use to be able to open this wallet?

Bitcoin Core is the only software that uses a file called wallet.dat, as far as I know.


Is there anyway I can recover my passphrase? I have a wallet for the bitcoin qt wallet but I accidentally deleted the only copy of my encryption passphrase... I have read about something called brute force but I'm not entirely sure on how its code is used. Can anyone help me please!? I am desperate to recover my bc!

It's rather implausible unless you remember a good deal of the password already, or you are certain that it followed a particular pattern. Even on a good processor you might only be able to try 10 variations a second, which is uselessly slow for anything in the password cracking world.

It needs to be strong, the encryption is designed keep your coins safe.

How much is at stake? Recovering them might not even be worth the time expenditure.


Private key recovery? I've seen many peoples are actually recovering their private keys using signatures pub key r s z values etc , anyway , I've found a way to recover it but using transaction  hex i can't found the identical R value , is there any other way to recover it from r s z ? or is it possible to recover any private key using random R values ?
I have tried this method , In my case the values of R are different , this method is just for example having same/identical R value.  ;

def inverse_mod( a, m ):
    """Inverse of a mod m."""
    if a < 0 or m <= a: a = a % m
    # From Ferguson and Schneier, roughly:
    c, d = a, m
    uc, vc, ud, vd = 1, 0, 0, 1
    while c != 0:
        q, c, d = divmod( d, c ) + ( c, )
        uc, vc, ud, vd = ud - q*uc, vd - q*vc, uc, vc

    # At this point, d is the GCD, and ud*a+vd*m = d.
    # If d == 1, this means that ud is a inverse.
    assert d == 1
    if ud > 0: return ud
    else: return ud + m

def derivate_privkey(p, r, s1, s2, hash1, hash2):
    z = hash1 - hash2
    s = s1 - s2
    r_inv = inverse_mod(r, p)
    s_inv = inverse_mod(s, p)
    k = (z * s_inv) % p
    d = (r_inv * (s1 * k - hash1)) % p
    return d, k

p  = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141

# this case is right
public_key=0x04dbd0c61532279cf72981c3584fc32216e0127699635c2789f549e0730c059b81ae133016a69c21e23f1859a95f06d52b7bf149a8f2fe4e8535c8a829b449c5ff
r =0xd47ce4c025c35ec440bc81d99834a624875161a26bf56ef7fdc0f5d52f843ad1
s1=0x44e1ff2dfd8102cf7a47c21d5c9fd5701610d04953c6836596b4fe9dd2f53e3e
s2=0x9a5f1c75e461d7ceb1cf3cab9013eb2dc85b6d0da8c3c6e27e3a5a5b3faa5bab
z1=0xc0e2d0a89a348de88fda08211c70d1d7e52ccef2eb9459911bf977d587784c6e
z2=0x17b0f41c8c337ac1e18c98759e83a8cccbc368dd9d89e5f03cb633c265fd0ddc
print "private:%x\n random:%x" % derivate_privkey(p,r,s1,s2,z1,z2)
print

# this case can be wrong
public_key=0x02a50eb66887d03fe186b608f477d99bc7631c56e64bb3af7dc97e71b917c5b364
r =0x0861cce1da15fc2dd79f1164c4f7b3e6c1526e7e8d85716578689ca9a5dc349d
s1=0x6cf26e2776f7c94cafcee05cc810471ddca16fa864d13d57bee1c06ce39a3188
s2=0x4ba75bdda43b3aab84b895cfd9ef13a477182657faaf286a7b0d25f0cb9a7de2
z1=0x01b125d18422cdfa7b153f5bcf5b01927cf59791d1d9810009c70cd37b14f4e6
z2=0x339ff7b1ced3a45c988b3e4e239ea745db3b2b3fda6208134691bd2e4a37d6e1

print "private:%x\n random:%x" % derivate_privkey(p,r,s1,s2,z1,z2)

is there any other way to recover it from r s z ?

What is the purpose of private key, if anyone would be able to recover it from other data?

  is it possible to recover any private key using random R values ?

the probability is the same as trying random values for guessing private key itself


Can one set how many confirmations MultiBit requires for a transaction to be accepted? Is there any way for users to specify the number of confirmations for a transaction?
If not, how many confirmations does Multibit require to complete a transaction?
And does the required default number of confirmations vary by size of the transaction?

From your side, an outgoing transaction are completed the moment you send it. However, it's up the receiving party to decide how many confirmations they require before they consider it received. The usual rule is 3 confirmations.

I have never used Multibit, so in regards to incoming transactions, I have no idea.


Token vs contract - are they the same? The Ethereum ERC20 token is also the contract. The token can never live without the contract. The name of the contract is the name of the token. In the code, the keyword is contract and not token.

I may hold 4 ETH but does that mean I'm holding 4 ETH contracts? If that is the case, why call them tokens at all?

Is everyone exchanging tokens or contracts?

For an ICO, there is an ICO contract created to limit supply and issue tokens. If the contract is the token and the ICO contract goes away after the ICO, how do the tokens exist?

On ethereum, all tokens are contracts, but not all contracts are tokens.

ERC20 is a specific type of contract that is recognized by everyone to be a token contract. It has a base definition and structure that is defined in the ERC20 spec regarding how transfers, balances, approvals, issuance, etc. work.

An ICO or anyone issuing a token will write an ERC20 contract that specifies things such as the initial supply, price of the token (if it is being crowdsold), bonus rounds, etc. This contract is deployed on the ethereum blockchain, and functions as the token. Any given user's token balance is simply a value that the contract says that user controls.

Ethereum is native to the platform, and does not have an underlying contract. It is not an ERC20 token.

You can also have non-ERC20 contracts, such as the lottery contracts, DAO contract, Ethereum Name Service contracts, etc. A contract can be any variety of programs in solidity.


Transfer Crypto Currency between exchanges How do I transfer BTC from one exchange to the other?

I would downvote this but I can’t so I’ll just answer it :(  Of course, easy and direct transferrence is the primary function of Bitcoin. Exchanges have a “deposit funds” function/button that provides the address for you to send the BTC from your current exchange or wallet. Just go to “send” or “withdraw” on your current exchange and plug in the new exchange’s (or another person’s) address and send it to the network. That’s it.


Is there any useful documentation on using the MtGox API with node.js? I have been looking for some help building a platform using node that works with the MtGox api. It seems easy to make request, but I am confused about how to pass a parameter.

Right now my code starts off like below. I can hit the server and get basic market data but I don't know how to do anything else....

request = require('request');

APIResponder = require('../libraries/apiresponder');

exports.market_data = function(req, res, next){
  request('https://mtgox.com/api/1/BTCUSD/ticker', function (err, response, body) {
    console.log(response);
    console.log(body);
    APIResponder.respond(res, response);
  });
};

The Bitcoin wiki has a nice example program:

var querystring = require('querystring'),
        https = require('https'),
        crypto = require('crypto');

function MtGoxClient(key, secret) {
        this.key = key;
        this.secret = secret;
}

MtGoxClient.prototype.query = function(path, args, callback) {
        var client = this;

        // if no args or invalid args provided, just reset the arg object
        if (typeof args != "object") args = {};

        // generate a nonce
        args['nonce'] = (new Date()).getTime() * 1000;
        // compute the post data
        var post = querystring.stringify(args);
        // compute the sha512 signature of the post data
        var hmac = crypto.createHmac('sha512', new Buffer(client.secret, 'base64'));
        hmac.update(post);

        // this is our query
        var options = {
                host: 'mtgox.com',
                port: 443,
                path: '/api/' + path,
                method: 'POST',
                agent: false,
                headers: {
                        'Rest-Key': client.key,
                        'Rest-Sign': hmac.digest('base64'),
                        'User-Agent': 'Mozilla/4.0 (compatible; MtGox node.js client)',
                        'Content-type': 'application/x-www-form-urlencoded',
                        'Content-Length': post.length
                }
        };

        // run the query, buffer the data and call the callback
        var req = https.request(options, function(res) {
                res.setEncoding('utf8');
                var buffer = '';
                res.on('data', function(data) { buffer += data; });
                res.on('end', function() { if (typeof callback == "function") { callback(JSON.parse(buffer)); } });
        });

        // basic error management
        req.on('error', function(e) {
                console.log('warning: problem with request: ' + e.message);
        });

        // post the data
        req.write(post);
        req.end();
};

var client = new MtGoxClient('mykey', 'mysecret');
client.query('1/BTCUSD/public/ticker', {}, function(json) {
        // do something
        console.log(json);
});

Here's documentation for the v1 API


How do i find my private keys in my blockchain.info wallet? I've tried numerous times to find private key in settings/addresses, but can't find any.

My question is not like the other problems here, because i cannot even see my private key. I can find xPub extended private key on my default wallet. But is that the same thing?

Please follow the below steps:

Go to settings, then click addresses as shown below:

Click on more options aside your address whose private key you require as shown below:

In 'More Options' you will find "Private Key", please click it:

They will show you a warning as below, please click continue:

You can see your private key for the corresponding wallet address:

Hope this helps you!


cpu, ram or bandwidth -- what is most important for bitcoin mining? [I know Bitcoin mining on a server is a losing proposition, consider this an academic question.]

I've got some old proliant rack servers and VMWare licenses and thought I'd put them to use mining.  In setting up the VM I can alter cpus, ram, and network.  (I'm stuck with 10k rpm HDDs.)  My question is which of these is most important for optimizing mining?

My guess is CPU followed by RAM but interested in thoughts here.  thanks.

CPU is basically the only thing that matters.

The memory requirements for mining are trivial (enough to run bitcoind; SHA256 uses only a few bytes of memory).  Having more that enough will add no benefit.  Disk performance is nearly irrelevant also.

A fast network connection may help you get new blocks a little bit faster.  This is helpful because the time in between when a new block is released and when you get it is effectively wasted mining time.  But even with a very slow network connection, this should be at most a few seconds.  With a 10 minute block time, the difference between the slowest and fastest network connection should impact mining efficiency by less than 1%.


Gaming Bitcoin by generating millions of wallets What’s to stop someone from gaming the system and creating millions of wallets, increasing their odds of accidental deposits?  If nothing else you could conceive of a DOS attack of sorts, where the addresses are all burned up.  This seems like a major flaw to me... regardless of how many possibilities there are, it's not infinite.

Nothing stops anyone from doing that. However, I don't think you'll find many people who agree that it's a "major flaw". If that's a major flaw, then every system in existence has thousands of major flaws. When you say things like "regardless of how many possibilities there are" you're engaging in wild speculative fantasy.


secp256k1 lib compiling issue "invalid use of incomplete type secp256k1_context" I make a small test code (test.cpp), try to show the problem I meet:
to compile use
g++ -o test test.cpp -lsecp256k1
#include <stdio.h>
#include "secp256k1.h"

static secp256k1_context_t *ctx = NULL;

int main(int argc, char **argv) {

ctx = secp256k1_context_create(SECP256K1_CONTEXT_VERIFY | SECP256K1_CONTEXT_SIGN);
printf("Context created!\n");
secp256k1_context_t *ctx_clone;
ctx_clone = secp256k1_context_clone(ctx);
printf("Context cloned!\n");

/* if enable below two lines of code the compliling error will happen */
// secp256k1_ecmult_context_t* clone_ecm_ctx;
// secp256k1_ecmult_context_clone(clone_ecm_ctx, &ctx->ecmult_ctx);

secp256k1_context_destroy(ctx_clone);
secp256k1_context_destroy(ctx);
printf("Context destroyed!\n");

return 0;
}

Without the two comments out code I will not have issue.
If with two comments out code, the complier will report that:
test.cpp:15:51: error: invalid use of incomplete type 'secp256k1_context_t {aka struct secp256k1_context_struct}'
 secp256k1_ecmult_context_clone(clone_ecm_ctx, &ctx->ecmult_ctx);
                                                   ^~
In file included from test.cpp:2:0:
/usr/local/include/secp256k1.h:50:16: note: forward declaration of 'secp256k1_context_t {aka struct secp256k1_context_struct}'
 typedef struct secp256k1_context_struct secp256k1_context_t;
                ^~~~~~~~~~~~~~~~~~~~~~~~

That looks like I can not operate the context struct internal member (because of the opaque struct), however, my code indeed need to access the struct inside of the context struct, for exp, the below code will trig a similar compiling error:
secp256k1_ecdsa_sig_verify(&ctx->ecmult_ctx, &r1, &s1, &q, &m)
is there any workaround there?

The reason for this error is that secp256k1_context is an opaque type. This means that you cannot create it on the stack; you need to create a heap-allocated version (and destroy it) using the functions from the API (specifically secp256k1_context_create and secp256k1_context_destroy, as Mark H mentioned in a comment). There is no way to access the internals.
You're right not to try to #include <secp256k1.c> ... aside from being unlikely to build and requiring you to bundle a copy of the whole library, it would expose internals of the library to your code which are not safe to use directly.
For what you are doing (replacing internal signing functionality with OCL-enabled versions) you are probably better off forking the library and directly editing the source. This isn't much more invasive than what you're trying to do, and it would let you use the existing unit tests and valgrind ctime tests to check your work.


How/when are transactions removed from the not-confirmed pool? I am not clear as to how the removal of transactions from the non-confirmed pool happens.  I have not found any descriptions explaining how the process works.

Here are the scenarios as I see them:

A) When a node selects a set of transactions to be included in a possible block it removes them from the non-confirmed pool.  So if/when the node solves the block there is no clean up necessary of the not-confirmed pool.

B) Transactions may be included in multiple potential blocks and remain in the not-confirmed pool while blocks are being solved, then when a block is solved the transactions included in the block are removed from the not-confirmed pool.  This sounds to me as the most likely scenario but it is not clear at all who/when removes the transactions from the not-confirmed pool.

In Bitcoin Core, the memory pool is a consistent set of transactions that can legally follow the best known block. As already mentioned, there is no guarantee of consistency between different nodes' mempools.

In practice that means:

when a new block is accepted (received from the network or locally mined), all transactions in it are removed from the mempool, while their dependencies are kept.
when a new block is accepted, all transactions that conflict with transactions in that block, plus all their dependencies, are removed from the mempool.
when a block is reorganized (disconnected), its transactions are attempted to add back to the mempool in reverse order (since they may interdependent), unless they conflict with transactions already there.


ZebPay - Direct sell from wallet I want to use ZebPay since I am from India but this question is applicable to all Bitcoin waletts like CoinBase. Can I sell directly from my wallet ?

For example if I have 1 BTC in my wallet can I sell it directly from there and get the funds in my bank account ?

Or do I have to wait for some third party to buy my bitcoins and then I can get paid ?

In short, can I sell to ZebPay or CoinBase directly for USD ?

With Zebpay, you can sell directly and get your INR. You do not have to wait for a third party to buy your bitcoins like in a typical exchange.

I believe it is same with Coinbase to sell and get USD.

Sandeep Goenka, co-founder, Zebpay.


How is Coinbase any different than Mt Gox? Apparently Coinbase handles the private keys for your wallet which allows them to easily handle buying and selling.

  As Coinbase is a hosted wallet, we do not provide users with their private keys; doing so would prevent us from taking advantage of our secure cold-storage technology to protect your bitcoin funds.

Isn't this exactly what Mt Gox did before it was compromised?

You're right that in this regard, Coinbase and Mt.Gox are similar: they control the private keys, and incompetence or malice on their part could result in the loss of your coins. One difference is that Coinbase doesn't keep a balance of USD (or other fiat) in your account, only bitcoins. The other major difference is that Coinbase has not (AFAIK) shown any signs of incompetence or malice jeopardizing your bitcoins stored there (these signs, I hear, were around for a long time before Mt.Gox finally died).

Cold storage is a good thing when done correctly: it improves security and doesn't prevent instant bitcoin withdrawals (except in exceptional circumstances).

Still, personally, I will (long-term) store my bitcoins in a local client or my own cold storage, not an exchange or online wallet. There's still a real (maybe even higher!) chance of loss this way, but it'd be due to my incompetence, not someone else's.