Run RPC request against I am forking the Altcointipbot for reddit to make a tipbot for Litecoin. There has been a lot of problems that I've managed to solve, but this one I cannot seem to solve. When I try to start the script, it stops when trying to make a RPC request, giving me an error with code 500. This is the traceback:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "cointipbot.py", line 539, in __init__
    self.self_checks()
  File "cointipbot.py", line 144, in self_checks
    b.register()
  File "ctb/ctb_user.py", line 230, in register
    new_addrs[c] = self.ctb.coins[c].getnewaddr(_user=self.name.lower())
  File "ctb/ctb_coin.py", line 172, in getnewaddr
    self.conn.walletpassphrase(self.conf.walletpassphrase, 1)
  File "ctb/pifkoin/bitcoind.py", line 69, in __call__
    return server._rpc_call(self.method, *args)
  File "ctb/pifkoin/bitcoind.py", line 216, in _rpc_call
    raise BitcoindException('%d (%s) response from bitcoind' % (response.status, response.reason))
ctb.pifkoin.bitcoind.BitcoindException: 500 (Internal Server Error) response from bitcoind

My guess would be that the RPC request goes to bitcoind (litecoind), where as now you need to use bitcoin-cli for requests (at least that's how it is in the terminal). However, I cannot seem to find anything in the code that's specifying that the request goes to bitcoind and not bitcoin-cli, so maybe it takes care of that automatically? I am by no means very good at this, so I was hoping someone with more experience could help me figure it out.

The part in the code where all the RPC requests happens can be found here: https://github.com/dpifke/pifkoin/blob/master/python/bitcoind.py

The rest of the source is here, but it's probably not necessary: https://github.com/vindimy/altcointip

I've already edited the litecoin.conf to include rpcport, rpcuser, rpcpassword and server=1.

Thanks in advanced!

I found the problem. Turns out the it was actually running as it should. The reason for the error message was that the program tried to decrypt the wallet, but I never encrypted it in the first place. After encrypting it, it works fine.


Where are the new smart fee estimate data saved? Can the file be re-used? Are the data for smart fee estimation (in bitcoin core with version 0.15.0 or larger) saved?

Where is it saved, what is the format?

Can they be re-used on a different node - so the estimates are accurate, even when the node is just started? If the file (or files) is moved from node to a different node (that has a different chain state), will the fee estimates still be accurate?

In the bitcoin data directory, there is a file called fee_estimates.dat.  This file is only written when bitcoind or bitcoin-qt exits so it is not up to date until that point. After that you could copy it and use it on another node to start with up to date estimates.

There is some trickery if the nodes are at different chain heights, but it should mostly do the right thing. It tracks the block height that the estimates were written as of and the new node won't affect the estimates until it's active chain has advanced beyond the latest recorded block in the old file.  Also if the chain in the new node is past the last recorded block in the file, then the estimates are decayed under the assumption that the data is no longer as meaningful.

In general if you start from scratch, you should only need to wait for about twice as many blocks as the target you would like an estimate for before you are able to get a somewhat reasonable answer.


Electrum seed words safety dumb question I am starting with bitcoin and even though I understand pretty well how the blockchain works, the seed words used by some wallets (MultiBit and Electrum) give me creeps and doubts.
The main question is: Why they are safe?
The base for the question: Humans are not good source from random data so we use seed words from a random-pc-time-based source. This seed words are a representation of a binary number and the phrase with 12 words makes a 128bit hash. Those words are drawn from a 4096 words dictionary. The dictionary from Electrum is saved in a python script, for example. So, we can say we know those 4096 words. I have a seed phrase (12 words) from my wallet. What protects all the network of someone who changes the last word of his own phrase 4096 times, to open 4096 bitcoin wallets?
I know with Electrum, again for example, that 128 of those 4096 generate valid addresses. What protect the network then of someone opening the bitcoin wallets of 128 mates and stealing all the money?
The last part is more simple, the validation is made online, how an wallet check of the words open the private key if they can work offline?

For the vast majority of possible 12-word combinations, the corresponding wallets were empty and never generated. The total number of the combinations is pretty huge so trying to brute-force them will not work out. In fact, words are just another (mnemonic) way to encode the entropy contained in the private key.


spend from p2sh with bitcoinj i am try to spend the coins on a p2sh

first, i generate p2sh and send coins to that p2sh

ECKey clientKey = new ECKey();
ECKey serverKey = new ECKey();
ECKey thirdPartyKey = new ECKey();
List<ECKey> keys = ImmutableList.of(clientKey, serverKey,thirdPartyKey);
Script multisigScript = ScriptBuilder.createP2SHOutputScript(2, keys);
String address = multisigScript.getToAddress(params).toString();

then i send coins to the "address" on testnet3

second, i use the wallet in bitcoinj to watch the "address" and get the tx

WalletAppKit walletAppKit = new WalletAppKit(params, new File("./btcWallet"), "test");
walletAppKit.startAsync();
walletAppKit.awaitRunning();
Wallet walletTemp = walletAppKit.wallet();
Address watchAddress = Address.fromString(params, "2NGY4n3Wc2iftWufhUg2MzZtccbkQWgdUiz");
walletTemp.addWatchedAddress(watchAddress,1576573079);
 Set<Transaction> transSet = walletTemp.getTransactions(false);

third, after i get the tx and the output, i want to spend it

TransactionOutput out = ...//output that the second step i get from the tx
Script scriptOut = out.getScriptPubKey()
Coin outValue = Coin.valueOf(10000);
Script redeemScript = ScriptBuilder.createRedeemScript(2, keys);
Address sendAddress = LegacyAddress.fromBase58(params, "2N6846hvswyZEdJ5DuEcjQZPaT5Xwb6PdGT");
Transaction spendTx = new Transaction(params);
spendTx.addOutput(outValue, sendAddress);
TransactionInput input = spendTx.addInput(out);

Sha256Hash sighash = spendTx.hashForSignature(0, redeemScript, Transaction.SigHash.ALL,
                        false);
ECKey.ECDSASignature cSignature = clientKey.sign(sighash);
ECKey.ECDSASignature sSignature = serverKey.sign(sighash);
TransactionSignature cTransactionSignature = new TransactionSignature(cSignature, Transaction.SigHash.ALL,
                        false);
TransactionSignature sTransactionSignature = new TransactionSignature(sSignature, Transaction.SigHash.ALL,
                        false);

Script inputScript = ScriptBuilder.createP2SHMultiSigInputScript(ImmutableList.of(cTransactionSignature, sTransactionSignature), scriptOut);
input.setScriptSig(inputScript);
input.verify(out);

it have error at "input.verify(out);",Script resulted in a non-true stack: [] [3044022043d0cdddb087c4db2937a3b656c37bf240fd95e16714125c0672875bb18b4c1902200f96e1ec0adc2258e324cbacba598cb72d502a4e3185212dea40c50b365d3fb901] []

i do not kown where my code is wrong and how to solve it.

find a similar problem, but not the same [1]: Errors when building/sending multisig transactions

Based on your example it looks like you are signing the same sighash twice, so it only looks like one key signed.

This example might help: https://github.com/magmahindenburg/MultisigExamples/blob/master/src/se/moar/bitcoin/multisig/MultisigPresentation.java

    // Sign the first part of the transaction using private key #1
    Sha256Hash sighash = spendTx.hashForSignature(0, redeemScript, Transaction.SigHash.ALL, false);
    ECKey.ECDSASignature ecdsaSignature = key1.sign(sighash);
    TransactionSignature transactionSignarture = new TransactionSignature(ecdsaSignature, Transaction.SigHash.ALL, false);

    // Create the sighash2 using the redeem script
    Sha256Hash sighash2 = spendTx.hashForSignature(0, redeemScript, Transaction.sighash2.ALL, false);
    ECKey.ECDSASignature secondSignature;

    // Take out the key and sign the signhash
    ECKey key2 = createKeyFromSha256Passphrase("Super secret key 2");
    secondSignature = key2.sign(sighash2);

    // Add the second signature to the signature list
    TransactionSignature transactionSignarture = new TransactionSignature(secondSignature, Transaction.sighash2.ALL, false);
    signatureList.add(transactionSignarture);

    // Rebuild p2sh multisig input script
    inputScript = ScriptBuilder.createP2SHMultiSigInputScript(signatureList, redeemScript);
    spendTx.getInput(0).setScriptSig(inputScript);

    System.out.println(byteArrayToHex(spendTx.bitcoinSerialize()));


What is the standard deviation of block generation times? A block is generated every 10 minutes, on average.
What is the standard deviation of this distribution?

It seems to be a measurable property, not a calculable one.

Is there a chart of the standard dev over time somewhere (should be added to blockchain.info)?

Excluding complications like difficulty changes and temporary blockchain splits, you can model the block generation time as an exponential distribution.

An exponential distribution has a standard deviation equal to the expectancy value. This predicts a 10 minute standard deviation for Bitcoin.

Measuring the actual distribution isn't that easy. While each block contains a timestamp, that timestamp isn't very accurate, and sometimes the time difference between blocks is even negative.
The timestamp doesn't change over the course of a single share, and some miners deliberately use timestamps deviating from the actual time


walletNotify on every Bitcoin Network transaction Is there any way by which I can receive each and every Bitcoin transaction that takes place on the Bitcoin network(not only my own wallet's transactions)? Just the way Blockchain.info provides a transaction stream no matter who made them and to whom they are going?

Can txindex=1 helps in this regard too?

Jeff Garzik's PyNode will, by default, connect to a Bitcoin Core running on local host a as a full node and download each transaction your node relays to it.  If you know Python, you can add extra triggers and post-processing to it.

Note, PyNode seems to be abandonware, and I think you currently need to hack it to get it to work with the latest versions of python-bitcoinlib.  It may still work with an older version of python-bitcoinlib.  You may also have better luck with PyNode2, a fork of the original PyNode.


How to open new wallet into Bitcoin Core and switch between? I have my old wallet which private key is compromised. So my reasonable way is to open new wallet and move all bitcoins from compromised wallet to new wallet.

I use Bitcoin Core. I do not trust any online wallets because private key stored into remote store.
So how can i open new wallet and move all bitcoin to it using Bitcoin Core only?

the funds are linked to your "compromised" keys. They are not in your wallet. So you can generate a new set of keys (as you mentioned, by creating a new wallet), and then transfer from old address to new address. Before you start anything, think of backups! Procedure might be like this (attention: wallet dirs on Windows, Unix and OSX locations differ, depending on your OS, you may want to adopt):

0.) stop bitcoind or UI
1.) backup of old (compromised) wallet to USB stick
2.) rename bitcoin wallet directory to s.th. like "OLD_bitcoin_dir"
3.) start bitcoin (it will create new wallet and keys, get one of the public keys via MENU->FILE->RECEIVE ADDRESSES, cut&paste or write it down)
4.) stop bitcoind or UI
5.) rename wallet directory to s.th. like "NEW_bitcoin_dir"
6.) rename wallet directory "OLD_bitcoin_dir" to your original name
7.) start bitcoin
8.) transfer your funds to your new address from step 3
9.) wait until you "see" in a block explorer your funds on the new address
10.) stop bitcoin
11.) delete wallet dir
12.) rename wallet directory "NEW_bitcoin_dir" to your original name
13.) check if funds are all there
14.) don't forget to backup again :-)

Hope this is the way to go, if there is an easier way within Bitcoin Core, I'd be happy to hear from the experts...


In practice, are redeemScripts commonly reused? In regards to P2SH-P2WSH transactions, are Txout-script values identical between transactions?  Is it reasonable to expect a business or vendor that accepts bitcoin to be using the same redeemScript for all transactions and use the same Txout-script value? Would users benefit from this value rotating?

Let's look at an example of this type of transaction:

The following example is the same 1-of-2 multi-signature P2WSH script, but nested in a BIP16 P2SH output.

witness:      0 <signature1> <1 <pubkey1> <pubkey2> 2 CHECKMULTISIG>
scriptSig:    <0 <32-byte-hash>>
              (0x220020{32-byte-hash})
scriptPubKey: HASH160 <20-byte-hash> EQUAL
              (0xA914{20-byte-hash}87)

So, let's say the user that created this script accepts multiple payments to this same script. In order to spend the Bitcoin received at the script, they must provide the same redeemScript, but one thing will change with each transaction, and that is the <signature1>. Since the transactions are not exactly the same each time, the data being signed will change, and even though it was signed with potentially the same key (could use key2), it will produce a different signature.

This isn't necessarily bad, but it is more common to see a business or vendor generate new script/addresses for each payment they receive so it can be easily tracked and verified.


Why do aggregate Schnorr signatures reverse the hash and the random number A bitcoin signature has:
z = hash(m)

Using a private key pk we can generate a signature for message m
consisting of two numbers: r (x coordinate of the random point R =
k×G) and s = (z+r⋅pk)/k. Then, using our public key P = pk×G anyone
can verify our signature by checking that point (z/s)×G+(r/s)×P has x
coordinate equal to r.

Aggregate Schnorr has:

Call L = H(X1,X2,…)
Each signer chooses a random nonce ri, and shares Ri = riG with the other signers
Call R the sum of the Ri points
Each signer computes si = ri + H(L,Xi,R,m)xi
The final signature is (R,s) where s is the sum of the si values
Verification requires sG = R + H(L,X1,R,m)X1 + H(L,X2,R,m)X2 + …

Why do the hash and the random value swap places in the aggregate Schnorr sig?

Schnorr signatures were patented by their creator, Claus Schnorr, and required permission from him in order to be used. The Digital Signature Algorithm (DSA) is similar to the Schnor signature scheme but is made available publicly for free by the US government.

DSA is largely an alternative to Schnorr and needed to be different enough from it so that it would not violate Schnorr's patent. Part of this is different signing and verification formulas.

So what you are seeing is part of the difference between DSA and Schnorr. Bitcoin currently uses DSA over an Elliptic Curve (ECDSA) and the proposed bip-schnorr uses Schnorr signatures over an Elliptic Curve. Thus the differences that you are seeing are because ECDSA and EC-Schnorr are two different algorithms designed to avoid each other's patents.


Digital wallet hard disk space If I delete any of my digital desktop wallet and of course without any digital coins stored in them, Will my hard disk become spaced out of all those GB taken by the blockchain stored in my computer?

It depends.

If you're concerned about disk fragmentation, you can run a disk defragmenter. In Windows Vista and later, this is done automatically if your PC is on overnight. If you're using a recent version of Linux, (if the filesystem uses ext2 or better) this isn't necessary either. If you're using a solid state drive, this won't help, because it doesn't have the long seeking times of spinning hard drives. This article tells you how to start the disk defragmenter on Windows manually.

In general, it doesn't matter very much.


Where change the size of the window in Bitcoin code? I already try changeing the height and width parameters of the forms in src/qt/forms but nothing changes, where else i need to look?

Open one of the .ui files from /src/qt/forms in Qt Designer

Press CTRL+O or click on [Form] -> [Break Layout]

Resize the form and different objects accordingly

Compile and run bitcoin-qt

I changed width and height in minimumSize property and same in geometry. Also made few changes in rpcconsole.cpp because I removed some objects, its not related to resizing the forms.


Bitfinex REST API v2.0 modify orders I am not sure if this is the right place for this kind of question, but there is no general crypto currency stack ...

I am developing an application which accesses Bitfinex data and also should be able to modify Bitfinex data and I am using the REST API to achieve this.

But all endpoints I see in https://bitfinex.readme.io/v2/reference are only read endpoints and do not modify orders or create/delete orders. Is this not possible in v2? Can I simply use the v1 endpoints for this or is this deprecated? I don't want to use the Websocket which is able to modify /create new orders.

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.


Extremely slow syncing speed while starting bitcoin-qt on HDD I'm sorry for adding dupelicate question (e.g. How to speed up initial block chain sync using SSD without wasting space?), but I observered a dramatical speed increase while using RAMDisk or some disk cache enhancement software (like PrimoCache).

I've enlarged database cache size up to 2048MB, it didn't seem to help. (about
only 2blocks/min, HDD active time 100%)

I created a 5GB ramdisk (vs 16GB total RAM on my PC) using ImDisk, then chainstate was moved into this ramdisk by creating NTFS junction (mklink /j). After such operations, bitcoin-qt seemed to be boosted up quite a bit(about 60 blocks/min, while HDD seemed to be quite idle).

I wonder if there is any smarter way to do this? Using RAMDisk to accomplish such "boost" seemed to be too awkward.

When you say smarter, you mean by not storing chainstate on a disposable drive? Unless ImDisk stores to HDD on shutdown.

Try this answer.


How do I read the contents of wallet.dat in C# I'd like to be able to add, remove, export etc. keypairs from my wallet.dat file. Looking over the source code of pywallet it doesn't look like such a tough task, but of course it's not as simple as from bsddb.db import * in C# and Google is failing me. Does anyone have some sample code or resources for how to handle wallet.dat in C#?

Wallet.dat is a Berkeley DB file.  You could check out Berkeley DB for .NET to see if it is able to read the file.


Where do the BCC go if an exchange doesn’t “support” it? So, it’s my understanding that any and all bitcoins will be duplicated on the BCC chain. So for all the exchanges that don’t support BCC, will they just pocket the coins? Especially since many of them have the user’s private keys?

Sorry if this shows a lack of understanding of the fork and blockchain, please enlighten me if I am confused.

As one popular Bitcoin advocate puts it, "your keys -- your bitcoin, not your keys -- not your bitcoin". Yes, the exchange can pocket your BCC, as well as it technically can pocket your BTC.

Even if an exchange declares BCC support, beware of accounting issues.


can I use bit coin to pay my overseas customers I have a business where I have to pay customers on other countries , I want to have the ability to transfer my funds to a bank in another country with out having to pay the high bank fees for transferring funds

Absolutely! Bitcoin can be transferred peer to peer, to anyone over the net.

Now, you should note that:

Bitcoin is very volatile.
Bitcoin is very congested and slow these days, using litecoin or ethereum may be a better pick at the moment.

Also too, you will need to make sure your oversea customers will accept bitcoin payments. Some countries do not have a online exchange available to cash in bitcoins, so it is very important to tell your customers if bitcoin payments are ok.

tl;dr - yes, you can send bitcoin payments to anyone, in any country as long as they accept it. Then, your customer can optionally choose to cash it at a online exchange available to him for fiat cash.


How to send everything in a bitcoind account? I have create an account in bitcoind, which has got some balance of 1.77 btc, I would like to send everything to another address that is an admin address, so is there any rpc method to send everything or need to do  transaction fee calculation for this.  If transaction fee calculation has to be done, please let me know the calcuation, this particualar func has to be impl in my backend for a platform.

I would highly recommend that you not use the accounts system as it is deprecated and has been removed for Bitcoin Core 0.17 and beyond. Furthermore, the way that you want to use the accounts system is not how it actually works. Accounts are only associated with addresses for receiving; for spending, when you "send from" an account, all that happens is the numbers for the account are deducted, not that addresses that were associated with the account for receiving are the ones actually used in the inputs.

To send everything from an account, just use the sendfrom command with the balance of the account. This will change the accounting entries so that that account is deducted however much you sent. Note that this will not necessarily choose the inputs that you think are associated with the account; it can choose any input in the wallet to create the transaction. However if you call getbalance <account>, you will see the account's balance be 0.


Does using Ripple to accept Bitcoin reduce risk of Bitcoin fraud? Does Ripple reduce the risk of double-spending, or other types of issues that may crop up when using Bitcoin natively?

With Bitcoin there are various ways to mitigate the risks and issues you mention to allow some use of payments with zero confirmations instead of waiting for sufficient confirmations to be sure the payment is irreversible.

With Ripple, once a transaction is validated it is irreversible. Ripple transactions usually validate within seconds (5-20 seconds depending on various things). So no such mitigation is required and double spends and related issues are not a problem.

However, within Ripple for any currency other than native XRP, the balance/asset that is irreversibly transferred is a balance with another party. Until you redeem that balance (or spend/trade it within Ripple) you have counter-party risks that bitcoin doesn't have (at least bitcoin in wallet/address you directly control). Although the risks are explicitly limited by "trust lines" you've setup in Ripple (e.g. you may trust Bitstamp for 10 BTC and DividendRippler for 2 BTC) and require no trust in the payment sender.

This risk is analogous to receiving PayPal or BitPay payments. Until they transfer your funds to your bank (and possibly even after that depending on your bank) you're relying on them to make good on their balance to you. Also analogous to using a hosted Bitcoin wallet or other intermediary service where you rely on that party to hold your funds temporarily.


Why public Electrum servers serving on websocket (WS) are so rare? Couldn't find a single one. Only TCP or TLS.
Am I looking in the wrong place? ( https://1209k.com/bitcoin-eye/ele.php?chain=btc )

They are rare because Electrum and all the other wallets using the protocol do not support it client-side, so nobody setting up an ElectrumX server has any incentive to enable this. ElectrumX requires you to enable individual protocols explicitly. Furthermore, as you can see in the changelog they have only been supported since May 2019.


Have there been attempts at a Bitcoin-powered general purpose database? https://en.bitcoin.it/wiki/Bitcoin-Powered_Database

As far I know, the Bitcoin blockchain is pretty much the only data structure that is both global and tamper-proof.

global - There is one global instance of the blockchain (up to forks ... which are then resolved).
tamper-proof - If a block enters the blockchain, after 6+ confirmations this block can't feasibly be faked or altered.

A Bitcoin-powered database would be an API over the blockchain, that would expose a subset of the usual CRUD database operations. In fact, it would be an append-only data structure, because nothing can ever be really deleted from the blockchain - so only CREATE and READ operations will be implemented. Object Versioning will be used to emulate updates and deletions.

Have there been previous attempts to create such a database? I have seen the MerkleWeb proposal, but I haven't really understood it, so I'm not sure if it answers my question.

This is it - the CryptoSphere.

It uses some Bitcoin concepts, and might support paying for storage using Bitcoins. I believe that "merge-mining it" using the Bitcoin blockchain would be possible (it's too soon to tell, the design is preliminary).


Tax deduction for US-based employer paying in Bitcoin to overseas contractor My employer can write off business expenses (my salary) if he pays me via wire transfer, PayPal, Payoneer and some other international payment systems. Is there a tax-deductible method for him to buy Bitcoin and send it to my wallet (or to my account from where I can withdraw to my wallet)?

I'm no good in legal terms, so feel free to edit the question if you understand what I'm talking about.

I don't at all see why he couldn't purchase bitcoin through Coinbase or similar and deduct it. That should be entirely deductible, even the fees paid to buy the bitcoin (bank fees plus whatever Coinbase is charging these days).


How can I connect to the Lightning Network on Litecoin's testnet? I installed the software but cannot find any nodes to connect to on testnet. There is a website with mainnet nodes but not testnet. Does anyone know where I can find some testnet nodes?

If you go onto IRC #litecoin-dev and ask for pwkad, I believe he is running one.


Authoritative list of Bitcoin resources? Has any website compiled a reasonably authoritative and trustworthy list of Bitcoin resources? I'm building an appendix for my course and I'd like to see if I missed anything.

https://www.udemy.com/bitcoin-or-how-i-learned-to-stop-worrying-and-love-crypto/

Edit:

To address Nick's concerns, let me clarify the purpose of this question. I am not asking for your favorite Bitcoin links. I am asking for authoritative and trustworthy lists of Bitcoin resources. For example: https://www.spendbitcoins.com/places/ is a reasonably trustworthy list of bitcoin commerce sites.

There are four really authoritative places for Bitcoin-related information that I can think of.

The Bitcoin.org homepage, which is managed by the core Bitcoin developers. All names listed on that site and references made can be considered authoritative.
BitcoinTalk.org, this was the homepage for the Bitcoin community from the start. Most of the first ideas were created here and still this is the best place to get information from other authoritative people strongly related to Bitcoin.
The Bitcoin Wiki, were you can find all technical specifications of the protocol as well as more basic information about how to buy, sell or use bitcoins. The wiki is maintained by the developers as well as insiders that helped shaping the protocol.
Bitcoin on GitHub, were development of the main client happens and all changes to the protocol are implemented for the first time. You can also find a link to this place on the Bitcoin homepage.


Who is the decision body for forking a blockchain ledger? Is it fair to compare the decision body responsible for forking a blockchain as 'escrow officers'? How can users of the blockchain network dare to the treat the distributed ledger as immutable as long as forking (ledger tampering) exists as a corrective measure? Who are these people and how who holds them accountable?

First of all, it is important to distinguish between multiple things, all of which are often called 'forks'.

The existence of two or more competing versions of history. These happen unintentionally in proof-of-work consensus systems when two miners produce a candidate block around the same time. These get resolved automatically.
Software projects branching off from another one. These are not generally (but could be) associated with a change to the ledger/rules.
A change in the rules about the validity of blocks (which additions to the ledger are accepted).

My view is that in a perfect world, (3) would never be necessary. We would all agree on what properties the system should have, encode those into software, and never touch those rules again. Reality is different of course, and sometimes changes to the system's rules are necessary - due to improve the technology, or to prevent against certain weaknesses or attacks. However, I do feel that cryptocurrencies (in general, as a research topic) intend to approach that goal, and are an experiment in building a system that lacks the need for human control. One of its value propositions is the prospect of creating a monetary system that is beyond control.

So how do we accomplish that? Clearly developers of node software that implements these rules have a strong influence over how it works. However, this influence is not absolute control. When you run a fully validating node, it comes with certain rules programmed in. It won't ever accept a chain of blocks that doesn't satisfy those rules. Only its operator can change that software to another version which has different rules. Developers can of course publish new versions that changes things, but they need to take into account that not everyone may update. Depending on the type of change, if significant (and not necessary large) parts of the ecosystem choose to not adopt an update, this can cause the ledger to split (where the result is 2 separate currencies, with each pre-existing coin spendable once on both sides). This risk is a strong deterrent to adopting changes, unless it is clear that those changes will be universally accepted.

So to answer your question:

  Who are these people and how who holds them accountable?

You are.

Cryptocurrencies have the unique property that all of the system's rules are verifiable by everyone. By running software that implements the rules you want, you know that the system maintains those properties. Anyone who wishes to change these will at least need to convince you to change your software (this is why Bitcoin Core intentionally does not have an auto-update function, for example - it would place far too much power in whomever has control over the auto-update server).


Is an SSD required to run a bitcoin full node and a lightning node? To run a full node and lightning node, I always read that people should use SSDs. Is that really required? And why is that? It's a slowly growing blockchain after all.
I would have everything for an umbrel node, except a big enough spare SSD.

A SSD is not required for running Bitcoin, but it certainly helps. You would definitely want one if you were running a production service using Bitcoin, but for something you're using personally it will just make synchronization substantially slower to use a hard drive. For a Raspberry Pi you absolutely do not want to be storing any data on the Micro SD card it uses as a boot disk, as this will result in corruption at some point.


What are the contents of the wallet.dat file? What is Key pool, default key and reserve keys? There is this https://en.bitcoin.it/wiki/Wallet simple explanation of the contents of a wallet.dat file from bitcoin-core/bitcoin-qt.

I have some questions about this:

What is the default key? Does this refer to the address is use by default for spending bitcoins? So, does it refer to the private key?
What are reserve keys? Are these the public/privte keypairs representing my addresses? But why reserve?
What is the Key pool? Is it a collection of addresses (i.e. private/public keypairs), and if so, why are they pregenerated, if I can generate a new address at any time with no cost?

So, if I have two addresses in use in my bitcoin-core client, does that mean, that I am using 2 keypairs from the keypool? And the others are just not showing yet in the user interface, but are already created?

What does the following sentence mean (it is refering to the key pool):

This pooling feature was added so backups of the wallet would have a certain number of keys that would be used in the future.

The page you are referring to on the Bitcoin wiki is pretty dated and doesn't really relate to current behavior in Bitcoin Core. Be aware that a lot of the wiki is like this. "Default key" isn't a phrase in common use, I can't fathom what that page could have been talking about in the context of Bitcoin Core.

Reserve keys and the keypool are essentially one and the same. The concept is born out of the problem that people would make a wallet backup, create a few new addresses and receive coins there, restore from a day old backup and find that all their money had disappeared.

The basic solution is to pre-generate a number of addresses and store them in the wallet file, when the client needs a new address it uses the oldest fresh key it has available. The resulting wallet file backup can be safe for as many future transactions as there are keys in the keypool (100 has been the default for a long time), after which point the backup will again become stale and money lost if the user has to recover from it. It's important to keep in mind that making outgoing transactions also consumes a reserved key as one needs to be used for a change address as well, this property makes it difficult for users to know when they need to make a new backup.

The keypool design prevents some very simple mistakes, but it's still easy to lose money to poor backup practices. Hierarchical Deterministic (BIP32) wallets are significantly safer as the backups never become stake, and this is instead used in more modern wallets. The Bitcoin Core wallet tends to be the most conservative and so is slow to move away from the keypool, but it will eventually happen.


How data is searched in blockchain? Alice has 500$ and bob has 1000$. Now alice wants to transfer 100$ to bob. Miners who got the chance to validate the transaction has to check whether alice have sufficient balance or not.
where are these alice and bob balances are stored? If they are stored in the block chain, how balance is retrieved? Does entire block chain is searched to find their balance and validate and update? or block where these balances are stored is kept track any where else?

Response really helps,
Thank you.

Alice has 500$

It is better to suggest "Alice has 500 mBTC" because amounts in the blockchain are not dollar-denominated.

  Miners who got the chance to validate the transaction has to check whether alice have sufficient balance or not.

No they dont.

Miners don't care about balances.

Miners only care whether Alice has provided proof¹ that she holds the private keys required by the scripts in the transaction inputs.

Other nodes validating blocks also don't care about balances.

In accounting terms, the blockchain is a transaction journal, not a ledger. It does not keep track of balances held by people. By processing the journal you can calculate a current amount for each Bitcoin address. Note that not all transactions use Bitcoin addresses. These addresses are merely an artifact of certain commonly used scripts. Scripts don't have to contain data that is conceptually an address.

  where are these alice and bob balances are stored?

Not in the blockchain.

  how balance is retrieved?

It isn't, not by miners and no one other than Alice ever retrieves Alice's total balance.

  Does entire block chain is searched to find their balance and validate and update?

No.

  or block where these balances are stored is kept track any where else?

No.

Alice's wallet might keep a separate record in memory and committed to local disk in some proprietary form. That would probably be sensible for performance reasons but is not required..

Footnotes

Proof

When Alice uses her wallet to pay 500 mBTC to Bob, her wallet checks its list of unspent transaction outputs (UTXOs) for the bitcoin-addresses that Alice has contol of in her wallet. It uses as many of these as are needed to add up to 500 mBTC plus the selected transaction fee. It constructs a transaction which lists these selected UTXOs as inputs and lists outputs including a 500 mBTC output to one of Bob's bitcoin-addresses and an output to one of Alice's bitcoin-addresses for the unused "change". The transaction includes cryptographic "signatures" made using Alice's private key(s) which proves she controls those UTXOs used as inputs and which can be checked (validated) by other people's wallets by using Alice's published public keys. These signatures by ALice's wallet satisfy the Bitcoin-scripts that are part of the UTXOs which Alice's wallet is using to make the payment.

Note that there is no need to calculate a sufficient balance. When Alice pays Bob $17 using a $10 note† and two $5 notes, Bob doesn't need to know haw many other dollar notes Alice has in her purse. He just needs to check the notes she gave him look real. Alice needs to make sure she gets $3 in change.

† US: bill; Rest-of-English-speaking-world: banknote.


How to add a second user with SSH access to my Ubuntu PC running Bitcoin Core? I have a friend who is interested in learning Bitcoin CLI, and I told him I would look into giving him access to my node - in a non-destructive way - perhaps testnet only ?

Totally trust this person, we work together closely on many projects, and he's interested in learning about the network but doesn't have the means to set up a full node himself. I tried lots of searching but couldn't find a clear response.

I want to preserve the integrity of my node, not give him access to my user account, but let him use it for educational purposes.

Any kind souls have a guide on this process?

You don't need to grant someone access to the entire machine to be able to use bitcoin-cli. You can provision credentials using the rpcauth parameter in bitcoin.conf (it may be defined multiple times for multiple username/password combinations), and whitelist their IP address for the port you are running the bitcoin RPC on.

They can then use a local bitcoin-cli binary along with the -rpcport and -rpcconnect options to use a remote bitcoind instance.

Naturally, you should avoid leaving unlocked wallets on this server, as anyone with RPC access may spend your coins. It should be treated as a read only instance.


Test Network Genesis Block I am using BitcoinJ for my java application which fetches the test network's genesis block. I referred to the basics mentioned at JavaWorld and BitcoinJ's Google Code wiki.

I am able to get it running but there seems to be an error while waiting for the node.

I receive the following output :

[main] INFO com.google.bitcoin.core.BlockChain - chain head is at height 0:
v1 block:
   previous block: 0000000000000000000000000000000000000000000000000000000000000000
   merkle root: 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
   time: [1296688602] Thu Feb 03 04:46:42 IST 2011
   difficulty target (nBits): 487063544
   nonce: 384568319

[New I/O boss #9] INFO com.google.bitcoin.core.Peer - com.google.bitcoin.core.Peer$PeerHandler@fe64b9 - Connection refused: no further information

Note: I am working from a NAT network, can this be a point of connection failure?

According to OP's comments

  I checked with my network admin, they were blockling port 8333.

probably meaning port 18333


How can I process Bitcoin transactions in my store? What merchant solutions are available to integrate Bitcoin in an online store? Is there a wiki page that describes the different merchant solutions?

Note - This question was originally asked specifically for a PHP store, but since most solutions are platform-agnostic this part was edited away.

StrongCoin has developed a PHP script for fast handling of micro transactions. You can read more on it here:

https://strongcoin.com/blog/bitcoin_micropayments_with_strongcoin
http://www.thebitcointrader.com/2011/12/monetizing-blog-with-bitcoin.html?m=1


Linking Bitcoin addresses based on a private key - is that possible I have seen a claim as follows:

  [We] apply algorithms to detect which bitcoin addresses are sharing the same private keys. In most cases, this leads to a high-level assertion of certain addresses to be owned and controlled by a single party

is that possible?

What I'm thinking is one private key per one public key
As far as i understand, HD wallets use a seed to create many private/public key pairs, but no two public key shares the same private keys.

Any pointers would be appreciated.

You are correct in thinking that there is only one private key for one public key (or rather that is one of the assumptions that ECDSA relies on). While technically it is possible for a Bitcoin address to have multiple public keys and therefore multiple private keys, this is extremely unlikely to occur as it requires a hash collision. Of course there are guaranteed to be addresses that have multiple public-private keypairs associated with them because there are more keypairs than addresses.

In practice, it is impossible for such a collision to occur so, for all intents and purposes, an address has only one public and private key. It is the same for BIP 32 HD wallets since the seed is used to generate the private keys for each address. There is no known mathematical relation between two child private keys so it is impossible to determine whether two public keys are derived from the same BIP 32 HD seed.

However, BIP 32 is not the only way to derive private keys as basically any string of 256 bits can be a private key. So people may be using other methods to generate their private keys, and those may have mathematical relationships between each other. So it is possible that this claim you have quoted refers to these other ways of generating private keys.

Alternatively this person is simply incorrect and doesn't understand cryptography, or they are trying to scam you.


Generating Output Script from Bitcoin.js or other Javascript Library I'm attempting to use the Ledger Wallet API to sign a multi-sig transaction. The API works as follows:

var inputs = [
  [ "71f97fa2a21486ecd99674a8ae068d92acd2e9db49c199473be39984e6cbe0f6", "00000000" ],
  [ "171e6a969ff196a2cfaaba4780c292e33fc297672a065cc5c5c684727cf9e3ba", "00000001" ]
];

var scripts = [
"52210289b4a3ad52a919abd2bdd6920d8a6879b1e788c38aa76f0440a6f32a9f1996d02103a3393b1439d1693b063482c04bd40142db97bdf139eedd1b51ffb7070a37eac321030b9a409a1e476b0d5d17b804fcdb81cf30f9b99c6f3ae1178206e08bc500639853ae",
"522102afe2165371442437b86089a17e8d1c26d127e3723b19f568e9c11e326946111521032d139518b16c112d5f1a52157f1468c0b7a570c41673debee8cd2e53eb084df12103b13fe78b0320ceb77795c87ed72069f12edf64169d15f8f9827f0bb4fdbe760f53ae"
];

var paths = [
  "44'/0'/0'/0/0/0/1",
  "44'/0'/0'/0/0/0/2",
];

var outputs_number = 2
var outputs_script = "40420f00000000001976a91496986c2703c6b311c884bf916d28621bc61e8b7a88acdc0c03000000000017a914ddf0a9f3e0c9822feef702d36dee6c0bd2bf7c6d87"

Ledger.signP2SH(inputs, scripts, outputs_number, outputs_script, paths);

I have everything working except generating the outputs_script - I know there are ways to construct this manually, but I have to assume there's a mechanism within one of the javascript libraries out there. I found in the bitcoin.js library a method which will turn an address into an output script:

var outScript = bitcoin.address.toOutputScript("1LRVwrvGF6XxQbCzqEBG71cPv9RrF8Uu5P")

But that doesn't incorporate value or multiple addresses. How can I generate just the output script component, for a primary and change address, from a Javascript library?

I wrote a tiny module to do just this: https://github.com/lukechilds/build-output-script

It can be used like so:

const buildOutputScript = require('build-output-script');

buildOutputScript([{address: '1LukeQU5jwebXbMLDVydeH4vFSobRV9rkj', value: 100000000}]);
// '0100e1f505000000001976a914da6473ed373e08f46dd8003fca7ba72fbe9c555e88ac'

You can pass in multiple P2PKH addresses.


What use are ripples? In the Ripple system we have two types of currencies - ripples and all other currencies useful for transacting with people in your web of trust. Ripples are the only currency in the system that can be used for paying transaction fees and transactions between any two users even if they are not connected.

With the discrepancy between the supply of ripples and the size of the fees, spamming the system would be virtually free. This usefulness of ripples is thus moot. Trading between any two peers could be accomplished with Bitcoin, so this use is also limited.

So, with that in mind, what use are ripples really, asides being a way for the developers of the system to monetise?

As explained in this answer fees are not fixed so I don't think that your conclusion about them being useless for spam protection is true.

Other than that I would say that they can be used similar to how Bitcoin is used. They may be a future competitor to Bitcoin even though they are certainly not marketed that way. They are scarce, easy to transfer etc.


How do I get coin supply on Bitcoin core? I've seen in other QT wallets I can get how many coins are in circulation typing a command like  getsupply, they also have this information in the output of the command getblock <hash>.
Is there a way to get this information using a RPC Command on Bitcoin Core?

It depends on what you want.
If you want to know the amount of currency that has been available for miners to bring into circulation (the "210000-1 blocks of 50 BTC, then 210000 blocks of 25 BTC, then 210000 blocks of 12.5 BTC, ..." rule), the answer is no, there is no RPC that computes this. It's easy to do yourself, though.
If you want to compute the amount in circulation, namely the sum of all UTXO values, there is; it is computed by the gettxoutsetinfo command.


Bech32 conversion to legacy P2PKH? Electrum now generates Bech32 addresses for SegWit wallets.

Example: bc1qnntcclssmtuvfw2te7q49lzvw67cfvpzxger4j

Pubkey: 023f1b3421c6ae0c1758834d40806c2418194b507be261fa343a0636653f3ec75b

If I search for that Bech32 address on btc.com, I get redirected to:
https://btc.com/1FJJdX5g1DX7FRxJBhJNTDrRjTeihhsJLs

This pubkey-to-address tool also generates the same address from the above pubkey.

Is it safe to receive funds at this 1FJJd... address?
Is there a downside to using this rather than Bech32?

Is it safe to receive funds at this 1FJJd... address?

Kind of. Your wallet knows the private key that corresponds to that address as it is the same private key for the bech32 address. However it does not necessarily know that it should be looking for coins sent to this address, so any transactions that send coins to that address may not appear in your wallet and thus it will be harder for you to spend those coins.

  Is there a downside to using this rather than Bech32?

As I said earlier, your wallet may not know about that address and thus won't track it. Even if it does, it is better to use the Bech32 address as that means that you will be using Segwit. The transaction fees for a spend from a segwit address will be lower than a similar spend from the non-segwit version of that address.


What is the BIP-44 Coin Type for Dash? BIP-44 compliant HD wallet trees use the m/purpose'/coin_type'/ account'/change/address_index convention to derive private keys and associated addresses. For coin_type, BIP-44 makes a reference to registered coin types.  Will the Darkcoin index of 5 work for Dash?

Compressed DASH private WIF key (Darkcoin v0.6+ stores public keys in compressed format.):
% echo 'very complex gibberish' | bx base16-encode | bx sha256 | bx hd-new | bx hd-private -d -i 44 | bx hd-private -d -i 5 | bx hd-private -d -i 0 | bx hd-private -i 0 | bx hd-private -i 0 | bx hd-to-ec | sed 's/$/01/' | bx base58check-encode -v 204
XH2Yndjv6Ks3XEHGaSMDhUMTAMZTTWv5nEN958Y7VMyQXBCJVQmM

Compressed public address:
% echo 'very complex gibberish' | bx base16-encode | bx sha256 | bx hd-new | bx hd-private -d -i 44 | bx hd-private -d -i 5 | bx hd-private -d -i 0 | bx hd-private -i 0 | bx hd-private -i 0 | bx hd-to-ec | bx ec-to-public    | bx ec-to-address -v 76
Xb9HJy46M9u3SLAWVitS4eV6gEMuVFfZX2

Uncompressed DASH private WIF key:
% echo 'very complex gibberish' | bx base16-encode | bx sha256 | bx hd-new | bx hd-private -d -i 44 | bx hd-private -d -i 5 | bx hd-private -d -i 0 | bx hd-private -i 0 | bx hd-private -i 0 | bx hd-to-ec | bx base58check-encode -v 204
7rrHic4Nzr8iMSfaSFMSXvKgTb7Sw3FHwevGsnD2vYwU5btpXRT

Uncompressed public address:
% echo 'very complex gibberish' | bx base16-encode | bx sha256 | bx hd-new | bx hd-private -d -i 44 | bx hd-private -d -i 5 | bx hd-private -d -i 0 | bx hd-private -i 0 | bx hd-private -i 0 | bx hd-to-ec | bx ec-to-public -u | bx ec-to-address -v 76
XiEsuvDERQJT5S9RF7qcKGrm4omMsJ1PPg

Yes, Dash should continue using the same HD index as Darkcoin. Only the coin name is changed.

So 5h is the correct HD index for Dash.


Which clients support nLockTime? I want to use nLockTime, but I don't know what clients support it?

No standard client supports NLockTime directly AFAIK.

You can create raw transactions with bitcoind and then use a standard client to transmit them to the network in the method described here


Password-based bitcoin transactions I have been reading about the role of script in transactions and I gather it should be possible to do a Bitcoin transfer to a receiver who knows a password. Instead of checking an address, the script would check that the hash of an input corresponds to the value given by the sender.

I have a few doubts on how this would work exactly. The script I have in mind, following the notation used in https://en.bitcoin.it/wiki/Script for standard and IP transactions, is:

scriptPubKey: OP_HASH160 <passwordHash> OP_EQUALVERIFY OP_CHECKSIG
scriptSig: <sig><pubKey><password>

The transfer would have six steps:

- Stack: Empty  Script: <sig><pubKey><password> OP_HASH160 <passwordHash> OP_EQUALVERIFY OP_CHECKSIG
- Stack: <sig><pubKey><password>  Script: OP_HASH160 <passwordHash> OP_EQUALVERIFY OP_CHECKSIG
- Stack: <sig><pubKey><passwordhashA>  Script: <passwordHash> OP_EQUALVERIFY OP_CHECKSIG
- Stack: <sig><pubKey><passwordhashA><passwordHash>  Script:  OP_EQUALVERIFY OP_CHECKSIG
- Stack: <sig><pubKey>   Script:  OP_CHECKSIG
- Stack: true   Script:  Empty

I have left OP_HASH160 because it is already being used so no new operation is needed, but the other hashes in script should be possible. The protocol has some nice properties like making the password public when the coins are transferred.

Is this code correct? Is there something similar in the blockchain? I would like to try it, but I'm not really sure how to connect to the network with such a script. Should I first create a transaction to a "Bitcoin Limbo" and then try to recover it to the final address?

What if somebody sees the password as the transaction is being relayed around, and makes a new version that transfers your bitcoins to them? If they have better network integration/a higher bandwidth connection, then their version might be able to overtake yours.


Could the "pizza guy" sue now had he not received the pizza? Let's pretend the guy that spent 10k BTC on a pizza in 2010 did not receive his pizza back in the day (basically got scammed). He shrugged it off as it was only ~20$.
He forgets about it, and notice now that a single bitcoin is valued at around 60k!
Would he be able to sue now 11 years later to get his 10k BTC back, or could he only hope to get back 20$ ?

No, he wouldn't be able to sue.

Basically the Statute of limitations for scam is 5 years, after this delay the claim can be dropped in court.

Even if he still went for it, he would only be entitled to the USD value of the transaction at that moment. It would be unreasonable to ask for a refund 10000x the price that was paid, see I paid in bitcoin, now I'm owed a refund. Can I demand it in bitcoin too?


Can I addnode to blockchain.info? Blockchain.info http://blockchain.info/connected-nodes shows a list of nodes it is connected to. Is it possible for me to add them as a node for connection?

As mentioned in Daniel's comment, if you are trying to connect to the Bitcoin-client that gathers the information for the Blockchain.info site this is not trivial as the IP does not match the one of the website.

If you are just interested in adding the same nodes the site is connected to, that's no problem.

With Linux or OS X you'd do something like this:

curl -s https://blockchain.info/connected-nodes | \
grep -oE '([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)' | \
sort -u

which gives you a sorted list of IPs to connect to. If you want a complete string to just append to your bitcoind client as options then try this:

curl -s https://blockchain.info/connected-nodes | \
grep -oE '([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)' | \
sort -u | \
sed 's/.*/-addnode=&/g' | \
tr '\n' ' '

this additionally adds the -addnode= prefix to each address and joins the line.


api for buy/sell bitcoin I have recently started a project to build an exchange plateform. I am unable to find an API that provides me an ability to implement a feature to buy and sell bitcoins.

Can someone please let me know

if an api is available to provide this feature.
also if i were to test it, how would i go towards testing that feature.

I have seen some api where there are end points available but it is very risky if end points are changed.

I will really appreciate your help.

Thanks,

A simple google search does the trick.

There are mutiple APIs from major crypto currency exchanges:

CoinBase API
Kraken API


How create / generate a coinbase transaction for a new block? I am coding a miner program with C, and right now I need some info of how create / generate a coinbase transaction to add to the block before submit it to the bitcoin network. Someone can indicate any article / tutorial explaining this (i am searching for this for a while now, and finding nothing useful of this sorts).

The coinbase transaction is like every other transaction except it has only 1 special coinbase input which you can read about here: https://bitcoin.org/en/developer-reference#coinbase. The outputs must have a value which sum to the block subsidy (currently 12.5) plus any transaction fees in the block. Those are the only stipulations for a coinbase transaction.


npm / node mining for litecoins UPDATED AND CLARIFIED AND SIMPLIFIED

I'm looking through npmjs.org - My thought is can a node.js server mine (without a graphics card just using its own possessing power?) If so (there are a lot of modules for different things to do with statum) has anyone else done this?

I'm having difficulty understanding things with these npm modules on how to get them hooked up the same as my batch file (.bat) currently using cgminner ( I don't want to use cgminner just node.js)

my .bat for cgminer looks something like this:

cgminer.exe --scrypt -u example.1 -p x -o stratum+tcp://united.wemineltc.com:3334 --gpu-platform 0 -w 256 -v 1 -I 17 -g 1 -l 1 --thread-concurrency 6496

does anyone use node.js for this
can someone show me which npm modules mine
can someone show me how to add my bat details to a npm node module js script

Thanks Guys!

The answer to this is yes, it will. Mining can be done on most turing-complete languages like Javascript. But the true question is how useful is a JavaScript miner. Not to mention Node.js is optimized towards asynchronicity, something which heavy math equations that mining requires aren't. Node.js isn't suitable for CPU heavy tasks but it flies when dealing with many requests at the same time. For this reason there aren't many miners built on Node.js/Javascript. A miner written in C++ is your best bet, such as CGMiner.


How to pay via Bitpay I'm trying to develop an app which integrates with the Bitpay API.
I managed to create an invoice which contains the URL in which to pay with Bitcoins:

But the problem is when I click on the Pay with Bitcoin button it redirects me to an address similar to this one:

bitcoin:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx?amount=0.0012

Is this really how its supposed to work? How do I actually pay and complete the transaction? Can you walk me through the process of paying via Bitpay?
Please enlighten me, thanks in advance!

Yes this is expected behavior, it will be handled by applications that register the bitcoin URI, particularly this is prevalent in mobile clients.  Here is a couple links with more information on this topic:

https://bitcointalk.org/index.php?topic=187597.0

http://electrum.org/bitcoin_URIs.html


How can I load a specific private key into my wallet Starting a Private Node using bitcoin-qt.
And then I generate a pair of keys for my own testing.
But unfortunately whenever I reset the node, it will generate a new pairs of keys, it makes my recursive test very tedious.
Is there a way for me to load a private key into my wallet instead of using getnewaddress every time and test with a new pair of keys?


What is the "misbehaving" log message? I was looking my bitcoind log and I saw this message:

Misbehaving: 91.230.200.131:8333 (90 -> 100) BAN THRESHOLD EXCEEDED

In which cases this message is shown and why?

It just a curiosity.

If some client's actions do not correspond with the Bitcoin protocol in a disruptive manner (e.g. flooding with invalid messages) a ban counter is increased depending on the seriousness of the violation of the protocol. When the ban meter reaches some predefined value (can be set with the -banscore option in bitcoind, default is 100) connection to that client is interrupted for a day (that's the default at least, but again, this can be changed with the -bantime option).

The values used are arbitrary (e.g. 100). It all about relativity. I don't know exactly how much penalty you get for which violation, but this can be found in the source code. If someone feels the need to compile a list of the amount of penalty per violation, please edit this answer.


Do legacy nodes receive the witness fields of a Segwit transactions? My question  comes from not understanding how BIP 144 works? Regarding the BIP what I ask is, whether legacy nodes support the new parser, so that they treat Segwit tranasctions as valid? There it is stated:

  Parsers supporting this BIP will be able to distinguish between the old serialization format (without the witness) and this one. The marker byte is set to zero so that this structure will never parse as a valid transaction in a parser that does not support this BIP. If parsing were to succeed, such a transaction would contain no inputs and a single output.

In relation to my main question, I could not understand how legacy nodes treat the witness fields of a segwit transaction?

Legacy nodes (that is, nodes before segwit) do not receive witness data.

Witness data is a separate data structure. It is only relayed if a node asks for it.

Older nodes don't know it exists, so they don't ask for it, and thus don't receive it.

Since segwit data does not contribute to the txid, old nodes can receive the regular block and still validate it as normal. They just interpret the segwit inputs as "anyone-can-spend" equivalents.


Where do exactly bitcoins exist? If Someone has bitcoin in a Wallet, then suppose that the company of the wallet get closed or finished work or destroyed, how could one restore his bitcoin?

Where exactly do the bitcoins exist? Are they "exist" in the blockchain and can be resored from there?

Bitcoins are stored in the blockchain in the form of unspent transaction outputs, i.e. the product of confirmed transactions. These unspent transaction outputs can be spent if you control the private key corresponding to the address they were signed over to. If a private key is lost irretrievably, the coins will never become spendable again. There is no key recovery service. You're responsible of creating sufficient backups and keeping your private keys safe.

If a company shuts down their service, they should pay out any remaining balances to their users. If they have full custody and go out of business without returning balances, you're probably (depending on the exact circumstances) out ouf luck.


What does the listaddressgroupings rpc method do? Can anyone please explain the listaddressgroupings rpc method? Its documentation isn't clear in Bitcoin Core

Lists groups of addresses which have had their common ownership
made public by common use as inputs or as the resulting change
in past transactions

Result:
[
  [
    [
      "bitcoinaddress",     (string) The bitcoin address
      amount,                 (numeric) The amount in btc
      "account"             (string, optional) The account
    ]
    ,...
  ]
  ,...
]

????

listaddressgroupings is a RPC call that really could have been left an internal method, but the core devs decided to expose it in order to give users more control and awareness of Bitcoin's privacy issues.

Let me explain:

As you probably know, when you make a purchase, the bitcoind or bitcoin-qt client (which both use bitcoin-core) return your change by default to a new address.  Well, if decide to use that address for another transaction, you have created a chain of "connectable" transactions.  If you're not careful, there are various other ways that you can create connected transactions (like always using the same receiving address).  However, if you already generate a new address to receive Bitcoins, this isn't a problem.

There are already numerous programs available that have the ability to scan the blockchain and list such connected transaction chains, which are definite proof that the addresses in question are or have been in the same wallet.

listaddressgroupings is a method that allow users to have the same ability to discern which groups of their addresses are connected on the public blockchain.  It allows users to use the (relatively) new coin control functionality with greater awareness of potential privacy-revealing issues.


Calculate Segwit address from public address I would like to calculate the segwit address of a public address.

First step:
take the compressed public address:
1L88S26C5oyjL1gkXsBeYwHHjvGvCcidr9

do a sha256 on that address:
151de228f6bec7635097f7813786830505d04bf56806f11eb056441fdc917d41

do a ripemd160:
9bbfb2424372d687cf35fd7d1e978f85a11157ca

encode with Base58:
usT1ggHqtEAcGd4ZysWqtxaaQmT

There is something wrong since every segwit address should start with "3". Can someone help me which step it is?

My source of how a segwit address is calculated is: How to get legacy address and private key from Segwit P2SH address? Quote:

  You have the private key so you can just derive the address from there. Get the corresponding public key, hash it with SHA256 and then that result with RIPEMD160. Then perform Base58Check Encoding on it.

Firstly, it is very dangerous to convert a public address to a different form and then use it, because the owner of that address will not be expecting payments on other forms, and could result in fund loss. Only use addresses which the recipient has asked you to use.

But there is a difference between a compressed public key and an address. Bitcoin addresses starting with 1 are base58 encoded keyhash with a checksum. To get the key hash which is the ripemd/sha256 hash of the public key, you must decode the base58 and ensure the checksum is correct. Then you simply use the keyhash in the redeem script, you don't need to perform any more hashing on it to form the P2WPKH script. Notice that there is no way to know if an address starting with a 1 used a compressed or uncompressed public key before it's spent, so if you tried to convert one which had an uncompressed key, it would be unspendable, very dangerous as I said earlier.

See here for more details: https://bitcoincore.org/en/segwit_wallet_dev/#creation-of-p2sh-p2wpkh-address


Why can't we expire two year old transactions? I understand any output in blockchain can be left un-redeemed forever. But If we expire all transactions that are more than two years old (specifically after some number of blocks), there are some benefits

Recycle lost/destroyed bitcoins by giving them back to miners
Miners will continue to get more transactions and thus more fees
Number of unspend transactions may become less speeding up verification
Size of blockchain to keep downloaded can be minimized
Broken cryptographic hahes/signatures can be made obsolute
New features can be easily introduced

Are there any alt coins that consider these? What are the advantages of keeping all transactions valid since genesis block?

One big reason against this sort of thing is that it creates a huge incentive for bad people to try to prevent you to do transactions (censor you).

If miners get the "lost" bitcoins they might simply refuse transactions with coins that are almost expired hoping to get a bigger reward later.
If miners don't get them but they are truly lost forever, then there is an incentive for big stakeholders to try to do the same thing: less coins means the value of everyone else's coins goes up.
It gives governments and other mafia huge power: don't want to comply? We'll just lock you up for 2 years and make your coins expire. Or more "humanely" use other censorship tricks (hacking/digital censoring) to prevent you from spending your coins before they expire.

Another reason is that people will en mass set up automated scripts to move all their coins regularly, which is a big security (and privacy) risk. It's much easier to keep private keys safe (on a piece of paper in a vault) than it is to keep an internet connected system powered up and safe 24/7.


How do I use walletnotify? I have bitcoin daemon and I want to use the walletnotify option with a json-rpc call. Some of the examples use a "transaction.sh" file for walletnotify. What is it for?

What do I have to write in that sh file, to make walletnotify work for more than 6 confirmations.

First you must configure your bitcoin.conf file for JSON-RPC

rpcallowip=127.0.0.1
rpcuser=yourusername
rpcpassword=reallystrongpasswordthatsnothis
rpcport=7788
walletnotify=/home/scripts/transaction.sh %s

Where transaction.sh is some bash program. One approach is to have it make an http request to some process to notify you of the deposit. An example:

#!/bin/sh
curl -d "txid=$1" http://127.0.0.1/some/route

walletnotify will execute transaction.sh every time you either

receive bitcoin
send bitcoin
when a bitcoin gets its first confirmation

%s is the transaction ID or txid which gets passed to transaction.sh.


How much power and cost do miners currently expend to mine one bitcoin? How much are mining pools currently spending on mining per BTC?

Power usage per GH/s changes with every new ASIC product.

I believe the Antminer S9 is probably still the state-of-the-art in december 2016. Batch 23 of this miner does 14 TH/s with 1372W +10% (at the wall, with Bitmain’s APW3 PSU,93% efficiency, 25°C ambient temp)

The price for mining hardware changes all the time. But now in december 2016 around 0.12-0.13 USD per GH/s should be expected. That's including the necessary power supply but not including shipping.

Of course there are people on ebay who will sell you a 1 GH/s USB stick for 10 USD. Not only do they cost way too much per GH/s but the power usage per GH/s will also be very high.

The price for electricity of course varies around the world.

Some miners get good deals buying mining hardware in large quantities and have special deals with power companies for very cheap electricity. Those deals will probably not be revealed. So we won't know the actual cost for a big miner to produce one bitcoin.

Keep in mind that some big miners are also manufacturers of bitcoin miners. If customers buy hardware from you, paying for the cost of having the chips designed and put in production, then you can make some extra machines for yourself very cheaply. If you can combine this with a good deal on electricity, then you can mine extremely cheaply. Unfortunately your mining will push up the difficulty which in turn hurts your customers who bought miners from you.


How to keep my shares when moving a pool server? I have a question...

If I'm mining with a litecoind/bitcoind process, and a pushpool. How can i move the whole shablam to a new server/copmputer WHILEST saving the progress I have on this current round?
Also, can i move the litecoind/bitcoind and/or pushpoold service and files without having to rebuild them from source on the new machine?

Help is highly appriciated!

If you're the only person using the pool server, it doesn't matter how many shares you have -- all the profits are yours. Who would you be sharing them with?


Is there some resourses where I can sell pc time for mining? is there some resourses where I can sell pc time for mining. I'm not talking about project where people set "some software" on pc and recive 1$ per day, that was popular on time low cost mining of bitcoin and where people even don't know that they mine bitcoins. I`m talking of market where people fully understand what they do. I know about cex.io, but there you buy and sell power of hoster, not your personal calculating power. The only place what I found is ebay, where from time to time people sell their calculate power for hours or days. Anything similar?

A PC's general purpose CPU is so far outclassed by specialized mining chips (ASIC's) that its value for mining is almost null. Perhaps the only instance where a PC could be useful for mining is at the very beginning of a crypto-currencies life cycle, when has just been launched, and very few are mining it. But when ASIC mining hardware joins the coin's network, difficulty will rise and render CPU miners inconsequential.
If you expand the definition of PC to include ASIC mining hardware, then the idea of selling hash power is interesting though. I found the following reference to this idea: https://en.bitcoin.it/wiki/Hash_Market


Port 8333 and Issues to have a connection So, I have a website, and that website is going to use Bitcoins. Right now, I'm trying to connect the bitcoin core with the website.

But I have a lot of issues with port 8333:

This is my error: http://prntscr.com/i34pqa
Bitcoin Config file: http://prntscr.com/i34q2e
8333 connections: http://prntscr.com/i34r1o

The bitcoin core I have is on a Linux VPS.

The thing is, I have to be able to connect the website to the bitcoin core, so I have this code in PHP:

include('c.bitcoin.php');
  $bitcoin = new Bitcoin('root','MY PASS','MY VPS SERVER','8333');
  $address = $bitcoin->getnewaddress('Test');
  die($address);

That code works on Localhost, without using the VPS Server Just 127.0.0.1 which means it creates the address :), But when I'm trying to connect it to the bitcoin core that is on my VPS, it doesn't work.

I could open the bitcoin core if I change the rpcport on the bitcoin.conf to another port, like instead of using 8333, we are going to use 8332:
http://prntscr.com/i34vni

And now, we check the node: http://prntscr.com/i34w5a
It's supposed to be working :), But at the end of the day, it doesn't make a connection between my website and the bitcoin core on my VPS.

So I don't know what's going on. I don't know how to solve it, I've tried everything I've found on the internet, but nothing happens. I've written -listen=0, on the bitcoin conf, and I'm not able to connect my website to it yet,

I need this help, I need a big help, Thank you!.

You are conflating the two ports that Bitcoin Core opens and uses.

There is the Bitcoin network port. That is port 8333 by default. You DO NOT want to try to connect to that as it is used for the connection to other nodes on the network.

The port that you do care about is the rpcport. That is port 8332 by default. This is the port that you want to connect to as that is what lets you interface with Bitcoin Core.

If you don't set the port or rpcport options in the bitcoin.conf file, then the default ports will be used.

As a security measure, Bitcoin Core does not allow anyone to connect to the rpcport. You will need to explicitly allow an IP address to connect to it by using the rpcallowip=<ip> option in the bitcoin.conf file. If you set it to 0.0.0.0, it will be open to all IP addresses, but this is not recommended as it is not secure.

In your Qt settings, you have proxies enabled with port 8333. That's incorrect. Those are not the IP and port that you want Bitcoin Core to use but rather that a proxy is listening on those ports.


Will the block data saved or discarded after synchronization? Does it get removed when uninstalling? When I first installed the program I noticed that it was synchronising with the network, and whilst it was doing so it was downloading blocks. I wanted to know if these blocks will be saved on my hard drive or will be be deleted after the synchronising is complete. If the files are stored on my hard drive I wanted to know if when I uninstall the program will the files also be deleted?

The blocks will be stored on your hard drive in the application data directory. If you uninstall, the block files will be kept. There may be an option in the uninstaller that will remove them, but the wallet.dat file will be kept for certain.

Future versions of the mainline client, Bitcoin-Qt, will handle this storage differently via Simplified Payment Verification.


Listening to all transactions of the Bitcoin network I searched with all terms I could think of, but could not find anything in direction that helps me.

In the context of a research project, I am trying to listen to all transactions that are broadcasted over the Bitcoin network. So we are especially interested in transactions, that will not occur in the blockchain later (e.g. got "lost", took very  long to get accepted, double spent, etc.).

I know of bitcoind, but the list of transactions is rather pull-oriented, whereby I'd like to have something like a callback, that informs me of a new transaction.

Can anybody recommend any software/libs/projects here?

PS: all I intend to do is read-only, so there does not have to be any wallet-support etc. I just like to get a deeper view into how the Bitcoin network actually works.

You can do this using BitcoinJ by implementing the PeerEventListener interface.

The OnTransaction will be called every time a new Transaction is broadcast out and received from a Peer.


Where to buy Bitcoin with Paypal? I have a Paypal account and I don't want to give up my ID card. Where could I buy Bitcoin at a price reasonably close to the exchange rate?

If you are happy to buy in dollars then you can do exactly this through irc channel #bitcoin-otc.


Privacy and Anonymity in Bitcoin I hope this is not a duplicate.
I have seen lot of people confused between terms "PRIVACY" and "ANONYMITY". Context is Bitcoin transactions and protocol. What does privacy and anonymity mean in Bitcoin?

Slides of my presentation: https://docs.google.com/presentation/d/1N6jT6SbBl3OxohbdEQj_f1su9nf9UqetAgLYu6RfeWQ/edit
Privacy: Things that a person doesn't want to share with everyone
Anonymity: Share things with everyone but not be associated with you IRL
When considering Bitcoin Protocol or Chain, these terms are confusing or used at lot of places without mentioning the difference. To achieve anonymity in bitcoin transactions (Real identity should not be linked with bitcoin transactions), users should follow best practices and still consider that no technology can help in 100% anonymity. Privacy is involved at different levels while using Bitcoin. If considering full node, lot of information is involved that you might not want to share with other nodes or not use others nodes and use your own node. Running node over Tor or i2p also helps in avoiding real IP being linked with any transaction. Once transaction is confirmed or even in the mempool, everyone can look at the address, amount and other details which may sound less private but this information is not really helpful for any spy until it is associated with real identity or any KYC exchange etc. Last but not least, never share information about your transaction on social media.
Things go wrong when you don't follow the best practices. Examples are many but one:
https://bitcoin.stackexchange.com/a/101959/
Basic things:

Use your full node

Do not re-use addresses

Use coinjoin and payjoin when required

Do not share information about transaction on social media

Use non-KYC exchanges like Bisq for trading

Bitcoin blockchain is like people sharing their nudes, everyone can see them, they are all blurred, few have information about real face etc.
Transactions being public doesn't make Bitcoin less anon or private. Privacy and Anonymity depends on the user, system and their interaction. There is always scope for improvement.


Is the hash of the previous block included in the block header? What the title says above, but for more clarification I am asking whether the hash of the previous block header is part of what is hashed to create the header of the new block? Like what are all the components that are hashed together to get the block header hash?

Thanks.

The block header is 80 bytes:

Version number: 4 bytes
Previous block header hash: 32 bytes
Merkle root: 32 bytes
Timestamp: 4 bytes
Bits: 4 bytes
Nonce: 4 bytes

The merkle tree hashes all the transactions in the block, the bits field is used to compute the target hash for the header, finally, the nonce is used as a counter to generate new block headers from a given merkle tree.


Is it a problem that miners participate in a pools? I am talking about miners centralization with large pools. Is it a problem?

I think there are some possible ways to prevent miners from pooling. For example add miner signature to the block header, so pool will not be able to disclosure their private key to outsource calculations. Miners should use something like insurance instead of pooling.

Is it a problem that miners participate in a pools?

It can be.  The most widely-used mining protocol at present (and the historically popular protocols) give complete control over what gets mined to the pool operator.  Even if the pool operator has the best of intentions, they can be hacked and their hash rate abused for evil.  This is what allegedly happened when the mining pool GHash.io (with about 30% of hash rate) stole about $100,000 in BTC from the betting website BetCoin Dice.

But it doesn't have to be a problem.  One current mining protocol, GetBlockTemplate, theoretically allows pools to give individual miners the ability to select which transactions they include in their blocks, preventing the pool from centrally making important decisions.  Another system, Peer-to-Pool Pool (P2Pool), is a completely decentralized pool where there is no pool operator, just a bunch of independent miners collaborating without any one of them making decisions for the others.

Both of these protocols have problems. GetBlockTemplate (GBT) is bandwidth intensive, complicated, and not very flexible; P2Pool is complicated, less efficient than centralized pooling (it can't include as many fee-paying transactions in a block), and doesn't necessarily work well for very small miners.

A new alternative to both of these protocols is BetterHash which looks like it many work much like GBT was supposed to without the problems.

  I  think there are some possible ways to prevent miners from pooling. For example add miner signature to the block header, so pool will not be able to disclosure their private key to outsource calculations.

This solution has been proposed many times before and it certainly could be added to the Bitcoin Protocol.  However, several experts worry that it would make centralization worse by only providing the benefits of pooling to the biggest individual miners.  Smaller miners who now couldn't join pools would be subject to increased block-finding variance and so would either be more likely to go out of business, or would simply rent hash rate from a large miner who would operate the equipment and payout rewards---increasing centralization in either case.


Intuitive CryptoCurrency? How would cryptocurrencies be explained intuitively? I tried reading about bitcoin but most articles explain broad concepts ambiguously, and I want to understand the concepts so I could potentially make a cryptocurrency myself. So, here is my intuitive understanding of it. With online currencies usually there is a central service that steals some of the money when you make transactions? You don't want that so you directly do transactions from one person to the other, perhaps by passing a code that is worth value to someone else. OK, but this has problems because of double spending. A person cannot be sure if the currency has already been spent. So that's why there's databases that everyone has access to and everyone writes to that stores the amount of money everyone has. How would the databases verify that you are in fact doing the transaction and not someone saying that they are doing it? Through public and private keys, right. How that works is that each person has a private key that encrypts a specific code, and everyone has access to the public key that is paired with the private key. If that code, when decrypted by the public key, is in the correct format, then it can be verified who is making the transaction, because nobody else has the private key. But the code that needs to be decrypted must be different every time because if it's the same every time, whoever sees the code can use it to spend money. So maybe you make a rule that when you decrypt the code it has to form the current date to verify the transaction. The public key would be stored in the database with the corresponding amount of money connected to the public key. Also when you make the transaction you say which public key you want to give money to and which public key you have, and how much money you want to give. A lot of people's computers verify the transaction so it's safe. Why is mining even necessary? I might just be dumb because I don't have much cryptography experience, I do have some programming knowledge however.

Your description works well enough until you start talking about encryption. The way you've described implementing public-key cryptography isn't quite right, if you're interested, I would suggest taking a looking at at the public-key cryptography wiki page.

I think more useful than explaining how your description is wrong, I'll just give an example of how I would re-write it to be more accurate (at least insofar as it is implemented in bitcoin). My addition in bold:

  How would the databases verify that you are in fact doing the transaction and not someone saying that they are doing it? Through public and private keys, right. Coins can be sent to public keys, and then spent using the corresponding private key. So you can share your 'pubkeyA' with someone, and then they can send bitcoins to that key (and thus to you). They do this by using their 'privkeyX' to sign a transaction that says "send the coins held at 'pubkeyX' to pubkeyA", and everyone else can use the pubkeyX to verify that the signature came from privkeyX, without ever knowing what privkeyX is!

Perhaps also worth mentioning, saying 'databases that everyone has access to and can write to' is sorta misleading, it makes me think of a database instance that many different people write to. In reality it is 'many instances of a database that are constantly updating according to the network's rules'.

  A lot of people's computers verify the transaction so it's safe. Why is mining even necessary?

Proof-of-work mining solves the problem of needing a large network of untrusted computers to all agree upon the ordering of transactions, in order to solve the doublespend problem. Otherwise, how will the computers agree on which transactions to include, and in what order? What would make any one copy of the database more trustworthy and accurate than any other?


Unconfirmed Transaction, what can I do? I sent a small amount of bitcoins from my electrum wallet. I control both addresses either side.

the transaction can be viewed here

https://blockchain.info/tx/a80f1ef7e4f2fdda8ca3fe2948bbad6a316976e9d91a6deacd56d3346f76d652

It's been unconfirmed for around 16 hours now, what can I do about this and how I do get my bitcoins back?

Please wait. the estimated transaction time is 3d days. The tx will be either confirmed or will be removed from mempool. If you have opted in for RBF , you can increase the fee.


Is Coinbase.com combining / commingling transactions or funds? In this transaction, I transferred 2 BTC from my Coinbase.com wallet to an external address.

Why are there 3 outputs in the transaction?

I understand the output of 2 BTC, and the 0.0001 BTC transaction fee.  One of the outputs is likely a change address.  But I don't know what the 3rd output is for.

Is/does Coinbase.com

combine unrelated user transactions into a single blockchain transaction?
tracking user's funds or transactions off the blockchain (effectively commingling funds)?
extracting its own fee from the transaction?

Yes, simply put, Coinbase and some other wallet/merchant services have internal bookkeeping.

So you've deposited 2 BTC. Soon thereafter coinbase will move funds around:

to cover other deposits/withdrawals
to exchange
to put in a hot/cold wallet

Once you've deposited your Bitcoin, just like a bank, you're effectively given an IOU (unless for services like Blockchain.info you own the private keys) and your withdrawal will draw upon either a single or multiple inputs to reimburse you.

The main reason this is done is twofold:

to cut down on Txn fees
because the bitcoin protocol always sends the full input amount (the remainder is sent as change)

By coupling change outputs as credits this allows for internal bookkeeping.

(It's worth noting that the txn fee wasn't paid by you directly. It's just a standard multi input txn)


How long on average would it take to discover all other nodes in Bitcoin network and connect to them? Are there technical obstacles to this? I am wondering how long on average would it take for a node to discover all other nodes in Bitcoin network and connect to them? Are there technical obstacles to this?

how long on average would it take for a node to discover all other nodes

No normal node ever does this.
A normal node only connects directly with a very small number of other nodes (e.g. max 8 outbound, max 125 inbound) and relies on those other nodes to pass on information to the small number of nodes they are in contact with. This way information diffuses across the entire network.
Since nodes are continually appearing and disappearing any attempt to contact all nodes would be essentially endless or both incomplete and incorrect (it would include nodes that have been removed since the start of the discovery process)


How to get public key from a Electrum based wallet? I have created a wallet with Electrum. Now I want to get the public key (not the address, but the public key for key-derivation).

How can I achieve that?

If you mean the extended public key aka master public key then you can get that via wallet menu > information. If you mean the address specific public key go to view menu > show address, switch to addresses tab, right click on the address in question and choose details to view the public key. You can also search the addresses on that tab by pressing ctrl+f.


When does `vin` contain multiple addresses I need to find out all the bitcoins transferred from a particular address to a particular address.

For this I am using the blockexplorer API, for this I use their "Transactions for multiple addresses" API since only this provides a paginated response. Others only give 10 results by default.

So I iterate through transactions, look fromAddress in vin, similarly search for toAddress in vout. If all satisfied I take that value.

for transaction in txs:
  valueIn = transaction['valueIn']
  valueOut = transaction['valueOut']
  confirmations = transaction['confirmations']
  if confirmations >= 12:
    vin = transaction['vin']
  for row in vin:
      if row['addr'] == fromAddress:
        vout = transaction['vout']
        for j in vout:
          addresses = j['scriptPubKey']['addresses']
          if toAddress in set(addresses):
            output.append(j['value'])

But in some case I saw multiple addresses in vin, when is that?
Would my logic would still be right, if my address is part of that?

So a transaction will have multiple vins, if it takes multiple UTXOs to send the value.

So let's say you in the past have received 10BTC from X, and 5BTC from Y.

You now need to send 11BTC to Kate.

What it will do is,

it will send out the 10BTC from X, as this is an Unspent Transaction Output, it will then send out the 5BTC from Y and send you back 4BTC.

In this case, you may see 2 inputs on the input side.

Your logic may not work because the "fromAddress" for the 10BTC might be the fromAddress that you hold, but the fromAddress for the BTC, you may not have.

In order to find out all transactions from personA to personB, you must know all of their public addresses in their wallet.

You also cannot assume that all inputs, are from personA because with BTC you can pool transactions, so each input can be from another person.

If you had all of the addresses, your code would look something like this:

if fromAddresses.contains(row['addr']):

Hope that helps.


Is it possible to use Bitcoin Core Qt as interface for DIFFERENT full node? bitcoind is running on the background, local RPC server is running, all good. But is it now possible to have GUI? To say to bitcoin-qt that it should use RPC instead of going to disk files (which are locked by the other instance)?

No, there is no support for this. It is not an interface which uses the RPC interface, it has much deeper access within the wallet than RPC provides.


Is the block size limit miners'-only thing, or should users participate? Lately I see a lot of back and forth between proponents and opponents of block size increase debate. I have made up my mind about this, but neither side provides any directions on how I can indicate what I think about that.

Is this a miner-only thing?

Ultimately, the consensus rules are set by (the consensus of) those running full nodes, and not by miners. If all Bitcoin node operators decided to switch to different rules for whatever reason, miners have no choice but following, or see their blocks become worthless.

Because of that, in the extreme, miners have no say at all. They have to produce blocks that satisfy the rules that full nodes demand.

Of course, in practice, the hard part is how to get consensus among full nodes, and this is a public debate in which many parties participate: developers, users, and miners. All of them have an incentive to form a consensus, because the alternative may be an irreconcilable fork (with two independent currencies, where each coin that existed before the split can be spent once on each side - the exact problem that Bitcoin was designed to solve).

While a single user can't just demand a change (or non-change) of rules, a large collection of economically relevant nodes certainly can.


Sending getblocks message but not getting inv message response I am building my own bitcoin client, and I have most of the protocol working from https://en.bitcoin.it/wiki/Protocol_Specification.

I successfully make a connection with the version and verack commands. And when I send a ping, I get back a pong with the same nonce.

The problem I am having now is that I don't get the expected response to my getblocks message. I build the block locator using the hash of the genesis block header, and I serialize the message and send it.

But then I don't get the inv message with MSG_BLOCK like I expect.

These are the raw bytes that I send as my getblocks message:

f9beb4d9676574626c6f636b73000000450000008634d5ae0100000001000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f0000000000000000000000000000000000000000000000000000000000000000

This is built following the specification here https://en.bitcoin.it/wiki/Protocol_Specification#getblocks.

I actually do receive the inv message. The problem is in the way that I try to decode the inv message.

The getblocks message seems to work fine.


I have what I believe are my address and password - don't know what wallet from 2017 I have what appears to be a GUID and a password.  But no recollection what service I used of if I even purchased / transferred or made a transaction with them back in 2017.  Any way to check to see if I have anything in here and retrieve it?  My current BTC is on a platform I use regularly, this was prior to me setting up my current process last year...  Any advice?

That would be a very old Blockchain.info wallet, they're the only ones using a GUID for the identifier.


Can two different nonces and different blocks produce the same hash? Say, I want to erase the record of a transaction by changing a block. Can I go back to that block and find a new block and nonce combination that makes the same hash?

Is it a case that finding such a new combination is computationally hard or is it actually impossible?

One of the main properties of a hash algorithm is collision resistance. If you would find an identical hash with two different datasets, then we would speak of a hash collision.

This is extremely unlikely to happen. The mathematical chance that a sha256 collision would happen is smaller then the actual chance that the universe will implode in this moment.

https://crypto.stackexchange.com/questions/24732/probability-of-sha256-collisions-for-certain-amount-of-hashed-values


Can a miner just introduce a block full of valid predetermined transactions in the blockchain and get rewarded? My question is - let's say a miner has control over a certain number of bitcoin addresses. He creates a block containing small transactions to and fro from these accounts ahead of time in advance and also calculates the golden nonce for that block should it be introduced in the chain in the future.

Can he introduce this block in the chain at a particular instant of time and get the mining reward, considering that he can determine all the variables that would affect nonce calculation in advance. Also my understanding says that this block won't be rejected by other nodes as all the transactions will be valid with proper signatures(the miner controls all those bitcoins and will only try to spend them at that particular instant). What would prevent such a situation from happening? This way miners could make bitcoins for themselves out of thin air. What am I missing here?

This will not work, because a block's content includes the previous block's hash which means that a valid block can only be mined after the previous block is known.

The dummy transactions would not yield a reward to the miner, because the transaction fees are just going from the miner's left pocket to the miner's right pocket. The miner will only gain the newly minted coins, which they would have collected anyway, even with an empty block that included no transactions except for the coinbase transaction. In fact, the miner is suffering an opportunity cost, because they could have collected fees from other transactions instead.


Are there any tools to check values in tx validation? Are there any developing tools that can show values(like the hash of tx to sign or the stack of script execution) in tx validation so that developers can check the correctness of their validation code?

For the hash of the tx to sign, I am not aware, but you can easily remove signatures, place the output script, adopt the length field(s), and hash yourself?

For script execution, there are several debuggers: here and here and here :-)


Can you add value to a Casascius physical coin? The firstbits address on the front of the coin (once fully resolved from blockexplorer) is just like any other address right? I can buy a 1 BTC Casascius physical coin, copy the address, bury that coin in my backyard, and use regular transactions to keep increasing its value?

Yes, you can add value.  The block chain only knows public keys. It doesn't care how or where the corresponding private keys are stored.


Generating Bitcoin address from private key in browser console I am a newbie Bitcoin evangelist and I have a recommendation to see all the code responsible for computing yourPublicKey from yourPrivateKey, especially for big deal addresses.
The easiest way to allow Bitcoin users to see the code is to write it in Javascript to let them run it on console, because any PC user has a browser and almost nobody has Python or any other interpreter. I saw a step-by-step manual in this answer to How can I generate a bitcoin address? but I still have some obstructions to produce one single sheet of code ready for running in console.
Please help me to write that code to make my recommendation easy to follow.

If JavaScript is your language of choice you might be interested in bcoin - the bitcoin full node implementation and modular library written in JS. It's designed for use in nodejs environments but can be compiled for the browser as well.

This guide in particular walks you through the process: https://bcoin.io/guides/webapp.html

Please note that web browsers are insecure environments for cryptography and especially cryptocurrency, this guide is based around public keys and testnet addresses to avoid any real risk. If you try to manage private keys in a browser's JS environment you need to be extremely careful (use an offline computer if possible, no "chrome extensions" etc)