My guess is that Satoshi did not know about the internals of ECDSA signatures, and simply used what OpenSSL gave him.

If it didn't require a hard forking change (requiring every wallet and verifying node on the network to upgrade), we'd have changed it long ago.


Is routing approach of Bitcoin Lighning Network "decentralized" and "trust-less"?

Is routing decentralized and trustless:

Generally, yes. It uses sphinx onion-routing to prevent any peer along the way to know origin/destination of payment.

Also note that Information of channel balances can leak if routing attempts are used to probe liquidity along a route.

Routing is not robust against sybil attacks, as compromised nodes can determine routes by reconstructing path via payment_hash in the htlc output scripts.

It is, however, incumbent upon the channel operator to ensure the lightning implementation is always synced with a full-node. Only this way can it detect a cheating channel counter-party and broadcast a penalty transaction. Watchtowers may provide vigilance as a service but they are not trustless

Also, note that the lightning network is a separate p2p network.

Discovering topology occurs with peers gossiping.


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

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

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

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

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


litecoin transaction time without transaction fee

You may find the solutions offered here to be of help:

http://bitcoin.stackexchange.com/questions/23012/btc-stuck-with-zero-confirmations

see also:

https://code.google.com/p/bitcoin-wallet/wiki/UnstickLowFeeTransactions


Using importaddress you can sync your balance for watch only address with rescan set to true:

importaddress "address" ( "label" rescan p2sh )

Adds a script (in hex) or address that can be watched as if it were in your wallet but cannot be used to spend. Requires a new wallet backup.

Arguments:
1. "script"           (string, required) The hex-encoded script (or address)
2. "label"            (string, optional, default="") An optional label
3. rescan               (boolean, optional, default=true) Rescan the wallet for transactions
4. p2sh                 (boolean, optional, default=false) Add the P2SH version of the script as well

Note: This call can take minutes to complete if rescan is true, during that time, other rpc calls
may report that the imported address exists but related transactions are still missing, leading to temporarily incorrect/bogus balances and unspent outputs until rescan completes.
If you have the full public key, you should call importpubkey instead of this.

Note: If you import a non-standard raw script in hex form, outputs sending to it will be treated
as change, and not show up in many RPCs.

Examples:

Import a script with rescan
> bitcoin-cli importaddress "myscript"

Import using a label without rescan
> bitcoin-cli importaddress "myscript" "testing" false

As a JSON-RPC call
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "importaddress", "params": ["myscript", "testing", false] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/


Getting transaction id from raw transaction of a multisig address

How am I suppose to get the txid of this transaction?

The same way you get the txid of any other transaction, by hashing it (unless it is segwit). Note that the transaction you linked to is not a segwit transaction, so you can just take its hash.

If the transaction is a segwit transaction (as indicated by the marker and flag bytes of 0x0001 following the version bytes), then you need to only hash the parts that are non-segwit. Specifically, you drop all of the segwit parts (so the marker and flag and any witnesses which can be found between the last output and the locktime), and hash what is left. This is described in BIP 144.

  And how is it different from a regular (without multisig) one?

There isn't.


Can I buy a Bitcoin from one exchange and sell it on another?

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

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


Could an algorithm be made ASIC-resistant by simply adding deterministic permutations depending on the hash of the previous block and the nonce?

Your solution will least at most a year until dynamically reconfigurable FPGAs appears in the market. Then creating any logic circuit on the fly will be possible, and so efficient FPGAs will outperform CPUs by a large margin.

See for example: http://en.wikipedia.org/wiki/Partial_re-configuration


What happens if a miner confirms their own double spend?

Every single Bitcoin node in the network will reject and ignore the block as invalid if there is a double spend in it. The block won't even spread very far, because the peers that first receive it will ban the miner who sent it and not forward on the block to any other nodes.

It is not a big disruption as the check for this is fast. Other mining pools don't need to "remine" it , they'll just recognize the submitted block as invalid, and keep working on their own block.


Which Bitcoin developers are referred to as saying that "users have no say in the system's core development"

You misunderstand what the developers are saying. They are not saying that they object to pubic scrutiny and participation. They are saying that being a user of Bitcoin does not somehow specially qualify you to comment on the design or implementation of the Bitcoin system.


Private keys importing in format got by dumpprivkey

I'm not familiar with Peerunity but here is how things work in bitcoin-qt, which is probably similar unless Peerunity changed something.

importprivkey accepts exactly the same format output by dumpprivkey.  The dumped private key is not encrypted in any way (if the walled was encrypted, you had to give the passphrase before dumping so that it could be decrypted).

The most likely explanation is that you wrote down the key incorrectly.  Private keys usually include a checksum so that errors can be detected immediately, and that seems to be what is failing here.  It shouldn't matter that the wallet is out of sync; importing a key doesn't need access to the network (though you will need to sync with the network to get an up-to-date balance).

If you made a mistake when writing down the key, you may be able to do something similar to the approach in the question Can you help me fix this address? to try changing a few characters at a time in hopes of recovering the correct key.


How come that there can be many transfers in a single Bitcoin transaction?

Ethereum is an account based system. It relies on the sender specifying the sequence of transactions to prevent double spending. The balance is associated with an address and when you spend from that address, you can specify what portion of the balance should be spend.

Bitcoin is not an account based system, but structured around transaction outputs. Double spending is prevented by making each transaction output only spendable once. Thusly, transaction outputs have to be spent in full when used. This has advantages and disadvantages: For example this allows funds to be easily mixed from multiple addresses, even if they are controlled by different parties. Also, transactions don't block each other when one is delayed, other than in the account-based model. However, it's unlikely to have the a matching spendable amount to what you're trying to send.
Bitcoin therefore allows many inputs and outputs, where inputs reference existing unspent transaction outputs that will be consumed and outputs specify who can spend the money next. In practice the count of inputs and outputs is only limited by the transaction size which above 100,000B becomes non-standard.


In which cases do transactions have multiple "from-account" but a single "to-account"?

First, if there is more than one 'From' address in a transaction, all of them necessarily have to be controlled by the same entity as each private key is required to sign the transaction.

Therefore, I see a few possibilities:

Somebody is consolidating a lot of small sums from different addresses to a single address owned by himself. This could be for example an Exchange moving deposits to cold storage, or a merchant preparing to pay his wholesale dealer. Alternatively, somebody needs to prove ownership of a discussed amount and moves everything to one address in order to sign a message proofing his wealth.
Somebody wants to pay a large sum, but doesn't have a single address that contains the full amount, so they source the payment from many smaller amounts.
Somebody is withdrawing a larger sum from an Exchange, Gambling Site or Online Wallet Service that hadn't been deposited in bulk.


which cloud backup files do I need to keep

I think you want to take a look at the Backups help page on multibit.org.

I can't say for certain (as the wording is a tiny bit vague here), but I am pretty sure that each of these are what they're referring to as "rolling backups" which "encrypt a snapshot of the current wallet".

If that's true, then each one of these contains the previous ones, so you would only need to keep the most recent one.

Either way, if MultiBit is doing it's job right (and I suspect it is), your seed phrase (what MB calls "wallet words") should be enough to recover your wallet no matter what. To quote them, "You can always recover your bitcoin through your wallet words (seed phrase)."


Can I use blockfilterindex in pruned mode?

The block filter index is build asynchronously from block downloading and validation. It is possible that the thread handing block storage and pruning could be enough ahead of the thread building the block filter index that it starts to delete blocks before the index thread processes them. This would be bad. So for the initial block filter index implementation, it was decided to simply disallow pruning when the block filter index is enabled. You can read some of the reasoning and discussion in the PR.
In theory it is possible to allow pruning with the block filter index. However it is more work to do this and at least for the initial implementation, the extra code wasn't worth it. PR authors often do this to keep the PR small enough to be reviewed. This functionality could be added in the future as it is part of the more general problem of how we should handle pruning with the wallet and with the txindex.


Bitcoin uses its own wire protocol, which is based on TCP. It's quite simple, with each packet type having strict rules for conformity and a checksum. New objects (transactions and blocks) are flooded through the network to all peers with a flag indicating they want that information, along with auxiliary messages like peer addresses and pings. No encryption is used for any connection.

https://bitcoin.org/en/developer-reference#p2p-network


Update orders are exclusive to Websocket APIs in version 2, so you have to either use them or use v1 rest APIs which is not recommended.


How do network nodes "connect" - amateur level

I have no idea what a "network" really is. I googled and read about LAN/WAN. Are these the types of network we're talking about?

No. A network is really just "a group of connected things". One example is indeed a LAN network through which multiple computers that are physically close to each other (a home, an office, ...) are connected to each other. The Internet is also an example of a network - one built up of smaller and very distinct networks like LANs.
But networks can be many more things than that. The group of people you know and hang out with is considered a network too. An electrical circuit inside a machine is sometimes called a network. I bring up these examples, because the word "network" in a computer setting often evokes the mental image of physical interconnections between computers - and while that is one example, the Bitcoin network is something fundamentally different.
The Bitcoin peer-to-peer network consists of Bitcoin nodes - pieces of software, not hardware. I could be running two nodes on my own computer, and they could be connected to each other - or not; they could also both just be connected to far away nodes elsewhere in the world. In fact, these connections don't even need to be established over the Internet. There have been projects to connect Bitcoin nodes over mesh networks, and you could arguably also consider the Blockstream satellite service to be part of this network.
So bottom line, the Bitcoin network consists of pieces of software talking to each other. How they talk to each other can differ, though most commonly, it is TCP/IP connections over the public Internet or over Tor. These connections are somewhat similar to the connection your browser makes to stackexchange.com to show you this answer, but instead of it just being many clients (browsers) talking to one server (stackexchange), it is all nodes that are equal - they are peers. No servers and clients; there are just nodes, and they each connect to one or multiple other nodes. Certainly some are more powerful or better connected than others, but none have a privileged position w.r.t. other nodes.

How do these "networks" work, how are they distinct?

This is where it gets interesting. Bitcoin, and similar things, follow a trust-minimized design. At least if you run a fully-validating node (like Bitcoin Core), your node will generally not trust anything other nodes tell it. They will exchange blocks, and transactions, and other things, but whatever your node receives it will validate independently to the extent possible. This includes very strict validity rules for blocks. Your node will only accept blocks that follow the exact rules implemented in the software.
The simple answer to your question is that Bitcoin and altcoin nodes have different rules, and simply won't accept each others blocks. If a node were to be only connected to nodes with different rules, it would be isolated, and not be able to learn about new Bitcoin blocks; it needs at least one connection to an honest like-minded node. To make sure that doesn't happen, nodes will detect the situation where their peers give them blocks they consider invalid, and when that happens, more aggressively look for more nodes to connect to, and possibly disconnect existing ones if they really seem to have a different idea. In practice, this quickly teaches nodes on both sides after a fork to shun the other side.

Certainly if I download bitcoin core and start running a full node it will start connecting me to other nodes in the bitcoin network. How does that process actually go down?

Bitcoin Core specifically has a number of mechanisms that control connections:

It maintains a database (called "addrman") with IP addresses (and Tor addresses, if that's in use) of known other Bitcoin nodes, together with some statistics and whether or not it has made a connection to it. New peers to connect to are drawn from this database. At most 10 connections are made, in order not to overload the network. This database is fed new information through:

Nodes gossip IP addresses of other nodes (the  addr P2P message) to each other.
A few DNS seeds are hardcoded that can be asked for more IP addresses if needed. This is only when not enough connections can be established after some time, and typically only needed the first time the client runs. After that, nodes autonomously find more peers to connect to.
As a very last resort, if DNS querying doesn't result in decent network connections, Bitcoin Core also has a list of hardcoded IP addresses to connect to.

The user can manually specify peers to connect to, using the connect= or addnode= configuration file options, or the addnode RPC command.
Nodes can accept incoming connections from other nodes too (there is a limit on this too; by default 125 connections, and when it's full some rules will prioritize peers from others).

how would nodes connect to the network without running bitcoin core?

Other implementations have their own mechanisms, but there is a wide spectrum - all the way from just connecting to the wallet provider's server, to learning about peers and connecting to them like Bitcoin Core does.

Supposed I wanted to write some code to develop my own bitcoin client. What was that code look like?

That really depends on what you want to do. There are libraries in many languages that implement the P2P protocol that lets you talk to other nodes, or you could start from scratch just following existing protocol documentation and Bitcoin Improvement Proposals (BIPs) that affect the P2P protocol. Remember, there is no authority in Bitcoin that can tell you exactly what "the" protocol is; proposals are made, and software dedvelopers implement them or don't. You'll want to test things, by not immediately dealing with the Bitcoin mainnet, but first try on the Bitcoin testnet or the newer "signet" test network.


How do I install Bitcoin Armory in Ubuntu 17.04?

The latest Armory version is from this year, 0.96. If that is not the version you are installing, then you are using an old and outdated version. The most recent version can be found at https://btcarmory.com/0.96.0-release/. Download the one labeled "Armory 0.96.0 for Ubuntu/Debian 64-bit with GCC 5.3". To install it, you can open the terminal, cd to the directory containing the downloaded deb file, and type

sudo dpkg -i armory_0.96-gcc5.4_amd64.deb

You will also need to install Bitcoin Core, which you can get from https://bitcoin.org/en/download.


This is happening because your node thinks it is in initial block download.

There are several reasons why that might happen, but I think only two apply here.

The chain tip is more than nMaxTipAge seconds old. Try setting the -maxtipage option to a big number, and see if that fixes it.
The chain tip has less than nMinimumChainWork (from chainparams.cpp) of work put into it.

Here are the conditions that trigger initial block download:

bool IsInitialBlockDownload()
{
    const CChainParams& chainParams = Params();

    // Once this function has returned false, it must remain false.
    static std::atomic<bool> latchToFalse{false};
    // Optimization: pre-test latch before taking the lock.
    if (latchToFalse.load(std::memory_order_relaxed))
        return false;

    LOCK(cs_main);
    if (latchToFalse.load(std::memory_order_relaxed))
        return false;
    if (fImporting || fReindex)
        return true;
    if (chainActive.Tip() == NULL)
        return true;
    if (chainActive.Tip()->nChainWork < UintToArith256(chainParams.GetConsensus().nMinimumChainWork))
        return true;
    if (chainActive.Tip()->GetBlockTime() < (GetTime() - nMaxTipAge))
        return true;
    latchToFalse.store(true, std::memory_order_relaxed);
    return false;
}


Sweeping paper sweeping private keys from 2009-2010 into electrum wallet

You have to import the keys into electrum. To do that, download electrum on your PC, click on new wallet > import private key > click next and you should see all the coins.

You can do more research by using the bitcoin forum on reddit https://www.reddit.com/r/Bitcoin/


How do I still have connections without forwarding port 8333?

When your node is not accepting inbound connections (either because there's NAT in the way or because you passed -listen=0 to Bitcoin) it still makes "outbound connections." These are connections to other Bitcoin nodes that are listening on a public port. Your node makes a maximum of 8 outbound connections. (Source.)

When you make an outbound connection, your router notices that you opened the connection, and forwards any reply packets to you. See How NAT / PortForwarding / TCP/IP works? Your router does the same thing when you browse the web.


Multibit: Whats the best way to proceed if I have forgotten my password but my wallet is still open

Multibit will prompt you for a password regardless of whether you are sending it to your own wallet or not. This is by design, since if it didn't do this, it would allow anyone who can access your laptop to transfer bitcoins from your encrypted wallet by sending it to the unencrypted wallet first.

Sorry but unless you made an unencrypted backup of the wallet in the past, your coins are lost if you can't recover your password.


Can larger transactions have a lesser fee per byte than smaller ones and still get equally treated?

No. There is no unit price discount for making larger transactions. Such transactions consume similar resources to multiple transactions which sum to the same size. They consume the same amount of block space, so they will cost the same in transaction fees.


Transaction with a high fee keeps getting skipped... Reason why?

$ src/bitcoin-cli getmempoolentry ed45c837d26c25fb6a763708376a87f1875ff57efbb0f56d1b26d00a16c1899e
{
  "fees": {
    "base": 0.00012042,
    "modified": 0.00012042,
    "ancestor": 0.00125452,
    "descendant": 0.00012042
  },
  "vsize": 224,
  "weight": 896,
  "fee": 0.00012042,
  "modifiedfee": 0.00012042,
  "time": 1612178927,
  "height": 668604,
  "descendantcount": 1,
  "descendantsize": 224,
  "descendantfees": 12042,
  "ancestorcount": 2,
  "ancestorsize": 22989,
  "ancestorfees": 125452,
  "wtxid": "ed45c837d26c25fb6a763708376a87f1875ff57efbb0f56d1b26d00a16c1899e",
  "depends": [
    "fb1183fa83759c51bd33d2bad9007804ea44f8256a7ae77f36f4f35a885a05d6"
  ],
  "spentby": [
  ],
  "bip125-replaceable": false,
  "unbroadcast": false
}

Looks like your transaction depends on another unconfirmed transaction, and that transaction is large and has a low feerate.  The combined feerate of the two transactions is only around 5.45sat/vB, which presumably explains the long time to confirm.


Sure you could However it would be necessary to know how you transact with the coins...do you simply trade them out for fiat immediately?  If so, then I would create the payment as a check from the exchange for the dollar equivalent that was collected and put the transaction ID and recipient address in QB.  You should probably setup something like coinpunk or at least a full wallet server so that you can issue one time use addresses that are meant to be tied to your customer's account.  This way, it will be easier to reconcile later.  If you try to process your payments together manually into your own wallet, then I at least suggest to create a new wallet each month so that your transactions can be bundled together for ease of reconciliation purposes.

I don't think that you can add XBT as a currency yet within QB but then again I haven't used it in a couple years now.


Orderly Transition Away from ECC? Or Bitcoin to zero?

Bitcoin is a social phenomenon as much as it is a technical one. Satoshi's whitepaper laid out a technical architecture for a network, but the implementation details of that network have slowly evolved over time, they are not absolutely set in stone.
Of course, some of the implementation details are perhaps more set in stone than others (eg, good luck trying to convince bitcoin users to change the issuance schedule), but ultimately it is only the collective agreement of the network participants that upholds the 'consensus rules' (ie, the implementation details).
So, if something catastrophic were to happen, and ECDSA were broken in a way which made all coins vulnerable to theft, then I would certainly expect that bitcoin users would work to change the implementation details, so that they could form a new social agreement around using the technical tool that is the bitcoin network.
Would this be messy if it happened unexpectedly? Most certainly. Would the value of the network drop? Probably. Would it mean that the bitcoin experiment would be over? I suppose that depends on what you define as 'bitcoin'. From a "no-hardforks" perspective, perhaps bitcoin would die (ignoring the possibility of a fancy soft-fork fix). But from a "we're here to participate in a novel consensus network" perspective, it certainly is possible to fork the network to change the implementation details in order to remove the compromised code. Whether or not you're happy to participate in this new consensus is a fair question, but I doubt every single bitcoin user would just give up and pack it in.

More generally, if public key cryptography is broken, I think the world is going to have bigger problems than the bitcoin network failing to remain secure. A huge amount of the (very valuable) internet is built upon the same cryptographic primitives that bitcoin uses. In spite of this, these algorithms have apparently remained secure. Ultimately, whether or not you participate in something like bitcoin is entirely up to you. I don't think anyone here will try to convince you it is a risk-free adventure to embark upon.


where is index value or hexa value of bitcoin in source code?

https://github.com/satoshilabs/slips/blob/master/slip-0044.md

Registered coin types
These are the registered coin types for usage in level 2 of BIP44 described in chapter "Coin type".
All these constants are used as hardened derivation.

index
hexa
symbol
coin

0
0x80000000
BTC
Bitcoin

1
0x80000001

Testnet (all coins)

2
0x80000002
LTC
Litecoin

3
0x80000003
DOGE
Dogecoin

4
0x80000004
RDD
Reddcoin

5
0x80000005
DASH
Dash (ex Darkcoin)

6
0x80000006
PPC
Peercoin

...
....
....
...

99999997
0x85f5e0fd
EQ
EQ

99999998
0x85f5e0fe
FLUID
Fluid Chains

99999999
0x85f5e0ff
QKC
QuarkChain

Coin types will be added only if there is a wallet implementing BIP-0044 for desired coin.


library for validating bitcoin private and public keys

No sane application should EVER attempt to validate a private key by attempting to pass it to an external API. That's a ridiculously easy way to lose all your funds if the API operator is malicious, compromised, or someone is eavesdropping on your communication with said API.
You should do this yourself, preferably using a well tested, community supported, open source library for your choice of language - most major languages have such libraries.
If this is too much work, you should reconsider building something like this. Do not compromise on safety, especially if you intend for other people to trust this code with their funds.


Will bitcoin's value be affected by other digital currencies?

Bitcoin is a "proof-of-work" based cryptocurrency.  Proof-of-work based cryptocurrencies are protected from a malicious 51% attack because of that coin's mining network.

Bitcoin is protected by 12,500 Th/s of mining capacity (using SHA hashes).  For an attacker to come in and attempt to commit "double spend" fraud (as the result of having 51% of the mining capacity), that attacker would need to spend perhaps a hundred million dollars to acquire the necessary mining hardware.  There is no way, today, that an attacker will be able to use this tactic to earn a profit because there's simply no way to withdraw even tens of millions of dollars worth of funds from exchanges (following the attack) -- due to exchanges employing KYC/AML policies such that an attempt would fail either due to withdrawal limits, access to cold-storage, etc.

Alt coins don't have this same threshold.

So in addition to Bitcoin having first-mover advantage and the strongest "brand" (thus that's why Overstock accepts Bitcoin and not Litecoin or anything else), it has the least risk of catastrophic loss due to a malicious 51% attack.

The difference between Dogecoin and a Bitcoin is like the difference between investing in a longshot penny stock issue of a nearly bankrupt company versus buying a blue chip NYSE which continues to deliver quarter-after-quarter.

So there is certainly a substitution effect.  Many of those speculating on Litecoin would otherwise have been holding bitcoins.  But there's not an easy way to know what the value of a bitcoin would be if the $500+ million valuation of all Litecoins in circulation were to grow by several billion dollars.  Since we haven't reached "saturation", perhaps many of those speculating on Litecoin might not have held Bitcoin regardless -- and thus if that were the case the existance of Litecoin didn't affect Bitcoin's exchange rate.

There's also the situation where an altcoin happened to be the "gateway drug" that caused a person to become interested in crypto currencies but then that person later embraced Bitcoin. In that instance, the greater the traction of that type of person to an alt currency eventually results in greater traction of Bitcoin.

There's also other altcoins that are not proof-of-work based.   For instance, PPCoin is a "proof-of-stake" crypto currency.  These are not vulnerable to a 51% mining attack (though they have other vulnerabilities).  So it is possible that those PoS coins could be seen as having an equal (or lesser) risk to that of Bitcoin and thus that coin could be seen as a substitute for Bitcoin by some.

To conclude, simply alt coins are not equivalent to bitcoin and thus a dollar spent on acquiring an altcoin doesn't mean there is one dollar less spent on acquiring or holding a bitcoin.


Would I be able to recover coins if Trezor went out of business?

Yes. Trezor uses BIP39 and is compatible with any other wallet  that would. You can in fact import your seed into electrum, though this to some extent defeats the purpose of having a hardware wallet.


AFAIK there's one good wallet other than the reference client that can import the private key and make a transaction.

That's Coinomi, it can import the private key and does support BTG.

(When I wanted to dump and sell my BTG, Coinomi was great, although I needed to use the Android emulator Genymotion [because I don't have an android device])


Is it possible to set an overall seed for generating blocks on regtest mode?

Generation of blocks uses the proof of work algorithm that includes a nonce that ensures randomness, if we could somehow recreate all these things the whole system of cryptocurrency would break down. The short answer is no.


What's the best mining option if you weren't worried about power costs?

At time of writing it still possible to run a GPU farm but at the speed of the increase in difficulty this will not last for long.

The second presumption with this is that you are not paying for the hardware, its very unlikely you would even  break even if you had to purchase hardware at this time. The only real option in a competitive market is to go down the ASIC route.

Performance in a good quality ASIC can be 100 x that of a top end GPU. The price tag could realistically be about the same. There is zero comparison.


Is Z-man's PTLC construction implementable using libsecp256k1-zkp?

My question is whether this MusigTweak is what is called the adaptor (last argument of secp256k1_musig_session_combine_nonces) in secp256k1-zkp?

No, what "Z-man" refers to as MusigTweak is not called the adaptor in secp256k1-zkp. The difference between the normal MuSig ritual and the "almost entirely MuSig" ritual is not the MuSigTweak. The MuSigTweak just determines how keys are aggregated and is called secp256k1_musig_coefficient in the secp256k1-zkp implementation as of commit cad7cc8f34d17166da2dabae20188ea6e747ac69. In the MuSig paper the MuSigTweak is called a_i. The adaptor argument of secp256k1_musig_session_combine_nonces refers to t*G (where G is the base point) in Z-man's description.

  And has in fact been implemented?

Yes, almost. What Z-man is describing here is the original adaptor signature scheme. It's not well suited for multi-hop locks (aka Lightning with payment points), because the creating party must know the t when creating an adaptor signature. Therefore, the implementation in libsecp256k1-zkp uses the adaptor signature variant that was introduced in the original Lightning in Scritpless Script mailing list post and in the Anonymous Multi-Hop Locks for Blockchain Scalability and Interoperability paper. If you want to know more about the multi-hop lock protocol, I suggest to have a look at the diagram in the scriptless script repo.

libsecp256k1-zkp has a unit test for a scriptless script atomic swap using that technique.

  How is MusigTweak computed? Is it the per-hop tweaked payment point, which means it will be the payment point for the hop connecting to the payer?

The adaptor point t*G is the per-hop tweaked payment point, not the MuSigTweak.


Problem using op_checksequenceverify (op_csv) with relative time flag

i manage to find answer for myself.

OP_CSV date consensus is based on median time past (mtp), not block's confirmed date.

once funding tx above has been confirmed, it is located in block#1609592 with block MTP is 2019-11-24 09:05:26 (UTC 0). At same time, chain's MTP is 2019-11-24 09:25:27 (UTC 0)

now come to spending tx, since utxo's confirmed date i used is 2019-11-24 09:05:26, plus 512 seconds = 2019-11-24 09:13:58. Therefore i can spend immediately as chain's MTP is more than 2019-11-24 09:13:58.


Forgot to add transaction fee, any way to add it now?

You can wait it out. Both of your inputs are around 1BTC so your transaction will likely be bumped up to "high priority" status in the next 12-24 hours.


How to extract the signature of a transaction using bitcoinj

This works for P2PK, and P2PKH, but multisig will not work.

int index = (the index you want);
List<TransactionInput> inputs = Transaction.getInputs()
TransactionInput input = inputs.get(index);
Script scriptSig = input.getScriptSig();
List<ScriptChunk> signature_and_pubkey = scriptSig.getChunks();
ScriptChunk sig_chunk = signature_and_pubkey.get(0);
bytes[] sig_bytes = sig_chunk.data;

If you want a TransactionSignature object instead of raw bytes:

TransactionSignature ts = TransactionSignature.decodeFromBitcoin(sig_bytes, false)


used Sending funds address to receive bitcoins

If dumpprivkey provides no private key, then your wallet does not have it. You are not the owner of that address, and those bitcoins are not yours.


What happens if a country blocked external Bitcoin traffic?

Is their local chain just completely wiped out due to lower POW?

Yep. Lower proof of work means orphan, invalid chain.

  Would local nodes be forced to go back to the time of the fork and download international blocks?

Yes, because the chain they followed before they reconnected, has no value after the re-connection.

  All those valid transactions at the time, gone?

Yes. This is also why the 51% attack is bad. One with more hash power could

1) cash out their coins

2) publish the new, alternative chain with more PoW

3) start mining secretly again

4) repeat until the coin price decreases enough to make mining inefficient

  And roles reversed, what if this country amassed enough mining power to have more POW?

Then everyone loses money. This'll also indirectly affect Russia because of the changes in coin price.


Time/memory complexity of Bitcoin API calls

Bitcoin Core maintains a LevelDB database (a key-value database) that contains the chain status data. This data includes the block headers, the block locations on disk, the UTXO set, and a few other things.

For blocks, the chainstate database has the block hashes as the key and block headers with some extra data appended as the values. The extra data also includes the block's location in the blk*.dat files (file number and byte offset within the file for the beginning of the block). So looking calling getblock just means that the key-value pair for the block hash is taken from the LevelDB database which I believe is O(nlog(n)) (IIRC it uses some kind of tree as the backing structure). To get the block itself, the lookup is O(1) as it just has to read a specific file at a specific offset.

Very few RPC calls in Bitcoin Core actually do any sort of searching through the blockchain. Most things are either stored in a database or a reference to its location is stored in the database so the item itself can quickly be retrieved by or following a database read.


How to generate or add balance in my btc testnet address

https://xmr.to has discontinued their service so this will not work anymore: https://xmr.to/blog/job-done
This workaround involves exchanging XMR(stagenet) to BTC(testnet). Everything is free and you get XMR(stagenet) from step 2 mentioned below. Questions and answers involving altcoins are offtopic on https://bitcoin.stackexchange.com however other bitcoin testnet faucets aren't working, so it's just a workaround to solve the problem and get free testnet bitcoin in few minutes
I always use this faucet and it works for me. Tried before posting this answer and got 0.05 tBTC in this transaction: https://blockstream.info/testnet/tx/86b2ae07645d664085a52e7474dac531e9b8c5790028162a7be9383a955fea33

Go to https://test.xmr.to/ and enter bitcoin address to receive testnet coins with amount less than 0.1

Proceed to next step, copy XMR address from payment instructions, open https://community.xmr.to/faucet/stagenet/ in another tab and paste the XMR address you copied earlier.

Click "submit" and if you don't see any error, tBTC will be sent to your address in few minutes

You can also share your testnet address with the question. If this faucet doesn't work I can send you small amount for testing or maybe someone else.


Where did Bitmain get the "Antminer" name from for all their ASIC miners?

Presumably (I'm not sure, this is an educated guess) they called it an antminer because they have very many of them, all set to do a single thing and doing it well. One could compare their mining pool to an ant hive, where each mining ASIC is an individual ant, foraging for food.

This is a very common metaphor, because ants are fascinating creatures, whose actions are completely governed by very simple rules, which cause truly incredible emergent behavior. See: Ant Colony Optimization for a good example of this.


Is it possible to share blockchain data between multiple nodes?

I don't think this is possible; you'd have multiple node instances trying to read/write a single data directory. This is not the intended operation, you'd likely end up with corrupt data.

If you must run multiple independent nodes and are worried about storage requirements, I'd recommend looking into 'pruning mode', it will limit the storage requirements for each node instance.

Note that you can copy the data directory folder of a synced node, so that you will not need to run through the initial block download and sync for each individual node (lots of savings in time and computation here). Just be sure to stop bitcoind before copying the data directory, and then start it up again once the copy is complete. This will help avoid potential data corruption/loss.


If I lose my wallet and private key does that effectively remove bitcoin from the market forever?

If you permanently loose your keys, the short answer is essentially yes. Your loss, a deflation, will cause the value Bitcoin being held by others to go up proportionately.

With a 100% efficient quantum computer (not likely at all), the amount of energy required to brute force compute the private keys will cost ~$100M each in electricity (assuming 5 cents per KiloWatt-Hour) if the public keys associated with the private keys are published on the blockchain.


What can I buy with cryptocurrencies today

Dr. Lilia Etkina in Long Island City can fix your teeth or do a cleaning for a fraction of a Bitcoin.

https://www.zocdoc.com/dentist/liliya-etkina-dds-58296


What are the implications of a huge amount of unused hash power?

I grasp your question, mining becomes unprofitable so mining hardware is turned off and the difficulty reduces. Then, an attacker coerces miners to turn on their hardware in a bid to attack the network.

This would be difficult to achieve. First, you would have to identify where the mining hardware that is turned off is, identify who it is that operated it and, make contact with them. Then, you would need to convince them to go along with your attack.

As mining is largely anonymous, at best you could potentially source some of the IP's that miners are connecting through. Nothing says that the IP a miner is connecting through is their IP and even less identifies the mining operator working behind a particular IP, and still convince enough to go along with your attack to make up 51% of the hash power. This attack is infeasible.


Hacked my blockchain.info wallet, stole 760 coins

Could you be more specific on which 2 way authentication you used?
What where the exact steps so we can rebuild the scenario or at least understand what happened exactly.

If it was email by gmail consider the machines you used the blockchain.info/ gmail on as compromised. Most probably all login forms on this machines have been grabbed.


Is there a shortcut for a synchronized bitcoin core after txindex?

When enabling or disabling txindex the blocks you already have are used, they are not re-downloaded. There is no shortcut, once you start you have to wait for it to finish. The process of re-indexing throws out the state you already have and rebuilds it completely from the block files where possible.


Failed CHECK(MULTI)SIG operation - BIP143 hash pre-image

After a while of debugging, I was able to find the issue.

My previous assumption that I was committing the wrong data to the hash was correct.

The transaction ID that is needed to construct hashPrevouts and outpoint was incorrect. I needed to reverse the bytes of this value for the hash to be correct.

For example:

b9d615615976600739be12a67f326836e4256d7d1c4fe50163536ad8dd7647c3 (a searchable txid on Bitcoin testnet)

becomes...

c34776ddd86a536301e54f1c7d6d25e43668327fa612be39076076596115d6b9.

In summary, my advice would be to step through the interpreter and reevaluate your assumptions of all the data that you're committing to the hash for signing.

A little bit of code never hurts,

Typescript: Buffer.from(transactionId, "hex").reverse().toString("hex");


If you mean a ticker that is constantly up to date then yes. See here .
 As far as a way for pulling that data here is a php example: https://stackoverflow.com/questions/21021266/parsing-json-data-from-a-remote-server


What is the significance of this red light on the Bitmain S9 board?

What are you seeing on your Antminer Status page? Is two of your boards showing 0 under the GH/S(RT) column?

Because I believe the absence of the light indicates an issue.


Is there a gui to manage the bitcoind server via a browser?

Looks, like it is 50 strings php file:

https://en.bitcoin.it/wiki/PHP_developer_intro

See, https://bitcoin.stackexchange.com/questions/13849/how-do-we-talk-to-bitcoind-in-a-php-plugin

Also, read this http://www.reddit.com/r/Bitcoin/comments/1tvn12/best_way_to_programatically_receive_and_send/

For the rest, https://en.bitcoin.it/wiki/Bitcoin-python


Is Bitcoin a threat to Paypal and why one cannot buy bitcoins with PayPal?

Unlike PayPal payments, Bitcoin payments are not reversible. PayPal payments are reversible up to 60 days.

Accepting PayPal payments to pay for bitcoins exposes your service to a stolen credit card fraud and PayPal friendly fraud
The fraudulent buyer makes the payment in PayPal, then the payment is disputed few days after the buyer received the bitcoins. When the PayPal payment is disputed, the seller of bitcoin is left without 1) bitcoins 2) fiat currency payment
Because PayPal is somewhat hostile towards using their payment service for selling virtual currencies, the bitcoin seller has little or no means to combat against fraudulent payments or disputed when accepting PayPal payments
Thus, the result is that running a profitable bitcoin selling business which accepts PayPal payments is difficult, though not outright impossible. Thus, all bitcoin sellers who accept PayPal have very high risk premiums.

Bitcoin is threat to the PayPal business in the sense that PayPal is global dominating online payment solution and bitcoin could replace PayPal payments in many scenarios, like ordering items online internationally or remittance (sending money to your foreign friends).


What is expected of current mining equipment 2 years from now?

Presumably you are asking about ASIC hardware as there is no sense in acquiring more GPU or FPGA hardware at this point in time.

There are always optimizations possible, so while the work performed by the miner hardware today will most likely still be a valid method two years from now there may be new approaches that make current mining hardware either incompatible with the new method, or of too low of performance to justify continuing to use it for mining.

As far as it being profitable, that cannot be answered.   Mining hardware profitability is determined by the difficulty level at intervals over time and the exchange rates -- neither of which can be known today.

Mining is a form of speculation on the Bitcoin exchange rate.


Is it possible to read every transaction my node relays?

I was advised that an easy way to read everything my node relays would be to connect to my node and accept all the messages it relays.

So here's a basic "node" written in PHP.

<?php

// --------
// SETTINGS
// --------
$version    = 60002;
$node       = array('85.119.83.25', 8333); // node you want to connect to
$local      = array('127.0.0.1', 8333); // our ip and port

list($node_ip, $node_port) = $node;
list($local_ip, $local_port) = $local;

echo "\nNode\n----\n";
echo 'version: '.$version.PHP_EOL;
echo 'node:    '.implode($node, ':').PHP_EOL;
echo 'local:   '.implode($local, ':').PHP_EOL.PHP_EOL;

// ------------------
// 1. VERSION MESSAGE
// ------------------

// General Functions
function fieldsize($field, $bytes = 1) {
    $length = $bytes * 2;
    $result = str_pad($field, $length, '0', STR_PAD_LEFT);
    return $result;
}

function swapEndian($hex) {
    return implode('', array_reverse(str_split($hex, 2)));
}

function byteSpaces($bytes) { // add spaces between bytes
    $bytes = implode(str_split(strtoupper($bytes), 2), ' ');
    return $bytes;
}

// Version Message Functions
function timestamp($time) { // convert timestamp to network byte order
    $time = dechex($time);
    $time = fieldsize($time, 8);
    $time = swapEndian($time);
    return byteSpaces($time);
}

function networkaddress($ip, $port = '8333') { // convert ip address to network byte order
    $services = '01 00 00 00 00 00 00 00'; // 1 = NODE_NETWORK

    $ipv6_prefix = '00 00 00 00 00 00 00 00 00 00 FF FF';

    $ip = explode('.', $ip);
    $ip = array_map("dechex", $ip);
    $ip = array_map("fieldsize", $ip);
    $ip = array_map("strtoupper", $ip);
    $ip = implode($ip, ' ');

    $port = dechex($port); // for some fucking reason this is big-endian
    $port = byteSpaces($port);

    return "$services $ipv6_prefix $ip $port";
}

function checksum($string) {
    $string = hex2bin($string);
    $hash = hash('sha256', hash('sha256', $string, true));
    $checksum = substr($hash, 0, 8);
    return byteSpaces($checksum);
}

// MAKE MESSAGES

function makeMessage($payload) {

    // Header
    $magicbytes = 'F9 BE B4 D9';
    $command = '76 65 72 73 69 6F 6E 00 00 00 00 00';
    $payload_size = bytespaces(swapEndian(fieldsize(dechex(strlen($payload) / 2), 4)));
    $checksum = checksum($payload);

    $header_array = [
        'magicbytes'    => $magicbytes,
        'command'       => $command,
        'payload_size'  => $payload_size,
        'checksum'      => $checksum,
    ];

    $header = str_replace(' ', '', implode($header_array));
    echo 'Header: '; print_r($header_array);

    return $header.$payload;

}

function makeVersionPayload($version, $node_ip, $node_port, $local_ip, $local_port) {

    // settings
    $services = '01 00 00 00 00 00 00 00'; // (1 = NODE_NETORK)
    $user_agent = '00';
    $start_height = 0;

    // prepare
    $version = bytespaces(swapEndian(fieldsize(dechex($version), 4)));
    $timestamp = timestamp(time()); // 73 43 c9 57 00 00 00 00
    $recv = networkaddress($node_ip, $node_port);
    $from = networkaddress($local_ip, $local_port);
    $nonce = bytespaces(swapEndian(fieldsize(dechex(mt_rand()), 8)));
    $start_height = bytespaces(swapEndian(fieldsize(dechex($start_height), 4)));

    $version_array = [ // hexadecimal, network byte order
        'version'       => $version,        // 4 bytes (60002)
        'services'      => $services,       // 8 bytes
        'timestamp'     => $timestamp,      // 8 bytes
        'addr_recv'     => $recv,           // 26 bytes
        'addr_from'     => $from,           // 26 bytes
        'nonce'         => $nonce,          // 8 bytes
        'user_agent'    => $user_agent,     // varint
        'start_height'  => $start_height    // 4 bytes
    ];

    $version_payload = str_replace(' ', '', implode($version_array));
    echo 'Version Payload: '; print_r($version_array);

    return $version_payload;

}

// -----------------
// 2. SOCKET CONNECT
// -----------------

// Print socket error function
function error() {
    $error = socket_strerror(socket_last_error());
    return $error.PHP_EOL;
}

// i. Create Version Message (needs to be sent to node you want to connect to)
echo "Connect\n-------\n";
$payload = makeVersionPayload($version, $node_ip, $node_port, $local_ip, $local_port);
$message = makeMessage($payload);
$message_size = strlen($message) / 2; // the size of the message (in bytes) being sent

// ii. Connect to socket and send version message
$socket = socket_create(AF_INET, SOCK_STREAM, 6); // IPv4, TCP uses this type, TCP protocol
socket_connect($socket, $node_ip, $node_port);
socket_send($socket, hex2bin($message), $message_size, 0); // don't forget to send message in binary

// iii. Keep receiving data (inv messages) from the node we just connected to
echo "\nReceiving packets from $node_ip...\n\n";
while (true) {
    if (socket_recv($socket, $buffer, pow(2,10), MSG_DONTWAIT)) {
        echo bin2hex($buffer)."\n\n";
    }
}

/* Resources
    - https://en.bitcoin.it/wiki/Protocol_documentation
    - https://coinlogic.wordpress.com/2014/03/09/the-bitcoin-protocol-4-network-messages-1-version/
*/

Thanks to theymos for the advice.

How to use:

Just change the IP at the top of the node you want to connect to, and it will start receiving every message it sends back.

Warning: It's very basic and I've only just got it working, so use with caution. However, it does seem to be working.

Bonus: Here's one in Python: Making peer connection in Python


Have you read the explanation on the Bitcoin wiki directly linked from the API calls list you already linked to?

I suppose the idea could be explained as the division of your wallet into sub-wallets called accounts. You can achieve the benefits of that by explicitly keeping separate wallets (if your bitcoin client allows that).  Account issues are well explained in the wiki article I linked to. You probably do not want to use accounts as suggested there, though, for creating individual customer accounts to receive payments; see the section on account weaknesses of the same wiki article.

A hypothetical use case I could imagine would be wanting to separate your bitcoin expenses. Imagine you use your wallet for purchases relating to two different hobbies, two different donation-receiving public addresses,  and miscellaneous expenses. By creating five accounts, one for each of these, you can more easily keep track of what you spend (or receive) for each purpose, without the need to create individual wallets.


Bytecoin (BCN) bytecoin.org uses the CryptoNight algorithm and cannot be mined with bitcoin mining hardware.

Bytecoin (BTE) bytecoin.biz uses SHA-256 and it can be mined with a block erupter (and any other bitcoin mining hardware).


What is the Bitcoin address to fill in under 'Pay to'

This should be an address belonging to the person or company you want to pay bitcoins to.  You have to get the address from them.

If you are trying to buy something from a company, usually they will tell you the payment address as part of the purchasing process.  If you are trying to send money to a friend, ask them for their address.

If you are not looking to pay money to anyone right now, then you do not need to use this screen at all.


How to use python reference for encoding a bech32 address?

The reference implementation provides a handy all-in-one encode function. To encode the scriptPubKey 0014751e76e8199196d454941c45d1b3a323f1433bd6 as a mainnet bech32 address, you would do:

import bech32
import binascii

spk = binascii.unhexlify('0014751e76e8199196d454941c45d1b3a323f1433bd6')
version = spk[0] - 0x50 if spk[0] else 0
program = spk[2:]
print(bech32.encode('bc', version, program))


MtGox support is available on https://support.mtgox.com, by email (support AT mtgox.com) and on IRC freenode server channel #mtgox.

You could try to check your spam folder if you are using a bad webmail provider or bad antispam.


Are multi-sig M-of-N transactions with N > 3 supported?

Standard multisig outputs have max 3 keys, but it is possible to add up to 16 keys.

This limit is probably a result of the hard limit of output script size.

EDIT: source: I don't remember where I found this information. (I implemented it in Dartcoin and put that in the documentation.) As an alternative source, check out Mike Hearn's BitcoinJ implementation here.


Is Ethereum essentially Bitcoin with Turing-complete Script?

Is Ethereum essentially Bitcoin with a Turing-complete scripting language and, if I understand correctly, where the script to be executed (not its hash) is placed in the Ethereum blockchain?

That's a bit of a simplification, (Ethereum has other improvements like GHOST) but for our purposes (discussing how a Turing complete scripting language could be implemented) it's essentially accurate.

  If so, why doesn't Ethereum just put hashes of its scripts in the Bitcoin blockchain, send the scripts to be executed through another secure means such as via a P2P network (which would greatly reduce blockchain bloat), and avoid being an altcoin altogether?

One of the important features of Ethereum is that you can condition spending funds on the output of a script. For example, you could write a lottery script that accepts money from a bunch of different people, and randomly sends all of the money to the winner. Imagine that we change this system so that only the hash of the script is included in the blockchain:

If it's not a consensus rule, then other nodes will accept a transaction that doesn't satisfy the attached script. In other words, if nodes can't see the entire script, how can a node know whether someone claiming the lottery winnings is actually authorized to do that?
If it is a consensus rule, that introduces a new set of problems. First, in order to tell if a block is valid, you need to download the scripts from the P2P network, and check that all of the scripts are valid. That increases the amount of time it takes to verify blocks, and therefore increases the amount of orphan blocks.

The second problem that this introduces is that full nodes synchronizing for the first time need these scripts, or they won't be able to check that the blocks are valid. Therefore, the scripts need to be stored indefinitely, in case new nodes join the network.

This doesn't really solve the blockchain bloat - it just moves the problem around.

There's one more solution that does use the Bitcoin blockchain, though. You could follow Counterparty's example, and create a system where you send a Bitcoin transaction with additional metadata to identify it as a colored coin. You don't change transaction validity rules on the main network; rather, you say that if the transaction doesn't follow certain rules, then it is not a valid TuringCoin transaction for the purpose of establishing ownership of TuringCoins. (Other TuringCoin transactions within the same block would still be valid, though.)

That's not an altcoin in the traditional sense (you're using Bitcoin's blockchain, and you must pay Bitcoin transaction fees) but it is an altcoin in the sense that you're creating your own token that isn't fungible with Bitcoin.

  If not, is the gas limit the real distinguishing feature of Ethereum compared to Bitcoin?

The gas limit in Ethereum is present for essentially the same reason that people have proposed making transactions in Bitcoin larger than 100KB invalid: otherwise, it becomes possible to create a block that takes a really long time to validate.


When BTC is traded at a Bitstamp, Mt Gox (or similar) what is the algorithm for matching Buys to Sells? How do partial fills occur?

(2) is the correct answer, the exchange will match the buy order with the lowest sell orders. This is the case with mtgox. Other exchanges should do the same, however it is up to them, hard to give a general answer here, need to look at each one case by case

(4) is specifically NOT true in case of mtgox because they do not act as counter party to any transaction. Not sure about any other exchange, because they all have their own policies.


Anyone know of an API I can get historical price time series for multiple coins

I am developing the ccxt cryptocurrency trading library, check it out on GitHub:

https://github.com/kroitor/ccxt

It is a library for cryptocurrency trading and e-commerce with support for many bitcoin/ether/altcoin exchange markets and merchant APIs.

With it you can access market data and trade bitcoin, ether and altcoins with more than 70 (!!!) cryptocurrency exchanges. It is used to connect and trade with crypto markets and payment processing services worldwide. It provides quick access to market data for storage, analysis, visualization, indicator development, trading strategy backtesting, bot programming, building trading algorithms on top of it, webshop integration and related software engineering.

The codebase is in JavaScript / Python (2 and 3) / PHP. You can deploy it from PyPI, with npm (for Node.js) or by cloning the GitHub repository.

The ccxt library is under heavy development right now, but already offers a quick-start for trading and technical analysis with many crypto exchange markets out of the box. It is intended to be used by coders, developers and financial analysts to build algotrading strategies on top of it.


Is there a way to parse raw transactions offline?

You can run bitcoind or bitcoinqt in offline mode (disconnected from the Internet). The client does not need to be synced. Then you can use the console to view transactions using the command.

decoderawtransaction <hex string>

To check if the signatures are correct, you need to do a

signrawtransaction <hex string> without any other arguments. It will output a {complete:true} result if the signature verifies.

Edit: I should mention that the signatures cannot be verified if the inputs are not known to bitcoind. In that case you will have to supply the inputs as discussed here.


Transfer btc from offline wallet bitcoin core to bank account

You can't transfer bitcoin to a bank account unless you live in a dursdiciton that recognises bitcoin as a legal payment, like Japan.

So you must find someone willing to exchange fiat currency with you, then you deposit that fiat currency into your bank.

Exchanges are one way, selling directly to another party is another.

Note: Exchanges often have withdrawal limits, so find them out beforehand and I would not trust them with all of that BTC at once.

I also would be extremely wary of selling it all direct without a contract, you wouldn't sell a house without a contract, this is a similar sum of money. I'd enlist a lawyer if you find a party to sell it all at once to.

The legal aspects are taxes and money laundering compliance. Exchanges should insulate you from the money laundering issue. Then taxes: in many countries, you will need to declare capital gains taxes. To be tax efficient, consult with an accountant, with >100BTC you can afford it and can't afford not to.


In my opinion block 398364 is the first BIP9 block.
Block 370434 was signaling BIP101. As you say, BIP9 was not created at the moment and even if is was meant to signal BIP9, it would also signal csv and segwit which where not active at the time: https://github.com/bitcoin/bips/blob/master/bip-0009/assignments.mediawiki
Block 398364 uses a BIP9 format to signal BIP109. The 4th bit is used to indicate the block version, 0b00110000000000000000000000000000 (0x30000000) which is within the defined version range of BIP9. But other proposals used the last bits in the version number.
Block 407021 is the first block with version number 0b00100000000000000000000000000000 (0x20000000) so a clear vote for only BIP9.
The green line below shows the BIP109 blocks and blue line BIP9.


How can Bitcoin Cash be blocks ahead of Bitcoin SV

Solutions to the proof of work are found randomly (by guessing until you find a valid block hash). So, the difficulty is adjusted in order to set an average block time of 10 minutes, but that is not always how it happens in practice.

Also, when the total network hashpower grows before the difficulty is recalculated (which happens every 2 weeks on Bitcoin), blocks can (and are) solved at a faster rate than every 10 minutes. The same applies in reverse, less hashpower will cause block times to increase above 10 minutes (until the next difficulty retargeting).


Mining on your own network, or creating your own mini pool

I finally sorted this out, so I'm back 17 days later to answer my own question. I also wrote a short article about the steps, should anyone else need them.

Here are the basic steps. The coin is referred to as Coin, as this works with all sha256 coins, and probably (untested by me) Scrypt variants as well. If not, the process will be very similar.

To start, your coin.conf file should look something like this:

daemon=1
server=1
listen=1
gen=1
rpcuser=uncle_bubs
rpcpassword=your_mother
rpcallowip=127.0.0.1
rpcport=8332

In your coin.conf file, add the line rcpallowip=12.34.56.789, replacing the IP address with the address of the computer you want to allow, or more simply rpcallowip=192.168.1.* to allow any IP address on your network. You can have as many rpcallowip lines as you want. Note that doing this will send your password unencrypted over the network, so it’s not recommended except within a secure network that you control.
Make sure your firewall is allowing incoming connections to coin-qt.exe.
Start coin-qt.exe -server on your server, and give it a moment to get caught up. (You should have the blockchain current before starting).
On your second computer, go into your router’s admin settings and look at the connected devices. This is usually done by entering 192.168.1.1 in a browser. You’ll need the router username and password to get in.
Look for the computer running your server. Mine was 192.168.1.8.
Now add that IP address and computer to the list of reserved addresses. The reason is that even if you leave your computer plugged into the same router all the time, it sometimes shuffles IP addresses unexpectedly. This is normally not a problem, but you need a fixed IP address to connect to. This step ensures your server always has the same IP address.
Finally, start your second miner, using the new address and port obtained from your router settings. Mine was 192.168.1.8:8332.


block explorer, just a parser and database query?

Yeah, that's how they work. For example, blockexplorer.com gets blocks from Bitcoin Core via JSON-RPC, gathers interesting chunks of data, and puts this data into a SQL database for easy access later. The code for this is only ~300 lines long (though it's very messy). Other block explorers work similarly. In fact, Bitcoin Core itself works something like this, though it uses a key-value database instead of a relational database, and it doesn't store any info about addresses.


To claim a patent you must be able to prove against contest that you invented the device, and have a working example that if built to the specs provided, runs.

As it was this Satoshi who invented bitcoin, and there are prior examples of a digital currency, it would be very hard for any one person to claim a patent so far after the fact. Some one could try, but the patent industry is built to make it hard to write a patent, easy to contest. Admitedly many companies do just that and are good at it, but anyone patenting bitcoin would have a hell of a time proving first invent.


How to spend from a paper wallet private key using a desktop app without a mobile app?

When you launch Electrum for the first time, it wants you to create a new wallet. Same when you just choose File → New/Restore at any point.

Then, choose "Restore a wallet or import keys" and "Standard wallet". On the next page, enter your private key. The password you can choose afterwards is optional and you can skip it or only remember for the period of time you're keeping this wallet on your computer.

If you want to try this in advance without typing your own private key in, you can use the private key KzbvEHb1HvDRZMPvVF7Du9F4N5g22QkeoeZ7qPCkjSPktt5bbCDU. Is has had 50 mBTC going in and out again as you can see on the blockchain.info page about its corresponding address 15dNGcjVE8ddCt3vgYwcpJjYXK4ydZtykF and you can find out how Electrum shows this to you if you create a wallet using it. This private key has been specifically created by me to be publicly known.

Note that Electrum won't be able to create more addresses from it because it only is a single private key. It is, however, able to show the one address the private key corresponds to.

You can use my answer to your question "
How do you send to multiple addresses by paying a one time fee? Which wallet supports this?" to transfer the remaining money back to the address it came from so you can spend it using the same private key in the future.


What is fTestnetToBeDeprecatedFieldRPC seen in chainparams.cpp?

The field corresponds to false for mainnet, true for testnet, and false for regtest. You can think of it as a flag that tells you whether the current network is testnet.
Why's it named like that?
To get people to not use it, and because getinfo and getmininginfo still use it:

jtimon commented:
Yeah, comparing to the testnet id was very readable so it's the new flag. The difference is that when people see "NetworkID() == something" they think they can use that too, while FlagWithLongNameIncludingTheWordDeprecated() is not as likely to be used or that's my hope.
@laanwj explained the deprecation thing, but basically, RPCs can just use bip70's networkidstring()
For the string, I was going to create another flag but @laanwj wants to keep chainparams clean of GUI-related things. Of course comparing to an enumerator is better than comparing to a string, again, the goal is that people don't see the comparation to the enumeration and think they can call CChainParams::NetworkID(), hopefully the comparison with a string will make people use that approach less, but we need the string for BIP70 anyway.

(Source.)


Can I mine bitcoin without damaging my hardware?

That would depend on your definition of damage.

First of all your equipment is going to 'wear down' much faster if the CPU is at 100% load longer than an hour or so. Normal computer usage lets the CPU throttle somewhere between 20% load and 100% for let's say 6 to 8 hours a day. CPU coolers are made to prevent the CPU from overheating in all possible situations, so it won't burn out your CPU immediately.

But with normal computer usage your CPU will heat up, cool down a bit (a bit less hot), heat up again, etc. With mining on a CPU, the CPU will heat up and continue heating up to the point where the heat exchanged by the CPU cooler will be equal to the heat produced by the CPU. This is called an equilibrium (or balance).

There are temperatures your PC would be OK with running 24/7, but that does not mean anyone would recommend you doing so. You won't ruin your computer right away, but the chances of it will definitely be higher.

Next to that, the amount of bitcoins you can generate letting your CPU mine bitcoin right now (December 2014) would be around 0.00000001 a week... ? That's about accurate. (Not taking power usage into account.) If you really want to mine cryptocoins on your CPU, look for a CPU-only cryptocoin and then exchange the mined coins to Bitcoin, that way you'll get much more in most cases.

If you absolutely want to mine Bitcoin directly without mining an altcoin, look at this: How do I start mining?


Why did Litecoin choose the scrypt factors that they did?

Litecoin basically copied the parameters from a coin called tenebrix. The parameters were chosen partially because using more memory intensive parameters caused the GUI to be noticeably slow.
Listen to Charlie Lee talk about this at the Hashers United conference in Las Vegas.

https://www.youtube.com/watch?v=aHX34MbXuOk#t=469m00s
https://www.youtube.com/watch?v=qbj7aXu7FTw

[transcript starts at approximately 9:45 in the second video.]
Q: [...] But in hindsight, do you regret selecting the N, r, and p, parameters for scrypt?
A: So, the parameters I chose were copied straight from Tenebrix. The reason why they were chosen that way is because if you make the parameters harsher, more memory harsh, it actually slows down the client. Every time a block comes in, the client would actually freeze, for a minute, to verify the block, because it was so hard. At that time, it was decided, that it was a tradeoff. They decided to go with a better experience of the user using the client, and not as memory harsh, because at that time there wasn't any GPU that was capable of doing it, and it was CPU-only.
It would be great if the parameters were more memory harsh, but I think it was a tradeoff, and it was decided early on, to err on the side faster client speed instead of harsher memory requirements.


One of the popular trading sites is coinbase.com. There you can sign up and buy and sell - should be straight forward. Of course there are other sites as well.


What is the reason for the recent drop in Bitcoin classic nodes?

there is indeed speculation that only a few people are running the majority of classic nodes via aws or similiar services. a user on reddit claimed to host 800 vps classic nodes alone on aws, see https://www.reddit.com/r/btc/comments/4aka3f/over_3000_classic_nodes/d113ffi

the comment is two months old and announced that those crowdfunded nodes will go offline in mid-may, which would fit the current drop.

not sure about the fake demand part of your question, as I don't think there is anything malicious in vps nodes per se and that a good amount of core nodes are on vps too.

btw. 21.co has a couple of nice charts regarding node distribution:
https://bitnodes.21.co/dashboard/#user-agents


Understanding skip pointers in BlockIndex in bitcoin sources

It is implenting a skiplist.

Every index node points to its immediate predecessor (pprev), and to some other predecessor that is further away (pskip). These skip pointers are used when we need to find a far predecessor quickly. One common case is when we need to find the 2016th ancestor of a block to recompute the target difficulty.

Most of the skip pointers only go back a few blocks, but ocassionally one points back very far, allowing many nodes to be skipped.


do isolated blocks create forks in block chain? (with forks I mean branches that are no longer valid) If yes then how does the node redeem itself?

If a block is mined on top of block A (let's call it block C), when Node B hears about block C, it will change its blockchain state to have block C as its tip and block B will become orphaned. This is because block C's chain has more work than block B's chain.

Seeing a double spend in blocks as you describe it does not make a block invalid. If I see a conflicting transaction in block A and block B, that conflict does not make one of those blocks invalid to me.


Ignis transaction not included in the blockchain

When you send a transaction to a new account on Ignis (i.e. ARDOR-LHJR-WZVF-VKTX-3PVAA is a new account) the fee you pay in IGNIS should cover the bundler cost of 1 ARDR. Currently the best bundling rate is 2.45 so you should have specified 2.45 IGNIS or higher as fee i.e. "feeNQT": "245000000". If you send it to an existing account the fee is only 0.01 ARDR paid in Ignis according to the best bundling rate.

My recommendation for exchange developers and application developers is to setup their own bundler as explained in section 5.3.4 and 5.3.5 of the Ignis Integration Guide


How does an exchange calculate the price of a coin?

It's normally all about offer and demand.

A "formula" for an exchange could be something like: BTC price shown on the website = average amound (in $) paid for 1 BTC within the last 2 minutes [- exchange fees]

If there are 2 trades in this time:
person A buys 1 BTC for 10,000$ and person B buys 1 BTC for 10,100$, the average is 10,050$. And if there are 500 trades in the last 2 minutes, you get a more accurate average price.


It depends how you measure value.

If the price of Bitcoin in USD goes down, then it might be because of a change in the value of USD rather than a change in the value of Bitcoin, so in that case fixing a Bitcoin price for your product may reduce fluctuation.

Realistically, the price of Bitcoin fluctuates more than the value of USD. Also, it usually makes more sense to aim for a particular USD amount for a product rather than a particular Bitcoin amount.

To resolve this, you can setup software to automatically adjust your prices so that the Bitcoin prices for your product are linked to the amount of USD you want. There are existing tools that do this, and they aren't unique to Bitcoin as they are used for fiat currency price conversion too.

When using such a tool, you're still exposed to changes in the value of Bitcoin from the time of a sale until the time you trade your Bitcoin for USD, but again you can setup automated software to manage that; it could be used to sell the Bitcoin for USD as soon as possible after each sale.


Unable to send total amount of bitcoin even after deducting the transaction fee what do I do?

i would go to coinb.in and manually broadcast the transaction to the network myself. this way you can have it set on the lowest fee, then go to viabtc.com and use their free transaction accelerator to give it a final push. works every time. GL


Have a 0/unconfirmed transaction stuck over 12 hours

I ran bitcoind with the --zapwallettxes flag and recovered the coins.  Thankyou for the help


I have my 12 word bip39 phrase but not in the right order

I suspect that the words are in the right order, since BIP39 includes a checksum word - If they were out of order, it is unlikely that the wallet would have accepted them to even attempt a recovery.

It is more likely that the two wallets you used were using different derivation paths and/or address types.

A seed phrase can lead to many different addresses, such as regular addresses, P2SH-P2PKH addresses, and native segwit P2PKH addresses. Many wallets these days support multiple types of addresses, and you would need to point the wallet to the correct derivation path when restoring a seed.

Moreover, wallets such as electrum default to their own seed semantics, and must be told to use BIP39 explicitly, which can also lead to different addresses being derived.

Your best bet would be to look up the original wallet and see what type of addresses it was deriving, and the derivation path. Then, use another wallet that allows you to restore the same path and address type.


It's unclear which version of dogecoind you are using. However, in the current 1.5 code on Github, there is a similar message:

if (mapArgs["-rpcuser"] == "" && mapArgs["-rpcpassword"] == "")
    throw runtime_error(strprintf(
        _("You must set rpcpassword=<password> in the configuration file:\n%s\n"
          "If the file does not exist, create it with owner-readable-only file permissions."),
            GetConfigFile().string().c_str()));

https://github.com/dogecoin/dogecoin/blob/master-1.5/src/bitcoinrpc.cpp#L1080

This indicates that your attempt at working around the problem with chmod 777 would not have had the desired effect. Instead, try chmod 600 dogecoin.conf.


Where's the bug in this unsigned transaction?

I found several bugs and now it works.

For the incoming transaction I used the public key, but I had to use the full scriptPubKey for the output I was trying to redeem. The clue for that was that my inputs were 0x14 long instead of 0x19 in the correct example.

In the output I forgot to add the length of the public key 0x14 after OP_DUP OP_HASH160 (0x76a9).

At this point BitcoinQT was able to parse the transaction and detect a newly introduced mistake I made in calculating the output size.

Later on I tried to sign and manually send the transaction using blockchain.info. This is where I uncovered another error, namely that the transaction hash needs to be little endian. In other words 0f7404...be54d3 needs to be written as d354be..04740f.

Here's the correct version (with slightly improved line breaks):

01000000
02
d354be7cd5426bfbe70517b934b8764d17ad7f93e2b8db868211851d4404740f 01000000
19
76 a9 14 23376070c7b24da64b435c71613053800494ab1c 88 ac  ffffffff
e49a65da5abe3edd6e5157327fe794a7c75befecaaf18fefd3154dbb4527d6d6 01000000
19
76 a9 14 23376070c7b24da64b435c71613053800494ab1c 88 ac  ffffffff
02
40420f0000000000
19
76 a9 14 c8a73488183dd49f63a11dea0a3b242ae70942d2 88 ac
10ae220100000000
19
76 a9 14 23376070c7b24da64b435c71613053800494ab1c 88 ac
00000000
01000000


Does being connected to more peers relay transactions faster?

No, very little of the time for downloading new blocks is actually related to network transmission.

Most of the work being done is the I/O against your hard drive as the program writes data to the BDB database storage.  If you are on an encrypted filesystem, the problem is exacerbated.  There is some CPU work as the elliptic curve encryption is used when verifying the signature for each transaction so a faster CPU will help as well.

Some people use SSD disk storage and report quite respectable download times

Some improvements are coming in v0.7 of the Bitcoin.org client but the real signficant performance improvement will come from the use of LevelDB and "ultraprune", both of which are expected in v0.8.


Why raw Bitcoin transaction are in hex format?

Because unlike addresses, hex raw transactions aren't meant to be seen or used by end-users. Hex is easy to encode and decode (every two character in hex represents one byte*, whereas in base64 one character is 3/4 byte and Base58 is log(58)/log(256) = 0.7322476244 bytes) so it is convenient if you want to debug your implementation.

*: which means if you can find an erroneous byte in the transaction that you can CTRL+F for that byte in the serialized hex transaction and change it since unlike Base58 or Base64 an encoded character depends on the part of only one byte and never two neighboring bytes. Hex is the highest base with that property. Binary (1 bit divides 8 bits), Quaternary (2 bits divide 8 bits), not octal (3 bits don't divide 8 bits), and hexadecimal (4 bits is the largest divisor of 8 that isn't 8) are other bases with that property, so hex is the most efficient one among them.

Or simply, it was created as an internal tool which didn't need the complexity of a new format that provides space efficiency or avoiding similar characters (or checksum, even though hex doesn't depend on checksum) that is user-friendly.

From Bitcoin QT 0.7.0 release notes:

  Added raw transaction API. See https://gist.github.com/2839617

Gavin Andresen, who created and submitted the hex transaction encoding code to Bitcoin Core/QT wrote:

  I considered parsing/writing BIP 10 format for raw transactions, but
  decided that reading/writing BIP 10 format should happen at a higher
  level and not in the low-level RPC calls. So 'raw transactions' are
  simply hex-encoded into JSON strings, and encoding/decoding them is
  just a couple of lines of already-written-and-debugged code.


Who will the first adopters of Taproot be (assuming it is activated at some stage)? What incentives are there to start using it straight away?

(A 2-of-2, 3-of-3, n-of-n will be referred to as a multisig scheme and a 1-of-2, 2-of-3, k-of-n where k < n will be referred to as a threshold scheme)
The most significant incentives for using Taproot (in terms of reducing transaction fees) exist for those who are using either multisignature/threshold schemes (the larger the multisig the larger the incentive) or complex scripts (that may also include various multisignature/threshold schemes within them).
There are various MuSig schemes that are at different levels of maturity. Classic MuSig (for multisignature, not threshold) has gone through multiple iterations and is at a point where its design is unlikely to be revised significantly. It is not yet used in production but it is plausible that it could be if and when Taproot is activated on mainnet.
Murch has an excellent Medium post and a StackExchange answer describing the fee savings from using Taproot and MuSig for a 2-of-3 threshold signature use case. There is not a threshold MuSig scheme that is ready to be used in production (at the time of writing, October 2020) but using multisig MuSig you can get up to 45% fee savings in comparison to using P2WSH. You do this by setting up your Taproot key path spend as a 2-of-2 MuSig (with only one combined key going onchain if it is used) and two alternative 2-of-2 MuSig script path spends as separate leaves in the Taptree. (You are effectively turning a 2-of-3 threshold into three alternative 2-of-2 MuSigs. This is the most efficient approach because for each MuSig only one key and one signature goes onchain when a MuSig scheme is used to spend.)
Assuming that you will use the key path spend the majority of the time (i.e. you can identify two of the three keys that will be used the majority of the time) the fee savings really are significant. These incentives are likely to drive some of the early adoption of Taproot.
For more details on the current state of Taproot multisignature and threshold schemes see this presentation from Tim Ruffing at London Bitcoin Devs (June 2020).
Thanks to Pieter Wuille and Murch for answering my questions on IRC. Any errors are my own.


Transaction unconfirmed after a day! Help!

You will need to create a new transaction to the address with a higher fee. There is very little you can do to an existing transaction in the pool.


Where can I find a list of business which accept Bitcoin?

Black and Yellow Pages and Agorist Marketplace both have people who sell services in bitcoin, though there are some people on those sites who prefer to deal in gold or silver.


What would the rough hash rate for an ec2 instance be - litecoin

It may not be as high as you expect with out compiling CPUMINER for multi core.
I can not tell if the last on the list is the same or a slower version of what you are referring to from this list online.

http://litecoin.info/Mining_Hardware_Comparison#Other
based on that page, each Amazon High-CPU Extra Large Instance, running Ubuntu 12.04.1 and using pooler's cpuminer 2.2.3, has a script hash rate of 38 Khash/second. Rounding down ( habbit, no real math reason other than the real world is usually slower ) to 19 times that makes it an estimated 722  Khash/second and possibly faster.


You can make use of the -blocknotify=<cmd> facility as described under: https://en.bitcoin.it/wiki/Running_Bitcoin.

This is a nice example of how to use -walletnotify: https://bitcoin.stackexchange.com/a/24483/11221, -blocknotify can be configured in exactly the same way.


Try this:

Close Bitcoin.
Press Alt + F2
Type bitcoin-qt -reindex
Press enter.


How do we have one-to-one mapping given the key size differences?

We don't have a one-to-one mapping in the sense that you are talking about. But, for practical purposes, we have a one-to-one mapping. Yes, if someone tried to map every single key, after a few million centuries, they'd have a problem. But we won't have to worry about that until long after the stars burn out.

To find two keys that hash to the same ID, you'd have to try on average 2^80 keys. If you had a million computers, each capable of trying 1,000 keys a second, it would take 380,000 centuries to find a single match. And all you could do with those two keys was claim money sent to the same ID with either one, which would cause no harm at all.

Now, if you want to find a key that matches a key that actually has Bitcoins already, that's a much harder task. Say there are 10,000,000 IDs that have coins. The odds of a single key matching one of these 10,000,000 is 2^160/10,000,000 -- even with 1,000,000 computers each trying 1,000 keys a second, it would take billions of billions of centuries.

So for practical purposes, it's one-to-one.


Mining is computation based, but it's not constant, it's random. Essentially, every hash calculated generates a random number. If the random number is below the target, it's valid to create a block. The probability of any single hash being low enough is minuscule (you have a better chance of winning the lottery several times in a row), but that's why you need to calculate a lot of hashes. The actual merkle tree makes no difference as long as the tree itself is valid. Miners don't have any obligation to include all transactions in the mempool, so they typically will submit blocks whenever they find a valid hash.

So really, the updates to the merkle tree don't actually matter. In fact, it can be helpful since there are more nonces to try.


See the following links for an overview and for details.

Note: In short, if you do not have a strong understanding of the BIP38 encryption and decryption workflow, do not BIP38-encrypt your paper wallet. Just print your paper wallet out without encryption, and keep it safe the same way you would jewels or cash.

Just encrypting with AES provides excellent security but the weakness is the key which is unwieldily since it needs to be random binary data and the encrypted output which is also binary data. In order to use a passphrase as the encryption key a function such as PBKDF2 is generally used and the output can be base64 encoded to make it ASCII so it can be printed/written. Finally, unless you are a crypto domain expert do not roll-your-own security schemes, they generally will contain flaws rendering the security null.

Note: Scrypt is a form of Password-Based Key Derivation Function (PBKDF2) that has increased memory requirements.

BIP38 encryption provides the above and some inter ability with the crypto currency eco-system.


I had the same issue when I had Bitcoin Core running.  Shutting down Bitcoin Core and restarting Multibit fixed the issue.

I'm guessing the issue was that Bitcoin Core had exclusive access to port 8333.  If you are not running Bitcoin Core, check for other software that might use that port.


There are a few things to consider here.

First, do you know the path of the HD wallet? You can find out what type of path structure your wallet is using, and if the address with the unspent transactions was the very first one, then it would be account 0, for example.

See this on BIP44 paths...

If you know the path structure, and you know the exact address you are looking for at a given path, then you could do something like this using bitcoinjs-lib:

const bip39 = require("bip39")
const bitcoin = require("bitcoinjs-lib")

const network = bitcoin.networks.bitcoin

for (const phrase of phrases) {
    const seed = await bip39.mnemonicToSeed(phrase)
    const root = bitcoin.bip32.fromSeed(seed, network)
    const path = "m/44'/0'/0'/0"
    const child = root.derivePath(path)
    const { address } = bitcoin.payments.p2sh({
        redeem: bitcoin.payments.p2wpkh({
            pubkey: child.publicKey,
            network
        }),
        network
    })

    if (address === '3...') {
        //this is yours
    }
}

Note that this example is for P2WPKH wrapped addresses (3 prefix). You would need to change this a bit depending on the type of address you are trying to match.


Question Regarding Send_to_many function of blockchain wallet api

What you need to manage is the fee rate. Bitcoin core nodes will not relay transactions (or include them in blocks) below the minimum fee rate of 1000 satoshi/kB (-minrelaytxfee), so if you keep increasing the transaction size, but not the fee, you risk not getting relayed or even mined (-blockmintxfee), since miners typically maximize the fee rate in the block being mined.


How to communicate between Java and bitcoind?

Here's an early experimental client I had played around with a while back. It supports getInfo, getBalance and getNewAddress, and can easily be expanded. In order to run it, the credentials for your local bitcoind have to match the values in the client class:

httpclient.getCredentialsProvider().setCredentials(new AuthScope("localhost", 8332),
                    new UsernamePasswordCredentials("btc", "123"));

Feel free to use this code in any way, but understand that it's only 5 minutes of work on a start, not a realistic client implementation. Hope it helps you generate some ideas!


Why are transactions grouped into blocks?(puzzle creation)

The "puzzle" metaphor may not be helpful.  The goal is always the same: create a block whose header has a sufficiently small hash value, less than the current target.

So every miner can create a block any way she wants, as long as it meets the general requirements of the protocol (all transactions are validly signed, block reward is no larger than the current standard value, etc), and then start varying the nonce value in hopes of finding one which makes the hash sufficiently small.  There is no single centralized authority or protocol that hands out blocks for people to work on.

In practice, this means that no two miners are ever working on exactly the same block.  Two different solo miners will have different blocks, because each will have a coinbase transaction that pays the reward to his own address.  Two different members of the same pool will be assigned different variants of the same block, in order to avoid duplication of work (perhaps each will put his own identifier somewhere in the block).

The target is, in some sense, uniquely determined by the protocol.  The Bitcoin protocol specifies how the target is to be computed, based on the timestamps of prior blocks; this is what ensures that it adjusts with the total mining power of the network to keep the block time approximately constant at 10 minutes.  It should be the case that all miners on the network are using the same target value to compare with their blocks.

So in that sense, everyone is trying to solve the same "puzzle" (aiming for the same target), but everyone is trying a different approach to do so (a different candidate block).

The target only changes every 2016 blocks (approximately every two weeks).  So most of the time, you can know what the target will be after the next block: same as the current target.  If the next block would be a multiple of 2016, then you will need to wait until it is mined, because its timestamp will be involved in the computation of the next target.


All transactions are added to the blockchain. If you need to use the bitcoins associated with a single address for payment, it will refer to the particular transaction from which it has received the bitcoins. The wallet stores each transaction separate so that you can see the transaction details (txid, sender, receiver, etc). Even though it shows the cumulative value of all the addresses, you don't have to worry of how much each address stores since the software will take care of combining multiple transaction outputs if need be. It would be easier to see the combined value of each address but then it makes it tougher to store individual transactions.


Why do LedgerJS and Electrum, using the same Nano S and derivation path, not refer to the same Wallet?

A public key can have multiple addresses. It looks like what is happening here is that Electrum is creating a P2SH-P2WPKH type address while your NodeJS code is creating a P2PKH address. These are two different address types which have different spending requirements and transaction data. However Bitcoin sent to either address type can still be spent with the same private key and the same public key was used to create both addresses.

When you sent the Bitcoin to the P2PKH address, Electrum won't show it because it is not looking for Bitcoin sent to that address. Just because you have the private key necessary to spend some Bitcoin does not necessarily mean that your wallet will be looking for outputs of that kind. A wallet cannot track all possible output scripts that it can spend (it is infinite), it can only track the ones it is expecting to see. So for Electrum, it's only tracking the P2SH-P2WPKH address and not the P2PKH address that you sent Bitcoin to.


How does MPOS communicate with stratum server?

NOMP actually implements MPOS compatibility mode, so you can reference the data format it writes to MySQL: mposCompatibility.js. For example:

Storing shares:

INSERT INTO `shares` SET time = NOW(), rem_host = ?, username = ?, our_result = ?, upstream_result = ?, difficulty = ?, reason = ?, solution = ?

Updating Miner Difficulty:

UPDATE `pool_worker` SET `difficulty` = ' + diff + ' WHERE `username` = ' + connection.escape(workerName)

New Pool Worker:

INSERT INTO `pool_worker` (`account_id`, `username`, `password`) VALUES (?, ?, ?)


Is signature/private-key required to accept payment over Lightning Network?

Yes invoices are signed according to bolt 11. One reason we do this is to fight dos attacks. If I would not have to sign my invoice I could create an Invoice for any node. That node would not have the preimage for that payment hash and routing of the payment would fail all the time.

While I can imagine other processes that don't require a signature in the invoice we still need the private key / signature to update the payment channel on which the payment is coming in. This is needed to accept the offered htlc and to settle it. Since we certainly need a signature for the htlcs we can use them for invoices as well.


How do I export a wallet from Wasabi Wallet to Samurai?

A single mnemonic seed phrase can be used to derive many different addresses, either via different derivation paths, different address types, etc.
It may often be possible to create multiple instances of the same wallet using different software, but the two wallet applications you've mentioned have nuanced operation and likely use different derivation schemes for certain wallet functions (eg mixed output change, etc). I doubt that there is the option to have them derive all of the same addresses. Perhaps it is possible via advanced settings, but at the least I hope my answer can help to highlight the nature of the situation.


How to generate bitcoin P2SH WIF key and address pair from sha256 private key?

Private keys give public keys, which can give bitcoin addresses starting with a 1. But a P2SH address (starting with a 3) is simply the hash of a script, and that script could be almost anything, it isn't usually associated with a single public/private key. Perhaps you mean P2SH-P2WPKH? In that case you could read something like this: https://bitcoincore.org/en/segwit_wallet_dev/ (specifically the section called 'Creation of P2SH-P2WPKH Address'). Otherwise maybe something like a 1-of-1 multisig address or simple P2SH encoding a normal P2PK/P2PKH redeem script? I'll update this answer if you clarify exactly what you mean :)


There is no 21 command for that. You need to: sudo minerd --stop


The difficulty is actually represented by the target threshold encoded in the nBits value in the block header. Where difficulty represents the human readable representation ("how often do we need to try to find a solution"), the target threshold defines the prefix a block must undershoot in order to be valid. This means that the 256-bit block hash interpreted as a number must be lower than the target threshold.
Although, nBits is only a 4-byte value, it is a compressed representation of a 256-bit (32-byte) number. The first byte defines the exponent, the remaining three bytes give a 24-bit mantissa for the target.

While this leaves most of the 32 byte in the target threshold to be just composed of zeroes, the difficulty can adjust in a much more granular fashion than just adding leading zeros.

David Harding has elaborated the full details in How is the target section of a block header calculated?.


Feasibility of using Ring Signatures with CoinJoin Technique

Using ring signatures off-chain to form a coinjoin transaction sounds hard, especially since because BTC doesn't have ring signature support without a hard fork or a soft fork.
You may find Cashfusion, an instance of CoinJoin shuffling, interesting, it's fully applicable to BTC and it uses TOR, which is simpler than Ring Signatures.