text:
Can I Hook Up RX-460 to Regular PCI Slot via PCI-E Riser
I have motherboard with 3 Regular PCI slots beside 3 PCI-Express slots. (https://www.asus.com/Motherboards/M4A88TDV_EVOUSB3/specifications/)
Can I Hook Up 3 RX-460 to Regular 3 PCI Slot via PCI-E Riser USB?  Will it be stable?

No.  PCI and PCI-e are two entirely different things.  PCI is a more traditional parallel data channel, while PCI-e is a serial data channel (that can have multiple parallel "lanes").
You cannot plug PCI-e devices into PCI sockets.
If you're desperate, you can try the mechanism specified here, no guarantees though :)
https://www.youtube.com/watch?v=5vDHACwXSxE


text:
What is the incentive for including transactions in a block?
I've been doing research in trying to answer this question and haven't found a good answer yet. I was wondering what is the incentive for miners to include a transaction in a block when mining bitcoin? Since it's a race to solve the proof of work problem, why wouldn't miners just leave the block empty to save time?
The reward for mining the block is much bigger than the transaction fee(s) so it doesn't seem to make sense to me to waste time validating transactions for the block just to accumulate small transaction fees. If anyone can provide an answer, that would be greatly appreciated. Thanks.

The incentive is the transaction fee. Although the individual transaction fee may be fairly small, all together, transaction fees now make up 2-3 BTC of the block reward. As the block subsidy diminishes, transaction fees will become a bigger and bigger part of the block reward, eventually becoming the entire block reward.

Thanks for your reply Andrew. Just a quick followup. I've read that having an empty block doesn't minimize the mining effort compared to having a full block of transactions. Is that true and if so, why is that?

Yes, that is true. The majority of the work going into mining a block is just hashing a bunch of different block headers. The size of the header (and thus the amount of work required to hash it) remains constant regardless of the data within the block and of the data within the header.

Three reasons:

Leaving the block empty doesn't save any time. They still hash however many times a second they hash.
Transaction fees make up a significant fraction of the mining reward today. Such a miner would be foolish.
Miners have invested in expensive hardware that is valuable only if bitcoins remain valuable. If too many miners mine empty blocks, confirmation times will go up and the usefulness of the network will be diminshed.

David, thank you for your response. One thing I wanted to follow up with you on. So what is the incentive for peers on the network to validate solved blocks? They could just use the block without validating it or continue mining the previous block. Plus, there are no fees for validating solved blocks, and even though it might be quick, it's extra work they'd have to do.

If you don't validate a block, how do you know whether other people will accept it or not? If you accept it and others don't, you can lose money by accepting as payment bitcoins that nobody else will accept as spendable. The system would be unusable if nobody validated blocks -- no two machines would agree on who has what. As for mining on the previous block, if you do that, you won't get any mining reward or transaction fees because only the longest chain stays valid long enough to spend its fees/rewards.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
Multiple spending transactions from a single Bitcoin address?
Supposing I am having 100 BTC in a single Bitcoin address and I send 1BTC to each individual ( total 100 individuals) and I have instantiated all of these transactions in one go( assuming that they will be running parallely).
Also, assuming that it takes 10 minutes to validate a transaction, How much time will it take for the 100th transaction to be validated? Will the time depends on the previous unconfirmed transactions? ( Consider that there is no double spending here)

What do you mean by "10 minutes to validate a transaction"? Transaction validating time is microseconds

Validation means confirming that the transaction is valid and is not a double spend.

When a transaction is confirmed a block is added to the Bitcoin block chain which takes about 10 minutes. Correct me if I am wrong.

You know absolutely nothing about hou Bitcoin network works. Start with reading basic manuals before asking stupid questions

Well, I am questioning here because I am not sure about this and I am not able to find about it. And if you are so clear than you should provide an answer.

I've downvoted this question, because when I tried to edit it, I couldn't figure out how to save it without completely rewriting it. It is sloppily written, incorrectly tagged, has an unsubstantial title, misuses terminology, and is based on incorrect assumptions. What are you trying to achieve? Why don't you simply send to all 100 recipients in a single transaction? Are you aware that blocks collect many transactions? Please read e.g. https://bitcoin.stackexchange.com/q/146/5406, https://bitcoin.stackexchange.com/q/12427/5406, https://bitcoin.stackexchange.com/q/43785/5406

Assuming that by "validate" you mean "confirm" then a chain of 100 transactions sent from the same wallet should, theoretically, all confirm in the next block or two - assuming that each transaction's included fee is sufficient.
However, the outcome described above is only theoretical, because many clients place a relay limit on unconfirmed transactions in a single chain. The Core client, for example, does not accept more than 24 unconfirmed transactions from a single chain into its mempool.
In the case of your example chain of 100 transactions there could, therefore, be a best-outcome delay of at least 5 blocks before all the transactions are confirmed.
Further to your question, it is not a case that the 100th transaction is dependent on the 1st or the 99th transaction to have to confirm first. If each of the simultaneous 100 transactions being sent from a wallet is valid and has sufficient fees, then they will each be mined as individual valid transactions by miners, regardless of their wallet of origin. If a miner happens to be running the Core client, then there will be a batch limit of 24 transactions (from the single chain) that can be mined per block.
As pointed out in the comments, a transaction can have more than one output, so your example's 100 recipients can each be sent bitcoin via a single transaction.

Thanks a lot for your answer. Your answer puts me in another doubt. Assuming I am including proper fees and Supposing that there were 101 people instead to whom I am giving 1BTC each (now I am double spending). Now, thinking of the case that all those are processed parallely, how will the double spending be taken care of?

Ha! Good thinking. Logical next step. As it happens there was a question a few days ago about how simultaneous double spend txns play out in the network: https://bitcoin.stackexchange.com/q/54734/38546

This answer is incomplete in two regards: 1) Many nodes do not relay long chains of unconfirmed transactions beyond a certain depth. E.g. Bitcoin Core doesn't accept more than 24 unconfirmed transactions in one chain to its mempool. 2) the answer should point out that a transaction can have more than one output, and thus all 100 recipients could be credited in a single transaction. ;)

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
How can I avoid re-using a Bitcoin address more than once?
I have a fundamental confusion regarding Bitcoin addresses. Apparently, addresses are only intended to be used once for security and privacy reasons (see here, for example). If I think of addresses as storing Bitcoins, then there seems to be a basic problem with this, which is that once some Bitcoins have been sent to a given address, they would never be able to be spent since that address must never be used again.
Clearly I have a misunderstanding of the connection between addresses and Bitcoins, and yet I can't find the resolution.

Address should not be used to receive bitcoins more than once, meaning each time you receive bitcoins you should use a fresh address. Of course, once you receive bitcoins at an address, you will want to spend them in the future, and that is fine. Ideally, an address is received to once, and then later spent from once.
The 'single spend recommendation' is sort of automatically enforced: when spending a UTXO, it is not possible to spend only part of the bitcoin, the entire UTXO must be consumed. So you just need to make sure you do not re-use an address to receive bitcoin / as a change address.
Perhaps the biggest reason this is recommended is that single use of an address preserves your privacy, as well as the privacy of those you interact with.

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Is there any punishment for Having more than 50% of the mining power of the network
I am just curious about it.
In history once it happened That GHASH.io owns 52% mining power, he was malicious and sell 5% to other miner. Bitcoin community keep watch on everything?

Quite the contrary. If a pool becomes too big it just earns more money. There is no punishment. Maybe some bad reputation, but not something the majority will even notice.
It has happened three times so far that pools reached hashpower majority or got too close to it: Deepbit, BTC Guild and GHash.
Only Eleuthria, operator of BTC Guild, handled this in a responsible way. He raised the pool fees which caused some miners to react, moving to other pools. This balanced out the pools.
GHash scammed a casino, but they could have done this without having so much hashpower as we are talking about zero-confirmation transactions. They later said it was done by a rogue employee who is no longer with them.
Deepbit and GHash acted irresponsible and so did the miners. It appears that the vast majority of miners are not keeping watch on whether a pool gets too much hashpower or they just don't care.
The fourth time this happens, maybe some very bad things will happen. Hopefully in that case miners will take note and act more responsibly. It is doubtful though, as almost noone reacted to the casino scam mentioned above.
Disappointing for sure, but it is what it is.

There's no bad consequence in the protocol for having more than 50% of the hashrate. However, the community keeps a close eye on the pool repartition and will try to prevent such a pool to exist by moving to a smaller one (as it happened with Ghash.io).
Ultimately, the only punishment is a stronger community monitoring to try to prevent selfish mining, double spends, etc... If a miner above 50% stays malicious, the only other recourse could be a HF to another PoW function.

... When it is observable. Many behaviours that can threaten the system when deployed on a wide scale (like spy mining) are entirely undetectable by the outside world (until it is possibly too late).


text:
What is the limitations in Bitcoin's network that can't be change by a Soft Fork?
I'm trying to understand why (Or how) there is all kinds of different version for the Bitcoin nodes?
I saw that if one node is following the Protocol limitations it can act as a valid node.
Is there a list that gathered all the rules?
Even the one who can be changed by a soft fork.
(block size, SEGWIT etc...)

Bitcoin.org's developer documentation has a pretty good description of the consensus rules, but it does not and cannot describe them fully. This is because the consensus rules are dictated by the code that enforces them, not by a document. AFAIK, there is no list of things that can be hard forked and things that can be soft forked as such lists would be infinite. A hard fork can do anything; a soft fork can do much less, but with some "tricks", a soft fork can do just about anything too.
In general, a hard fork is a change which makes something that was previously invalid, valid. This would mean things like changing the transaction and block formats, the current scripting system, etc.
In general, a soft fork is a change which makes something that was previously valid, invalid. This would mean things like changing when the OP_NOP (no operation) opcodes are actually no op and not. Soft forks can also add extensions to what currently exists, but not always change what already exists. So a soft fork could add something to the transaction format, but it can't change the current transaction format to something else. Changes like these would be segwit and extension blocks.


text:
First buy or sell of bitcoins
What steps do I have to take to buy/sell bitcoins? What's the minimum amount of bitcoins that I can buy, and how much will I pay for transaction in a buy/sell operation?

For a start and to get to know the different exchanges and wallets you should checkout: https://www.bestbitcoinexchange.io/ (I'm not affiliated with that website).
To buy and sell Bitcoin I recommend https://gemini.com and https://xcoins.io. https://coinbase.com is popular but I'm not a huge fan of them for a number of reasons.
Just sign up and add your bank account to purchase Bitcoin. Gemini allows you to buy/sell Ethereum as well.
If you're worried about adding your bank account I would use https://xcoins.io or https://localbitcoins.com


text:
How Bitcoin system prevents the previous owner of a Bitcoin to spend it?
I am a Bitcoin noob.
As per my knowledge, a Bitcoin is a digital signature.
Owner of a bitcoin knows the private key of it.
If I spend my bitcoin, I still know the private key of it, using which I can spend it later despite not owning it.
Surely there must be something in the system which prevents this. One idea which comes to my mind is modifying the Bitcoin's Digital signature in a way so that the only new owner has the new private key.
I might be stupid and my above query may be just BS. Please guide me in the right direction.

If I spend my bitcoin, I still know the private key of it, using which I can spend it later despite not owning it.

Your are not really "the owner of the bitcoin". It's decentralized. You are the owner of a private key and of an adress.
And you can use the private key to send money away from your adress. Let's assume, you have only 1 BTC on your adress and send it all to your friend. After that, you can't send BTC from your adress anymore because there is nothing on the adress anymore. Only if someone sends BTC to your adress again, you can spend them again. You can't spend the 1 BTC again because it's on your friend's adress. You don't have the private key for his adress, but he has. So he can spend the BTC.

thanks Alpha!..so can I put it like this - that u always a key pair for an address which has the bitcoin. Its the private key of the address using which u can spend the BTC inside that address. Thats why a new address key pair is generated for every transaction.. makes sense?
if the above is right.. then the BTC is just a token..then why is it reqd to be a digital signature?

"That's why a new address key pair is generated for every transaction". Yes, wallets do it like this. But you could theoretically use an adress multiple times (receive 1 BTC, send 0.5 BTC, send 0.25 BTC, receive 2 BTC, receive 0.1 BTC, send 1 BTC -> you can do all that with just 1 adress and 1 private key).

Once you broadcast the transaction and it is written on the block chain, even if you send the transaction again it won't be added to the block because you have already spent your previous input.
It is the double spending problem .
If your transaction is still in the mempool and not added to the blockchain , you can send the transaction again with a higher fee. It will get accepted to the chain and your intial transaction will be invalid.
The transaction can be marked as completed only if it is added to the chain.


text:
Whats the technical/database entity of a crypto-currency / Bitcoin?
I know that Bitcoin accounts are public private keys combination.
Is it the same with the currency? Is one Bitcoin a combination of public pvt key? Or is it a token?

A bitcoin, as defined in the whitepaper, is a chain of digital signatures. "To own 1 bitcoin" is by definition equivalent to the following: "in the history of transactions, as defined by the heaviest blockchain branch originating from the genesis block, there exist unspent transaction outputs that sum up to 1 bitcoin such that you have the private key(s) required to spend them".


text:
Why is it so that if some bitcoin is spent by any user, the rest of his account's amount should also be spent and paid him back?
I guess this is called Circular spending.
Why is it required in the bitcoin protocol?

Because on the lowest level of bitcoin protocol there is no accounts. There are scripts inside transaction. The most common script says: show me public key, I will compute Hash160 of it, compare with given Hash160, and if they are equal, I will check signature.
Let imagine, transaction contains single output with 1 bitcoin. Script contains Hash160 (which we treat as account). There is no way to spent part of bitcoin. We have to spent entire output, which is equal to 1 BTC in our case.
Transactions, like blocks, form some kind of chain.

thanks for the answer! if you can share any documentation about this, that wud b very helpful

You can use official wiki: https://en.bitcoin.it/wiki/Protocol_documentation#Transaction_Verification https://en.bitcoin.it/wiki/Script


text:
Share blockchain data between bitcoin-core and btc-1
I am currently running a BTC-1 node and would like to setup an additional core node before the November fork. Ideally, I would avoid the need to resync the entire blockchain again. Is it possible for me to locally copy the blockchain data I have already downloaded for btc-1 and use it to avoid a full resync with bitcoin-core?

Not sure about BTC-1, but my question about BCH/Bitcoin ABC could be relevant.  You might want to check that.


text:
Help with very old wallet.dat file and keys, next steps?
recently I found a very old wallet.dat file back from 2011 (I did some mining back then). I was able to run pywallet to export the keys into JSON file, this file includes private keys and all, so i assume it was not encrypted. The structure is as follows, there are bunch of these.
    {
        "addr": "",
        "compressed": false,
        "hexsec": "",
        "private": "",
        "pubkey": "",
        "reserve": 1,
        "sec": "",
        "secret": ""
    },

The question is - what do I do with this now? I want to check if there any coins that I have mined but i have no idea what the next step is.
I have tried copying the value of "private" into Bitcoin Core's console with "importprivkey" but i get "Invalid private key encoding (code -5)"
Thanks for your help!

You don't need to import the keys to see if they have a balance or not. Just copy the content of "addr" and use a Bitcoin blockchain explorer such as https://blockchain.info/ to check if there is any BTC on the address.
And i guess you could just import the wallet.dat on Bitcoin Core directly if there is any BTC on any of your addresses.

Thanks for your reply, but there are hundreds of these in there. Doing it by hand one by one would not be very pleasant. I just installed Bitcoin Core, and its currently downloading the chain. Is there a quick way to import the wallet file once it's done?

You can check here : https://bitcoin.stackexchange.com/questions/10974/import-wallet-dat-into-a-new-bitcoin-qt-client


text:
Can I buy cryptocurrency being on H1B Visa?
Can I Buy/Sell bitcoin/Ethereum or get involved extensively in cryptocurrency? If so how much capital can I invest? I am currently on H1B Visa and wanted to get some insight on this. Thanks!

Not all people are familiar with Visa specifics. Can you elaborate, why you think this could be relevant? Which country are you from and from which is the Visa?


text:
How is this procedure a proof of reserve?
i'm still learning about bitcoin, and i learned about the "proof-of reserve"-concept, that online wallets need to accomplish to prove they are having enough bitcoins for all their liabilities.
Now, the only procedure that i know of to do that is the one described in this document: https://www.bitstamp.net/s/documents/Bitstamp_proof_of_reserves_statement.pdf
This document describes how bitstamp is giving a proof of their reserves, by sending their whole cold storage amount to an adress of themself. So far, that makes sense.
What i don't understand is: What purpose has the signing of a selected message by the third party, described at the end of the first page?
Thanks for any help.

What i don't understand is: What purpose has the signing of a selected message by the third party, described at the end of the first page?

Without this step, it is possible that the transfer you're observing is entirely unrelated to Bitstamp. They could have watched the chain for a while, waiting for a transfer of sufficient amount, and then claim that it was theirs.
Assuming you trust the third party is in fact a third party, and is not colluding with Bitstamp, the signature proves that BitStamp in fact has control over the private key the funds were sent to, meaning they also have control over the funds.
Note that there is research around more advanced cryptographic techniques that do not rely on a third party, and don't require moving all funds around. For example, see this paper: http://www.jbonneau.com/doc/DBBCB15-CCS-provisions.pdf.


text:
Why are pre-softfork blocks are not causing problems for post-softfork clients?
i read the answer to this question and got some new one.
As far as i understand how a soft fork works, it means that post-softfork clients with new consensus rules accept only blocks that follow those new consensus rules, while older, pre-softfork clients accept both, pre- and post-softfork blocks. If a old client mines a block, that gets rejected by the newer clients, therefore causing a temporary blockchain fork that is resolved eventually after at least 51% of all clients are upgraded, because the clients then switch to the blockchain fork of the newer clients.
My questions are:

Don't this bear the risk of invalidating all transactions still made by the old clients, but that where rejected by the newer ones? If i made a transaction that gets mined by an old client by the time the old clients still have 51% of the hashing power, but it then switches to the chain of the new ones that previously rejected this block, it disappears from the chain altogether, doesn't it?
Since the blockchain don't change, a lot of old blocks that were following old consensus rules are still in there. When i'm starting a new, post-fork client and download the whole blockchain, how isn't this causing problems for the client when it tries to validate the whole blockchain with all the old blocks in it? Isn't it checking for old blocks following new rules?

Thanks for any help.

Your question is about deployment.
Softforking changing generally are not applied unconditionally to every block in history. Instead, an activation mechanism is used so that all clients know when they need to start being enforced. Before that activation point, new clients still enforce the old rules but not the new ones.
Activation mechanisms that have been used in the past:

Time-based (apply to every block whose timestamp is past a fixed point in time). Used in BIP16 and BIP30.
nVersion signalling (apply to every block after the first range of 1000 blocks in which at least 750 have a nVersion field that is higher than a specified value). Used in BIP34, BIP66, BIP65
Versionbits signalling (using signalling on individual bits of the nVersion field; see BIP9). Used in BIP141/143/144/147.


text:
Trezor Firmware update just hangs indefinitely
Trezor out of the box - first firmware update with the wallet not even set up and just hangs on "Installing...Please Wait". Read through all of the troubleshooting section on Trezor's website but no help at all. Can someone help me?

Try it again. If it does not work, contact support and ask for a replacement unit.


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

Yes, to get addresses from scriptPubKeys, you will need to do a pattern match. There are only a small number of address types each with their own fixed scriptPubKey pattern. Keep in mind that not all scriptPubKeys map to an address so you will find scriptPubKeys that have no address and you will need to handle those.
Bitcoin Core has a pattern matcher for going from scriptPubKeys to address types in the solver function. The MatchPayToPubkey, MatchPayToPubkeyHash, and MatchMultisig can be found higher up in that file. The IsPayToScriptHash and IsWitnessProgram functions can be found here.
One thing to note about the solver is that it does not return just address types. Some of the types it returns do not map to addresses. These are TX_NULLDATA, TX_MULTISIG, TX_PUBKEY, and TX_NONSTANDARD.
It may also be useful for you to see how you get the scriptPubKey from an address. Bitcoin Core does it here.

Thanks a lot Andrew. I'm not great at C++ (only been programming for a year) but I think I can use it as a guide. One more question: why would a scriptPubKey not map to an address? For the purposes of my block parser, would I just discard it?

A scriptPubKey can be literally any sequence of bytes; it doesn't have to be a valid script, the output will just be unspendable. Those standard scriptPubKeys that don't have addresses occur because there was/is no reason for them to have addresses. A very common one that you will see are Pay to Pubkey outputs. These are in basically all of the early blocks because the original Bitcoin client created coinbase transactions with P2PK outputs. Some block explorers will convert these to addresses, but that is incorrect.

I recommend that you do not discard them because you will be losing information. It is useful to know exactly what the scriptPubKey for an output is. So you should still just store them. Maybe decode them into opcode notation instead of storing the bytes themselves, but you should still keep the scripts around in some form.

Regarding the handling of segwit txns, is my understanding correct?

Check if it's non-native or native.

If the former, check if it's p2sh-p2wpkh or p2sh-p2wsh and then handle it like any other p2sh.

If the latter, determine if it's p2wpkh or p2wsh.

After extracting the script hash, perform the appropriate hashing and base58check encoding to extract the addresses?

You won't be able to tell if an output is non-native segwit. The scriptPubKey will not contain the segwit script at all, you will just see a p2sh output. So you should treat all p2sh outputs the same, because, as outputs, they are.

With library https://github.com/petertodd/python-bitcoinlib
a P2WPKH address derivation example:
from bitcoin import SelectParams
from bitcoin.core import x
from bitcoin.core.script import CScript
from bitcoin.wallet import P2WPKHBitcoinAddress

SelectParams('mainnet')
# Create an address from that private key.
scriptPubKey = CScript(x('Paste_scriptPubKey_Here'))
address = P2WPKHBitcoinAddress.from_scriptPubKey(scriptPubKey)
print(address)

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
How to sign Bitcoin transactions using JCE?
I need to sign Bitcoin transactions using JCE primitives(no bitcoinj), but my signatures are not considered valid by bitcoinj.
I tried to simulate this process. I created a random hash and signed it using both JCE and bitcoinj. Signatures are not equal.
Here is the code
import org.bitcoinj.core.ECKey;
import org.bitcoinj.core.Sha256Hash;
import org.spongycastle.crypto.digests.SHA256Digest;
import org.spongycastle.crypto.params.ECPrivateKeyParameters;
import org.spongycastle.crypto.signers.ECDSASigner;
import org.spongycastle.crypto.signers.HMacDSAKCalculator;
import sun.security.ec.ECPrivateKeyImpl;
import sun.security.ec.ECPublicKeyImpl;

import java.math.BigInteger;
import java.security.*;
import java.security.spec.ECGenParameterSpec;

public class ECDSABitcoin {

    private static final String SIGN_ALGORITHM = "SHA256withECDSA";

    public static void main(String[] args) throws Exception {

        KeyPairGenerator keyPairGenerator = createGenerator();
        final KeyPair keyPair = keyPairGenerator.generateKeyPair();
        ECPrivateKeyImpl privateKey = (ECPrivateKeyImpl) keyPair.getPrivate();
        ECPublicKeyImpl publicKey = (ECPublicKeyImpl) keyPair.getPublic();
        try {
            Sha256Hash hashOut = Sha256Hash.wrap(toSha256("abc".getBytes()));
            byte[] signatureBytes = sign(hashOut.getBytes(), keyPair);

            ECKey.ECDSASignature mySignature = ECKey.ECDSASignature.decodeFromDER(signatureBytes).toCanonicalised();
            ECKey.ECDSASignature bitcoinSignature = sign(privateKey.getS(), hashOut.getBytes()).toCanonicalised();
            System.out.println("My signature s " + mySignature.s + " r " + mySignature.r + " canonical " + mySignature.isCanonical());
            System.out.println("Verify my " + verify(keyPair, hashOut.getBytes(), signatureBytes));
            System.out.println("Bitcoinj signature s " + bitcoinSignature.s + " r " + bitcoinSignature.r + " canonical " + bitcoinSignature.isCanonical());
            System.out.println("Verify Bitcoinj " + verify(keyPair, hashOut.getBytes(), bitcoinSignature.encodeToDER()));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static boolean verify(KeyPair keyPair, byte[] message, byte[] signatureBytes) throws NoSuchAlgorithmException, InvalidKeyException, SignatureException {
        final Signature verifySignature = Signature.getInstance(SIGN_ALGORITHM);
        verifySignature.initVerify(keyPair.getPublic());
        verifySignature.update(message);
        return verifySignature.verify(signatureBytes);
    }

    private static byte[] sign(byte[] message, KeyPair keyPair) throws InvalidKeyException, NoSuchAlgorithmException, SignatureException {
        final Signature signature = Signature.getInstance(SIGN_ALGORITHM);
        signature.initSign(keyPair.getPrivate());
        signature.update(message);
        return signature.sign();
    }

    private static KeyPairGenerator createGenerator() throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
        final KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("EC");
        ECGenParameterSpec ecParam = new ECGenParameterSpec("secp256k1");
        keyPairGenerator.initialize(ecParam);
        return keyPairGenerator;
    }

    private static ECKey.ECDSASignature sign(BigInteger privateKeyForSigning, byte[] data) {
        ECDSASigner signer = new ECDSASigner(new HMacDSAKCalculator(new SHA256Digest()));
        ECPrivateKeyParameters privKey = new ECPrivateKeyParameters(privateKeyForSigning, ECKey.CURVE);
        signer.init(true, privKey);
        BigInteger[] components = signer.generateSignature(data);
        return new ECKey.ECDSASignature(components[0], components[1]).toCanonicalised();
    }

    private static byte[] toSha256(byte[] message) throws NoSuchAlgorithmException {
        MessageDigest crypt = MessageDigest.getInstance("SHA-256");
        crypt.reset();
        crypt.update(message);
        return crypt.digest();
    }
}

The result is:
My signature s 45669553786690215047884329722902825758089042579493437816717142987836102849876 r 14778973653615637448416336446742229796258878351047437829727432860950944374049 canonical true
Verify my true
Bitcoinj signature s 24278043061766196831119988370534304503511938256487950554838614741011144316017 r 26413727078831382349368962255251267289169651926313668837949728205557969096319 canonical true
Verify Bitcoinj false

As you see, signatures are completely different, even though I use the same private key. What is wrong with my code? I just don't get it.

Your signatures don't verify because in JCE you are using algorithm SHA256withECDSA which hashes the supplied data (re-hashes, since you are supplying a hash) before doing the kG.x,kinv(h+rd) computation, or the similar verification computation, whereas the spongy/bouncy ECDSASigner used in bitcoinj only does the latter, assuming the input is already the correct hash. If you use JCE NONEwithECDSA instead, it will verify okay.
Note however the correct hash for bitcoin transaction signing is double SHA256, not the single SHA256 you coded. Although the data you are SHA256'ing isn't a bitcoin transaction at all, so the fact you are hashing it wrong is kind of moot.
Finally, even with these fixed, the signatures will still be different. JCE using the SunEC provider uses random K as per the standard (X9.62 and FIPS 186-2), whereas BC LWAPI can and the bitcoinj code you copied does use 'synthetic' K per RFC6979. Both are valid, but the signature values are totally different. (The BC provider does have some 'ECDDSA' (D for deterministic) algorithms using this K calculation, but only with hashing, and anyway if you have BC provider you also have BC LWAPI.)
In addition, as you seem to have detected, bitcoin uses 'low S' signatures; neither JCE nor BC LWAPI does that for you, so in either case you must add it (as bitcoinj does in toCanonicalised).


text:
spend a specifc UTXO
Is there any methods to pick a particular UTXO and send it to a particular address in bitcoin regtest mode using bitcoin-cli other than createrawtransaction and sendtoaddress

You can use fundrawtransaction and specify a particular input to be used in the transaction. Bitcoin Core will then choose the rest of the inputs to meet your output amount automatically.
You can also use lockunspent to prevent specific UTXOs from being selected for coin selection thereby limiting which UTXOs can be used. Then any time that coin selection is used to create a transaction (i.e. in sendtoaddress, sendmany, fundrawtransaction, walletcreatefundedpsbt), only outputs that are not locked will be selected.


text:
Bitcoin multisignature addresses
Suppose we have a multisignature address "abc"  with 100 coins in bitcoin regtest network,  I want to that 100 coins in 10 slots that is i want spend 10 coins at a particular interval.
I tried the following:
At t1:
send 10 coins from "abc" to some address and a change returning 90 coins back to multisig "abc"
At t2:
send 10 coins from "abc" to some address and a change returning 80 coins back to multisig "abc"
and so on.
The step followed at time t1 worked perfectly but I am getting the below mentioned error while trying to do the step mentioned at time t2. That is , i am not able to spend again from the same multisig account.
error code: -25
error message:
Missing inputs

How can I spend multiple times from the same multisig address?

are you trying to spend the same inputs twice? How are you creating the transactions?

I am creating a new raw transaction by using the same tx id and vout that funded the multisig address(like i did it first time).

you can only use a specific txid and vout once. If you try to use it again, that input has already been used and it will result in a missing input error. For the 2nd tx try using the vout from the 90 coins that were returned.

I tried doing the same thing you mentioned but still I am getting the same error. @JBaczuk

Sorry without the transaction details its hard to help any further

I was using the wrong tx id (tx id without confirmation). Now its working. Thank You. @JBaczuk


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

You will likely need to add an OP_CHECKSEQUENCEVERIFY guard before the OP_CHECKMULTISIG statement in your output script.
https://github.com/bitcoin/bips/blob/master/bip-0112.mediawiki


text:
Bitcoin Lightning Network
I created a channel in lightning network, did the payment and the channel balance of the receiver got updated. But after closing the channel , the wallet balance of the receiver is not getting updated and the sender is also losing the funds. (Even after mining)
Is there anything that needs to be done for the balance to get updated.

Need more information to answer your question. Which software did you use? How did you close the channel (mutual or force)? Can you share the transaction ID of the funding transaction or the shortchannel ID of the channel?

I am running the lnd nodes in regtest mode. It is a mutual close using the lncli closechannel using funding transaction id command.


text:
Create a Double sha256 block and trandaction
I have same problem whit create a double sha256 of the transactions and blocks with C++.
The hash block it is created with the concatenation of these data,
version + previusBlock + merkleRoot + timeStamp + bit + nonce
In the hash block is not necessary to include the all data raw transaction because is are include in the merkleRoot, right?
For create, hash transaction is create whit the concatenation of these data,
versionRawTransaction + output of the transaction input + scriptSing + sequences transaction input + cAmmount transaction output + publicKeyScript + lockTime raw transaction
Or are include the data for saving the variable structure? in this method
numberRawTransactions + versionRawTransaction + numbarTransactionInput + output of the transaction input + scriptLenght + scriptSing + sequences transaction input + numbarTransactionOutput + cAmmount transaction output + publicKeyScriptLenght + publicKeyScript + lockTime raw transaction
Now I've tried to apply this theory in my C ++ program but can't get the desired hash. Can you help me?
This is the my test code
    TEST(hash_test, first_test_double_sha_bit_genesi_block_bitcoin_crypolibrary)
{
    //Init logger
    FLAGS_minloglevel = 0;
    FLAGS_logtostderr = true;
    google::SetLogDestination(google::GLOG_WARNING,  "/home/vincenzo/Github/SpyCblock/test/log/first_test_sha_not_on_bitcoin_protocolo.log");

    string version = "01000000";
    string previusBlock = "0000000000000000000000000000000000000000000000000000000000000000";
    string merkleRoot = "3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a";
    string timeStamp = "29ab5f49";
    string bit = "ffff001d";
    string nonce = "1dac2b7c";

    stringstream stream;

    stream  << version << previusBlock << merkleRoot << timeStamp << bit << nonce;

    Bytes byte = asciiBytes(stream.str().c_str());
    Sha256Hash shaHash = Sha256::getDoubleHash(byte.data(), byte.size());

    LOG(INFO) << "The hash genesi block converting with double sha256: " << shaHash.ToString();
    ASSERT_EQ(shaHash.ToString(), "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f");

}

but I get this result 46f4d3f53251d05ab58a3f8925ce7023f2115dc38468ec78521c7d0e1dc7bd19
Since I know practically nothing in cryptography in practice, I relied on this library where I use this type of data here that makes the double sha256 Find here
Sorry for my terrible English but I'm learning

The problem is that you are hashing the string of the hexadecimal representation of the bytes of the block header, not the bytes of the block header itself. You need to hash the bytes of the block header itself.
You need to set everything as a byte array, not a string. So you would have something like this for the entire block header all together:
Byte[] block_header = {0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                       0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3b, 0xa3, 0xed, 0xfd,
                       0x7a, 0x7b, 0x12, 0xb2, 0x7a, 0xc7, 0x2c, 0x3e, 0x67, 0x76,
                       0x8f, 0x61, 0x7f, 0xc8, 0x1b, 0xc3, 0x88, 0x8a, 0x51, 0x32,
                       0x3a, 0x9f, 0xb8, 0xaa, 0x4b, 0x1e, 0x5e, 0x4a, 0x29, 0xab,
                       0x5f, 0x49, 0xff, 0xff, 0x00, 0x1d, 0x1d, 0xac, 0x2b, 0x7c};

It's possible convert the string hex into matrix byte in C++ with this code
  vector<unsigned char> ToHexIntoVectorByte(string &hexData)
{

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

  }
  return *bytes;
}

for extract the matrix in the unsigned char using vectorresult.data() and if using the Bitcoin-Cryptography-Library the final code is
vector<unsigned char> vectorByte = ToHexIntoVectorByte(stringHex);

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

Do you recommend some C ++ functions that convert the string into bytes?


text:
The use of Bloom filter in SPV nodes
I know what Bloom Filter (BF) is, and I'm aware of this post and this paper. But I don't understand how it's used in bitcoin.
I can imagine that an SPV node encodes the transaction(s) it's interested in, into a BF and sends it to full node. What I don't understand is that what does the full node do after that?
Does it traverse through all the previous transactions and check which one is in the BF and sends it to the SPV node?
Also, it's not clear how private the approach would be, because at the end the full node retrieves what the SPV node wants and sends it to the node, so it knows what it's interested in.

If the goal is to preserve the privacy of the SPV's query, then some sophisticated approaches such as private information retrieval or oblivious ram must be used but they are not efficient for the bitcoin setting.

I can imagine that an SPV node encodes the transaction(s) it's interested in, into a BF and sends it to full node. What I don't understand is that what does the full node do after that?

The full node goes through every transaction on the blockchain. (Or, at least, every transaction that happened after the wallet was created.) It checks the following things against the bloom filter.

Test the hash of the transaction itself.
For each output, test each data element of the output script. This means each hash and key in the output script is tested independently. Important: if an output matches whilst testing a transaction, the node might need to update the filter by inserting the serialized COutPoint structure. See below for more details.
For each input, test the serialized COutPoint structure.
For each input, test each data element of the input script (note: input scripts only ever contain data elements).
Otherwise there is no match.

(Source.)
If it matches, it's sent to the SPV node. The SPV node discards the false positives.

If the goal is to preserve the privacy of the SPV's query, then some sophisticated approaches such as private information retrieval or oblivious ram must be used but they are not efficient for the bitcoin setting.

I don't know of any private protocol that doesn't require the full node to scan through the entire blockchain for every request.
If you know of one, let me know. :) Always interested to hear about that kind of thing.

Thanks for the answer and source. In the links I provided in my question,  it's said the Bloom Filter is also used to hide (to some extent) the query of SPV nodes but it's not clear to me how it's achieved.

Bloom filters naturally have false positives. If a key matches a bloom filter, you can't tell if it matches because that key is in the user's wallet, or because it's a random false positive. However, there are ways to undermine this, like checking both the key and the pubkeyhash, as the paper you linked describes.


text:
how to generate SECRET_KEY prefix?
base58Prefixes[SECRET_KEY] =     std::vector<unsigned char>(1,176);

I need prefix L , but i cannot find how do this, please do not post link to prefix list bitcoin , it's only for address prefix.
i search all google end find noting.

Are you creating your own currency, or are you trying to find the value for an existing one? In the former case, set it to whatever you like.

did you ever figure this out?

Addresses and private keys are encoded using Base58Check Encoding. The prefix bytes are chosen such that once whatever you are encoding is actual encoded with Base58Check Encoding, you will end up with a string that has the intended prefix character.
The process of creating a Base58Check encoded string is described on the bitcoin wiki:

A Base58Check string is created from a version/application byte and payload as follows.

Take the version byte and payload bytes, and concatenate them together (bytewise).
Take the first four bytes of SHA256(SHA256(results of step 1))
3.Concatenate the results of step 1 and the results of step 2 together (bytewise).
Treating the results of step 3 - a series of bytes - as a single big-endian bignumber, convert to base-58 using normal mathematical steps (bignumber division) and the base-58 alphabet described below. The result should be normalized to not have any leading base-58 zeroes (character '1').
The leading character '1', which has a value of zero in base58, is reserved for representing an entire leading zero byte, as when it is in a leading position, has no value as a base-58 symbol. There can be one or more leading '1's when necessary to represent one or more leading zero bytes. Count the number of leading zero bytes that were the result of step 3 (for old Bitcoin addresses, there will always be at least one for the version/application byte; for new addresses, there will never be any). Each leading zero byte shall be represented by its own character '1' in the final result.
Concatenate the 1's from step 5 with the results of step 4. This is the Base58Check result.

The resulting prefix character is also dependent on the size of the data being encoded.
The only way to get a prefix byte that you want to use that has a specific character is to guess and check. The data you are encoding must be of a fixed length, and even when it is, you may still end up with multiple possible prefix characters for a given prefix byte.
A list of prefix values and the characters they produce for 20 byte values are also available on the bitcoin wiki

hmm, not sure what you are asking. Normally you have a private key in hex chars. When you do a base58 encoding, you use hex 0x80 as prefix, which results in "K" or "L" at the beginning of the so called WIF compressed key (wallet interchange format). It would be "5" for a normal WIF key. If this is what you are looking for, you may read up (online available) the chapter http://chimera.labs.oreilly.com/books/1234000001802/ch04.html#private_public_keys from Andreas' book "Mastering Bitcoin".

litecoin have 176 but how they get this, a ask where find the list of prefix for this key , or how convert L to hex end to decimal for find what value need :/
all altcoin have different privat key prefixes... But how create it no explaining    , not list of baseprefix how for address.


text:
How to calculate nbits from powlimit
I remember some where was table and python scrypt for do this , when reinstall my debian i was lose this script.
Example we hv uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
what is = 0x1d00ffff

The formula for the conversion can be found on the bitcoin wiki.
Essentially, the first byte indicates the number of trailing 0 bytes (minus 3 for some reason). The remaining 3 bytes are the next 3 bytes of the target.
So 0x1d00fffff has 0x00ffff followed by 0x1d - 3 = 26 trailing 0 bytes with the whole thing padded out to 32 bytes. So the final result is 0x00000000ffff00000000000000000000000000000000000000000000000000000.


text:
Completing a bitcoin transaction
I sent bitcoin to a company address for investment .  Transaction was confirmed. The output to the company address indicates that it has been spent.  However, the output to the other address shows output is unspent. Two questions: Does this mean the company has received the payment for the investment? Can l claim the unspent output ?

Does this mean the company has received the payment for the investment?

Yes
Once a transaction has more than about 6 confirmations it is regarded as complete and the money is fully under the control of the recipient

Can l claim the unspent output ?

No and Yes.
If the recipient hadn't yet spent the money you sent them, it is still their money not yours. You no longer have any control over it.
The change returned to you is under your control, you can spend it whenever you want. Your wallet should show this change amount included in your wallet "balance"

What would be the advice when a company you have sent the bitcoin to insists the bitcoins are not in their wallet even though the transaction shows it was completed (Spent)?

@Mapanza: The same advice I'd give someone who sent cash (or a Western Union money transfer) to a company who then denied receiving the money. 1) check you sent it to the right address. 2) report theft/fraud to your local police 3) Don't do business with them again.


text:
What is the need for multiple private keys?
From what I understand, there is initially a seed from which the private keys are derieved and from that the public key respective to each private key is derived.
The public key is essentially the wallet address. So now say I wish to receive 10 BTC from Bob. So Bob makes a transaction "paying 10 BTC to wallet address #####(mine)" and signs it with his private key.
I (or the validators for that matter) can verify it by looking at the digital signature with Bob's public key. And if I have to send 10 BTC to Bob, I do the same as above.
What I don't understand is what is the use for having multiple private keys when just a single one can suffice? (I've read somewhere that wallets act more of a storage for keys than storage for Bitcoins, that's why the doubt).
Also, if there are many private keys (=> public keys => wallet address) pertaining to each transaction, how does it become possible to trace back to the previous transactions as each has a different address?

From what I understand, there is initially a seed from which the private keys are derieved and from that the public key respective to each private key is derived.

Yes, if the wallet follows BIP 32 (hierarchical deterministic wallets), then this is the case. Some older styles of wallets will just derive random new keys, but this makes it harder to create backups efficiently.

The public key is essentially the wallet address.

Not quite: the public key is hashed to obtain the public address.

I (or the validators for that matter) can verify it by looking at the digital signature with Bob's public key.

Correct, the public key is included in the transaction data, so that the signature can be verified.
Note: you should be a validator (meaning, you run a node that checks to ensure transactions are valid), otherwise you're trusting someone else to do this. Miners work to confirm transactions, which is different in an important way.

What I don't understand is what is the use for having multiple private keys when just a single one can suffice?

If you only stored one private key, then you would only be using one address, which is very bad for your privacy (and the privacy of those you transact with).

I've read somewhere that wallets act more of a storage for keys than storage for Bitcoins, that's why the doubt

That is true. Bitcoins themselves are not 'stored in a wallet', rather, the history of them is tracked publicly, on the distributed blockchain ledger. It is just the private keys that allow some amount of bitcoin to be spent, that your wallet app will keep track of.

Also, if there are many private keys (=> public keys => wallet address) pertaining to each transaction, how does it become possible to trace back to the previous transactions as each has a different address?

Your wallet will be able to keep track of the history of your transactions without any issue, but third party observers will not be able to (which is the entire point! Privacy is important).

About the last point, how does it work exactly? I understand that a third party obersvers can follow all of the addresses that are used and where they are sending their bitcoins. He just not know who has he private key for those public keys/addresses?

@totalMongot yes, exactly that. Parties to the transaction will know which addresses are theirs. Third party observers can see the addresses, but who controls/owns each address will not necessarily be known to them.

thanks you for the answer :)

The main reason to use multiple private keys is for privacy. Say you receive 1 BTC at address A, and you want to send 0.1BTC to someone at address X. (We'll neglect tx fees for easy math).
0.1 BTC Address A -> Address X
0.9 BTC Address A -> Address B

Now assume you were trying to watch any spending activity from the User at Address A, how would you know whether they own Address X or Address B? If you send change back to Address A, then it is easy to continue to track the user's spending after the 1st transaction. So, wallet applications keep track of all of the newly generated change addresses (since it generated them), so they can be aware of all the user's unspent Bitcoin.
Another reason might be to manage multiple accounts for accounting purposes. BIP32 is a common standard for generating sub-accounts using the same master key pair.


text:
Sending Bitcoin from my wallet to a different bitcoin address
When I want to send bitcoin from my wallet to another bitcoin address in blockchain.info, I must to have a private key. How I can obtain a private key?

You want to send to another address of yours, or to an address of some other person?

When completing a transaction via bitcoin, you never need the target's private key.  Never give your private key to anyone.  NEVER.  The private key is the only secret you have that protects your bitcoin.  If you give your private key to someone else, they can "spend" your bitcoin.
When sending money to someone, you simply need an "address"; the recipient should provide you with that address.  If you are attempting to send money from one BlockChain.info wallet to another waller on BlockChain.info, you can get the target address by clicking on the "Request" link inside your wallet.
See this BlockChain.info support page for details.


text:
What is most efficient way to validate bitcoin target (difficulty) value in C++
I have two values
1. h = hash of the block (32 bytes long in memory representation - not hex)
2. bits (uint32_t)

To make the calculation easier we create a function difficulty such that:
auto d = difficulty(bits)

Now what is the best way to create such a difficulty function that, I believe should, return a 256 bit value?
Then I am thinking casting both h and d values into an array of type uint64_t and compare all 4 elements from msb (bit 255) to make sure the condition holds.
Is there a better way for comparing as well?

Bitcoin Core has its own arith_uint256 class for calculations on 256-bit unsigned integers.  Its code to convert "bits" (so-called compact format) to arith_uint256 can be found in arith_uint256::SetCompact in the file arith_uint256.cpp.
So you could always just use its code directly.  This might be a good idea because if your version differs in any way from their behavior (e.g. rounding errors), you could disagree with Bitcoin Core on the validity of a block.  If your version is in a widely-used client, this would fork the block chain.

I have come up with following version that seems to be working correctly for few test cases I have defined.
First we need a helper function that prints hex value given binary data:
void hexdump(unsigned char *data, int len)
{
    int c = 0;
    while (c < len)
    {
        cout << hex << std::setw(2) << std::setfill('0') << static_cast<int>(data[c++]);
    }
    printf("\n");
}

Now lets define the actual function that takes block.bits and converts it to 256 bit value in memory:
bool convert_bits(uint32_t bits, uint64_t* value, int val_len = 4)
{
    assert(val_len == 4);
    assert(value != NULL);

    if (val_len != 4 || value == NULL)
    {
        return false;
    }

    // if bits =  0x1b0404cb, hex target = 0x0404cb * 2**(8*(0x1b - 3))
    uint32_t x = 8 * ((bits >> 24) - 3); // number of zero bits on right
    uint64_t val = bits & 0x00FFFFFF;

    // Number of maximum bits required for val is 24.
    assert(x <= (256 - 24));
    if (x > (256 - 24))
    {
        return false;
    }

    int startq = (3 - int(x / 64));
    int endq = (3 - int((x + 24) / 64));

    int shift = ((3 + endq) * 64 - x);
    if (startq != endq)
    {
        shift = 64 - shift;
    }

    value[startq] = htobe64(val << shift);
    value[endq] = htobe64(val >> shift);

    return true;
}

Now lets test the above function:
int main()
{
    uint64_t num[4] = { 0, 0, 0, 0 };
    if(convert_bits(0x1b0404cb, num))
    {
        hexdump((unsigned char *)num, sizeof(uint64_t) * 4);
    }
    return 0;
}

This prints: 00000000000404cb000000000000000000000000000000000000000000000000

htobe64 is particularly slow (about 50 executions in a single thread with my i5-1240P).

I ended up using https://gist.github.com/Ending2015a/70373b2f6f665a765b4d0b0c427f052b

Bytes shift don't need us to pay attention to the endianness. Endianness must be taken in account iff the code is copying integers with memcpy.


text:
why can I not recreate my blockchain.info addresses?
I'm trying to generate a list of all my Addresses ever used on blockchain.info wallet with balances prior to august 1st,2017. i used the tool below to do this:
https://github.com/iancoleman/bip39
But when I feed this with my Twelve word backup phrased from blockchain wallet, It does not work and gives the error "one word is not listed in dictionary!"
what's the issue? what should i do?

I solved the issue! the point was that in fact I should have removed 1. , 2. etc before my 12 word seed phrase.pretty funny, huh? :)

You can click the check mark button by your own answer, to mark this question as resolved.  Otherwise, the system will think it does not have any satisfactory answer and will keep trying to encourage others to answer it, which is annoying.

authors: ศักดินา บุญชิต


text:
What the maximum expenditure on a lighting network channel depends on
I'm new in the lighting network world, and now I have a question on "How it work", so the light network, work with channel and one node for connection to a channel must spend a little of satoshi for "subscribe" to channel, I hope to understand well.
My question is what is the minimum value the satoshi for "subscribe" to the channel?
Also, with the satoshi, I finance the channel and I can spend the maximum value of the loan, right?
An example, if I have a channel X with 10000 satoshi, I can't spend the value with my node > 10000?

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

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

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

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

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

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

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

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

You don't subscribe to a channel you open a channel. If you open a channel with 100k Satoshi you can send up to 99k Satoshi (the rest is blocked as the channel reserve). Once you have send some satoshis you can receive them back and resend them. Thus as long as you "earn" your money back you can send as much as you wish.
The lower bound for channels should be 20k satoshis but many people recommend to make larger channels. I suggest to do at least 1million Satoshi per channel. In general a small channel is not very useful.

Thanks so much, but I have a question, and I do an example for this use case, if I open a new channel, with x satoshi, I can use the x - commissionTx but If I want the close channel without use the channel, the satoshi that I use for open challe are they still mine?

Yes if you close the channel you get your satoshis back (minus the onchain fees  that you pay for closing the channel. These are higher if you force close the channel) remember opening and closing are always onchain tx.


text:
How to store full blockchain on server and run Bitcoin Core as client only?
How to store full blockchain on server and run Bitcoin Core as client only?
I want to run Core wallets on 2 or 3 or even more computers on my local network. The best way to store the full blockchain is to put it on one server on my local network.
I want the Core client to read only the blockchain data and listen for changes from the server but not write anything to the server, like a read-only directory. The server should be the only one allowed to write updates to the blockchain data.
The Core client should write private data to %AppData%\Bitcoin as usual but segregate the blockchain data onto the server.
How do I do this?

It is possible to configure your server/clients as follows, although it is not exactly what you have described. I presume that you still want each client to have its own separate wallet.

On your server, make a full installation of Bitcoin Core.

In the config file set bind=<internal network IP>.
Set any other options, for example to enable incoming peers from the internet.
Restart server node for config to take effect.

On each client make a full installation of Bitcoin Core.

In your config file set connect=<server IP>.
In your config file set prune=<n> where n is greater than 550MiB. This will limit storage requirements.
Set any other options.
Restart client node for config to take effect.

Using connect= disables automatic connections so, your nodes will only connect to the server.

This is not supported.
What is supported:

Run Bitcoin Core in pruning mode (which means it still has a local blockchain, but only recent blocks are kept.
Run lightweight software as client, and make it only connect to your (clearly trusted) server. This way you get a fully validated chain, without the resource usage.

You could try Bitcore instead. It contains a fork of the reference bitcoin implementation with added support for indexing of data, and includes an API for running it on a server. You can then use the API from your local computers or access the built-in blockchain explorer.


text:
Error validating transaction using BLOCKCYPHER
I recently followed the steps on the answer by StephenM347 to the following problem:
Cannot access my bitcoins because my wallet is still synchronising. What can I do to spend them immediately?
However, on the last step (broadcasting my transaction on https://live.blockcypher.com/btc-testnet/pushtx/) I got the error message:
Error validating transaction: Transaction eddxxxxxxxxxxxxxxxxx orphaned, missing reference 00350a8xxxxxxxxxxxxxx.
I am very new to this and all I want is to have my bitcoins on a MultiBit wallet (where I sent the Bitcoin Core bitcoins to).
Could anyone point me in the right direction here?

When a transaction is orphaned it usually means that it is part of an orphaned block. This happens occasionally so there is no reason to panic :)
According to Anonymous in this answer, orphaned transactions are not lost and are returned to the memory pool where miners can pick it up again and attempt to confirm it.
In short, as long as the transaction has a high enough fee (which it should have considering it was added to a block already) it should confirm eventually.
You can also keep track of it using this service:
https://mempool.observer/


text:
At the moment SegWit2x forks, will mining be way easier?
Is there a need for people to run full nodes that are mining on CPUs when/if the SegWit2x fork occurs?
Will almost all of the mining power be switched over to SegWit2x?

No, it will not be easier. The "difficulty" of mining is determined by the difficulty (the value). The difficulty only adjust itself every 2016 blocks, so when the Segwit2x fork happens, the difficulty will not adjust until 1152 after the fork happens. So the difficulty will not change at the time of the fork for either chain (barring any difficulty adjustment thing that segwit2x decides to implement in the future) so it will be equally difficult to mine on both chains and thus not easier at all.
When the difficulty adjusts, it can only adjust by a factor of 4 at most, so only down to a difficulty 1/4th that of the difficulty at the time of fork. This means that it won't be possible to CPU or GPU mine either chain for a while as the difficulty needs to adjust down a lot.

@Andrew, Couldn't a fork decide to change the adjustment window?

@Pacerier yes they can do that. However it seems that Segwit2x does not have any plan to do so.

@AndrewChow, Btw, since all miners have decided to support branch 2, does that mean that relatively speaking, mining going to be much much easier on branch 1?

@Pacerier No, read the answer to this question which asked exactly that. The same answer can be applied to the Bitcoin (non-segwit2x) chain as well.


text:
Needed maths for full understanding
I often come across papers written in the Bitcoin space involving some math that I am not formally versed in.
Could anyone point out general topics in math that I should have a formal grasp on in order to really understand cryptography?

The signatures in Bitcoin (and Bitcoin Cash, Ethereum, and many other cryptocurrencies) are generated using elliptic curve curve cryptography. I found these videos very helpful in that regard:
https://www.youtube.com/watch?v=jQLmaBjYrk4
Other than that, you probably want to look into hash functions and asymmetric cryptography in general.
As a general introduction to cryptography, I took the cryptography course on Coursera which I can really recommend. This goes into the role of the adversary and what he can achieve. The teacher of this course, Dan Boneh, is, I believe, among the ten most renowned and best cryptographers in the world. On top of that, he is a very good teacher. The course does go into both symmetric and asymmetric cryptography but in the asymmetric field, it only teaches you RSA and Diffie-Hellman, not elliptic curves. Use the above videos for that.

I updated the answer.


text:
How to test Bitcoin's RPC interface?
I can't find any tool to test RPC interface. I am looking for something like Postman (Chrome extenstion). I would like to send request (with login and password) and see their responses in JSON.

I'm looking for something similar as well. Or at the very least, a tutorial

Not to worry. Found what I needed here: https://en.bitcoin.it/wiki/API_reference_%28JSON-RPC%29, and here: https://github.com/jgarzik/python-bitcoinrpc

My favorate tool to test an API endpoint is always curl
curl --user user --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockchaininfo", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/

source: https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)#Command_line_.28cURL.29


text:
Have a bunch of wallet.dat files. What alt-coins do they have (and may be how much)?
A few years ago I mined a couple of alt-coins. Now I have approximately 5 wallets which are named in non-suggestive way: wallet_01.dat, wallet_02.dat, ..., wallet_05.dat. Each of them has reasonable amount of coins, also I have no idea how much exactly and what coin correspond to each wallet. Now I would like to restore some order by checking what do I have and how much.
Is there a way for me to figure this out? I do not remember exactly what these alt-coins are but have approximate ideas (probably can try to remember and select 30 potential candidates).
With this, I clearly can try each of the alt-coin client, wait for sync (may be do not even need this) and try to open each of the wallet. This will be very slow and because I am not 100% sure I will be lucky with my 30 crypto-coin guesses might take even longer.

So, is there a way to find a corresponding alt-coin for a wallet. Even maybe finding how much coins are in the wallet without downloading the client?

I think you can narrow your search space. If you're on linux, and you run the command
strings wallet.dat | grep purpose | less

you should get a list of all of the addresses in the wallet, even if the wallet is encrypted. You can check that against a list of address prefixes for each altcoin.
If you run
strings wallet.dat | grep tx | less

you should get a line for every transaction that wallet has sent or received. (This only catches transactions that were present the last time the wallet was open. If someone sent you a billion cryptobucks ten minutes after you logged out, this will not catch that.)

Thank you for looking into my question. When I run strings wallet.dat | grep purpose I get no output at all. The same for strings wallet.dat | grep tx.

@wallet-hoarder Can you try name or ckey or key ? Does strings wallet.dat print anything at all?

strings wallet.dat returns many many strings, | grep names returns something like name"IdOs4Users... (changed because I do not know whether it is important). For some wallets it has a bunch of such names. ckey returns nothing. key returns many lines, majority look like key!

@wallet-hoarder That's a good sign. Part after name is an address. Also, if key shows up, but not ckey, then the wallet is not encrypted.

It is highly likely that the wallets are not encrypted because they were in a truecrypt container. Thanks to you I found that the first character in the name can tell me the currency. In one of the wallets the first character is Q. I found this database for altcoin prefixes. The integer value of Q is 81, and it tells me that it is PotCoin (I am very sure I have never mined this). Q also suggest quarkcoin which I remember mining. Do you know how to find the currency from this character?

@wallet-hoarder My best idea is to try both and see if one of them works.

Just open each file and look for name"
the address will be after that.

Hi weff, welcome to Bitcoin.Stackexchange.com. You seem to have an idea how to help the asker. Could you please further explain how knowing the address would help the asker to determine which altcoin the wallet belongs to?

And what should I do with this address?

Open in a hex editor search for name, might say team doge or some other thing that will be simple and if you are not on linux getting python and a few plugins working just to figure out what coin is the wallet.dat is a pain. Although if you need to extract a key or try to fix it you will want python and some other tools.
There is a hex editor plugin for notepad++ if you are trying to find one.


text:
Can I change bitcoin core code for my node?
Bitcoin is working on some of sort of code. Now it is p2p network as well. When I am accessing network as a full node, I have to download the whole ledger first and then I can proceed.
Where does the code comes in picture? Do I download bitcoin core code as well with the ledger? Since, there is no centralized server, this code has to be working on all nodes.
Also, Can I access the network if I have made some changes to the code. Say, I have changed the value of the BTC rewarded for mining, and then accessing the network, to get increased reward.

depends of your nodes

Can you explain a little??

there might be too many questions in one post, which makes answering difficult. Next time try to raise separate questions please.
1.) yes, bitcoin is working on an extremly well tested code. And yes, there is a p2p network to excahneg information about valid transactions and valid blocks.
2.) hmmm, yes. Full nodes load the whole history ("the Blockchain") with all transactions since inception. There are however nodes, that can use pruning. Then you only keep a set of last transactions in your node.
3.) Which code? Bitcoin exists of several 1000 lines of code.
4.) The bitcoin core wallet can be downloaded as source code, then you need to compile it, to get it running. Or you download the binary, which is directly executable. The software includes a wallet. And a fresh start will download the "ledger" ( we call it the blockchain).
5.) yes, since there is no centralized server, this code is working on all nodes.
6.) Yes, you can access the network after code changes. And yes, you can change block reward. It is just, that your local node might think, you have had a higher reward, but when you try to spend this at any point in time, it will be recognized as an invalid transaction by the other nodes.
I consider reading the book from A. Antonopoulus "Mastering Bitcoin". A lot of stuff get's much clearer, than just a few words here. It is available in many languages. The online link is here: http://chimera.labs.oreilly.com/books/1234000001802/

on your point 6.
So when I broadcast my minted block with 100 btc mining reward, other nodes will not accept the block considering the reward as invalid, or it will cause problem only I try to spend my earned blocks ??

There is a rule that says: "Reject if coinbase value > sum of block creation fee and transaction fees" (https://en.bitcoin.it/wiki/Protocol_rules). I haven't tested, maybe meshcollider, andrew or @murch can confirm.

shouldn't it be rejected if coinbase>block creation fee only. If it is referring to what I think it is.

If a block's coinbase transaction claims more money than the (currently 12.5 BTC) subsidy + fees from other transactions in a block, that block and every block built on top of it will be considered invalid, and treated as non-existing by full network nodes.

A full node participates in the verification of new blocks, and can also send new blocks to the network. Following the network rules. This verification based on database that you download from network.
If your changes are reflected in these functions, in the sense that they give a different result, then you will not be perceived by the network as a full node.
As for the reward for the mining, as a full node you can select the transactions from the pool at your discretion, filtering by the commission you need. And if you mined the block with transactions wich you chose faster than the rest, the commission will be yours.
So there is no any technical limits for changing the bitcoin core code.


text:
Does bitcoin mining power add up and how does this affect the difficulty?
I read that if my hashpower remains constant, and total network hashpower increases, after 2016 blocks difficulty will increase. Now as far as I have understood, difficulty increases if blocks are mined before 10 min and I find no co-relation of this statement with previous one.
Say current total hashpower is 100,000 MH/s. If 2 people have joined network with hashpower of 50 MH/s. Total haspower is 100,100 MH/s. There are large pools having 5,000 MH/s or even more on current difficulty, mining at block/10 min, chances are very low that that these new miner with much low hashpower can calculate block @ <10 min.
This thing make sense if all machines in mining pools (say 50 MH/s), work on different blocks, then new miners can get block possibly in less than 10 min. But if hashing power is added i.e. 5,000 MH/s is used for finding block, then such minor additions should have no effect on difficulty.
So what exactly is going on here ??

Mining is a lottery, not a race.
Think of mining as digging for gold in your own piece of land. Everyone has an equally large piece of land, but some people can dig faster than others (=hash power).
One in every billion grains of sand contains gold. Despite that very low fraction, there are still plenty of gold grains out there. There are so many grains of sand out there that even just in your own piece of land, there are plenty of good ones.
However, the gold is randomly mixed with the pieces of sand, so every grain of sand you dug up has an equal chance of being good. Certainly those who dig through more sand faster stand a higher chance of winning, but even the very first grain you look at has a chance of being gold.
So how long does it take for a gold coin to be found? On average, as long is needed for all miners together to go through one billion grains. So does it matter if someone only adds 1% of the digging power to the total? Sure, he now has a 1% chance of finding the next gold grain. That isn't much, but on average that will absolutely reduce the time needed for a solution by 1%. And the difficulty (the ratio of sand to gold) will go up occordingly.

thanks, great reference btw.
Also can you tell, if all hashpower by different miner joining a mining pool is added up to solve one block or are working on different blocks ??

Everyone works on different blocks, always. However, with more people working, the rate at which blocks found on average will still be higher.


text:
Bitcoin SPV not able to fetch transactions
I am developing a Bitcoin wallet SPV and using 3rd party SDK for the same.
However, I tried to create wallet and it gets successfully created and I can also restore those wallets but amount and transactions not coming. Making amount always 0 as amount calculation depends on transactions.
//
//  XORWallet.swift
//
//
//  Created by Paresh Thakor on 06/07/19.
//

import UIKit

let KEY_MNEMONIC = "wallet_mnemonic"

class XORWallet: NSObject {
    static let shared = XORWallet()

    var peerGroup: WSPeerGroup?
    var wallet: WSHDWallet?

    func create(_ seed: WSSeed? = nil) -> WSHDWallet? {
        let parameters: WSParameters = WSParametersForNetworkType(WSNetworkTypeMain)
        var theSeed: WSSeed? = seed
        parameters.scriptAddressVersion()

        if theSeed == nil {
            theSeed =  (WSSeedGenerator.sharedInstance()?.generateRandomSeed())!
        }

        if let s = theSeed {
            let store: WSBlockStore = WSMemoryBlockStore.init(parameters: parameters)
            wallet = WSHDWallet.init(parameters: parameters, seed: s)
            let downloader: WSBlockChainDownloader = WSBlockChainDownloader.init(store: store, wallet: wallet)
//            wallet?.usedAddresses()
            print(wallet?.usedAddresses()!)
            print(wallet?.receiveAddress()!)
            print(wallet?.sortedTransactions())
            print(theSeed?.mnemonic()!)
            let peerGroup: WSPeerGroup = WSPeerGroup.init(parameters: parameters)
            peerGroup.startConnections()
            NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: "WSPeerGroupDidStartDownload"), object: nil, queue: nil) {(note) in
                print("Jay Mataji")
            }
            peerGroup.startDownload(with: downloader)
            NotificationCenter.default.addObserver(forName: NSNotification.Name(rawValue: "WSPeerGroupDidFinishDownload"), object: nil, queue: nil){(note) in
                print("Completed")
            }

            self.peerGroup = peerGroup
        }
        return wallet
    }

    func generateSeed() -> WSSeed? {
        let theSeed: WSSeed? = WSSeedGenerator.sharedInstance()?.generateRandomSeed()
        return theSeed
    }

    func saveToUserDefaults() -> Bool {
        if let w =  wallet,
            let m = w.seed()?.mnemonic() {
            let def = UserDefaults.standard
            def.set(m, forKey: KEY_MNEMONIC)
            def.synchronize()

            return true
        }

        return false
    }

    func loadSavedWallet() -> WSHDWallet? {
        let def = UserDefaults.standard
        if let m = def.string(forKey: KEY_MNEMONIC) {
            let seed = WSSeed(mnemonic: m)
            return create(seed)
        }

        return create()
    }
}

Create a wallet like,
if let wallet = XORWallet.shared.create(XORWallet.shared.generateSeed()) {
            print(wallet.allReceiveAddresses()!)
            print(wallet.balance())
        }

Please help me solving the issue as here wallet.balance() always comes 0. There is balance for this account.
I am  new to bitcoin dev and may messed up  something.

Are you rescanning the blockchain once you create your wallet? Or in the case of SPV "replaying" the chain once all your addresses are added to the bloom filter?

@pinhead  I did not really get you. As  mentioned  in code, I am creating wallet by create() and then access balance and address by specific methods. I don't get about bloom filters and "replaying" stuff.


text:
Bitcoins and transactions missing
I had a wallet which had approx $660 worth of bitcoin somewhere around 0.05 BTC and all of a sudden it has vanished and my transaction tab shows nothing.
I have put my receiving address into the block chain and it shows that a transaction sometime in March of 2019 was made and I didn't make any transactions in March of this year. How odd. Anyway this has blown my mind and I don't know who to ask for help or what to do ?
Any ideas or can someone be of assistance? I really don't know what to do. In addition, I was thinking that maybe bitcoin had plummeted on the market and maybe it lost value and that's why maybe I have none but to be fair there was enough bitcoin in my wallet but no nothing.
Am I doing something wrong and it is safe for me to paste my receving address here for someone to take a look or is that a bad move ?
I only use my bitcoin to pay for VPN and it does show that I renewed my VPN in august which is when I did make a transaction so why it is showing a transaction in March 2019 makes no sense whatsoever.
I've read that something does cause bitcoin to appear as vanished but to be fair I've re-synced which took over 24 hours and I created new receiving addresses which I read can sometimes re-gig the system and your available bitcoins appear.
Nothing?
Any ideas ?
Thanks
KC

You can safely post the address here. It will begin with 1 or 3. Are you sure you are checking the right address? Many wallets don't re-use address and generates a new one for every new transaction

My address: 1MQbH1iM5iauKza39EVQenmmsapRwpbzMH

It shows a transaction 2019-03-12 08:28:05. I used it in August 2018 to renew my VPN and that's all. I have no idea what's going on.

I think the software that I use does not automatically create a new address you have to do this manually I think. Anyway I'm upset and doing to make a coffee to relax

Any thoughts about the address I specified ?

Any ideas or can someone be of assistance? I really don't know what to do

TL;DR:  Your money has been stolen. There is nothing you can do that has any significant probability to recover your $660.
The thief got access to the private-keys stored in your wallet.

a transaction sometime in March of 2019 was made and I didn't make any transactions in March

One possibility is that someone gained access to your wallet and stole your money.
One recent issue was with the Electrum wallet.
However, if you have a PC wallet or access an online wallet from a PC it is always possible that other malware on your PC stole your passwords and used them to access your wallet, steal money and finally erase logs and data to cover their tracks.

I have put my receiving address into [a] block chain [explorer]

Most modern wallets are HD wallets that create a new receiving address for each transaction.

I created new receiving addresses which I read can sometimes [make] your available bitcoins appear.

I've not heard of this, it would have to be a bug in a specific wallet. In general I would be surprised if this helps.
If you found unexpected transactions in a blockchain explorer, it is unlikely that there is a fault in your wallet software. More likely you are a victim of theft.
If your wallet is misbehaving. One solution is to make a careful copy of your seed-words or your private key (you should have these already in a safe place), then use those on a fresh computer (or phone etc) to download and install the wallet software from the only genuine trusted website and make a new duplicate wallet and let it synchronise fully. You don't need to erase your old wallet until the new one is working fully.

it is safe for me to paste my receving address here

Yes.
There are potential privacy issues if you only use one receiving address. Anyone can see a list of all the transactions made involving that address. But it doesn't give anyone any way to access your money.
You can also safely publish a transaction id and the name & version number of your wallet software (e.g. bitcoin-core 0.18.0, electrum 3.3.4, ...)
Never give anyone your private key, your seed-phrase / recovery-phrase or the password to your wallet or online wallet or account. Changing a previously disclosed password does not re-secure your wallet/account.

Also this is what I read regarding created a new address can sometimes show balances again: reddit.com/r/Iota/comments/6sim7o/

That advice relates to IOTA not to Bitcoin.

I'm positive that I never used bitcoin this year

Everything suggests your Bitcoin was stolen.
I wouldn't use that wallet again and I wouldn't use that PC for any new wallet or any further financial activity again. Even after zeroing the disks and cleanly reinstalling the operating system, I'd worry about BIOS malware, infected USB devices, etc.

My address is: 1MQbH1iM5iauKza39EVQenmmsapRwpbzMH

Also this is what I read regarding created a new address can sometimes show balances again: https://www.reddit.com/r/Iota/comments/6sim7o/psa_if_your_wallet_displays_a_0_balance_suddenly/

The client that is use is Multibit 0.5.18 and is no longer supported as I tried to look for an updated version they've shut shop and discontinued.

To be honest I don't use a private key or seed-phrase or recovery phrase - I have a local wallet on my PC which I use with that Multibit software which is local on my PC and I run windows 10 and my machine is secure no one has physical access and to be fair I use malware bytes.

Thanks for replying and take a look at my address and see if you can see anything odd ? I'm positive that I never used bitcoin this year I only use it to renew my VPN on a yearly basis and the transaction in Aug of 2018 is correct because that is when I renewed my VPN services via bitcoin which I use for anonymity purposes. Anyway my bitcoin is gone and I'm well gutted.

@user96814 you shouldnreally make a backup of your wallet (recovery phrase). If your PC hard drive crashes (and it will, eventually), there is a good chance you will lose your wallet permanently. Also, for bitcoin users, malware bytes is not a sufficient defence against many attacks, it just provides a blanket reactionary defence against common threats. Be wary of depending on it to keep your bitcoins safe!

@user96814: Answer updated

I do have a backup of my wallet stashed in evernote. Will the funds be available in that ? But if someone has extracted my money using a transaction even after a restore wouldn't that transaction take precedence ?

It's funny you should mention Electrum wallet getting hacked and people losing their money. Multibit recommended people move to that platform. Maybe the software itself stole my money before they closed it down - I've never had a problem untili now -  funny how Multibit have disappeared off the scene. Is there no way to find out or challenge the wallet address who took my small amount of bitcoin ? I've traced it and it went to an address and was subsequrtently moved to a different address who's current funds are approxmiately 450k..

Any thoughts about the address I specified ?

Anyway flipping hell if you can't even keep a wallet on your own PC without some c*** taking your money then how on earth can someone extract my funds from my wallet. I've really gone off bitcoin now. I just can't see someone gaining access to my machine even via malware to steal my bitcoin there has to be another explanation. If my bitcoin was hosted online and it got jacked fair game but for my bitcoin to go missing from a wallet which was on my local PC is very odd. Has anyone checked the address i specified. I'm just really pissed off about what has transpired and to be honest I'm fuming!

@user96814 I checked that address in a Blockchain explorer. It shows the transaction in March which you mentioned. That's a real transaction. Since you didn't create it, someone else did. The only way they can have created a valid transaction is by using the private-keys from which your address was generated. How they got those keys can't be determined by looking at the blockchain. The keys are stored in your wallet (and in backups) A forensic examination of your PC (and your backups of your wallet etc) might reveal how the theft occurred.


text:
What happens if you copied private key and try to use it again?
I am very new to bitcoins. I have one question. Suppose some one copied their private key and saved it in their harddisk. Next they will do the transaction. Now since you already copied the private keys can you use it again?
How bitcoin prevent this?
I am asking this because. I wish to create something smaller for my brothers  school project. So I am out of ideas on how to prevent this.

Excuse me, your question is not clear to me. You probably lack some basic knowledge about private/public keys, addresses and transactions in Bitcoin. I suggest you look up some material on how Bitcoin works:

Quick explanation: https://bitcoin.org/en/how-it-works
Bitcoin Wiki: https://en.bitcoin.it/wiki/Main_Page
Detailed guides and references: https://bitcoin.org/en/developer-documentation

NOTE: I would add this as a comment, but I don't have enough reputation to do so.

Ok got it. It was my mistake. I thought coins are stored in your computer with every bitcoin as its own address. Now I understand it perfectly.

Every private key owner can spend any amount of coins on appropriate address, but every coin on any address can be spent only once. After spending the coin it is suggested to go into another address which has another private key.
upd: Technically they are stored on the blockchain file (>200GB now), which of course is able to copy and wanted to be copied, but your private key is the only ability to let your coins be moved in the chain - if (and only if) you have the proper key. So, the proper key is hard to get and easy to lose and you might not like the idea to copy it except of backup operation.

Your private key gives you access to your public key/address (wallet). Yes you can copy the private key as many times as you like (as people do for backing it up) but the same key is used for that same public key/address or any other address derived from that private key. An analogy would be making multiple copies of you front door key. You will have multiple keys but they still only open one door.


text:
How do can I create a bitcoin wallet with a already created address and private key?
I have a bitcoin address and a private key. What wallet can I use to import the key and address I already have? Every wallet I tried only lets you create a new address or use a 12 world recovery phase to access another wallet.
What wallet will let me directly import my private key & address?

Bitcoin Core supports importing private keys. Use the importprivkey RPC.

Jaxx allows this: howto-link
Or Exodus: howto-link
Both support multiple currencies. I would look at this list of wallets and if you find one that you like just google "walletname import private  keys" too see if it's possible and how to do it.

I know electrum lets you import private keys. I did this with the portable version but I assume thats its the same with the installed version.


text:
Where can I find a detailed network protocol spec?
I have been trying for a while to understand how the bitcoin network works, which I (kind of) do on a high level. However, all of the sources I read don't go into the details of the protocol that nodes use in order to communicate with each other.
I'm trying to make a client that directly asks other nodes for the last few blocks in the blockchain and displays it to the user. I know this isn't nearly as secure tracing all the blocks back to the genesis block, but I'm doing this mostly for fun and education. So I don't care that much about security.
I can't find any clear specifications for the protocol. There must be something obvious I'm missing, but I don't know what it is.
Where can I start, or how do I know what should be sent to other nodes in order to request a block?
Thanks in advance.

Sorry if sound too stupid, it's just that I'm new to programming blockchain nodes and I don't know where to start...

Possible duplicate of What happens if a miner receives a block but not its previous?. Although the linked question does not seem to be same as this question asked, but the answer contains detailed spec of how block syncing takes place.

Actually, that seems pretty helpful. Also, when I googled the format of a version message, I got to this site that explains the protocol quite extensively: https://bitcoin.org/en/p2p-network-guide#connecting-to-peers
Thanks @UgamKamat


text:
Destination address(es) when redeeming an HTLC
Starting from this text at https://en.bitcoin.it/wiki/Script:
"The script for a typical Bitcoin transfer to destination Bitcoin address D simply encumbers future spending of the bitcoins with two things: the spender must provide 1. a public key that, when hashed, yields destination address D embedded in the script ..."
and then looking at the HTLC script:
OP_IF
    [HASHOP] <digest> OP_EQUALVERIFY OP_DUP OP_HASH160 <seller pubkey hash>
OP_ELSE
    <num> [TIMEOUTOP] OP_DROP OP_DUP OP_HASH160 <buyer pubkey hash>
OP_ENDIF
OP_EQUALVERIFY
OP_CHECKSIG

My original thought was that the HTLC could only be redeemed to the address behind <seller pubkey hash> or <buyer pubkey hash>: they are the only data relating to addresses embedded in the script so must be the "destination address" referred to above. I understand this to be wrong.
Am I now correct in thinking:

That the two pubkey hashes merely establish the right of the redeemer to take the respective branch;
There is in fact no "destination address D embedded in the script" for an HTLC;
That the seller or buyer may redeem to any address they like;
And that address can remain undecided through the funding and life of the HTLC until the moments before redemption?

The inputs of a transaction have absolutely no ability to effect the outputs in any situation. They can only define who can spend, not the conditions for how they go about spending it.

It had not occurred to me before now that the redeemScript is one of the inputs, so thank you for that - that's obvious to me now it's pointed out.
I suspect I was conflating "the script" used on the page in the narrower sense of "redeemScript".


text:
Unconfirmed transaction, cannot see money in receiving account
I sent 0.6 bitcoin from my coinbase account to my blockchain account. The money doesn't show up in my blockchain account and shows as pending on my coinbase account with 0 confirmations. It has been about 2.5 hours. I'm a little worried because blockchain changes the wallet id for each transaction, and I never requested the money but just scanned the QR code from my iphone. Am I just being paranoid?
Miners fee was 0.00115, or about $5
What happens if it never gets confirmed or that address is no longer valid?

Barring chain reorganizations, valid transactions are binary: either they are confirmed, then your money has been signed over to the recipient, or they are yet unconfirmed and your funds are still unspent.
A transaction can remain valid but unconfirmed indefinitely, if the miners never chose it for block inclusion.
Most wallets have a mechanism to forget unconfirmed transactions in order to be able to spend the funds elsewhere. When any of the funds used for the original transaction are used, the original transaction ceases to be valid.
Addresses do not become invalid after some time, and generally services keep records to associate addresses with the corresponding users even if an address didn't get used for a long time after it was generated.
For more general information on how to deal with unconfirmed transactions, please see: Why is my transaction not getting confirmed and what can I do about it?