How do you switch your bitcoinjs integrationfrom TransactionBuilder to transactions-psbt.js? the code below works:

const btc = require('bitcoinjs-lib');

var tx = new btc.TransactionBuilder(net);
inputs.forEach(o => tx.addInput(o.txId, o.vout));
outputs.forEach(o => tx.addOutput(o.address, o.value));
tx.sign(0, owner);
var body = tx.build().toHex();

but it's complaining that TransactionBuilder is deprecated... sigh...

  Deprecation Warning: TransactionBuilder will be removed in the future.
  (v6.x.x or later) Please use the Psbt class instead. Examples of usage
  are available in the transactions-psbt.js integration test file on our
  Github. A high level explanation is available in the psbt.ts and
  psbt.js files as well

and apparently the signing methodology has also changed (grr):

  DEPRECATED: TransactionBuilder sign method arguments will change in
  v6, please use the TxbSignArg interface

I've read the documentation on Psbt and understand the general concept but have not found a guide that helps with the transition.  I tried to simply change tx.sign() for tx.signInput() but it pukes

I've also looked at the test suite for the library but it's too complicated for me to understand.  How do I convert my code to the new mechanism?

You're only signing the first input? tx.sign(0, owner); Usually every input has to be signed somehow.

I also struggled with the switch to Psbt. Biggest difference was basically requirement to have a full transaction hex of every input for non-segwit inputs. Segwit inputs can be simpler but they can also be created using the full hex of the tx using non-segwit command so don't have to add extra logic differentiating between inputs. You can no longer just provide txid and vout, just add on the hex of tx that created each input for your object.

I really just followed examples https://github.com/bitcoinjs/bitcoinjs-lib#examples

So this is my take on a very general tx with psbt that I use for now:

import * as bitcoin from 'bitcoinjs-lib'

// not all parts of inputs have to be defined
// inputs - array of all data needed for inputs
// outputs - array of all data needed for outputs

const network = bitcoin.networks.testnet // or bitcoin.networks.bitcoin

const psbt = new bitcoin.Psbt({ network })
psbt.setVersion(2)    // default
psbt.setLocktime(0)   // default

// ************** create inputs **************

inputs.forEach(input=> {
  psbt.addInput({
    hash: input.txid,  // txid number
    index: input.vout,  // output number
    sequence: input.sequence, // often 0xfffffffe
    nonWitnessUtxo: Buffer.from(input.hex, 'hex'), // works for witness inputs too!
    redeemScript: input.redeemScript, // only if there's redeem script
    witnessScript: input.witnessScript // only if there's witness script
  })
})

// ************** create outputs **************

outputs.forEach(output => {

  psbt.addOutput({
    address: output.address, // only if not op_return type output (no address for those)
    value: output.value,
    script: output.data  // only if there's string (utf8) data to embed in op_return
      ? bitcoin.payments.embed({ data: [Buffer.from(output.data, 'utf8')] }).output
      : undefined
  })
})

// ************** signing **************

inputs.forEach((input, index) => {

  // sign regular inputs that can be simply signed
  if (!input.redeemScript && !input.witnessScript) {
    psbt.signInput(index, input.keyPair)

    // give error if signature failed
    if (!psbt.validateSignaturesOfInput(index)) {
      throw new Error('Signature validation failed for input index ' + index.toString())
    }
  }

})

// ************** finalizing inputs **************

inputs.forEach((input, index) => {

  // sign regular inputs that can be simply signed
  if (!input.redeemScript && !input.witnessScript) {
    psbt.finalizeInput(index)
  }

  // for p2sh or p2wsh script inputs
  if (input.redeemScript || input.witnessScript) {
    psbt.finalizeInput(
      index,
      getFinalScripts({
        inputScript: input.inputScript,
        network
      })
    )
  }
})

// ************** make tx **************

const tx = psbt.extractTransaction()

const virtualSize = tx.virtualSize()
const txid = tx.getId()
const hex = tx.toHex()

console.log('tx virtualSize:', virtualSize)
console.log('tx txid:', txid)
console.log('tx hex:', hex)

And for some reason finalizeInput for custom scripts is not exactly built in yet but I found it in examples and just added as a function I import or put somewhere in same file.

function getFinalScripts ({ inputScript, network }) {
  return function (
    inputIndex,
    input,
    script,
    isSegwit,
    isP2SH,
    isP2WSH,
  ) {
    // Step 1: Check to make sure the meaningful script matches what you expect.

    // Step 2: Create final scripts
    let payment = {
      network,
      output: script,
      input: inputScript,
    };
    if (isP2WSH && isSegwit)
      payment = bitcoin.payments.p2wsh({
        network,
        redeem: payment,
      });
    if (isP2SH)
      payment = bitcoin.payments.p2sh({
        network,
        redeem: payment,
      });

    function witnessStackToScriptWitness(witness) {
      let buffer = Buffer.allocUnsafe(0);

      function writeSlice(slice) {
        buffer = Buffer.concat([buffer, Buffer.from(slice)]);
      }

      function writeVarInt(i) {
        const currentLen = buffer.length;
        const varintLen = varuint.encodingLength(i);

        buffer = Buffer.concat([buffer, Buffer.allocUnsafe(varintLen)]);
        varuint.encode(i, buffer, currentLen);
      }

      function writeVarSlice(slice) {
        writeVarInt(slice.length);
        writeSlice(slice);
      }

      function writeVector(vector) {
        writeVarInt(vector.length);
        vector.forEach(writeVarSlice);
      }

      writeVector(witness);

      return buffer;
    }

    return {
      finalScriptSig: payment.input,
      finalScriptWitness:
        payment.witness && payment.witness.length > 0
          ? witnessStackToScriptWitness(payment.witness)
          : undefined,
    };
  }
}

I haven't tested every kind of input yet but this is basically what I use for p2wpkh and p2wsh inputs. I try to find examples spending exactly the type of input I need usually.


Fixing "Block not found on disk" rpc error I have a full node with txindex enabled that I've been trying to use for an electrum server. However, whether I use ElectrumX or Electrs, I hit the same error on initial indexing of "Block not found on disk". With a bit of digging, I found out this error comes from the getblock rpc call, and the comment in the code for when this error is thrown is as follows:

  Block not found on disk. This could be because we have the block
  header in our index but don't have the block (for example if a
  non-whitelisted node sends us an unrequested long chain of valid
  blocks, we add the headers to our index, but don't accept the
  block).

I'm not sure how I got to this state. This is a node I initially spun up several years ago and reindexed to use txindex earlier this year, I've never had any issues with it for other purposes or any data loss/corruption issues that I can recall. If anyone has a theory/explanation, I'd be interested to hear it.

My question is: Can I fix this error without starting over from scratch? I'd like to avoid even a reindex if possible, although I'm not even sure if that would fix it because as I understand it reindex uses the blocks on disk and apparently I'm missing a block on disk. Is there a way to get only the block or file(s) that I need? I have a friend with a full node who would let me copy files if needed.

I don't know exactly which block is missing yet, although I could probably figure that out with some more digging if it would be helpful.

Blocks are not stored in individual files, but flat bundles of a fixed size, so replacing one that is missing isn’t really possible. If a block can not be found on disk it has either keen deleted manually or by an errant process, or the disk is seriously corrupted. A re-index will fix this, but it’s an indicator of other possible issues related to hardware that this has happened.


Not generating any blocks on testnet I am running bitcoind, and I have cgminer solo-mining on it. I am mining on Testnet3. My hash rate (this is an OLD computer) is ~800Khash/s, so according to one online calculator I should be generating a block every 1.5hrs at difficulty 1. The difficulty has been one for quite some time now, and I still haven't gotten any blocks, though I have been mining for much more than 1.5hrs. More like 7 or 8 total I think.

What is wrong?

The difficulty is not really 1.

testnet has a "20-minute rule": if no block is successfully mined within 20 minutes, the difficulty drops to 1 until a block is mined.  Then it reverts to its previous value.  However, it appears that getdifficulty returns 1 whenever the most recent block was difficulty 1, even if it was accepted under the 20-minute rule; this doesn't necessarily match the "real" difficulty.

I've asked a new question about how to find the real difficulty.  But by browsing blocks on http://blockexplorer.com/testnet, the most recent block which was less than 20 minutes newer than its predecessor is 153337, which has a difficulty of 11512.  So most likely the real difficulty right now is 11512, unless it has adjusted very recently.

Thus there are two possible ways for you to mine a block:

Find a block at difficulty 11512.  If your computation was right, this will happen on average once every 2 years with your current machine.
Wait until it has been 20 minutes since the last block, and find a block at difficulty 1 before anyone else does.  Looking at recent timestamps, it appears that difficulty 1 blocks are typically submitted about 20 minutes and 4 seconds after the previous block.  Thus, you have about a 4 second window to find a difficulty 1 block (probably even less due to propagation delays).  Based on your computation, your probability of successfully doing this on any given block is at most about 0.0007, suggesting that you would succeed roughly once every 3 weeks on average (this is probably very optimistic as noted).  Even if you do mine a block within this time, another miner may find a block at roughly the same time; if the next miner to find a block decides to accept his instead of yours, yours will be orphaned and excluded from the chain.

So it is not surprising that you have not successfully generated a block.


What is the difference between "native segwit" and "bech32"? People seem to be using "native segwit" and "bech32" interchangeably. Are they really the same thing?

TL;DR: Native segwit refers to segwit outputs without P2SH-wrapper. Bech32 is the address format used to represent native segwit-v0 locking scripts.
Wrapped segwit vs native segwit
When segwit activated, it introduced the zeroth generation of segwit, segwit-v0. The corresponding locking scripts came in two flavors:

The forward-compatible "wrapped segwit" or "nested segwit" output types wrap the witness program in a Pay to Script Hash (P2SH) output. There are two variants, P2SH-P2WPKH for single-sig, and  P2SH-P2WSH for arbitrary scripts including multisig.
As all P2SH addresses, wrapped segwit outputs get encoded using Base58Check. The wrapping allows any P2SH-enabled wallets to send to wrapped segwit addresses.
The compatibility-breaking "native segwit" output types which can only be paid to by segwit-enabled wallets. Native segwit outputs are more blockspace efficient because they avoid the additional data necessary for the P2SH-wrapper by resolving the witness program directly. Native segwit locking scripts get encoded using the newly introduced bech32 address format (BIP-173) (for v0 native segwit outputs).

Other uses of Bech32
Bech32 is also used for other purposes such as e.g. encoding Lightning invoices. Originally, it was planned to use Bech32 for later native segwit output versions as well. However, after a mutability weakness was discovered, and surveys found that many wallets did not properly handle sending to higher segwit versions, an amended version of Bech32 is in discussion. This amended version of Bech32 would use a different checksum constant to explicitly break forward-compatibility, i.e. require wallets to upgrade to create segwit-v1 outputs. Breaking forward-compatibility protects wallets from burning funds by incorrectly downgrading segwit-v1 addresses to segwit-v0 addresses, and allows the mutability weakness to be fixed.
Native segwit-v1 to use Bech32m
The proposed Taproot soft fork introduces the native segwit-v1 output type, Pay to Taproot (P2TR), which would be the first native segwit output type to use this amended Bech32 address format, called "Bech32m" proposed by BIP-350.


Is it safe to import my private key into another wallet? I sent some bitcoin to my bitcoin core wallet before it synced, not knowing this sync would take days, and was wondering if i was to import my private key into a different wallet if that would work?

It's safe as long as you're sure that no one else has access to that private key.

For example, you shouldn't import a private key someone else gave you. They could send coins to that key to make it look like they sent you money, and then steal them (since they have the key as well).

If it's just copying one private key on one of your own wallets to another one of your own wallets (both of which only you have access to), then you should be fine. Just be aware that coins given to that key will appear simultaneously in both wallets, and coins spent from that key will disappear simultaneously in both wallets as well. This doesn't sound like an issue in your case, since you won't be using the old one at all.

The alternative is to just do a standard bitcoin transaction to transfer it from one of your wallets to another. Although, I see that this is made difficult by the fact that your Bitcoin Core client not fully synced with the network.

Related: Did I just create counterfeit bitcoins?


Is it possible to create a thin client that only listens for transactions and pending transactions? I looked into using a thin client but even thin clients implement SPV (Simple Payment Verification). What if you just wanted a client that only listens for transactions/pending transactions, doesn't store the blockchain, and only uses memory.

When receiving a payment, it is critical to know whether or not the transaction that makes that payment is a legitimate Bitcoin transaction (or not).

This is determined by checking if the transaction is valid according to the network's rules- and a crucial part of this is determining whether or not the transaction's inputs are valid. In order to determine the validity of the inputs, the client must have some way of knowing the current state of the network. Generally this is accomplished in two ways:

Full node: this is software that will independently download and validate every transaction and block, thus verifying what the current state of the network is. As such, any transaction can (and will) be checked for validity.
Thin/Lite/SPV client: this is software that will download the longest chain of block headers, but not the entire block. The client can thus check the validity of transaction by requesting proof of the transaction's inclusion in a block from full nodes on the network, this is accomplished via the merkle root included in the block header. This method of transaction verification requires more trust (that miners are in fact creating valid blocks), so the thin-client must trust that this verification is being performed by other nodes on the network.

If you are not performing verification of incoming transactions in one of these ways, then you will be easily defrauded, since you will be unable to differentiate between a valid and invalid transaction, without fully trusting someone else to supply this info to you.


Question regarding LN node backups I have LN node running on c-lightning. I am performing ~/.lightning dir backups time-to-time.

Let's say after backup i open few new channels and withdraw rest of onchain funds to my electrum. Then i restore a backup.

What will happen to my node and its channels?

P.S. i have tried such scenario once. Onchain funds status after backup restore become 'spent'. i had to launch 'lightning-cli dev-rescan-outputs' to refresh onchain funds and get actual status. While my node lists channels in 'listfunds', i see that those channels become inactive. What is happening under the hood? what is the correct way of making and restoring node backups?

As pointed out in similar questions backups are tricky with lightning. In the case of lightning each payment channel is a 2 of 2 multisig wallet. One of the keys is in your possession and it differs for each channel but in generally is derived from your master key.

The masterkey in c Lightning is 32 byte and stored in binary in ./lightning/hsm_secret

Unluckily it is not sufficient to backup your masterkey. Every channel has a so called state and an old state of the channel will yield problems (potentially a forceful close of the channel partner and them being able to claim your funds.)

So here is what should happen :
If you turn off your node and make a backup of your lightning dir you will be able to restore that backup on this or a different machine and after turning on your lightning node everything should work as before.

If however you change channel state before restori g your backup your channel partner and you will most likely see a mismatch and fail the channel which means they publish their latest state. If you are lucky it is your partner and you can claim your outputs. If not it is your node and your partner will probably throw in their penalty tx to claim all coins of the channel due to the channel breach.

Generally under the hood after restart of a lightning node all peers are being connected again. If that does not work (because the other node might be offline) there will be inactive channels.


Has a hard fork ever occurred? BIP 50 describes the 2013 event in which a block chain fork persisted for several hours. Its first paragraph reads:

  A block that had a larger number of total transaction inputs than previously seen was mined and broadcast.  Bitcoin 0.8 nodes were able to handle this, but some pre-0.8 Bitcoin nodes rejected it, causing an unexpected hard fork of the chain [my emphasis].  The pre-0.8 incompatible chain at that point had around 60% of the hash power, ensuring that the split did not automatically resolve.

I interpret this to mean that the term "hard fork" describes a state of the network.  Some nodes have accepted a block, but others have rejected it.  The nodes accepting the questionable block keep and extend it.  The nodes rejecting the block neither keep nor extend it, but rather build their own branch.  The resulting "fork" is only visible to nodes which have accepted the questionable block.

However, the Wiki has this to say about a hard fork:

  A hardfork is a change to the bitcoin protocol that makes previously invalid blocks/transactions valid, and therefore requires all users to upgrade.

In other words, a hard fork is a kind of update to Bitcoin Core (given that Bitcoin Core is the protocol).  The idea was repeated in the top answer to this SE question.

The difference is subtle, but important.  For example, consider the question: has a hard fork ever occurred?

At least one Core developer says that Bitcoin has never experienced a hard fork, apparently using the Wiki definition.  The 2013 fork was not caused by a software update (according to some new, but undocumented information), but rather was (caused by?) nondeterministic behavior that would have happened even without the update.

The answer seems to depend on how you define a hard fork. If a hard fork is a condition of the network, the answer seems to be "yes".  But if a hard fork is a kind of software update, the answer seems to be "no".

It's not hard to see how a software update could lead to a persistent block chain fork as seen by some nodes.  So clearly the two ideas are connected.  But imprecise language around hard forks can lead to confusion, and, more importantly, to incorrect conclusions.

So which is it?  Does "hard fork" describe a condition of the network, or a software update?

So which is it? Does "hard fork" describe a condition of the network, or a software update?

Either is acceptable. You can say that version so-and-so causes a fork, and you can say that the network is currently forked.

  Was the March 2013 fork a hardfork?

It depends on your definition. The March 2013 incident initially appeared to be a hard-fork, but a later investigation showed that it was possible to trigger the issue even when all nodes were running the same version.

Quoting from BIP50:

  This would be an issue even if the entire network was running version 0.7.2. It is theoretically possible for one 0.7.2 node to create a block that others are unable to validate, or for 0.7.2 nodes to create block re-orgs that peers cannot validate, because the contents of each node's blkindex.dat database is not identical, and the number of locks required depends on the exact arrangement of the blkindex.dat on disk (locks are acquired per-page).

However, it was a hardfork in the sense that newer clients would create and validate blocks that an older client would not see as valid.


Does the program I downloaded (bitcoin-qt) mine bitcoins? Possible Duplicate:
  How can I start mining Bitcoin?

Nothing ever says how to actually mine bitcoins, except to join a pool. I don't want to do that. All I really know is that each block has an equation associated with it, and whoever solves it gets the coins. I assume that the miner is trying to solve the equation, and I also assume that this just means running the bitcoin client and hoping your computer can generate a block. If bitcoin qt (from the website) doesn't mine bitcoins, what does?

Yes, but not efficiently. In fact, CPU's are so bad at mining bitcoin that the option was removed from the user interface. However, the code is still there (though mostly as a reference implementation), and you can go to Help > Debug Window > Console and type in "setgenerate true" to turn it on.  Type "setgenerate false" to stop.

You can also give bitcoin the option -gen at the command line.


Transaction Malleability in the blockchain How does a transaction malleability look like in the blockchain? Are there any examples?

Here is example: https://blockchain.info/tx/683f45578328242a06bc5c54acbcbe6e70a5435b4561fc8b0570a59ab09f8bfa?show_adv=true

Look at first input script in raw:

4d49003046022100847361c694421bf63ea1b51d8e2189805b161ab3d4cb96ab745a20468dd6c2ea0221009160897652bedfd7c837855d793c32509063338ac7524b8f09abfed761cf16fc014d410004c8dde23708932059bf4491c96794c5412b1182d62d2741e0986cb87276d3053f0b7326155114ad67c04adc60b5a47718fa8744ecb86a001f99da8761113edb24

Look at first byte: 4d (OP_PUSHDATA2). It means, that next 2 bytes contains length of data, that will be pushed to stack. This length = 0x49. But typical transaction does not use OP_PUSHDATA2 command. If transaction was created by bitcoin-qt, it starts with length of data directly:

[4d]49[00]3046....

I take into brackets unnecessary bytes.

So, someone added 2 bytes to signature script, but did not break signature and changed id of transaction. Original tx was deleted from blockchain.info. Next link no longer works: https://blockchain.info/tx/ef74c1cbf0003fc4e96a87a59838f7dd3da488d9d83fec3f270b0d3d7c2bc309?show_adv=true

Look at wiki for more information about scripts: https://en.bitcoin.it/wiki/Script


Is it possible to mine with both (2) GPUs in headless mode? I've got a Mac Pro with two different GPUs in it—one is a new 5850 and the other is some old (stock) Radeon.

I'm wondering if it is possible to mine with both cards simultaneously if the OS is configured to be headless (i.e., neither card is used to display a GUI)?

I have tried the bitminter client for mining and it seems that both of my gpus are used.

You can try downloading it from here


Clarification of lightning network example (putting funds into lightning) I'm checking How does the Lightning network work in simple terms? answer example:

  1) Putting funds into Lightning  We both send 0.5 BTC into a shared
  2-of-2 multisig address. This requires a transaction on the Bitcoin
  blockchain.  As a "balance sheet", we each create a 2-of-2 multisig
  transaction that pays out 0.5 BTC to you and 0.5 BTC to me. I sign
  one payout transaction and give it to you. If you want to put it in
  effect, you need only add your own signature and broadcast it to the
  Bitcoin network. Vice versa, you give me your copy of the payout
  transaction that you have signed and I have not yet. The "balance
  sheet" is a regular 2-of-2 multisig transaction in the Bitcoin
  network, it just isn't valid yet, because it doesn't have all
  signatures.

So in the first step you make a regular transaction from your address A to our common 2-2 address C, and I make a regular transaction from my address B to our common 2-2 address C?

I have one key of this 2-2 multisig address C and you have another?

Address C now has 1BTC.

Now from this address C I return 0.5 of its 1 BTC to your address A and sign with my key, and you return remaining 0.5 to my address B and sign with your key?

So in the first step you make a regular transaction from your address A to our common 2-2 address C, and I make a regular transaction from my address B to our common 2-2 address C?

Yes, although in the current lightning spec and implementation, only one party funds the channel. However it could certainly be both parties that fund it.

I have one key of this 2-2 multisig address C and you have another?

Yes.

Address C now has 1BTC.
Now from this address C I return 0.5 of its 1 BTC to your address A and sign with my key, and you return remaining 0.5 to my address B and sign with your key?

Two transactions are formed at this point:

one that you make and sign and send to me that gives 0.5 BTC to you and 0.5 BTC to me,

one that I make and sign and send to you that also gives 0.5 BTC to you and 0.5 BTC to me.


Do I need to pay fees for the transactions from my full node? I have a full node running right now.
I've created a wallet on my server. Do I need to define any transaction fees while transferring my coins to another wallet? lets say to a wallet on blockchain.info?

Thanks.

Yes. All transactions should pay a transaction fee. Running a full node does not give you any special ability for you to not pay a transaction fee and still have your transaction confirmed in a timely manner. Your wallet should take care of setting the transaction fees for you.


Blockchain.info testnet websocket doesn't work When I try to connect testnet websocket provided by blockchain.info api. Connection doesn't establish, when i looked into the code. It says for testnet it uses "wss://ws.testnet.blockchain.info/inv" url. I guess that blockchain.info stops the service for testnet. Is there any other websocket api provider for bitcoin testnet?

~> curl --head https://testnet.blockchain.info
HTTP/1.1 503 Service Unavailable

It's likely the service just isn't something that exists.


Address and Public key I am reading about cryptography in Bitcoin. Bitcoin adress is created by applying cryptographic hash function to public key of the wallet. I know that this function is a trap door function but what are possible vulnerabilities if the public key could be derived from the address? Public keys are used anyway when authenticating the creator of the transaction (signer of the transaction).

There are several aspects to not sending to a public key directly. Here are a few I can name

RipeMD160 shortens the address from 256 bits to 160 bits
A checksum is introduced to the address
An address doesn't expose the pubkey, so if the ECDSA gets compromised, funds are still safe ["quantum PC attack resistant"]
Pay to script hash is possible with the same address format; in later iterations with e.g. taproot this can greatly enhance privacy and functionality at little or no extra on-chain cost


SignRawTransaction - What is scriptPubKey and redeemScript? [SOLVED] Let me talk about how I got to the situation I'm in right now. I am using PHP and the JSON library to control bitcoind. And doing so.....

I created a multisignature address requiring 2 of 3 signatures with createmultisig.

I then sent funds to the multisignature address and was able to confirm the transactions sent to this address with using getrawtransaction and decoderawtransaction.

Next, I wanted to release those funds to a specific address (because I control all the keys, this is just a test run)

So I created a raw transaction in which I entered the transaction ID that I used for one of the transactions to send funds to the multisignature wallet. I also added the desired address and amount. After this, it spit out a raw transaction hex.

My next step is to sign the raw transaction. This is where I am stuck.

The parameters for signrawtransaction are confusing to me, and I need it explained to me as if I was 5 years old.

hexstring - assuming this is the hex string that createrawtransaction spit out

transaction id - is this the transaction id from when I transferred in the amount to the multisig wallet?

scriptPubKey - no idea what this is

redeemScript - no idea what this is

I grabbed scriptPubKey and redeemScript from the transaction I used to transfer funds into the multisig wallet, but the resulting output was the exact input of the hex string, so it is obviously not signing it correctly. I am not sure what these 2 paramters are.

Can somebody please help me with this. I need it explained to me like I am retarded because none of the explanations I have read online have helped.

Thanks.

EDIT to RE: Jonathan

Here is what I have done so far.

1) Created a multisig address using 3 public keys that I generated.
I took note of the private keys as well, and the outputted multisig address (ABC) and redeemScript (redeem1)

2) Sent coins to the multisig address and by searching through the blockchain found that the transactions exist. I had multiple transaction IDs, to send to this address but I am focusing on one that I am trying to use as an output. We will call it (txid1). In txid1, when I called getrawtransaction, it also had a 46 byte hexed pubkey attached to the output, I will call that (pubkey1)

3) Next I created a raw transaction which included the paramters;

txid1, vout=0, address (address to spend to) and amount (matches the same amount transferred to the multsig address with txid1) and it spits out a hexstring, which I will call (hex1)

4) SignRawTransaction - here is where I am stuck.
The parameters it asks for are;

 [{"txid":txid,"vout":n,"scriptPubKey":hex, "redeemScript":hex},...] [,...]

So I am inputting signrawtransaction(hex1, ["txid"=>txid1, "vout"=>0, "scriptPubKey"=>pubkey1, "redeemScript"=>redeem1, array(oneofmyprivatekeys))

But the resulting output is just the hex1, without a single change to it. I am not getting any error messages, just an outputed string identical to hex1.

Can you give me an idea of what I am doing wrong? Thank you so much!

First of all, take a look at https://gist.github.com/gavinandresen/3966071.  That's a script that creates two raw transactions: one to fund a multisig address, and another to spend the funds.  It shows each of the steps necessary to create and spend from a multisig address.  Unfortunately, the script doesn't do a good job of explaining where the parameters come from.  I'll try to explain the parameters you need.

As you guessed, hexstring is the output from createrawtransaction, and transaction id is the ID of the transaction that sent the coins to the multisig address.  redeemScript is easy.  When you first generated the multisig address, the command returned both the address and the redeemScript.  If you don't have that value, you can recreate the multisig address with the same public keys and you'll see it in the output.  scriptPubKey is the one I'm not sure about.  I think I know what it is, but I don't have bitcoind in front of me so I can't be sure.  If you decode the raw transaction that send coins to the multisig address, you'll see one or two outputs, one of which sends coins to the multisig address.  (The other output sends the rest of the coins to a change address.)  There will be a scriptPubKey section in that output.  Copy the hex string from that section and use it as the scriptPubKey parameter.

Once you have those parameters, you can sign the raw transaction and send it.  If it doesn't work, leave a comment here and I'll try to work it out when I get home.


How to quickly get the balance of any bitcoin address? (with no third-party API) As some people have mentioned (eg. here), the only way to get the balance of an address in bitcoin core was to import it as a watch-only address and rescan the blockchain. Starting with bitcoin core v0.17, we can use the scantxoutset command, however this is quite slow:

> time bitcoin-cli scantxoutset "start" "[\"addr(17Pu3CEx34YX8bpGATq45PfL2fGBCPcr2u)\"]"
{
  "success": true,
  "searched_items": 64162818,
  "unspents": [
    {
      "txid": "9796cee98fa88efcb9fdb954188d276b73d6e76719af6b5470ad23a2f744ecca",
      "vout": 1,
      "scriptPubKey": "76a91446255848182640edff4d178f365d7824513bc28d88ac",
      "desc": "addr(17Pu3CEx34YX8bpGATq45PfL2fGBCPcr2u)#x2q6xgrk",
      "amount": 0.02155141,
      "height": 607852
    }
  ],
  "total_amount": 0.02155141
}

real    0m42.419s
user    0m0.007s
sys 0m0.003s

42 seconds is quite slow, I would like to get something comparable to block explorers (less than 2 seconds). Is it possible to achieve faster results with some advanced bitcoin core configuration?

Or, is there any open-source project I could use to index the UTXO set by address? Not sure if libbitcoin, bitcoinj, bitcoinJS, etc. are able to do this faster. Some tool block explorers might use to provide this service would be what I am looking for.

There is no way to enable faster querying for arbitrary addresses than scantxoutset in bitcoind.

Explorers provide this functionality by maintaining a separate database of all addresses and transactions which is optimized for that kind of query. Bitcoin Core, on the other hand, is optimized for consensus related queries, which are largely a hashset lookup for a given input for a transaction.

You could try running something such as ElectrumX, which backs the electrum wallet, or Bitcore, which backs many of Bitpay's wallet and explorer services.


How to identify the owner of a Bitcoin address? My father's computer was infected with a CryptoWall virus. The virus attacker asks for Bitcoins to send me an app to decrypt my our files.

Is there any way to identify the Bitcoin address owner?

How can I identify his country? How can I let his local police know about this cyber crime?

I didn't send him Bitcoins.

See: http://www.bleepingcomputer.com/virus-removal/cryptowall-ransomware-information

First off, I'm glad you didn't send money as that often does not help in these situations. As for tracking the attacker through their bitcoin address, I'm sorry to say but most likely that is not possible. It's impossible to determine the location of a bitcoin address without some sort of identification tied in. They also most likely would tumble the bitcoins before sending them to any address actually tied to their identity.

You could give all the information you possess to your local police but most likely there is not much more they can do. These type of scams are pretty safe to commit sadly.


Bitcoin API - How can I identify new incoming payments? Good afternoon,

I am struggling a bit to receive Bitcoin payments at my online store. So far, I have installed bitcoind in my system and created a set of receiving addresses, and now I face the problem of checking for new payments.

I am using the following resources:

https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list
http://code.gogulski.com/bitcoin-php/class_bitcoin_client.html

I would like to make a cron job that searches for new payments and stores each one of them into a relational database, each transaction identified by:

Transaction ID
Sender's address
Amount as a 64-bit integer

Everything is pretty easy but I can't find an efficient way of extracting the new incoming transactions from my bitcoin daemon. For instance, I am able to extract the balance of each address, but I don't find a feasible way to obtain a collection of incoming transactions with all required data. This creates a further problem because I don't want to process transactions twice.

Which is the best way to do it using the API?

Thank you very much.

If you want to identify incoming payments, the recommended way is creating a new receive address for every request. When the confirmations of a transaction to a given address get high enough, you can consider the payment confirmed.

Using the 'sender address' does not give you reliable information - it can only identify (one of the) addresses that were previously in control of the coins. There is no guarantee that these correspond to the sender of the payment (it may be a webwallet with shared coins, for example).

Not reusing addresses also has other benefits, like making bitcoins as a whole less easily traceable.


Is it possible to get Node Id that paid an invoice? I know it's possible to decode an invoice to see which node ID signed it by decoding it according to specs.

Is it possible to get Node ID that paid an invoice to my node?

This is not possible. The buyer has privacy by default. The only information sent in a payment is the payment_hash, the amount and a CLTV value.


How to transfer only the blockchain to a friend's computer? After installing the bitcoin client (Qt) a friend got interested as well. He doesn't have as fast an internet connection, though, so I thought of burning some DVDs with the blockchains for him to have.

I saw this question on how to transfer blockchain from PC to Mac and the solution was to copy the whole "Bitcoin" folder. However, that folder also contains MY wallet as well (which I definitely do not want my friend to have, even if encrypted).

So I'd like to know, which folder(s) and/or files do I need to copy, minimally, so he needs to get as few blocks over the network as possible?
If it's too much of a hassle, most probably I'll suggest him to use multibit or electrum instead :-)

Transfer everything except wallet.dat and the database folder.


List imported watch-only adresses I can import addresses without private key just to track incoming transactions as it is provided in RPC calls :
https://bitcoin.org/en/release/v0.10.0#watch-only-wallet-support

But how can i see my previously imported addresses? (With or without RPC)

Bonus : Is there any proper way to delete them?

OK. I've found a workaround by adding label on importing :

bitcoin-cli importaddress <address> my_imported_address_list

Checking my label on listing :

bitcoin-cli getaddressesbyaccount "my_imported_address_list"

This solves my problem for now. But still searching for better answer where i dont need to label my own imported addresses.


Can a Trezor accept/use a private key created independently offline? Can I create a private key using bitaddress.org offline and then use that private key in a trezor wallet? Also will the trezor use that private key to produce a mnemonic phrase?

You cannot import individual private keys into a Trezor. However you can generate your own mnemonic offline and import that into a Trezor.


Do BitCoin wallets generated by websites have validity? Is there a way to generate my own Bitcoin address offline without using the websites?

You can save the bitaddress.org site and load it offline and it will still work.

You can also use VanityGen to generate "vanity" addresses.


How does Ripple solve the double-spend problem? How does the Ripple system solve the double-spend problem? Does it also use some block-chain-like entity that officially dictates which transactions are confirmed and which are not, or does it use some other clever mechanism?

The details are very complex, but the core concept is fairly simple. Ripple solves the double-spend problem by consensus.

The analogy I use is an "agreement room". To walk into the room, you have to agree with everyone who is already in there. If you want to disagree, you have to leave and form your own room. Everyone who is honest wants to get into the biggest room they can with the most people in it.

In the room, people constantly agree on the current state of the system. It's implemented as a hash tree, so that's just one 256-bit number.

To perform a transaction, you walk into the big room and read out the transaction. Everyone checks the transaction against their ledger. Assuming there's no conflicting transaction or other problem, everyone agrees that the transaction is valid and they include it in the set of transactions they believe should be applied.

They then work on any disagreements they have by an avalanche process. Essentially, if someone is voting yes on a transaction that doesn't have overwhelming majority support, they just change their vote to no. This ensures there's a quick agreement on a set of transactions.

Once a set of candidate transactions is agreed upon, those transaction are applied and everyone computes the next ledger according to a set of deterministic rules. They all sign it, publish those signatures, and now clients know which transactions have been accepted by the consensus process.

If a transaction doesn't get in for some reason, but it's still valid, every honest person in the room will say yes to that transaction in the next round.

So, back to the double spend problem. A double spend is essentially two transactions, each of which is valid if and only if it's applied before the other. Thus solving the double spend problem "merely" requires agreeing on an order for the two transactions. If everyone agrees which comes first, the problem is solved -- the one that comes first is applied and thus the other is invalid.

In the Ripple system, if two transactions are a double spend, one of three things can happen:

One transaction will get voted into a consensus set before the other. In this case, that transaction will be in a ledger signed by all the people in the room, forever invalidating the other.
Both get into the same consensus set (this should almost never happen). In this case, a deterministic rule when the consensus set is applied determines which gets into the ledger, forever blocking the other.
Neither gets into a consensus set because neither gets a majority and both transactions are at around 50%. In this case, every node that sees both transactions (which will quickly be the vast majority of nodes) will vote yes on the transaction that wins by a deterministic rule and no on the transaction that loses by that rule. The one that wins by that deterministic rule will get in the consensus set, be applied to the ledger, and forever block the other.

That's a gross oversimplification, but it's inherently fairly complex.


Is the "vin" value field necessary or just a matter of convenience? I notice that vin has a value field denoting the amount of money being spent from the input transaction. Am I correct that this is here for convenience and must equal the value of the specified transaction output?
The only other case I can think of is splitting the same transaction output into two transaction inputs, but I don't see the point of this.
"vin": [{
  "txid":"672aeb1bc62b3941f2e9a530ff6d12e5e70c257632d536d5b0633e12b68a915d",
  "vout":1,
  "scriptSig":{
    "asm":"..."
  },
  "addr":"1HKqcNrf3NPuz4s2MdoAzpYYfjYvbbsxZf",
  "value":0.0468234
},
...]

That field in the RPC response is by definition just information about the output being spent, so yes, it is always going to be equal.
As for whether it's necessary - no, of course not. But the RPC in the first place exists because of convenience.


What valid transactions are not broadcastable? Many valid transactions are not broadcastable by default in bitcoin core to avoid attacks that could harm the network. These would rarely be found in a node's mempool but could, however, be found in blocks because they don't violate any consensus rules.
What transactions fit these criteria?

The following transactions are not broadcastable with the default bitcoin core configuration but could be found in new mined blocks:

Transactions whose fee is smaller than 1 sat/vB (and RBF bumps that increment less than 1 sat/B).
Transactions with size greater than 100 vkB (and smaller than ~ 1 vMB)
Transactions with outputs amounts smaller than 566 satoshis (dust limit)
Transactions that are considered non-standard (I will try to list them because this is a very broad category)
Transactions with scriptSigs larger than 1650 B (and smaller than 10kB)
Transactions with more than one OP_RETURN output or an OP_RETURN output bigger than 83 B.
Transactions with scriptPuKeys of bare n-of-m multisigs, where m > 3.
Transactions with scriptPubKeys or ScriptSigs that make the transaction malleable.


GDAX Java Bad Request Trying to request private data on GDAX but keep getting bad request. Cannot figure out what I am doing wrong. Please help.

private static JsonObject getAuthenticatedData() {
        try {

            String accessSign = getAccess();
            System.setProperty("http.agent", "Java Client");

            URL url = new URL("https://api.gdax.com/accounts");
            HttpURLConnection con = (HttpURLConnection) url.openConnection();
            con.setRequestMethod("GET");

            con.setRequestProperty("CB-ACCESS-KEY", "accesskey");
            con.setRequestProperty("CB-ACCESS-SIGN", accessSign);
            con.setRequestProperty("CB-ACCESS-TIMESTAMP", ""+System.currentTimeMillis() / 1000L);
            con.setRequestProperty("CB-ACCESS-PASSPHRASE", "passphrase");
            con.setRequestProperty("Content-Type", "application/json");

            con.setConnectTimeout(5000);
            con.setReadTimeout(5000);

            String status = con.getResponseMessage();
            System.out.println(status);

            BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
            String inputLine;
            StringBuffer content = new StringBuffer();
            while ((inputLine = in.readLine()) != null) {
                content.append(inputLine);
            }
            System.out.println(content);
            in.close();

            con.disconnect();

        }catch(Exception e) {
            e.printStackTrace();
        }
        return null;

    }

And this:

public static String getAccess() {

    //Set the Secret
    String secret = "secret==";
    //Build the PreHash
    String prehash = Instant.now().toEpochMilli()+"GET"+"/accounts";
    String hash = null;
    try {

        Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
        SecretKeySpec secret_key = new SecretKeySpec(secret.getBytes(), "HmacSHA256");
        sha256_HMAC.init(secret_key);

        hash = Base64.encodeBase64String(sha256_HMAC.doFinal(prehash.getBytes("UTF-8")));
         hash = hash.replace("\n", "");
        System.out.println(hash);
       }
       catch (Exception e){
           e.printStackTrace();
       }
    return hash;
}

Can you try to add/modify with the with the following lines of codes in your methods:

private static JsonObject getAuthenticatedData() {

  String timestamp = Instant.now().getEpochSecond() + "";
  String accessSign = getAccess(timestamp);

  con.setRequestProperty("CB-ACCESS-TIMESTAMP", timestamp);
  con.setRequestProperty("accept", "application/json");
}

public static String getAccess(String timestamp) {

  String prehash = timestamp+"GET"+"/accounts";
  byte[] secretDecoded = Base64.getDecoder().decode(secret);
  SecretKeySpec secret_key = new SecretKeySpec(secretDecoded, "HmacSHA256");

  hash = Base64.getEncoder().encodeToString(sha256_HMAC.doFinal(prehash.getBytes()));

  return hash;
}


How to listsinceblock mempool transactions? I am using listsinceblock RPC call to show me transactions relevant to my wallet addresses only. Absolutely useful feature, but I cannot figure out how to include also mempool transactions.

Is there something that would implement such functionality?

Thanks!

Currently there is no way to get this information. However Bitcoin Core does track this information (at least the block height at the time the transaction entered its mempool) so it should be possible to make such a command.

Note that listsinceblock is a wallet RPC so it cannot also work on the mempool due to the separation between the node and wallet that we are trying to make.


How to secure my Electrum wallet? What I did is put a password on word document and put the seed words in there and then put the file in google drive.

I can't think of any way I can lose it. I can't think of anyone stealing the money either without knowing my password.

The Electrum wallet is also encrypted with the same password.

Are there any ways to improve my security?

https://en.wikipedia.org/wiki/Microsoft_Office_password_protection

Password protected word docs only use 128 AES encryption. An improvement you could easily make is upping this encryption level to 256. Another suggestion you could also PGP encrypt the seed words inside the document itself.

I also think putting this information in a cloud environment would be sacrificing security. I assuming you are counting on google drive being around in the event of your hard-drive crashing. Unless you need this information on the go though I would think writing the information on a piece of paper and locking that away would be more secure, depending on your locations physical security.

You should also have multiple backup points in the event of a loss, even if you are counting on google drive being there you don't want that to be a single point of failure. I would suggest at least having one paper copy and possibly a thumb-drive/DVD copy.


Wouldn't the blockchain size become a bottleneck if all payments happened on Bitcoin? I am learning about Bitcoin. I understand that bitcoins are stored on a ledger, and the ledger itself is widely distributed and available to all parties. I also understand that the ledger stores all the previous bitcoin transactions for all the bitcoins.
Suppose in the hypothetical future, everybody moved to bitcoins, with no USD or other fiat currencies. What would be the ledger size in bytes due to all transactions that happened within a year? If you were to record all past transactions from the time bitcoins started, so you could track it, it seems to me it would quickly become a huge network bottleneck, as the ledger is updated over the network. Even the size of the ledger itself might become a big concern over a few years.
Has anybody looked into this aspect of bitcoins?

That would indeed create a lot of data. However, there are solutions for this.

First of all, as a normal consumer you don't store the blockchain anyways. Only some nodes like Bitcoin services and generally those who choose to store the blockchain.

Secondly, even as a miner, keeping the UTXO pool available fast is important. They don't need the entire blockchain which shows you all previous payments available at high speeds. They only need to know what unspent money there is and how it's possible to spend it. That's much less. Storing the blockchain itself isn't much of a problem because storage space is super cheep, compared to mining equipment and their energy costs.

And third, what you probably want to know, high activity on the main chain can and very likely will be avoided via lightning networks and payment processors. Both have their own advantages and disadvantages, of course. You can read about lightning networks in the linked Bitcoin wiki article. I wrote about payment processors 2 hours ago in my answer to this question.


Is it possible to mine altcoin with antminer? Uh..I'm not sure if it's allowed to ask this kind of question here but anyway...

I saw some comments at other forum said that theoretically it's possible to use like antminer s9 from bitmain to mine other SHA-256 based altcoin, and I'm wondering how to do it practically.

There is a place for SD card on S9 so I was thinking will it be just like what we do to GPU miners. We download mining software from mining pool, save it to the SSD, and run it.

So I checked those S9 set-up tutorial but it seems like I was wrong, there wasn't any step including download anything from mining pool.

Did anyone here try similar things before?

And I know that this kind of ASIC miners are optimized for certain kind of coins. But for example, is S9 optimized for bitcoin or for SHA-256 algorithm?

Thanks a lot.

If an altcoin uses the SHA256 double hash algorithm for their proof of work algorithm, then yes, you can use antminers or any other Bitcoin mining hardware to mine those altcoins. You will need to modify the antminer in order to use other mining software (you should be able to ssh into it and load whichever mining software you want).


Closed a wallet in Multibit mac and cant find it from application support First time installed Multibit for mac and had my bitcoins transfered there. I had the software and wallet open for 2-3 days and decided to close the wallet. After closing i couldnt find the wallet in the application support folder. There was nothing related to multibit in that folder. Ive been trying to search .wallet files from the Finder but it comes up empty. Are my bitcoins gone for good?

Are you sure you looked in the right folder? The path should be: /User/your username/Application Support/Multibit/xxxx.wallet.

I didn't find my wallet because I made the misstake to looked directly under root: /Library/Application Support/  and got rather stressed but I found the path eventually.

This cataloug is hidden and you have to unhide it with the commando in a terminal window: chflags nohidden /Users/your username/Library/Application Support/


Where is the actual data stored in blockchain? I know that the blockchain stores the transnational data and it is immutable but where is the actual data stored? If there is a use case to replace a centralized data center solution with a blockchain solution, where will the data be stored in blockchain? Data centers usually have petabytes of raw data, hence I am assuming that a decentralized solution like blockchain won't be able to accommodate large amounts of data.
For e.g. bitcoin as of today is ~270GB, meaning that every node requires this much amount of storage. But the problem here is that the data is an ever increasing entity. How does blockchain try to solve this problem ?
Note: Many links on google say that blockchain is not an ideal solution for large data, but then any solution will eventually produce an ever increasing amount of data.
I have referenced the following question on the forum but it does not answer by doubts:
Where is the data stored in Bitcoin?

where is the actual data stored?

Each full node on the network will download and validate the blockchain history, it will request and receive this data from other full node peers. Each node does not necessarily have to keep that data after validating it though, it can choose to 'prune' data that is not relevant to the user's wallet.

For e.g. bitcoin as of today is ~270GB, meaning that every node requires this much amount of storage. But the problem here is that the data is an ever increasing entity.

By running a pruned node, you needn't keep the entire blockchain history on file, though you will still need to download and validate it in the first place. So while the blockchain will continue to increase in size, it is through careful engineering that we can hope to limit the rate of increase, hopefully such that technological capacity will increase at a comparable rate (ie, faster and cheaper CPUs for validation, faster and cheaper storage, etc). This is important, because the health of the network depends on there being a sufficiently large number of nodes online.

Many links on google say that blockchain is not an ideal solution for large data, but then any solution will eventually produce an ever increasing amount of data.

The key point with this is that not all types of data usage are equal. It is preferable to get the most utility you can per byte of data stored. Compressing a ton of economic happenings into a bitcoin transaction (eg the opening/closing of a lightning network channel) represents a ton of utility per byte. Storing your favourite funny-cat-video on a blockchain is the opposite, and there already exist far more efficient ways to store and transmit that sort of data.


Precisely what did Mt. Gox do wrong? Everyone likes to trash Mt. Gox.  There is a ton of hearsay out there.  Can someone produce real evidence of their poor business practice?  I was hoping to find their old website FAQ for example.  What about their management and policies was so different from any of the other exchanges?  There are tons of customer complaints out there but do we know the underlying causes of those complaints and is there documentation to back those up?

Nick

Specifically:

They blamed transaction malleability for a hack, which was clearly a lie - blaming Bitcoin for their own mistakes.
They stopped withdrawals but continued allowing deposits and trading. A leaked strategy document shows that this was an attempt to conceal the size of their losses from the public, ie they didnt' come clean when they should have .  http://www.scribd.com/doc/209050732/MtGox-Situation-Crisis-Strategy-Draft#scribd
Their communication with their customers leading up to the hack was generally awful.


How is Bitcoin governed by mathematics? I keep hearing talks from Bitcoin evangelists that claim Bitcoin isn't governed by any central authority, rather it's governed by mathematics.

What exactly do they mean when they say "governed by mathematics"?

That the network is secure by means of math instead of some central authority (e.g. a bank overseeing everything)? If so, what math?  The math that makes PoW possible?

This question may be opinion based in some ways, but I'm going to attempt to answer it as it is an important concept, and somewhat unlike traditional systems.

Bitcoin is governed by math, in some places. At the end of the day, it's software, and even the math rules can be updated to use different rules, or removed altogether by means of a soft or hard fork (depending on how drastic the change is).

As for the math, there are primarily three sections where it is in play.

The first is mining - the hash function is used to calculate a value, which is compared against the mining target.

The second is signatures - elliptic curve signatures are used to enforce utxo ownership (for standard outputs anyways).

The third is the block reward - The Bitcoin block reward halves every 210,000 blocks, lea

That said, none of these are particularly math-y. As with any computer program, math is used to enforce certain functionality.

It may be more appropriate to say that Bitcoin is governed by code - The code is ultimately what decides things such as block reward halving, signature technicalities, and mining process. As the abundance of altcoins shows, there are many permutations and combinations on all of these parameters that still result in valid and functional networks. Even Bitcoin has gone through a series of network upgrades that have altered some of these rules, such as moving from an infinite supply to a fixed supply.

As chytrik mentioned in the comments, the infinite supply fix was actually a bug fix (the infinite supply was a side effect of C++ behaviour, and would not have occurred for equivalent code in many other languages).

Bitcoin can indeed be looked at as a model of social governance governing the code, and the code governing the network.


I get invalid argument error when running bitcoin-cli -getnetworkinfo, and a few other parameters So I have bitcoind -daemon running and it appears to be generating the blockchain. keeps saying

  Potential stale tip detected, will try using extra outbound peer...

The issue is I run bitcoin-cli commands and get the following error:

$ bitcoin-cli -getnetworkinfo
Error parsing command line arguments: Invalid parameter -getnetworkinfo

same for many others. The only cli command that seems to work is :

bitcoin-cli -getinfo
{
  "version": 180100,
  "protocolversion": 70015,
  "walletversion": 169900,
  "balance": 0.00000000,
  "blocks": 0,
  "timeoffset": 0,
  "connections": 0,
  "proxy": "",
  "difficulty": 1,
  "testnet": false,
  "keypoololdest": 1573696666,
  "keypoolsize": 1000,
  "paytxfee": 0.00000000,
  "relayfee": 0.00001000,
  "warnings": ""
}

according to the manual they should all work but many are saying invalid argument. I have searched and am shocked that there does not appear to be any info on why this is happening to some and not others. So here I am.

getinfo has been deprecated as an RPC command, and the hyphenated version is provided as a bridge for legacy applications that have not yet moved to getblockchaininfo and getnetworkinfo.

For regular RPC commands, you do not need the hyphen, and can simply run them as bitcoin-cli getblockchaininfo.

The hyphenated parameters control the behaviour of bitcoin-cli itself, such as which datadir to connect to, or whether to use named parameters in the requests.


Economics of Bitcoin Mining I thought I understood the gist of what "bitcoins" are: electronic currency tokens representing $X USD that could be used to trade, buy or sell online items.

But recently I heard the term "mining for bitcoins" and it piqued my interests...

I read this article and still feel like I'm missing the bigger picture here.

If I understand "mining" bitcoins correctly, then:

Bitcoin mining is the act of setting up a commodity hardware cluster to try and "crack" some cryptographic puzzle
When you finally crack such a puzzle, you are rewarded in bitcoins
You can then, theoretically, sell bitcoins for real money

So to start, if anything I have said so far is off base or needs correction, please begin by clarifying what bitcoins and/or bitcoin mining is!

Assuming I am more or less correct, then I have several questions that (surprisingly) have been nearly impossible to find answers for:

Who issues these puzzles and validates a correct answer?
Who brokers the generation and awarding of "mined" bitcoins (after you've cracked the puzzle)?
Isn't this (really) just a crytpographic game? You play the game, and you win, except you get money. But there's no reason why someone would need you to be cracking these randomly-generated crypto puzzles.
When new "puzzles" are generated, and new bitcoins are generated and awarded to the people who correctly solve these puzzles, doesn't that dilute the value of each existing bitcoin? Not an economist here, but if you have more of something, it's value usually goes down since it's not as scarce.
Is it even worth a programmer's time to delve into this stuff or is the bubble already bursting?

To me it seems like bitcoins are just a game that has been disguised to as a pyramid scheme that has been disguised as a legitimate radicalization of e-commerce. Thanks in advance for any help/insight here!

The puzzle is to find ordering and choice of pending transactions with certain restriction of hash and put the into a block. Therefore the puzzle is part of system. The verification is done by everyone - every time you connect to bitcoin you verify that block chain you have received is valid. If it is not you just reject it.
No one awards them. Simply the person who puts a block is allowed to add note that he put it at the end. (S)he is awarded the benefits of putting it (transactions costs and the mining award)
Bitcoin mining as activity can be viewed in this way but it is not the only way of viewing it. In gold standard when you gold mine you are playing 'a game' however it is not the main purpose of money in such system.
Yes. However there is limit of how many bitcoins will ever be produced and you know exactly the schedule. The increase of money supply can be offset by money demand. In the end the only award for minings will be voluntary transactions costs (on the other hand as miner picks the transactions it is presumed that the highier the donation the faster the transaction will be processed).
I won't answer it but technically you can image say a country adopting bitcoin as official currency. This is for you to decide.

I believe there are several in-depth answers you can find on the web. I belive there is episode of Security Now, Linux Outlaws as well as bitcoin wiki which can answer further questions. My guess is that bitcoins per se were not design as scheme and mining in principle can be seen similar to gold one (assuming gold had no other purposes then currency) with possibility of gold fevers. If it will survive I don't know.

In any case please do NOT consider this answer as investment advice (or any other advice).

EDIT Simple explanation of terms as I understand them

Transaction: Any sending from one bitcoin address to others is transaction - it is not revertable. The transaction is verified by the sender private key but all transactions are public (bitcoin is not anonymous - even the amount of money on the account is visible). Once it is done the transaction is pending. You may set a transaction cost to ensure quicker processing of it.
Block: Block is a set of transactions that have been confirmed. They are verified by hash which, in addition, needs to fulfil certain requirements like number of 0-s at the beginning (the proof-of-work). Person who created a block is awarded all of the transactions costs and up to the point a bonus (currently 25 bitcoins). Currently the latter is main benefit of mining. However in future the award will be 0.
Block chain: Block chain is chain of blocks. As this is distributed systems the histories might diverge - as general rule the longest wins (first in case of ties).


Blockchain data storage My learning on blockchain is mainly theory based. I have always been under the impression that blockchain is about data processing and data storage which I think this is where I am confused.

I have always pictured blockchain as a P2P decentralised data storage system where anyone can transfer/upload/store anything on the blockchain network. Data can be anything of a value. Any upload and transfer of data is encrypted. Data is stored encrypted. There is some magical formula that turns whatever size data into digest. Anyone who retrieve the digest will be able to turn it back to the original content with the key.

The more I delve into it, the more it seems I have been understanding it all wrong.

Data Storage

I understand Bitcoin is not meant for data storage. It can be but not meant for. I read about IPFS.

Now, the data storage part whenever it is mentioned with blockchain technology(not restricted to bitcoin), without reference to IPFS or equivalent, does the data generally mean hashes of digital signatures? We store the digital signatures of the data. We don't 'upload and save' the content like what we do with cloud storage? (Let's assume cost of storage is not an issue.)

The recipient is not able to 'convert' the digest to the original content since the original content is not 'transfer'/'store' on the blockchain at all.

If we want to encrypt the data, we will do it 'on our own' using an external service off the chain. We sign the encrypted data with private key. The recipient will use our public key to verify the digital signature and what they received is the encrypted data. The decryption part is to be communicated off the chain.

Have I understood the above correctly now?

=======

My question is not restricted to Bitcoin but blockchain in general.

How does IPFS use Blockchain
https://ipfs.io/#how says

Blockchains
IPFS and the Blockchain are a perfect match! You can address large amounts of data with IPFS, and place the immutable, permanent IPFS links into a blockchain transaction. This timestamps and secures your content, without having to put the data on the chain itself.

So yes, IPFS is separate from the Bitcoin blockchain but it seems you have the option of embedding a hash in a Bitcoin transaction (for which the usual fees are needed) as proof that the hashed data existed at a point in time.
The Bitcoin blockchain is a journal of Bitcoin currency transactions. Small items like hashes can be included in the transaction details that are recorded but you pay a fee per byte and you need to have a funded wallet.

Related Questions

What methods are currently used to embed additional data into the Bitcoin blockchain?


Changing Bitcoin's deflationary nature One of the most common criticisms made against Bitcoin is related to its deflationary nature.  Regardless of the advantages and disadvantages of an inflationary system, would it possible to change the rate of coin generation in order to transform Bitcoin into an inflationary currency?

I know that the Bitcoin protocol and client are often updated to incorporate new features, but what part of the protocol (if any) is set in stone? Could such a drastic change be done by the developers?

Changing something like coin generation has two major risks:

a) You fork the network.  If you make a change and it doesn't have universal support then those supporting the old network will see new blocks as invalid and those supporting the new network will see old blocks as invalid.  To users who don't want to get caught up in a "fork war" the results will be confusing. If user on fork A send coins to user on fork B they will be gone but user B will never get them (unless he modifies his client to fork A).

b) You cause a loss of confidence.  Bitcoin is based on "nothing".  Part of its intrinsic value comes from the fact that nobody can make changes and thus like the "rules" or don't like them you at least know the rules won't change.  Anytime you make a change someone gains and someone loses.  For example if the Federal Reserve lowers interest rates that helps debtors but hurts savers.  Once you start changing the rules Bitcoin becomes open to manipulation with each party pushing for changes that help them.  There is a real risk that will cause a huge loss of confidence.  IF you can gain enough support to change the generation rate you can change just about anything and some people won't like that ambiguous future.

Those risks aside to change the rate of generation you need to
a) decide on a future block in which to change generation
b) reach near unanimous consensus among users (at least among users you can reach)
c) provide updated client which incorporates changes at the preset future block.
d) encourage rapid and widespread adoption of clients with new changes prior to the change block.
e) at the "change block" be prepared for significant issues from users with out of date clients.

There is no way to force this (or any other) change on the Bitcoin community.  Any change require consensus and for something as devisive as generation change that would be difficult.  If it has low support the "inflation fork" will die off.  If it has high support, then even those who dislike it will eventually adopt it and the original fork will die off.  A worst case scenario would be a "fork war" where both versions have roughly equal support and neither one gains an upper hand.  That likely could crippple Bitcoin or at least push it back significantly.


Is it possible to separate blockchain and wallet functions? I'm looking for a way to use bitcoin-core in monero-way (It uses separate blockchain daemon and wallet daemon).

I'd like to run bitcoin-qt interface on my laptop and connect to external node with full blockchain. In this way I can share my full node with other people and my wallet will be safe.

Is it possible to use bitcoin-core in this way?

P.S.: I listen about electrum-server, but I don't want to use another software.

Is it possible to use bitcoin-core in this way?

No. bitcoin-qt is a completely standalone software that includes all of bitcoind's functionality. It does not start bitcoind in the background nor does it connect to a background daemon.


Coinbase address still has a balance I understand that Coinbase creates many btc addresses per wallet. I am not sure though that if you have an overall zero balance (or $0.01 overall) all your associated btc addresses should also have a zero balance.

So, here is the actual question: I see that one of my btc addresses associated to one of my coinbase wallets (let's call the address ABC123) still has a bitcoin non zero balance. It's not a rounding issue as the balance is too large for this. Overall my coinbase balance is almost zero. Does this make sense?

When I go to https://bitref.com and check ABC123 I can see the balance.

Coinbase (the company) is not bound to any value presented in any block explorer or even in the actual blockchain.  They decide what will be presented as your balance on their service's website, and hopefully it is always the same value that you expect to see.

Coinbase might allow funding of your balance through payment to bitcoin addresses over the bitcoin network, but in reality they will maintain a separate, much more efficient database than a blockchain to track that balance from that point on.

When you operate on those funds, you're operating on the number kept in Coinbase's database, not the one in the blockchain.  It costs money (as fees paid in bitcoin) to move funds between participants on the network, so any transactions that can be kept off chain are done within their own database (like sending between two Coinbase users).

In case you are withdrawing bitcoins from Coinbase, they will have to use an on-chain transaction (eventually), but the funding to it can come from any other payment made to them.  It doesn't have to be the same payment that you made.


How safe is sending out transactions using unconfirmed inputs for a service? I've been running into problems with a high-traffic hot wallet, where a single transaction would lock up any input for a block with the spendzeroconfchange disabled.

Would it be safe for a service like Coinbase to use unconfirmed inputs on average transactions? Would I run into similar issues like MtGox did?

Safety is relative---large payment processors like Coinbase probably have non-block-chain anti-fraud measures.  However, a confirmation (and each additional confirmation after it) reduces the risk of a double spend fraud, so waiting for a certain number of confirmations is an easy and effective anti-fraud measure that doesn't cost you anything.

I don't know for sure what happened to MtGox, but it is true that an unconfirmed transaction can become effectively unspendable if any of its inputs become unavailable---which could happen because a block was created containing a transaction that already spent that input (a double spent) or because the transaction which created that input was added to a block in a mutated form (transaction malleability).


What are Bloom filters and why does Bisq require them to be activated on my local node? First of all, why does Bisq care about Bitcoin Core being installed or not?
Then why does it require it to be fully synced and not pruned?
Finally, the error message talking about "Bloom filters" is confusing me, what are they and why does Bisq need them ?

Bloom filters are a legacy way for a light client to query transaction data from a P2P node.
They are defined by BIP37 and we usually refer to these clients as "SPV wallets".

Why does Bisq care about Bitcoin Core being installed or not?

So that it can query transactions from localhost instead of scanning from some external source (with the well-known privacy leaks of bip-0037).

Why does it matter if it's "fully synced" or not before Bisq is started?

Considering the application, they may want to be sure to be to the latest Bitcoin state before taking any action on their own P2P network.

Why does it matter if it's "running in pruned mode"?

You'd be missing blocks and potentially some historical transaction data that Bisq might want to query for.


How probable is a sybil attack? I'd like to know what's the probability of a sybil attack and if there are mechanisms built in to prevent this kind of attack?

One cool thing about Bitcoin is that coins are inherently scarse and this is by itself a huge protection from sybil attacks. In other P2P systems, sybil attacks are much harder to prevent because there's no such concept of scarcity. In Bitcoin, a sybil attack would be achieved if one has lot of coins, by sending tons of transactions, and therefore spending such coins.

There are other types of sybil attacks such as overloading nodes connections, and the recent one of filling up the memory pool of specific nodes with really tiny transactions. A way to prevent these would be for example to increase the fees.


How to perform automated mining in regtest mode? I'm trying to setup a private network of bitcoin nodes for testing and experimentation. From what i understand, i have two choices while setting up a network:

I can run bitcoind -testnet and connect to the public test network. The testnet has nodes that will facilitate the mining of my transactions as long as i just broadcast them.
I can configure the node with regtest=1 and manually run the generate command whenever i want to create blocks.

I've also managed to find out that the mining is no longer a part of the core codebase and is usually in an external component.

What i don't understand is how any of these mining softwares interact with the bitcoin node. Does it periodically poll through the JSON RPC to check if the transaction pool has reached a certain threshold (in numbers or size)? If not, what triggers the beginning of a mining operation? Can the bitcoin node send out events when the transaction pool reaches a threshold?

I want to setup a similar automated process for creating blocks in my regtest network, but using the generate command instead of any mining software. I don't need a robust PoW setup in my local network. My aim is to just build an app which interacts with the nodes and makes transactions. Is writing an RPC client which periodically queries the pool size and fires a generate command on reaching a threshold the right way to proceed? Or does the bitcoin node itself provide some way to setup periodic generation of blocks?

Thanks in advance.

P.S. I'm very new to bitcoin development, so apologies if this is an obvious question.

The miner can generate a block candidate with the getblocktemplate call, which uses certain heuristics to construct an approximation of an fee-optimised block given the current local mempool state.

1) The question in regards to when to begin mining

Generally, the miner will want to begin mining the next block as soon as the strong chain is extended, maximising the time available to search for the solution.

However, consider building an optimal block template from a growing number of unconfirmed transactions being accepted into the mempool. This means a transaction selection so that total block fee reward is optimised, whilst ensuring no double-spend. A growing mempool provides a greater optimisation space, but takes time. Solving for the exact optimal block from an increasingly large pool of valid transactions is NP-Hard (knapsack/max independent sets) and expensive.

At some point, the gains in fee rewards of solving this optimisation problem will be offset by the opportunity cost of the miner (during optimisation, the miner hashing equipment will necessarily be idle). Simpler heuristics may optimise for a less than optimal block template (as in getblocktemplate), but enables the miner to begin mining immediately.

If you wish to apply your own block template solver, you can get a mempool dump via
getrawmempool (not very efficient to acquire over RPC).

2) Regarding regtest in a local network

Is it possible to create bitcoind regtest network on Ubuntu (which itself is on Virtualbox)?


Do Multi-Signature Wallets Require Two Separate Bitcoin Wallets? Put more simply, is it possible to set up a multi-signature wallet that takes both signatures from itself?

No, two wallets are not required. It sounds like you might be confusing wallets with addresses, where one bitcoin wallet can house many bitcoin addresses and keys.

If you want to be able to execute a 2 of 3 multisig from one wallet you can do so with bitcoin core with raw transactions. You will have to keep track of the private keys and redeemscript yourself and save them somewhere like a thumb drive for example.

Here's a video tutorial that can guide you through creating and spending with your multisig address using bitcoin core.


Are hashes of Merkle tree roots unique throughout whole blockchain? The "Mastering Bitcoin" book says that each block header contains a 32B long hash of the Merkle root for all the transactions it contains.
If I extract all these Merkle roots from all the blocks in the blockchain (longest branch only) and put them in a list, will that list have any duplicates?

The merkle root is a 32 byte hash.
As the hashing operation is sha256, it is exceedingly unlikely that you will find duplicates, but it is not, strictly speaking, impossible.


Why must UTXO be completely consumed? Imagine Alice owns 10 BTC and wants to send 1 BTC to bob, with a 1 BTC miners fee.

In the blockchain, the transaction is recorded as "Alice spent 10 bitcoins, 1 goes to Bob, 1 goes to the miner, and 8 goes to Alice".

That seems rather unintuitive. Why not just record the payment and miners fee explicitly?

I've looked into this before, and I've never been able to find an explicit rationale from Satoshi, but there are a couple of possible reasons.
For: Simplifies SPV verification
Imagine that rather than using the spent/unspent model, you track the balance of each address. You get a zero-confirmation transaction that pays to you from an address.
Now, to figure out what the balance of this address is, you need to get all of the deposits and withdrawals from it. If you miss one, you calculate the wrong balance.
You could fix that by forcing each transaction from an address to reference the last transaction by hash, but that eliminates an important property of Bitcoin - multiple deposits and withdrawals to and from the same address can be processed at the same time, without coordination between them.
For: Improves transaction privacy in theory
The change output (which you referenced as '8 BTC goes to Alice') is sent to an entirely new address, and in theory it is not possible to figure out which output is the change output. In practice, the real output is usually a nice round number, and the change output is something like 0.00019841.
Against: Makes increasing the fee really complicated
If you've used Bitcoin for long enough, you've probably run into a situation where someone sent you some Bitcoins, but didn't attach a fee.
If the change output were explicitly marked, the sender could just resend the transaction with a slightly smaller change output, and a slightly larger fee. Miners would know that they could safely accept the new transaction into their memory pool without helping anyone commit fraud. Then, we wouldn't need stuff like replace-by-fee or child-pays-for-parent.
Against: Makes the UTXO set much larger
If you have 50 outputs that make up your money, that means that you're taking up 50 times more space than you would if you had a single balance.
TL;DR: It could have been done differently, and there are some reasonably compelling arguments, but it's impossible to change now.


On Coinbase Pro does anybody know what criteria are used to decide if a limit order should be rejected due to insufficient funds? I'm playing around with their sandbox api and trying to figure out when a buy order will be rejected due to insufficient funds. It seems that market orders will be rejected only if you give the order funds greater than the amount of USD you have in your wallet. That seems straight forward enough. The case for limit orders seems a little bit more complicated. If I have $1000 in my wallet and I specify a buy order for 1 BTC for $1000 the order will be rejected due to insufficient funds. I'm guessing this is because I need money for any possible fees. However if the order goes on the order book as a maker order.

My question is do I need enough USD for possible fees regardless if the order becomes a maker or a taker order?

From experimentation it seems like if you're placing a limit order you need enough USD in your account to cover any possible fees regardless if the order will become a maker or a taker. I'm going to mark this as the answer util someone corrects me.


Is there a way to identify number of wallets opened by an exchange This is precursor to a data science question.
Essentially, I am trying to map bitcoin's price to the number of wallets opened today on an exchange.
It's quite common that the users would put in a buy request tomorrow, so a time series can be applied.

You won't be able to see the number of wallets, but you could get quite an idea by looking at the number of adresses an exchange generated.

( Exchanges such as poloniex only have 1 wallet for all their customers. )

See https://www.walletexplorer.com/wallet/Poloniex.com/addresses

I'm not entirely sure if walletexplorer also tracks coinbase adresses, but in the case it doesn't, you can use http://matbea.net

They currently track over (28.500.000+) coinbase adresses.

https://blockonomi.com/matbea-trace-bitcoin-address/

^^ (I wouldn't recommend using their webwallet though, and i'm also not saying that this is 100% indexing all adresses.)

For example, using matbea.net, i was able to identify 1DUiLkf34q7MVxtRkMAXVtP42UNGRrbftY  as a coinbase adress.

https://www.walletexplorer.com/wallet/000001e522b362b7?from_address=1DUiLkf34q7MVxtRkMAXVtP42UNGRrbftY


Ripple validator nodes Are ripple validation nodes appointed by central authority? If not, what prevents 51% attack through validator nodes? Why ripple.txt file contains validation nodes list? Who maintains this list? What is incentive for users to run validator nodes?

Thanx!

Are ripple validation nodes appointed by central authority?

No. Nobody has any particular right to tell anyone what validators to use or listen to.

  If not, what prevents 51% attack through validator nodes?

It depends what you mean by a 51% attack. If you mean a case where validators refuse to agree, then a 51% attack would cause the attacked node to fail to make forward progress. In that case, one would hope the operate of that node would stop listening to the validators that are causing the problem. Validators sign every statement they make, so this is not difficult to detect.

A 51% attack on the XRP Ledger is extremely unlikely because it doesn't allow a double spend. It just stops forward progress. So some group would have to convince people to listen to their validators only to lose any credibility they had gained the first time they attempt such an effort.

We would expect users to choose validators based specifically on how unlikely they are to collude to DoS the network. So you would have to have someone go to all the effort to convince people they're not likely to do the very thing they intend on doing, and all they get out of it is perhaps a short term denial of service on the network and then they lose everything they worked to build. It's extremely unlikely such a thing would ever happen, simply because it's so much work to do and you have so little to show for it.

  Why ripple.txt file contains validation nodes list?

If users just want the system to work and don't particularly care how two valid but conflicting  transactions received at about the same time are resolved, they can just use the default list. If it stops working, then they can change it.

  Who maintains this list?

Whoever publishes that file. Anyone who wants to can publish such files.

  What is incentive for users to run validator nodes?

Roughly the same as running a bitcoin full node. If you're running an XRP Ledger node anyway, the additional cost to run a validator is effectively zero. It doesn't get you any special powers, just as running a bitcoin full node doesn't, but it does help to keep the network stable and resistant to DoS attacks. People who want the network to be stable and resist DoS attacks will have an incentive to run a validator.


How to track bitcoin wallet activity with extended public key? I recently signed up on blockchain.info and on the manage addresses section I can see my wallet Extended Public Key (xPub). There is a warning message saying:

  You should only give this Extended Public Key (xPub) to those you
  trust. With this information, they may be able to keep track of your
  payments, and may be able to disrupt your access to your wallet.

I'd like to know how this works. How could someone keep track of payments that a wallet receives and sends if he knows it's Extended Public Key?

Using the extended public key one could derive all of the addresses associated with your wallet. This would allow someone to determine future and current addresses in your wallet, this could allow someone to monitor your financial activities. I'm not sure how they could disrupt access to your wallet. I believe it functions similar to a HD wallet public key.


Does rpcpassword need to be non-obvious in bitcoind? I'm syncing a full BTC node onto an external hard drive, which I'm connecting to by USB. I've created a bitcoin.conf file which sets a very insecure rpcpassword. This is literally the only field I put in the bitcoin.conf file. In what way does this matter?

(I've just changed the password. Should I restart the sync, given that it's 49% through?)

By default the RPC interface is only exposed to localhost (127.0.0.1 and ::1), not to the world. In that setting, you need an RPC password only to protect against untrusted local users on your system (unless you're somehow tunneling the RPC port 8332 out).

That said, why do you have an rpcpassword at all? If you're only going to use bitcoin-cli for example you don't need one since version 0.12 (see https://bitcoin.org/en/release/v0.12.0#rpc-random-cookie-rpc-authentication). If you need for having external applications to to bitcoind, rpcauth is preferred over rpcpassword.

There is certainly no need to restart syncing.


my coin transferred on 17 Dec and confirmed on 31 Dec still showing unspent on 5 Jan I have done a couple of transaction in Blockchain but have never experienced such problem. I transfered coins from my wallet to another account by choosing custom fee option on 17 Dec which got confirmed on 31 Dec and showing unspent there till 5 Jan now.
https://blockchain.info/tx/592d3405f60e87c55afa72b989354c7f773def2bca848bb0f15d3039c4d6b91e

I hope my coins are safe and will get it soon?
please help
Manoj

That transaction is valid and confirmed.

"Unspent" in the right-hand column means that the outputs have not been spent.  The funds are still sitting in the 1965... and 144f... addresses and have not been moved out of those addresses.

If one or both of those addresses belong to you (i.e. you generated them with your own wallet and have the private key(s)), then you can spend those funds any time you like.

If they belong to someone else (e.g. a merchant from whom you are trying to buy something, an exchange where you are trying to make a deposit to your account, etc.) then that person has the funds.  If they haven't acknowledged the funds (delivered your order, credited your account, etc) then that is something you have to take up with them directly.  But the Bitcoin protocol has done its job at this point.


How to create bitcoin wallet by PHP I'm new to Bitcoin. I want to use PHP to create a bitcoin wallet on my own website. I came to here https://blockchain.info/api/create_wallet but I don't know how to apply it.

Would like to have good tutorials from some websites or videos.

You can find your answer here

Snippet of code

Example from bitcointalk

    <?php
  #Below is full list of available characters.
  #"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
  $fp=fopen("/dev/urandom","r") or die;
  $available_chars="23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnpqrstuvwxyz";
  do{
    $minikey='S';
    for($i=0;$i<29;$i++){
      while(($c=ord(fgetc($fp)))>=strlen($available_chars));
      $minikey.=substr($available_chars,$c,1);
    }
    $check=hash('sha256',$minikey . '?') . "\n";
  }while(substr($check,0,2)!='00');
  fclose($fp);
  $priv=hash('sha256',$minikey);
  print "Minikey: $minikey\n";
  print "Privkey: $priv\n";
?>

You can find some useful information here


What other currencies have same malleability vulnerability as Bitcoin? Malleability of Bitcoin protocol has contributed to major losses and represents uncomfortable risk to Bitcoin investors in addition to possibility of 51% attack that depends on promise of biggest mining pool.

Of course, any centralized exchange company can run away with depositors money, but, at least, currency protocol should be strong enough to not allow exchange company owners to blame losses on protocol and hackers.

Do Ethereum or NXT or counterparty or ripple or mint or any in top 10 have same vulnerability ?

This is a quite hard analysis to make. In general all alt-coins that are based on the concept of dynamic input-scripts and output-scripts are subject to transaction malleability. This is because anybody could change the input scripts of a transaction, by adding commands that wouldn't alter the validity of the script, but would alter its hash. For example adding OP_DROP will leave the stack exactly as before prior to scriptPubKey execution.


understanding how exchanges "store" bitcoins I understand that securing your bit coins is basically about protecting the private keys for your addresses. This makes sense from my past dealings with public/private key encryption. How do exchanges handle and store your bit coins for you? Is it basically a secured list of your keys? Can you get access to the keys either to back them up, spend them outside the exchange, or move them to another exchange? What would happen if an exchange was compromised (i.e. siezed). I can imagine that I'd lose any dollars but my bitcoins are still accessible to me outside the exchange as long as I have the private keys, right?

You access the bitcoins in your account at an  exchange through their web interface only. They keep the private keys to those those bitcoin addresses hosted at their exchange. So, even though its your account, they control the private keys.
If you want to move those funds outside the exchange, pay them to yourself on a wallet hosted on a device you control. An exchange is unlikely to give you access to the private keys, because then the private key would be out of their control and they could not guarantee that the funds were safe nor be held responsible if they were spent.


how do I create and encrypt a dogecoin wallet? I've looked at the dogecoin wiki, but don't see any resources explaining how to actually create a wallet and encrypt it.

I'm running dogecoin-qt on Linux.

Under "much receive" on the GUI, I can add addresses.  But there's no option to encrypt which I see.

The "wow" tab says wallet, 0.000 doge (which I expect).

Where is the wallet info to read?  Is it encrypted?  How do I encrypt it?

I can find the file itself well enough:

thufir@dur:~/dogecoin$
thufir@dur:~/dogecoin$ locate wallet.dat
/home/thufir/.dogecoin/wallet.dat
thufir@dur:~/dogecoin$

but I'm trying to use the GUI.


how and when does block and transaction validations take place? I have a couple of questions and will try to explain them here.
So, let's say we have 4 nodes in the whole network.

one of the nodes (node A) took transactions from pool. before they put it into a candidate block, they first validate each transaction, right ? if so, i guess they check balance and signature. Anything else ?  and if all good, they put each valid transactions into a candidate block and after that, they start mining this block... I guess unvalid transactions disappear or something..

Let's say node A mined the block the quickest. It put the block into its ledger and also shared this block to other nodes so they can add it to their own ledger too.  I know that other nodes won't just add it to the ledger until they confirm that this new block was really mined(will take the hash of the header and check if it's below current). Is this correct ? if so, Then, question is, will they also conduct a validation for each transaction from this block ? if yes - why ? if no - why ?

If I make 2 transactions one after another, even though I only have balance for only one transaction, those 2 will go to pool first. and I guess, when my node checks validation of transactions before putting it into a candidate block, they will see that whichever they check first is valid, and second one is not valid anymore since they already have checked the first one. Right ?

Generally each transaction is validated when it is added to the mempool of the node. This happens when the node first sees the transaction, it doesn't wait til it is added to a candidate block for mining. The candidate block for mining would be formed out of the transactions already in the mempool - those which have already been validated by the node.
If another node receives a block then yes, it will validate the proof of work and other factors such as the timestamp, and it will also validate each transaction in the block that it hasn't seen before. The ones it has seen before will simply be removed from its mempool and do not need to be re-validated.
Re 3., nodes will not accept two conflicting transactions into their mempool. Each node will accept whichever valid transaction they see first. This may not be the one that ends up in the block eventually, but the node will correct this once one of the two conflicting transactions has been mined.