Create a Double sha256 block and trandaction

The problem is that you are hashing the string of the hexadecimal representation of the bytes of the block header, not the bytes of the block header itself. You need to hash the bytes of the block header itself.

You need to set everything as a byte array, not a string. So you would have something like this for the entire block header all together:

Byte[] block_header = {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 0xa3, 0xed, 0xfd,
                       0x7a, 0x7b, 0x12, 0xb2, 0x7a, 0xc7, 0x2c, 0x3e, 0x67, 0x76,
                       0x8f, 0x61, 0x7f, 0xc8, 0x1b, 0xc3, 0x88, 0x8a, 0x51, 0x32,
                       0x3a, 0x9f, 0xb8, 0xaa, 0x4b, 0x1e, 0x5e, 0x4a, 0x29, 0xab,
                       0x5f, 0x49, 0xff, 0xff, 0x00, 0x1d, 0x1d, 0xac, 0x2b, 0x7c};

It's possible convert the string hex into matrix byte in C++ with this code

  vector<unsigned char> ToHexIntoVectorByte(string &hexData)
{

  vector<unsigned char> *bytes = new vector<unsigned char>();
  for(unsigned i = 0; i < hexData.length(); i += 2)
  {
      string byteSubString = hexData.substr(i, 2);
      unsigned char byte = (unsigned char)strtol(byteSubString.c_str(), NULL, 16);
      bytes->push_back(byte);

  }
  return *bytes;
}

for extract the matrix in the unsigned char using vectorresult.data() and if using the Bitcoin-Cryptography-Library the final code is

vector<unsigned char> vectorByte = ToHexIntoVectorByte(stringHex);

Sha256Hash shaHash = Sha256::getDoubleHash(vectorByte.data(), vectorByte.size());


Is there software or a service to let you manage multiple crypto currency exchanges from one interface?

check coinpayments API. supports trade(via shapeshift) deposits & withdraws with multiple currencies.


What software should I use to open the .dat flles

The .dat files are opened by Bitcoin Core, they are not supposed to be opened in plaintext. The blockchain will be in the blocks/ subdirectory. You can see a list of the files bitcoin core uses here:
https://github.com/bitcoin/bitcoin/blob/master/doc/files.md


Can a channel be closed while the funding tx is still stuck in the mempool?

I started out writing this answer while trying to do it myself, but then found out that we don't yet have tools to manually edit partially signed Bitcoin transactions (PSBTs) which is the very last step before we finalize the double-spend. So this answer is currently incomplete, but I'm planning on building out that tooling and write a plugin that automates all of this, so it get much easier

Given that you're asking for c-lightning let me walk you through the options you have:
Wait and rebroadcast
If the fee is not way too low, and the peer hasn't given up yet, you could have a chance of still establishing the channel, by confirming the original funding transaction. It might require you to rebroadcast the transaction from time to time when it drops out of the mempool. To do so take note of the funding transaction that was returned when calling fundchannel or retrieve it from the database by looking its ID up:
CHANID=$(lightning-cli listpeers [peer_id] | jq '.peers[].channel_id')
sqlite3 $HOME/.lightning/bitcoin/lightningd.sqlite3 \
        "SELECT hex(rawtx) FROM transactions WHERE hex(id) LIKE '$CHANID'"

This will get you the funding tx for that particular peer. You can use bitcoin-cli decoderawtransaction to decode the transactions and verify that the txid matches the funding_txid in the lightning-cli listpeers output.
You can then rebroadcast using the bitcoin-cli sendrawtransaction or lightning-cli sendrawtransaction methods.
I suggest waiting at least over the weekend, since fees drop considerably, increasing chances of the tx confirming anyway.
Double-spending the funding transaction
If you need the funds somewhere else, or decided the channel isn't worth waiting for you can also double-spend any of the inputs and the funding transaction will never be able to confirm.
 Notice that you wont be able to open a new channel with that specific peer until both sides have given up, as from c-lightning's point of view it may still happen and we need to be ready if it does
To do this look up the funding transaction like above, then use the following to list the inputs of the funding transaction:
bitcoin-cli decoderawtransaction [tx] | jq '.vin[] | [.txid, .vout]'

Next we synchronize the UTXO status with bitcoind, since we marked the outputs spent by the funding transaction as spent (note that you need to have c-lightning compiled with DEVELOPER=1 for this to be available):
lightning-cli dev-rescan-outputs

Now pick a subset of the inputs and create a new transaction, that collides with the funding transaction on purpose to double-spend it:
lightning-cli utxopsbt satoshi=all feerate=normal startweight=756 utxos=["ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB:0"]

This gives you a partially signed Bitcoin transaction (PSBT), which has one input ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABAB:0 (matching the result from the decoderawtransaction results above) and no output. Notice the startweight is 756sipa, which is approximately the size of a single-input-single-output transaction which we're trying to build.
This isn't a valid transaction yet, so we need to add an output that goes back into your wallet. To do this we first generate an address to send to your wallet:
lightning-cli newaddr

And now we need to amend the PSBT to include an output with all funds (minus the fee) going to that new address.
... but we don't have tools in place yet to manually edit a PSBT, or at least I'm no aware of any. I'll follow up once we have.


What hardware do I need to get started with Bitcoin?

Nothing out of the ordinary hardware wise is necessarily required if you are just using bitcoin as a currency. The only case you would need specific hardware was if you intended on mining bitcoin. For just normal bitcoin transactions you can utilize whatever electronic device you are using to visit stack-exchange.

There are really only 2 big decisions you have to make as a user. What wallet do you want to use and what exchange you want to purchase bitcoin from. Below is a resource to help you decide what wallet would meet your needs (it depends on the device you are using and the security level you require)
https://bitcoin.org/en/choose-your-wallet

There are two characteristics that make up the main difference between wallets, one being the type of environment they work on ie: some are for desktop computers, some for mobile devices and some are web based and work through the web-browser. The other is if they are full validation wallets or simplified validation. As a starter I would suggest beginning with a simplified validation wallet like electrum and getting your feet wet with that. Later as you learn more about bitcoin you can decide if running a full validation wallet like bitcoinqt would be something you'd be interested in doing to help out the network.

The second thing you need to decide is what exchange you want to use to purchase your bitcoin. This mainly depends on your location and personal preference.

Here is a general resource to help you learn more information about bitcoin:
https://bitcoin.org/en/getting-started

I would suggest reading up on most of the bitcoin.org pages, the whole website is a great resources for people new to bitcoin.


Convert plaintext script into hex-encoded script in python

I'm reading the specification. Your hex string has to start with 6a [OP_RETURN opcode] followed by 4c [OP_PUSHDATA1] followed by a one-byte number indicating the size (in bytes) of the following data. You have 10 bytes, so this 0a. Then come your actual data, and here I think you made a mistake. In any case, 0102030405060708090a (in your by-hand example) is neither the hex encoding of the string "12345678910" nor of the integer 12345678910. Look at this python snippets:

>>> from binascii import hexlify
>>> hex(12345678910)
'0x2dfdc1c3e'

>>> hexlify("12345678910".encode()).decode()
'3132333435363738393130'

So I guess you need to clarify what your data represent and how you want it encoded...


Do I need to keep all blocks when running Bitcoin Core?

Full nodes keep all blocks by default, but this is not necessary to achieve full node security. Full nodes validate the complete blockchain and enforce all consensus rules regardless of whether a full history is kept.
Keeping all blocks is a service to the network, as you'll be able to provide all blocks for synchronizing nodes or requests of thin clients.

If keeping the full blockchain is a problem, you can reduce the storage-footprint by running Bitcoin Core in pruning mode. Just add prune=<n> to your bitcoin.conf, where <n> is the amount of youngest blocks you want to keep in terms of mebibytes storage. The minimum is 550 MiB.


While verifying previous blocks, how does the node know the difficulty at nth block?

Contrary to popular belief, the difficulty is not actually based on the number of leading zeros, that's just an oversimplification to help people understand what difficulty is. Rather the difficulty is based on the value of the block hash when interpreted as an integer. The difficulty of a block must be less than or equal to a target value. The target value is adjusted every 2016 blocks and is encoded in a compact form in every single block (it is part of the block header).

When a node is syncing, they start with the target value encoded in the genesis block. Every 2016 blocks, a very simple algorithm is run to calculate the target value for the next 2016 blocks. This algorithm is deterministic, so given the same set of blocks, all nodes will result in the same target value calculation. In this way, a node which has validated from the genesis block can know exactly what the target value for the nth block in the blockchain must be.


why aren't transactions on the blockchain stored like "from, to, amount"?

On some blockchains, they are. They just don't work that way on the bitcoin blockchain. There are advantages to the way bitcoin does it. What if you want to send bitcoins to more than one destination or from more than one source?

Also, bitcoin's scheme is much simpler. Either a particular transaction output exists and is unspent or it isn't. A balance is the end result of a very large number of transactions and much more complex to verify.


Where do you get the transaction data & where do you submit your work?

when going into real production I guess you need data like the latest hash, info about the block and transactions and so forth.

If you're using a mining pool, you would use Stratum to subscribe to a mining pool's job notifications and their notifications would include this information. If you're using bitcoind to mine on your own, you'd use getblocktemplate. Additionally, you can build the template yourself.

Is there an API to which you submit your work

If you're trying to submit a block to the Bitcoin network itself, there is the submitblock bitcoind RPC call that will allow you to submit a full block. If you're trying to submit shares to a mining pool, you'd probably use the mining.submit Stratum RPC call.

to which you attach also your bitcoin address of your wallet, and once you make the right guess the btc is transferred to this account?

If you're using a mining pool, you specify this information at the mining pool's website. The block work they give you will be paying to their address, so it's irrelevant.
If you're mining yourself, you'd specify this by including a "coinbase" transaction at the beginning of the block that pays an address you specify the appropriate block reward and transaction fees.


Encrypted bitcoin private key from bitcoin-cli

There is no such way to do that. Bitcoin Core does not support BIP 38 for private key encryption so you cannot export nor import an encrypted private key.


What are the benefits of running a bitcoin daemon?

You will not get anything money wise from running bitcoind, however the Bitcoin network depends on people running it for verifications.  Its providing a service to the rest of the bitcoin community.  I run it because I participate in the bitcoin community and want to give something back.

This is how the "decentralized" part of the bitcoin protocol works.  People like you and I run the daemon and it verifies everyone elses transactions, the more people who run bitcoind the more secure the network becomes.

As for your other questions, I can't speak to speculation and this website will suspend your posts if you ask opinion or theoritical questions.


Each node can choose to build and maintain its own UTXO set, which it can then verify incoming transactions and blocks against.

  If there are servers which keep track of UTXOs, is it not leading to some centralization?

The network remains decentralized as long as a sufficient number of users are running their own nodes around the world. Each node could be considered a 'server' in some sense, but I think you are talking more about industrial server farms, which is not the case for btc nodes.

  the owner of these servers may tamper with the UTXOs.

This is not possible, the other nodes would recognize that the transactions involving tampered UTXOs are invalid, and reject them.

  If there are servers which keep track of UTXOs, how can one doublespend?

Double spends are not possible, once a transaction is confirmed in a block, all of the nodes will update their UTXO set appropriately, and reject any transactions / blocks attempting to spend already-spent or otherwise invalid transactions.

  If there is a double spent transaction in a block then the whole block gets orphaned right?

No, the block would simply be invalid. Orphaned blocks are valid, but not included in the longest blockchain (likely because another valid block with the same blockheight was found and relayed through the network first).


How does the bitcoin transaction fee get paid to miner(s)?

The very first transaction in every block is called a coinbase transaction. This coinbase transaction is created by the miner themselves, to pay them the block reward and the fees from the transactions in that block. At the time of writing, the block reward is 12.5 BTC, and then the total of all the fees is added to that, and the coinbase transaction is created to pay themselves that total.


Bitcoin transaction as been unconfirmed for 9 days

When transactions are published to the network, they first are mere payment promises. You have received notice of a transaction on the network to one of your addresses. However, for the money to actually become signed over to you, transactions need to be confirmed by being included in a block of the Bitcoin blockchain.

Most nodes on the network track unconfirmed transactions on the network only for a few days before they drop them from their memory pool. For example in Bitcoin Core this timelimit used to be three days previously and is now fourteen days. It seems that blockchain.info dropped the transaction because it timed out of their memory pool.

To speed up confirmation of the transaction, you could try to construct a child-pays-for-parent transaction: you would send another payment from your wallet and spend the money that you would receive from the unconfirmed transaction. If you use Bitcoin Core, you can specifically select inputs by enabling the "coin control features" in the settings. Otherwise, you can enforce spending the unconfirmed transfer by spending your complete balance. Many recent wallets will then automatically generate a new transaction with a higher fee that should get both the parent and the new transaction confirmed.

Unfortunately, the only other options are

to wait it out
to request that the sender updates their payment with a higher fee.

In this particular case, I think that your transaction should soon go through, as there are currently only about 3MB of transactions above 240 satoshi/byte and the one that you're waiting for pays ~239.18 sat/B.


A Bitcoin is divisible down to 8 decimal places (that is x.xxxxxxxx).


Im new to Bitcoin and want to know if storing wallet on my hard drive could corupt it?

It will increase the risk of corruption as much as storing any other file of the same size on your hard drive, which is to say that there is no additional risk of corruption for having a wallet. Wallet files aren't special in some way that makes them more prone to damaging a hard drive.


What if my Internet Service Provider decides not to let me send bitcoins?

Since bitcoins are sent through the internet, what would happen if my Internet Service Provider prevented me from sending bitcoins?

There really is no practical technical way to do this, but they could just have a rule.

  If they can do that, does that mean that I don't really control my bitcoins?

No, since you choose your ISP.


Is it possible to combine PoW with PoS by taking turns?

Yes. The problem with this approach is that all PoW nodes will be idle half of the time, and all PoS nodes will be idle half of the time. This isn't a huge problem. You could mine a different coin during the time that your PoW miner was idle; PoS nodes being idle half the time is not a big issue.

Your proposal does have a security advantage that I don't think you've pointed out. Specifically, in order to conduct a 51% attack, you need to be able to produce both PoW and PoS. You can have 51% of each, or you can compensate for a smaller amount of PoW or PoS by having more of the other.

For a 51% attack, ordinary PoW requires:

  W = Your PoW capacity, where 0.5 means you control half of the hashpower
  W > 0.5

For a 51% attack, ordinary PoS requires:

  S = Your PoS capacity, where 0.5 means you control half of the coins actively participating in PoS
  S > 0.5

For a 51% attack on this scheme, you'd need:

  1/((1/S + 1/W)/2) > 0.5


Bitcoin core does not have all unconfirmed transactions

In general, mempools are not guaranteed to be the same node-to-node. The behavior of the reference client is that once mempools reach 300MB, the lowest fee tx's are thrown away.

It's possible your node has reached this limit (either because it's 300MB or because your default is much lower) or simply because you're connected to nodes that have the same limitation.


This is actually already implemented: blk0001.dat contains the first two gigabytes of blockchain data, blk0002.dat contains the second two gigabytes, and so on. We just haven't hit two gigabytes of data yet.


Unconfirmed BTC after 48H, 0.000119 Fee!

Microtransactions can take pretty long, even with a relative big fee.

The confidence of your transaction is: 17.39% and miner preference is low:
https://live.blockcypher.com/btc/tx/f40f229b36f94bfbaa97a9998107c0014a6ad079370566698ec1cb58f2c94cb8/

At the moment there are a huge number of unconfirmed transactions:
https://blockchain.info/nl/unconfirmed-transactions

See also this site, it will show you the estimated confirmation time in minutes:
https://bitcoinfees.earn.com/#delay

But don't worry, you wont lose any BTC. If it takes too long you will get your balance back.


How do I sort the output of listtransactions "*"?

You can run the listtransaction JSON output through this little python script (save it as jsonTOCSV.py). That will produce csv (comma separated value) output that Excel or Google Spreadsheets can import, both of which can sort by columns (if I recall correctly).

So:

  bitcoind listtransactions | jsonTOCSV.py > transactions.csv

#!/usr/bin/env python
#
# Reads an array of JSON objects and writes out CSV-format,
# with key names in first row.
# Columns will be union of all keys in the objects.
#

import csv
import json
import sys

json_string = sys.stdin.read()
json_array = json.loads(json_string)

columns = set()
for item in json_array:
  columns.update(set(item))

writer = csv.writer(sys.stdout)
writer.writerow(list(columns))
for item in json_array:
  row = []
  for c in columns:
    if c in item: row.append(str(item[c]))
    else: row.append('')
  writer.writerow(row)


Possibility of broadcasting new block to only a fraction of honest nodes?

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

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

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

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


What is the difference in hashing algorithm between bitcoin and litecoin?

Here you find an example, how to extract the data from getwork and call the scrypt function
http://litecoin.info/Scrypt

Unfortunately it is not clear (to me) what the resulting values of the scrypt should be. First I thought it is the result of the valid block above, but that has a different nounce.

If you find a valid result, please let me know the value.


Am trying to start mining litecoin with litecoin-qt

At some point they removed the GUI for mining from the litecoin-qt client. So you have to run minerd from the command-line or terminal.  The actual command syntax seems to be loosely documented, however.

Two reasons for this:

cpu mining simply is relatively too slow and unprofitable to warrant much further development.
Nevertheless the general consensus (at least according to the wiki and other available info) is that pooler/cpuminer is by far a better client in terms of speed, compatibility, usability, etc.

Also you can pick up a USB ASIC miner for ~$15 (usd) that will far surpass what a CPU can do today.

As far as the command syntax goes for CPUminer check out
https://bitcointalk.org/index.php?topic=55038.0

And scroll down to basic usage examples. Also may want to register at a pool first and have your login details ready.


Can you run a full Bitcoin node on Node.js?

Yes, bcoin:
http://bcoin.io/
https://github.com/bcoin-org/bcoin
bcoin is a modular Bitcoin library for nodejs with full node and SPV node functionality, as well as a scalable BIP44 wallet used in production by several Bitcoin businesses including Purse.io.
Bcoin has the second-fastest initial sync time out of all available full node implementations (after Bitcoin Core, of course): https://blog.lopp.net/bitcoin-node-performance-sync-tests/


Retrieve last x transactions from multiple wallet

Idea: Every transaction received on any wallet goes to a local database with a time stamp. That local database might just be 100 entries long. In the overview over all wallets you display info from that database.


I think the transaction could take a long time because the fee you paid is to small. Also, you can try to bump the fee through your wallet.


Parse UTXO of a transaction from chainstate

You are right, however you are not interpreting the result correctly. The value is indeed 287, that is (2288 >> 3)  + 1, however this does not mean that the bitvector contains 287 bytes, but that it contains 287 non-zero bytes, so when parsing the bitvector, you should decrease the byte counter only when you find a non-zero value. Here you have a piece of code that deals with this (n is 287 in this case):

# If n is set, the encoded value contains a bitvector. The following bytes are parsed until n non-zero bytes have
# been extracted. (If a 00 is found, the parsing continues but n is not decreased)
if n > 0:
    bitvector = ""
    while n:
        data = utxo[offset:offset+2]
        if data != "00":
            n -= 1
        bitvector += data
        offset += 2

Notice that this is just a fragment of the code. I've coded a full decoder in Python recently, you can check out the code on github.


Associating a bitcoin address with a user in a shared wallet

You generate and store the receiving bitcoin addresses of each user in the database. Then you poll bitcoind for new transactions for the all the receiving address you have in your database. When the receiving bitcoin address has incoming transaction, then you follow the relation from the receiving bitcoin address to the user and then credit the transaction on the user's database balance.

Some of this is covered in my tutorial Accepting bitcoins in Django application.


The lnd.conf information you shared above is required for the LND instance to query your local bitcoind node (to detect or follow on-chain/mempool events), and does not represent the LND user interface.

LND has a REST API which you can query with curl:
https://api.lightning.community/rest/index.html#lnd-rest-api-reference

The REST interface listening port can be configured here:
https://github.com/lightningnetwork/lnd/blob/master/config.go

The LND documentation describes it in more detail, but you will need to generate valid macaroons for LND https calls.


Online exchange bitcoin balance to hardware wallet

Generate an address on the hardware wallet.  Then log in to your web wallet account and send all your coins to that address.  That's all.


How can using Bitcoin with Tor improve privacy?

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

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


How to develop a crypto exchange leveraging on third party API like coinbase, blockchain.com

I think you are somewhat confused on what you want to build. You can either (try to) build an exchange that sources Bitcoin from an exchange like Coinbase or Blockchain and then sells them on for a markup. Or you can build a P2P exchange like Bisq, Paxful, LocalBitcoins etc. If you do the former it isn't P2P and it is subject to limits enforced by the API provider. If you do the latter you have no use for an API from Coinbase or Blockchain. Bisq is open source so you could look at their code if you want to understand how their P2P exchange works.


What does setting up a Trezor actually do?

Trezor does two main things.

It generates a wallet based on your recovery seed. The seed is your most important data as it be used to access your funds, even without a Trezor.
It signs transactions using signatures based on your recovery seed, without the need to expose the recovery seed to any people or software.

The seed represents your wallet, so if you're concerned it may have been compromised and never used it, you should definitely generate a new one. The Trezor provides no security if your seed has been compromised, because somebody can just load it into a different device.

Everything Trezor does is based on the seed, so as long as you never used it and are willing to generate a new one, you should be fine.


Do multi-PoW currencies open up additional attack vectors on a blockchain?

Chaining algorithms reduces security as if one part of the chain fails, the whole chain fails. And in this case fail doesn't just mean completely broken, it can also mean an ASIC-proof algorithm turning out to be not ASIC proof.


Some newbie questions about bitcoin transactions and anonymity

1) After having installed Electrum I go to the Recieving tab in the GUI. There I can see some different addresses. Can I publish them all to the public to get payments?

Yes, these addresses are meant to be "published" to other parties who will send you payments

  2) Are these addresses static? That is, will I have these addresses forever to receive payments and I guess multiple people can insert bitcoins multiple times to the same address?

Electrum is an HD wallet which means it generated its addresses in a deterministic way so as long as you keep your seed phrase in a safe place you will be the owner of these addresses. Reusing addresses without a good reason is generally discouraged.

  3) Actually, from an anonymity perspective, what is the difference between having several receiving addresses in one wallet to get payments and multiple wallets with one address each?

Having multiple wallets with one address each is a huge overkill and improves nothing in terms of anonymity, it will only make it easier for you to get lost amongst your wallets, not being able to use the bitcoin network the way it is supposed to be used and eventually lose some funds.

  4) If one would be totally anonymous when getting and making payments (let´s say person A will get payment from B and then A will pay C), is this a correct way to do it and still become anonymous:
     a) install a local wallet with tor support (Electrum for instance)
     b) connect to the tor network and give one of the receiving addresses to person B
        so he or she can make the payment
     c) Go to the Send tab and send to person C.
     When the transactions are done, close the wallet and disconnect from tor

I suggest you take a look at these wiki entries: Anonymity, Protect your privacy.


Getting root pub key form derived public keys

You cannot. It is impossible to get the parent public key from the child public keys. This is because a hashing algorithm is used in deriving the child keys and hashing algorithms are not reversible.


Setting up Statistics with litecoin-qt or bitcoin-qt

Dylan, i suggest you do a lot more reading before you attempt to run a pool. A pool is not an easy job, you need an in-depth knowledge of bitcoin/c++/python etc. It's not simply cut and paste.

Unfourtunately from waht i am reading you are only running a coin daemon as your pool node which won't work for a pool. check out how to install mmcfe for litecoin. that should help you out


What is the required input for python-bitcoinlib getrawtransaction command?

getrawtransaction requires little endian format of the trxid, like:

import bitcoin.rpc
from bitcoin.core import lx
p = bitcoin.rpc.Proxy(service_url='http://usr:pa@ip:port')
trxid = lx('7e195aa3de827814f172c362fcf838d92ba10e3f9fdd9c3ecaf79522b311b22d')
rawtrx = p.getrawtransaction(trxid)
print(rawtrx)

Comments from Mr Peter Todd on that:

https://github.com/petertodd/python-bitcoinlib/blob/master/examples/spend-p2pkh-txout.py#L41


Does ASIC miners leave a trace in the mining history of bitcoin?

No. ASICs do only hash calculation. All data in block (except nonce) is defined by pool/node software


Who are the owner of bitfunder.com and btc trading corp?

With BTCT.CO each asset issuer receives a full list of all shareholders holdings every twelve hours.  So if the site did go down the damage would be limited.  Also you should only keep just enough coins for your orders on the site and not use it to store coins long term.


What is exactly user B's stealth address? Is it his public key?

In the simplest stealth address scheme, yes. The exact encoding depends on the implementation; DarkWallet's is described in their wiki.

  how can I multiply this coordinate with PublicB since both of them are points?

Correct, S = PrivA * PublicB = PrivB * PublicA is a point. We want an integral shared secret. ECDH tells you to use the x coordinate of S as the shared secret, but in Bitcoin it's done differently. Instead int(sha256(compress(S))) is used:

serialize S in compressed form as per SEC 1's Elliptic-Curve-Point-to-Octet-String Conversion
take its SHA-256 digest
interpret the result as a 256-bit big-endian integer

This integer, c, is then used by A to calculate a public key PublicB + c*G to which A spends, and by B to calculate its private key (PrivB + c) * G from which B can redeem (where G is the base point generator).

Note that there's a problem with this "simplest" scheme. The only way that B's wallet software can see if a UTXO is redeemable by B (to keep track of the wallet's balance) is by doing the math above, which requires PrivB. In other words, it makes watching-only wallets impossible (and cold wallets impractical).

One solution to this is to use one PublicB/PrivB pair for ECDH, but a different PublicB2/PrivB2 pair for deriving the spend/redeem keys. Now you can keep PrivB in your watching-only wallet, and PrivB2 in your cold wallet. On the down side, B's stealth address is now twice as long, containing both PublicB and PublicB2.


What is the average number of hashes it takes to mine bitcoins?

(Average hashing power of network per second between the last difficulty adjustment and the difficulty adjustment that came before it) * 600

or (2^32 * difficulty)


What is the maximum number of names (domains) that can be registered with NameCoin?

Given increased use of Namecoin, which would lead to a shortage of namecoins as you describe, the fee would be reduced. I have previously seen plans to reduce the network fee to 0.001 or lower, but can not find it now.

These changes would require a hard fork of Namecoin, but it is important to note a fee is only destroyed upon a new registration. Updates of DNS records and domain renewal go to miners.

I am not aware of any hard block size limit, but should one exist (or be implemented with a hard fork) it would be unlikely to get anywhere near the 2.1 billion names as you describe.


MuSig does not support m-of-n multisig, so you should use a threshold signature scheme like this:
http://cacr.uwaterloo.ca/techreports/2001/corr2001-13.ps


If the PHP script and the Bitcoin wallet are on the same computer, does encrypting the link is necessary?

It probably doesn't help much.

If the wallet (server) and the script (client) are running on the same computer, and you're connecting to it directly (e.g. on 127.0.0.1), then the data being sent should never reach any external network, and could only be intercepted by the user(s) running those programs, or a system administrator with higher privileges.  In most cases, those people would also be able to recover the SSL key, so encryption would not help very much.  For that matter, they would also probably be able to recover private keys and other sensitive data directly from the files or memory being used by the programs.

On the other hand, in most cases, RPC has so little traffic that the overhead of encryption is negligible, so it costs you almost nothing to turn it on, and it might make an attacker's job somewhat more difficult.

If your system uses more advanced separation of privileges (e.g. Linux admin capabilities and securelevels) then there might be more situations where someone might have access to local network traffic but not the keys or other sensitive data.  In such cases, encryption could make more of a difference.


Why does GBTC frequently not track Bitcoin's price?

An Investor's Business Daily article discusses why GBTC's value does not match the value of the Bitcoins held in the fund.

It says that GBTC is not an ETF - it is a grantor trust.

  It is not registered with the SEC [...] and it doesn't trade on an exchange.  It trades on the over-the-counter market, which has less stringent participation rules than exchanges. And unlike most ETFs, GBTC charges a high annual fee of 2% of assets."

It uses a recent day as an example of how GBTC trades at a substantial premium relative to the value of the Bitcoins held by the fund:

  At the Jan. 29 closing price, Bitcoin was $11,233.95. That would make the NAV for a share of GBTC (11,233.95 x 0.00100733) $11.31. However, shares of GBTC closed at $19.14, a 69% premium to the NAV. So investors would have to pay 69% more per share than the underlying asset is worth.

It explains the premium by noting there has been a high demand for GBTC and a small supply of shares:

  Instead of an ETF, people should think of GBTC as a closed-end fund. These typically trade at a premium or discount to its NAV. The reason for GBTC's premium is the high demand for the small supply of shares. It has only 176 million shares outstanding. [...] "If GBTC was more liquid and larger, and Bitcoin had wider acceptance, then there would be closer correlation between the price of GBTC and the price of the underlying asset," said David Foster, a securities fraud litigator in Farmington Hills, Mich.

Michael Sonnenshein, managing director of Grayscale Investments, basically said the same thing in the article:

  "Since the shares began quotation on the OTCQX market in early 2015, they have traded at a premium valuation to the NAV," said Sonnenshein. "While we cannot pinpoint a singular reason for the premium, we can surmise several factors. Firstly, there are fewer shares available on the market than there is demand.  Secondly, it is the only U.S.-based investment vehicle that provides direct exposure to Bitcoin through the purchase of a security."

The article then mentions how the recent GBTC stock split has increased the supply and lowered the premium:

  Grayscale recently declared a 91-for-1 stock split for the trust for shareholders of record on Jan. 22. They received 90 additional shares on Jan. 26. This lowered GBTC's share price and increased the supply adding more  shares to meet demand, thus increasing liquidity. The premium of share price over NAV has fallen but is still a whopping 47%.

Another thing the article mentioned is that the amount of Bitcoins held in the fund will fluctuate significantly as people buy and sell GBTC, so that would probably explain the frequent daily discrepancies that I've seen:

  GBTC held 177,037 Bitcoins as of Jan. 29. The number of coins held by the trust fluctuates substantially as investors move money in and out of GBTC.


How can I prevent Armory from getting stuck at "30 seconds" Building Databases on OSX 10.9?

WARNING: Triple-check you have a backup of all of your Bitcoin-Qt and Armory wallets before deleting anything.

Deleting the Armory and Bitcoin data directories (~/Library/Application Support/Bitcoin and ~/Library/Application Support/Armory) and re-downloading the entire blockchain (starting with a fresh bootstrap.dat) in Bitcoin-Qt fixed this for me.


Can a Wallet Generated by Linux Multibit Client be Used with Windows Multibit client?

Absolutely, if it didn't it would be a bug anyways. Linux and Windows Multibit should work properly on the same backup.


What laws apply to selling / buying bitcoins for USD in California?

I am not a lawyer but I think this Bitcoin Magazine Article should be informative. As far as case-law goes I would check out the bitcoinica bankruptcy suit as well as the tradehill bankruptcy suit


how to make a bitcoin buy with euros on Kraken API

Found how to do it, we shoud use the oflags

oflags = comma delimited list of order flags (optional):
    viqc = volume in quote currency (not available for leveraged orders)
    fcib = prefer fee in base currency
    fciq = prefer fee in quote currency
    nompp = no market price protection
    post = post only order (available when ordertype = limit)

In this case:

("pair => "XXBTZEUR",
"type" => "buy",
"ordertype" => "market",
"voulme" => '10',
"oflags" => "viqc"
)


What happens if a P2SH redeem script is lost?

Yes, if you lose the redeemscript, the funds are going to be locked forever. In order to spend a p2sh output, you need to both reveal the redeemscript that hashed to the address and then satisfy the conditions of that redeemscript. If the script cannot be recovered, it cannot be satisfied and the funds will not be spendable.


Private key only wallet for Bitcoin Core regtest

No, there is no such option.

You can do what you want with the raw transaction RPC interface (createrawtransaction, fundrawtransaction, signrawtransaction, sendrawtransaction), though.


What does it mean to have -1 confirmations?

It is a known bug, just restart the client and/or switch to another server in the Network window (green dot in the bottom right).

If this doesn't fix the 'Unverified -1 confirmation error' try deleting the block_headers folder on your Electrum directory -> https://bitcointalk.org/index.php?topic=330626.msg5292794#msg5292794


The RPC interface is an authenticated interface. You need to provide a username and password in order to send RPC commands. These are usually specified in the bitcoin.conf file with the rpcuser and rpcpassword options or the rpcauth option. There are also temporary RPC credentials stored in the .cookie file that can be found in the datadir.

The reason that you have no problems with bitcoin-cli is because it looks up the RPC credentials from the bitcoin.conf file or the .cookie file..


Difference between wallet,accounts and addresses

Wallets
A wallet is an application that manages your keys and can create transactions. There are many open source and closed source wallet applications for different platforms (Desktop, Mobile, custom Hardware Wallets). Bitcoin-core has an implementation that runs on a full node. See Bitcoin Wiki - Wallet.

Accounts
An account can have different meanings depending on the wallet application you are using, but in bitcoin core it is a way to give a readable name to an address and keep track of your balance. In bitcoin core, an account can include multiple receiving addresses. See Bitcoin Wiki - Accounts explained. Note: See @Pieter Wuille's comment below that this will be deprecated from bitcoin-core.

Addresses
An address can be a form of your public key (or a script), to which people can send bitcoin, and which can only be spent by the corresponding private key (or by satisfying the script). There are many forms your address can take, because it can be derived from any valid script. A simple P2PKH (Pay to public key hash) address is the RIPEMD160(SHA256(public key)) encoded using Base58 checksum. A P2SH is a hash of a script. Basically, in order to spend coins sent to any address, one must satisfy the script that address represents, which usually includes providing the script (P2SH) that the address was hashed from, and any required signatures. See Bitcoin Wiki - Address


Paper wallet generated client side and off network is not necessarily secure

You can generate the random bits yourself to eliminate possibly weaknesses / backdoors in an offline wallet generator. For example throw a dice 100 times and write down the sequence, and use the SHA256 hash as your private key. Or if you don't have a dice, toss a coin 256 times is ok too.


how to dump private key from multisig address

You can't dump the private key for a multisig address because there are multiple key pairs (thus multiple possible private keys) assigned to the address. You need to specify which key pair you want. First, get the public keys belonging to that address by using:

$ bitcoin-cli getaddressinfo <your address>

{
  "address": "<your address>",
  ...
  "embedded": {
    ...
    "pubkeys": [
      "<pubkey 1>",
      "<pubkey n>",
      "..."
    ],
   ...
}

Assuming you want the private key corresponding to <pubkey 1>, you can convert it to a simple P2PKH address and then use dumpprivkey, for example:

$ hash160 <pubkey 1>
  <pubkey 1 hash>
$ echo 00<pubkey 1 hash> | xxd -r -p | base58 -c
  <P2PKH address>
$ bitcoin-cli dumpprivkey <P2PKH address>
  <privkey>

Where hash160 is just a bash script that uses openssl:

#!/bin/bash
## Command Line parsing
#######################

if [[ $# -lt 1 ]]; then
    echo "Usage: $ hash160 <input-hex>"
    exit 1
fi

inputHex=$1

hash1="$(printf $inputHex | xxd -r -p | openssl sha256 | cut -c 10-)"
printf $hash1 | xxd -r -p | openssl ripemd160 | cut -c 10-


Can anyone explain this pseudocode to find a returning address?

Repeat after me: Bitcoin transactions do not have a return address. Bitcoin transactions do not have a return address.

As you say, a transaction can have multiple inputs. Each input spends a coin that was previously controlled a particular address/key or script. However, these "input addressee" are not return addresses, for multiple reasons:

The different inputs could belong to different people/entities, for example if they use CoinJoin or simar protocols. You don't know which is the sender of your payment (the pseudocode above will just return all of the sender addresses).
There may not be a recognizable address for every input (for example if it was sent through a high-level protocol), but only an arbitrary script (the pseudocode above will fail in this case).
Even if there is a clear address, it may belong to a service the sender used - and sending coins back to it would credit the service or an arbitrary user of it rather than the sender of your transaction (the pseudocode would give the service's address in this case).
Even if there is an address that indeed belonged to the sender, they may not expect a payment to it, and perhaps not have kept the private keys for it around.

In general, if you want to refund some money, there is only one solution: ask the sender ahead of time for a refund address.


Claiming Bitcoin Cash - where did I go wrong?

You may have gone wrong by exporting the private key of your /new/ wallet. You want to export the private key of the /old/ wallet and import that into Electron Cash. It isn't clear from your description if you got this right, and that would be one explanation.


Bitcoin communication with non-standard ports

If you make only outbound connections it won't matter what ports you use. Your client will be able to fully participate in the network without any issues.


How many BTC addresses have balance in them?

There are approximately 800,000 unique addresses on the blockchain with some Bitcoin held at those addresses at the present time according to blockchain.com.
Let's assume these addresses are all bech32 (to simplify the calculation, in reality these are the minority).
The witness program in a bech32 SegWit v0 P2WSH address is 32 bytes. In theory this means there could be approximately 8^32 = 7.9 x 10^28 different witness programs.
The percentage of unique addresses on the blockchain then works out to be:
800,000 / 7.9 x 10^28 = 1.0 x 10 ^(-23)
This is 0.00000000000000000000001 percent of the total bech32 SegWit v0 addresses.


Cannot synchronize with Bitcoin in testnet mode

I got it to work by adding
[test]
addnode=104.237.131.138
addnode=151.80.205.132
addnode=192.155.82.123
addnode=74.220.255.190

to the config file.
The reason is your wallet needs to connect to nodes to connect to the blockchain. Usually it comes with all the nodes required to connect, but sometimes the devs failed to include the nodes or released a new node list after an update (try looking in the bitcointalk page or the official website listed by the coin developers), so you have to add them manually.


Android Bitcoin Wallet, zero balance after keys import

Probably you didn't set the wallets birthdate correctly. In any case usage like this is strictly discouraged.


Block.io is pretty easy to use, but their free api is limited.

Blocktrail is another option that is easy to sign up for, and relatively easy to use as well.

My personal favorite is still blockchain.info but you are not the first one to mention difficulties getting an API key.

I've noticed the same lack of tutorials for Bitcoin web development which is why I started my site and youtube channel 2 years ago. If you Google how to use block.it api or how to use blockchain.info api you should be able to find tutorials that will help you.


How do I communicate with the BTC network?

I think I figured it out. "curl" doesn't add the "Content-Type" header, which seems important to the pool when parsing the JSON body. Adding that header fixed it.

So, a working curl command would be:

  curl -H "Content-Type: application/json" -u [Wallet ID:gibbrish] -d '{"id": 0, "method": "getblocktemplate", "params": [{"capabilities": ["coinbasetxn", "workid", "coinbase/append"]}]}' http://[Pool IP:Port]


How is Public Key extracted from (message, digital signature, address)

An algorithm called Public Key Recovery exists for ECDSA, which lets you construct the public keys for which a given pair of message and signature would be valid.

To explain the algorithm, remember that ECDSA signatures are pairs (r,s) for which sR = mG + rP. In this equation m is the message hash (which must be a hash of a known message), P is the public key (an elliptic curve point), G is the curve generator point, and R is a point for which R.x mod n = r. n is the curve order.

Rearranging this equation you get rP = sR - mG, or P = (s/r)R - (m/r)G. Thus, it seems we can just compute the public key from the message and the signature. Unfortunately, there can be up to 4 different points R for which R.x mod n = r (in practice, the number is almost always 2).

This technique is used in the message signing, allowing the signature to be verified against just an address, rather than a public key. The verifier in this case recomputes the public key from the message and the signature, converts it to an address, and then compares with the provided address. The address input is still required to prevent people from just giving a signature and message, and then seeing an address and thinking this implies the signature was valid. It must be compared against the expected public key or address to be the case.

The reason this isn't implemented for P2SH or BIP173 addresses is because the "standard" was never extended to incorporate those address styles. There is a proposed new standard (BIP 322) which would cover all types of addresses and more, but isn't widely implemented or used yet. BIP 322 also doesn't use pubkey recovery anymore; it simply uses the Script language and encapsulates a scriptSig/witness to verify against the script that corresponds with the address.


This has nothing to do with RFC6979, but with ECDSA signing and public key recovery.

The (r, s) is the normal output of an ECDSA signature, where r is computed as the X coordinate of a point R, modulo the curve order n.

In Bitcoin, for message signatures, we use a trick called public key recovery. The fact is that if you have the full R point (not just its X coordinate) and s, and a message, you can compute for which public key this would be a valid signature. What this allows is to 'verify' a message with an address, without needing to know the full key (we just do public key recovery on the signature, and then hash the recovered key and compare it with the address).

However, this means we need the full R coordinates. There can be up to 4 different points with a given "X coordinate modulo n". (2 because each X coordinate has two possible Y coordinates, and 2 because r+n may still be a valid X coordinate). That number between 0 and 3 we call the recovery id, or recid. Therefore, we return an extra byte, which also functions as a header byte, by using 27+recid (for uncompressed recovered pubkeys) or 31+recid (for compressed recovered pubkeys).

Strictly speaking the recid is not necessary, as we can just cycle through all the possible coordinate pairs and check if any of them match the signature. The recid just speeds up this verification.

In general, if h is the cofactor, the maximum number of different points with given "X coordinate modulo n" will be 2(h+1). In the case of secp256k1, which has cofactor 1, we get 2(1+1) = 4.


What is the difference between chainstate and blocks folder?

Is the blocks and chainstate folder store the same blocks data ?

No, the blocks directory contains the actual blocks. The chainstate directory contains the state as of the latest block (in simplified terms, it stores every spendable coin, who owns it, and how much it's worth).

  How can we read those data using code and display that on the web frontend like the blockchain explorer websites

No, you need transaction and address indexes for that. Bitcoin Core is not designed to provide those.


When / how frequently do miners get paid for transaction fees?

With every block the successful mining entity reaps all the included transaction's fees. So, in the case of solo mining, a miner gets paid transaction fees every time he finds a block, in the case of a mining pool a miner's payouts depend on the mining pool's policies.


How to display Recipient Address, Change Address & Transaction Amount

Just go to BTC explorer any search in google
example:
https://www.blockchain.com/explorer
type your wallet adress or transaction ID
And check.


Connecting to a bitcoind in "-regtest daemon" mode remotely from another node (e.g. BitCoinJ)

If anyone is looking to connect to a RegTestnet using bitcoinJ here are the step on mac:

I used a docker image to setup the bitcoin network.

https://github.com/freewil/bitcoin-testnet-box

run this docker image using this command:

docker run -t -i -p 19001:19001 -p 19011:19011 -p 19000:19000 freewil/bitcoin-testnet-box

When you run this docker image it will start 2 bitcoin nodes.

Node 1 will listen to bitcoin node connections on port 19000 and for rpc connections on port 19001.

Node 2 is not listening to bitcoin node connections. Node 2 is connected to node 1.

Now using the port forwarding settings in Virtual Box forward the container port 19000 to your host machine port 19000.

Now you can connect to Node 1 from any machine in your local network (wifi network) using the address your-machine-local-ip:19000

Here your local machine ip is the ip address of your laptop in your local network. In mac you can find it out from network preferences.

To connect to Node 1 from bitcoinj use this:

mParams = RegTestParams.get();
.
.
// define how to connect based on network params
if (mParams == RegTestParams.get()) {
    try {
        PeerAddress pa = new PeerAddress(mParams, InetAddress.getByName("<your-machine-local-ip>"), 19000);
        mKit.setPeerNodes(pa);
    } catch (UnknownHostException e) {
        e.printStackTrace();
    }
}


What does this output item in the result of the call with blocktrail api mean?

You can find a full explanation of OPRETURN here: https://en.bitcoin.it/wiki/OP_RETURN

TLDR; OPRETURN is a "data push" output, it allows for putting up to 80 bytes of data into the transaction that have effect on the transaction.
And the value for that output can be 0.

It is used for various things, amongst others; publishing "proof of existence" hashes in the blockchain and meta protocols.


Receiving funds in Bitcoin is an asynchronous and passive process.

A sender creates a transaction which consumes some unspent transaction outputs (UTXO) and assigns the freed-up value to newly created UTXO. A UTXO generally specifies an amount of bitcoin and some spending conditions that must be fulfilled to consume the UTXO. The most common spending condition schemas are represented with addresses.

As users of exchanges give fiat and/or cryptocurrency into custody of the exchange to gain access to the exchanges order book, the user must request a withdrawal to retrieve their funds. In the withdrawal request, the user must specify how to lock the funds which they do by providing an address from their wallet. The sending of a transaction is fully controlled by the sender: they merely sign over some of their funds to a locking script specified by the recipient in advance. The receiver's wallet does not need to sign-off, nor does it have a veto. It is therefore perfectly possible for the recipient wallet to be not connected to the internet and transcribed to a piece of paper as long as the recipient just knows how the corresponding address.


Is demurrage already integrated into Ripple? If so, how does one create a demurrage currency?

You can find an answer with an example here:
https://gist.github.com/justmoon/8597643

Type 0x01 means demurraging currency:
01 __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __
CURCODE- DATE------- RATE------------------- RESERVED---
CURCODE - Three character uppercase ASCII.
DATE - DEPRECATED Demurrage start date (Ripple epoch; seconds since 2000) -> There is no reason to choose one reference date over another so this feature will be removed.
For now just make sure you ALWAYS set the date to 00 00 00 00
RATE - Demurrage rate, defined as e-folding time in seconds
(IEEE 754 double-precision floating-point)
RESERVED - Reserved for
future use, duh
Note: Date and rate are four-byte aligned, rate is eight-byte aligned,
for easy parsing on 32/64 bit CPUs.
Demurrage example:
01 58 41 55 00 00 00 00 C1 F7 6F F6 EC B0 BA C6 00 00 00 00
// Calculating the demurrage rate //
// We want 0.5% per year. There
are 31536000 in a year, so the e-folding time in seconds is:
31536000 / ln(0.995) = -6291418827.045599
// In plain English: The nominal amount of this asset will decrease
(hence the minus sign) e times (≈2.71828) every 6291418827.045599
seconds
// As hex (IEEE double):
http://gregstoll.dyndns.org/~gregstoll/floattohex/
0xc1f76ff6ecb0bac6
// Final currency code 0158415500000000C1F76FF6ECB0BAC600000000
// Example TrustSet
{"Flags":131072,"TransactionType":"TrustSet","Account":"rNb721TdNHN37yoURrMYDiQFmvXmENCZW6","LimitAmount":{"value":"1000","currency":"0158415500000000C1F76FF6ECB0BAC600000000","issuer":"rUyPiNcSFFj6uMR2gEaD8jUerQ59G1qvwN"}}

Create the code for your currency as shown.
Set a Trustline for this currency (As shown in the end of the quote)

Thats it, it's created now.
P.S.: For now I know the only one place where this currencies are shown correctly:
https://bithomp.com/explorer/forabc


Does bitcoind (as of 0.15) support BIP39 mnemonic phrase for wallets?

No, bitcoind does not support BIP39 seed phrase backup. It supports deterministic key derivation (BIP32), and the seed is just random number generated on wallet creation. Moreover, the generated keys do not follow BIP44 key paths, so even if you imported successfully in some way your seed to bitcoind wallet, there is no chance to see your money from wallets which follow BIP44 key paths.

As far I know wallet encryption in bitcoind has more to do with symmetric encryption of private key data. It has nothing to do with seed converted to seed phrases.


How to run Bitcoin Core both main and testnet on the same machine?

Do I need to run 2 instances on bitcoind / bitcoin-qt.exe for that?

Yes. If bitcoin-qt is already running and on mainnet then open up a command shell and type:

>bitcoin-qt -testnet

This will launch a second bitcoin-qt on testnet using the default -datadir= and -conf= options.

The -testnet option uses the folder {default bitcoin datadir path}/testnet3/ and the default bitcoin.conf file by default. If you wish for your testnet instance to have different options to your mainnet instance then add the -conf={file} option after -testnet on the command line.

This works much the same for bitcoind.


Where can I find some guidelines on how to program a merged mining transaction?

I'd suggest looking at the merged mining spec at the bitcoin wiki.

When I was writing my merged mining implementation I also looked at the source code of namecoind, bitcoind and merged-mine-proxy.

As far as I know there is still no easier documentation on how to implement merged mining, so you will likely be looking through existing source code a lot to figure out the details. The merged mining spec was a big help for me though, even if it is a bit slim.


When you buy from Coinbase, you are buying from a service provider, not from a person who is selling....so, yes, you will be paying more.

Don't ever actually buy from Coinbase (or sell); they mark up the price that is set on THEIR OWN exchange, GDAX. It literally only takes you seconds and zero cost to transfer your funds from Coinbase over to GDAX to trade yourself at a better rate, so there's no reason to take the Coinbase markup.


Is MultiBit secure? And hong long will MultiBit import .aes.json take?

There is currently a bug in the 0.5.9 code that prevents it from loading blockchain.info wallets. It is fixed in the develop code and will get into version 0.5.10 (which will probably be released after the Bitcoin conference now). The older versions work fine - version 0.4.23 is in https://multibit.org/releases . You could just use that version for the import.

Is MultiBit secure ?
Security for bitcoins has several aspects - here are the main ones:

Is it open source ? Yes.
Can you trust the developers ? Well that is for you to decide but I've been working on it solid for over a year now and code it 'in the open' not pseudonymously.
Can you check the downloads are the correct ones ? This is important now that Trojans have started appearing. Yes. Download from https://multibit.org. Check the binary against the PGP signatures. The Mac version is also signed with a Mac developer cert and soon I'll start doing the same with the Windows version. Not enough? : build it directly from the code.
Do you control the private keys ? Yes, there are stored locally.
Can you encrypt them ? Yes.
What about malware and keyloggers ? Until we get hardware wallets bitcoin clients in general are vulnerable to an attack by malware and keyloggers combined. You need to practice 'Safe Computing' on the computer you have your bitcoin on. If you are dealing with serious amounts of bitcoin sign your transactions offline with either Electrum or Armory rather than MultiBit.


What is the total value of XRPs or the market cap of Ripple?

Keep a few things in mind. Not all 80 billion XRP that OpenCoin is supposed to give away is already in people's hands. Also, the founders that kept 20 billion will probably not be likely to sell a big part of it. For this reason, the total amount of XRP in circulation is many times lower than 100 billion.

Beside that, it is true that the total market cap can be valued at 100 billion * 0.0044.. USD/XRP = ± 450 billion USD. But that number does not make too much sense because the price will drop very fast when people sell big numbers of XRP. The reason that the price has this (relatively high) value is because most people are not likely to sell their XRP and everyone wants to buy a little bit of them to experiment or to keep as an early investment.

The main reason why people buy XRP now is because they believe that Ripple has potential to become big some day. And possibly for development and testing purposes.


Beginner's question: Why must proof-of-work be useless?

In addition to the technical factors mentioned by MCCCS, it's important to consider economical factors as well.
If the problem being solved has value outside of the Bitcoin network, it allows miners to essentially "double dip" on the rewards - they earn both from the Bitcoin received as block rewards, as well as the incentive structure off chain.
For example, if the problem being solved is character recognition, it would enable a number of companies who seek good character parsing systems, such as Google, self driving car companies, etc, to double dip. These companies are then incentivized to build a a mining farm to not only train their programs, but also use that training to earn Bitcoin, subsidizing the operation they're already doing.
Being such large companies, their primary goal is likely to have a good text recognition system - the value of Bitcoin earned is secondary. This allows them to invest much more into their mining farms, potentially outstripping other miners who do not have a dual incentive. Moreover, as they get paid twice, it is in their favour to attempt to resolve minor reorgs to build on top of their blocks - they are already subsidized via the off chain incentive, so the cost of losing a block proportional to their operating cost is much lower, allowing them to take riskier routes to resolving minor forks.
This also reduces the cost of mounting attacks - if the mining power required to launch an attack is subsidized by external incentives, it is easier to pay for and acquire.
This also changes the reward structure overall - if the majority of the earnings for a miner are from an outside source, they are less concerned with the effects of bad blocks, 51% attacks, or other bitcoin issues that drop the value of bitcoin. The risk:reward calculation for attacking the chain becomes skewed, allowing for high reward attacks to have a lower cost than in a single use system.


How much data traffic does participating in Bitcoin mining cause?

If you mine with a pool, your actual internet activity will be fairly small.  I just took a look at my network statistics and BFGMiner used 9MBytes down and 11 MBytes up over the previous 24-hour period.

The Bitcoin-Qt application on the other hand maxes out my upload bandwidth since I always seem to get 2-3 peers who want to download the entire 12 GB blockchain from me.  Other than that, the main Bitcoin-Qt network usage occurs when you are receiving or relaying the latest block (blocks are typically 100-400 KBytes).

Since you have limited internet bandwidth, your best bet would be to run a lightweight client such as Electrum or Multibit.  If you are mining in a pool, you don't need a local Bitcoin-Qt.


How many transactions per second can blake2s algorithm can handle?

The number of transactions per second a blockchain can process is not correlated to the relative computational speed of the hashing algorithm.

A faster hashing algorithm just means the network's miners will be able to attempt more hashes per second, given the same (general purpose) hardware.

The number of transactions per second will depend on the block size, transaction size(s), and the average block time.


Blockchaind Node Monitoring and local testnet

Can i Monitor transactions coming in?

Yes. There are a couple of ways to do this.

Personally, I'd use the ZMQ pubsub capability and process the transactions with a separate program by subscribing to the ZMQ endpoint.

  Can i log all in and outputs and traffic of my Daemon?

Yes.

  Can anyone point to good documentation regarding creating a testnet, joining testnets?

You can run your own network using regtest.

To learn more about this, I suggest here.

Unsure what you meant by "joining testnets".

  Any documentation to create more currency on local wallet/local testnet and spend currency in an automated way?

You can create more bitcoins by mining blocks using the general block bitcoin-cli command. This is only usable in regtest.

If you want bitcoins in testnet3, you will need to get them from a faucet or another bitcoin developer.

The regtest guide should contain instructions on how to generate more bitcoins for yourself to test.

To automate the entire process, I'll assume you have some basic scripting skills to invoke bitcoin-cli commands.


Does slippage occur on MtGox when 'Market Order' is unchecked?

No, slippage also occurs because the price can move adversely between your decision to sell and your order's execution on the market. Typically in financial markets the other participants can see a large order and move their limit orders accordingly.

What you're talking about is called "sweeping". This is simply the fact that there are not enough orders at the best price to match a sufficiently large order. If you have a market order you will then end up filling the next price, which will be worse.


Ramifications of creating Electrum 2.x seeds which are not BIP39

For the purposes of this answer, I'll assume we're only talking about mnemonics which can be generated by Electrum 2.x, and not ones that are simply accepted by Electrum 2.x for restore (the latter number is infinite).

  What is the percentage of 12 words Electrum 2.x seeds (relative to 13 word seeds)?

Electrum 2.x seeds by default encode 136 bits of data. Any leading zero bits are ignored during encoding, so the resulting mnemonic length varies.

Each word encodes log2(word_list_length) bits of data, so for most* Electrum 2.x word lists, that's log2(2048) = 11 bits per word.

Therefore 13 and 12-word long mnemonics can encode up to 143 and 132 bits of data respectively. In order for a 136-bit seed to be encoded into 132 bits (12 words), at least the first 4 bits must be zero, which happens with probability 1 in 24, so 1 in 16 random mnemonics will be of length 12 or fewer.

Likewise, for an 11-word mnemonic, encoding 136 bits into 121 bits requires that 15 leading bits must be zero, so 1 in 215 or 1 in 32768 will be of length 11 or fewer.

Finally, if you need an exact answer, it would be 1/16 - 1/32768 = 2048/32768 - 1/32768 = 2047 in 32768 will be of length 12 exactly.

* For the Portuguese word list, it's log2(1626) ≈ 10.67 bits per word

  What is the percentage of Electrum 2.x (12 word) seeds which do not meet the BIP39 standard?

12-word long BIP-39 mnemonics have 4 bits of checksum, so 1 in 24 generated 12-word Electrum 2.x mnemonics will happen to be valid BIP-39 ones, and 15 in 16 Electrum ones will be invalid for BIP-39.

  If all 12 word Electrum 2.x seeds were filtered such that they are not BIP39 compatible, what is the decrease in entropy going to be?

I'm interpreting this as asking: If valid Electrum 2.x mnemonics were required to be invalid BIP-39 ones, by how much would this decrease their entropy?

Wolfram|Alpha says very small: about 0.0056 bits based on this input:

solve  (2^n - 1) / 2^n = 2047/32768 × 1/16  for n


First off, Alice doesn't hash the transaction as part of validation.  The hash Alice produces is simply a hash of the transaction, which is how transaction IDs are created.  In truth, anyone participating in the network could hash the transaction body and arrive at the same hash.  It is when the miners hash an entire block of transactions that hasing is part of the validation process.

Secondly, Bob doesn't have a "mailbox".  That's not what his public key is.  The blockchain is a public ledger, so Alice isn't sending the transaction to just Bob, she's announcing it to everyone.  Bob can see this transaction, just like everyone else, and now has to wait for a miner to include it in a block.

Miners create blocks of transactions, and they have to create them in such a way that the rest of the network will accept them.  One of the requirements is that the transactions in the block are all valid transactions.  So yes, miners will validate that Alice has 5 bitcoins to give before they add the transaction to a block.  If the miner cheats, and puts an invalid transaction into a block, then the rest of the network will reject that block, and the miner would have wasted their time doing the proof of work on that block.

The 10 minutes is a product of the proof of work algorithm.  It is retargeted every 2,016 blocks such that on average, it takes the entire network 10 minutes to construct a block whose hash is lower than the target value (starts with a certain number of zeros).  It is not a single transaction that takes 10 minutes to validate, but the construction of the entire block of transactions with the required proof of work.

Once a block with the proper proof of work has been found, it is broadcast to the network, which will accept it if the block meets all criteria.  After that, Bob can see that a transaction to the public key he supplied to Alice has been included in a block.  This is called a "confirmation".  Once another block is mined on top of that block, the transaction is said to have 2 confirmations, and a block later, 3 confirmations...and so on.

Here's some other answers you may want to read:

What exactly is Mining?

What is proof-of-work?


You may need to perform a factory reset and re-try

The manufacturers instructions for wallet recovery are are:

  Step 1. Restore from recovery phrase

  Connect the Ledger Nano S to your computer using the supplied USB cable. Your device should display Welcome to Ledger Nano S. If you are setting up your device for the very first time, please contact us if the device immediately asks for a PIN code. It may not be safe to continue using this device.
  Press the left or right button to navigate through the on-screen instructions.
  Press both buttons simultaneously to choose the option Restore from recovery phrase.

  Step 2. Choose your PIN code

  Press both buttons when Choose PIN code is displayed on the device.
  Press the right or left button to choose the first digit of your PIN code.
  Press both buttons to enter a digit.
  Repeat the process until you've entered 4 to 8 digits.
  Select the checkmark (✓) and press both buttons to confirm the PIN code.
  Use the backspace icon to erase a digit.
  Confirm your PIN code by entering it once more.

  Step 3. Enter your recovery phrase

  Choose the length of your recovery phrase (12, 18 or 24 words). Press both buttons to validate.
  Select the correct recovery phrase length and always enter all recovery words.
  Press both buttons when Enter word #1 is displayed.
  Enter the first letters of word #1 by selecting them with the right or left button. > 1. Press both buttons to validate each letter.
  Choose Word #1 from the suggested words. Press both buttons to validate it.
  Repeat the process until the last word of your recovery phrase. To correct a mistake, you can restart from a previous word from the suggested words menu.
  Your device will display Processing and then Your device is now ready once you've successfully restored your private keys.
  Press both buttons to access the Dashboard. The Dashboard is where you can access the apps and settings on your device.

If you are having trouble following this procedure you should contact Ledger support


Understanding the receive tab in electrum

Those fields are encoded into the QR code, so that it is easy for the person to pay you. The payer just scans the QR code, and if their wallet knows how to read BIP21 URIs, then they will already have the amount, description, and address filled into their payment form. In addition, if the offer is only available for a limited time, the wallet will prevent/warn the user from completing the transaction.


Multibit seed/ or files to Electrum wallet

You haven't specified how it failed so we can only guess. Here's a more detailed guide. Pay attention to the last two paragraphs and try again.


What were the dates of Bitcoin's previous price plummets prior to 2015? What articles were written about it?

The most notable cases were:

In 2011, the price reached a peak of $32 in June, and went down all the way to $2 in November. A decrease by a x16 factor, or 93.75%.
In 2013, the price reached a peak of $266 in April, and quickly afterwards went down to the $65 range. A 75% drop.

This can be seen graphically here and here.

As for media coverage, this list of "obituaries" is handy. Among the most infamous (at least, around people who were around that long) is wired.com's 2011 piece "The Rise and Fall of Bitcoin".


What the maximum expenditure on a lighting network channel depends on

so the lightning network, work with channel and one node for connection to a channel must spend a little of satoshi for "subscribe" to channel

In the current implementation, the spending basically involves only one of the node opening a channel by locking some bitcoins in a multi-sig address that is controlled by both parties of the channel. However, while opening the channel the node sending the bitcoins to the multi-sig address may unconditionally send some bitcoins to other parties side of the channel. In the 1.1 implementation we will have the option where both nodes can contribute to the multi-sig.

  what is the minimum value the satoshi for "subscribe" to the channel?

There is no specified minimum value but the node needs to maintain a number of conditions to open a channel.

You will need to include the amount in funding_satoshis field that can at least cover the transaction fees on-chain to establish the channel.
Since commitment transaction is signed before the funding transaction, the to_remote or the to_local outputs of that commitment transaction should be higher than the channel_reserve_satoshi that you specified in the open_channel message.
If the other node finds the funding_satoshis to be too less, it MAY fail this channel.

However, there is currently a temporary maximum limit of 224 satoshi (0.1677 BTC) that can be used to fund a channel.

  with the satoshi, I finance the channel and I can spend the maximum value of the loan, right? An example, if I have a channel X with 10000 satoshi, I can't spend the value with my node > 10000?

Although the channel has a capacity of 10,000 satoshi, you can spend only the amount that belongs to your side. Also you cannot spend the maximum amount of the channel balance that you have. Your balance need to be at least equal to the channel_reserve_satoshi which is generally 1% of the channel balance. You can spend the rest that belongs to your side. This reserve is kept so that a node has something to lose if it were to try to broadcast an old, revoked commitment transaction.


That's probably not gonna happen. The only way restarting the block chain without losing the distribution of coins would be by hard coding all the unspent outputs from the moment of the reset in all Bitcoin clients.

If you say

  Certainly it can't just keep growing for all time?

Why can't it? If the block chain grows at a slower pace that the price of storage, which can be predicted by Moore's law, why would it matter? Also, Bitcoin will probably evolve to a situation where not every user will have to keep in sync, but will use a service wallet or another payment network backed by Bitcoin so that it doesn't need the data.

Also, old blocks can be compressed when you don't use them, so the blockchain size can be reduced a little if it becomes really big.


Question about blinding factors in Confidential Transaction

There are many ways an implementation could do this.

For example, the blinding factor of the output could just be set to a hash of a shared secret.

But this has a complication that there is normally one fewer degree of freedom than there are outputs because the blinding factors must sum to zero. Due to this it's not possible for all outputs to just have their blinding factors be set as the result of a shared secret.

The obvious answer would be to just include an encryption of the relevant blinding factor.  However, in my implementation the randomness in the proof can be used to form an encrypted communication channel, so the blinding factor (and value out the output) can just be communicated via that.

Another alternative would be to include a dummy output with a range of 0 (which is very efficient to prove).


Can Bitcoins be duplicated if two private keys share the same public key?

There can only be a single spend of a transaction output, it doesn't matter if there's multiple private keys which correspond to a script. It is functionally the same as one private key signing two transactions, they can't co-exist due to the consensus rules of Bitcoin.


Why does unspent address index differ between APIs?

both return an index of 0.

0 is the correct answer here.

  Am I missing something here?

Not sure.

I can't reproduce your problem. I'm querying blocktrail like this:

curl https://api.blocktrail.com/v1/tbtc/address/2N6qMqR9D4BTkD6fS1h6Sq3kRV2FeB1L14j/transactions?api_key=MY_APIKEY

and that returns all of the transactions for the address, none of which have an index of 4.

Can you post the line of code that calls their API?


Why did the remaining money go to another address?

What you are observing is a change address.

The wallet created a new address for itself to send the change of spending the 1 BTC to. This is so that it is non-obvious to the rest of the world which is which. The 0.9999 BTC is still hers to spend, just assigned to a different address.

And it is working: if you didn't know she was sending to her brother or his address, you would not be able to infer anymore how many BTC she holds.

  I never had a reason to use the Blockchain Explorer

You generally never have to. The problem is that explorers do not know your wallet. They present a lower-level view of what is going on in the system than your wallet does, which can be confusing.

Read more: Why does Bitcoin send the "change" to a different address?


A hard fork means that the consensus rules of the fork are incompatible with the current consensus rules. So in order for miners to accept a hard fork, they would need to be running software that views those consensus rules as valid. This means that they have to manually intervene to change their software prior to the fork in order to accept it. So yes, there is manual intervention for a miner to accept a hard fork.


How similar is Blockchain (as a data structure) to double linked list?

It's a single linked list. Each block points to the previous one. It's not possible to blocks to point the next one on the chain, cause 1)it doesn't yet exist 2)there will be possible multiple blocks in the future, every one except one will get orphaned.

The term 'blockchain' is somehow misleading, it's more like a tree data structure. Only most branches diverging from the principal one are ignored after some time, and called 'orphans'.


How to calculate transaction size before sending (Legacy Non-Segwit - P2PKH/P2SH)

Assuming all the inputs you are spending are from regular "pay to address" transactions, each input will contribute 180 (plus or minus 1) bytes to the transaction.  Each output adds 34 bytes to the transaction.  And there's a fixed extra 10 bytes which are always present.

The "plus or minus 1" comes from the fact that each input needs a signature to be claimed.  The signature contains two 32 byte values, but if either of the values has a first byte of 0x80 or more, it has a 0x00 byte prepended to it.  So I'm assuming one of the two is high and the other is low.  That way I'm off by at most one byte per input.

So if your transaction has in inputs and out outputs, the transaction size, in bytes will be:

in*180 + out*34 + 10 plus or minus 'in'

For example, this transaction has 40 inputs and 16 outputs.  That gives us a transaction size of

40*180 + 16*34 + 10 +- 40

i.e. 7754 +- 40 bytes.  The actual size is 7761 bytes.

If the inputs are from "pay to pubkey" transactions then the inputs are smaller than for "pay to address" transactions.  And this will be different also for "pay to script hash" inputs too, depending on how/if that's implemented.

Edit: This transaction was made with bitcoins stolen in the Linode heist and shows a transaction size of 1337, possibly a deliberate use of leetspeak in the blockchain.

Edit2: Now that compressed public keys are commonplace, each input is 32 bytes shorter and so the transaction size is now:

in*148 + out*34 + 10 plus or minus 'in'


How to build Bitcoin binaries for Windows on Ubuntu using cross-compile

By using the pull request and instructions at https://github.com/bitcoin/bitcoin/pull/11526 you can build Bitcoin Core, except the two Qt dependent projects, with Visual Studio (or msbuild tools) on Windows.


Can I change a transaction description in Electrum while the transaction is still unconfirmed?

Descriptions are a feature of the electrum wallet, and do not appear on the Bitcoin chain - someone using another wallet (or even you restoring the keys into another electrum wallet) will not see the description.


You are correct about the first part.

Unfortunately, it's not quite possible to recover the public key from the signature. You can recover a public key that works for ECDSA purposes, but that doesn't guarantee it is byte-for-byte identical to the intended public key. That means it may not hash to the right address, which could cause the check whether the right public key was used to fail.


What are main advantages of Bitcoin over Monero?

So, what would be the main advantage of Bitcoin over Monero?

Bitcoin is more scalable. Monero inherently requires every full node to maintain an ever-growing database of spent outputs, and is many times slower to validate transactions for. Bitcoin uses a UTXO set whose size is proportional to the number of coins currently in circulation, not its history. Longer term, I believe this means Monero's technology wouldn't be able to sustain the amount of usage Bitcoin sees without seriously hurting its decentralized properties.
Bitcoin has a larger ecosystem. Currencies - especially worldwide currencies - show a strong network effect: nobody wants a currency that nobody wants/uses. In the long term, I expect that this will result in just one or a few cryptocurrencies, and Bitcoin has a much better change being one of those.
Bitcoin is less of an experiment. Monero has planned hard forks twice a year, determined by a rather centralized group of developers. This allows them to evolve much faster, but also means it's hard to consider it a decentralized currency (AFAIK even their developers will say this). For example, a government would likely have far less difficulty to force certain changes into Monero than in Bitcoin due to an ecosystem that is just much less eager to follow one group.
Bitcoin has more hashpower. Bitcoin is less vulnerable to a 51% attack than any other (decentralized) cryptocurrency.

In general, I see Monero as a research project to experiment with better privacy technology, not as a currency in its own right. However, that does not mean the  technology being developed there can't benefit Bitcoin or its users.
Bitcoin absolutely needs better privacy. And I believe it will get it too - partially due to better technology, and partially due to better practices.

Bitcoin is naturally slow to adopt changes, but improvements are continuously being worked on (search for things like MAST, TumbleBit, Layer-2 payments, Taproot, signature aggregation, scriptless scripts, confidential transactions, ...). Do I expect Bitcoin to one day have better privacy than what is possible with Monero's technology today? Probably. Do I expect Bitcoin to have better privacy than what is possible with research technology at the time? Probably not. And that is fine.


Different fee rate units - sat/vB, sat perkw, sat perkb

No, one vbyte [vB] is equal to four weightunits [wu]. The people working on C-Lightning use "sipa" interchangeably for a weightunit.
1,000 sat/kvB = 1 sat/vB
1 sat/vB = 0.25 sat/wu
0.25 sat/wu = 250 sat/kwu
20 sat/vB = 5,000 sat/kwu
Also see: Is there a difference between bytes and virtual bytes (vbytes)?


How would one get Bitcoin cash from their existing Bitcoin private keys?

You can use your private keys to get your Bitcoin Cash on any Bitcoin Cash wallet. I personally moved it to Bittrex since they'll support both after the split so I will automatically get my Bitcoin Cash there. Bittrex will allow trading with Bitcoin Cash right away but it won't allow transactions so you could sell it immediately if you want.


Bitcoin Core initialization taking forever

Are you running the latest version? (0.12 is much faster than earlier versions) On decent PC hardware with decent internet connection it should finish well within a day, I think.

On a PC you might want to give bitcoind a bit more memory:

-dbcache=<n>    Set database cache size in megabytes (4 to 16384, default: 100)


What are all the different fees used in Ripple?

The answer you cited discusses the fees that can be charged on fiat currencies by gateways, when exchanging currencies, and when using other users to swap IOUs. The XRP fees are imposed by the network itself.

The transaction fee is the only fee that is destroyed. Currently, it is 10 drops per transaction under normal load conditions. (A drop is a millionth of a Ripple.)

The fees you mentioned are actually reserves. Reserves are amounts of XRP you must hold to maintain an entry in the ledger. The reserve is returned when the entry is removed, however, there is no way to remove an account. The reserve is not destroyed, it stays in the account. You can use your reserve to pay transaction fees. You just can't create a new entry if you don't have the reserve to cover it.

Currently, the only entries that require a 50 XRP reserve are credit lines and offers. It is expected that future entries, such as contracts, will also require a reserve. A credit line only counts towards your reserve under some circumstances. Other people can't extend credit to you and increase your reserve.


Could Neutrino technically as side-effect, incentivize centralization of the bitcoin network?

Dorier is correct that Neutrino/SPV nodes are not full nodes, because they do not verify the entirety of the blockchain, leaving potential room for attack. However, the portrayal that Neutrino is no better than other SPV modes is not correct.

Neutrino is a form of SPV which improves greatly over other implementations in regards to privacy. All SPV modes inherently leak some hints about transactions you wish to receive because the information must be queried. Neutrino improves over previous SPV modes by limiting precision of information leaked to the blocks which contain the transactions they are concerned with. A full node does not leak any information because all blocks are archived and no querying needs to occur.

The trouble with SPV nodes is that they only verify that transactions have occurred using some SPV proofs, but they do not guarantee that you are on the correct, most proof-of-work chain. Any single deviation of the full validation rules could fork off onto a separate chain, where the full nodes would reject the chain which SPV users might follow.

To give a concrete example, the maximum block size is part of the validation rules. A full node will never accept a block which is over the allowed size. An SPV node may accept any sized block as truthful, because it doesn't know the block size and cannot measure it - it only receives the block header and it must trust the servers delivering the block header information to have properly validated the information.

The only way to counter this is to perform all of validation rules expected by a full node, which includes the block size, and therefore, requires you to receive all of the transactions in a block to measure its size.

Another validation not performed by current SPV modes is the rules regarding the coinbase transaction, which mints new coins. Deviation from this rule could lead to inflation of the supply of coins on the chain followed by an SPV node, who would be none the wiser.

The above do not mean that SPV nodes are inherently bad or must necessarily be avoided - but highlights that there is an attack surface which SPV nodes are vulnerable to, but which full nodes are immune to by design.

The concern that Dorier and others have, is that if it becomes commonplace to ditch running full nodes because of the expectation that a Neutrino node is good enough, then full nodes might begin dropping off the network and leaving fewer and fewer entities responsible for the validation of the full set of rules. If an overwhelming majority of nodes simply follow the rules of a few validators, then protection of the economic majority against inflation and block size expansion would be weakened compared to a network where a majority of people validate all of the rules.


Derive LTC Segwit (M-Address) private key from Trezor

When you are deriving addresses, you are actually deriving private or public keys from which an address is derived. However addresses are actually an encoding of what type of script to use in the output, but private keys have no concept of what scripts are. So when you derive your keys, they don't specify what type of address to create. Each private key can actually correspond to multiple addresses.

To specify what kind of address to create, your wallet software must be able to understand what the derivation paths mean or be able to be told what kind of address to be created. Just using a derivation path for keys which were used to derive one type of address does not mean that all software will create the same addresses.

You will need to use a software that knows how to create the address type you want and then you need to be able to tell it to do that.


How do you sign data with a private key? [javascript]

You could try using eccrypto

index.js:

var crypto = require("crypto");
var eccrypto = require("eccrypto");

// A new random 32-byte private key.
var privateKey = Buffer.from('2fd7cab0970c692b4151d77a6aeebcae2a3284556cbfc6f182c571eccfc2424f', 'hex')
// Corresponding uncompressed (65-byte) public key.
var publicKey = eccrypto.getPublic(privateKey);

var buf = Buffer.from('05de69f5d37f41340eed3230f03d2394dde5e497738a76f027b7d962a0cbdf39', 'hex')
// Always hash you message to sign!
var msg = crypto.createHash("sha256").update(buf).digest();

eccrypto.sign(privateKey, buf).then(function(sig) {
  console.log("Signature in DER format (hex):", sig.toString('hex'))
  eccrypto.verify(publicKey, buf, sig).then(function() {
    console.log("Signature is OK");
  }).catch(function() {
    console.log("Signature is BAD");
  });
});

console output:

$ node index.js
Signature in DER format (hex): 30440220352f6d47bc33e2596600c6a297a0e3e84079a9b2f16d10cb9396993370365976022062a30c63adfeef315bcfc690e254dd3b6d4f14fe9919317e14ebb15c29325326
Signature is OK

full disclosure: I'm a maintainer of eccrypto


What portion of the mining process does an ASIC perform?

TL;DR: ASIC input/output is the bold text below.

No, the ASIC does not assemble a block.

The block is assembled by a mining pool server. If you are solo mining you could let bitcoind assemble the block but you'd still need mining pool or proxy software in between to make a modern ASIC machine (stratum only) and bitcoind (getblocktemplate only) communicate.

Modern ASIC miners have a small computer built-in, acting as a controller. Some use a beaglebone. This is a low-performance computer which handles the stratum protocol, generating work, pushing work to the ASIC chips in the machine, and receiving results from them. The ASIC chips only handle the part of the number crunching that must be repeated many billions of times.

When the miner receives data over the stratum protocol it is allowed to change the nonce, the timestamp and part of the coinbase (often called the extra nonce). An ASIC chip goes through all possible nonce values pretty quickly, so the controller needs to be able to make more work using the extra nonce.

When the controller changes the extra nonce it needs to generate a new hash for the coinbase transaction (which has now been modified) and use this hash together with a merkle branch received from the pool server to generate a new merkle root. This merkle root goes in the block header.

After a merkle root is generated the controller can now calculate the midstate. The bitcoin block header is 80 bytes. SHA-256 hashing is done in chunks of 64 bytes. Since the interesting parts which we are going to change are not in the first chunk the controller will hash the first chunk once and then the ASIC chip will do the rest billions of times while changing the nonce in the second chunk each time. The midstate is the state of the SHA-256 hashing engine after the first chunk has been processed.

So the input for the ASIC chip is the midstate (32 bytes) and the 16 bytes of the second chunk (last 16 bytes of our bitcoin block header). The outputs are nonces (4 bytes) that resulted in hashes below the target. These nonces are retrieved by the controller and passed on to the pool server.

So what are those 16 bytes of data the ASIC chip needs in addition to the midstate? These 16 last bytes of the bitcoin block header are the 4 last bytes of the merkle root, 4 bytes of timestamp, 4 bytes of "bits" indicating current bitcoin target/difficulty, and 4 bytes of nonce.

In reality the ASIC doesn't need to receive a 4 byte nonce from the controller. It is going to try different nonce values on its own. So we are left with this:

The inputs to the ASIC chips are a 32 byte midstate, the last 4 bytes of the merkle root, a 4 byte timestamp, and 4 byte "bits" (target/difficulty).

If I managed to explain the above properly then you should now see why the ASIC chip is focused on this specific part of the work. For each time the work up to completing the midstate is done, the work after that point is repeated billions of times.

You can also see that generating a new midstate (which also entails generating a new merkle root) is a lot more work than just incrementing the timestamp. So once you have enough midstates to keep the ASIC chips happy for one second, you can reuse the same midstates over and over every second just by incrementing the timestamp. If the controller is slow enough and the ASICs fast enough then this "time rolling" may be necessary for the machine to work.

The slowness of the controller can also mean that the ASIC machine has a minimum difficulty it can operate on. Otherwise it will get more results (nonces) than it can handle. But the same thing goes for the mining pool server which would also not want to be spammed to death.

For maximum efficiency the ASIC is designed to only handle a limited area where expensive specialization really pays off, while the rest is handled by a tiny computer that is very cheap and very energy efficient.

Note: there are of course some differences between manufacturers. For instance some ASIC chips do not scan the entire nonce range. But the above should be the gist of it.


Paid the seller but did not receive my Bitcoin

Checking the 17PvS.. address, there are a number of transactions in and out. It is perhaps worth mentioning that by design, bitcoin addresses should be used just once, to help protect your financial privacy.

The transaction ID you linked is for a transaction that has been confirmed, if the funds are not appearing in your wallet then I would guess that either your wallet is out of sync with the network, or someone has hacked your wallet and stolen the coins. Considering the 17PvS.. has outgoing transactions after the transaction you linked, I fear the latter may be the case for you.

(Also, for what its worth, I would not use blockexplorer.com. They have decided to refer to bitcoin cash as bitcoin, which makes using their site very confusing. In my answer I assume you are using bitcoin, and not bitcoin cash)


BTC received in BECH32 (P2WPKH) format address not exist in Electrum

did you prefix p2wpkh: to the wif when importing? do you see the address under the addresses tab? view menu > show addresses if it's not there.