Is it possible to read every transaction my node relays? I'd like to add every valid transaction my node receives to my own database.

At the moment, I'm using getrawmempool every second to find new transactions, and then getting the data for them using getrawtransaction.

However, these bitcoin-cli queries can be slow. So is there a way to "intercept" every valid transaction my node relays without having to use bitcoin-cli? Preferably using PHP?

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

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

<?php

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// MAKE MESSAGES

function makeMessage($payload) {

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

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

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

    return $header.$payload;

}

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

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

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

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

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

    return $version_payload;

}

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

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

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

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

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

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

Thanks to theymos for the advice.

How to use:

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

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

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


What are the hex and asm field values in the JSON decoded from a raw transactions? I used the command line bitcoin-cli decoderawtransaction <hex-value> and got back a JSON output (see below). However, I noticed there are hex and asm fields that are themselves hex values (at times). I am thinking these are metadata that can further be decoded. Is that right?

Is there any more documentation on the structure and meaning of the JSON passed back for these 2 fields (or more)?

I read this SO post which referred to this out-dated article.

Also, I checked the transaction on bitcoin block explorer. They seem to have a few metadata that I don't see in the JSON (e.g. received time, confirmations, relayed ip, etc...). Where are these values coming from?

{
  "txid": "2514161c059ac18bf2eff1e05c4628e322d846e930fd6dd4b24805ea59dc4913",
  "hash": "2514161c059ac18bf2eff1e05c4628e322d846e930fd6dd4b24805ea59dc4913",
  "size": 259,
  "vsize": 259,
  "version": 1,
  "locktime": 0,
  "vin": [
    {
      "txid": "4f40655c4ab1a029bc41bc547f79556a0dc48d22df7202778fad592791c77fcd",
      "vout": 0,
      "scriptSig": {
        "asm": "3046022100cd6795ebcd1b6b87833a4ad812733d3804065d34bafee24da181a770892272b902210088cd2484952ad2572f9bfb2874643dbb4b3c492b749e79d8177a14eb4a3bc61a[ALL] 04bbf2b84900b6f898548687aefba86cc06da6f4656a71e45fa55128b501455b5486cb09705cfa23c1899fe46d4355c9058bb2de4f1a7f1a01ff27e00b306f7356",
        "hex": "493046022100cd6795ebcd1b6b87833a4ad812733d3804065d34bafee24da181a770892272b902210088cd2484952ad2572f9bfb2874643dbb4b3c492b749e79d8177a14eb4a3bc61a014104bbf2b84900b6f898548687aefba86cc06da6f4656a71e45fa55128b501455b5486cb09705cfa23c1899fe46d4355c9058bb2de4f1a7f1a01ff27e00b306f7356"
      },
      "sequence": 4294967295
    }
  ],
  "vout": [
    {
      "value": 889.94500000,
      "n": 0,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 f9d49c5cf3e120ad1be60b67d868603a8fc945d2 OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914f9d49c5cf3e120ad1be60b67d868603a8fc945d288ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "1PmyxDv5VvGoSAKMr1DQcWB6sHPx1ZbgWe"
        ]
      }
    },
    {
      "value": 10.00000000,
      "n": 1,
      "scriptPubKey": {
        "asm": "OP_DUP OP_HASH160 088465c1f0c8b3b3da06f7073a921d6b95b22f49 OP_EQUALVERIFY OP_CHECKSIG",
        "hex": "76a914088465c1f0c8b3b3da06f7073a921d6b95b22f4988ac",
        "reqSigs": 1,
        "type": "pubkeyhash",
        "addresses": [
          "1n31g4rKiEeXnZEZR6VZwm3LggLicEqEC"
        ]
      }
    }
  ]
}

Furthermore, I decoded the raw transaction using https://blockchain.info/decode-tx and got something different.

{
   "lock_time":0,
   "size":259,
   "inputs":[
      {
         "prev_out":{
            "index":0,
            "hash":"4f40655c4ab1a029bc41bc547f79556a0dc48d22df7202778fad592791c77fcd"
         },
         "script":"493046022100cd6795ebcd1b6b87833a4ad812733d3804065d34bafee24da181a770892272b902210088cd2484952ad2572f9bfb2874643dbb4b3c492b749e79d8177a14eb4a3bc61a014104bbf2b84900b6f898548687aefba86cc06da6f4656a71e45fa55128b501455b5486cb09705cfa23c1899fe46d4355c9058bb2de4f1a7f1a01ff27e00b306f7356"
      }
   ],
   "version":1,
   "vin_sz":1,
   "hash":"2514161c059ac18bf2eff1e05c4628e322d846e930fd6dd4b24805ea59dc4913",
   "vout_sz":2,
   "out":[
      {
         "script_string":"OP_DUP OP_HASH160 f9d49c5cf3e120ad1be60b67d868603a8fc945d2 OP_EQUALVERIFY OP_CHECKSIG",
         "address":"1PmyxDv5VvGoSAKMr1DQcWB6sHPx1ZbgWe",
         "value":88994500000,
         "script":"76a914f9d49c5cf3e120ad1be60b67d868603a8fc945d288ac"
      },
      {
         "script_string":"OP_DUP OP_HASH160 088465c1f0c8b3b3da06f7073a921d6b95b22f49 OP_EQUALVERIFY OP_CHECKSIG",
         "address":"1n31g4rKiEeXnZEZR6VZwm3LggLicEqEC",
         "value":1000000000,
         "script":"76a914088465c1f0c8b3b3da06f7073a921d6b95b22f4988ac"
      }
   ]
}

asm refers to the de-serialised form of the script, with well-known tokens parsed as script tokens.

hex is just the serialised form of the script in hex encoding.

If you compare them carefully, they are essentially equivalent.

For example:

OP_DUP OP_HASH160 f9d49c5cf3e120ad1be60b67d868603a8fc945d2 OP_EQUALVERIFY OP_CHECKSIG

76 a9 14 f9d49c5cf3e120ad1be60b67d868603a8fc945d2 88 ac

76 is OP_DUP

14 is the number of bytes to be pushed onto the stack.

and etc...


Why does Bitcoin need transaction fees prior to hitting its maximum coin limit? I have a question regarding the theory of Bitcoin . Why does Bitcoin build in transaction fees before it hits the maximum allowed amount of coins?  That is, shouldn't the reward of coins for mining a block be enough to keep the system going?  In addition to the trouble we're seeing now (a high value of Bitcoin makes doing simple transactions uneconomical), it seems like building in a transaction fee taht the user can select would rig the system such taht higher fee transactions would get prioritized over lower-fee ones, which would restrict some people from using Bitcoin.  I guess all cryptocurrencies do this so there is no way of avoiding it.

One reason behind a transactions fees is to make spam attacks expensive.
Without fees, a malicious party could create a lot of no-fee transactions for a DoS attack on blockspace. And without fees a miner wouldn't be incentivised to include the highest fee transactions in a block. He could attack the network by mining empty blocks or including spam transactions. (e.g. transactions with clearly and solely exist to bloat the UTXO-set or to fill up blocks).

And correct - with a high enough transaction fee some people in e.g. third world country's can't pay for the transaction. However enabling users to select a transaction fee is necessary. A user that doesn't need fast confirmations can pay a lower fee than a user with a need for an instant confirmation. Thus a fee-market can develop.

This might be an interesting read regarding this topic:
The Fee Market Explained by Jimmy Song


Stealing a correct hash because of an invalid block Suppose that a miner find the right hashes but involuntarily or by malicious intention then create an invalid block, like trying to double spend a transaction
My guess is that the moment this block is broadcast the first node to receive and test this block will immediately copy the correct hashes and produce a block of his own this one valid and with his own coinbase address.
I know that this scenario has little chance to happen because miner know that their coinbase will be steal and rejected by the network, but is this a valid working process ?

It's not a valid working process: all transactions commit to the block hash.
First of all a miner cannot "find a right hash" then insert a double-spend transaction. This would invalidate the hash (and the block, actually).
For the same reason, a node receiving the block cannot malleate the coinbase transaction. It would not be able to "immediately produce a block" either.
In addition, blocks have consensus rules and a valid block does not only consist of a block header hash inferior to the target but must respect a number of other rules as well (locktimes, existing outpoints, valid scripts, ...).
The cost of producing a valid PoW is so high that you would not expect a miner to commit energy to an invalid block.


What is the current status of Multi-Sign function in bitcoin network? Are they convenient enough for some real world transactions? Like an easy escrow that the two party can assign to a third party to finish a transaction?

This topic has gotten a lot of traction recently, with new implementations continually popping out.

For example, there's a really nice standalone HTML5 app with slick interface called Copay, developed by Bitpay. There's also an online service BitGo (haven't tried this one though).


How does the Bitcoin payment forwarding at Blockchain.info work? We have been using the payment service provided by blockchain.info https://blockchain.info/api/api_receive

It allows us to generate a unique address for each payment and forward Bitcoins received by these addresses to a forwarding address. From what I understand, bc.info pays the transaction fee for the forwarding transaction for us.

We want to use our own wallet. I have two questions:

1) How does bc.info handle this cost? Am I missing something? Are they really paying 0.0001 BTc for each payment their clients receive?

2) Is there a way to forward payments without paying fees?

The fee for each transaction can be calculated using estimatefee API call. And yes, blockchain.info have to incorporate fee in every transaction, 0.0001 BTC being the minimum. One of the reasons attributed for the necessary fee deduction is the quick inclusion of the transaction in the next few blocks.
You can try creating a transaction with the outputs spending all of the inputs and not paying any tx fees. The client will throw an error stating insufficient priority.
Yes you can, but then are conditions apply. You can check out this link to clear things a bit more.


Does Bitcoin limit the number of parallel connections from the same IP? Is there a measure in place to prevent an adversary from connecting to a Bitcoin node many times in parallel, thus saturating its open connection slots?

The measure is that the node running bitcoin removes the cap to the number connection slots.  The cap for connection slots I have found is set to no limit when running a bitcoin service.

Sorry I stand corrected, back in 2011 looks like a cap of 125 connections was introduced Is there a connections limit on bitcoind?

in the net.cpp file  https://bitcointalk.org/index.php?topic=52772.msg629593#msg629593

but this has since been changed and I dont think there is a cap anymore... Looking at the file looks like this is the area you are interested in: https://github.com/bitcoin/bitcoin/blob/master/src/net.cpp#L1081
and the values set here https://github.com/bitcoin/bitcoin/blob/master/src/net.h


Do miners become temporary dictators of blocks they mined? This is something I've read here: https://blockgeeks.com/guides/bitcoin-forks-guide/

"When a group of miners discovers and mine a new block, they become temporary dictators of that block"

Can anyone elaborate on what it means exactly, please?

Does it really mean that those particular miners who mined the block can do whaterver they want with that block, like setting txs fees and putting txs? What about the other miners who didn't find that particular block? They become powerless until another block is mined?

Thanks in advance.

Can anyone elaborate on what it means exactly, please?

It just seems like a weird phrasing for saying that the miner has complete control over which transactions are included in the blocks they mine.

  Does it really mean that those particular miners who mined the block can do whaterver they want with that block, like setting txs fees and putting txs? What about the other miners who didn't find that particular block? They become powerless until another block is mined?

Miners can select which transactions they wish to include in the block they are mining. However, they cannot change the fee for a given transaction (except in certain uncommon signature types). In transactions using SIGHASH_ALL, the fee is implicitly signed into the tx since all inputs and outputs are signed, and if a miner attempts to alter the fee, they will invalidate the transaction, and thus the entire block. Pretty much every wallet I'm aware of uses SIGHASH_ALL.

A miner is powerless if they don't find a block simply because they cannot control what another miner picks for their block.

Note that after a miner mines a block, they can no longer change the contents of that block, as it would invalidate the proof of work.


Question regarding mining difficulty I understand that the Bitcoin mining problem is to find a string s (hash of previous block + transaction hashes + nonce) such that sha256(s) has n leading zeros, where n determines the mining difficulty.

The result of sha256(s) is a 64-length hexadecimal string. Each position of 64 has 36 possibilities (a-z, 0-9). So, the expected number of guesses would be 36^n.

The hash of block #485891 is

0000000000000000007ea3c67381ecfcf8e44e9941dcef554e8b029068857b55

which has 18 leading zeros. Thus, the expected number of guesses is

36^18 = 10314424798490535546171949056.

This hash was found by Antpool which has a hash power of 1284.32 PH/s. Therefore, the expected time for Antpool to find the hash would be

36^18 / (1284.32 * 10^15) = 8.03104*10^9 s = 255 years.

This time is obviously incorrect. Is there anything I missed out?

As you say, the result of sha256 is a hexadecimal string.  Hexadecimal only uses the digits 0-9 and a-f, which is 16 possibilities, not 36.

If you redo your calculation with 16^18 instead of 36^18, you get an average time of around 3600 seconds, or 1 hour.


Unable to bind any endpoint for RPC server I recently updated my bitcoin docker image to bitcoing v0.18.0 version and can't allow external rpc connections to it now. It binds to localhost if I set rpcallowip=X.X.X.X, then I tried to used rpcbind parameter also, but couldn't set my docker container to allow external rpc connetions.

This is what I get:

bitcoin_1       | 2019-05-23T13:39:34Z Bitcoin Core version v0.18.0 (release build)
bitcoin_1       | 2019-05-23T13:39:34Z Assuming ancestors of block 0000000000000000000f1c54590ee18d15ec70e68c8cd4cfbadb1b4f11697eee have valid signatures.
bitcoin_1       | 2019-05-23T13:39:34Z Setting nMinimumChainWork=0000000000000000000000000000000000000000051dc8b82f450202ecb3d471
bitcoin_1       | 2019-05-23T13:39:34Z Using the 'sse4(1way),sse41(4way),avx2(8way)' SHA256 implementation
bitcoin_1       | 2019-05-23T13:39:34Z Using RdSeed as additional entropy source
bitcoin_1       | 2019-05-23T13:39:34Z Using RdRand as an additional entropy source
bitcoin_1       | 2019-05-23T13:39:34Z Default data directory /root/.bitcoin
bitcoin_1       | 2019-05-23T13:39:34Z Using data directory /home/BTC
bitcoin_1       | 2019-05-23T13:39:34Z Config file: /home/BTC/bitcoin.conf
bitcoin_1       | 2019-05-23T13:39:34Z Using at most 125 automatic connections (1048576 file descriptors available)
bitcoin_1       | 2019-05-23T13:39:34Z Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements
bitcoin_1       | 2019-05-23T13:39:34Z Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements
bitcoin_1       | 2019-05-23T13:39:34Z Using 0 threads for script verification
bitcoin_1       | 2019-05-23T13:39:34Z Binding RPC on address X.X.X.X port XXXX failed.
bitcoin_1       | 2019-05-23T13:39:34Z Unable to bind any endpoint for RPC server
bitcoin_1       | 2019-05-23T13:39:34Z Error: Unable to start HTTP server. See debug log for details.
bitcoin_1       | Error: Unable to start HTTP server. See debug log for details.
bitcoin_1       | 2019-05-23T13:39:34Z Shutdown: In progress...
bitcoin_1       | 2019-05-23T13:39:34Z scheduler thread start
bitcoin_1       | 2019-05-23T13:39:34Z scheduler thread interrupt
bitcoin_1       | 2019-05-23T13:39:34Z Shutdown: done

My bitcoin.conf file looks like this:

server=1
rpcbind=X.X.X.X
rpcallowip=0.0.0.0/0
rpcport=XXXX
port=XXXX
rpcuser=user
rpcpassword=password

Here's how you fix the rpcbind issue with the latest change in version 0.18.0.

Before 0.18,  if you put rpcallowip=0.0.0.0/0, the value of rpcbind didn't need to be set as it defaulted to all interfaces.

Now that is no longer the case.  Here's my setup, for running bitcoind in a container through Docker compose:

rpcallowip=0.0.0.0/0
rpcbind=127.0.0.1
# local DNS name (container name used in my Docker Compose file)
rpcbind=bitcoind

The first rpcbind is so I can make RPC calls from inside the container.  The second is so other containers can reach the bitcoind container.

I think this does what you want:

I can RPC from inside the bitcoind container
I can RPC from another container on the same network (as specified in the compose file) to the bitcoind container
I can RPC from my localhost outside the container.

For the last, I exposed port 8332 to my localhost in the compose file and I can curl to the container:

$ curl --user user --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getbestblockhash", "params": [] }'  -H 'content-type: text/plain;' 127.0.0.1:8332/
Enter host password for user 'user':
{"result":"0000000000000000000ece9381a7e0a4020353f4adde7b560a6b2840d5d44cfa","error":null,"id":"curltest"}

The full details of my container setup are here, in case there's something I missed in writing up my answer.


Scrypt (Litecoin) memory / performance tradeoff For Litecoin, if memory size is increased in processing the Scrypt algorithm, for example to 384 kB instead of 128 kB (and assuming likewise an L2 cache size of 384 kB), would the typical CPU architecture (x86, PPC, etc) be likely to see a corresponding increase in performance?  And if increased memory size were used, would mining output remain 100% compatible with Litecoin (I believe the answer is yes, but also I note that almost all GPU miners are using fixed Scrypt parameters for N, r, and p).

I realize that increasing BlockMix memory sizee is not typically done on GPU architectures, for various reasons.  Also as a note my objective is not profitable Litecoin x86 CPU mining -- I just want to be sure I understand the  memory/performance tradeoff.

For Litecoin, if memory size is increased in processing the Scrypt
  algorithm, for example to 384 kB instead of 128 kB (...), would the typical CPU
  architecture (...) be likely to see a corresponding increase
  in performance?

No, it works the opposite. If you increase memory, which is used by the scrypt to generate a single hash, the time it takes to generate it, in theory, will increase. The time may not increase if the processing unit can fully use its fastest cash in a single data transfer call. However, you need standardised hardware and you would want to deliberately adjust scrypt memory size for it. Which is inconvenient on a global users scale.

Moreover, it's not up to you, personally, to decide the memory size of scrypt. This is a universal agreement of all litecoin users, that memory size of the scrypt algorithm has to be N bytes. If you want to use something else, any transaction you issue will never gets validated by any other users.


How to get transaction fee I have transaction id, how can I get a fee of this transaction from blockchain.info? For example I see that
this transaction https://blockchain.info/tx/https://blockchain.info/tx/963b9f407aabf8ebca660763bc5d3e8800eb6a5dffaf692cd061f0525ee770e1 has 0.00105453 BTC fee, but there is no such number in json data https://blockchain.info/tx/963b9f407aabf8ebca660763bc5d3e8800eb6a5dffaf692cd061f0525ee770e1?format=json

I'm new in bitcoin and I'm trying to write some scripts.
Thanks.

Sorry, I think I have found how to calculate transaction fee.
So we have to subtract sum of out values from inputs.prev_out.value.


Software for mining Quarkcoin on 32-bit Windows Is there a software for 32-bit Windows to mine Quarkcoins as part of a pool?

I think this is the right place where you can find the information bitcointalk


AML laws seem to be very erratically enforced It seems that only MtGox actually enforces them.  Are they now a PSP or bank?

MtGox says the reason they prohibit wallet-to-wallet bitcoin transfers (yes, they are prohibiting for unverified accounts now - even if you put your coins in there long ago) is because of the AML laws... yet, no other wallet site (that I know of or use) has this restriction, as they all allow me to transfer bitcoins to another address without the need to verification.

So, either MtGox is making up it's own AML rules, or none of the other sites, like Blockchain, for example, are following them.

Does any know what the real deal is with these AML laws?  it is all kept very secret.  In fact, the AML laws require that the exchange NOT notify the users in advance before the exchange put in place any new restrictions or limits...but only AFTER they are in place.

The real question is... where can I read the AML laws, specifically on how they apply to bitcoins? (although I still find it hard to believe they even Do apply for wallet-to-wallet transaction... but that is what I am told by MtGox)

Your question is almost meaningless unless you specify which country's AML laws you are interested in. Some potentially useful pointers:

US Federal Regulation 31, especially Part 1022 about Suspicious Activity Reports
German Gesetz zum Aufspüren von Gewinnen aus schweren Straftaten (Geldwäschegesetz), which translates roughly into Law towards Detection of Profits from serious Crimes (Money Laundering Law).

There is also the question of how to apply these laws. In the US, FinCEN's guidance on Bitcoin (FIN-2013-G001) has a statement that indicates FinCEN views bitcoin exchanges as Money Service Businesses (to which above FR 31, Part 1022 relates). I believe there are multiple interpretations of whether this would apply only where real currencies enter, or if the bitcoin side alone is enough to qualify.

Beyond all this is the practical, rather than legal necessity for customer identification. If an exchange allows anyone to do business on your exchange, you may attract the kind of illicit business that its bank's more elaborate AML procedures might flag as suspicious---which may be one explanation why bitcoin exchanges have, historically, run into trouble with their banks, often getting their accounts closed and having difficulty to find new banking. Dreaming of starting my own bitcoin exchange, I had decided I would need some identification due to these practical issues even before I learnt of legal AML requirements.

I do not think your premise that only MtGox requires identification is correct. I suspect all of their competitors do, even for only handling bitcoin. For their biggest competitor, Bitstamp, I am actually rather certain that they do. However, some of them may have been slower in adopting such measures, and indeed what exactly is required varies, both from country to country and from business to business as some of the anti-money laundering laws seems to require effective measures rather than prescribing anything in particular. A company with more data on their customers or more insight into how to second guess what of their behavior may be suspicious might get away with more selectively seeking information.

Finally, let me address the erratic enforcement you hinted at. Is there any chance you could supply more information about what that term describes in your mind, what led to the idea, etc.? I agree that, at least in the past when apparently no bitcoin exchange even tried to identify their clients, they would, in retrospect, appear to probably have been breaking some kind of legal AML requirement. However, this retrospective outlook is probably unfair and the wrong standard to apply; after all, bitcoin and the comparatively small market was hardly seen as "financial" back then. Law enforcement action, as we have seen in a few cases, naturally depend on police or other government agents becoming aware of the violation, and on a local prosecutor to decide that the specific case is worth pursuing. Whilst a standard involving no chance and no human element might seem best theoretically, I suppose that is not practically possible in our world, or at least not in our legal systems. So if you are talking about erratic actions by the authorities, then I suppose I can only point out that they must proceed on a case-by-case basis---to my own regret, considering I wish for a level playing field for all bitcoin exchanges.


If the same private key is used to sign different data with the same R (or equivalently k), the private key can be extracted. Since the transactions you linked have inputs from different addresses, there's no one private key that you can extract.
However, if you know the k value that caused this R value, which you would if you're the creator of at least one of these transactions, you should be able to extract the private key of the other by using the same method but skipping the derivation of k steps.


Buying Bitcoins using Guyana Dollars Does anyone know what is required to establish an exchange that accepts Guyana $ as payment for Bitcoins?

You need a bank account in Guyana for people to deposit money. Then you need a server to run the exchange. For the software you can check the answer to this question: Is there an open source Bitcoin exchange?

If you don't want to run you own server you can look at this: http://www.buttercoin.com/#/


Bitcoin scriptSig with two transactions to unlock the scriptPubKey For example, the bitcoin script of a scriptPubKey that consists of OP SUB < 100 > OP EQUAL, and is used to lock an output of a transaction. OP SUB pops the top two elements in the stacks, subtracts them, then pushes back the result. < X > pushes value X on the stack.
Also, the following, a scriptSig script that consists of < 200 >< 100 >, which is used as an unlocking script to spend that output.
In that case, will the scriptSig succeed to unlock the scriptPubKey thus allow the transaction to spend the money? Because of how Bitcoin combines the scripts and how it executes them, like what are the contents of the stack at each step of the execution?

You cannot put your plain script in scriptPubKey hence it's considered non-standard and will not be relayed/mined. You need to hash your custom script, put script hash in P2SH output, and reveal the script later when you spend it (in scriptSig).
Here's a step-by-step demonstration:
OP_SUB < 100 > OP_EQUAL

Convert your script to hexadecimal representation:

a. OP_SUB is encoded as 0x94 (in hex)

0x94

b. 100(dec) is encoded as 0x6400 (in little endian) plus one-byte length prefix

0x94026400

c. OP_EQUAL is encoded as 0x87 (in hex)

0x9402640087

Hash your script in order to get script hash:

RIPEMD160(SHA256(0x9402640087)) =
0xa038dd58be8e9c3bd9f26fe585dcdfe85d70ac4d

Your P2SH scriptPubKey is:

OP_HASH160 a038dd58be8e9c3bd9f26fe585dcdfe85d70ac4d OP_EQUAL

In order to spend/unlock this output your scriptSig should be:

< 200 > < 100 > < OP SUB < 100 > OP EQUAL >

In Hex:

0x02C800026400059402640087

Please note that arithmetic operations like OP_ADD and OP_SUB can only accept 32-bit integers, so if any input encountered longer than 4 bytes, the script must abort and fail.
Feel free to learn more about P2SH here


Checking if a receiver has enough coins How do miners verify the blockchain transaction history to check if the sender has enough money if the address can be changed at any time?

Bitcoin does not have the concept of account balance. Anyone who can provide a valid signature to the locking script of a particular transaction output can spend those bitcoins. As a result when you spend your bitcoins in a transaction, you have to include the transaction id and the output no. from which you earned those bitcoins. The nodes maintain a set of unspent transaction outputs (UTXOs) in the memory to check that this transaction output that has been referenced in the input has not been spent previously (this prevents double spending.)

If you want to send X BTC to a particular address, you will need to reference enough transactions in the input so that sum of all those unspent bitcoins >= X. This referenced transactions can come from different addresses. You just need to provide valid signature with your private key to show that you are the owner of those bitcoins.


Are there any blockchain inspection tools/libraries? I am going to write software that gets information from the blockchain directly.

Are there any tools or libraries to speed up that process? I am looking for things like decoding and encoding transactions, verifying signatures, scanning for certain data etc.

Preferred languages: Python or C/C++.

You probably make the right decision to not use one of the centralized API (blockchain.com, etc.).
Run you own bitcoin-core fullnode(s) and connect to the RPC or REST interface.

You could connect via python with things like http://laanwj.github.io/bitcoin-python/doc/examples.html or any other RPC client.

If you need blocks / headers / chaininfos and transactions, consider enabling bitcoind -txindex and access data over the REST API (https://github.com/bitcoin/bitcoin/blob/master/doc/REST-interface.md).

If you need to verify scripts, you could use libbitcoinconsensus. There is a verify function:

EXPORT_SYMBOL int bitcoinconsensus_verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen,
                                    const unsigned char *txTo        , unsigned int txToLen,
                                    unsigned int nIn, unsigned int flags, bitcoinconsensus_error* err);

Bitpays insight is also a nice library (https://github.com/bitpay/insight) but it's javascript node.js based.


Wallet as daemon, what's the security-concern about "rpcallowip"? When running (btc-/ltc-/whatever) wallet as daemon, I have to set "rpcuser" and "rpcpassword".

There is the option "rpcallowip", it is recommended to have this value very strict, e.g. "127.0.0.1".

I cannot see any danger setting this value to "..*.*" - if anyone guesses my server and credentials, he/she is welcome to mine for my wallet.

So, is there any danger opening rpcallowip?

if anyone guesses my server and credentials, he/she is welcome to mine
  for my wallet.

He/she can also call all other RPC commands. For example, sendtoaddress. So, if your wallet is unlocked you can loose your coins.


Chainstate database for download Is it possible to download a recent snapshot of the chainstate database?

I'm running bitcoind (v. 0.11.8) on a machine with ~1mb/s download speed. After my client reached 300000 blocks, the synchronization is going insanely slow. I suspect it's because verification is very slow. The bitcoind processs is using nearly 100% CPU. However, for my purposes I only need a reasonably recent (i.e., up to 30 days old) chainstate database.

A 30 days old chainstate database does not make sense. Either you have the chainstate completely, and are able to do full validation, or you don't, and you can't validate at all. There is no middle ground of only validating recent transactions, as any transaction you encounter with unknown inputs could either be fraudulent or created more than 30 days ago, and you'll have no way to tell without a full chainstate.

So, either you don't need full validation, and you can use a number of lightweight clients instead, or you do, and you'll either need to build the chainstate yourself by synchronizing history, or copying from a source you trust.

Please don't go download a chainstate from a random place on the Internet though. They can introduce arbitrarily many coins assigned to themselves, and your client would accept them. If many people started running nodes using the same chainstate 'copy' such transactions could even get into blocks, and cause forks in the best case, and theft in the worst case.


In order to reduce fees, can I 'consolidate' my wallet by sending the entire balance to a new address in the same wallet? My balance is currently made up of lots of small amounts
I know I'm not going to be using my bitcoin wallet for a while, so I don't care if the consolidation transaction is slow.

Would creating this transaction with no(or relatively low) fee achieve the aim of making subsequent transactions smaller and therefore less likely to attract higher fees in order to go through quickly?

Assuming this sort of 'consolidation' even works..
What would happen if a wallet program had a feature that allowed people to automatically 'consolidate' overnight depending on the makeup of the wallet's balance? Might it have a negative effect on the network?

It depends which of two cases you are in:

If you have lots of decently-sized transactions to 'gather', it will likely have the reverse of the effect you want. Right now, you probably have lots of old transaction outputs that your future transactions can claim. That means you can form many transactions that use only old outputs, and thus get a higher base priority. If you consolidate your coins, you will have only one transaction output to claim. So in the future, you will only be able to create one high-priority transaction. Once you do that, you will have no more old coins.

But if you have lots of absurdly-small transactions to 'gather', it will likely help you. By not having to gather lots of small transaction outputs together in the future, your future transactions won't be as large and therefore won't require as high a fee (or as large a wait).


Bitcoind uses only ~1.5% CPU for RPC command "getnewaddress" I'm running bitcoind and generate a bunch of bitcoin addresses. I use a PHP script and an Apache2 server to make calls to the RPC API.

bitcoind uses ~ 0.7%-2.2% of the CPU and writes ~3 MB/s on the SSD.
Apache2 uses ~0.3% of the CPU.

I set -rpcthreads to 8 but that didn't do anything for me.

Where is the bottleneck?
Is there a way to speed the hole process up?

I know that vanitygen can create a lot of addresses but then I would need another step to add them all to a wallet therefor I would prefer using bitcoind. bitcoin-qt is just awful slow at the same task with RPC commands.

This is a known problem in the wallet code.

Whenever a new address is retrieved from the key pool, a new key is also generated to replenish the key pool. When this happens, we try to make sure this new key is safely on disk, so we flush the wallet file to disk. Due to probably overly aggressive flushing, this results in large writes to disk in BDB.


How to calculate Hashes per Second How exactly do you calculate how many hashes your hardware is generating?

Most mining software will have that number available for you.  Or you can join a pool for a day or two and most of the bigger ones (eg slush, 50btc) make these stats available for your miner(s).

If you are trying to programmatically calculate this for software you are writing probably best to take an average every minute or so. As in most cases, the formula is built right into the unit -- num of hashes per (ie divided by) num of seconds.

Actually it's Mh/s (1,000,000 hash/sec) usually now so more like (Num hashes / 1,000,000) / sec


How can i set up CPU mining on bfgminer? I just downloaded Bitcoin Core and BFGminer on linux and I would like to start CPU mining just to see how it works, maybe later I'll buy ASIC. So, how can I configure CPU mining on BFGminer?

You can run a miner on a CPU, you just won't generate any measurable revenue. But as an experiment, it's certainly possible to do. I run cgminer on a CPU as an integration test for one of my node.js modules.

This is a rough outline of the steps you can go through to install an older, CPU-supported version of cgminer on your computer: https://github.com/hashware/node-cgminer-api/blob/master/.travis.yml#L11-L24


How can you make sure that there will be routes with large enough balances to handle transactions? I'm creating a "Megathread" regarding the Lightning Network and have been fielding questions. To help obtain the correct answers with sources, I'm reaching out to the Bitcoin StackExchange.

I was asked to make a separate post for each question.

Thank you in advance for helping the community understand more about this great technology.

This is not so easy. Infact it seems almost impossible to be done in an elegant way. While the capacity of public channels is known to everyone on the network the balance of each channel is unknown.

As nodes sharing their balance is

a privacy issue,
technically in a peer-to-peer network difficult as the channel state / balance might change several times per second and gossip protocol propagation takes longer and
Hard to proof validity of a published the channel Ballance

We usually don't know the balance.

Thus a Sender could just use try and error which is particularly inefficient in large networks as the number of paths grows quite quickly.

In practice node operators could use "manipulated onions" to probe nodes for a current minimal channel balance. Which obviously is also difficult as the balance might change quickly.

In precise people work on AMP routing which means doing several small payments (maybe even over several paths) instead of a large one or JIT routing which allows nodes along a path to rebalance their channels if they don't have enough balance to forward the onion. (disclaimer I proposed JIT routing and it is not clear yet if it becomes a lightning standard)

On a Side note :maybe you want to add my youtube channel with lightning educating to your mega thread (which in the past helped me a lot! Thanks!)


Is it possible to create private multi-signature transactions? Since ZCash is based on the bitcoin core it is also enabled to create multi-signature transactions by default.

ZCash now adds the possibility to create also private transactions.

But how to create private multi-signature transactions? Is it even possible?

Currently Private multisignature transactions are not supported. However, multisignature transactions are possible without the privacy.
It is possible to do a private Zcash spend to yourself, then do a globally transparent transaction (which could be a multi-signature transaction), and then the new holder of the funds (possibly you or possibly someone else) does another private Zcash spend to themselves.


Calculating the current price of 1 BTC? I am planning to get into BTC as I have some PC with xfire (7970's) laying around here and I am currently trying to learn more about it; what I would like to first understand is BTC pricing to make sure the energy I will spend with this PC can be paid off with it.

At https://mtgox.com/ the last price is at USD$249.99900: is that the current value of 1 BTC? If not, how is that calculated in order to know how 1 BTC is worth?

Market price is market price, which is what people are willing to pay for it.  You can pick any market out there (mtgox, bitstamp, etc).  No different to the price of gold, if you wish.

Although an average price across multiple exchanges might be useful in a theoretical sense, the reality is that when you come to sell you will sell in a single exchange at a single price.  Added to that the exchange rate of BTCxUSD is fluctuating so rapidly right now that attempting to use it to calculate what you might obtain even a week from now is probably not a sound basis on which to generate a financial calculation.

If you want to work out if mining for coins is worth it, then the general answer is "no".  A more detailed answer can be found by using a mining calculator

Until now, it has has always been the case that purchasing bitcoins is a wiser way of spending your money than putting it in to hardware or even power to generate your own.  Unless you're buying an ASIC-based miner I would suggest that this is the best way to approach bitcoins right now.


Is there a working Open source implementation of litecoin mining application for Linux without GUI Is there a working Open source implementation of litecoin mining application for Linux flavours without GUIs (think debian, ubuntu server etc.)

I found a couple of implementations by developers but all of them are closed source.

cgminer should work, it is open source, cross platform miner for bitcoins and litecoins (--scrypt key  used for scrypt based coins like litecoin.)


Will Bitcoin copy Best Features of Litecoin, Ripple, if its Open Source? Proponents of Bitcoin always mention that Bitcoin is Open Source, so if any better cryptocurrency comes along, Bitcoin can just copy those features in their open source.
Both Litecoin and Ripple have faster transaction speeds and more transaction capacity.
So why hasn't Bitcoin just copied those features, to improve itself?
We already know Bitcoin has current feature pull requests, and many of the nodes are agreeing to the changes. So why can't they upgrade speed/and capacity immediately?
Who approves the feature and bug code reviews in Bitcoin?
https://github.com/bitcoin/bitcoin/tree/4405b78d6059e536c36974088a8ed4d9f0f29898

Proponents of Bitcoin always mention that Bitcoin is Open Source, so if any better cryptocurrency comes along, Bitcoin can just copy those features in their open source.

Bitcoin can of course adapt to whatever its community agrees to. This isn't so much a result of the fact that it is open source, but of the fact that its use is entirely opt-in: it works because people want to use it with the properties it has. Any group at any point can decide to create their own modified network/software, possibly creating their own coin in the process. This has happened in the past, but only with very limited success.

Both Litecoin and Ripple have faster transaction speeds and more transaction capacity.

They do, but those come with significant costs too. Litecoin is fairly similar to Bitcoin, but has higher upper bounds on certain resource costs like bandwidth usage, processing time for nodes, block propagation guarantees... all metrics that influence how realistic it is to keep Bitcoin's full node network decentralized. Ripple is a completely different design that relies on wildly different security assumptions.
Note that I'm not trying to say the different choices those systems make are necessarily bad - they're just different trade-offs, and those are things to be decided by the network's ecosystem. It is highly unlikely you'll convince a sufficiently large and important subset of the ecosystem that such changes are desirable. Sure, some people will feel they are - but others won't, and unless it is clearly better in (almost) all regards, the Bitcoin ecosystem will likely prefer being conservative about such choices as it has been in the past.

So why hasn't Bitcoin just copied those features, to improve itself?

TL;DR: because not everyone considers those changes to be improvements, when taking the costs into account.


How is Simplicity better suited for static analysis compared to script? Quoted from the whitepaper, one of the design goals of Simplicity is:

  Provide  formal  semantics  that  facilitate  easy  reasoning  about  programs using existing off-the-shelf proof-assistant software.

How does Simplicity achieve being more static-analysis-friendly than script? Is it the read-write order in the bit machine?

For this answer, I will mainly focus on static analysis of computation resources such as memory use and time.

In Simplicity, we have a separation between the Simplicity language and the language of the Bit Machine with a formal translation from the Simplicity language to the Bit Machine language (see Figure 2 from the whitepaper).  This translation has been formalized in the Coq proof assistant. Only the Simplicity language is exposed at the blockchain's consensus layer with the Bit Machine technically being an implementation detail.  This means that only the Simplicity language needs to be analyzed.

Because Simplicity subexpressions can only manipulate their local data (i.e. from the point of view of the Bit Machine implementation, Simplicity subexpressions can only manipulate the top of the read and write stacks), we can write a simple recursive analysis to determine computation costs such as memory use (see Figure 3 and Figure 5 from the whitepaper) and similarly for time resources (not yet implemented).  Furthermore, the Simplicity combinators are extraordinarily simple, which makes the static analysis practical.  One form of the memory static analysis algorithm is already verified correct with the Coq proof assistant.

On the other hand, Script comes with a few wrinkles that can impede static analysis.  In particular DEPTH is non-local (i.e. it isn't a simple function of a fixed number of stack elements), and IFDUP leaves one or two items on the stack depending on the runtime value of the top stack item.  Nothing in Script guarantees that when exiting an IF ENDIF block that the number of stack items left would be identical in either case (compared this with Simplicity's case combinator that requires the resulting type of the two branches to be identical).  And lastly while ROLL, PICK, and CHECKMULTISIG are usually used with a constant n (and m) parameters, nothing guarantees this is the case.

All this makes static analysis of memory use that much more complicated to do for a generic Script program, though for specific normal Script programs that do not use/abuse the above OP codes, analysis is probably feasible.

The story for time analysis is a bit better since Script just iterates through the code.  Though ROLL is  problematic since it requires O(n) work.  (Recently the implementation of IF was repaired so that it now only requires O(1) work).  Simplicity combinators only require constant amount of time each, with the exception of iden, which copies a statically known number of bits when implemented in the Bit Machine.  Because the amount of work for iden is known statically, we can incorporate that into our analysis.

Simplicity aims to make static analysis of computation resources easier than for Script while at the same time increasing the practical expressiveness of the language.

For reference, the SCRIPT Analyser that I am aware of makes simplifying assumptions about Script operations (e.g. that values passed to OP_IF are either 0 or 1).  On the other hand, the SCRIPT Analyser does a full symbolic analysis rather than time and space resource analysis.  Such a symbolic analysis probably isn't practical for Simplicity programs. Instead one is expected to use the formal semantics of Simplicity to directly reason about Simplicity expressions (for example we have a proof of correctness of the SHA-256 implementation in Simplicity).


Can anyone without knowledge of encrypted tech use bitcoin? I am interested in registering online, however I haven't got any knowledge on encrypted language not even on software design or whatever it is called.  Is it possible for a person like me to register and enjoy the benefits from bitcoin that surely will become the currency of our modern generation:)

If you just want to use Bitcoin, it is no harder than using a credit card or online-banking. I suggest reading up on some safety best-practices in order to protect your funds, and to use two-factor authentication.

We have put together a collection of frequent questions new users ask. It is to be found here: I am new to Bitcoin, how can I get started?.
It is essentially a bunch of pointers to yet other questions, but should help you find answers to questions that you are concerned with now. Don't worry, you don't have to read all of them at one time or even at all.

If you want to understand how Bitcoin works under the hood, it is more complicated. However, when you think about it, so are credit cards and online-banking. ;)


Bitcoin-qt and lost local blockchain files For some reason I've lost all data in my .bitcoin directory except the wallet.dat file. Now bitcoin-qt shows 0 balance, and it's 5 years behind sync. Is this possible to restore coins in this case?

If the blockchain files are gone, then your Bitcoin client has no way to match up the keys in your wallet with the transactions in the blockchain. Remember the balance is not stored in the wallet, but the keys in the wallet can be matched with transactions in the blockchain to calculate your balance.

Fortunately, the blockchain files are public and the same for everybody so you now just have to wait for them to download. It may take quite some time (days or more). You could try downloading a torrent of the blockchain to speed up the process, but this is optional.


Why not issue all the Bitcoins at once What is the point of mining the Bitcoin and thus issuing new Bitcoins over the span of some time versus simply issuing all 21 million coins at once?

In a way, all bitcoins were issued with the genesis block: The total number was fixed and the distribution schedule defined with the rules put in place then. However, distributing them over a longer period of time allows for the bitcoins to be spread out more, creates incentives for miners to contribute work to the Bitcoin network and probably also helped fewer of them getting lost during the emergence of Bitcoin when many people just tried it briefly and likely didn't properly store their coins.


What will happen when the last bitcoin will be find I have read there is a mathematical limitation of bitcoin count.
What will happen when a miner will find the last bitcoin ? I have read nobody will do mining anymore.
But, we will need miners in order to compute proof of work of transactions ?
They will earn bitcoin with transaction fees ? So mining won't stop ?

Thanks

The Mining process uses the proof-of-work algorithm to generate new bitcoins and protect the network from attack by attackers, such as the publication of an invalid block or the modification of a transaction within a block. .
Bitcoin performs the validation of transactions on average every 10 minutes and they are considered "valid" only when the block containing them is appended to the official chain; each transaction can include within it a bitcoin value which is equivalent to a fee addressed to the miner for reward of the work done, which can choose to give precedence to transactions with a higher commission than a quantity of bitcoins of their choice.
Bitcoin establishes a process of creating a new decreasing and limited currency, in fact it imposes a maximum upper limit of twenty-one thousand bitcoins; the value created by the miners halves every 210,000 blocks, on average every 4 years.
The creation of bitcoin began with an amount equal to 50 bitcoins per block in January 2009 and halved to 25 bitcoins in November 2012 thus estimating the complete issuance of all the bitcoins available in 2140; at the end of the issue, the gain of each miner will be exclusively the value of the commission.

So, the mining will not stop, only the miner's gain will decrease (it is not said because there could be many transactions)


How can a Ripple contract use random values and reach consensus? There an interesting page about contracts on the Ripple Wiki.

My limited understanding of contracts is that like other transactions in Ripple, it is the consensus across many servers that ensures validity.  Am I right that when a contract is running in Ripple, the code runs on multiple servers and consensus ensures the contract's instructions are run correctly?

If so, I'm particularly curious about the "Lotto" example on the wiki page.  It chooses one account randomly to be paid some amount of some currency.

If that code ran simultaneously on many Ripple servers, they'd each randomly choose a different winner.  How would they ever achieve consensus?

That contaracts wiki page may be out-of-date.
However, the loto example uses rand float which in the data access section of the wiki page is described as:

  this number is deterministically created based on the hash of the collection of transactions or something

That implies to me that it's random only in the sense that the contract itself, or any Ripple user, cannot guess what the value will be at run time, but once running all validators will use the same value.

This is similar to how some Bitcoin gambling sites work, using numbers based off the Bitcoin blockchain hash.


What is the "1 RETURN" bug? From Nathaniel Popper's “Digital Gold : Bitcoin and the Inside Story of the Misfits and Millionaires Trying to Reinvent Money", this heavily edited (by me, for clarity) excerpt:

  “In late July Gavin and Satoshi got an e-mail from ...a programmer
  from Germany going by the screen name ArtForz, ... had found a
  previously undiscovered weakness in the code that ...made it possible
  to spend Bitcoins in someone else’s wallet.”

  “For now, don’t call it the ‘1 RETURN’ bug to anyone who doesn’t
  already know about it,” Satoshi wrote to Gavin.”

What is this 1 RETURN bug? It's obviously been patched, but I'm interested because the book doesn't delve into technical details.

(FWIW, I highly recommend buying this book).

Have a look at the early sources here: http://www.bitcointrading.com/forum/bitcoin-clients/original-bitcoin-source-code-archives/

there is a small piece of code in script.cpp:

    case OP_RETURN:
    {
        pc = pend;
    }
    break;

which allows to spend ANY UTXO with just a very simple scriptSig OP_1 OP_RETURN


Transaction stuck because of "Dust"? been waiting 8 days for this transaction because Bitcoincore couldn't be arsed working out the network fees.  Not a big transaction, but has caused a lot of grief because recipient now thinks I'm dishonest, even though I sent again from an online wallet which went through !!

if anyone can help the transaction ID is
7fb10192748c0cea3d441a98789086d9905c6d83de11bc19b716b4be6ade5c04

I don't even mind if it is confirmed and sent to original vendor as, at least, my reputation will be restored

Thanks in advance

You used a fee-rate of 6 sat/B. Even though fees have dropped drastically over the week, that's about factor ten too little to confirm. Additionally, one of your outputs will cost its own value to spend at 3 sat/B. Even at today's exchange rate it's only worth about 1.5¢, you should try to avoid creating outputs that small as they're unspendable burnt money. That's the output that triggered the dust categorization.


How does the Lightning Network stop flooding nodes (DDoS) with micro transactions? Is this even an issue? I'm creating a "Megathread" regarding the Lightning Network and have been fielding questions. To help obtain the correct answers with sources, I'm reaching out to the Bitcoin StackExchange.

Thank you in advance for helping the community understand more about this great technology.

As of right now, Lightening Network suffers from the same flaw that allows mempool spamming in the Bitcoin network (making tons of incredibly small transactions with normal fees), and therefor if there are a large number of microtransactions, will suffer from the same flaw.

  All channel updates are broadcast to everyone. How badly that will suck depends on how fast updates happen, but it's likely to get painful somewhere between 10,000 and 1,000,000 channels.

It is important to note that the mempool attack works by creating an artificial demand for space in a networks mempool. The transaction fee is average or above average, but there is little to no output. This attack works because it forces real transactions to pay higher fees.

However in LN the problem is different. It is more a question of what the network bandwidth can handle. This is not to say the issue is not fixable, the LN Developer listed in the source goes on to say that this system is not optimized. A possible solution would be for the seller to only send the preimage (for more information on how LN transactions hop through the network) to the those who have created an HTLC with the seller and to pass the preimage along the chain of debt until it reaches the payee.

Source: RustyReddit, RustyReddit


How do I get a bitcoin address? I don't know how to get a bitcoin or cryptocurrency wallet address.

Can anyone help me with that information?

Generally speaking you would want to download a bitcoin wallet application (desktop, server, or mobile app) and use that (usually there is a "receive" button, or similar depending on the type of wallet, and that will show a new receiving address).

There are ways to generate an address without a wallet, like using a site like https://www.bitaddress.org ,however, I don't recommend that unless you know what you are doing.

Here is a list of some different bitcoin wallet applications: https://bitcoin.org/en/choose-your-wallet


What does the `gen` option in bitcoin.conf do? The gen option isnt copiously described in the sample bitcoin.conf file  ... does that mean that the daemon started up will attempt to mine for coins?

That configuration parameter no longer has any effect because the CPU mining engine has been removed from the mainline client.

Earlier versions of the client did have a built in miner and the gen parameter controlled if it ran in the background.  Given the much higher difficulty today the developers felt it no longer served a purpose and would be confusing to new users (who could wait months of even years without generating a single coin).  It was removed from the client.  The wiki should be updated to reflect that.


What does the IRS tax in terms of bitcoin practices What of the following do I put on the tax form that I got money from a website for viewing ads, donating money, turning gift cards into bitcoin, buying gold, putting money into a bitcoin savings acount, buying miningsweden mining shares, or handing money to a scammer?
By the way I did not buy any bitcoins from an exchange.

They tax the exact same things as if you'd done those things in Thai Baht, or Nigerian Dollars, or British Pounds. If you view ads, that's income. If you buy gold, and it appreciates, that's capital gains. If you buy a mining contract, the income minus depreciation is capital gains.


Is it possible to get bitcoin-cli without having to build all bitcoin source? I'd like to use the bitcoin client to examine some of the inner workings of bitcoin-qt (non-invasively, using gets and lists mostly). Is it possible to do this alongside the standard executable? I don't really want to download and build everything from source.

Yes. Go to Bitcoin-Qt -> Help -> Debug Window.

Help -> Command Line Options gives a list of all options.


How to make cryptocurrency easier for law enforcement? I am researching the topic of cryptocurrency and its impact on society.

It's often said that cryptocurrency is equivalent to cash, but that is clearly not true since cash is very difficult to transport in large quantities over borders and usually requires physical presence to conduct a trade. It is also said that Bitcoin is not anonymous since the transactions can be tracked. However, in reality, its pseudo-anonymity can easily translate to true anonymity when a good laundry service is employed. Thus, cryptocurrency can and does open new avenues for criminals, such as making it much easier to transport and launder the proceeds of crime, facilitating bribery and blackmail by reducing their risks, and many of the bad things cash is associated with since money has always been a central element in crime.

Regardless of what you think of this from a political point of view (and I expect that many in this community don't see a problem with it), I think there is an interesting technical question here:

Is it possible to design a cryptocurrency that achieves a compromise between the relatively strong pseudo-anonymity of Bitcoin and the classic banking system that is disastrous to personal privacy?

Ideally, we should design a system that keeps as much as possible of Bitcoin's strong privacy protection and other desirable features such as decentralization, but at the same time, allows law enforcement to track anti-social actors like the classic banking system allows.

So, I'm asking for ideas of about how to get the best of both worlds. The network should work in a high privacy mode by default, and when the need arises, law enforcement should be able to reduce the privacy in a very visible way, for example by requesting the collaboration of other users. There should be no backdoor, no way to deanonymize the whole network in a surreptitious way like the NSA is doing by tapping all SWIFT traffic.
Therefore, the definition of "law enforcement" is not a magic attribute or key stored by the network, rather it's implicit: the party who can convince nodes to collaborate to deanonymize other nodes.

Additionally, it would be desirable to prevent anonymous laundry services while keeping the network open to join like Bitcoin, without the classic KYC routine of banks. This seems like a contradiction (Sybil attack) but maybe some compromise exists, so your thoughts are much appreciated.

It is possible to mitigate criminal elements in existing cryptocurrency networks within the current regulation framework.

Addresses of results of criminal actions are well known. Think stolen Bitstamp funds. Eventually these are written to police reports somewhere.
Exchanges, and other respected corporations, should act as a gatekeepers in this community off their own interest. Authorities of financial institutions have a duty to report crime (Misprision of felony).
If any exchange process transaction that has gone through a blacklisted address, the transaction should be stopped and the actor should go through anti-money laundering process, because they have somehow got criminal assets in their hands. There should be a paper trail to follow. If exchanges do not do this then they should be themselves subject to money laundering investigation due to breaking local AML and KYC regulation.
Tracking back Bitcoin transactions to blacklisted addresses is technically very feasible, because all transactions are public and it is just matter of maintaining a tree of transactions in computer memory. It doesn't matter how many times you tumble your coins, because you simply can't eliminate the trace of transactions from blockchain.
This assumes there is a party (Interpol, FBI) who maintains and enforces a known black list of addresses. The list should be publicly available for anybody. The list contains addresses compiled from police reports world wide. Currently no no such party exist. All parties in global trusted police consortium should be able to add addresses on this list with reference back to a local police report.
Fungibility, as promoted by some Bitcoin advocates, does not exist. You simply can't say "I don't know where my money is coming from." to government officials. Banks and financial institutions like PayPal are already subject to this regulation.

This way the system would be opaque to every day transactions (think a transaction of hiring divorce lawyer, medical bills) but still having a mechanism to track down criminals.


How does the Litecoin difficulty get calculated? Bitcoin creates 2016 blocks, and if the average time of 2016 blocks is less than 10 minutes, the difficulty increases. If it is more than 10 minutes, the difficulty decreases.

How does the Litecoin mining difficulty get adjusted?

Litecoin is a fork of Bitcoin Core, and uses the same difficulty adjustment period (2016 blocks), which on Litecoin is 3.5 days because the block time is 2.5 minutes instead of 10.  See chainparams.cppL#85:

consensus.nPowTargetTimespan = 3.5 * 24 * 60 * 60; // 3.5 days
consensus.nPowTargetSpacing = 2.5 * 60;


Electrum iOS alternative that can create multisig wallet with other Electrum wallets? I want to create a multisig Electrum wallet with two signers: my desktop and my mobile. Since Electrum is not on iOS and I really want to keep using it on my desktop, is there an alternative available for iOS that is able to create multisig wallets together with Electrum?

Copay has multi sig options. First, it will generate you a regular wallet. After initial process is done, you can create new shared (multi sig) wallet or join the existing one.


If i have 42 tera hashes of mining power, how long will it take me to mine a block solo, and if i join a mining pool, how much bitcoin will I get? If i have 42 tera hashes of mining power, how long will it take me to mine a block solo, and if i join a mining pool, how much bitcoin will I get? I am intrested in buying 4 Bitmain Antminer T9+.

At the time of writing, less power costs, and assuming no change in difficulty:

it would take on average 50 years, 21 weeks to generate a block.
it would produce on average 0.000678 BTC per day, or about $6.70.


Running out of disk space with Bitcoin Core A year ago I purchased some bitcoins and it was sent to my address. I loaded up Bitcoin Core and installed it to my laptop HD, it ran out of space on the HD, mid blockchain sync. It has now been a year. I have confirmation that the coins have been sent to the address and they are there, what can I do?

How are you? WOW guessing you're rich now!
The proof you have bitcoin in your wallet does nothing. Bitcoin is not a system you can go and get your wallet back with showing them you have bitcoin in your wallet.
Go to blockchain.info and download the app. Click on add address. Scan your private key and then you can use your bitcoins again.
Hope you can gain access to your wallet.


How do wallet developers earn money? Does anyone know how the Bitcoin wallet developers earn money?

Do they live on only donations? Is it possible to survive on only donations?

Why would they develop wallets if they don't make any profit from it? :)

You should know that lots of things in life come for free. Specifically when it comes to software, lots of professional developers would rather develop things "their own way" for free, instead of getting paid and "being forced to do it". Most open source developers also simply enjoy the act of creating things. They're engineers and scientists that care more about people using their inventions, rather than an economical compensation.

However, as you say, at the end of the day developers have to eat and pay the bills too. If I remember correctly the MultiBit developers will add an option to automatically send a portion of the fees you use for transactions towards themselves. However, I've read this news on some blogs and not directly from the MultiBit developers: http://www.coindesk.com/cash-strapped-multibit-developers-charge-transaction-fee/

But at the end of the day, if you're a developer of a famous bitcoin wallet, you'll have no problems finding a job to earn some money. So money isn't really an issue for most of open source developers. I'd argue that money would actually poison the open source philosophy. You're more in it for the act of creating, for the reputation and fame, for the feeling of doing something nobody has ever done before.


Transaction propagation criteria vs mempool inclusion cirteria Do Bitcoin nodes propagate every transaction or only transactions that meet certain criteria? For instance, a transaction with a fee of 0 won't necessarily get included into a block and it might even be excluded from a node's mempool but would that transaction still get propagated throughout the entire network? Or can node choose not to propagate certain transactions?

If there is some criteria to which transactions get propagated what are they? I am guessing at the very least that nodes won't propagate invalid transactions?

There are also the 'standardness rules', which are separate from 'validity rules'. So this means a transaction can be either valid and standard, valid but non-standard, or invalid.

A node can choose to broadcast any transaction it would like to the network, or none at all.

If a node broadcasts invalid transactions, then it is likely that its peers will disconnect, due to misbehaviour. An invalid transaction cannot possibly be included in a valid block.

The bitcoin-core core code does not relay non-standard transactions, but it will still accept blocks that include them (since they are still valid). This lack of relaying the non-standard transactions is a safety measure to prevent DoS attacks, etc. You can find some good info about issues with relaying non-standard transactions here.

Even for standard transactions, there is no stipulation that requires a node to relay them through the network. Many nodes will do so, but this is entirely up to that specific node's policy.


BIP32 HD Wallets: HMAC vs. "just" Hashing the Seed In A. Antonopoulus' Mastering Bitcoin (2nd edition) on page 106, there is a nice illustration showing how the basis for a BIP32 HD Wallet is generated:

So here is the one thing I don't understand about it:

In the middle of the picture there is the part where the seed is HMACed and stretched to 512 bits. Why is there a HMAC needed instead of just simply taking a hash of the seed (SHA512)?

As far as I understand, the difference between a hash and an HMAC is that the HMAC delivers some sort of non-repudiation namely that only the ones who are able to create a valid HMAC are the ones knowing a specific key (so kind of like a signature). This feature however is useless in the given use case.

So why HMAC-SHA512 instead of SHA512? Is the idea to artificially increase the workload needed for the generation of a HD Wallet to limit the possibilites of a brute-force attack?

I found this answer by David Schwartz under the cryptography tags in stackexchange, it may answer your question: HMAC . It basically states that HMAC is smaller in size and takes less CPU to compute.


Can't connect to rpc.blockchain.info with bitcoin-cli I'm trying to, given a bitcoin address, retrieve the last X transactions to this address. After researches, I found this to be an interesting solution, as I don't want to download and validate the entire blockchain for this simple purpose.

On my Windows 10 machine, I downloaded bitcoin-core and tried to send a getinfo (I didn't execute bitcoin-qt as I don't want it to start syncing with the blockchain) :

./bitcoin-cli -rpcconnect=rpc.blockchain.info -rpcport=80 -rpcuser=my_id -rpcpassword=my_password getinfo

I got an error message complaining about bitcoin.conf and credentials (indeed, there was no bitcoin.conf file in %APPDATA%\Roaming\Bitcoin\)

So I created a bitcoin.conf file :

server=1
rpcuser=my_id
rpcpassword=my_password
rpcport=80
rpcconnect=rpc.blockchain.info
#rpcssl=1        #SSL mode for RPC is no longer supported

However, I get this error (bitcoin-cli has been allowed to access the web in Windows Firewall) :

error: couldn't connect to server: EOF reached (code 1)
(make sure server is running and you are connecting to the correct RPC port)

Has the service been discontinued ? Or is there a problem with my configuration ?

It appears this service is no longer available per other discussions (and a failed ping of rpc.blockchain.info).

An alternative would be to use the address query on blockchain.info's api:

https://blockchain.info/rawaddr/$bitcoin_address

Example

Single Address

https://blockchain.info/rawaddr/1AJbsFZ64EpEfS5UAjAfcUG8pH8Jn3rn1F

Address can be base58 or hash160

Optional limit parameter to show n transactions e.g. &limit=50 (Default: 50, Max: 50)
Optional offset parameter to skip the first n transactions e.g. &offset=100 (Page 2 for limit 50)

{
    "hash160":"660d4ef3a743e3e696ad990364e555c271ad504b",
    "address":"1AJbsFZ64EpEfS5UAjAfcUG8pH8Jn3rn1F",
    "n_tx":17,
    "n_unredeemed":2,
    "total_received":1031350000,
    "total_sent":931250000,
    "final_balance":100100000,
    "txs":[--Array of Transactions--]
}


What happens if the developers make a controversial change to the "standard" client? One criticism I commonly hear of Bitcoin is that it merely transfers trust from some sort of central bank or government entity to the developers of the main project.  Can anyone provide a clean summary of what would happen (technically speaking) if a large majority, small majority, large minority, or small minority of Bitcoin users opposed a backwords-incompatible change to the protocol via the standard client?  And does this "power to dissent" lie disproportionately with miners, and/or with major economic players like businesses and exchanges?

The power to dissent over changes that causes existing clients to reject a block does lie disproportionately with miners. Any change that causes existing clients to consider a block invalid is useless until the majority of miners update.

Miners who consider the block invalid will never attempt to build on a chain that includes any such blocks. So until a majority of miners upgrade, the longest chain will never stably contain a block requiring the update.

Once the majority of miners have updated, those running clients will pretty much have to update. Otherwise, they'll be stuck on a shorter block chain that won't agree with the more secure block chain.

The change would have to be pretty detrimental to key interests for businesses or ordinary users to be able to stand up to the miners. That seems pretty unlikely to me because there interests are pretty well aligned.


How to buy BTC as a company Is there any other options how an i buy BTC other than on an exchange ?
Why do i ask, we would like to buy BTC as a company which is not in ENG speaking country.
For that reason all paperwork has to be translated and then sent to exchange in order to create a business account - do you have any experience of doing so ?
In the meantime is there any legit way how to buy a BTC as a company ? - do you have any experience of doing so?
Thank you all for information ! stay healthy

Are there other options? Short answer: Yes.
Find a person with bitcoins and make an offer. That's how trading works.
Exchanges minimize the risk and centralize the trade. But they do not monopolize it.
English isn't the only option on most exchanges. If you can't find one supporting your language you have to translate, of course.
As Murch already pointed out legality depends on where you are from. So, check here to see if bitcoin is legal in your country. Plus I strongly recommend asking a lawyer for legal advice.


Should Electrum users give out their master public key? I have seen a recent service advertising that users can turn their Electrum Wallets in to a "Cold Wallet" by providing the 3rd party service the Master Public Key from the Electrum wallet.

Ignoring the "Cold Wallet" aspect, and besides turning over complete wallet privacy to a third party what other reasons should users be encouraged to do this or not do this?

Users should be strongly discouraged from doing this because it makes them targets for robbery and extortion. Knowing a user's Electrum Master Public Key is equivalent to knowing all of their addresses and being able to look on the blockchain to see if they're worth robbing.


Bitcoin core does not produce a wallet at all I'm reading tutorials on working with bitcoin core like this:

http://bitcoindaily.org/bitcoin-guides/bitcoin-core-tutorial/
and
http://bitcoindaily.org/bitcoin-guides/how-to-recover-bitcoins-bitcoin-core-wont-sync-export-private-key/

Both of which suggest the use of bitcoin core should produce a wallet address of some kind automatically.  Specifically, the second says:

  Bitcoin core automatically generates your first bitcoin address for
  you but you can create as many new ones as you want.

I can't seem to get a wallet address to get started.

Where there is supposed to be a wallet address there is none, and I am asked to enter one, but how do I get one in the first place?

Here is what I see:

There is no address, and I can't just guess one---anything I type in the Address box says it is invalid.

Bitcoin core automatically generates your first bitcoin address for you but you can create as many new ones as you want.

This is outdated. An address is no longer created for you by default.

You can create an address from within the Receive tab by clicking the "Create new receiving address" button.

  Here is what I see:

You are looking at the Sending Addresses window which is for addresses that you want to send to. It is not for your own receiving addresses; that would be the Receiving Addresses window. In recent versions of Bitcoin Core, the functionality to create a new address in the Receiving Addresses window has been removed.


Clarification of Tx Fees settings in Bitcoincore 0.10 I'm looking for clarification of the new Tx priority and Tx Fees settings (eg fee per kB in the 0.10 version of Bitcoincore. Is the 0.0001 BTC fee deprecated? Why the move towards variable Tx fees?

Why the move towards variable Tx fees?

Almost all miners choose what transactions to include in blocks based on fees and priority relative to byte size, so transactions that pay higher fees are more likely to be included in the next block than similar-size transactions that pay lower fees.

Advanced users have always been able to take advantage of this mechanism to set their fee higher for transactions they want to confirm quickly and lower when they don't mind waiting for a while.  But to do this right has always required manually looking at recent blocks to see what were the lowest fee or lowest priority transactions they accepted, which put this kind of "fee market" out of reach of everyday users (or advanced users who don't want to spend much time pinching pennies).

However, Gavin Andresen introduced code into Bitcoin Core 0.10.0 to automatically have each Bitcoin Core node keep its own statistics about block fee and priority thresholds, so now you can run a simple command like this,

$ bitcoin-cli estimatefee 25
0.00001919

to see that if you don't mind waiting up to 25 blocks for confirmation, you can probably set your fee to 0.00001919 per kilobyte.

Thanks the the work of several volunteers, the Bitcoin Core GUI now also uses this information to allow everyday users to easily choose between fast confirmation and low fees.

(source: bitcoinillustrated.org)

This really gives the fee market a chance to develop so that Bitcoin Core can automatically adjust to things like filled (max-size) blocks, new larger blocks, changing use patterns, and significant changes in BTC/fiat exchange rates.  It is also hoped that some safe way will be found to allow SPV clients to also estimate fees and priority so that they can offer their users the same informed choices.

  Is the 0.0001 BTC fee deprecated?

Yes, mostly.  It's still the default if not enough information can be gathered from the network.

There is also still unchanged the default relay fee of 0.00001 BTC per kilobyte.  This isn't related to transactions you create but rather the transactions your node will accept for relay.  The default is widely used, so paying less than it is not a good idea.


Why is downloading blocks taking longer and longer? First off, this really needs to get fixed. I'm downloading blocks for at least 8 hours now, and it's still not done. I know the problem of having to download the entire block chain is being worked on, but I feel it's already out of hand. Setting up an application should take something you would measure in minutes, not hours or days. (After spending the entire night, it's now 4:15am, I would estimate the setup time to be two days.)

Also downloading can be much optimized as it is. It's far from using my maximum download speed, and being connected to one peer is as fast as being connected to 8+ (yup, also tried port forwarding).

Now, ontopic.

Is it normal that downloading blocks goes slower, the further you progress? The first half (out of 194.000) went in the blink of an eye, after that it became less and less fast. Now at 20.000 blocks remaining, progress comes in bursts, but there can easily be 20 seconds of inactivity and when it bursts it's like 10 blocks.

Is this normal behavior? And also, why doesn't the number of connections make any difference for the speed at all? If it works like Bittorrent, which some describe it to work like, it should get faster with more people who can upload to you (more connections).

I've Googled, but all I've found is that it takes a few hours and that it may get stuck. It's not stuck and taking as long as people describe it to be, but I just wonder if it's normal that it's going slower and slower, and why it doesn't saturate my download capacity (like BitTorrent) no matter how many connections.

Thanks

Very little of the time is spent downloading the blockchain data compared to how much time your computer is spending verifying each transaction.  Bitcoin does a ton of disk i/o for this.

As there are more transactions since April (thanks to SatoshiDICE, we now see 40K and more transactions a day) those blocks take longer to verify.

If you are on an encrypted filesystem, that will really be hurtful for perfomance.  If so, consider moving the blockchain and index to a filesystem that isn't encrypted and then symlink to them there.

Also, the latest release of the Bitcoin.org client (v0.6.3) has peformance improvements in this area over previous releases.

End uses generally will not need to run the client and instead use SPV (Simplified Payment Verification).  So individuals and organizations that do want to run the full client should recognize that to do so requires a beefy CPU and quick storage (SSD maybe even).

A future version (after 0.7) will include LevelDB which should make huge gains as far as performance.

In the meantime, you can always securely download a full set of blockchain data from   Sourceforge that is as-of a fairly recent point in time.


Self trade prevention I've read recently following on GDAX:

  You cannot trade with yourself on GDAX. If you create a buy or sell
  order for the same price as another matching order then they will
  cancel each other out.

I want to know is it a default protection practice, used all over the exchanges or only a GDAX innovation?
What about stock markets and other legal trading platforms. Do they also implement this?

Trading with oneself is commonly known as wash trading and is most commonly used to manipulate markets.

  I want to know is it a default protection practice, used all over the exchanges or only a GDAX innovation?

Other exchanges implement this feature. To discourage wash trading, some exchanges will cancel orders that wash, yet still charge commissions for the orders, despite the trades never hitting the market (showing on tickers, trade history or charts)

  What about stock markets and other legal trading platforms. Do they also implement this?

I will ignore the implication that bitcoin exchanges are not legal exchanges.

  used all over the exchanges or only a GDAX innovation?

NYSE/Euronext-Liffe and Eurex do not implement STPM (self-trade protection mechanism). However it's against exchange rules and you will receive nasty letters and/or fines, suspensions or bans for repeat offences.

ICE (Intercontinental Exchange) whose most popular products are oil futures are an example of a well established exchange that implements STPM.

A common use of wash-trading is to trigger stops, especially during periods of low liquidity.

Overall, wash trading is a nefarious activity and I don't know of a legitimate reason you would want to do it, hence exchanges attempt to obstruct traders engaging in the activity.

Defeating STPMs seems a trivial problem (traders can operate multiple accounts) or get their buddy to high/low tick something for them.  STPM can also be defeated in software.  Some trading software even has built in functionality for this, allowing traders to specify that orders should be pulled before when an order is submitted that would wash.


Is there a risk in entering my Bitcoin-Core wallet passphrase, if it's for sending all my available balance and never using that wallet again? I have Bitcoin-Core wallet.dat with a single address and a small amount of bitcoins in it.
Say I want to send all the available bitcoins I have, and then never use that wallet again. Can I use an online computer for that, including entering the passphrase while connected to the internet? Will anybody be able to steal any bitcoins from me?
Thanks

Sure, just make sure it's a computer you trust to be free of malware.


How do websites get prices for a coin? There are websites with historical data of coins. How do they get it?

Do they get the price from 10 exchanges at the same time, then divide by 10?

Every website may have a different way of aggregating this sort of data. I would expect that the exact method used by each website will be determined by their specific needs/applications. There is no absolute "right or wrong way" to get this job done. For example:

A simple implementation someone makes for fun might just display the average of two different API calls
A firm like the CME will pull data from only the most legitimate sources, with external considerations to ensure the price data cannot be manipulated to game futures trades on their exchange

To find more info on some actual implementations, I would suggest looking up some websites that display data in the way you're looking for, and see if they provide any info on the algorithms/methods used. I would guess at least a few sites make that info public.


Why does the order in which the transactions occur matter when we reconstruct ownership information? I was wondering why the order in which the transactions occur matters when we reconstruct ownership information. Can't we just aggregate all the input and output for each account to calculate how much it owns?

I was wondering why the order in which the transactions occur matters when we reconstruct ownership information. Can't we just aggregate all the input and output for each account to calculate how much it owns?

There are no accounts on Bitcoin, but even if there were accounts, how would you deal with the case where the sum of the transactions exceeds the funds necessary for all of them to be valid?  Transaction order is necessary to deal with that case.  Here's an example:

Mallory receives 1 BTC to her account
Transaction A spends 0.5 BTC to Alice from Mallory's account
Transaction B spends 0.5 BTC to Bob from Mallory's account
Transaction C spends 0.5 BTC to Charlie from Mallory's account

Assuming negative balances are forbidden, the order of these transactions determines who gets paid.

Because transaction order matters, and for other reasons, Bitcoin doesn't have accounts.  Each time you receive funds, it's paid to an output that's uniquely identifiable.  That is, it may have the same spending condition (e.g. address) as other outputs you've received, but each output can be uniquely identified by the transaction it appears in (txid) and its sequence in the series of outputs in that transaction (output index number, or output vector (vout)).

When you spend funds, you create an input that uses that unique identifier (called an outpoint) to references the output you're spending.  Bitcoin only allows you to spend an output once within a block chain (an ordered list of transactions), so you have to spend all of the value of that output or you lose the value you don't spend.


How do I print unspent transaction outputs of an address using pybitcointools I am a beginner looking to write a simple program that takes an input (address) and prints the unspent amount in it.

I copied some code from chapter 4 of Mastering Bitcoin to generate a random keypair, and the last lines Andreas had in the code I copied were:

>     # Generate bitcoin address from public key
>       print "Bitcoin Address (b58check) is:", bitcoin.pubkey_to_address(public_key)
>
>     # Generate compressed bitcoin address from compressed public key
>       print "Compressed Bitcoin Address (b58check) is:", \
>           bitcoin.pubkey_to_address(hex_compressed_public_key)

I added the following bit at the end that prints the UTXO. It is currently printing "[ ]" because there are no UTXOs because I'm generating a new address, but it at least works when I do this and prints something.

>     #Print the UTXO for the given address
>     print bitcoin.unspent(bitcoin.pubkey_to_address(public_key))

However, when I type an address instead of the "(bitcoin.pubkey_to_address(public_key))", like so:

>     print bitcoin.unspent(16jn6k2FJqwrNLDpbZmmmpf4TCW7uM6LED)

It gives me an error ("SyntaxError: invalid syntax) and points to the "D" at the end of the address. I really want to use this specific bit of code to enable me to enter an address and have the UTXOs returned. (Please note, I just found that address on blockchain.info by clicking addresses until one with unspent coins came up! Also I am a complete novice so please go easy on me!)

Thanks in advance

>     print bitcoin.unspent('16jn6k2FJqwrNLDpbZmmmpf4TCW7uM6LED')

Sovled the issue.


how to get change address using derived BIP44 publicKey? I have generated a private key using my master seed private key.

PHP Code:

 $bip44 = HierarchicalKeyFactory::fromExtended($result['masterPrivKey']);

$publicKey = $bip44->derivePath("m/44'/0'/0'")->toExtendedPublicKey();

Now using the public key

    $masterkey = HierarchicalKeyFactory::fromExtended($publicKey);

    $result['address'] = $masterkey->derivePath("m/0/1")->getPublicKey()->getAddress()->getAddress();

Should I just change 0 in the middle m/0/1 to 1 to get change address?

I guess I've found the answer as explained in bip43

m / purpose' / *
Apostrophe indicates that BIP32 hardened derivation is used.

We encourage different schemes to apply for assigning a separate BIP number and use the same number for purpose field, so addresses won't be generated from overlapping BIP32 spaces.

Example: Scheme described in BIP44 should use 44' (or 0x8000002C) as purpose.

Note that m / 0' / * is already taken by BIP32 (default account), which preceded this BIP.

Not all wallets may want to support the full range of features and possibilities described in these BIPs. Instead of choosing arbitrary subset of defined features and calling themselves BIPxx compatible, we suggest that software which needs only a limited structure should describe such structure in another BIP and use different "purpose" value.


What are the benifits of using Compressed Bitcoin Addresses rather than Uncompressed addresses if same length? They are both in base58, both 34 characters long, so where exactly is the space saved? When converted to binary is there one less bit on the compressed key as opposed to the uncompressed one? (This is concering legacy addresses as I do not believe SegWit has uncompressed keys that work)

An address contains a hash of something, usually of the public key. For signature verification, a signature, the signed data and the public key is needed. Since inverting a hash is considered impossible the public key is revealed and embedded in the blockchain every time a 1... address spends an Unspent Output paid to it.
Hashes are of constant length, but the public key saved in the blockchain to spend isn't. There is no special handling code that causes uncompressed public keys to be compressed before they make it to the blockchain either. Hence uncompressed public keys take larger space and their transactions are more expensive.


minimal transaction for gandi.net I'm registering with a few different bitcoin sites.  I notice that, at least according to older questions, paypal isn't generally accepted.

Is there a simple way to buy a few US dollars worth of bitcoins?  The purpose is to register a domain with gandi who have a $10 min for paypal.  Some domains are quite inexpensive:  .pw is less than one dollar.

Or, would I simply end up paying more in transaction fees and time than its worth?  For security and volatility, alone, I don't want to hold on to bitcoin.

It's best to read through the steps detailed on www.bitcoin.org, they also link to a list of exchanges. A lot of exchanges will require ID verification which may be more hassle than you're willing to go through. But some exchanges do not for smaller amounts. Or you might try to find an Bitcoin-ATM near you.

Exchange and transaction fees will likely be lower than PayPal. And you may lose or gain a bit of value over any Bitcoin leftover in your wallet. Since price fluctuates, you probably want to buy a little more bitcoins than you really need, to make sure you can fully pay the domain name.


How is a transaction not present in 2 or more solved blocks? If node A picked 10 unconfirmed transactions to solve in a block and node B picked the same 10 transaction in A plus another 10 transactions to solve. If node A finished solving the block informed all nodes and placed the block on the chain, what happens to the same transactions being mined by Node B?

When node B gets informed about block A being mined he would start working on a new block that does not conflict with the first one.

If block B happens to be mined around the same time as block A there would be a fork. All nodes in the network that hear about both blocks will keep both branches and will wait for the conflict to be resolved.

The miner that mines the next block will have to place his new block on top of one of the branches. When that happens and the new block gets broadcasted, all nodes will pick the branch with the most work and the other branch will become orphan.


If a double spend is executed, what happens to the original transaction? So I think i have read enough about double spending so as to be able to execute one.

But I have found nowhere what happens to the original transaction.

A doublespend is a set of transactions which are conflicting with each other. This happens when all transactions are trying to spend some of the same UTXO for inputs. As UTXO can only be spend once, only one of the transactions of the set can be confirmed. When one gets confirmed, all the others become invalid, the invalid transaction will then be forgotten by the network at that point.

Just be sure that some of the inputs match, otherwise you're sending the payment a second time instead of creating a conflicting transaction.