Differentiating Output Script (scriptPubKey) Types I am working on a little script to breakdown the data inside coinbase transactions. This is largely to improve my understanding of legacy and SegWit transactions (Given coinbase transactions have less data than for example a multisig TX, it is easier for me to work through).

One thing I've noticed about these transactions is differences in the output scripts. The Bitcoin RPC API works pretty well in decoding them, though I would like to know how to do it without an external tool.
I am aware that there are different types such as P2PKH, P2SH, and P2PK. However, what I do not know is how to differentiate them only given the raw hexadecimal representation.

For example this transaction has two output scripts:

76A91494155788E7233D7BEA9AA29FEB2ED37BC878C40B88AC

and

6A24AA21A9ED7387872912D999B657F4146043675D84B9BBCF66AD5DEC8BCC14117E4FB6999E

The RPC API tells me the first one has the type pubkeyhash with a P2SH value of 3EstC3Hhe8zvNGP73oX9oDvo36sNCygjJi

The second output script appears to be random data which cannot be decoded. (I've also seen many coinbase transactions have one readable output and one or more output that cannot be decoded).

Another example, The genesis block coinbase transaction decoded by the RPC API has the type pubkey with this script:

4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac

Question: How can I take this output script and determine the type of transaction and the assembly (OP script code) of it without external APIs?

Thank you!

thx for linking one of my older pics from 2016 :-) meanwhile things had changed, especially the multisig was not clear enough. I attach an updated version here. I didn't have the time to put newest SegWit related things into the pic though...
Still happy to see other opinions ...


How do I connect to the Electrs index? Goal:

My goal is to be able to have my own local blockchain indexed so I can perform searches based on public keys.

Blockchain:

wget https://bitcoincore.org/bin/bitcoin-core-0.19.1/bitcoin-0.19.1-x86_64-linux-gnu.tar.gz

I have a full node fully sync'ed

It seems electrs has now fully indexed the blockchain

Electrs was configued based on instructions here:

https://github.com/romanz/electrs/blob/master/doc/usage.md

What's next?

Unsure what to do next?  Do I need to create a C# app to connect to the Electrs index using JSON?  Do I need to use C# to connect to the rocksdb, which is the database used by electrs to index the blockchain?  If any of these is the next step, can someone please provide me with basic start code?  As in, how to connect my C# app to the index, pass it a parameter, in this case a public key, and retrieve a value back?

According to https://github.com/romanz/electrs

The server indexes the entire Bitcoin blockchain, and the resulting index enables fast queries for any given user wallet, allowing the user to keep real-time track of his balances and his transaction history using the Electrum wallet.
Supports Electrum protocol v1.4

It seems to me there are at least three ways forward:

Study the examples in the examples folder and add to electrs the facility you need using the interface of your choice.

Implement the Electrum protocol v1.4 in a custom client that you write. I would start by looking at the source code for Electrum.

use Electrum and import into it any address whose balance you are interested in.

The last seems like it might be the least work.


Do larger blocks make it harder for smaller miners to compete? Why? During the discussion of Bitcoin’s scalability, I’ve read the statement that

  "Large miners benefit from larger block sizes, because it makes it more difficult for small miners to compete." [1]

In the linked comment this is used as fact without explanation, but it isn’t obviously true at first glance. Please explain: Do larger blocks make it harder for smaller miners to compete? Why?

Yes. There are reasons at multiple different levels.

Propagation related.

It takes time for a new found block to propagate around the world to all other miners. Bandwidth, network latency and validation times play a roll. It's also important to keep not just worst case numbers in mind, but even adversarial case. The average case isn't very relevant.

So assume propagation takes 1 minute (bit extreme but not unheard of), that means that miners that hear about the block 1 minute after it was created, have just wasted 1 minute of hashing work on the wrong block.

Assuming all else equal this will happen to large and small miners. However a 30% large miner will NOT have that problem for 30% of the blocks (their own blocks). Small miners will only NOT have it for their own 1%.

Similar logic applies to orphan blocks: 2 new blocks found by different miners at the same time. A 30% miner has a good chance of finding another block on top of their own, while for a smaller miner (all else equal) that chance is negligible. Meaning smaller miners will have a higher orphan rate.

Economies of scale related.

Almost by definition economies of scale are favouring larger players.

All kinds of discounts and better deals you can make when buying in bulk: equipment, electricity, accommodation, staff, security, DDOS protection, fast redundant internet connections... Pretty much everything you can get faster (latest technology) and cheaper when you're bigger.

Economies of scale are sort of naturally limited by diminishing returns though. At some point electricity doesn't become cheaper anymore if you buy more and at some point fixed overhead costs become insignificant anyway. It's hard to say when the combined benefits to growing further will stop being significant. But it can certainly push small miners out of business and make it that much harder and riskier to start a new mining company.

One economy of scale that sort of works as a disadvantage to larger miners is heat dissipation: it's a easier to get rid of waste heat (or even to use the heat productively) at small to medium scale. Large concentrated miners need special equipment to get rid of heat or it prevents them from operating in hot climates.


What's wrong with this getrawtransaction JSON-RPC call? This is a very simple question. I'm trying implement a client for Bitcoind JSON API and I'm stuck on this getrawtransaction call:

{"id":"getrawtransaction",
"param":["91eb6cb34b9253cce0ab5da171a0f5aae9d3d36208e23062ba61cd9e21c09a3d",1],
"method":"getrawtransaction","jsonrpc":"2.0"}

As the result I get:

{"result":null,"error":{"code":-1,"message":"getrawtransaction <txid>
[verbose=0]\nIf verbose=0, returns a string that is\nserialized, hex-encoded data for
 <txid>.\nIf verbose is non-zero, returns an Object\nwith information about
 <txid>."},"id":"getrawtransaction"}

Could someone point me at what can be wrong? I'm sure it's something simple but I cannot get it. Bitcoind v. 0.8.

I think that should be "params" not "param"


Transaction verification for bitcoin transaction What sort of verification is done on a bitcoin transaction?
This is because the transaction has already been hashed by the miner. So how can other nodes in the network say that the transaction is valid when they cannot see the transaction contents?

A Bitcoin transaction is validated against the consensus rules. This includes that any inputs in the transaction have not already been spent (they are valid utxo's used as the inputs) and several other things.

The contents of transactions can be seen but the transaction outputs cannot be unlocked to be spent without the correct key to sign for the receiving address.

You can have a look on blockchain.info if you are interested and look up transactions, addresses or, blocks.

You can find a very good Bitcoin primer in this video:
https://www.youtube.com/watch?v=Lx9zgZCMqXE


Does NBitcoin use hardened private derivation? When writing the following code:

            ////////////////1st offline SERVER//////////////////
            //Create Master Private Key with a seed
            ExtKey privateKey = new ExtKey("16236c2028fd2018eb7049825e6b4f0191de4dbff003579918de7b7348ff06ac");
            //create master public key from this privateKey
            ExtPubKey pubKey = privateKey.Neuter();

            //save it's wifStr as key to the next server to use and generate all child keys
            string wifStr = pubKey.ToString(Network.Main);
            ////////////////END//////////////////

            ////////////////2nd online SERVER//////////////////
            ExtPubKey key = ExtPubKey.Parse(wifStr);
            //The payment server receive an order, note the server does not need the private key to generate the address
            uint orderID = 1001;
            //address created with only extendet publik key
            BitcoinAddress address = key.Derive(orderID).PubKey.GetAddress(Network.Main);

            Console.WriteLine(address);
            ////////////////END//////////////////

Am I using hardened private derivation function ? please explain why .
I know that in order to use hardened private derivation function I should derive it from a hardened parent, but how do I know that the parent is hardened parent ?

Am I using hardened private derivation function?

No. You're using nonhardened derivation. That's the only kind of derivation that you can use when you only have the public key.

Hardened derivation looks like this:

BitcoinAddress address = privateKey.Derive(orderID, true).Key.PubKey.GetAddress(Network.Main);

It requires the private key. It also doesn't matter if the parent is hardened or not.

I would recommend using nonhardened keys for most applications.


I spilled a little bit of candle wax on my Bitcoin private key and now it won't scan electronically what can I do? I need help. What can I do to still use my paper key?

You can make a manual copy of the QR code. Get out a sheet of graph paper, a #2 pencil, and start copying the grid from the QR code. Count the number of rows, and make sure your graph paper is large enough. Each square in the QR code should be either entirely filled in or entirely blank. As long as each square in the QR code is legible to you, you can make a clean version.

You don't need to get every square correct - QR codes have an error correction code.


How does blockchain ensure that a closed loop in network is not formed? Suppose there are 9 nodes and each node can connect to 8 other nodes. All these 9 nodes connect to the 8 others. Then when a new node comes where does it connect to in this case? All the current nodes are full (connected to 8 other nodes).

Nodes have more than 8 connection slots, by default they have 125 maximum connections. There are 8 outbound connections, but can still have incoming connections from other nodes when all 8 outbound connection slots are full. So in your example, the new node can open a connection to any of the other nodes in the network because they all have available incoming connection slots.

Furthermore, because connections are classified as incoming or outgoing (but data is still bidirectional), at least 8 of the 9 nodes will have at least one more outgoing connection slot.

Also, your question has nothing to do with blockchains and is solely related to networking.


HTLC (Hash Time Lock Contract) using bitcoin-qt Is it possible to manually create a HTLC using the bitcoin-qt command line?

I know how to manually creating createrawtransaction/sendrawtransaction using the bitcoin-qt clients command line, and wanted to know how to manually create a HTLC.

When  I say "manually", I mean, really getting your hands dirty, like using notepad to construct the contract, putting the values into bitcoin-cli, to convert it into a hash, ready for it to be sent using sendrawtransaction.

The HTLC isn't really a specific type of bitcoin transaction, it is more a specific output script with the required spend conditions. Thus to make an HTLC, you really need to create a custom script which the bitcoin core command line tools don't really accomplish. You could construct the script by hand or perhaps find another tool which allows more easy script editing, perhaps btcdeb by kallewoof.

A HTLC script format can be found in BIP 199. There was also a PR opened to bitcoin core to add HTLC support to the wallet, but the author became too busy to continue maintaining that PR and it was never merged. It may interest you, you can find it here.

Let's show an example. Take your value "secret", and hash it with sha256 (you could use hash160 instead also). Then create the following script:

OP_IF
    OP_SHA256 hash_of_secret OP_EQUALVERIFY OP_DUP OP_HASH160 your_pubkey
OP_ELSE
    timeout OP_CSV OP_DROP OP_DUP OP_HASH160 their_pubkey
OP_ENDIF
OP_EQUALVERIFY
OP_CHECKSIG

To spend, the first value on the stack is true or false to pick which branch of the if statement to evaluate. If you are the seller who has the preimage of the secret hash, you use the top branch and reveal the secret and sign the transaction to spend the output instantly.
Otherwise, if the deal falls through or whatever, they can redeem their funds again without revealing the secret after a certain amount of time. If the CSV with the timeout (you could use CLT instead) is successful, meaning the time has passed, they redeem it with just their signature on the transaction, and don't require the preimage of the hash.

It is relatively trivial to convert this script to an actual hex encoded script, simply by looking up the correct hex representation of each op_code and using the correct push opcodes for the length of each piece of data you are pushing (pubkeys, secret hash, etc)


Using Bitcoin Commands On the page https://en.bitcoin.it/wiki/Running_Bitcoin it shows several commands. Is this only for the bitcoin qt or can I use a more lightweight client like Electrum?

This is specific to Bitcoin-QT and the bitcoind daemon. Other clients have to provide their own command line options and API to implement this functionality. Option and command names will likely differ in syntax and semantics.

Electrum for example provides console access to its internals.


What is the difference between deleting a private key and deleting an address? On Blockchain.info, when deleting private keys from your wallet, it asks if you want to delete only the private key or if you want to delete both the private key and the address. If you choose to delete the address in addition to the private key, does this mean that unless the address is generated again, it doesn't exist anymore? If not, what does it do?

An address can be generated from a private key. But you need to have the private key from the address to be able to spend it's funds.

So, when deleting the address, it will just be completely removed from your wallet. (Note that there is no such notion of "whether or not an address exists". All addresses exist, but if nobody owns a private key for the address, the balance will be unspeakable.)

When deleting the private key only, the address will still be in your wallet, but it will be watch-only. This means that you will see the address's balance in your account, but you won't be able to spend the funds unless you enter the private key again. The main reason to do this is for security. If you write the private key down on a piece of paper, f.e., you could delete the private key from your wallet so that a person that hacks into your wallet will not be able to spend the funds.


BIP67 + importmulti + multisig descriptors I'm trying to setup a Bitcoin Core watch-only wallet using importmulti and a sh(multi(m,xpub1/*,...,xpubn/*)) ranged descriptor, and then use deriveaddresses to get receiving addresses.

Is it possible to import only BIP-67-compliant addresses somehow? With a ranged descriptor I can't manually order the multisig script pubkeys from my side as suggested in this abandoned PR because my client only touches the account xpubs.

I could manually inspect and skip addresses until I get ordered pubkeys, but that's really ugly and fragile.

No, the descriptors language currently doesn't support BIP67.

It would be easy to add a multi_bip67 or so to the language if there is a need for it.


Stale block verification at node level It comes to my curiousity about how exactly the node A will mine block N+1 when he & node B generated block N (not in same time but) in a fairly close timeframe.

In many articles, it says that when 2 nodes (A&B) are generating the same height block at same time, it will cause a fork. This means some nodes will mine after A's new block and others mine B's. This is understood. However, it will take time when A's new block sync to B. Let's assume it takes 10 seconds to pass to B. In the middle of the sync (saying 5th or 6th second of total 10), B just generates the new block (with same height), and propagate it out before receiving A's block. What will happen when B receives A's block then?

I have 2 possible answers but not sure which one is correct, or neither.
(assuming all TX/UTXO in the block has no issue)

ANSWER-1: B will discard B's block, and accept A's, because B block's timestamp is older than A's (make sense?)

ANSWER-2: when B broadcasts his new block, B by default accepts its own generated block (N+1) and immediately start to mine block N+2 upon that (at the time when B has not received A's block yet.) Then B receives A's block (N+1), in this case, B should keep A's chain but still continue to mine at his N+2 block height.

Any advice?

ANSWER-2: when B broadcasts his new block, B by default accepts its own generated block (N+1) and immediately start to mine block N+2 upon that (at the time when B has not received A's block yet.) Then B receives A's block (N+1), in this case, B should keep A's chain but still continue to mine at his N+2 block height.

This is basically correct. B will receive A's block, validate it, and if it is valid, he will store the block. However he will not change his view of the blockchain to include A's block. He merely holds onto A's block just in case more blocks are found on top of it which would then require B to change his view of the blockchain.

B's view of the blockchain will remain with his N + 1 block and continue to mine his N + 2.

In general, when two blocks are found at the same height around the same time, nodes will update their view of the blockchain to include the block which they saw first. The view of the blockchain only changes if there exists a blockchain that has more cumulative work than the one that the node currently sees as the correct blockchain. If the two blockchains have the same cumulative work (i.e. orphan race as described in this question), then the node uses the one it saw first.


Is it safer to use one type of hardware wallet of several? I know that there are several brands of hardware wallets with open source firmware that are considered safe. Is it better to just one that is safe and you are most familiar with? Or would hedging by storing coins in multiple wallets make sense just in case some exploit is found in the future?

Personal, I would use multiple wallets just in case some exploit is found in the future. For the more paranoid/safety conscious person, I would also place the hardware wallet in a mini faraday cage, until needed. The reason behind the faraday cage is that electromagnetic radiation of WIRED or even hardwired devices can be picked up from up to 65 feet away; you could turn off the device to combat that possible risk (instead of a mini faraday cage)... Don't take my word for it... here is a short youtube clip of this in action. I would also use only a external hardware wallet which only connects to the internet by Ethernet cable for the same reasons described above. When not in use, simply disconnect it from the internet... this further improves the security of the store private key.


Is it safe/wise to buy bitcoins with a credit card? I'd like to buy bitcoins with a credit card or should I use my debit card?

Buying any crypto from your credit card is same as buying it through any other payment method. both are equally secure.
But always buy it from authentic source only, there are many scamming sites running in the crypto world.


What happens if I send a Bitcoin to an address no one owns? Say I send 1.0 BTC to a Bitcoin address that is valid but has never been used yet.

Does that 1.0 BTC effectively disappear? Or will the transaction fail?
If the transaction succeeds, could someone eventually start using that address and claim that 1.0 BTC?

If the address is valid, the transaction will succeed. If nobody knows the private key for that address, the money is lost forever. For all practical purposes, it's impossible to guess the key for an address that you made up.


How can one remain relatively anonymous while using Ripple? Inspired by this and that.

What can an individual that uses Ripple do in order to remain as anonymous as possible? How do Ripple's "anonymity profile" compare to Bitcoin?

One specific difference is that Ripple accounts need XRP to be opened, and that XRP has to come from somewhere, while Bitcoin accounts are free to create.

Current client doesn't expose it yet, but each account is really an Account Family of un-linkable addresses which can be single use.

https://ripple.com/wiki/Account_Family


Does the block reward get halved every 4 years regardless of hardware advancements? Is the invention of a faster computer (let's say a quantum computer) or the lack of advancements in computing power (let's say it takes a decade to make any progress greater than incremental increases on currently technology) capable of affecting the amount of time it takes to halve the block reward?

In other words, does the block reward get halved every 4 years, regardless of how much the hardware available is or isn't progressing?

The block halving takes place every 210,000 blocks. The difficulty retargeting mechanism makes it so that 210,000 blocks take approximately 4 years, but this is not exact. If the hashrate is rapidly growing, it will take a little less than that.

For example, if the total network hashrate doubles every year, it will take about 1 month less. If it doubles every week (increases by a factor of 4.5 quadrillion every year), it will take only 2 years.


Bitcoins sent and confirmed by blockchain. But hasn’t been recieved https://btc.com/57d2819220862abf8a54f4912f3f973f0041cf8c3d64e229ff6248417cad0e73
I have sent money from cryperium. They have confirmed that the money has been sent. But i havent recieved the money at the source. Please help

The blockchain is the truth, the whole truth and nothing but the truth. It is the only truth,  the absolute truth. It is incontestible.
If the blockchain says the money was received it has been received. Money that has been received with more than five confirmations virtually never ever becomes unreceived.
It is probably worth checking several different copies of the blockchain by using several different blockchain explorers.
If a wallet does not show this amount it means one of:

The wallet doesn't know about the receiving address. Perhaps because the address was not generated by that wallet.
The wallet isn't fully synchronised
The wallet is broken in some way
A person managing the wallet is lying to someone without direct access to that wallet.

See also

Answers to other questions about money not received


Which address gets the money from the multisig transactions? (and multisig in general) I am playing with the blockchain and I saw this transaction there

https://blockchain.info/tx/60a20bd93aa49ab4b28d514ec10b06e1829ce6818ec06cd3aabd013ebcdc4bb1

the output from decoderawtransaction  by bitcoind is here

http://pastebin.com/wbLH3HZa

I don't really get what is hapenning. I tried to read this https://blockchain.info/wallet/escrow but I am not that much wiser.

Does it mean that the  multisig output works as some kind of "escrow" for the whole transaction, not just the 0.01 output?
more importantly, who from the two addresses can spend the output of the multisig transaction?
How do the parties "free" the money from "escrow"?

I would like to see it on this specific transaction - who gets what kind of money and how? Thanks.

I don't know how a 1 of n multisig transaction would affect the balance display of individual wallet clients, but because only one of the two addresses must sign, the coins effectively belong to both until one spends them.

To explicitly address your bullets:

A multisig output can be used for escrow, but it only affects the multisig output itself.  Because this output only needs signature of one, it doesn't make for effective escrow.  2 of 3 outputs with two parties and an arbiter make for good simple escrow.
In this case, either address can spend this output
In this case, the funds are 'freed' when either party decides to spend them.  In a 2 of 3 escrow situation, an unsigned transaction is created to spend the multisig output and then two of the addresses must sign that transaction individually before it becomes valid.  Broadcasting the fully-signed transaction frees the coins by sending them to whatever output was specified, which could very well just be a regular address.


How does offer creation impact fund requirement of an account? How much does each offer created increase the XRP requirement on that account?

Does it relate to PayerGets?

Is it cleared once I cancel the offer?

Every entry in the state tree of the ledger requires 12.5 XRP reserve, it doesn't matter if it's a trade offer or a trust-line. When the entry disappears from the ledger (by getting filled or being canceled), the reserves can be moved again.

The only exception is the account entry, which requires 50 XRP instead of 12.5 XRP and is perpetual (because accounts cannot be deleted).

See https://ripple.com/wiki/Reserves for details and the current reserve requirements (they can and have changed).

It is not related with the field TakerGets of the message OfferCreate.


Correlation of number of (non mining) full nodes to internet bandwidth Are there any correlation studies showing the number of (non mining) full nodes per country (total or per/capita) compared to average internet connection speeds?

I know there are great differences between connection speeds depending on ISP and if the users are in rural or urban areas.

The time to download an entire blockchain from scratch for maximum security can take a very long time in some places. I want to know how much this discourages people from using full nodes (in favor or SPV wallets).

Comparing average connection speed to number of full nodes (per capita) in each country is what I am looking for.

I don't think any such study exists, because it is very difficult to gain any concrete information about full nodes on the network.  Because nodes can (and often are) run over proxies or TOR, their true IP addresses are often obscured.  Furthermore, IP addresses aren't necessarily a good indicator of geographic location, and certainly not connection speed.

Even if you identify a node in a country with generally poor residential bandwidth, the operator of that node could be running it from a commercial data center that has much better connection speeds than the average for that country.  Attempting to sort full nodes into residential and commercial categories would be almost impossible.

It sounds like you're trying to do something similar to this:  Bitcoin node Decentralization


What options does one have to manage Bitcoins? I started trading and buying Bitcoins for a while now, and realised: I have multiple wallets and multiple websites where I have bitcoins/litecoins.

I think most of the people, including me, want use Bitcoin in there day to day life, and also invest in Bitcoin and Litecoin.

For this, which setup is recommended?

  Is it safe yet to store, lets say, 50 to 100 Bitcoins at some online service, or should I, after purchasing, transferring it to a
  hardware wallet?
  Are there any sites which are buying Bitcoins or is it always from person to person (therefore, Volume might be a problem when investing)
  All recommended services and wallets also have as many open "recently got hacked" reddit threads. Which ones have to be in a basic
  setup?

In my perfect world, I have

A hardware wallet with my Bitcoin investment
A hardware wallet with Litecoin
A mobile app for day-to-day bitcoins
A trusted online service where I go to buy Litecoin/Bitcoin and also
sell it

Is my perfect world correct, are the big tradings time over or yet to come? From a tech perspective, Bitcoin is quite old, but there are still just low-quality apps out there.

Any guidance?

I am not a trader, so I don't have much advice to offer in terms of which services are best.  However, I do have some thoughts and experience with storing bitcoins.

From a technology standpoint, bitcoins are secured by the private keys held by the owner of the coins.  Private keys are cryptographically amazing, but terrible in terms of user experience.  If the management of private keys was easy to create an interface for, the internet would be a much more secure place.  Unfortunately, humans have proven really bad and managing private keys.  This is the problem every bitcoin wallet attempts to solve.

To understand your options for managing private keys (wallets), you have to understand how the security model works.  As the name suggests, private keys are meant to remain private.  Anyone who has knowledge of them has access to your bitcoins.  Meanwhile, you also never want to lose your own access to the private keys.  If you do, you lose your bitcoins.  This creates a problem with solutions that have an indirect relationship between the two issues.  If your private keys are well protected, you increase the chance that you will lose your access as well.  If your private keys are easily accessible, you are unlikely to lose them, but far more likely to be robbed.  There are some elegant technical solutions for this paradox, but no user-friendly solutions that come to mind.

Let's explore some of the options.

Web Wallets

This is the case where some online service manages your private keys for you, but gives you access to control how the bitcoins they store are used.  Personally, I would define the owner of the bitcoins to be whomever has access to the private keys.  With this viewpoint, you are not the owner of the bitcoins held in an online wallet.  You are the owner of an account with an organization who owns the bitcoins on your behalf.  The question of whether it is "safe" to store 50 to 100 bitcoins in an online wallet can only be answered by answering one or both of these questions:

Do I trust this 3rd party with 50 to 100 bitcoins (both with honesty and security)?
Can I afford to lose 50 to 100 bitcoins?

If your answer to either question is "no", then you may want to consider reducing the amount you store in the online wallet to an acceptable amount.

Hardware Wallets

These are single-purpose computers that manage your private keys for you.  Because they are usually offline devices, they go a long way towards being hacker-proof, but remember that there really is no such thing.  These sound great, and many people have started using them, but I'm personally skeptical.  These products were created from a growing demand, and rushed to market to beat out competitors.  Even if the security is perfect (which it never is), you are now trusting your wealth to the reliability of these machines.  I would recommend letting the market settle down for a couple of years, and let a few more generations come out, before trusting too much of your wealth to these devices.  You don't want the scenario where the thing won't power on, but you have your life savings stored on it.

Mobile App Wallets

These wallets are by far the most convenient for day to day use, perhaps even more so than online wallets.  You can scan QR codes to pay people, generate QR codes to be paid, and have your funds at your fingertips as you go about your day.  The drawbacks are also pretty steep.  Your funds are now only as secure as your phone.  If you get malware, you could lose your money.  If your phone gets lost or stolen, you lose your money.  If your device breaks (ex. dropped in the toilet), you may lose your money.  I view a mobile app wallet as I view a physical wallet.  You don't go about your day to day business hauling around your retirement savings.  You only leave the house with as much cash as you plan on spending that day, and try to keep it to what you can afford to lose.

Desktop Wallets

This is the case of running Bitcoin Core, or Electrum, or some other desktop-based wallet.  In principal, these are about the same as a mobile app wallet, with the advantage that you may be participating as a full-node in the Bitcoin network.  This allows you to trust transactions and blocks more than with an SPV Wallet, but doesn't really offer anything better in terms of the management of private keys.  Desktop wallets can be run on your day to day desktop, or perhaps a desktop that is usually kept offline and used only for bitcoin transactions.  Like with mobile app wallets, the security of this wallet is only as secure as the computer it runs on.  Also remember that software wallets (both mobile and desktop) have the ability to backup the wallet files, which can add to their reliability, but increase the number of ways your bitcoins can be compromised.  Again, there's always a trade off.

Paper Wallets

A paper wallet is a physical, paper document that contains a QR code of the the private key to a Bitcoin address.  You can store money in the wallet by sending bitcoins to the address, and then redeem them later by importing the private key into some other type of wallet.  This document can then be stored in a safe, a safety deposit box, buried in the woods, or anywhere else that you feel is safe from burglary and fire.  Think of this as a stack of fiat currency being held in a safe.  This is one of the safest ways to store your bitcoins, but is terribly inconvenient.  There is also the question about how the address was generated in the first place.  If you don't trust the software/organization that generated the paper wallet, then you can't trust the wallet.

Brain Wallets

A brain wallet is a way of generating a private key from a passphrase that is not stored anywhere, but rather remembered by the owner of the wallet.  It is much like a paper wallet, except that the private key is never written down.  Again, you must trust the software used to generate this address from your passphrase.  You will also most likely want to generate a passphrase, rather than use a passage from literature or a song lyric.  With computer speed and storage increasing along an exponential curve, and all the worlds books being digitized, it is not unthinkable that someone will attempt to steal bitcoins by brute forcing every known phrase from every book and song.  With cryptography, randomness is extremely important.

To conclude, diversification is always a good strategy for wealth management, and bitcoins are no different.  If you spread out your bitcoins between different types of wallets on different storage mediums, then you are less likely to lose everything, but more likely to lose something.  If you limit exposure to the wallets you use for long-term holding, you increase your security.  Just don't forget your password, passphrase, safe combination, place you buried it, or whatever.

I hope that helps.


How is the endian conversion done? This answer seems simple, but I'm finding mixed answers. This question describes the conversion from little-endian to big-endian hex strings (or vice-versa) as switching the order of bytes in every slice of four bytes, where here it's described as just a string reversal. Both seem correct in their contexts, so what's really going on?

In general, converting between big and little endian values depends on exactly how you're storing those values, so both of your examples could be correct in different implementations. To this end, techniques are likely to vary even within the same application since it's more dependent on how your input data is formatted.

It's also dependent on how your particular use case defines endianness - there's no one-size-fits-all definition - endianness can refer to the order of 8-bit bytes within a 16, 32 or 64 bit word or it could refer to the order of individual bits or even the order of entire words within a larger context. If you're encoding the 16-bit word "07F3" for example and your definition of endian refers to bytes within a word then big-endian would be "07F3" and little-endian would be "F307" - working with a 4-bit byte you would end up with "07F3" and "3F70" and working with individual bits big-endian would be "0111 1111 0011" (07F3) and little-endian would be "1100 1111 1110" (0CFE).

One excellent example, however, is the EncodeBase58() function in Bitcoin's base58.h which uses a char vector and C++'s built-in reverse_copy function to reverse the elements' order in the vector:

// Convert big endian data to little endian
// Extra zero at the end make sure bignum will interpret as a positive number
std::vector<unsigned char> vchTmp(pend-pbegin+1, 0);
reverse_copy(pbegin, pend, vchTmp.begin());

Now I'm not 100% sure but I believe that what's being passed in to the encode functions is a UTF-8 encoded string representation of the value, so in your own words it would seem that Bitcoin's endianness conversion - at least where Base58 conversion is concerned - is a simple string reversal as long as the input is UTF-8 encoded.


How can I send thousands of small amounts (10'000 sat.) to bitcoin wallets without paying to much fees? I want to make a faucet. But my problem is that I don't know how I can make my payouts. I would have a lot of little amounts (like 10'000 satoshis) to pay.
Is there an efficient way of doing thousands of those transactions without paying to much fees?

Do I have to make every transaction manually (in Python or in Java with the Blockchain API)?

Thanks for the answers.

Thanks for all the visitors, which have thought about that.
I found now the solution for that problem. I use the blockchain.info API. There is an option to send to many addresses at the same time.
https://github.com/blockchain/api-v1-client-python/blob/master/docs/wallet.md


Where can I learn how to build a blockchain from scratch? I am a newby programmer, I am learning python and objective C and I want to learn how to build a blockchain from the beginning. Are there any resources that could help me.

There was a recent presentation by Portia Burton going over some of the basic steps in creating your own custom blockchain based on Ethereum, however it is in Node not Python as you are requesting.

It's not incredibly detailed, but still it could be useful: https://youtu.be/QWHjp_nzxaY?t=14m11s

There's also this guide on bitcointalk using C++ and the litecoin source code. https://bitcointalk.org/index.php?topic=225690.0


Is block reorg works in this way? i need an expert to clarify is my understanding correct to block reorganization. I can't find answer can persuade me, sound like only i dunno what is block reorganization :(.
say my bitcoin network has total 10 nodes, and 10 of 10 are all miners
say i had successfully mined a block#10, and that is another competitor also mined a same height of block at the same time and then i shut down my node.
after few days, i restart my node, so now what event will be trigger in my bitcoin program? i imagine possible steps would be like this. below "I" refers to my bitcoin node.

i found my largest chainwork is block#10 with hash 0000123.

i broadcast getheader message to all my peers, with max query blocks = my block height + 100 to grab next 100 block headers after my block.

say 5 of my peers return me result. i wonder now is bitcoin performs PBFT on returned result? say at least 3 peers return me same result, then i assume that this result is correct.

ok, now result return from point 3 told me that there no longer got block added after my blockhash, i know my block has been orphaned.

next, i lower my block height to 9, then i ask my peers again, and peers response me yes that is block#10 which hash is 0000456 and prevhash same to my hash in block#9.

before start to download all blocks start from hash 0000456, i need orphan my block#10, so i remove it from chain and revert the transaction to mempool.

and now i feel safe to keep download until meet most chainwork block.

i need your clarification. thanks.

Your understanding is basically correct. Keep in mind two things:
First, chain length isn't really the correct metric but accumulated chainwork. For practical discussion we can imagine for now they are the same thing.
Second: the entire purpose of Bitcoin full node software is to find the chain with most accumulated work. The whole meaning of its life is to discover that chain and synchronize its database with that chain (specifically, the UTXO set aka list of unspent coins aka "the ledger").
So it does not matter who mined what block. As long as it is running, the full node will try to stay in sync with its peers by sending locator messages (getheaders) and responding to new block announcements.
When a full node receives a valid block header that has more chainwork than its own tip, it attempts to download whatever blocks are necessary to verify that chain. If those blocks are valid and require "rewinding" the current chain, the node will do so, iteratively.
Consider this set of chain tips:
A-B-C-D-E-F
       \
        G-H-I

If your node synced blocks A through F then some time later learned about block header I, it will first download and verify headers G through I, then if they are valid download blocks G through I. If those blocks are valid, the node will disconnect F from its own chain, then disconnect E, then connect blocks G through I from the common ancestor D.
To address your points specifically:

You don't really "request +100 blocks" what you do is tell your peers about your own chain tip and ask them if they know about any chains with greater work.

"orphaned blocks" are blocks with no parent and this does not really ever happen on Bitcoin any more. I think you mean "stale blocks" here, but even then if peers do not respond with a greater-work chain, your node does nothing and assumes it is on the correct chain tip.

You would never "lower" your chain unless you were doing a reorg as I described above. In fact, if there were two blocks at height 10 you still wouldn't do anything until one of those chains got extended to height 11. THEN -- you become aware there is a greater-work chain out there and your node will attempt to download and verify it.


Is it possible to combine multi-sig and locktime? Is it possible to create a 1 of 2 multi-sig address in which only one of the keys is time-locked and the other can sign any time?

only one of the keys is time-locked

Keys aren't time-locked. Transactions are. However, Bitcoin now has an opcode for this purpose: OP_CHECKLOCKTIMEVERIFY.

Essentially, it forces the transaction to have a lock time further in the future than its argument, otherwise the transaction is invalid.

In your case, the script would look like this:

OP_IF <this pubkey can spend at any time> OP_CHECKSIG OP_ELSE <block number> OP_CHECKLOCKTIMEVERIFY OP_DROP <this pubkey must wait until block number> OP_CHECKSIG OP_ENDIF

The spend-anytime key can redeem the transaction with

<Sig> 1 <above script>

The other key can redeem with

<Sig> 0 <above script>

but only after the given block number.


randomly assigned pow? in Bitcoin, every node solves the POW puzzle.

instead, are there cryptocurrencies where a random group of nodes is chosen (before block creation), and only that group solves for the puzzle?

in Bitcoin, every node solves the POW puzzle.

Not really, only miners solve the "PoW puzzle" as you put it, all the other nodes just verify that the "solution" is correct. It is actually random which of the miners solves it, like you suggest, while higher probability of finding a solution is given by more powerful mining hardware, even mining with the smallest computer theoretically has a chance of finding the next block.


What are the risks of in-person private currency exchanging for travellers? This answer suggests popularity growth of people privately exchanging bitcoins for a physical currency, in person. This might occur in "coffee shops, hotels, hostels, hackerspaces, etc".

An example would be 2 travellers meeting in a hostel in, say, the UK. Traveller A has just been to the USA and traveller B is about to go there. Traveller A has US$200 that's no longer needed, so he agrees to exchange it for some of traveller B's bitcoins.

Definitely assume traveller B has a mobile phone or other internet access to perform the transfer, but please consider both cases of traveller A having and not having similar access at the time.

What are the risks of such a deal, and what can be done to improve the chances of a successful deal?

I think that "personal safety risks" are outside the scope of this website, so I'll mention the technical risk - double spend. If you don't wait for one confirmation, a double spent attack can be performed, and you won't get your Bitcoins.

Luckily, you'll only have to wait five ten minutes on average for a block to be found (blocks are one every ten minutes, so the expected delay until the next block is five minutes).

After one confirmation, it's very unlikely such a small transaction will be double spent. If you want to increase your security, wait another block or two.

Traveller A doesn't need to have internet, he can use a Pimpcoin-like card (link NSFW), with SMS notifications of incoming transactions.


How do I get started debugging Bitcoin Core functional tests? I would like to get started with debugging Bitcoin Core code. I have heard debugging Bitcoin Core functional tests is a good place to start as they are in Python rather than C++ and they are easier to understand. Any recommendations or good resources to help me do this?

To understand the functional tests, I think it's important to start with an understanding of how bitcoind works and how the RPC interface is used.
Start Bitcoin Core in a terminal window in regtest mode (a local test network that does not connect to any peers by default):
$ bitcoind -regtest

Keep an eye on the output! This is your debug log, and important messages are printed there -- many tests even check to make sure a certain message was printed.
In a second window, get a list of commands:
$ bitcoin-cli -regtest help

You can get help for any specific command:
$  bitcoin-cli -regtest help getnewaddress
getnewaddress ( "label" "address_type" )

Returns a new Bitcoin address for receiving payments.
If 'label' is specified, it is added to the address book
so payments received with the address will be associated with 'label'.

Arguments:
1. label           (string, optional, default="") The label name for the address to be linked to. It can also be set to the empty string "" to represent the default label. The label does not need to exist, it will be created if there is no label by the given name.
2. address_type    (string, optional, default=set by -addresstype) The address type to use. Options are "legacy", "p2sh-segwit", and "bech32".

Result:
"str"    (string) The new bitcoin address

Examples:
> bitcoin-cli getnewaddress
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getnewaddress", "params": []}' -H 'content-type: text/plain;' http://127.0.0.1:8332/

Give it a try!
$ bitcoin-cli -regtest getnewaddress
bcrt1qua6ku8kkx4m57tg6q44wh00h58vpk7lm8h82sy

Now go take a look at a simple test like wallet_resendwallettransactions.py and note the syntax node.getnewaddress() -- by this point you probably know exactly what that does and what the return value will be.
To go deeper and understand how the test framework launches and configures individual nodes, read test_framework.py. You'll notice many of the functional tests pass configuration parameters to the start_nodes() function.
To get a dictionary of those command line parameters, execute:
$ bitcoind -help

These are the key tools I think and the in-program help information is an invaluable resource. By going through functional tests and looking up the rpc commands and launch arguments, you'll eventually get an instinct for how the more complicated tests work.


Hacked or Cracked i lost coins Left wallet qt alone for some months, then started it up and during sync coins disappeared?

There is a chance that someone took your coins by hacking into your computer and copying your wallet.  However, if this is the case, you should be able to load your wallet and see the out payment transactions.

Alternatively, search your payment address at BlockChain.Info  BlockChain.Info is possibly the best block explorer for bitcoin.  It's a good place to do research.


Why does bitcoind say "error: couldn't connect to server" for the first few minutes of boot-up? After starting bitcoin from the command line, with:

./bitcoind -daemon

I immediately run the followup command:

./bitcoind getinfo

which gives me the following error:

  error: couldn't connect to server

This error lasts from a few seconds to a few minutes depending on the machine.

Two questions:

What is Bitcoin doing during this time, that causes this error (i.e. prevents the client from returning the results of getinfo)?
Are there any steps I can take that will minimize this start-up time?

The first thing Bitcoin-QT does is verify that the data stored on the disk is valid. Among other checks this includes verifying the last 288 blocks (the past two days in expectation). This task involves a large number of signature checks and will take some time to complete. Only after the startup checks have successfully completed will the connections to the Bitcoin Network be established and only then the client will start listening for incoming JSON-RPC requests.


How to read cryptowatch? I'm a complete newbie to crypto, and to trading, and I would like to be able to understand what the lines and charts mean on cryptowatch. I know this is a tall order to collect and collate, but I imagine other people wonder about this as well.

In order to make the discussion easier, i've made a labeled snapshot of their output.

Help me understand what these labeled charts display and mean?

Check this out:
https://www.youtube.com/watch?v=yO-W_GDwZrg&t=497s

This video will walk you through the different aspects of Cryptowatch and how to use them for profitable trading.


Can I retrieve my bitcoins from years ago that I never received? How can I get hold of my bitcoins that never made it to my wallet years ago?

I purchased some bitcoins years ago (have got my receipt and all emails from who I purchased). I downloaded Bitcoin-Qt 7, synced it, got an address for the seller. It went through, but I could never sync it again as I was using prepaid internet credit. So, the bitcoins never got to my wallet! I gave up for a few years, but now I have unlimited download. Now Bitcoin-Qt 7 has a download issue. I switched to Bitcoin Core 11 now. I would like to know how I can get hold of my bitcoins?

Ther was no data transferred over to Bitcoin Core 11 sadly. Please can any one help me?

If you still have the wallet.dat file and your password you can access your bitcoins. You do not have to use Bitcoin-Qt 7 and it does not matter if your wallet ever synced before. If the sender sent the bitcoins to an address you control and the transaction was confirmed, the bitcoin are yours.

https://blockchain.info/wallet/import-wallet

If you want to use a new version of Bitcoin-Qt you can do that too: See Import wallet.dat into a new Bitcoin-Qt client


How to compile sources on MAC OS in 2017? I know there are a few questions like this on the stack already, but currently I'm facing issues with a compilation. I've tried an official guide from the github for mac os, but end up with a lot of errors.
First of all, I always get this kind of errors:

aclocal: error: aclocal: file '/usr/local/share/aclocal/introspection.m4' does not exist

and other files from aclocal.

If you have an experience, and know how to setup, or know any guides, please share share. Thanks in advance :)

On a Mac Pro with MacOS Sierra 10.12.6 I got a clean compilation by following the instructions in doc/build-osx.md.

The sequence of commands is:

1) First install Xcode and HomeBrew by executing (in Terminal)

xcode-select --install

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null

2) Then install required libraries with

brew install automake berkeley-db4 libtool boost --c++11 miniupnpc openssl pkg-config protobuf qt libevent python3

(note: I added python3 otherwise there would be errors during "make check")

3) Download and compile

git clone https://github.com/bitcoin/bitcoin
cd bitcoin
./autogen.sh
./configure
make
make check


Can't send raw transaction Bitcoin Core 0.19.1 - non-mandatory-script-verify-flag (Signature must be zero for failed CHECK(MULTI)SIG operation) I wanted to send a raw testnet transaction and I was doing it like in the bitcoin documentation, but I still get this error:

non-mandatory-script-verify-flag (Signature must be zero for failed CHECK(MULTI)SIG operation) (code 64) (code -26).

What am I doing wrong?

I take one transaction from my listunspent

{
    "txid": "8ee71fee9e4706100c09fb2da4c3ccdac1a4475981bd893ba1eba9417947abff",
    "vout": 0,
    "address": "2Mw44JvAhBs4hgh5bT3gP2NgbhTbVwngW1m",
    "label": "",
    "redeemScript": "00143b88811e01b3efaa0bcd9da16ef85ef3a1583349",
    "scriptPubKey": "a91429c3d920cd18e34db9035c4322474aae4465792187",
    "amount": 0.02641617,
    "confirmations": 16197,
    "spendable": true,
    "solvable": true,
    "desc": "sh(wpkh([8939dfa5/0'/0'/8']02a44b3dd2f0964048265982156f668c037dfabc140eb98f292dbb723d28b85261))#husuy9tw",
    "safe": true
}

Then I create raw transaction from this:

createrawtransaction '[{"txid":"8ee71fee9e4706100c09fb2da4c3ccdac1a4475981bd893ba1eba9417947abff","vout":0}]' '{"2NCH5HXBwfHegFEUTNrkSKzyYTnTYQKDUjU":0.02}'

dumpprivkey
And signs the transaction like this

signrawtransactionwithkey '0200000001ffab477941a9eba13b89bd815947a4c1daccc3a42dfb090c1006479eee1fe78e0000000000ffffffff0180841e000000000017a914d0c3f50336b5f109207d722c692191ff86263e968700000000' '[" $privKey "]' '[{"txid":"8ee71fee9e4706100c09fb2da4c3ccdac1a4475981bd893ba1eba9417947abff","vout":0,"scriptPubKey":"a91429c3d920cd18e34db9035c4322474aae4465792187","redeemScript":"00143b88811e01b3efaa0bcd9da16ef85ef3a1583349","amount":0.02}]'

{
  "hex": "02000000000101ffab477941a9eba13b89bd815947a4c1daccc3a42dfb090c1006479eee1fe78e00000000171600143b88811e01b3efaa0bcd9da16ef85ef3a1583349ffffffff0180841e000000000017a914d0c3f50336b5f109207d722c692191ff86263e968702473044022010c174b3306cac5ca8ddbb6eadf0de2299c2a216ade25088290c17880aa5bd60022017bc9de608e7ff59ffa09a6a60d848875d37edfc4a4b687f0eb94d4c2cd11b4f012102a44b3dd2f0964048265982156f668c037dfabc140eb98f292dbb723d28b8526100000000",
  "complete": true
}

But when I want to send raw transaction

sendrawtransaction 02000000000101ffab477941a9eba13b89bd815947a4c1daccc3a42dfb090c1006479eee1fe78e00000000171600143b88811e01b3efaa0bcd9da16ef85ef3a1583349ffffffff0180841e000000000017a914d0c3f50336b5f109207d722c692191ff86263e968702473044022010c174b3306cac5ca8ddbb6eadf0de2299c2a216ade25088290c17880aa5bd60022017bc9de608e7ff59ffa09a6a60d848875d37edfc4a4b687f0eb94d4c2cd11b4f012102a44b3dd2f0964048265982156f668c037dfabc140eb98f292dbb723d28b8526100000000

non-mandatory-script-verify-flag (Signature must be zero for failed CHECK(MULTI)SIG operation) (code 64) (code -26)

I tried with a lot of transactions but I can't send it and can't see what I'm doing wrong. Normally, the Bitcoin Core send button works fine.

That error message is irrelevant.
SegWit introduced a new way of producing the hash digest for signing which requires the "amount" being spent to be included during hashing. This "amount" is the value of the output that is being spent not the amount of the new output you create. In your it is 0.02641617 or the actual value 2641617 in satoshi.
Your step 4 should become:

signrawtransactionwithkey '0200000001ffab477941a9eba13b89bd815947a4c1daccc3a42dfb090c1006479eee1fe78e0000000000ffffffff0180841e000000000017a914d0c3f50336b5f109207d722c692191ff86263e968700000000' '[" $privKey "]' '[{"txid":"8ee71fee9e4706100c09fb2da4c3ccdac1a4475981bd893ba1eba9417947abff","vout":0,"scriptPubKey":"a91429c3d920cd18e34db9035c4322474aae4465792187","redeemScript":"00143b88811e01b3efaa0bcd9da16ef85ef3a1583349","amount":0.02641617}]'


Bitcoin fork! can I gain access to the coins I wanted to know - I got some 1.18 BTC on blockchain.info and I noticed just now that there are allot of hard forks happened till now.
how is it possible to gain the coins from those hard forks ...and are those still live?

Name---Fork from---Fork height

Clashic Bitcoin 478559
Gold    Bitcoin 491407
Cash    Clashic 504032
2X  Gold    494784
Diamond Bitcoin 495866
SuperBitcoin    Bitcoin 498888

You can access your coins in blockchain.info only if blockchain.info announces will support the fork.
Remember you should have bitcoin on your account before hardfork.


How can I use the vanity name generator to look for an address? How do you use the vanity name generator to look for an address?

Is there an estimate on how long it takes to find addresses of varying lengths and complexities?

Proper syntax for VanityGen is:

Usage: vanitygen [-vqrikNT] [-t <threads>] [-f <filename>|-] [<pattern>...]
Generates a bitcoin receiving address matching <pattern>, and outputs the
address and associated private key.  The private key may be stored in a safe
location or imported into a bitcoin client to spend any balance received on
the address.
By default, <pattern> is interpreted as an exact prefix.

Options:
-v            Verbose output
-q            Quiet output
-r            Use regular expression match instead of prefix
              (Feasibility of expression is not checked)
-i            Case-insensitive prefix search
-k            Keep pattern and continue search after finding a match
-N            Generate namecoin address
-T            Generate bitcoin testnet address
-X <version>  Generate address with the given version
-t <threads>  Set number of worker threads (Default: number of CPUs)
-f <file>     File containing list of patterns, one per line
              (Use "-" as the file name for stdin)
-o <file>     Write pattern matches to <file>
-s <file>     Seed random number generator from <file>

The important options to know are -i and -r which cause the search to be case-insensitive and use regex, repsectively. In its simplest format, you issue a command like:

vanitygen.exe 1david

Which tells vanity gen to look for an address with the exact prefix "1david." On a single core of my core i5 this runs at about 325,000 keys per second as shown by the status display (which does show a time estimation.):

[324.43 Kkey/s][total 15166208][Prob 0.1%][50% in 9.1h]

Using the -i option drastically decreases generation time. vanitygen.exe -i 1david produced the following results in just a few seconds:

Difficulty: 36384905
Pattern: 1david
Address: 1DAVid3iW7XhDBzdoj8FbnaSaqWCjeTgUP
Privkey: 5JvtXtpUbwbNNqRoQjF3w2nyXHhphJk6LX1pWkPYEkBr4nnnBeL

The -r option allows the specification of a regex value instead of the default pattern option. If, for example, I demanded that my address contain all lowercase letters but I don't care if the "D" in "David" is uppercase or not, I could use vanitygen.exe -r 1[Dd]avid. One downside to specifying a regex prefix is that you will not be given any estimated time or probability data since such calculations are not as trivial as matching a simple prefix.

The more specific your matching criteria (and the longer the pattern) the longer it will take to generate your address(es). This can be sped up considerably if you have an ATI/AMD video card since there is also an OpenCL version of VanityGen which can try millions of keys per second on a decent GPU.


Is it possible to track stolen Bitcoin after exchange I don't know if someone can help me but I found out someone has stolen several times some crypto of me, mostly bitcoins. He had access to my computer and my phone to do the Google Authenticator because he is my IT guy.
I know who it is and everything is on police investigation but they can not do much on it at this moment.
So I would like to know if there is a possibility to track my Bitcoin transfers after they have been exchanged to another crypto.
When I look on the blockchain we just see 1 transfer and after this no trace anymore.
We already know he exchanged some Bitcoins to Ethereum, but how can we track or trace this exchange?
Is there a possibility to know which Crypto Wallet Company received my stolen Bitcoins?
Thanks for your help.

There were several transfers from your wallet to the thiefs wallet(s). This would be the chance to catch the scammer:

All involved bitcoin addresses needs to be analysed to see if there are more addresses belonging with a high liklihood to the same scammer.
All outgoing transactions from each of the addresses of 1) needs to be traced if they end up in one of the millions of known exchange addresses
If there are evidences then the police should ask the exchange directly (or via help of their peers in the exchanges country) for any information about the scammer which is likely their client. This can be the id, bank account, a bitcoin withdrawal address or an altcoin withdrawal address. In the first two cases you can claim back the lost funds. In the last two cases this is the starting point for a new analysis/tracing

If someone moves bitcoin to an exchange then the follow on activities aren't visible in the blockchain anymore, then the exchanges support is needed.
To be more specific I'd need to see the bitcoin address(es) where the coins went to after leaving your wallet.


Can I ignore the blocks directory for time machine backups on OSX? After installing Bitcoin-QT I have over 40GB of files in the ~/Library/Application Support/Bitcoin. It seems that the most important file there is wallet.dat. Does it mean that I can exclude from time machine backups the ~/Library/Application Support/Bitcoin/blocks subdirectory to reduce the backup footprint? Will the bitcoin client download again those files in case of backup restoration without this subdirectory?

Yes, it is completely safe to exclude the blocks directory from your backup process.

In the event that you lose all your files and need to restore from backup, Bitcoin will download all missing blocks. This may take some time, but there is no information in that directory that is unique to you.


Trying to understand extended keys I'm slowly getting educated about how the blockchain and Bitcoin addresses work. I now understand why it is more secure to use a different Bitcoin address for every transaction you make but I'm now trying to understand how I could achieve that with something as basic as paper wallets for educational purposes.

So, I noticed most big exchanges nowadays do generate a new public address every time you want to deposit cryptocurrencies. From what I've read, this is made possible by the use of an extended key, which contains a public and private part, just like regular keys. Now, where I'm still a little bit confused is how does it work exactly for them (the exchanges) to access all the funds from all the public addresses you generated at the same time (since they do show you a total balance and you can spend that balance with what seems to be only 1 transaction). Does the private extended key give you access to spend all the funds in all the public addresses generated with that 1 private extended key?

Also, when we say addresses should never be used more than 1 time, I assume it still must be used 2 times at some point, since you add funds and then withdraw it, meaning 2 transactions total? Or do I get it completely wrong?

It is not more secure to use different adress for every bitcoin you receive, it just gonna give you more privacy since it is gonna be harder to track you.

I guess the exchange use different bitcoin account then generate different adress for them just like we could, and keep a track of all that.

I think you are just confuse about the way exchange keep your coins, once you send them your bitcoin, you do not have a bitcoin key to access the adress you send
your bitcoin to, they just have keep track of it, and if you want to withdraw your bitcoin to your cold wallet, they will use one of their wallet to send it.

And as I said it is safe to use the same adress to receive your bitcoin, but you are right in your example they gonna be 2 transactions.


Is the number of coins limited by rule or by computational infeasibility? it is well known that the upper limit of bitcoins is 21 million, which can be calculated mathematically; but from documents i have read, this is because mining a new block is defined to have diminishing returns (1 halving per 210k blocks); is this the sole factor limiting the possible number of coins? is there anything i missed in this crypto system which becomes more and more difficult over time and finally becomes computationally infeasible that is limiting the number of coins?

No it does not become computationally infeasible, 1 halving per 210.000 blocks leads to a total of 21m due to math.

Bitcoin block reward is 50 for 210.000 blocks then 25 for 210.000 blocks then 12.5 etc. So the total reward is 210.000 * (50 + 25 + 12.5 + ...). Inside the parenthesis is a geometric series which can be rewritten as 50 * (1 + 1/2 + 1/4 + ...).

Now using the formula in the link we have a = 50 and r = 1/2 and the sum of this infinate series is 100. Multiply that by 210.000 and you get 21 million bitcoins total (actually a little less than that because a bitcoin is not infinately dividable).


Bip39 tool - BIP32 Extended Private Key vs BIP32 Root Key In the bip39 mnemonic tool there is three sections :

Mnemonic : we input our words or a BIP39 seed and the tool compute for us the BIP32 Root Key
Derivation Path: there is a BIP32 Extended Private/Public Key
Derived Addresses

Questions :
1- If i want to use Electrum wallet and I have already a wallet. Which key should I have to import ? What is the difference if I import the BIP32 Root Key or if I import the BIP32 Extended Private Key ?
2- Should I use BIP44 instead of BIP32 to import my wallet in an Electrum one ?

If you want to import a wallet, you should import a BIP32 extended private key. It is often derived from mnemonics.

What is the difference if I import the BIP32 Root Key or if I import the BIP32 Extended Private Key ?

The terminology is a bit confusing. The BIP32 derivation is done using a number, called the chaincode, over a private key (called the master private key). This private key has nothing special: it's just the starting point of the derivation.
The concatenation of a private key and the chaincode is called an extended key.
To import your wallet you need to import the master extended private key.
Regarding your question about BIP44, it is not a replacement to BIP32 just a set of recommendations of how to use it.
NB: you might be interested in the description of the key derivation process by the bitcoin.org documentation.


How do you publish a transaction which is cancelled if not claimed by a given time? How do you publish a transaction which is cancelled if some output is not claimed by a given time? (ie returning all the spent coins to their inputs or else creating new conditions under which they can be claimed)

Is this possible?

Using the blockchain you can't. If the transaction is in the blockchain with a reasonable number of confirmations it cannot be cancelled nor reversed. In that case only the owner of the recipient wallet can spend the balance. If for any reason the private key of that address is lost, the balance is irreversibly lost.

To reverse the transaction in the manner that you describe you would need to use some off-chain transaction method.


What languages can I write plugins for c-lightning in? I know that there's a Python library available for writing plugins for c-lightning. What would I need to do to for example use a JVM language like Scala?

Plugins can be written in any language as long as a client library for that language exists.

The command line API and the Plugins communicate with lightningd over a unix domain socket using JSON RPC 2.0.

As far as I know no Java / Scala lib exists. I have started creating one at this pull request: https://github.com/ElementsProject/lightning/pull/2223

also it makes sense to look at the python plugin lib to see how the format of the JSON RPC 2.0 is used. Check out: https://github.com/ElementsProject/lightning/blob/master/contrib/pylightning/lightning/plugin.py which is really just a client lib talking to the UNIX Domain socket and parsing / dispatching the JSON RPC responses. So as soon as you create this in Java / Scala you should be able to create as many plugins as you wish. You could build upon my pull request (though I have started with the client library for the standard API)


Storing bitcoins without a wallet using only a seed phrase Presently I have some BTC in a custodial wallet which I want to transfer out. I don't want a use a wallet at all. Neither hardware nor software.
If I install Electrum on a live Ubuntu session, create a wallet, transfer BTC to it, note down the seed phrase and terminate the live session, will I still be able to recover my wallet with coins several years from now?
What are the downsides of this method over a cold storage wallet?

Essentially what you are proposing would be a cold storage if you install electrum via usb stick and not connecting your computer to the internet. What is really important that you note down not only the seed but also the derivation path to your HD wallet. This is necessary for recovering the coins years from now. There is a good side where you can check:enter link description here


Generate Unique address for each users? I have PHP Based Web Bitcoin Wallet on localhost. I use simple Login system and basic bitcoin Json-RPC.
In fact, everything is runing clearly, but my Bitcoin daemon giving same Bitcoin address to all users.

I want, Unique bitcoin address for every user? How?

The JSON-RPC has a method called getnewaddress that will generate a new private-/public-keypair and return it to the caller. You can use this to generate a new address for each user. In order to track the balances of users I'd suggest grouping a user's addresses in an account associated with the user by calling getaccountaddress with the user ID or the username. You can then use the getbalance <user> call to check its current balance. However, there are some caveats when grouping addresses with accounts.


A cheap LNB for Blockstream satellite? Has anyone here built their own setup for connecting with the Blockstream satellite network?

I'm still looking for a cheap low-noise block downconverter.

  PLL LNB (linear polarization) w/ < = 200kHz LO stability

The ones I can find range from $100 -> $200..

Seems like 200kHz is not required, broader ranges are acceptable.
"L.O. Accuracy & Stability Within +/-1.5MHz" seems to do the trick and they are considerably cheaper (~15$).

Grubles has written up a guide for how to set up a blockstream satellite node: https://medium.com/@notgrubles/building-your-own-bitcoin-satellite-node-6061d3c93e7. That should be helpful; it includes links to amazon where you can buy all of the materials required.


Wallet validation methods (centralized, SPV, etc.) - please clarify for Ledger and in general 1) ledger: https://bitcoin.org/en/wallets/hardware/ledgernanos/

  Variable validation - Payment validation features are provided by the software wallet you use with this device.

2) wasabi: https://bitcoin.org/en/wallets/desktop/windows/wasabi/

  Centralized validation - This wallet relies on a centralized service by default. This means a third party must be trusted to not hide or simulate payments.

3)  Simplified validation (SPV) - This wallet uses SPV and random servers from a list.

Community, above linked definitions for wallet validation types is taken from the popular bitcoin website. I can understand every type, but the first one called "Variable validation" of Ledger.

Question: Is this technically correct to define Ledger's validation method like bitcoin.org defines it above?
If not, what is from your knowledge Ledger's validation method?

And If yes, I do not understand their definition. Can you explain from technical/censorship standpoint, what it means?  How is Ledger using servers for validation, is it their own servers or what is the difference to a centralized validation method?

Thanks

The answer is simple: Ledger is not a wallet, it's a device to improve the security of a wallet. Everything depends on what wallet you use it with.

It's a hardware signing device. They're often called "hardware wallets", but that is a misleading name. It does not manage your money, or send or receive transactions. It's simply a secure, offline, device to hold your private keys, and sign transactions provided to it.

As such, it's really just a way to improve the security of an actual wallet, which it is used in conjunction with.
Ledger has their own, but several more common software wallets (e.g. Electrum, Green, Bitcoin Core through the HWI toolset, ...) can use Ledgers as a signing device. The security and privacy tradeoffs you get depend on the software you use it with.


What distinguishes a miner from another? So I've been recently studying about Bitcoin and had few questions:

1) What distinguishes a miner from another miner? Is there any proof that two miners are not the same person?

2) What can we say are the transactions accepted by a miner? Is it all transactions in the blocks after itself, that have been added to the miner's blockchain branch?

3) In any case, what's the proof that a transaction has been accepted by any miner?

Thanks!

You can't find out whether 2 blocks have been mined by the same entity (e.g. person) for sure. Guessing is possible. If you go to http://blockchain.info, you'll see a "Relayed By" column in the table right on the start page. You can be reasonably sure that that mining pool mined the block. Some mining pools always send their money to the same address. In that case, you can be even more sure that all the blocks whose coinbase transaction went to that address have been mined by the same entity because else they'd be giving a lot of money to a different entity.

The proof that a transaction has been incorporated into the blockchain is that there is a valid blockchain which contains a block which contains that transaction. You can't simply take a blockchain and swap a transaction in it out for a different one because that'd make the blockchain invalid as the hashes wouldn't check out.

Furthermore, if you want to be entirely certain that the transaction isn't just in any blockchain but also in the longest one, you need to be connected to the Bitcoin network so you know the longest blockchain. The longest one is the one which counts.


What is the variable in a block that holds hash of found PoW? Can anyone please tell me, which variable holds the hash of the solution of block's PoW in broadcasted block?
I know that a block consists of (I am pretty sure I am forgetting some variables here):

Magic no
Block size
Transactions (raw)
Transactions counter
Block header

version
hash of previous block
timestamp
bits
nnonce
hash(MerkleRoot)

So basically, my question is which variable holds the hash of solution of current block's PoW?
Thanks in advance.

It is not stored. The proof of work is in the fact that the hash of your generated block should be of a certain form. It does not make sense to store it either, because you cannot trust it to be the real hash of the block and thus should be calculated anyway.


how many miners approve a block; before it gets added to the block? Is it 51%? I read a lot of material regarding this and didn't get much clue.
Easy explanatory, non-technical answer please. Please!

If a miner solves the puzzle and pushes the block ahead.

The rest miners checks whether the puzzle solved by the miner who claimed to solve is correct or not. Then how many miners approve to it; before it gets added to the block?
Is it 51%?
Suppose a wrong entry gets there in the public ledger. Won't it affect the credibility of bitcoin? How it gets rectified? How a wrong transaction is rectified?
I also read somewhere that each block contains the information about previous block. So after 6 blocks is added to the block-chain; it is surely confirmed that the last 6th block is fully a valid transaction.
The miner gets the reward of 12.5 bitcoin. He adds this transaction to himself to the block?

Who mines this 12.5 bitcoins for him? Does it comes from bit-coin treasury?
Does someone mines it for the miner voluntarily?

The rest miners checks whether the puzzle solved by the miner who claimed to solve is correct or not. Then how many miners approve to it; before it gets added to the block? Is it 51%?

No. The miner creates the block himself. There isn't actually a puzzle that the miner solves; he just does a specific mathematical formula (called a hash function) over and over again, slightly changing the inputs to that formula, until he gets a result from that formula (known as the hash) that is less than a specific target value. The target value is a value that is deterministically calculated from all previous blocks; i.e. given the same blockchain, you will always calculate the same target value for a given block.

There is no approval process or anything like that. What happens is that the miner will just broadcast the block to everyone, and everyone individually decides if they want to accept the block or not. This decision is based upon whether the block meets the consensus rules built into the software powering people's nodes. Other miners will also receive the block and decide whether they will accept the block or not. If they accept the block, then they will begin mining another block on top of it.

Blocks get added to the blockchain when nodes accept the block and add it to their local blockchain. There actually isn't anything that is "the blockchain", rather it is just that all nodes who are following the same consensus rules will accept and reject the same blocks so all nodes using those consensus rules will have the same blockchain.

  Suppose a wrong entry gets there in the public ledger. Won't it affect the credibility of bitcoin? How it gets rectified? How a wrong transaction is rectified?

Blocks are not the "final say" of what is valid or not. If a block is invalid in any way (invalid block header, too large, contains an invalid transaction, etc.), everyone who is following the consensus rules that make the block invalid will reject that block and refuse to add it to their local blockchain. Thus those who are following the same consensus rules will still be using the same blockchain. Other miners will be doing the same thing and they will not mine more blocks on top of that invalid block. It isn't possible for a "wrong transaction" to be included in the blockchain because that would make the block that included it invalid to everyone using Bitcoin's consensus rules and thus the block is not part of Bitcoin's blockchain.

  I also read somewhere that each block contains the information about previous block. So after 6 blocks is added to the block-chain; it is surely confirmed that the last 6th block is fully a valid transaction.

No. Blocks do not determine the validity of a transaction. If a block contains an invalid transaction or is invalid in any way, those nodes following the consensus rules that make the block invalid will reject the block under all circumstances. They will never accept the block even if the block has more blocks mined on top of it.

  The miner gets the reward of 12.5 bitcoin. He adds this transaction to himself to the block?

The miner creates a transaction which pays himself 12.5 BTC plus transaction fees. The 12.5 BTC (the block subsidy) is created out of nothing; there is no issuer, there is no treasury.


Unable to connect to Litecoin Testnet with Litecoin Core on Mac I've downloaded the LiteCoin Core for the Mac (High Sierra 10.13.3) in order to use the testnet for testing an online shopping cart. I'm not looking to mine any coins, just use the wallet. The application loads up correctly when connecting to the normal wallet, but when I add testnet=1 to the litecoin.conf, it won't connect to the peers. When I look at the debug log, I see

2018-03-01 14:37:02 connect() to 104.236.211.206:19335 failed after select(): Connection refused (61)
2018-03-01 14:37:03 connect() to 173.209.44.34:19335 failed after select(): Connection refused (61)
2018-03-01 14:37:03 connect() to 173.209.44.34:19335 failed after select(): Connection refused (61)
2018-03-01 14:37:04 connect() to 66.178.182.35:19335 failed after select(): Connection refused (61)
2018-03-01 14:37:04 connect() to 66.178.182.35:19335 failed after select(): Connection refused (61)
2018-03-01 14:37:05 connect() to 173.209.44.34:19335 failed after select(): Connection refused (61)

I've tried adding an RPC user/pass, but still no go. Error 61 seems to relate to the service not running on the port on the destination machine. I'm in an office environment, so cannot make any network changes. Is there anything I'm missing?

Here is my current litecoin.conf

rpcuser=litecoinrpc
rpcpassword=mypasswordhere
testnet=1

One possibility is you are using an older version of litecoind which is trying to get testnet3 instead of testnet4.

If this is the case, updating to the latest version should solve it.

See Reset Testnet section at https://blog.litecoin.org/litecoin-core-v0-14-2-release-ab6d2217405f


Trade Execution v.s. Trade Execution Update Using the Bitfinex WebSocket API I am subscribing to trades.

The data I receive looks like this:

  chanId  msgType tradeID   Timestamp      Amount     Price
[ 139260, 'te', [ 73962571, 1507383025000, 97.628437, 0.503 ] ]
[ 139260, 'tu', [ 73962571, 1507383025000, 97.628437, 0.503 ] ]

te = Trade Execution

tu = Trade Execution Update

As stated by the Abbreviations Glossary

What I do not understand is that for the same tradeId I first get a te message and then a moment later a tu message. There is no difference in content of these messages, so what is the purpose of the tu message?

What is the difference between a Trade Execution and a Trade Execution Update?

The documentation of the authenticated side of the API from where these orders are created states the following:

  After a te message you receive shortly a tu message that contains
  the real trade id (TRD_ID) and additional/updated fields.

These updated fields are for example fees that are charged afterwards.

Although from the public side of the API this real trade ID is already known and fees are irrelevant. Therefore, the data of the te-message is identical to the tu-message.

So, it seems tu-messages can be ignored.

+

Bitfinex now has it explained at their Bitfinex API module for Node.JS.
https://github.com/bitfinexcom/bitfinex-api-node

How do te and tu messages differ?

A te packet is sent first to the client immediately after a trade has been matched & executed, followed by a tu message once it has completed processing. During times of high load, the tu message may be noticably delayed, and as such only the te message should be used for a realtime feed.


Why does Blockchain (the company) open source their code but not license it? I'm very curious as to why Blockchain (the company) doesn't license their open source software. Also, does this mean we (the public) can just use their software and license it using Apache's 2.0 license?

David

If they haven't put a license, it means it is "All rights reserved" You can refer to these questions about it:

https://stackoverflow.com/questions/4007674/whats-the-default-license-of-code-published-at-github

https://softwareengineering.stackexchange.com/questions/148146/open-source-code-with-no-license-can-i-fork-it

https://opensource.stackexchange.com/questions/1720/what-can-i-assume-if-a-publicly-published-project-has-no-license

It probably means "You can use it for yourself, and for small projects. However, if we want, we may shut down all your projects containing our code."


How do I use Stellar API to power my Universal Trading and Multicurrency Payment+Transacton Gateway? I am planning to build on top of Stellar a unified universal gateway+trading platform(all frequencies) for banks and financial institutions to power ultrafast international payment transfers in fiat/crypto currencies, automated equity and forex trading as well as interbank transactions involving trade financing instruments e.g. Conditional Lines of Credit, LCs and Bank Guarantees. I plan to write its low-latency backend in C++ and frontend will comprise of a PID server in combination with a web/JavaScript site as GUI.

The PID server monitors the PID’s of the strategies/transactions running on the server and executes the commands as they come. The server could consist of a webserver listening on port 8888 with a simple JSON interface, to make it super flexible.

How do I use Stellar API to accomplish my goal?

I'd start by reading the concepts here so you know what stellar will do for you vs what you have to do on your own: https://www.stellar.org/developers/learn/
It also has the API documentation.


Parsing a SegWit transaction - what is the size of witness data? I'm parsing s SegWit transaction, I got it done until i reach the witness data.
How big is the witness data?

I found it:

Each witness field starts with a compactSize integer to indicate the number of stack items for the corresponding txin. It is then followed by witness stack item(s) for the corresponding txin, if any.

Each witness stack item starts with a compactSize integer to indicate the number of bytes of the item.

If a txin is not associated with any witness data, its corresponding witness field is an exact 0x00, indicating that the number of witness stack items is zero.

for each input {
    stackItems = read integer
    if stackItems > 0 {
        for each stackItem {
            bytes = read integer
            //witness data is bytes long
        }
    }
}


Why are hashes in the bitcoin protocol typically computed twice (double computed)? According to the wiki specification of the bitcoin protocol, hashes are typically "computed twice". For example:

hello
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 (first round of sha-256)
9595c9df90075148eb06860365df33584b75bff782a510c6cd4883a419833d50 (second round of sha-256)

What is the reasoning for this? I imagine it somehow provides additional security, or protection against potential attack vectors, but I can't reason what those attacks might be.

We don't know for sure, but the most popular theory is that a double hash was chosen to protect against length extension attacks.


How get raw block data? I can use getblock json rpc method to get parsed block, but I need raw data.
Is there any way to get raw block data using bitcoin core?

There's a boolean parameter to that RPC call that'll return it as a hex string representing the binary contents of the block.

  If verbosity is 0, returns a string that is serialized, hex-encoded data for block 'hash'

getblock 'hash' 0 should return what you want.


PlexCard Visa : Would it be legal all around the world? Recently, Plexcoin is to come up in the market with very promising future. Directly, citing from their website, the features include

In comparison to Bitcoin (45 minutes), the transactions (deposit, withdrawal, purchase, sale, transfer) of PlexCoin are confirmed faster (30 seconds) and they have increased storage efficiency.

and

With PlexCoin, you will be able to undertake regular transactions and spend money with your PlexCard VISA© anywhere around the world. You will also have the option to send or receive funds from anyone, in a totally private way.

Will the VISA card be legally accepted around the world ?

and

How can they achieve(claim) to have such fast transaction confirmation time ?

VISA and MasterCard cards are issued by banks all over the world, that have a valid license. It's not the first time we see cryptocurrency based VISA card. Those cards can be used in every shop (online or physical) that accepts VISA cards.

If this PlexCard VISA card is issued by a bank that has a valid license to issue VISA cards, then the card will be legally accepted wherever VISA cards are accepted.

As for the second question (fast transaction confirmation time), I don't know about PlexCoin but there are other coins with near instant confirmation times, that are using techniques like faster block time and/or MasterNodes.


Is lightning network censorship resistant? I know this is a hot topic at the moment, and I really don't want to create some kind of debate here, i'm just interested in if this question is adressed. Any other place where I have spent time, it's impossible to get any good objective answer to this question because of all the politics. Stackexchange, you are my last hope.

As far as I can understand, the common expectation is that lightning network will be a distributed, but not decentralized. If one or more countries started saying to nodes that shovel a lot of bitcoin: "We consider you banks now and you cannot participate in a payment-routing unless you have Know Your Customer/Ante Money Laundering compliance on all participants in the chain, effectively splitting the lightning network into a legal and an illegal part, does the lightning network have any kind of protection against this?

this is a bit of an old question I assume you've found the answer by now, but I'll answer it so others can benefit.

the short answer is yes the lightning network is censorship resistant.

although naturally some nodes will be more connected and therefor more traffic will go through them, but there is no necessary nodes there will usually be alternate paths between 2 nodes so if a node refuses to let a payment go through the payment will just go through a different path.

more importantly the Lightning network uses onion routing which means each node will only know the node that was before it and the node that came after it, therefore they can't discriminate based on who is the sender or receiver of the transaction.

BOLT #4: Onion Routing Protocol:
https://github.com/lightningnetwork/lightning-rfc/blob/master/04-onion-routing.md


getrawtransaction method in details Referring to https://en.bitcoin.it/wiki/Raw_Transactions,
I`m using getrawtrasaction method call to define as much information about incoming payment transaction details as possibe. Is there any detailed information about fields that are returned by getrawtransaction method?
For example what means "vout" field? How can be useful "scriptSig" field that consists of "asm" and "hex"?

A bitcoin transaction takes a number of inputs and spends those input to the specified outputs. If the value of inputs exceeds outputs the network treats that as a miner's fee.

vout is the list of output transactions.

scriptSig is only useful if you're trying to do some non-standard stuff.

See https://en.bitcoin.it/wiki/Transactions for more information on what's in a transaction.


How can I sign an Ardor transaction using an offline computer? I would like to generate the transaction json on an online computer. Send it to the offline computer without blockchain, sign it. Send the signed json to an online computer and broadcast it.

On the offline computer use the sign.bat / sign.sh script:

Usage: SignTransactionJSON <unsigned transaction json file> <signed transaction json file>


Why explorers show difference balance for genesis block? When I check balance for the address 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa - different sources show different results.

66.92700504 BTC

https://bitref.com/1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
https://www.blockchain.com/btc/address/1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa

16.91700504 BTC

https://insight.bitpay.com/address/1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
https://blockstream.info/address/1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa

and many others who don't sum two transactions:

for 50 BTC https://www.blockchain.com/btc/tx/4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b?show_adv=true

and 0.1 BTC https://www.blockchain.com/btc/tx/3387418aaddb4927209c5032f515aa442a6587d6e54677f08a03b8fa7789e688

why?

In order to explain this, you'll need to understand that on a technical level, a bitcoin does not exist as a 'balance at some address', instead the system uses 'unspent transaction outputs' (UTXOs). See this question for more info.

The reason it is especially relevant to understand this, is that due to an apparent bug in the bitcoin codebase, there is no UTXO for the genesis block reward, which means the genesis block reward is un-spendable.

So with that in mind, we can look at each of the examples you listed.

  66.92700504 BTC

  https://bitref.com/1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa >https://www.blockchain.com/btc/address/1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa

These block explorers are listing the balance of the address that the genesis block coinbase transaction pays out to, and including the 50 BTC block reward in their report.

  16.91700504 BTC

  https://insight.bitpay.com/address/1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa >https://blockstream.info/address/1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa

These block explorers are apparently only listing UTXOs that exist and are spendable. The block reward is not spendable, so it has not been included in the sum.

66.92700504 BTC - 50 BTC = 16.91700504 BTC

  and many others who don't sum two transactions:

  for 50 BTC >https://www.blockchain.com/btc/tx/4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b?show_adv=true

  and 0.1 BTC >https://www.blockchain.com/btc/tx/3387418aaddb4927209c5032f515aa442a6587d6e54677f08a03b8fa7789e688

These two URLs link to specific transactions, not to the address itself. The first is the coinbase transaction (though as mentioned above, there is no valid UTXO for this), and the second is a transaction creating a 0.1 BTC UTXO that is spendable by the owner of the 1A1zP1eP... private key.


What does a merchant need to do to reject RBF transactions I understand replace-by-fee transactions are no threat to merchants who require multiple confirmations. However many businesses still accept 0 confirmation transactions as a means of improving usability and help with marketing. I expect demand for 0 confirmation transactions to continue (at least for transactions with a value below a certain economic threshold). What is the easiest way to automatically reject all RBF transactions?

Replace-by-fee (RBF) transactions all have a sequence number that is below MAX - 1.  If the payment a merchant receives comes from a transaction that has such a sequence number, the merchant can either wait for the transaction to be included in a block, or ignore the payment altogether.  Ignoring the payment is fraught with other complications, however, since the bitcoin will still go to the merchant if included in a block.  The customer would have to replace the transaction, using RBF, before it is mined.  It's probably easier for most merchants to simply wait for the first confirmation.


How does mining work I have a basic question on mining.  How does it work?

For example, if I use my computer to mine coins such as litecoins, do those coins go straight into my offline wallet?  Or must I be connected to some online centralised pooling service, which holds to coins until I transfer them to my offline wallet?

You will most likely be using a mining pool, in which case the coin you earn will remain on your pool account until you choose to withdraw it to your local wallet. Most pools support auto-withdrawals (i.e. when the balance reaches a certain threshold).


p2sh execution timing info help I'm a newbie and trying to grasp some concepts that are challenging.

In the case of a p2sh transaction - when is the transaction executed?
I grasp that these transactions give the receiver control of the terms of sending - but what I want to know is if the sender - when initiating the transaction - submits this data to the block and if so does that mean that p2sh transactions are mined twice? Initially from sender to '3' prefaced address and then once again from '3' prefaced address to the receiver..?
Any info is appreciated.
Regards,

Not sure why this question was down voted, some explanation would have helped...

In general: A p2sh tx sends data to a hash. The hash is a one way function, so we cannot know, what content is behind the hash... also there is no double mining or similar. There is a funding tx, and a spending tx. Like with any other tx, you mine a first tx from someone else to my account, and if I spend the tx, another tx is created and mined. Same applies to p2sh transactions.

The funding tx is created, defining a condition for spending the funds (e.g. multisig, with a “type3” address), and post this tx to the network. Everyone can see the tx, but nobody knows, what’s inside (privacy gain). If then one day these funds get spent, the content of the hash is made visible, and only then one can see, what the original funding tx was about.

Advantage beside privacy: the funding of the tx is fairly cheap on fees, cause you have a short tx with several bytes. The spending tx however, reveals the hash contents, and if multisig, can be very long (increasing tx size and thus fee costs).

I found the best explanation for this in Andreas book “Mastering Bitcoin”, which is also available online.


How do you get "the raw bytes for the genesis transaction"? This post

How to retrieve the from and to wallet addresses of a transaction?

contains code by Nick ODell which refers to a file called 'genesis.bin' which contains "the raw bytes for the genesis transaction". I wonder if anyone knows how to retrieve that data?


is it possible to retrieve some block transactions using bitcoin-core? I'm trying to fetch specific block transactions, is it possible to do so using bitcoin-core?

for example block number: 517716 can I get hex transactions or even just the txid's of that block?

Yes. Use the getblockhash and getblock commands. You would do:

getblockhash 517716

and this will return you the block hash for block 517716. Then you can do

getblock <hash> 2

where <hash> is the hash from getblockhash. This will give you the full block details with the full details of all of the transactions in the block. If you just want txids, change the 2 to a 1.

Note that this only works if you are not in pruned mode. If you are pruning, there is no guarantee that you still have the block.