Struggling to successfully broadcast a p2pkh transaction I've been experimenting with sending bitcoin transactions with python for the past week. I successfully was able to send p2wpkh->ALL address types, p2sh-p2wpkh->ALL address types.

What I am struggling with is sending a legacy p2pkh transaction. I keep getting:

SIGNATURE MUST BE ZERO FOR FAILED CHECK(MULTI)SIG OPERATION

when I try to broadcast the signed transaction using https://testnet.smartbit.com.au/txs/pushtx

It seems to me like it is a signature error. But I can't understand why I am able to generate good signatures for other payment types but then bad signatures for p2pkh.

My rawtx:

  01000000 01 4f8fe5092e16ad3da3327c36a6c5209c9aede34fc68615cfdf3049945e91ca61 00000000 00 ffffffff 02 4c4f000000000000 1976a9143f7ff5e4d9b36cbce77199043d5cf51b5fb4e8d188ac 546f4b0000000000 1976a9143f7ff5e4d9b36cbce77199043d5cf51b5fb4e8d188ac 00000000

My signed TX:

  01000000014f8fe5092e16ad3da3327c36a6c5209c9aede34fc68615cfdf3049945e91ca61000000006a47304402205881bb01ff20100233d6c1284eb6fe1857fb25a8cee52f5fe48ef8bbf61e42fe02201b00187031f299283b60b214d801c5ca0db8342a8e68c8020caf96e9a064b471012102a7b51771f972f4d2de85129886415af3e13efe943c12f149ab7c43c318f45ae9ffffffff024c4f0000000000001976a9143f7ff5e4d9b36cbce77199043d5cf51b5fb4e8d188ac546f4b00000000001976a9143f7ff5e4d9b36cbce77199043d5cf51b5fb4e8d188ac00000000

Signed tx parsed with my python parser:

Segwit: False
txn version: 1
Flag: 00

------------------------------------------------------------
Inputs: 1
------------------------------------------------------------

(1)
Previous txn hash: 61ca915e944930dfcf1586c64fe3ed9a9c20c5a6367c32a33dad162e09e58f4f
Index: 0
sigScript: 47304402205881bb01ff20100233d6c1284eb6fe1857fb25a8cee52f5fe48ef8bbf61e42fe02201b00187031f299283b60b214d801c5ca0db8342a8e68c8020caf96e9a064b471012102a7b51771f972f4d2de85129886415af3e13efe943c12f149ab7c43c318f45ae9
Sequence: ffffffff

------------------------------------------------------------
Outputs: 2
------------------------------------------------------------

(1)
Value (satoshis): 20300
pubKeyScript: 76a9143f7ff5e4d9b36cbce77199043d5cf51b5fb4e8d188ac

(2)
Value (satoshis): 4943700
pubKeyScript: 76a9143f7ff5e4d9b36cbce77199043d5cf51b5fb4e8d188ac

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

Locktime: 0

Can I use compressed public keys in normal p2pkh transactions or does it have to be normal uncompressed?

In my script I build the preImage the same way as my other segwit inputs/outputs but obviously I dont use flag, marker witness fields. I also followed another post on here attempting to only sign a single input and I got other errors different from the one at the top of this post.

How does the segwit signing process differ from legacy?

Nevermind.

I combined the two answers from these posts and managed to get something working:

Redeeming a raw transaction step by step example required

https://bitcoin.stackexchange.com/a/41226/89247

Yes. You can use compressed public keys with p2pkh. There are no restrictions.


Which sender is banned in case of nvalid transactions or blocks? When a node receives an invalid transaction or block, as far as I know, it bans the sender for 24 hours. However, I didn't exactly get which sender is banned. Is it the neighbor node that provides the data to this node, or is it the creator of the data (transaction or block)?

There is no way to know which node created a transaction or block, unless they publish that information themselves. Nodes should not have an identity that leaks into transaction or block data.

So banning for relaying invalid blocks or transactions always applies to the peer that gave you the information, based on their IP address. The protocol requires you to validate information before relaying, so you are in violation whenever you pass on invalid data.


What could be the consequences of many bitcoins being lost out of circulation if people lose their wallets? If for some reason many people lose their wallet files then many bitcoins are effectively taken out of circulation.

Seen as it's not possible to tell as far as i know if bitcoins are actually disabled in this way, so to speak, I'm wondering what are the implications for this.

I thinking of the hypothetical doomsday scenario whereby it's a significant percentage of the economy. Lets say it was enough to significantly reduce the volume on the markets.

For example a large group of people who hold a great many and live in the same city are subjected to a large EMP. :-)

Would this effect the value of bitcoin indirectly?

Economic theory tells us the price would rise.  It would have a deflaitonary effect on bitcoin economy.  However because bitcoins are so easily divisible it would not impact the ability for the network to function.

If 90% of bitcoins were lost/destroyed that would leave 2.1 million "whole" bitcoins in circulation.  This wouldn't be an issue because currently bitcoin network supports transactions down to one satoshi (0.00000001 BTC) which is 210 trillion discrete units of exchange.

It is possible to allow smaller units of exchange however I will illustrate that is unecessary.  The world's money supply (M0) is valued at ~ $20 trillion.  If entire world switched to using bitcoin for all commerce the value of a "whole" bitcoin would be $9,524,000 each.  However the smallest unit 1 satoshi would be worth $0.10 Even with 90% of bitcoins destroyed/lost there would be sufficient units remaining to allow commerce down to a 10 cent granularity with Bitcoin replacing the entire world's money supply.

It would result in some changes in language.  Obviously most people wouldn't value things in terms of bitcoins but rather in smaller units like satoshi's (0.00000001 BTC).

As an example a fastfood meal could be priced as $5USD, 0.00000053 BTC, or 53 satoshi's. Obviously 53 is far easier for humans to express than 0.00000053 BTC despite them having equivelent value.  Given the high value of a single BTC, "whole" BTCs would rarely be used other than to express things that are currently express in millions of dollars (like salaries of celebrities, values of corporations, size of national debts, etc).

Satoshi is used as an example but alternatively SI prefixes could be used. For common usage prices in fractional μBTC (micro bitcoins) makes the most sense with 1 μBTC = 1E-6 BTC.

Some examples:

"Man gold broke 200 μBTC today"

"The US Congress raised the minimum wage to 1.50 μBTC effective Jan 1"

"I got the job.  Starting salary is 8,400 μBTC a year"


How does Poloniex Bitcoin loaning work? I just learned about Bitcoin loaning as seen below and tried it a few times. I'm not too clear on the earnings.

Does it mean you can loan your Bitcoin for .0988% return every 2 days? But when I check my loan history, it seems like the loan gets returned to you multiple times a day and it gets loaned out again. Does this mean every time someone that borrows from you gets charged .0988% ? So what is the 2 days for then?

I guess the rate base on daily, and 2 days mean to lock down for 2 day. so you have chance to cancel, or change the higher rate some how.

Rate: The daily interest rate you are offering your funds at.

here is the link to explain in more detail officially


How would one inject a blockchain fork to the Bitcoin network? For theoretical purposes, how would one inject a blockchain fork in to the Bitcoin network? For example, lets say we have a small chain of blocks prepared in a program that is not a standard client / standard client with modified code. Can one force a client to accept those blocks through getmemorypool RPC command, or will the client not accept any block that would not go at the tip of the current blockchain?

What are the ways of getting a blockchain fork into the Bitcoin network?

EDIT:
I'm not talking about alternative blockchain forks, like SolidCoin, etc., but rather about a fork in the standard Bitcoin chain/testnet chain that would cause some blocks to be orphaned.

Just pass the blocks one at a time to your official bitcoind program, and it will broadcast them to the network.  You don't need to do anything tricky, except for somehow manage to hash faster than everyone else combined.


What mobile wallet software is available for BlackBerry? Is there a technical reason why there is no mobile wallet software for BlackBerry users?

Is it just because the marketplace on BlackBerry is awkward? Or are there other technical problems?

Are the Android and iPhone markets easier (less strict) to upload apps to?

The Blackberry World (app store) shows two wallet apps:

Bitcoin Wallet by Andreas Schildbach
Bitcoin Spinner (unofficial release, so I'ld check first on the Bitcoin Spinner forum thread to see if it is verified as a straight port with no wallet stealing code injected)]


Are there any bitcoin communities for women? Not to knock the guys, but it would be nice to talk to girls about this awesome virtual currency...partly to bring awareness to enable widespread adoption of bitcoin, as well as to try to get involved with other girls who may be working on bitcoin-related projects.

There is a Meetup for Women in Bitcoin in San Francisco. It might be helpful to try to get in touch with them as they might be able to point out a meetup near you or recommend an online community, unless you happen to be near there anyway.


How can I get the bitcoin amount of an bitcoin address which doesn't belong to my wallet? I am trying to make a query about a bitcoin address's btc amount. As I've read, getreceivedbyaddress rpc command can only be used for the addresses of a wallet that one owns and that command is awallet command. I want to make a query about any bitcoin addresses btc amount. Is it possible? If yes, how do I do it?

You can use the new scantxoutset method to check for UTXOs matching a given script, address, or key descriptor.

For example, to scan an address, you can use:

bitcoin-cli scantxoutset start "[\"addr(1....)\"]"


Is there only ever 1 send address for a wallet I know you can create label / address pairs to receive coins and also that a wallet automatically generates a new address when you need change from a transaction for the receive operation.

Will there only ever be one send address for any given wallet?

So on the blockchain all my send transactions will only ever have the one address even though I can and will have multiple receive addresses?

It doesn't work that way.

Any address can send and receive. Since you'll receive coins on multiple addresses, sooner or later you will have to use those addresses to send too, in order to spend those coins.


Getting error while accessing bitcoin client from ruby using Rpc I am getting the following error while trying RPC call from ruby. bitcoind server is running. I am using bitcoin-ruby library .

Code Tried in irb to test:

require 'bitcoin'
=> true
irb(main):002:0> txid= "611b40973fe68cc42b70ae5af365a449af458d76086415c6fa6c45364c36278e"
=> "611b40973fe68cc42b70ae5af365a449af458d76086415c6fa6c45364c36278e"
irb(main):003:0> rtx= bitcoinRPC('getrawtransaction',[txid])

Error :

NoMethodError: undefined method `bitcoinRPC' for main:Object
    from (irb):3
    from /usr/bin/irb:11:in `<main>'

Any suggetion will be highly appreciated.

Thanks in advance,

R

Use the following method to call BitcoinRPC using Ruby:

Create ruby file test.rb as

require 'net/http'
require 'uri'
require 'json'

class BitcoinRPC
  def initialize(service_url)
    @uri = URI.parse(service_url)
  end

  def method_missing(name, *args)
    post_body = { 'method' => name, 'params' => args, 'id' => 'jsonrpc' }.to_json
    resp = JSON.parse( http_post_request(post_body) )
    raise JSONRPCError, resp['error'] if resp['error']
    resp['result']
  end

  def http_post_request(post_body)
    http    = Net::HTTP.new(@uri.host, @uri.port)
    request = Net::HTTP::Post.new(@uri.request_uri)
    request.basic_auth @uri.user, @uri.password
    request.content_type = 'application/json'
    request.body = post_body
    http.request(request).body
  end

  class JSONRPCError < RuntimeError; end
end

if $0 == __FILE__
  h = BitcoinRPC.new('http://username:password@127.0.0.1:8332')
  txid= "611b40973fe68cc42b70ae5af365a449af458d76086415c6fa6c45364c36278e"
  p h.getrawtransaction(txid)
end

NOTE:
username and password are from your bitcoin.conf file.


How create a personal node c-lighting for create a new channel with other node I want to create my personal node to create a new channel with another personal node, an example my node with URL 12345678@192.164.1.7 I want create a channel with another personal node.

I could not found some reference for this problem, can you help me for creating my personal node?

I try to add and parameter to command line --addr but this I think is not enough, right?

First you will need to decide which machine will fund the channel. In the current implementation only one party can lock funds to a multi-sig address. Let's say the machine that will fund the channel is A and the other is B. Now open the c-lightning in the terminal on machine B and type lightning-cli getinfo. It will give you a bunch of information. Look for the id and address. Then open the c-lightning on your machine A's terminal and type  lightning-cli connect id@address:9735. Where id and address are the info that you got from the getinfo command on machine B.

After connection has been established, you can then open the channel using the command lightning-cli fundchannel id satoshi [feerate] [announce] on your machine A. Here id is the node id of the node with whom you want to open the channel and satoshi is the amount of bitcoins in satoshis that you want to use to fund the channel. If you want to keep your channel private you can set announce to false.

If you want to expose the node to the internet and use the internal IP addresses you can do so by adding bind-addr=<internal_IP> and announce-addr=<public_IP> in the config files. You can also pass these commands in the terminal when starting the lightningd daemon, but it is easier to do it in config file so that you don't have to do it everytime you start the daemon.


How do I extract the address from a scriptPubKey? I am creating a block parser and just learned about Scripts in Bitcoin yesterday which is kind of confusing so far. I want to extract the addresses involved in each transaction. Right now, I am able to read the script for each output. To extract the address, am I correct in thinking that my code will need to handle all of the different formats of scriptPubKeys?  Is there any sample code out there to guide me? If I am completely wrong, how should I do it?

Yes, to get addresses from scriptPubKeys, you will need to do a pattern match. There are only a small number of address types each with their own fixed scriptPubKey pattern. Keep in mind that not all scriptPubKeys map to an address so you will find scriptPubKeys that have no address and you will need to handle those.

Bitcoin Core has a pattern matcher for going from scriptPubKeys to address types in the solver function. The MatchPayToPubkey, MatchPayToPubkeyHash, and MatchMultisig can be found higher up in that file. The IsPayToScriptHash and IsWitnessProgram functions can be found here.

One thing to note about the solver is that it does not return just address types. Some of the types it returns do not map to addresses. These are TX_NULLDATA, TX_MULTISIG, TX_PUBKEY, and TX_NONSTANDARD.

It may also be useful for you to see how you get the scriptPubKey from an address. Bitcoin Core does it here.


would 10 x 2TH/s machines give me the possibility to mine solo Would 10 X 2TH/s machines give me the a heads up on pool mining or go solo mining obviously using different addresses on each machine, or one address prone to redundant work?

Tim S. had a good answer about this earlier today.

Since your overall hash rate is going to be around 20 TH/s, you would be OK doing your own solo mining. But with solo mining, your rewards will be a lot more inconsistent than if you mined in a pool.


fee 4 times what I am sending I am attempting my first Bitcoin transfer from Abra to Bittrex. I am only sending the equivalent of $10 US dollars to test it. The money did not go through as I do not have enough in my account to pay the fee which is $44!! Is this right - it costs $44 USD  in fees to send $10 USD?

Yes, they are that high at the moment. You should not send such small amounts of bitcoins nowadays. You could wait until the Lightning Network works. The fees will probably fall then.


How to send Bitcoin from one addresss to another using nodejs which api i can use to tranfer BTC from one address to another. I have knowledge about bitcoin-transaction api but it does not allow to setup fees. We have try this api but it cost too much high for micro transactions.

If there is any option to setup fees i would prefer it because it not complex compared to others.

Learn bitcore-lib npm package:

Bitcore library provides a very simple API for creating transactions.
Let's take a very simple transactions:

var transaction = new Transaction()
    .from(utxos)          // Feed information about what unspent outputs one can use
    .to(address, amount)  // Add an output with the given amount of satoshis
    .change(address)      // Sets up a change address where the rest of the funds will go
    .sign(privkeySet)     // Signs all the inputs it can


Where can I find my Bitcoin core key? I bought some bitcoins a few years ago using Bitcoin Core.

I have since discarded my computer as it broke.

Where/how can I find my bitcoins?

If you recover your wallet.dat file, you can import it into a working bitcoin node and sweep the wallet. You must have access to the hard drive of the broken computer.

Your wallet.dat file can be located at:
Linux ~/.bitcoin/
Mac ~/Library/Application Support/Bitcoin/
Windows%APPDATA%\Bitcoin

You can also import the .dat file into blockchain.com which naturally I do not recommend since it defeats the purpose of decentralization.


Determining a Block's Extranonce Value How do I determine a block's extranonce value? I know they are in the coinbase transaction, but where? How do I decode the part that is the extranonce?

In Bitcoin v0.1.5 to v0.3.24, the coinbase scriptSig contained:

txNew.vin[0].scriptSig << nBits << ++bnExtraNonce;

In Bitcoin v0.4.0 to v0.5.3, it changed to:

pblock->vtx[0].vin[0].scriptSig = CScript() << pblock->nTime << CBigNum(nExtraNonce);

Bitcoin v0.6.0 to v0.6.3:

pblock->vtx[0].vin[0].scriptSig = (CScript() << pblock->nTime << CBigNum(nExtraNonce)) + COINBASE_FLAGS;

Bitcoin v0.7.0 to current:

txCoinbase.vin[0].scriptSig = (CScript() << nHeight << CScriptNum(nExtraNonce)) + COINBASE_FLAGS;

So the coinbase scriptSig field has changed over time, but it has always placed the extranonce as the second item.

In Bitcoin v0.1.5, the size was unlimited, and in more current versions, it's 4 bytes or less. (This is caused by the switch from bnExtraNonce to nExtraNonce.)

There are some other odd details - in v0.1.5, it only resets when the client resets, but in later versions it resets on every new block.

Of course, this is just what the core client does. Other miners or pools might do something else.


How would the gossip protocol announce channels from a channel factory? I was just listening to SLP59 with Christian Decker. They mainly discussed channel factories. While the construction of multiparty channels and higher order systems (sub channels) being derived from them seems clear
 and is being described in this paper I wonder how the gossip protocol would have to be adapted so that people would be able to announce such channels?

Generally there is the necessity to point to a funding tx of a payment channel in order to prevent spamming channel announcment messages and in order to authenticate channels. However with channel factories there is only one large funding tx for the multiparty channel. The sub channels are offchain.

How would a solution for the gossip protocol look like?

Pretty much everything would stay the same. If you look at the relevant messages channel_announcement and channel_update we have the following formats:

channel_announcement

  type: 256 (channel_announcement)
  data:

  [64:node_signature_1]
  [64:node_signature_2]
  [64:bitcoin_signature_1]
  [64:bitcoin_signature_2]
  [2:len]
  [len:features]
  [32:chain_hash]
  [8:short_channel_id]
  [33:node_id_1]
  [33:node_id_2]
  [33:bitcoin_key_1]
  [33:bitcoin_key_2]

channel_update

  type: 258 (channel_update)
  data:

  [64:signature]
  [32:chain_hash]
  [8:short_channel_id]
  [4:timestamp]
  [1:message_flags]
  [1:channel_flags]
  [2:cltv_expiry_delta]
  [8:htlc_minimum_msat]
  [4:fee_base_msat]
  [4:fee_proportional_millionths]
  [8:htlc_maximum_msat] (option_channel_htlc_max)

If you look at this you'll see that the channel_announcement includes a lexicographically sorted list of node and bitcoin signatures and their corresponding pubkeys. This is trivial to extend to arbitrary number of participants by making this list variable in length.

In particular the short_channel_id still refers to the single output that the off-chain contract was opened with, that'd also stay the same.

channel_update may seem a bit more complicated since now there are n*(n-1) possible directions (sender-receiver pairs) this contract can be traversed, whereas in the simple 2 participant channel we just have 2 directions. The direction concept can however be easily extended to just lexicographically rank all sender-receiver pairs and use the index to identify the pair.

It is likely that some of the message formats need to be amended (variable length pubkey and signature lists) and some fields be made explicit (rank index for sender-receiver pair), but the general concept stays the same.


Can I download blockchain updates from somewhere? I use Bitcoin only on rare occasions - say once every month. I want to avoid long waiting times for downloading and verifying blocks that consequently await me when I reopen bitcoin-qt. There are many options available for downloading the whole block chain when one starts out (like the blockchain torrent or the blockchain on Sourceforge). However, these options are full of warnings that tell you they should NOT be used when updating the block chain on an existing wallet but rather only when installing from scratch.

Are there similar ways of more quickly updating the blockchain by downloading recent blocks from some other source?

Note: I am not looking for other clients, but specifically for alternative blockchain download options for bitcoin-qt.

There's not, keep your client open or use a 3rd party wallet which doesn't require you to run a bitcoin client (blockchain.info wallet or coinbase)


Can I run a bitcoin full node on my laptop and use a external hard drive to store the blockchain? I tried setting the datadir=/Volumes/BLOCKCHAIN (which is the path to my external drive). Then I ran bitcoind and this is the end of the output, right before it kicks my drive out and gives me a Bus error: 10.

...
2019-10-22T16:30:26Z init message: Loading block index...
2019-10-22T16:30:26Z Opening LevelDB in /Volumes/BLOCKCHAIN/blocks/index
2019-10-22T16:30:26Z Opened LevelDB successfully
2019-10-22T16:30:26Z Using obfuscation key for /Volumes/BLOCKCHAIN/blocks/index: 0000000000000000
Bus error: 10

Is there another way I can achieve this?

If you're using USB 2.0, your problem is going to be the read/write speeds.

Minimum requirements state that you need at least a read/write speed of 100 MB/s.

Typical high-speed USB 2.0 connected drives only do about 40-50 MB/s.


Can I buy a Bitcoin from one exchange and sell it on another? Is it possible to buy a Bitcoin at one exchange, say BTC-e, and then sell it on another, like LocalBitcoins? If it is possible, how would this be done? More specifically, how could you transfer a Bitcoin from one wallet to another wallet that uses a different exchange?

Yep you can! This form of trading is called arbitrage and is not only done with BTC, but with nearly any un-centralized market.

Only drawback here is the financial difficulty of moving fiat from or to Bitcoins, since exchanges don't let you share your fiat balance with others without having to withdraw to a bank account. The withdraw process for most exchanges is known to take up to weeks and in that time BTC may have fallen or rose, similar with deposits. But a few people get away with arbitrage and make a profit in the end of the day.


Wasting of calculated hashes If I am trying to find a nonce and in the meantime someone finds a nonce and adds a new block to chain, then will my work be wasted or it could be useful in finding other nonces?

your work is "wasted" caused by the mining-algorithm.

you have found a new block if sha2(sha2(blockheaderOfnewBlock) starts with a certain amount of zeros. the blockheader contains a nonce, the hash of the previous block and some other information. since the previous-block-hash is another hash if a new block was found you have another information-base for your mining-software.


What is "trickling" in terms of bitcoin? In the Bitcoin (0.10.0) source code I'm coming across the term "trickle".
Could someone please give short but accurate explanations on following instances and tell what they're used for?

bool fSendTrickle
bool fTrickleWait
CNode* pnodeTrickle ?

What is the general idea behind "trickling"?

Trickle is a reference to how the node manages announcing other peers addresses.


What is "difficulty" and how it relates to "target"? I don't understand what "difficulty" means and how it really relates to "target".

I understand what "target" is - it tells the miners, how small the resulting hash should be. (Basically, how many zeroes are there at the beginning, altough not exactly.)

But I don't understand what "difficulty" is, how it relates to the target and why it's important. I tried to read the article on wiki - https://en.bitcoin.it/wiki/Difficulty - but I don't have a clue what is it trying to say either.

Difficulty is basically a different representation of the target to make it easier for normal humans to understand it.

Difficulty represents how difficult the current target makes it to find a block, relative to how difficult it would be at the highest possible target (highest target=lowest difficulty).  The current difficulty of 6,695,826 means that at a given hash rate, it will, on average, take ~6.6 million times as long to find a valid block as it would at a difficulty of 1, or alternatively, it will take, again on average, ~6.6 million times as many hashes to find a valid block.

Difficulty is the largest possible target (0x00000000FFFF0000000000000000000000000000000000000000000000000000) divided by the current target (as of right now, 0x00000000000002816E0000000000000000000000000000000000000000000000).


how do you transfer your Bitcoin core wallet while syncing? I would like to transfer my btc wallet to an electrum wallet. Syncing is taking to long.

Follow this guide.

Summary:

Download Electrum and verify the signature to prove it was not modified in transit. Create a new Standard Wallet and choose "Create a new seed". Electrum will give you a seed phrase which you should write down on paper.
If using Bitcoin-Qt, click Window -> Console.
If your wallet is encrypted, use this command to decrypt it for 5 minutes (300 seconds):

walletpassphrase your-wallet-passphrase 300

If addresses with balance are known:

Use the dumpprivkey command to get the private key. Repeat for as many bitcoin addresses as have money in them.

dumpprivkey <your bitcoin address>

If addresses with balance are not known:

Use the dumpwallet command to get all private keys from the wallet.

dumpwallet path/to/exported-wallet.txt

In the Electrum window, click Wallet -> Private Keys -> Sweep. Paste the private keys from Bitcoin-Qt here. Check the resulting transaction is okay and click Broadcast to sweep from the addresses in Bitcoin Core to the Electrum wallet.

If the address generated from the private key is wrong, then on the Sweep Private keys dialog box in Electrum click the Info box in the upper-right. It will give instructions for prefixing your private key so that the correct address is generated. For example if your address starts with 3 then use p2wpkh-p2sh:[your-private-key].

Warning: Make sure the Electrum wallet is not a watch-only wallet. The Electrum window title bar should not say [watching-only].


What would Bitcoin be like with two block chains? I once heard somebody say that to overcome the absolute supply limit of 21 million bitcoins, one could start their own block chain.

Besides the adoption concerns (most likely nobody would accept the new block chain as genuine in the currently existing Bitcoin network even if it had its own genesis block and wasn't just a fork), are there any networking problems with this? If, hypothetically, the adoption concerns could all be overridden, would there be any data conflicts with the existing block chain? Is the Bitcoin protocol designed to be able to use more than one block chain? Can the client handle it?

Most other crypto coins is more or less what you describe.

The bitcoind code has build-in "checkpoints" (block height x has hash y), but a new blockchain would anyway use a "new" ( / forked ) client, so you could just remove these checkpoints.

However the 21 million bitcoin limit will never be a problem. Today each bitcoin can be divided down to 8 decimal places (0.00000001 BTC), should we for some weird reason need more bitcoins, then this limit can be changed.


How can I spend my paper wallet directly? I am totally new to Bitcoin. Can you tell step by step, how I can spend a paper wallet directly? Or is it necessary to create a software wallet?

Unless you plan on doing ECC math and hashing algorithms by hand (it would take you about a day just to do a single round of SHA256) and publishing the raw binary transaction via raw network protocol, you're going to need some software.

I would recommend getting Mycelium, which has a paper wallet import feature. You can then spend it where you like using the wallet.


How to find ripple faucet coin for development I'm developing an app with ripple. I need some faucet coin for ripple. How can I find it?

I haven't tried it these website but i guess it should work: http://satoshibakery.com/ripple-faucet.php


Altcoin (Litecoin fork) creation. No synchronisation i m trying to create an altcoin from the current Litecoin master branch on github. Its Litecoin in the version of 0.15.1.

By editing some parameter in chainparams.cpp i m able to create my genesis block. But i cant get the network to synchronize!

I m running litecoind on a vps with all ports open, and i am able to connect to the node when i start the litecoin-qt on my machine (with -addnode or -connect to the vps).

On my vps i can see my machine with -getpeerinfo and its block count (0).
On my machine i can see that it is connected to the litecoin node on my vps.
When running generate on my vps, to create some blocks, i can even see on my machine, that the block count of my vps has risen. Still, there is no synchronization! The blockchain on my machine stays 0.

The litecoin-qt on my machine shows me "Connecting to Network" all time, even though it is connected to the litecoin node on the vps.

In chainparams.cpp i have edited the following sections:

pchMessageStart:

    pchMessageStart[0] = 0xf1;
    pchMessageStart[1] = 0xc0;
    pchMessageStart[2] = 0xb6;
    pchMessageStart[3] = 0xd0;
    nDefaultPort = 9333;
    nPruneAfterHeight = 100000;

and the genesisblock:

genesis = CreateGenesisBlock(1512851040, 376896, 0x1e0ffff0, 1, 25 * COIN);

and the checkpoint (the genesis block i created):

      checkpointData = (CCheckpointData) {
        {
            {0,           uint256S("0x6213f0e07c17e4ccef1fd9d023b06ce7e8bdbddaf2c4175197149302b7c351e8")},
        }
    };

    chainTxData = ChainTxData{
        1512851400,
        500,
        0.06
    };

Anything else is unchanged! Ports, etc. are alle the same as with Litecoin!
Please help. debug.log shows no errors. Took different approaches with -listen, -server, -deamon and of course a .conf file. Nothing seems to help.
This is the last step of my first chapter in blockchain development :)

remove the chainTxData

chainTxData = ChainTxData{
    0,
    0,
    0
};

and make sure also that your first block is mined soon after the genesis time.


Can a merchant find my other bitcoin addresses in the same wallet if it sends me money to one? I would like to do business with a merchant (deposits and withdrawals) but do not want the merchant to know that I am one person making multiple transactions.

If I have multiple addresses in a wallet and only use each one once, will there be any way for the merchant to link those to addresses that I have previously done business with them at?

If so, what is the best way to stay anonymous as I have described?

If you are only receiving funds then no, the merchant cannot link the addresses. The problem is if you are also sending them funds. With most wallet software when you create a transaction it doesn't ask you select the specific unspent outputs to spend so it could possibly spend from one of the addresses you are "not supposed" to be associated with.

So let's say merchant sends funds to Alice and Bob, but you're actually both when the merchant thinks you're two different people. If you then accidentally use unspent outputs for Bob when you are supposed to only be Alice (for example, later buying something from that merchant or issuing a refund) -- then the jig is up, the merchant now knows that Alice also has Bob's key(s).


Bitcoin Core full node has saved a lot more space than 260gb I've had Bitcoin Core running on my Macbook i5, 8gb ram, the last five nights and have gotten to 58%. It's downloading to an external hdd and now the blocks directory contains 375gb of data.

Another computer, Huawei laptop i5 8gb ram, started downloading it yesterday and has gotten to 61% with just under 200gb or storage space used. Although this computer first downloaded to its internal ssd and then I copied it to the hdd. Now its crashing all the time in the same way the first has been for the last days.

I cant figure out why its saving more than the original blockchain. Why is this?

This is a known issue and a bug with APFS. This will be fixed in the next version of Bitcoin Core.


I changed bitcoin address but the bitcoin is still stuck in the old address and i don't know how to access my former address??? Please help me I sent bitcoin to my bitcoin core app a few weeks ago, however the app wasn't synced so i tried to export the private key but it wouldn't work, it said it couldn't work for the address, so i changed address but the bitcoins remained in the previous address, i updated my hard drive so i could sync the app and now the app doesn't have my old address in my history but the coins are still in the old address, is there any way i can access the former address??

Where are bitcoins stored?
Some basic principles:
Bitcoins are not actually stored in wallets. Your private-key is stored in your wallet and from that the "bitcoin address" is derived.
The bitcoins are associated with the address.
Movements of bitcoin values are kept track of in an accounting ledger called "the blockchain". Bitcoins are not actually stored in the blockchain, the blockchain just keeps track of the movements of bitcoin values from one address to another.
There is no master copy of the blockchain but lots of people running bitcoin software have their own copies of it and can use it to check transactions.
So bitcoins are not stored anywhere and moving their value from one address to another involves a bitcoin transaction paid for using a mining fee. You cant just change the address of some bitcoins without making a transaction and having it published to everyone's copy of the blockchain.
Where are my bitcoins?
To see how many Bitcoin are associated with your "old address", you can type the address into a "blockchain explorer" website.
If the bitcoin value has been moved ("spent"), this will show you the bitcoin addresses it went to.
Change address
You don't say how you changed the address. Is it possible you mistakenly generated a change address - This is an address for change to be sent back to you when you buy something. Change in a similar sense to small coins returned when you buy something using a large banknote. If you did this, your original address is still usable and nothing is lost or broken.
Recovering from an unusable wallet
Using the private key
See How can I export the private key for an address from the satoshi client? and note that, if your wallet is protected by a passphrase (as it should be), you have to enter command walletpassphrase correcthorsebatterystaple 600 before command  dumpprivkey 1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2 but replacing correcthorsebatterystaple with your wallet passphrase and replacing 1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2 with your old address.

One way to recover from a broken wallet requires the private key. It looks something like either of these two examples

E9873D79C6D87DC0FB6A5778633389F4453213303DA61F20BD67FC233AA33262 or
5Kb8kLf9zgWQnogidDA76MzPL6TsZZY36hWXMssSzNydYXYB9KF

If you have that written down somewhere (which you really should), you can download a lightweight wallet to a new clean computer and import your private key into that wallet. Use a lightweight wallet because it takes much less time to sync and be usable.
Once you have recovered, I would suggest using a paper wallet for long term storage or a hardware wallet for more security. Regularly practise recovering your wallet from backups, recovery-phrases and private keys.
Using an old backup copy of wallet.dat
See Import wallet.dat into a new Bitcoin-Qt client - essentially, make a copy of old wallet.dat install a new bitcoin-core wallet somewhere, stop the program, replace it's new wallet.dat with your copy of the old wallet.dat and restart the program. You may have to wait a few days while it synchronises with the network.


Why can't I create a fork of BTC that has no difficulty changes so I can premine the rest of the coins? I don't want to necessarily do this, but what prevents this scenario from being possible? [just timestamps and a difficulty modifier alone? - if that's the case then why can't I modify the client to be set at a much higher difficulty to mine stuff in anticipation of a harder target as opposed to simply using network difficulty?]:  How come I cannot make a modified version of Bitcoin QT and all historical transactional data re-utilized to mine all past stale blocks and simply premine all remaining bitcoin without difficulty?

Depending on what you meant to ask, the answer is one of the following:

If you run a Bitcoin-qt fork which is incompatible with the rest of the network, you're running a separate currency which has no value (because no one else accepts it).
If you ignore blocks and forge historic timestamps to create a branch with more blocks of low difficulty, it will not be chosen over the main branch because the choice is made based on total difficulty, not number of blocks.


What nodes are best for lessening the risk of loss from a race attack A successful race attack is one where the payment recipient's node receives a spend transaction yet the next block that is mined has a different transaction that spends the same coin.  Thus the payment recipient's transaction will not confirm and the recipient never receives the funds.

This is an explicit attack to double spend.  The recommended protection is to not accept payment on 0/unconfirmed if there is no recourse (e.g., an anonymous buyer who makes off with the item traded before the double spend can be detected.)  For some types of businesses (e.g., retail, low-value goods purchased in-person, face-to-face), the risk is acceptable.

The recommendation for the merchant is to disable listening on the client (using -nolisten) and to explicitly connect to a well connected node (using -connect= ).

How does a merchant know which nodes are well-connected.  Because pool mining solves over half the blocks, ideally the well-connected node is one that reaches these pools first, so that if a transaction is relayed by the well-connected node then the odds are it will end up being the transaction mined by a pool even if there was an attempted double-spend.

Are there any nodes that are known to be good for relaying transactions to the pools, and thus preventing a race attack from being successful?

It would be recommended to connect directly to most of the major pools. This way one doesn't need to rely on any other nodes to relay the informations.

However, you should note that the conflicting transaction could already be pre-mined, rendering such precautions useless.


Can the coin symbol prefix in a cloned NXT blockchain start with a digit? Creating a new blockchain with the Nxt Blockchain Creation Kit, is it possible to use a coin symbol prefix beginning with a digit in the wallet address?

I get an error that the address is malformed when I try this. Should I look for an error, or is this impossible?

No, adding a coin symbol prefix is not doable as it will impact other functions that might take it as a parameter. Your better off just doing it on the front end using a css :before class using the content: property.


What is the relationship of ckeypool and ckeystore? In the source, there are ckeypool and skeystore. I wonder what is the relationship of them and why need both.

CKeyStore is a class for storing keys. It provides the functions for storing and retrieving keys.

CKeyPool is a class for a key that is in the keypool. It is specifically a database object for storing a public key and its location inside of the keypool.

CKeyStore and CKeyPool are two different things and are largely unrelated.

The keypool is the set of keys that are unused. It is separate from CKeyStore and has an entirely different purpose. CKeyPool objects are specific to a CWallet which is a subclass of CKeyStore.


How to transfer private addresses from one wallet to another? My wallet has 3 addresses. My other wallet has 5 addresses. I just want to synchronize those.

How would I do so?

Just export the private key of one wallet and import to the other.


Is there a way to take out a loan on your Bitcoin like how Ethereum can be used as a CDP in the MakerDAO to get DAI? I wanted to sell some BTC to pay some bills, but I also didn't want to lose out on the Bitcoin rise in the inevitable future. Ethereum has the ability to be used as a CDP (“collateralized debt position”) to get the stablecoin DAI which you can cash out at coinbase, but still own the Ether you put up for the loan. As long as you pay back the loan, you can get the eth back.  Is there a method of doing this with Bitcoin?

The closest method of doing this is using an exchange that provides margin trading. The only issue I have with it is that you need to trust your BTC with the exchange. One can recreate what the makerdao has with better rates too, but with a more centralized approach.

Say you wanted to cash out $1000 USD worth of BTC (ex. 0.1 btc @ 10k btc price), but you also don't want to sell it because you see the price might be higher in the long term. What you can do is the following:

Deposit 0.2 btc ($2000) onto an exchange that provides margin.
Sell the 0.2 btc for USD. Now you have $2000 in your account.
Send $1000 to your coinbase or however you want it in and cash out to your bank account. Now you have $1000 USD in your bank.
The remaining $1000 USD that is on the exchange. Open a margin buy position for 0.2 btc.
When the price of BTC doubles from the price you sold at, you close the position. Now you have back your 0.2 BTC minus the fees.

The liquidation price of your margin position will be usually 50% of the price you sold at. Say its 10k, if you were to get liquidated, BTC would need to drop to 5K.

Bottom line, your basically taking a loan out with your BTC as long as the price doesn't drop by 50% from the current price. Also to note, not your keys not your coins risk if the exchange exit scams or freezes your account.


Is bitcoin-qt as PPA really secure? How to proof? With Bitcoins being that much worth currently, I came to the conclusion of using a unique old computer just for this "use case".

I would like to run Ubuntu with bitcoin-qt (from PPA), but now the paranoia kicks in: what if the client is corrupted? I know that I can check against the MD5/SHsomething, but who guarantees that the client itself is not corrupted due to an error/mistake or even intentionally?

It is said that with PPA, nobody guaratees that the software itself is not corrupted, so I am unsure about transfering quite a lot of money to some software I don't know anything about.

You can instead directly install from the source code. It is available on the project site along with release signatures.


What is the approximate hashrate of a human? Which and how much mathematical operations are required for the blockheader-to-blockhash operation and how fast would a human be able to calculate a single hash?

EDIT: For simplicity, I think it's a good idea to use the world record for mathematical calculations to make it a little more fair.

The user C121 on r/bitcoin explored this topic in the thread Mining Bitcoin by hand.

He states that it takes 3385 integer operations to calculate one double SHA-256 hash.

His conclusion was that you would reach about 0.00003 H/s, or in other terms, it would take about 9.4 hours for one hash, assuming the human in question could do a 32-bit operation in 10 seconds.

He also estimates that you would fill about seventy pages of paper with the calculations per hash.

Update:
As Mathias711 pointed out in the comments, Ken Shirriff actually calculated some SHA-256 operations manually and wrote an article about mining bitcoin with pencil and paper. He arrives at an estimate of 0.67 hashes per day, at a vastly uncompetitive energy consumption. ;)


2-of-3 multisignature account with limitations on withdrawal I want to create a 2 of 3 multi-signature account from where one can withdraw money only after a certain period of time. How can this be done?

You will likely need to add an OP_CHECKSEQUENCEVERIFY guard before the OP_CHECKMULTISIG statement in your output script.

https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki


Where do I check if a 1 satoshi / byte fee will go through for a 3xxx address segwit transaction? Where can I go to see if I set a 1 satoshi / byte fee that it will go through in a bitcoin transaction when using a 3xxx segwit address?

You don't know whether a transaction will confirm in advance.

You can look at fee estimation built-in to wallet software, or analysis sites, but ultimately it is up to miners to include your transaction in a block. There is no guarantee whether they will - just be prepared to re-issue or replace the transaction if it doesn't.


How can I work with multiple testnets? Apart from running a private testnet-in-a-box there are also the public testnet instances. You can use this instead of the regular (production) bitcoin network by setting testnet=1 in your bitcoind configuration file. However, the fact that there are multiple instances and not just one testnet can be confusing.

Is it my version of bitcoind that determines which testnet I am on, or something else?

How can I see which testnet I am using?

Is it possible to switch testnet? If I was on testnet 2 and wanted to use testnet 3 would it require upgrading bitcoind? Would upgrading bitcoind automatically bring me over on the new testnet, deleting all my old blocks, transactions and coins from the old one?

Are there other bitcoin clients that support testnet and if so which one(s) do they use?

If I want to use blockexplorer or something similar, do they only support the "latest edition" testnet?

If you are using Bitcoin version 0.7, you are on testnet 3. Updating to that version will put you in the newest testnet. Blockexplorer and Testnet Faucet use that version.


PUSHDATA4 unnecessary? Any data push greater than 520 bytes in a Bitcoin transaction is not allowed (https://github.com/bitcoin/bitcoin/blob/v0.10.0rc3/src/script/script.h#L18).

The opcode OP_PUSHDATA4 specifies, that the next four bytes contain the number of following bytes to be pushed onto the stack. The smallest number using four bytes is 0x10000000=268435456.

But due to the 520 bytes limit and since 520=0x208, we only need at most two bytes to represent the number 520.

So for example, if I want to push any 520 bytes of data I can do: OP_PUSHDATA2 0208 [520-bytes-of-data]. Right?

In that case, what is the PUSHDATA4 used for?

There is currently no real need for an OP_PUSHDATA4, which would allow pushing up to 4GB onto the stack. It was in the original script definition and simply was not disabled when the 520 byte limit was introduced. The only possibility for it to appear in today's scripts is as a non-minimal push and may be caused by a custom client or transaction malleability.


How to pratically doublespend bitcoins? I tried to put bitcoins into an p2p exchange with bitcoin-qt. I added a to small transaction fee, so the coins are now stuck as "Unconfirmed". The offer from the exchange is overdue, so all that will happen if the transaction gets confirmed is that I get them back with an administrative fee.

I would like my coins right now and avoid paying the fee. I've read that you can double spend the coins back to yourself and if I add a higher payment fee than the first time this would probably override the original payment. How can I practically do this? I'm not a hardcore developer but feel comfortable using commandlines and know my way around computers.

Technically, you are not double spending, since the transaction was never confirmed on the blockchain. Double spending is possible by 51% attack; what you are trying is to replace the transaction with one with desired fees, before it is confirmed on chain.

You can use https://github.com/petertodd/replace-by-fee-tools


Buy BTC without linking PAN card and aadhar card How can we buy bitcoins in India without linking our pan card and aadhar card?

Try localbitcoins.com, there is a quick buy option which doesn't require ID


Bitcoin Mixing? Is it even real? I have been trying to find a "bitcoin mixing" service but it seems that ALL the "bitcoin mixing" sites I have looked at are scam. Does anybody know of any that are actually real and do what they say they do??

Take a look at Wasabi Wallet https://www.wasabiwallet.io/ it is a privacy focused wallet and comes with a built-in coinjoin feature.


Is Lightning Offers an improvement over Key Send? The draft for BOLT#12 (Offers) introduces a new payment flow where the receiver of funds posts an Offer. The Payer can then request a unique invoice and pay the invoice. There are significant improvements in the flow including payment and payer proofs.
In a Key Send payment, a payer can send funds to a receiver without an invoice by encoding the preimage in the onion payload for the receiver.
Let's say in the context of donations, a receiver can either post an Offer to use the BOLT#12 payment flow OR post their node's public key to use the Key Send payment flow.
Am I correct in thinking that BOLT#12 is an improvement over Key Send payments? Or are these two solutions solving completely different problems?

Yes, offers are a carefully constructed rethinking of use cases like donations that used to be serviced by hacks like keysend.
One specific improvement for this use case is that unlike in keysend, you do receive a receipt for the donation you are giving.
But offers are meant to service many more use cases beyond just donations, and do so in a less ad-hoc fashion.


ECIES - When is it bad to sign and encrypt using the same keys? Suppose I have a public key for a particular user (perhaps extracted when using the new public key recovery format included in P2SH, and BIP32 transactions).

Is it OK the same key for both signing and encryption?

Since I'm obtaining the public key from a message, PS2H script, or BIP32 wallet I want to make sure that all secrets (Bitcoins, private keys, and privacy relating to BIP32) are maintained and no risk to privacy exists.

What are some known, safe, (or unsafe) scenarios to use the same key for signing and encryption?

Since I'm obtaining the public key from a message, PS2H script, or BIP32 wallet I want to make sure that all secrets (Bitcoins, private keys, and privacy relating to BIP32) are maintained and no risk to privacy exists.

Though it might have changed in the revisions of BIP0032, in some situations you can put the entire wallet at risk if you expose a single private key. You basically never want that happening, both for privacy and security purposes.

You'll need somebody more in tune with EC like Gregory Maxwell to answer the encryption specific questions, in Bitcoin we only sign and never encrypt so it's something I have never researched deeply. I believe in more recent SSL ciphersuites EC is only used for the key agreement and the rest is handed off to a symmetric cipher for speed purposes.

Remember that Bitcoin addresses are usually not designed to stick around, basing any form of encryption on something that is inherently disposable is probably not a particularly wise idea. The only real use we have for message signing functions is for systems like Eligius which do have a static address already due to their function, and we need to prove that the same user is authorizing a change.


How to get public master key of a Ledger wallet? I have a ledger Nano S and would like to know how to extract the public master key of its wallet, in order to do HD key derivation in an external process.

Is there a way or is this info never exposed in any way?

Find the HD Public key for your wallets:

Open the Ledger Wallet Chrome bitcoin app
Click your account in the overview, it’s called “My account” by default
Click “Account Settings” in the top right corner, under the balance
Click “Export” next to “Extended public key”
And when you see the QR code pop, you’re ready to begin the next part.

You can test the address by going to:
https://blockchain.info/xpub/123XYZ where 123XYZ is your public key. You should see your transactions and balance.

Credit: https://keepingstock.net/storing-your-cryptocoins-in-a-bank-with-a-ledger-wallet-52d7895b9dd


Question about Bitcoin Licensing Why is bitcoin using MIT?
From what I understand, MIT doesn't care about trademarks, whereas Apache2 will prevent from using the BTC name. This should help identify the difference with the looming s2x fork where misinformation won't be spread.

From what I understand btc1 is trying to exploit this loophole so they can inject code like this without documenting it properly.

https://choosealicense.com/licenses/

Think of it like Internet.

Tim Berners-Lee could submit patent applications and be much richer, but he wanted everyone to use the Internet.

Satoshi could choose a strict license, but then there won't be that much users and merchants, and only one client. 3-4 devs, editing code would be illegal. This would cause node centralization and if an exploit was found an attacker would illegally change the code of the client and make 51% attack easily.

Main idea: Satoshi wanted everyone to use bitcoin, and allowed everyone to change the code that they're running. Thank you Satoshi for BTC freedom!

And now, they can't change the license, but you can be sure that if BTC had a strict license, the attackers (IYO) would still use changed code client with TOR and no one would be able to stop them.


How often do miners update their block transaction list? Assuming an interval where no block is found, do we know how often the typical miner updates his block transaction list with new transactions from the mempool?

I found a reference which suggests that the default update time is 60 seconds, but I'm not sure what software the pools are using to generate their block transaction lists.

Welcome to the site!
It depends on the protocol being used.
Some protocols have the pool dictate how often the list of transactions is updated, and others have it defined by the mining client.
Stratum
In Stratum, the pool sends the miner a new merkle branch when it sees a new block or when a certain amount of time has passed. By default, it updates the list of transactions every 60 seconds.
Of course, this is only a default; a pool operator can change this.
GBT
In getblocktemplate with longpoll, the pool sends new work on block change, or after 60 seconds. (For bitcoind, at least.)
// Wait to respond until either the best block changes, OR a minute has passed and there are more transactions
...
checktxtime = boost::get_system_time() + boost::posix_time::minutes(1);

(Source)
In getblocktemplate without longpoll, the miner looks for new work every so often. 'Every so often' is miner-defined.
cgminer does it every 60 seconds:
static void gen_gbt_work(struct pool *pool, struct work *work)
...
if (now.tv_sec - pool->tv_lastwork.tv_sec > 60)

(Source)
bfgminer is user-configurable, but defaults to 60 seconds:
--scan-time <arg>   Upper bound on time spent scanning current work, in seconds (default: 60)

(Source)
Conclusion
Changing work every after the network finds a new block and every 60 seconds is by far the most common way of doing things.


Invalid Argument Error when broadcasting a transaction with Bitcore When I try to broadcast a transaction, I'm having this error:

/home/aziz/node_modules/bitcore-explorers/node_modules/bitcore-lib/lib/util/preconditions.js:14
throw new errors.InvalidArgument(argumentName, message, docsPath);
^
Invalid Argument Error
at NodeError (/home/aziz/node_modules/bitcore-explorers/node_modules/bitcore-lib/lib/errors/index.js:20:41)
at Object.checkArgument (/home/aziz/node_modules/bitcore-explorers/node_modules/bitcore-lib/lib/util/preconditions.js:14:13)
at Insight.broadcast (/home/aziz/node_modules/bitcore-explorers/lib/insight.js:96:5)
at /home/aziz/node_modules/megachain-bitcoin.js:39:12
at Request._callback (/home/aziz/node_modules/bitcore-explorers/lib/insight.js:80:12)
at Request.self.callback (/home/aziz/node_modules/bitcore-explorers/node_modules/request/request.js:188:22)
at emitTwo (events.js:106:13)
at Request.emit (events.js:194:7)
at Request.<anonymous> (/home/aziz/node_modules/bitcore-explorers/node_modules/request/request.js:1171:10)
at emitOne (events.js:96:13)
at Request.emit (events.js:191:7)
at IncomingMessage.<anonymous> (/home/aziz/node_modules/bitcore-explorers/node_modules/request/request.js:1091:12)
at Object.onceWrapper (events.js:293:19)
at emitNone (events.js:91:20)
at IncomingMessage.emit (events.js:188:7)
at endReadableNT (_stream_readable.js:975:12)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)

And this is my code:

var bitcore = require('bitcore-lib');
var explorers = require('bitcore-explorers');
var insight = new explorers.Insight('testnet');

    var sendBTC = function (SenderPrivateKey, SenderAddress, ReceiverAddress, Amount) //adresses in string format
    {
        SenderPrivateKey = new bitcore.PrivateKey(SenderPrivateKey,'testnet');
        ReceiverAddress = new bitcore.Address(ReceiverAddress,'testnet');
        SenderAddress = SenderPrivateKey.toAddress();
        console.log(SenderPrivateKey);
        console.log(SenderAddress);
        console.log(ReceiverAddress);

        insight.getUnspentUtxos(SenderAddress, function(err, utxos) {
            if (err) {
                console.log(err);
            } else {
                var tx = bitcore.Transaction();
                tx.from(utxos);
                tx.to(ReceiverAddress, 500000);
                tx.change(SenderAddress);
                tx.sign(SenderPrivateKey);
                tx.serialize();

                insight.broadcast(tx, function(err, txId) {
                    if (err) {
                        console.log('Error!:'+err);
                    } else {
                        console.log('Successfully sent: '+txId);
                    }
                });

            }
        });
    }

Can someone help me? thanks!

Either create the transaction using constructor:

var transaction = new Transaction();

or pass serialized transaction to broadcast method:

insight.broadcast(tx.serialize(), ......


What are some compelling reasons to use Electrum? I currently use Bitcoin-qt on OSX and I'm considering switching to Electrum.

What are the advantages and disadvantages to using Electrum over another Bitcoin client?

My two major concerns are security and ease of use. Is Electrum safe / trustworthy as a client?

Why Electrum?

Instant on: Your client does not download the blockchain, it uses a remote server.
Forgiving: Your wallet can be recovered from a secret seed.
Safe: Private keys are never sent to the server. Information sent by the server is verified using SPV
No downtimes: Several public servers are available, you can switch instantly.
Ubiquitous: You can use the same wallet on different computers, it will auto-synchronize.
Open: You can export your private keys into other Bitcoin clients.
Tested and audited: Electrum is open source and was first released in November 2011.

http://electrum.org/tutorials.html#why-electrum


Bitcoin core has been stuck syncing to the network This keeps repeating in the log file:

2020-04-16T23:59:53Z ERROR: AcceptBlockHeader: block 0000000000000000000fb8b3828b04c17205ffcdedddc8be1d400d132d336460 is marked invalid

The only answer I could come up with myself was to "unprune" the blockchain to force it to redownload. I then reactivated the "prune" feature and restarted the blockchain download. I think the block was corrupted - we'll see.


Opening Wallet with a different App I just bought a couple of bitcoins. I got my wallet from Bitcom.org but I learned that there is this Electrum wallet which Id like to try. How do I open my wallet with the new App?

thanks!

The best way to switch to Electrum is to send all the bitcoins you have on your old wallet to one of the addresses on your Electrum wallet. This way you'll have all your bitcoins secured with your seed.

You could import the private keys from your old client, but you will have to keep a backup of those keys separately as they won't become part of your Electrum seed.

http://electrum.org/tutorials.html#switching-to-electrum


are all nodes validate each transaction added in a new block? are all nodes validate each transaction added in a new block?

Because what if someone said I have completed block and added invalid transaction? and if others node just accepts a block without validating a transaction.

are all nodes validate each transaction added in a new block?

Yes, each full node checks each transaction and block to make sure they are valid according to the network rules.


Sample proof of work in Ruby, what am I doing wrong? Given the following block, how do I verify the proof of work? I got this data from bitcoin-cli getblock and parsed in to a Ruby hash called data:

{"hash"=>"00000000000000001354e21fea9c1ec9ac337c8a6c0bda736ec1096663383429",
 "confirmations"=>2, "size"=>529935, "height"=>347928, "version"=>2,
 "merkleroot"=>"14b2c974a4f9ab92a68f03a491965063d1f8a2e8b2268fdb4cbce92262bb09c0",
"tx"=>"..removed for space convenience...", "time"=>1426554998,
"nonce"=>3284264479, "bits"=>"18172ec0", "difficulty"=>47427554950.6483,
"chainwork"=>"000000000000000000000000000000000000000000056f68a6406c831f16c1bd",
"previousblockhash"=>"000000000000000007c464352935f12c3695f7de4eee8390f444233682abf8aa",
"nextblockhash"=>"000000000000000016e3530b3a7cdaaa495e6eb70aa8f3f15d02fd078235e931"}

I have tried the following:

version = "02000000"
prev = data["previousblockhash"]
merkle = data["merkleroot"]
time = data["time"].to_s(16) #convert to hex
bits = data["bits"]
nonce = data["nonce"]

hashable = version + prev + merkle + time + bits + nonce

answer = Digest::SHA256.hexdigest hashable

The problem is my answer is this:

b7dc9db86cdf47bf1b13274f88b14211a1ce58c52ac1e41c987b4ad65cf50f4f

but the given answer (in data["hash"]) is

00000000000000001354e21fea9c1ec9ac337c8a6c0bda736ec1096663383429

What am I doing wrong?

Thanks for any help,
Kevin

A few things that need to be fixed here:

Endianness - The data given to you in JSON is almost completely in big endian but bitcoin uses little endian to serialize block headers before hashing.
You need to double hash the result with SHA256, meaning apply it once on the header and then apply the algorithm again on the result of the first hash.
Conversion to binary before hashing. You can't just hash the ascii characters, as those are just an encoding for the underlying binary, which is what is meant to be hashed.

I'm not very familiar with Ruby, but I made a short python script that you can use as a reference.

import hashlib
import binascii

def rev(string):
    revsed = ""
    for i in range(int(len(string)/2)):
        revsed = string[2*i : 2*i+2] + revsed
    return revsed

def DoubleHash(string):
    bin = binascii.unhexlify(string)
    hash = hashlib.sha256(hashlib.sha256(bin).digest()).digest()
    raw = str(binascii.hexlify(hash))[2:-1]
    return rev(raw)

# Straight from JSON

version = "02000000"
prev    = "000000000000000007c464352935f12c3695f7de4eee8390f444233682abf8aa"
merkle  = "14b2c974a4f9ab92a68f03a491965063d1f8a2e8b2268fdb4cbce92262bb09c0"
time    = "55078076" # hex(1426554998)
bits    = "18172ec0"
nonce   = "c3c1e61f" # hex(3284264479)

header = version + rev(prev) + rev(merkle) + rev(time) + rev(bits) + rev(nonce)

print(header)
print(DoubleHash(header))

The results:

02000000aaf8ab82362344f49083ee4edef795362cf135293564c4070000000000000000c009bb6222e9bc4cdb8f26b2e8a2f8d163509691a4038fa692abf9a474c9b21476800755c02e17181fe6c1c3
00000000000000001354e21fea9c1ec9ac337c8a6c0bda736ec1096663383429


How used the getrawtransaction for fin the tx blockchain How used the getrawtransaction to find the tx blockchain?

inside the documentation says to use the -txindex, can you give me an example for the complete command please?

When you start bitcoind just pass the -txindex flag in order to have it create the transaction index to be able to get any transaction by id:

bitcoind -txindex

In the console, you can get any raw transaction by its transaction id (hash):

bitcoin-cli getrawtransaction
15f7c2c57cce37d9b8927f957840ec9367bb504780347e497c758ee022b2a143

...


This seems to correspond to the ISO 8601 datetime format, specifically the complete date plus hours, minutes and seconds with time zone designation format.

YYYY-MM-DDThh:mm:ssTZD (e.g. 1997-07-16T19:20:30+01:00)

The TZD hereby stands for time zone designator, which is a ±hh:mm offset from UTC* .

Accordingly, "-05:00" would represent Eastern Standard Time.

* UTC (Coordinated Universal Time) is also known as GMT (Greenwich Mean Time), i.e. the time in London's time zone.


I have the phrase words but I donot know which words shall i insert to get my wallet back , what shall I do? Trust wallet
I have my 12 phrase but I am not able to get my trust wallet back

You insert all of them in the order you wrote them down - assuming that is the same as the order they were shown to you by the wallet when you wrote them down.
See https://community.trustwallet.com/t/how-to-restore-a-multi-coin-wallet/43

Step 1 - Launch Trust Wallet
Open Trust Wallet and then tap on Settings.
Step 2 - Access Wallets
In the Settings screen, you will find here Wallets. Tap on it to display the wallets that you currently have. Tap on the “+” sign on the upper right to access the Import Screen.
Step 3 - Access Wallet Import Screen
Since we are trying to restore a wallet, select I already have a wallet. Then, tap on Multi-Coin Wallet.

If you don't want a multi-coin wallet it appears you can just select Bitcoin.

Step 4 - Input the Recovery Phrase
Almost done. Carefully type the recovery phrase, put in the name of the wallet. Tap on Import.


Are there any web wallets around with open APIs? For a long while, blockchain.info offered a web wallet with a convenient web API, but it recently turned out that it now requires an installation to function. I'm wondering - are there any other reputable web wallets out there for developers, with open APIs for sending / receiving coins that don't require an installation of any sorts?

Yes, block.io is a good alternative with full wallet functions. No requirement for NPM or a VPS.


How to get unspent bitcoins using bitcoinj I'm trying to get unspent transaction using bitcoinj like here
without using api calls. How can I do this?

Bitcoinj is only a library, but there is an experimental full verification mode that would allow this. https://bitcoinj.github.io/full-verification  It is important to note it is not intended for production use and almost certainly contains chain splitting bugs.


Any source for a visualized SHA-2? Is there any source that visualizes how SHA-2 works (including internals) with animated video or an interactive web page?

you can check this repo, iti si creedt for Cryptography For Developers, Simon Johnson (pg. 218):
https://github.com/in3rsha/sha256-animation


BIP 113 - monotonic guarantee BIP 113 mentions:

  Existing consensus rules guarantee this value to monotonically advance, thereby removing the capability for miners to claim more transaction fees by lying about the timestamps of their block.

Can you please explain where this guarantee comes from?

The guarantee comes from the consensus rule that a block's timestamp must be greater than the median timestamp of the last 11 blocks. This median timestamp is known as the median time of the block. Because the median is used, and because timestamps of each block must be greater than their median time, the median time will always increase from block to block. This also means that the median time for a block is set prior to it being mined.


Why are certain transaction not visible on blockchain.info? For example this transaction is visible here but not on blockchain.info

https://blockchair.com/bitcoin/transaction/4c26a54af671b4b86cebe648134fd3e4f05634cf3b86523c17882d416b28ebb0

Why is that?

Every node builds it's own blocks. Blockchain.info is simply unaware of the existence of this transaction, it will be aware when it will be implemented in a block that will be broadcasted to the network. In other terms, it will show up on Blockchain.info when it is confirmed.


How to convert encrypted wallet.dat to decrypted? (Yes, I know the password) I don't want to spend transaction fee for transferring coins to unencrypted wallet.dat.

What should I do?

The easiest way is to export your private keys using the dumpprivkey functionality.

  DumpPrivKey: returns the wallet-import-format (WIP) private key corresponding to an address. (But does not remove it from the wallet.) Bitcoin Developer Reference

Do this for each address that is storing bitcoin (use listreceivedbyaddress to view all addresses with funds)

  ListReceivedByAddress: lists the total number of bitcoins received by each address. Bitcoin Developer Reference

Then create a backup copy of your wallet.dat file and then remove it.  The next time bitcoin-qt runs it will create a new empty unencrypted wallet.  Now you can use importprivkey to restore your funds.

  ImportPrivKey: adds a private key to your wallet. The key should be formatted in the wallet import format created by the dumpprivkey RPC. Bitcoin Developer Reference


Pros & Cons of Using the "Satoshi" Method to Track User Deposits In this question user @lungj suggests using "satoshi" as a marker for user deposits.

Another method I’ve seen used on bitcoin is using satoshis as a
marker. For example, when paying for a one bitcoin item, an additional
7 satoshi could be added to the amount due to distinguish from another
user asked to add 6 satoshi. Payments must be in exact amounts for
this to work (but you can always refund an incorrect payment, less
fees, to a sender). This does not scale all that well if your IDs must
be permanent. This avoids the need for users to interact with a
contract to include metadata.

This method basically allows all users of a service to deposit funds to the same Bitcoin address while allowing us to keep track of who deposited which funds.
Off hand I can think of two potential issues with this method:

If we reserve 1 Bitcoin address to 100 users, we are adding a minuscule amount of $$$ to each payment (between 1 - 10 cents if Bitcoin exchange rate = $100,000)
It only works when we know in advance how much the user intends to deposit (otherwise there's no way of calculating how much extra "satoshi" was added to a payment (so it won't work for general deposits)

What are some of the other pros and cons of using this protocol to keep track of user deposits? Are the issues above solvable?
Thanks

That's a question about Ethereum, a system that's notoriously difficult to accept payments with due to some incredibly bad design decisions. Ethereum has operational costs for making new addresses which make this sort of poor engineering attractive.
We have no need to do anything ridiculous like that to try to distinguish payments, we can just make a new address per payment and have people pay to it. There's no need to try to re-use addresses as there's no resource being consumed by you creating new ones. All this would serve to do is cause mass confusion, difficulty when people made two transactions to pay an invoice, and unmitigated confusion about who owns what payment if anything goes awry.
There is no pros at all to what you're describing.
One new address, per invoice, per user. There's no reason to over think it.


Difference between bitcoin-cli getnetworkinfo version and bitcoind --version I tried to upgrade bitcoin core from 0.18.0 to 0.20.0.
When I ask for the version through bitcoind bitcoind --version it prints Bitcoin Core version v0.20.0 but if I ask for the version through bitcoin-cli bitcoin-cli getnetworkinfo it prints "subversion": "/Satoshi:0.18.0/"
How is this possible that this is not the same?

bitcoind --version is asking the bitcoind binary what its version is
bitcoin-cli getnetworkinfo asks the currently running bitcoind what its version is

So this means that you at some point had a 0.18.0 bitcoind, started it, then installed a 0.20.0 one, but the 0.18.0 one is still running.


How can SPV nodes trust received Open Assets? I was reading over the specification for the Open Assets (colored coins) protocol. It seems that keeping track of Asset ownership requires looking up the scriptPubKey for each input in a transaction, and possibly even recursively looking up the prevouts for inputs, in order to verify the chain of ownership. Full nodes can do this, as they process all blockchain data.

However, it's possible to make a transaction that looks like a valid Open Assets transaction, but that breaks the link in ownership somewhere along the way. More confirmations won't help convince SPV nodes that the transaction is a valid OA transaction, as miners do not enforce that all transactions structured as OA transactions are actually valid.

Can SPV nodes participate in the Open Asset protocol with any reasonable security?

You can't trust pure SPV for any Bitcoin 2.0 protocols, because of the 'metadata faking' issue that you outline. You have a few options:

Accept you need to run a full node to backtrack through transactions. (Though note that this will not scale well anyway for popular assets.)
Use a blockchain that has native support for assets, like Sidechain Elements or MultiChain.
Use some kind of external service to track assets, like the CoinPrism API for Open Assets or CoinSpark's federated asset tracking model.


Connect mined blocks with various addresses From code:

 // Create coinbase tx
 CTransaction txNew;
 txNew.vin.resize(1);
 txNew.vin[0].prevout.SetNull();
 txNew.vout.resize(1);
 CPubKey pubkey;
 if (!reservekey.GetReservedKey(pubkey))
     return NULL;
 txNew.vout[0].scriptPubKey << pubkey << OP_CHECKSIG;

 // Add our coinbase tx as first transaction
 pblock->vtx.push_back(txNew);
 pblocktemplate->vTxFees.push_back(-1); // updated at end
 pblocktemplate->vTxSigOps.push_back(-1); // updated at end

How I can connect mined blocks with various addresses in base58? Not only with miner address.

I want send part of mined value to one address (developer fund), different of miner address.

add vtx[1]?
Only check it in connectblock and createnewblock functions?

This isn't a complete answer but I might be able to point you in the right direction:

It seems like you have:

CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)

So you're taking a CScript  as a parameter. Some additional relevant links.  I think you would either use that to create multiple outputs, or you would use

txNew.vout[1];

https://en.bitcoin.it/wiki/Transactions#general_format_.28inside_a_block.29_of_each_output_of_a_transaction_-_Txout
https://en.bitcoin.it/wiki/Script
https://dev.visucore.com/bitcoin/doxygen/script_8cpp.html
https://dev.visucore.com/bitcoin/doxygen/class_c_transaction.html
(and follow the links to CTxIn/CTxOut from there

Also see how they do it here:
 - https://dev.visucore.com/bitcoin/doxygen/miner__tests_8cpp_source.html


What are the sizes of single-sig and 2-of-3 multisig taproot inputs? There was a Twitter discussion about the sizes of inputs and Taproot came up. What are the input sizes for Taproot inputs?

Please cover both the key path spend (single-sig or default spend) and 2-of-3 multisig script path spends.

Taproot generally has two ways of spending. The default way is to spend the output using the key path: pay-to-taproot then behaves like a p2pk output except that it is using a schnorr signature and the corresponding address being encoded using bech32.

The alternative is to reveal that the inner key was tweaked with the root of a Merkle tree, the Merkle path to one of the leafs, and the arbitrary segwit v1 script contained in the leaf, and then to fulfill the spending conditions of this script.

In the following, a 2-of-3 spending condition is split out into three 2-of-2 conditions:

2-of-{A, B, C} = (A && B) || (A && C) || (B && C)

The assumption is that two of the keys are hot while the third is a backup key for recovery. The default case of spending with the two hot keys is aggregated into the root path pubkey using MuSig. The other two spending conditions using the backup key are stored in leaves of the tree. Two variants are explored: one where the backup key is capable of participating in MuSig signing, another that falls back to a simpler multisig scheme where signing is non-interactive e.g. because the backup key is airgapped and the multiple roundtrips required for MuSig are inconvenient.

Key path spending costs

* outpoint (txid:vout): 32+4vB
* scriptSig size: 1vB
* nSequence: 4vB
* num witness items: 1WU
* witness item size: 1WU
* signature: 64WU

32+4+1+4+(1+1+64)/4 = 57.5vB

Control Blocks

Control blocks are used to reveal the script path and prove the inclusion of the script. For a single leaf, the root is equal to the leaf and the tree has a depth of 0 additional layers. Two leaves require a depth of 1.

Depth 0 control block:

  * Length of control block: 1WU
  * Header byte (script version, sign of output key): 1WU
  * Inner key of root key: 32WU
= 34WU

Depth 1 control block:

  * Length of control block: 1WU
  * Header byte: 1WU
  * Inner key of root key: 32WU
  * Hashing partner in tree: 32WU
= 66WU

Script path spending cost in addition to key path spending cost

Script path spend assuming 2-of-2 MuSig leaf

* script size: 1WU
* script "<pk> OP_CHECKSIG": 33+1WU
* Depth 1 Control block: 66WU

57.5+(1+34+66)/4 = 82.75vB

Leafs cannot do MuSig, construction with 2-of-2 OP_CHECKSIG:

* +2nd sig: 1+64WU
* script size: 1WU
* Script "<pk1> OP_CHECKSIGVERIFY <pk2> OP_CHECKSIG": 33+1+33+1=68WU
* Depth 1 Control block: 66WU

57.5+(1+64+1+68+1+1+32+32)/4 = 107.5vB

Discarded other variants

Less efficient construction for 2-of-2 OP_CHECKSIG

* +2nd sig: 1+64WU
* Length of script: 1WU
* Script "<pk1> OP_CHECKSIG <pk2> OP_CHECKSIGADD 2 OP_EQUAL": 33+1+33+1+1+1=70WU
* Depth 1 Control block: 66WU

57.5+(1+64+1+70+66)/4 = 108vB

Less private, more costly variant with a single 2-of-3 leaf in lieu of two 2-of-2 leaves:

* +2nd sig: 1+64WU
* +1 empty witness item: 2WU
* Length of script: 1WU
* Script "<pk1> OP_CHECKSIG <pk2> OP_CHECKSIGADD <pk3> OP_CHECKSIGADD 2 OP_EQUAL": 33+1+33+1+33+1+2=104WU
* Depth 0 Control block:

57.5+(1+64+2+1+104+1+1+32)/4 = 109vB

Disclaimer: All data best effort, don't trust, verify. Also, please correct me, if I made a mistake somewhere.


Applying additional oauth scopes to coinbase I am trying to apply the coinbase wallet API with oauth to use its send functionality. I have been able to connect to the API and use its endpoints, but whenever I try to use the send functionality, I am thrown the error Invalid amount for meta[send_limit_amount]. My omniauth initializer looks like this:

provider :coinbase, , ENV['CLIENT_ID'], ENV['CLIENT_SECRET'],
scope: 'wallet:user:read wallet:user:email wallet:accounts:read wallet:transactions:send'

The reason for this error is because, in order to use the send functionality, coinbase requires additional parameter meta[send_limit_amount]. Where and how am I supposed to apply this additional scope?

Old posting, but hit this and this was the first Google result so worth updating.  You can append the meta values to the redirect URL:

 meta[send_limit_amount]=50&meta[send_limit_currency]=USD&meta[send_limit_period]=day

This is buried in the OAuth2 docs on the Coinbase site.


Can someone show me an example rootstock smart contract that is the equivalent of an Ethereum Smart Contract? Coming from Ethereum, is there an example rootstock smart contract code that is the equivalent of an Ethereum smart contract code?


Rationale behind accepting btc as a mode of payment? Tesla has said they "expect to begin accepting Bitcoin as a form of payment for our products in the near future."
But Bitcoin doesn't scale. It achieves about roughly 6 transactions per second, paling in comparison to the likes of Visa, which facilitates around 1,700 transactions per second.
What's the rationale behind their decision?

Sending a Bitcoin payment incurs a fee relative to the weight of the transaction. Every transaction must have at least one input and one output. Assuming a minimal transaction weight for either, it costs the same to send 1 mBTC or 100 BTC.
The cost per transaction weight is one reason why on-chain transactions are ill-suited for micropayments, but it also means that larger payments can come at a significantly lower relative cost than other payment forms.
A new Tesla 3 costs about 0.9 BTC today. At a feerate of 150 sats/vB (next block confirmation even at high demand) and a transaction weighing 250 vB, the transaction fee of 37,500 sats (0.375 mBTC) translates to a relative fee of 0.0417%. I believe that you will find many other payment forms to incur a larger fee, especially for the merchant.
On the other hand, payments on the Lightning Network incur a cost relative to the paid amount, so I expect smaller payments to shift to Lightning Network and similar solutions more and more.


How do I flush the keypool? After the heartbleed vulnerability, I'm concerned that my private keys could have been compromised.  I want to send all my coins to a new address with a freshly generated key.

However, if I just ask the Bitcoin Core client to generate a new address, it will just select one from the existing keypool.  The keypool keys may also have been compromised, so I don't want to use them.  I want a key that is really brand new.

Short of asking Bitcoin to generate hundreds of new addresses to exhaust the keypool, is there a way to flush the keypool and start getting fresh addresses?

I understand this happens when you encrypt a wallet, but I prefer not to do that.  (Anyway, if my wallet was already encrypted, that wouldn't be an option.)

If you call getnewaddress 100 times (via RPC for bitcoind, in the debug console for Bitcoin-Qt), the key pool is flushed.

After that, you can request one more new address and send all your funds there.


Selfish Mining: stale or orphan? In terms of a selfish attack many sources speak of orphaned blocks, i.e. blocks that are not on the main chain and thus not paying any coinbase transaction to its miner. Still I'm not sure and confused by terminology.

Don't we actually mean stale blocks when talking in context of selfish mining?

Despite an answer by Pieter Wuille to a similar question I'm not sure which type would apply to a block outside the best chain in a selfish mining scenario.

Here's an extract to Pieter's answer:

  However, there also exist real orphan blocks, with orphan in its original meaning of "having no parent". These are blocks received by a node that does not have its entire ancestry (yet) and thus cannot be validated. Nodes keep such blocks in memory, while asking their peers to fill in the gap of their history. The client does not show these, so when people talk about orphan blocks, they are most likely referring to extinct blocks. Note that since Bitcoin Core v0.10, there are no such orphan blocks anymore, due to a significant change in the download mechanism.

Furthermore I'd love to know if and which of stale or orphaned blocks are pruned from history? And in what time intervals, if so?

Don't we actually mean stale blocks when talking in context of selfish mining?

You always mean stale blocks, never orphan ones.

An orphan block is one that you can not connect to your local chain because you are missing a parent, in the current version of the software you can never get into the situation where this happens. When most people are talking about an "orphan block" they mean "stale block", the syncing behavior is not something users ever come into contact with.

This misnomer comes from when users mined with bitcoin-qt, when a block became stale the transaction paying the coinbase output into their wallet would gain the tag "orphaned". People associated the term "orphan transaction" with "orphan block" incorrectly, not helped by the fact that many popular websites also use this term to describe stale blocks as well.

  Furthermore I'd love to know if and which of stale or orphaned blocks are pruned from history?

They are retained on disk in case they are used again in the future. There is no process for removing stale blocks from disk specifically.


Hash functions in Bitcoin source codes I'm new to programming. I got into it because I wanted to learn Bitcoin.

I've downloaded the source files from Bitcoin Core. Can anyone enlighten me where the source codes related to the hash functions are located at?

I'd say in the src/crypto folder: https://github.com/bitcoin/bitcoin/tree/efb4383ef6c69e801ddca160a53e7fb4ee8b156a/src/crypto


How to transfer blockchain between two machines? I have two computers A and B. A has a partial history of bitcoin blockchain (about 60% of entire history) which is not pruned (~120GB). I would like to transfer the history to B and run a pruned full node there. Both machines are on the same local network. (B is not connected to the internet)

So far I have run this on machine A (192.168.1.100):

bitcoind -whitelist=192.168.1.0/24 \
         -disablewallet \
         -blocksonly \
         -maxconnections=1 \
         -upnp=0 \
         -listen=1

And on machine B (192.168.1.104):

bitcoind -addnode=192.168.1.100 \
         -connect=192.168.1.100 \
         -listen=0 \
         -upnp=0 \
         -maxconnections=1

However, B does not receive any blocks from A. Is that because A is not fully synced? How can I copy all blocks from A to B without having to contain them all at any point of time on B (B has about 8 GB free storage)?

A node won't sync blocks from another node (peer node) if the peer node is not fully synced. There might be a message in your debug.log that says as much. Your best bet is to wait until node A is fully synced.

This is the only reason the node won't sync.


get the location of UTXO data I need to find the location of the code which deals with UTXO, and then implement FIFO on UTXO storage. I aint able to find the location of UTXO code and also where it is stored.

What you want is the code for Florincoin's wallet's coin selection. This is found in the CreateTransaction function. Within CreateTransaction, the wallet also calls SelectCoins and that calls SelectCoinsMinConf. The coins are actually selected with SelectCoinsMinConf but SelectCoins and CreateTransaction are all involved with coin selection.

Also, because Florincoin's wallet is based on Bitcoin Core, it does not use FIFO for coin selection. Rather it uses Bitcoin Core's special algorithm for selecting coins which is difficult to understand (it tries to solve the knapsack problem by selecting exactly the amount you want to spend, but then it does some weird things to handle fees and change).


What does this mean? connected to stratum.bitcoin.cz diff 1 with stratum as user xxxxxxxworker1
block f9aa8c61...Diff 4.25 started [20:26:18] Best share 0
Stratum from pool 0 detected new block

I just started doing this and it looks like I'm doing it wrong. Am I?

This seems normal. Wait 10 minutes and see if theres some "Yay!!!" messages


reproduce CVE-2018-17144 (inflation bug) on regtest for learning I'm reviewing CVE-2018-17144 inflation vulnerability for learning. I think I reproduced the error on regtest. Is it a correct way to reproduce it? I want to know if I'm missing something about it.

Steps to reproduce:

I have 2 regtest nodes; bitcoindA, bitcoindB. The both version are v0.16.2 and connected each other.

bitcoindA is running as mining node with the following patch to accept invalid transaction.

$ git diff
+++ b/src/consensus/tx_verify.cpp
@@ -181,6 +181,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, bool fChe
     }

     // Check for duplicate inputs - note that this check is slow so we skip it in CheckBlock
+    fCheckDuplicateInputs = false;
     if (fCheckDuplicateInputs) {
         std::set<COutPoint> vInOutPoints;

[1] generate 2 addresses on bitcoindB. (for receive the invalid utxo)

2NBeTpfn57VpE4e167tFuEtc761jYX7t893,
2N2bb6idv8qsPULP2rqGYoC5yirvVos6YEU

[2] mining 101 blocks on bitcoindA

$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -regtest generate 101

[3] check the spendable txid from the mined block and a create transaction with the txid. duplicated utxo are set like the following.

$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -regtest createrawtransaction '[{"txid":"5214dc65e9c9d75550a29e9ef9773452d808c5fd0c56bfe396eb7c2d034f5778","vout":0},{"txid":"5214dc65e9c9d75550a29e9ef9773452d808c5fd0c56bfe396eb7c2d034f5778","vout":0}]' '{"2NBeTpfn57VpE4e167tFuEtc761jYX7t893":99.99}'

[4] sign, broadcast and mining on bitcoinA. And then check utxo on bitcoinB.

$ ./bitcoinB/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16592 -regtest listunspent

[
  {
    "txid": "c885a3f8c0275424401d2793e69aa6bca81f7badbfc1755e18033e8801b74703",
    "vout": 0,
    "address": "2NBeTpfn57VpE4e167tFuEtc761jYX7t893",
    "account": "",
    "redeemScript": "00141c8746e62e30554790f9bd74eeea89f45bdd5e13",
    "scriptPubKey": "a914c9d76124901125aaf2a9b37d8e2d1103a9e5508387",
    "amount": 99.99000000,
    "confirmations": 1,
    "spendable": true,
    "solvable": true,
    "safe": true
  }
]

[5] check if the above utxo is possible to send to the generated address (2N2bb6idv8qsPULP2rqGYoC5yirvVos6YEU)

No, that's incorrect, there is two types of double spend:

single transaction spending the same utxo
multiple transaction spending the same utxo

CheckTransaction() which is called by CheckBlock() only validate the first case, not the second, the second is done by both Consensus::CheckTxInputs and CheckInputs(),

if you look at the code in CheckTransaction, it only check whether there are duplicated vins exists in the same transaction, it doesn't know whether the vins has been spent in another transaction.


Is DNSSec needed / Possible with namecoin? I'm interested in the most secure and reliable Namecoin DNS resolution as possible, although I admit I don't fully understand how these concepts relate to each other (Namecoin and DNS)

Is DNSSec needed or possible with Namecoin based DNS services?  Would that come at a higher "cost"  (more namecoins are needed?)

No DNSSec is not needed with Namecoin.  The mapping from name to IP cannot be forged.

However, DNSSec requires changes to resolver libraries so the domains are actually cryptographically verified.

Namecoin, to be secure, requires similar changes to resolver libraries because nothing in the current resolver libraries actually checks the integrity of the results.

Anyone can run software to verify that a traditional (insecure, no cryptography) nameserver that resolves .bit addresses actually return addresses corresponding to the blockchain.

Thus namecoin name servers can be ensured to not "fool all the people all the time" by having some servers that continuously check the integrity of the results produced by the insecure but backwards compatible nameserver.


Why does bitcoin mining take so long? I was wondering that a block (Here's a Block #506398)

It's nonce is 1,229,291,212 (A little over a billion), Then why does it take so long to mine a block because my system alone can do about 500 GH/s (500,000,000,000 Hashs per second), Which is very little in comparison to what an ASICs can do.

Then why does it take so long to mine a Block??

Thanks for your help!!

The entire purpose of proof-of-work mining is to force participants to spin their wheels doing busywork.  It takes about 10 minutes to mine a block because the difficulty automatically changes so that it always takes about 10 minutes to mine a block.  When more hashing power is added to the network, the difficulty increases to accommodate.  The time it takes to mine a block is intentionally set to 10 minutes.

You should read What exactly is Mining? for clarification.


Do extra hop channels in a BOLT#11 invoice need to exist on chain? According to the BOLT#11 specification, a node may add extra routing information for private channels to an invoice, where they specify the public key of the penultimate hop, along with the short_channel_id.

  r (3): data_length variable. One or more entries containing extra routing information for a private route; there may be more than one r field

  pubkey (264 bits)
  short_channel_id (64 bits)
  ...

However, unlike channels announced through a channel_announcement message, there are no signatures to prove that the invoice payee actually owns that channel, or even that it really exists. Technically, it appears that the invoice creator could point to any valid 2-of-2 UTXO on the chain and claim it to be their private channel.

Do existing implementations check whether the transaction referred to by the r field's short_channel_id actually exists on the blockchain and that they are valid 2-of-2 multisig transactions?

If not, could short_channel_id in the invoice r field be re-purposed to refer to some abstract account which the pubkey in the hop information has custody of (Such that the pubkey node unwraps the last onion packet himself and signs any messages with the private key associated with the account)?

A user sending a payment should not need to worry about whether the channel really exists, as long as they receive the payment from the node who owns pubkey.

Otherwise, if there are any potential risks, should the BOLT#11 specification also be modified to include a pair of signatures for the funding transaction which short_channel_id refers to?

What you propose is (theoretically) totally possible but as far as I understand (for a good reason: the short_channel_id would loose its semantics) not implemented.

The problem is as far as I understand that even the construction of private channels are currently implemented with a 2-2 multisig wallet. You could patch your lightning node though so that your private channels could operate on a different payment channel mechanism (or without an actual channel as an what you call it abstract channel)

Let us assume you have such an abstract channel after patching your lightning node:
The sender who creates the payment would use the channels from the invoice to create the onion. In the onion the sender has to use the short_channel_ids that are given from the gossip protocol and from the invoice.

As far as I remember the code the node creating the invoice relies on the fact that the information from the gossip protocol and the invoice is correct and constructs the onion. In particular the existence of a private channel cannot be checked against the gossip store anyway. Also the nodes routing the payment don't know later hops anyway and don't care.

So only your nodes that run private channels who are actually forwarding the payment have to see if they know the channel (and they should if they mess around with the protocol. The channel does not even have to be backed on the blockchain in such a case)

However theoretically the sender could - when creating the onion - check if there is at least an output on the blockchain that is referenced by the short channel id and that the output is at least a 2-2 multisig wallet. However that would only be a a hint that this output belongs to a funding transaction of an actual payment channel. In general payment channels cannot be detected for certain from the blockchain data.

BTW: When I was tinkering about similar ideas I came up with the name virtual payment channels instead of your proposed name abstract payment channels. Meanwhile I believe the best way to construct virtual payment channel is by fetching the htlc of the first node in your private network. This can for example be done with a c-lightning plugin (which does not exist in an open source way) and can be used to scale a farm of lightning nodes for an HA service. ]

I recommend waiting until rendezvous routing from BOLT1.1 is implemented. With Rendezvous routing it will be very easy to construct private channels. You can create an onion with a rendez vous point outside of your private network and as soon as the onion enters your network the first node can catch the htlc and talk with the real recipient over any communication protocol to release the preimage.