text:
How to retrieve all addresses with non-zero balance and their balances?
I'm looking for a way to retrieve all address balances of addresses with a non-zero balance in the blockchain.
Is there a software tool that can calculate the balances in an accessible format?
Or perhaps I can download them somewhere?
With an accessible format I mean that it can be interpreted by a computer. Either in a database-structure or in parseable text format.

Possible duplicate of All Bitcoin Public Keys with non-zero balance

Rather the other one would be a duplicate of this one, this one is almost two years older.

This guy wanted to do the same thing. You can find a solution there.

in short:

get a Linux Box/VM with >=8GB RAM
download blockparser
compile it
run "./parser allBalances  -w 250000 >allBalances.txt"

the parser run take around 2 minutes on my vSphere VM (2x3Ghz Xeon, 16GB of RAM)
now you have a list of the top 250.000 adresses sorted by BTC amount.
add some sed/awk/cut magic to make a csv and you are done.

how to get ALL "nonzero" balances?

I am sorry, I don't remember. It was 4 years ago

That's a brilliant answer. You might taken hours to test it out. Thanks and here's an up vote for your hard-working Maciej M.

You can use btcposbal2csv.py script to export the list to CSV.

To get current addresses with positive balance, let the full node client sync with the network. Stop the bitcoin-core client before running this utility. If you not stop the client, the database might get corrupted.

Then run this program with path to chainstate directory (usually $HOME/.bitcoin/chainstate).

For example, the following will read from ~/.bitcoin/chainstate, and write result to ~/addresses_with_balance.csv:
./btcposbal2csv.py /home/USER/.bitcoin/chainstate /home/USER/addresses_with_balance.csv

Notes:

That the output may not be complete as there are some transactions which are not understood by the decoding lib, or that which do not have "address" at all. Such transactions are not processed. Number of them and the total ammount is displayed after the analysis.

The output csv file only reflects the chainstate leveldb at your disk. So it will always be few blocks behind the network as you need to stop the bitcoin-core client.

Other dumps:

https://bitkeys.work/download.php

authors: Дарья Иосифенко


text:
using coinbase with uc_bitcoin drupal module
I need a simple hack to change the Drupal uc_bitcoin modules code so it gets the exchange rate from Coinbase, it is designed to use MtGox. I want to avoid using the entire coinbase API because I just want the exchange rate, not the kitchen sink. There is a lot of documentation there.
I have found the code in the uc_bitcoin drupal module which gets the information from MtGox. It needs some simple changes so it gets this data from Coinbase. Since both are so different, and I'm not fluent with PHP I thought someone might be able to help me with this.
Here is the code which gets the exchange rate from MtGox:
function uc_bitcoin_exchange_rate($order) {

  static $rate;

  if(isset($rate)) {
    return $rate;
  }

  if ($order->currency == 'BTC') {
    // BTC 1:1
    return 1;
  }

  // Supported MtGox currencies, Dec 15 2012
  $mtGox_currencies = array(
    'USD',
    'EUR',
    'JPY',
    'CAD',
    'GBP',
    'CHF',
    'RUB',
    'AUD',
    'SEK',
    'DKK',
    'HKD',
    'PLN',
    'CNY',
    'SGD',
    'THB',
    'NZD',
    'NOK'
  );

  // @todo add cache
  if (in_array($order->currency, $mtGox_currencies)) {
    if ($response = drupal_http_request('https://data.mtgox.com/api/1/BTC' . $order->currency . '/ticker')) {
      if ($response->code == 200) {
        $data = json_decode($response->data);
        if(!empty($data->return->avg->value)) {
          $rate = $data->return->avg->value;
        }
      }
    }
  }

// @todo add cache
  if (in_array($order->currency, $mtGox_currencies)) {
    if ($response = drupal_http_request('https://data.mtgox.com/api/1/BTC' . $order->currency . '/ticker')) {
      if ($response->code == 200) {
        $data = json_decode($response->data);
        if(!empty($data->return->avg->value)) {
          $rate = $data->return->avg->value;
        }
      }
    }
  }

  if (!$rate || !is_numeric($rate)) {
    watchdog('uc_bitcoin', 'MtGox lookup - Unable to get current exchange rate', WATCHDOG_ERROR);
    $rate = FALSE; // just to be super sure.
  }

  return $rate;
}

I'm not terribly familiar with drupal, and I've never used the module you're talking about, but I'll take a shot at it:
function uc_bitcoin_exchange_rate($order) {
  static $data;
  $rate = FALSE;
  $currency = $order->currency;
  $currency_code = 'btc_to_' . strtolower($currency);

  if ($currency == 'BTC') {
    // BTC 1:1
    return 1;
  }
  if (!isset($data) {
    if ($response = drupal_http_request('https://api.coinbase.com/v1/currencies/exchange_rates')) {
      if ($response->code == 200) {
        $data = json_decode($response->data);
        $rate = $data[$currency_code];
      }
    }
  }

  if (!is_numeric($rate)) {
    watchdog('uc_bitcoin', 'CoinBase lookup - Unable to get current exchange rate', WATCHDOG_ERROR);
    $rate = FALSE; // just to be super sure.
  }

  return $rate;
}

Getting this error: syntax error, unexpected { on line 7 of this code. I can't figure out why, everything looks fine.

Found the problem.

Does this help you?
https://dgtlmoon.com/how_configuring_drupals_ubercart_bitcoin_payment_module
unfortunately it needs to communicate with a real 'bitcoind' instance via JSON/XMLRPC, I'm not sure if blockchain.info will provide this?

source: Stack Exchange

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

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

sort: votes


text:
What is the proper configuration and command to run bitcoincore and use RPC over LAN?
So, I'm trying to setup my node on a small computer I have lying around and, for practical reasons, I want to be able to do RPC requests to it from computers within my own LAN. Specifically I'm running it on an ubuntu machine and trying to send requests from a windows machine.
I've found 2 questions already here and here and I did attempt their answers, but they didn't work.
As far as I can tell, curl is connecting successfully to the server. It prompts me for the RPC password, but then I get no response back.
What I've tried so far
Running bitcoind with:
bitcoind -rpcbind=0.0.0.0 -rpcallowip=192.168.1.0/24

I get:
EDIT: I later found out that, in windows, I should use curl.exe to use the same curl as in linux. I still get the same results
PS C:\Users\Mateus> curl.exe --user ceuta --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method":"getblockchaininfo", "params": []}' -H 'content-type: text/plain;' http://192.168.0.8:8332/

PS C:\Users\Mateus>

If I set these values in bitcoin.conf, I get the same results. If I do the curl command from a terminal session in the node machine, using the 127.0.0.1 ip, I get the response back.
Alternatively, if I specify rpcbind to be 192.168.0.8 (my node's computer ip address), I get the same behavior, except that in the node's machine now I also don't get the response.
I'm sorry if this might actually be more of a networking question, but I'm just wondering what is a standard way to configure one's node to be able to do RPC requests from other machines on the same LAN and if there are any configuration prerequisites for the machines like firewalls, static ips or whatever, pointing me to a resource would be quite helpful too...

Is it possible you have a firewall on the server, or your router, which blocks port 8332?

Yeah. I actually also have made sure this wasn't a firewall issue. Now, I'm unsure wether its the router. I did try to setup port forwarding, just to be 100% sure (I found nothing mentioning it was blocking anything) but my provider configured it so I can't add port forwarding rules. So now that's where I'm heading....

I'm leaving this as the answer merely to have the question marked as done.
First thing: the questions I linked to and what I described as my node configuration are indeed the correct configuration to have a node accept RPC requests over a network.
My issue was that my router seemed to be interfering. I'm unsure how this should work but 2 things lead me to believe this is true:

The router's configuration had port forwarding turned off. I guess this is the evidence with the least force since it also mentions this is needed to forward requests from the public internet. But hey, it was the only thing that I could remotely relate to something blocking requests between computers in my LAN.
I just made a VPN using tailscale and my RPC requests just worked. And since against facts there can be no arguments, that pretty much settles it in my mind.

Unfortunately, my ISP thinks I'm not allowed to reconfigure these settings, for my own "safety". In other words, I need to get a different router. One that I control.
So to future readers, the advice is: check your router and use a VPN like tailscale. You even get the benefit of not having to be in your LAN to use your node.

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


text:
First Synchronized has been running for 7 days and is at 82%
I have a raspberry pi 5 and the sync has been running for over a week and is only at 82%. Each process point takes longer. I have increased the memory usage to 6000 MB. How long does the first sync take today? BR
——
Ok, I understand there's not much I can do. It just take time. Does anyone know what the current average time is?

This question is similar to: Sync with bitcoin-qt very slow (0,01%). If you believe it’s different, please [edit] the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem.

See also answers to other questions about raspberry pi synchronization such as this


text:
How can i convert my euro in BTC the fastest way
consider me a crypto noob.
All i want is to transfer some ~10 euro (reside in my prepaid mastercard) to a BTC address (i have one, in my blockchain account).
Then i need to give those BTC to some service that have asked for that (like 0.001); they also provided me a QR-code.
What is the fastest (like, right now) way you can think of to pay my service?

PS. I just got verified on blockchain (and became a Gold member), however when i try to deposit EUR/USD (in Exchange), it just shows me some bank information (recipient, where to send etc.), no paypal or anything else. I guess this way will take some time for money transfer.
Thanx for the help

Go to https://bitbay.net
Here you can deposit in EURO and Buy Bitcoin and other cryptocurrency.

I use Kraken.com from the UK bank transfers take 15 mins tops

You need to register in a Crypto Exchange and use this 10 Euro to buy Bitcoins, this value will be credited to your wallet.
I might suggest an exchange in your own country which will allow Euro deposits.


text:
Setting up node, no connection when announce ip address to peers
I want to announce my host name when running node. When I set nxt.myAddress=hostname or IPaddress, there are no connection to peers. But when I keep it empty everything is fine.

Problem solved. Port 27876, 27874 was blocked by ISP.


text:
gettransaction cannot get address where it send from
Hi i have test few time with gettransaction method, it seem only show full detail about transaction when send inside node.
But if i send from another address outside my node, gettransaction only show transaction detail of receive address.
How i can get full detail for both ways even that address not come from my node

Can you provide example transactions and the outputs?

it should display like this : https://jsoneditoronline.org/?id=d15e70e603bc4b628681ec9fff2362dd  but when i receive it only display detail about category receive, detail array only contain category receive, send category not appear, and look like this : https://jsoneditoronline.org/?id=e66e2773205040e6aa8d30c2e94ba62a

What you're looking at is a byproduct of the now-deprecated account system. The send/receive labels are applied according to the addresses that are part of your wallet.
If you want the sender/recipient details as a whole, pass the raw tx hex to decoderawtransaction. This will give you the inputs and outputs as they appear in the transaction, without the accounting filters on it.

i already track in getrawtransaction, but it seem i dont see any sender address here.

That's because Bitcoin transactions don't have a "sender" address. Gettransaction shows you the effect on your wallet (address incoming funds were received with, address outgoing funds are sent to).


text:
Noob: new to bitcoin, bitcoind will not run on Windows 10
I just heard about Bitcoin, it looks huge, and am trying to get it to work and see how it works.
I live in a very rural community and we do not have Internet yet, I had to do some dirty deeds to get my first minimal hardware, and to get this far to simply post.
--
I installed QT and let it sync.
I want to learn how to run bitcoind on my local Windows PC and issue commands in hex to the network.
I can't get bitcoind to run.
C:\bitcoin-0.17.0\bin\bitcoind -daemon -datadir=c:\bitcoin          ( when I ran QT, I added -datadir=c:\bitcoin )
Error: -daemon is not supported on this operating system
--
I am assuming I can't or should not run Bitcoin QT and the daemon at the same time.  I'm trying to understand the bitcoin commands, from the command line (not the QT console) and believe that I can not run both at the same time, because both try to sync the blockchain, correct me if I'm wrong.

You can run bitcoind.exe on windows if you leave off the -daemon flag, as the error message says. Then it will run in the command prompt window or whatever you are running it with. While it's running, you can interact with it using bitcoin-cli.exe in a separate command prompt window.
No, you can't run bitcoind and bitcoin-qt at the same time if they're using the same data/wallet directory, correct. But that's not the cause of the error here.


text:
Block Validation: who does it? How much it costs? And is it present in all protocols?
Different threads were posted in order to clear up this question, but there are some points that I would need to confirm:

When you become a full-node (NOT miner, you just downloaded the full blockchain with a wallet or smilar), are you automatically a validator? Meaning that every new block will be validated by you (and the rest of full-nodes) in order to publish to everyone else whether is trusted or not. Or it does not exist someone that can be only a "validator", and only miners can be also validators?
Does block validation process spend too much energy? Or validate blocks is not a "big deal"?
In protocols that use PoW and PoS/DPoS (Bitcoin, Ethereum, Cardano, EOS...), once a block has been constructed using one of those consensus methods and included into the chain, will be always being involved this "second" validation for the rest of the full-nodes in that particular blockchain network? (I suspect that this second validation could be work slightly different in each of them, but always including this validation for the rest of the nodes)
And finally: what happen if one full-node start to rejects new blocks (he/she considers that are not valid), but the rest of the nodes says that is correct? Imagine a troll/hacker that starts to say that all the nodes are invalid, can that people be banned? Or will be that person just ignored?

When you become a full-node (NOT miner, you just downloaded the full
  blockchain with a wallet or smilar), are you automatically a
  validator? Meaning that every new block will be validated by you (and
  the rest of full-nodes) in order to publish to everyone else whether
  is trusted or not. Or it does not exist someone that can be only a
  "validator", and only miners can be also validators?

Yes, all full nodes validate all transactions before putting them in their mempool and all the blocks they receive. You do not publish to anyone if it's trusted or not, everyone checks if it is valid by themselves.

Does block validation process spend too much energy? Or validate
  blocks is not a "big deal"?

No.

In protocols that use PoW and PoS/DPoS (Bitcoin, Ethereum, Cardano,
  EOS...), once a block has been constructed using one of those
  consensus methods and included into the chain, will be always being
  involved this "second" validation for the rest of the full-nodes in
  that particular blockchain network? (I suspect that this second
  validation could be work slightly different in each of them, but
  always including this validation for the rest of the nodes)

Not sure what exactly you mean here. Every full node will validate all blocks once.

And finally: what happen if one full-node start to rejects new blocks
  (he/she considers that are not valid), but the rest of the nodes says
  that is correct? Imagine a troll/hacker that starts to say that all
  the nodes are invalid, can that people be banned? Or will be that
  person just ignored?

If someone rejects valid blocks he will be left behind as the other nodes will continue to build their chain. No one asks anyone if "other nodes are valid" or "other blocks are valid", they ask each other for blocks which they verify themselves when they receive them. If he tries to provide an invalid block when asked for one he will be banned by other nodes. That's the whole point of bitcoin, you don't have to trust anyone, you check yourself.

Hi Mike, pretty good answers over here! :)
Was interesting the statement "you dont have to trust anyone, you check yourself". What happen if your transaction is being confirmed (good validation, you have enough founds) by some nodes but rejected by others? (this should not happen since everyone is following the same rules, but imaging that this could happen), or in other words, how many "good" validations should get your transaction before going into the mempool?

Every node has it's own mempool. As long as you are connected to one good node (i.e not one that is not relaying your valid transaction on purpose) your tx will eventually be propagated to the whole network and a miner will pick it up and put it in a block. Remember transactions are not considered final until they are in a block and have a few confirmation.

The question was more focused to what happens when a transaction, TX1 for example, its being spreaded over the network and some nodes reject it (not valid) but others accept it (valid transaction). This should not be possible since all are following same rules, but imagine that happens: - Is there a minimum or "valid transaction" confirmations needed, so the miners can check it into a new block?

@3Chicken nothing happens, it doesn't matter who rejects, it all it matters is if it's in a block or not. If it can reach a miner and he puts it in a block then there is no problem.

Hi Mike. Knowing that a node that detects an invalid transaction does not "publish" it to the rest of them, can happen that an invalid transaction get into a block and no one detected as invalid (but some nodes did)? I would say that this is pretty improbable (since loads of nodes validate your transaction, and I think that also the miner that construct the new block with the TX) but...could happen?

On the Bitcoin network, all full nodes are validators. Each and every node will check every block it receives to make sure the proof of work is valid, the transactions match the merkle root, the transactions themselves are valid, the block time/size are valid, among other consensus rules.

Does block validation process spend too much energy?

Compared to mining, block validation is rather cheap. However, it is not free, and very large blocks can take a relatively long time to validate. This is one of the reasons for the 20,000 MAX_SIGOPS limit per block.
Networks such as ethereum use the concept of Max Gas to limit the amount of work required to validate a block, since gas consumed is roughly proportional to the computational effort needed to validate a block.

In protocols that use PoW and PoS/DPoS (Bitcoin, Ethereum, Cardano, EOS...), once a block has been constructed using one of those consensus methods and included into the chain, will be always being involved this "second" validation for the rest of the full-nodes in that particular blockchain network?

Yes, in every network, each full node should be validating each block it receives, regardless of the method of construction.

what happen if one full-node start to rejects new blocks (he/she considers that are not valid), but the rest of the nodes says that is correct?

In Bitcoin, a node that provides false data will be banned for bad actions from the peer list of the node it provided false data to.

Hi Raghav, thanks for the details :) Based on your answers and other threads, basically each node has it`s own mempool where validate transactions.
Now my concern is what happens when a transaction, TX1 for example, it`s being spreaded over the network and some nodes reject it (not valid) but others accept it (valid transaction). This should not be possible since all are following same rules, but imagine that happens:

Is there a minimum or "valid transaction" confirmations needed, so the miners can check it into a new block?

And, also: - Is there some value that identify every TX as unique? Whether TX1 it`s spreaded over the network, and exist in millions of nodes (basically millions of mempools) what will avoid to include that TX in more blocks (so will be duplicated, and provoke double spending? I would say that some kind of unique identifier should exist per TX, right? (so whether a TX has been already included into the blockchain, will not be included again).

Or it does not exist someone that can be only a "validator", and only miners can be also validators?

It totally does exist and is known as full node, which means that it is a node that validates all the rules.

are you automatically a validator?

As above, yes, by definition the full node validates

Does block validation process spend too much energy? Or validate blocks is not a "big deal"?

This depends on the consensus rules and the implementation of the node. In bitcoin, the aim is to make the validation as cheap as possible.

will be always being involved this "second" validation for the rest of the full-nodes in that particular blockchain network?

When the miner creates new block it usually tries to propagate it to the network as quickly as possible so that the rest of the network can build on the top of it so its block will become a part of the best chain.
This means that the block is sent to other nodes and those nodes are usually validating the block and only if it is valid they will propagate further to the network and/or built on top of it.

what happen if one full-node start to rejects new blocks (he/she considers that are not valid), but the rest of the nodes says that is correct?

When a node rejects a block, it usually blacklists the peer that sent it. If there is disagreement on which blocks are valid, the network will split and you will have two different forks that are not compatible.


text:
What is the relationship between parity and the sign of the points on the elliptic curve?
EDIT: I found out that the answer on the second question is just to do 10 * -G, that is, 10 * G(X, -Y) instead of -10 * G. However, I still do not understand relation between parity and the sign of the point.
I know that a private key is some random 256 bit number, which multiplied with G (generator point), gives a public key (a point on the curve). Multiplication denotes adding G point to itself private key number of times. For every X coordinate, 2 Y coos exist, EVEN and ODD. Also, these two point are negations of each other, so (X, Yeven) + (X, Yodd) = Inf and (X, Yodd) + (X, Yeven) = Inf.
For example, in the elliptic curve:
a=2
b=4
p=11
G=(2, 4)

... for the point (3, 2) the negation is (3, 9) and vice versa. Also, (3, 2) + (3, 9) = Inf and (3, 9) + (3, 2)= Inf.
This is completely clear to me because in the equation for adding two points of the elliptic curve, in this case we will get below / zero (0), so division will not be possible, and the result is Inf.
However, in many articles I see that they talk about POSITIVE and NEGATIVE Y coordinate, not even and odd.
According to them, there exists pair of points (X, Y) (X, -Y) and, from it, the equations (X, Y) + (X, -Y) = Inf and (X, -Y) + (X, Y) = Inf. That is, for every (X, Y) exist its negation -(X,Y) = (X,Y).
So in the previous example, for the point (3, 2) exists -(3, 2) = (3, -2) and an equations (3, 2) + (3, -2) = Inf and (3, -2) + (3, 2) = Inf.
This makes no sense to me because the point (3, -2) is not part of the elliptic curve at all and elliptic curve is only "in the context" of the positive numbers.
1. How is it possible? What is the relationship between parity and the signs of points on an elliptic curve? Should I use the -Y point in the addition equation even if it is not part of the elliptic curve?
Also, all these articles says that we can get a negation of some point by doing - private_key * G. Since the private key for the (3, 2) is 10, they say that we should just use -10 and -10 * (2, 4) to get (3, 9).
2. If we know that the public key is a result of adding G point to itself private key number of times, how is it possible to apply addition with a negative number, that is, in the example, to add G to itself -10 times?

First some background
The X and Y coordinates of an elliptic curve are not integers. They are elements of a finite field. In secp256k1, that is the modulo p = 2256-232-977 field. In your example, that is the modulo p = 11 field. Elliptic curves over different fields are also possible, including ones which don't even look like integers.
In these modulo fields, many standard arithmetic operations have a different meaning. Addition, subtraction, and multiplication are performed following a modulo p step. I think you understand this already, but miss that it also applies to constants. -2 is the negation of 2, which modulo p = 11, equals 9. Thus, (3, -2) very much lies on your curve, as it's just another way of writing (3, 9). Note that our choice of treating [0, 1, ..., 10] as the "right" way of representing these field elements is also just a convention - there is nothing special about this choice. All elliptic curve formulas work just fine with the other representations too.
It goes further, though. Division in the field modulo p isn't anything like integer division. Given the fact that for example 3×8 = 24 = 2 (mod 11), and division is the reverse operation of multiplication is division, it has to hold that 2/8 = 3 (mod 11), and 2/3 = 8 (mod 11), but from an integer perspective, 2 is clearly not divisible by 3. The answer is that division modulo p is actually multiplication with the modular inverse. Similarly square roots are also nothing like normal square roots, but become modular square roots (the reverse operation of squaring).
Why do people use the same terms/symbols for things like negation, multiplication, division, square roots, if they're nothing like the "normal" ones? Because for abstract mathematics, it actually doesn't matter what field one works on, or what these exact operations correspond to. Elliptic curves can be defined over any field, and their equations, addition formulas, properties, ... generally hold over all or many of them. This abstraction means mathematicians can describe these curves just once, and then one can instantiate them for whatever field one likes, as long as one uses whatever these operations mean for the chosen field.
So what do the terms "positive" and "negative" refer to?
If -2 and 9 are the same thing modulo 11, we clearly can't use this fact to call some numbers positive or negative. Every field element has both positive and negative integer representatives (infinitely many even, because -2 is also equal to -13, -24, -35, or to 20, 31, 42, ...).
The truth is, there just doesn't exist a well-defined "positive" and "negative" for modulo fields. However, it turns out that it's still useful to pick some definition, in analogy with integers or real numbers, so that one can make statements like "for a given X coordinate on the curve there are two Y coordinates - one positive and one negative". The reality is that it doesn't really matter how one chooses this - it's just a convention - as long as it holds that negating a (nonzero) positive element gives a negative element, and vice versa.
There are many different possible choices for these, and all are used in some context(s):

Call a field element positive, if when represented as an integer in range [0, p-1] it is smaller than p/2, and negative if above p/2.  Modulo 11 this means [1, 2, 3, 4, 5] are positive, and [6, 7, 8, 9, 10] are negative. This also means that 20 = 9 = -2 = -13 is negative, and 14 = 3 = -8 = -19 is positive.
Call a field element positive, if when represented as an integer in range [0, p-1] it is odd, and negative if even. Modulo 11 this means [1, 3, 5, 7, 9] are positive and [2, 4, 6, 8, 10] are negative. In this case, sign and parity are basically the same thing.
Call a field element positive if it has a square root, and negative if it doesn't. (this only works if p mod 4 = 3). Modulo 11 this means [1, 3, 4, 5, 9] are positive and [2, 6, 7, 8, 10] are negative.

Picking a different definition will result in different field elements being called positive and negative, but for all of them, it will be the case that among the two Y coordinates for a given X coordinate on the curve, one will be positive and one will be negative.
So: pick whatever definition you like.
Back to your questions

What is the relationship between parity and the signs of points on an elliptic curve?

If you pick parity as sign, then they are the same thing. If you don't, they're really unrelated.

Should I use the -Y point in the addition equation even if it is not part of the elliptic curve?

It is part of the curve. If (X, Y) is on the curve, then so is (X, -Y), if one takes into account that that negation sign is the field's negation operation, which isn't necessarily the same as integer negation. Specifically, for modulo p fields, -Y = p-Y.

If we know that the public key is a result of adding G point to itself private key number of times, how is it possible to apply addition with a negative number, that is, in the example, to add G to itself -10 times?

Adding G to itself -10 times is the same as adding (-G) to itself 10 times. Alternatively, you can compute it by first adding G to itself 10 times, and then negating the result. It's also equivalent to subtracting G 10 times from the point at infinity (where point subtraction is the same as point addition with negation of the operand).
There is a third option, by taking into account that G is a generator for the elliptic curve group, which has order n (for your small curve, n=17). This means that every 17 additions of G you loop around (or, put otherwise, 17×G = Inf). This means that going backwards 10 times is the same as going forward 7 times, and (-10)×G = 7×G, or more generally, (-a)×G = (n-a)×G.


text:
Are consensus rules allowed to be associated with off-chain information and how is the locktime consensus rule?
In answer to one of my previous questions, Pieter Wuille wrote that the +2h rule for block acceptance cannot be a consensus rule because it is based on comparing block timestamp with information that is outside the chain (real-world timestamp). Cite:

And since real-world time is necessarily external to the chain, any
rule that provides this relation cannot be a consensus rule. It's a
network rule, crucial for Bitcoin's security, but it relies on
information that is not part of the chain itself.

Does this mean that consensus rules are only those related to data from the chain, and any rule that is in any way connected to information outside the chain (such as comparison, subtraction, addition, or anything else with something from the real world) cannot be part of consensus rules because we can all perceive that 'something outside the chain' differently, even if we are entirely correct/honest?

Do consensus rules have to be such that something is either forever correct or forever incorrect, and not that it can become correct or incorrect over time (for example, a block with a certain timestamp becomes valid at some point)? When I say forever, I do not consider cases when consensus rules change.

A transaction with a locktime value (set to a timestamp; not to block height) that has not yet occurred must not be part of the block. As far as I know and as I have thought so far, this is a consensus rule. What interests me is how this can be a consensus rule when the comparison will be made with real timestamp, which is off-chain information?

Does this mean that consensus rules are only those related to data from the chain, and any rule that is in any way connected to information outside the chain (such as comparison, subtraction, addition, or anything else with something from the real world) cannot be part of consensus rules because we can all perceive that 'something outside the chain' differently, even if we are entirely correct/honest?

Yes, consensus rules can only depend on information that is committed to by block hashes. Anything cannot be guaranteed to be observed identically by every validator, at every point in time. And when consensus rules yield different results for different validators, the chain can fork.
Note that it doesn't even need dishonesty; after all, we only care about honest nodes behaving correctly. To use the example of real-world time, nodes can receive blocks at different point in time (due to propagation delays, network infrastructure failures, or even just due to a node synchronizing from scratch only years later). In all these cases, nodes must come to the exact same conclusion at every point in time about which blocks are valid or invalid, or a fork occurs.

Do consensus rules have to be such that something is either forever correct or forever incorrect, and not that it can become correct or incorrect over time (for example, a block with a certain timestamp becomes valid at some point)? When I say forever, I do not consider cases when consensus rules change.

Yes. Think of the consensus rules abstractly as a function which is given as input an entire chain of blocks (so a block with all its ancestors, not including any blocks that were once part of the chain but got reorganized out), and returns either "valid" or "invalid". It takes no other input, and cannot use randomness in the process.

A transaction with a locktime value (set to a timestamp; not to block height) that has not yet occurred must not be part of the block. As far as I know and as I have thought so far, this is a consensus rule. What interests me is how this can be a consensus rule when the comparison will be made with real timestamp, which is off-chain information?

That's not correct. A transaction with a locktime is compared against the block timestamps, not against real-world time.
Specifically, since BIP113, it is compared against the median of the timestamps of the 11 blocks preceding the block the transaction is included in. Before BIP113, the block's own timestamp was used.

Re 2.: Perhaps this is an artifact of imprecise language in the question ("correct" vs "valid"), but transactions can be invalid and then become valid. E.g. timelocked transactions are not valid to be included until they are mature, but then valid from that point on.

@Murch The consensus rules, strictly speaking, only apply to entire blockchains (not individual blocks, and not individual transactions). Of course we do validate transactions individually insofar is possible without context (e.g. script validation), but that's necessarily only partial validation (timelocks being one aspect, but also input UTXOs existing, and block weight limit form relevant context).

Right, what I mean is that LeaBit asks about both blocks and transactions in their question and whether things have to be forever correct or incorrect. Your answer on the other hand only focuses on the validity of the blockchain, and I was wondering whether this point should be made in your answer explicitly.

Basically, the distinction I was trying to make is that a transaction can be "correct", but a block that includes it would be invalid until the transaction’s locktime passes. So, the transaction goes from "invalid for inclusion" to "valid for inclusion" at some point in time. Also, if there are two transactions competing to spend the same input, they may both be "correct" while they are unconfirmed, but once one of them is included in a block, the other is "invalid". I guess what I’m saying is that I’m not sure what you mean with "correct".


text:
Address Reuse vs. Coin Selection
I have read at length that address reuse should be avoided, for instance the bitcoin wiki describes numerous reasons here. I have also read Murch's master thesis on coin selection. These two concepts seem to be at ends with each other. That is, if all bitcoin users follow the instructions to never reuse an address, there should only ever be one UTXO associated to an address, and then it is abandoned once the UTXO is spent - thus only one input to any given transaction. Does following the address reuse recommendation render the concept of coin selection useless?
Some smaller related questions that I don't feel deserve their own questions:

Do the instructions to not reuse an address include change? That is, should I generate a new key pair for any transaction that needs to receive change, and then manually specify my change be sent to the newly generated address?
If I make a new address for every transaction, and let us say I have one key pair associated to a 1 btc UTXO and another key pair associated to a 1 btc UTXO and I want to send Alice 2 BTC, then following the address reuse policy I would ask her to provide me 2 seperate bitcoin addresses, and I would make two separate transactions, 1 btc sent to each address?
Terminology - does the term "wallet" refer to a key pair, or to software/hardware etc. that could contain many key pairs. For example, thinking of a Nano Ledger S, is the device itself the "wallet" and each 3-tuple (private key, pub key, address) also considered a "wallet"?

EDIT:
My question has been sufficiently answered - I failed to understand that when conducting a transaction with multiple UTXO inputs, they do not all need to be associated to the same address/private key. Good news Murch, your masters thesis wasn't in vain :)

Do the instructions to not reuse an address include change? That is, should I generate a new key pair for any transaction that needs to receive change, and then manually specify my change be sent to the newly generated address?

Wallet software will do this automatically for you. Whenever change is created, the wallet will construct a new keypair, compute its address, and send the change there. You shouldn't ever do anything manual.

If I make a new address for every transaction, and let us say I have one key pair associated to a 1 btc UTXO and another key pair associated to a 1 btc UTXO and I want to send Alice 2 BTC, then following the address reuse policy I would ask her to provide me 2 seperate bitcoin addresses, and I would make two separate transactions, 1 btc sent to each address?

No, you (or your wallet) will just create a single transaction that spends both 1 BTC UTXOs, and send 2 BTC to Alice's address. No reuse.
The advice of no reuse just means that if you later want to send more money to Alice, you'd ask a different address of hers, and don't send again to the same one. This is generally good practice for other reasons anyway, as Alice may have moved to a new wallet setup, and prefer not be paid to old one anymore.

Terminology - does the term "wallet" refer to a key pair, or to software/hardware etc. that could contain many key pairs. For example, thinking of a Nano Ledger S, is the device itself the "wallet" and each 3-tuple (private key, pub key, address) also considered a "wallet"?

You'll hear conflicting opinions on this, but in my view it's closer to the second. A wallet is something that manages a collection of addresses, coin selection, helps constructing transactions, ...
In my view, a "hardware wallet" is badly named, because it is not managing any of these things. It is a hardware transaction signing device, which needs communication with an actual wallet to be instructed what to do.

"No, you (or your wallet) will just create a single transaction that spends both 1 BTC UTXOs, and send 2 BTC to Alice's address. No reuse." --- but if 1 btc had been sent to one of my addresses, and the other btc had been sent to another one of my addresses, when I make the transaction to Alice, when it appears on block explorer, which address will it appear to have come from?

It will appear to come "from" both.

Ok, I think I am in full understanding now. Thank you for a quality answer. I have never actually used a wallet of any kind as I am only learning about bitcoin for intellectual stimulation, so I don't really know what kind of things they do/don't do for you. Thanks!

Does following the address reuse recommendation render the concept of coin selection useless?

No, it does not.
It seems like the main misconception is that using an address multiple times creates fewer UTXOs than using multiple addresses for each payment. However they are the exact same. If you receive 5 payments to a single address, you will have 5 UTXOs. If you receive 5 payments to 5 different addresses, you will also have 5 UTXOs. To a coin selection algorithm, these are the exact same scenario: 5 UTXOs of the same size with the same size requirement for spending.

Do the instructions to not reuse an address include change?

Yes

That is, should I generate a new key pair for any transaction that needs to receive change, and then manually specify my change be sent to the newly generated address?

Most wallet software will already be generating new change addresses for you. There is no need to do that manually unless you are using some ancient or poorly written wallet software that does not. And in that case, you should use a different wallet software.

If I make a new address for every transaction, and let us say I have one key pair associated to a 1 btc UTXO and another key pair associated to a 1 btc UTXO and I want to send Alice 2 BTC, then following the address reuse policy I would ask her to provide me 2 seperate bitcoin addresses, and I would make two separate transactions, 1 btc sent to each address?

No. A single transaction can (and most do) have multiple inputs and multiple outputs. Your 2 UTXOs will be in the same transaction that creates a single 2 BTC UTXO for Alice.

Terminology - does the term "wallet" refer to a key pair, or to software/hardware etc. that could contain many key pairs. For example, thinking of a Nano Ledger S, is the device itself the "wallet" and each 3-tuple (private key, pub key, address) also considered a "wallet"?

Wallet can refer to two things:

A collection of keys and their associated addresses and transactions
A piece of software or hardware that manages a collection of keys and their associated addresses and transactions.

Wait, I think my actual misconception was that when I "sign" a transaction with my "private key", I thought the "private key" used for signing needed to be associated with ALL of the inputs in the tx AND the address I was sending from. Is that not the case?

Every input will contain its own signature. If those inputs spend UTXOs corresponding to distinct addresses/keys, those will be signatures with those distinct keys.

Ok, I see now. Thanks! So let me just clarify one more thing: If I construct a transaction with multiple inputs associated to different addresses, when the transaction gets to mempool and appears on block explorer, which address is the one the transaction appears to be from?

It will appear to come "from" all of them.

Thanks Andrew and Pieter for your answers. Both were high quality IMO.


text:
Best Practice for Using Btc
I have recently learned about best practice for storing private keys with hardware wallets. I understand the necessary information including backups from seed phrases, the concept of cold storage, safely storing seed phrases, and having multiple HD wallets incase one goes missing, etc.
Ok. But now, I want to actually use bitcoin in the real world, because what better way to support btc than to actually use it!
So I want to have a wallet, preferably on my phone that I can use for quick and easy payments with friends and merchants in public. I plan to keep $100 or less on this account, similar to my debit account with my usual bank.
But I still want to do my best to be secure, and I don’t understand a lot of the vulnerabilities with my public keys being stored somewhere on my phone. Can someone please perhaps recommend a mobile based platform for btc transactions and outline the vulnerabilities and how I can avoid them? I understand that my hardware wallet is offline, what vulnerabilities come with my phone being online?
Example: I have heard people mention to never connect to public WiFi. How does this make me vulnerable? So when I leave the house should I disable WiFi? Are there any vulnerabilities with using 4g?

There is many wallets outhere, some of them open source that you could even compile and run into your device so you can audit the code if you don't want to trust the manufacturer.
My advice use the one you think or see works good (in my case https://blockstream.com/green/)
With the care you are proposing right now, having only what would spend.
I like to think that it's the same than having cash in our pockets, if you lose it you won't claim to anybody.
So create another separate wallet, feed it with sum funds from your hard wallet and enjoy safely. And remember to ALWAYS keep your private keys out of any connected device (at least the big wallet), never share it , never take a picture and so on.


text:
What role has bitcoin-init as a process?
I have set up a node on a RaspberryPi. When I check for active processes with top I see bitcoin-init occupying 50% of memory and 7% of CPU.
I can check for bitcoind and it is active:
bitcoin@raspberrypi ~ $ service bitcoind status
● bitcoind.service - Bitcoin daemon
   Loaded: loaded (/etc/systemd/system/bitcoind.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2019-08-09 14:43:54 CEST; 2 weeks 4 days ago
  Process: 623 ExecStart=/usr/local/bin/bitcoind -conf=/home/bitcoin/.bitcoin/bitcoin.conf -pid=/home/bitcoin/.bitcoin/bitcoind.pid (cod
 Main PID: 772 (bitcoin-init)
    Tasks: 16 (limit: 4915)
   CGroup: /system.slice/bitcoind.service
           └─772 /usr/local/bin/bitcoind -conf=/home/bitcoin/.bitcoin/bitcoin.conf -pid=/home/bitcoin/.bitcoin/bitcoind.pid

According to this thread I assume that the daemon process bitcoind
has been renamed to bitcoin-init but I am not sure if I understood that correctly.
My node seems to update the chain, but very slowly - 50GB after several weeks. And it is not reachable if I check my local IP via Coindance.
If I run bitcoin-cli getinfo with my usual Rasperry user pi I get
error: Could not locate RPC credentials. No authentication cookie could be found, and RPC password is not set.  See -rpcpassword and -stdinrpcpass.  Configuration file: (/home/pi/.bitcoin/bitcoin.conf)`

I have not set up a bitcoin.conf file.
If I run it with user bitcoin (not sure if that would be the right thing to do):
bitcoin@raspberrypi ~ $ bitcoin-cli getinfo
error code: -32601
error message:
Method not found

So, is bitcoin-init maybe just a startup process and my node is not working?

EDIT: The book (Antonopoulos) sais that bitcoind will give an error unless I set an rpcpassword in the configuration file. I don't have such a file, but bitcoind gives:
2019-08-28T07:27:16Z Bitcoin Core version v0.18.99.0-12fd4bbd1 (release build)
2019-08-28T07:27:16Z Assuming ancestors of block 0000000000000000000f1c54590ee18d15ec70e68c8cd4cfbadb1b4f11697eee have valid signatures.
2019-08-28T07:27:16Z Setting nMinimumChainWork=0000000000000000000000000000000000000000051dc8b82f450202ecb3d471
2019-08-28T07:27:16Z Using the 'standard' SHA256 implementation
2019-08-28T07:27:17Z Default data directory /home/pi/.bitcoin
2019-08-28T07:27:17Z Using data directory /home/pi/.bitcoin
2019-08-28T07:27:17Z Config file: /home/pi/.bitcoin/bitcoin.conf (not found, skipping)
2019-08-28T07:27:17Z Using at most 125 automatic connections (1024 file descriptors available)
2019-08-28T07:27:17Z Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements
2019-08-28T07:27:18Z Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements
2019-08-28T07:27:18Z Using 4 threads for script verification
2019-08-28T07:27:18Z scheduler thread start
2019-08-28T07:27:18Z Binding RPC on address ::1 port 8332 failed.
2019-08-28T07:27:18Z Binding RPC on address 127.0.0.1 port 8332 failed.
2019-08-28T07:27:18Z Unable to bind any endpoint for RPC server
2019-08-28T07:27:18Z Error: Unable to start HTTP server. See debug log for details.
Error: Unable to start HTTP server. See debug log for details.
2019-08-28T07:27:18Z Shutdown: In progress...
2019-08-28T07:27:18Z scheduler thread interrupt
2019-08-28T07:27:18Z Shutdown: done

EDIT: I seem to have two seperate directories for .bitcoin. How can I tell bitcoind to use the other one?

My node is running good again, bitcoin-cli works and the process is still called bitcoin-init while the blockchain is initially downloaded. So the process is renamed or it is called this way during initial download.

The reasons for my problems where the following:
bitcoin-init seems to be the correct process.
getinfo is no longer a method, it has been removed.
My startup skript /etc/systemd/system/bitcoind.startup was running bitcoind with user bitcoin. When I started it manually bitcoind run with another user (the active one I was using the shell with). bitcoind will then automatically set up a working directory in the home directory of this other user.
Another issue is that bitcoin-cli as a client can use password and user for authentication with bitcoind as a server (but it will be deprecated). But bitcoin-cli is also able to connect to a bitcoind server on the same machine without password/user just by a cookie. This is not the case for the class RawProxy() in python-bitcoinlib - it needs authentication. So, a command with bitcoin-cli might work without user/password while the same in a script with that library will not.

With the order, I will try to response to your question.

According to this thread I assume that the daemon process bitcoind has been renamed to bitcoin-init but I am not sure if I understood that correctly.

I don't think the bitcoind is rewriting to bitcoin-init, but I don't have a mode for testing bitcoin-core on raspberry, so I ask you if you can post "how you have installed the bitcoin-core?", with command sudo apt install or a zip directory on Github/official site bitcoin?

My node seems to update the chain, but very slowly - 50GB after several weeks. And it is not reachable if I check my local IP via Coindance.

The answer is "depends", depends on your connection, in any case, is a little slow if you don't have an ADSL 7 mbs

EDIT: The book (Antonopoulos) sais that bitcoind will give an error unless I set an rpcpassword in the configuration file. I don't have such a file, but bitcoind gives:

Is possible to configure the node bitcoind with the file config, "bitcoin.conf", you have a complete example here and here file must be inside the directory bitcoin, if you don't change it, will be in the folder /home/yourName/.bitcoin/bitcoin.conf or you can set the bitcoind from the command line, an example bitcoind -rpcuser=vincent

I seem to have two seperate directories for .bitcoin. How can I tell bitcoind to use the other one?

If you have synchronized the bitcoin-core inside another directory (an example because you have a version bitcoin inside the external HDD) your command for bitcoin is similar this, bitcoind  -datadir=/media/vincenzo/Maxtor/BitcoinCore/node if you not call the bitcoind with the daradir, the bitcoind re-synchronized the blockchain of bitcoin inside the /home/yourName/.bitcoin/ directory

If I run bitcoin-cli getinfo with my usual Rasperry user pi I get

The problem should be the datadir different from /home/yourName/.bitcoin/

I am running version 0.18.99.0 which I compiled via git. Did you check the link I provided for finding out if bitcoind has been changed to bitcoin-init (just the process, the servicename is still bitcoind). https://github.com/bitcoin/bitcoin/issues/16007 Also, I am now running it in -printtoconsole to check if it works. Which command can I use to give bitcoind the path to my config file? -conf=... seems not to work.

I have add this details inside the aswer, with -datadir=path and the bitcoin.conf must be inside the path


text:
I am updating RaspiBolt - Where is my old electrs config?
I am updating my RaspiBolt according to this guide. Unfortunately, the guide changed a lot since my last update. It is still great, though!
I am upgrading from v0.8.10 to v0.9.3 and somewhere in between the path for electrs config changed to /data/electrs/electrs.conf.
Where was it before?

I found the old config with systemctl edit --full-edit electrs.service in the line
ExecStart=/usr/local/bin/electrs --conf /mnt/bitcoin/electrs/electrs.conf.
The location of the config changed because the guide introduced a different setup for the data storage. In the old setup user bitcoin was necessary. This user is now deactivated for interaction and just used by the bitcoin service. Data is now stored in /data which is owned by bitcoin:bitcoin and the user admin is in the group bitcoin, making changes possible with user admin.
I was wondering why /data is not mounted from the external SSD/HDD. Reason is the guide now suggests to run the whole operating system from the SSD.
Other important notes for updating electrs can be found here. Although it is not stated as necessary, using the old verbose = option in the config did result in a failed startup. I had to just use log_filters =.
Also, I had to update bitcoin.conf with whitelist=download@127.0.0.1 so that electrs can get a connection.


text:
How to update an older C++ code from Antonopoulos' book to work with current libraries?
I am trying to compile a code in C++ from the Book "Mastering Bitcoin" by Antonopoulos (page 69).
I am new to all of this, including C++, python, etc. I see it as a way of doing something interesting and alongside it learning a bit about different languages.
The code uses #include <bitcoin/bitcoin.hpp and I already had troubles making this work on my Raspberry Pi. I installed libbitcoin from source and then I had to give the path of libbitcoin.pc to the pkg-config to be able to execute the following command:
g++ -o addr addr.cpp $(pkg-config --cflags -- libs libbitcoin)
The compiler then gives the following errors:
69_addr.cpp: In function ‘int main()’:
69_addr.cpp:9:3: error: ‘ec_point’ is not a member of ‘bc’
   bc::ec_point public_key = bc::secret_to_public_key(secret);
   ^~
69_addr.cpp:10:34: error: ‘encode_hex’ is not a member of ‘bc’
   std::cout << "Public key: " << bc::encode_hex(public_key) << std::endl;
                                  ^~
69_addr.cpp:10:49: error: ‘public_key’ was not declared in this scope
   std::cout << "Public key: " << bc::encode_hex(public_key) << std::endl;
                                                 ^~~~~~~~~~

I suspect there have been changes to the libraries since the book came out in June 2017.
This is the code from the book I try to compile:
#include <bitcoin/bitcoin.hpp>

int main()
{
  bc::ec_secret secret;
  bool success = bc::decode_base16(secret,"038109007313a5807b2eccc082c8c3fbb988a973cacf1a7df9ce725c31v14776");
  assert(success);

  bc::ec_point public_key = bc::secret_to_public_key(secret);
  std::cout << "Public key: " << bc::encode_hex(public_key) << std::endl;

  const bc::short_hash hash = bc::bitcoin_short_hash(public_key);

  bc::data_chunk unencoded_address;
  unencoded_address.reserve(25);
  unencoded_address.push_back(0);
  bc::extend_data(unencoded_address, hash);
  bc::append_checksum(unencoded_address);
  assert(unencoded_address.size() == 25);
  const std::string address = bc::encode_base58(unencoded_address);

  std::cout << "Address: " << address << std::endl;
  return 0;
}

EDIT: Shortly after posting this question I found out about the github from my answer below. I used the new code from there to compile and now I am able to do more but still it exits with error. Here is the full log, the problematic parts are of course at the bottom and say undefinined reference to __gmpn_set_str and __gmpn_gcdext.
13:28:16 [bitcoin@raspberrypi BuchSkripte]$ g++ -v -o addr 69_addr2.cpp $(pkg-config --cflags --libs libbitcoin)
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/6/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Raspbian 6.3.0-18+rpi1+deb9u1' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --program-prefix=arm-linux-gnueabihf- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-armhf/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-armhf --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-armhf --with-arch-directory=arm --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-sjlj-exceptions --with-arch=armv6 --with-fpu=vfp --with-float=hard --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 6.3.0 20170516 (Raspbian 6.3.0-18+rpi1+deb9u1)
COLLECT_GCC_OPTIONS='-v' '-o' 'addr' '-I' '/home/pi/libbitcoin/include' '-L/home/pi/libbitcoin/lib' '-shared-libgcc' '-march=armv6' '-mfloat-abi=hard' '-mfpu=vfp' '-mtls-dialect=gnu'
 /usr/lib/gcc/arm-linux-gnueabihf/6/cc1plus -quiet -v -I /home/pi/libbitcoin/include -imultilib . -imultiarch arm-linux-gnueabihf -D_GNU_SOURCE 69_addr2.cpp -quiet -dumpbase 69_addr2.cpp -march=armv6 -mfloat-abi=hard -mfpu=vfp -mtls-dialect=gnu -auxbase 69_addr2 -version -o /tmp/cca8JFzr.s
GNU C++14 (Raspbian 6.3.0-18+rpi1+deb9u1) version 6.3.0 20170516 (arm-linux-gnueabihf)
    compiled by GNU C version 6.3.0 20170516, GMP version 6.1.2, MPFR version 3.1.5, MPC version 1.0.3, isl version 0.15
GGC heuristics: --param ggc-min-expand=88 --param ggc-min-heapsize=109911
ignoring duplicate directory "/usr/include/arm-linux-gnueabihf/c++/6"
ignoring nonexistent directory "/usr/local/include/arm-linux-gnueabihf"
ignoring nonexistent directory "/usr/lib/gcc/arm-linux-gnueabihf/6/../../../../arm-linux-gnueabihf/include"
#include "..." search starts here:
#include <...> search starts here:
 /home/pi/libbitcoin/include
 /usr/include/c++/6
 /usr/include/arm-linux-gnueabihf/c++/6
 /usr/include/c++/6/backward
 /usr/lib/gcc/arm-linux-gnueabihf/6/include
 /usr/local/include
 /usr/lib/gcc/arm-linux-gnueabihf/6/include-fixed
 /usr/include/arm-linux-gnueabihf
 /usr/include
End of search list.
GNU C++14 (Raspbian 6.3.0-18+rpi1+deb9u1) version 6.3.0 20170516 (arm-linux-gnueabihf)
    compiled by GNU C version 6.3.0 20170516, GMP version 6.1.2, MPFR version 3.1.5, MPC version 1.0.3, isl version 0.15
GGC heuristics: --param ggc-min-expand=88 --param ggc-min-heapsize=109911
Compiler executable checksum: 79dca666fccaa96025c9107a8b3f60f3
COLLECT_GCC_OPTIONS='-v' '-o' 'addr' '-I' '/home/pi/libbitcoin/include' '-L/home/pi/libbitcoin/lib' '-shared-libgcc' '-march=armv6' '-mfloat-abi=hard' '-mfpu=vfp' '-mtls-dialect=gnu'
 as -v -I /home/pi/libbitcoin/include -march=armv6 -mfloat-abi=hard -mfpu=vfp -meabi=5 -o /tmp/ccryc6jT.o /tmp/cca8JFzr.s
GNU assembler version 2.28 (arm-linux-gnueabihf) using BFD version (GNU Binutils for Raspbian) 2.28
COMPILER_PATH=/usr/lib/gcc/arm-linux-gnueabihf/6/:/usr/lib/gcc/arm-linux-gnueabihf/6/:/usr/lib/gcc/arm-linux-gnueabihf/:/usr/lib/gcc/arm-linux-gnueabihf/6/:/usr/lib/gcc/arm-linux-gnueabihf/
LIBRARY_PATH=/usr/lib/gcc/arm-linux-gnueabihf/6/:/usr/lib/gcc/arm-linux-gnueabihf/6/../../../arm-linux-gnueabihf/:/usr/lib/gcc/arm-linux-gnueabihf/6/../../../:/lib/arm-linux-gnueabihf/:/lib/:/usr/lib/arm-linux-gnueabihf/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-o' 'addr' '-I' '/home/pi/libbitcoin/include' '-L/home/pi/libbitcoin/lib' '-shared-libgcc' '-march=armv6' '-mfloat-abi=hard' '-mfpu=vfp' '-mtls-dialect=gnu'
 /usr/lib/gcc/arm-linux-gnueabihf/6/collect2 -plugin /usr/lib/gcc/arm-linux-gnueabihf/6/liblto_plugin.so -plugin-opt=/usr/lib/gcc/arm-linux-gnueabihf/6/lto-wrapper -plugin-opt=-fresolution=/tmp/cc0zjaUW.res -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --sysroot=/ --build-id --eh-frame-hdr -dynamic-linker /lib/ld-linux-armhf.so.3 -X --hash-style=gnu -m armelf_linux_eabi -o addr /usr/lib/gcc/arm-linux-gnueabihf/6/../../../arm-linux-gnueabihf/crt1.o /usr/lib/gcc/arm-linux-gnueabihf/6/../../../arm-linux-gnueabihf/crti.o /usr/lib/gcc/arm-linux-gnueabihf/6/crtbegin.o -L/home/pi/libbitcoin/lib -L/usr/lib/gcc/arm-linux-gnueabihf/6 -L/usr/lib/gcc/arm-linux-gnueabihf/6/../../../arm-linux-gnueabihf -L/usr/lib/gcc/arm-linux-gnueabihf/6/../../.. -L/lib/arm-linux-gnueabihf -L/usr/lib/arm-linux-gnueabihf /tmp/ccryc6jT.o -lbitcoin -lboost_chrono -lboost_date_time -lboost_filesystem -lboost_iostreams -lboost_locale -lboost_log -lboost_program_options -lboost_regex -lboost_system -lboost_thread -lpthread -lrt -ldl -lsecp256k1 -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/arm-linux-gnueabihf/6/crtend.o /usr/lib/gcc/arm-linux-gnueabihf/6/../../../arm-linux-gnueabihf/crtn.o
/home/pi/libbitcoin/lib/libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function `secp256k1_num_mod_inverse':
/home/pi/build-libbitcoin/secp256k1/src/num_gmp_impl.h:128: undefined reference to `__gmpn_gcdext'
/home/pi/libbitcoin/lib/libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function `__gmpn_sub':
/usr/include/arm-linux-gnueabihf/gmp.h:2190: undefined reference to `__gmpn_sub_n'
/home/pi/libbitcoin/lib/libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function `secp256k1_num_set_bin':
/home/pi/build-libbitcoin/secp256k1/src/num_gmp_impl.h:49: undefined reference to `__gmpn_set_str'
/home/pi/build-libbitcoin/secp256k1/src/num_gmp_impl.h:49: undefined reference to `__gmpn_set_str'
/home/pi/build-libbitcoin/secp256k1/src/num_gmp_impl.h:49: undefined reference to `__gmpn_set_str'
/home/pi/libbitcoin/lib/libsecp256k1.a(libsecp256k1_la-secp256k1.o): In function `secp256k1_num_get_bin':
/home/pi/build-libbitcoin/secp256k1/src/num_gmp_impl.h:34: undefined reference to `__gmpn_get_str'
/home/pi/build-libbitcoin/secp256k1/src/num_gmp_impl.h:34: undefined reference to `__gmpn_get_str'
collect2: error: ld returned 1 exit status

I am not sure if this is a problem specific to my setup or in general but I opened an issue: https://github.com/bitcoinbook/bitcoinbook/issues/643

I just found out there is a github where the code is updated.
The specific code for addr.cpp is this.
Compilation works with --static e.g. g++ -o addr addr.cpp $(pkg-config --cflags --libs --static libbitcoin).

You can add -lgmp when it happens


text:
Anonymous (no ID, no verification) Payments to PayPal?
Not looking for a discussion on how Bitcoin payments can be traced and it's not truly anonymous. I'm not looking for total anonymity, I just don't want the merchant or payment processor to identify me.
Prior to their update, you could use BitInstant to send money to peoples' PayPal addresses straight from a Bitstamp coupon. Now, they want you to verify who you are with a name, address, urine sample etc. I'm looking for services like the old BitInstant which allow you to direct-pay to PayPal.
Tor being allowed is a plus but not required. I can pay from Bitcoin, MtGox, BTC-e or Bitstamp. The minimum transaction should be trivial, no more than $25-30.
Thanks for the help.

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


text:
How to set up ASIC properly?
Okay so butterfly labs has these ASIC chips available yet I am very confused on how to implement these. I have never seen these type of things and googling has gotten me nowhere.

The documentation to these chips has not been released yet, as you can see on the page:

Reference documentation:  Butterfly Labs is releasing it's PCB schematics & MCU code to open source.  Links to this documentation will follow shortly.

Be aware that by ordering these you are not purchasing a finished product, you are just purchasing the chips to build one.

@Griffin: There are (will be) companies that will take the chips from you and assemble them into a board for you. TerraHash for example.

@DavidSchwartz Also it says 100. Does that mean you get 100 at 4.5 GHz each or 100 that add up to 4.5GHz?

@DavidSchwartz I'm talking about the product from butterfly labs

100 is the minimum order. It has nothing to do with the chip's specifications.

@DavidSchwartz I understand that however I'm wondering is each chip 4.5GHz or are they all combined 4.5GHz

Neither. The chips do not run at 4.5GHz and speeds do not add up (100 cars going 50 miles per hour don't "add up" to 5,000 miles per hour). However, each chip is capable of doing hashes at a rate of 4.5GH/s, and rates at which work is done do add up.

@DavidSchwartz That was my fault adding the z in there sorry.

@DavidSchwartz But does each one do 4GH/s or do all 100 add up to 4GH/s

@Griffin Each chip is capable of doing hashes at a rate of 4.5GH/s.


text:
How to get signature for tweaked public key in P2TR in case of multiple signature?
EDIT: Can we just tweak the signature with the root MAST as well?
As I understand, the public key in scriptPubKey for P2TR is obtained by tweaking (let's call it original public key) and the root of the MAST. This original public key, in context of multi-signature, is obtained by the process of Schnorr aggregation of the public keys owned by multiple participants. In the following, I will refer to the obtained public key (the one in scriptPubKey) as the P2TR public key.
What I'm interested in is how do we get a proper signature for such a P2TR public key?
If it was just one public key (not one obtained from multiple public keys), it would be easy. We would simply tweak the private key with the MAST root as well and then create the signature.
However, in the case of multisig (as far as I understand) the signature is created in such a way that all participants, each with their own private key, create partial signatures that are then merged into one. The problem is that this signature will match the original public key, not the P2TR public key that is in the scriptPubKey. So, the signature is not correct.
How is this overcome? How to make a correct signature in this case?

To sign for an aggregated public key you need to run the respective collaborative signing protocol (e.g. if you use MuSig2 key aggregation to aggregate the keys, you need to run the MuSig2 signing protocol between the signers). There are several such protocols.
If the aggregated public key that comes out is then also tweaked in some way, you need to use a modified version of the signing protocol that also supports tweaking. This is a simple modification, but it's not just an additional step after the normal MuSig2 signing protocol.

So If I understood, there are a different ways (algorithms/protocols) to create a public key and its corresponding signature when we work with Schnorr. For example: MuSig, MuSig2, MuSig-DN... All these algorithm use some parts of Schnorr mathematic to create a correct signature and its public key. However, when we (and other nodes) validate the signature, we always use one validating (Schnorr) algorithm that does not have anything with the way we created that public key and its signature.

So, other nodes do not need to know the way we got the signature and public key (the used algorithm; for example, is it MuSig or MuSig2), public key and signature just need to match each other according to the Schnorr signature validation algorithm and that's all. Is this correct?

@LeaBit Yes. Public keys look all indistinguishable from one another (they're supposed to be random-looking, regardless of how they were generated). And for signatures the only requirement is that it's a valid BIP340 signature for the public key in the output (for key path spends) or for the public key(s) in the revealed script (in a script path spend). Nodes do not know or care how that signature was generated.

Just one more question. Is this a specificity of the Schnorr algorithm and the way it works, or can this also be applied in ECDSA? I know the basic (original) algorithm for obtaining signatures in ECDSA and ECC public keys, where we can additionally do basic tweaking of public and private keys with some value (for P2C) and that's it. However, with ECDSA, can we also use DIFFERENT algorithms (MuSig, MuSig2 etc) to obtain public key and its corresponding signature, and then use ONLY one ECDSA signature validation algorithm? In other words, does this whole story also apply to ECDSA?

There also exist multi-party ECDSA algorithms, but they are very different and much more complicated (look up 2P-ECDSA for example). MuSig and friends don't apply to ECDSA, as their signing algorithm results in a valid Schnorr signature, not a valid ECDSA signature. It's specifically due to Schnorr's simple structure that multi-party variants are easy.

Okay, but still different algorithms (related now to ECDSA mathematic) can be used for generating public key and its signature and these algorithms do not have anything with the process of validating signature. That is, only one validation signature ECDSA algorithm is used? I ask, because as I know we do not state anywhere in ECDSA which algorithm we used to generate the keys and their signatures, it is only important to signature be valid and that's all. Is this true?

Yes and no. ECDSA (like any digital signature scheme) is technically speaking a collection of three algorithms (key generation, signing, verification). It just so happens that the 2P-ECDSA scheme (which replaces the key generation and signing part with something else) happens to have the same verification algorithm as normal ECDSA. The same is true for MuSig etc. with BIP340/Schnorr. So yes, the verification algorithm is always that of just ECDSA (for pre-Taproot outputs) or BIP340 (for Taproot outputs).

@Leabit: If you have a follow-up question that goes beyond the scope of the original question, please create another topic.—Pieter: Could you please incorporate the additional information relevant to this topic from the comments into your answer?


text:
What makes it difficult to prevent transactions where value transferred is less than the fees paid?
I can't wrap my head around the fact that someone could pay more fees than the value transferred(even though some wallets could be taking care of it at that level) but this also enables a well funded DDoS vector possible.
Is there a technical reason why Bitcoin doesn't prevent something like this at the consensus level or at least Bitcoin core as one of the policy rules?
There's an option for minimum dust relay which has a completely arbitrary default value(making it quite ineffective and inconvenient to use), may be that should be dynamic with an on/off option instead.

Just a small note about "why Bitcoin core doesn't prevent something like this at either consensus or policy levels": Bitcoin core is not an "owner" of Bitcoins consensus rules, its just one of the implementations (among much other) of Bitcoin full node; so it can't prevent anything by itself on consensus level

When we talk about full nodes, we can only assume that the majority of the network uses Bitcoin Core. However, my point was not about that, but only that Bitcoin Core cannot change the consensus rules by itself. Perhaps it would be more correct to write in question why Bitcoin does not prevent it at the level of consensus or at least Bitcoin core as a standard rule.

gotcha, I agree and updated

There are no standard rules in Bitcoin protocol, just in full node (eg Bitcoin core) implementation.

Surely, I appreciate the edits suggested.

Why is this problematic?  There are reasonably foreseeable situations where one would rationally want to send such a transaction.  Let's say I have an installment of BTC 0.001 due on a loan.  If I don't make the payment on time, it'll incur late fees and penalty interest of BTC 0.01.  So even if transaction fees are currently BTC 0.002, it would be entirely sensible for me to pay it send the transaction.  And I would be extremely upset if protocol rules wouldn't let me do it.

So I see no reason to stop someone from paying high fees if the transaction is really worth that much to them.  And in particular, I don't see why the amount of the outputs should be a special threshold.  In the example above, I would be just as eager to send the transaction for a fee of 0.0099 as for 0.0011.  It would just be a coincidence if the required fee happened to be slightly above or below the output value.

It happens with fiat money too.  Currently my credit card company owes me $1.29.  They are going to mail me a check, for which the postage and printing costs will almost surely exceed $1.29.  It may be silly, but I'm legally entitled to that money, and they've got to get it to me somehow.  Should the postal service refuse to accept the envelope for mailing?

At the wallet level
Nothing prevents wallets from implementing reasonable safety measures to protect their users from undesirable behavior.
Bitcoin Core for example has a feature to (by default) reject the creation of transactions with a very high fee value. There is no specific rule to prevent fees higher than the amount transferred, but there certainly could be. Other wallet software may have similar and/or different preventative measures.
At the policy level
Policy rules exist to protect the network, not the individual node operator. A rule to prevent too high fees doesn't belong here, as it doesn't hurt the network.
Furthermore, it is hard to imagine what such a rule would look like, because the amount paid/transferred is by design not visible in the transaction (most transactions have change that is sent back to the sender, but which is indistinguishable from the "payment" output to outsiders).
The dust relay rule is intended to disincentivize the creation of transaction outputs which would be more expensive to spend than their value. Such outputs are likely to remain unspent in the UTXO set forever, slowly accumulating and eventually increasing node operation costs.
At the consensus rule level
The same considerations apply here as for policy rules, except they need to be agreed upon by the entire ecosystem, and are such much harder to change.
So far, this has meant no rules at all that relate to fees (apart from requiring them to be non-negative). This is in part due to the fact that what is "reasonable" economical behavior may change over time, at timescales much shorter than those over which consensus rules can be adapted.

I used to think that preventing someone from sending more fees than recipient amounts would interfere with CPFP, but really that should be possible to distinguish.

"Policy rules exist to protect the network, not the individual node operator.", what about maxmempool so my node doesn't crash? or is that also to protect the network somehow

@WhoIsNinja Fair enough, I wasn't considering resource limits when I wrote that. My point was more that it would be wrong for your node to (try to) prevent another user from shooting themselves in the foot, in situations where they're perfectly capable of preventing that themselves.

that makes sense, thanks Pieter!

More importantly, rejecting transactions with a very high fee is not mining incentive compatible.

@Murch  I thought the focus of Bitcoin development is more on decentralization, rather than just miner incentive.

Luke says it's NOT difficult...
https://github.com/bitcoinknots/bitcoin/issues/74

Dynamic dust limit #74
luke-jr commented on Mar 22 •  There is now (as of 26.1) experimental
(and disabled by default) support for dynamically adjusting the "dust"
spam filter threshold. It can be enabled in the GUI, or by configuring
-dustdynamic=target:N to adjust based on a fee estimate for confirmation within N blocks, or -dustdynamic=mempool:N to adjust
based on the worst fee in the best N kvB of your mempool. In either
mode, the fee will be adjusted every 15 minutes (the first time not
for 15 minutes after startup, in an effort to ensure estimators have
sufficient data to work with). Implementation details (including how
often adjustment occurs) may be changed in future releases.

I would love to hear Murch's opinions on the functionality of this code, as it's obviously more complex than my elementary level coding proposal of
if (Tx < TxFee) {isDust = True;}
While a 4 MB block full of 330 or 546 sat Txs each with 440,000 sat TxFees would be short-term good for miners, such incessant repetition would NOT be good for the Bitcoin Monetary SYSTEM, which is much, MUCH larger than miners. The long-term view of storing & transferring value requires moving Txs that are larger than their Fees.


text:
Can a spend before a timestamp condition be put on a Bitcoin UTXO?
How to make spending conditions of a UTXO in Bitcoin such that before a particular timestamp, say t, it can be spent only in one way and, after t, it can be spent only in another way.

You can do this by creating a P2WSH output with the following script:
OP_IF
  <condition 1>
OP_ELSE
  <timestamp>
  OP_CHECKLOCKTIMEVERIFY
  OP_DROP
  <condition 2>
OP_ENDIF

Then depending on what condition you're taking you put 1 or 0 on top of the initial stack when spending.
You can also do this more privately (and in most cases cheaply) by using P2TR and splitting the two conditions into separate tree leaves. If the first condition consists of a single public key (or a set of keys that can be aggregated) you can use it as the internal key, and when you're taking that condition using the key path you don't even need to reveal a script.

@kirti-singh note that after  <condition 1> is still valid.

@bordalix True, how to make it such that after , the <condition 1> does not hold?

That's impossible. Transaction validity is by design monotonous, i.e. once a transaction becomes valid it stays valid, unless one of its inputs is spent or a soft fork activates that invalidates it. See also Antoine's answer.

It's not possible to set spend conditions which expire on a Script. It's sometimes referred to as an "inverse timelock". It is widely believed to not be desirable as a valid Script becoming invalid makes it much harder to reason about reorgs and caching.


text:
Where can I find a usefull log if bitcoind stopped for no apparent reason?
I am running bitcoind (Bitcoin Core) on a Raspberry 3B and the process occationally "disappears" from the list in top. The log debug.log shows no etries, last entry is usually something like
2019-11-08T20:21:33Z UpdateTip: new best=0000000000000000001dd32ef554a1bb9e204d6f46ab345302019412ac2f6af9 height=506280 version=0x20000000 log2_work=87.972007 tx=295647959 date='2018-01-27T01:16:11Z' progress=0.631698 cache=13.3MiB(59241txo)

What could be a reason and where could I search?
My config for my low-memory-system is:
 $ cat bitcoin.conf
daemon=1
#printtoconsole=1

# is required by Fail2Ban described below
logips=1
# magic RBP optimisations
maxconnections=40
maxuploadtarget=5000

# running without swap
dbcache=100
maxorphantx=10
maxmempool=50

txindex=1

rpcuser=...
rpcpassword=...
rpcclienttimeout=300
server=1
#datadir=/home/bitcoin

Maybe I have a problem with my external HDD:
/var/log/kern.log shows
Nov 17 21:23:22 RPi3 kernel: [642589.539592] EXT4-fs error (device sdb1): ext4_find_entry:1455: inode #2: comm smbd: reading directory lblock 0
Nov 17 21:23:22 RPi3 kernel: [642589.539653] EXT4-fs error (device sdb1): ext4_find_entry:1455: inode #2: comm smbd: reading directory lblock 0
Nov 17 21:23:22 RPi3 kernel: [642589.539798] EXT4-fs warning (device sdb1): htree_dirblock_to_tree:995: inode #2: lblock 0: comm smbd: error -5 reading directory block
Nov 17 21:23:22 RPi3 kernel: [642589.539895] EXT4-fs error (device sdb1): __ext4_get_inode_loc:4674: inode #2: block 2081: comm smbd: unable to read itable block
Nov 17 21:23:22 RPi3 kernel: [642589.539913] EXT4-fs error (device sdb1) in ext4_reserve_inode_write:5883: IO failure
Nov 17 21:23:22 RPi3 kernel: [642589.539932] ------------[ cut here ]------------
Nov 17 21:23:22 RPi3 kernel: [642589.539953] WARNING: CPU: 0 PID: 29585 at fs/fs-writeback.c:2238 __mark_inode_dirty+0x2f4/0x408
Nov 17 21:23:22 RPi3 kernel: [642589.539959] bdi-block not registered
Nov 17 21:23:22 RPi3 kernel: [642589.539967] Modules linked in: fuse rfcomm bnep hci_uart btbcm serdev bluetooth ecdh_generic 8021q garp stp llc sg brcmfmac brcmutil sha256_generic cfg80211 $
Nov 17 21:23:22 RPi3 kernel: [642589.540331]  ip_tables x_tables ipv6
Nov 17 21:23:22 RPi3 kernel: [642589.540359] CPU: 0 PID: 29585 Comm: smbd Tainted: G         C        4.19.66-v7+ #1253
Nov 17 21:23:22 RPi3 kernel: [642589.540364] Hardware name: BCM2835
Nov 17 21:23:22 RPi3 kernel: [642589.540391] [<80111f38>] (unwind_backtrace) from [<8010d4b0>] (show_stack+0x20/0x24)
Nov 17 21:23:22 RPi3 kernel: [642589.540410] [<8010d4b0>] (show_stack) from [<808191e0>] (dump_stack+0xd4/0x118)
Nov 17 21:23:22 RPi3 kernel: [642589.540428] [<808191e0>] (dump_stack) from [<801209c8>] (__warn+0x104/0x11c)
Nov 17 21:23:22 RPi3 kernel: [642589.540444] [<801209c8>] (__warn) from [<80120a38>] (warn_slowpath_fmt+0x58/0x74)
Nov 17 21:23:22 RPi3 kernel: [642589.540460] [<80120a38>] (warn_slowpath_fmt) from [<802dd4f8>] (__mark_inode_dirty+0x2f4/0x408)
Nov 17 21:23:22 RPi3 kernel: [642589.540477] [<802dd4f8>] (__mark_inode_dirty) from [<802c8434>] (generic_update_time+0x8c/0x100)
Nov 17 21:23:22 RPi3 kernel: [642589.540493] [<802c8434>] (generic_update_time) from [<802ca614>] (touch_atime+0xc8/0xe4)
Nov 17 21:23:22 RPi3 kernel: [642589.540510] [<802ca614>] (touch_atime) from [<802c0138>] (iterate_dir+0xf8/0x160)
Nov 17 21:23:22 RPi3 kernel: [642589.540528] [<802c0138>] (iterate_dir) from [<802c0728>] (ksys_getdents64+0x98/0x140)
Nov 17 21:23:22 RPi3 kernel: [642589.540544] [<802c0728>] (ksys_getdents64) from [<802c07e8>] (sys_getdents64+0x18/0x1c)
Nov 17 21:23:22 RPi3 kernel: [642589.540560] [<802c07e8>] (sys_getdents64) from [<80101000>] (ret_fast_syscall+0x0/0x28)
Nov 17 21:23:22 RPi3 kernel: [642589.540568] Exception stack(0x81adffa8 to 0x81adfff0)
Nov 17 21:23:22 RPi3 kernel: [642589.540579] ffa0:                   017bc2b8 017bc2d8 00000021 017bc2d8 00008000 00000000
Nov 17 21:23:22 RPi3 kernel: [642589.540592] ffc0: 017bc2b8 017bc2d8 017bc2bc 000000d9 017bc2b8 7eae92e0 017b5db0 76d6c534
Nov 17 21:23:22 RPi3 kernel: [642589.540601] ffe0: 76dfaf58 7eae91b0 76237474 762373a8
Nov 17 21:23:22 RPi3 kernel: [642589.540609] ---[ end trace 0aca54ceb067b5f8 ]---
Nov 17 21:23:22 RPi3 kernel: [642589.541693] EXT4-fs error (device sdb1): ext4_find_entry:1455: inode #2: comm smbd: reading directory lblock 0
Nov 17 21:23:22 RPi3 kernel: [642589.541744] EXT4-fs error (device sdb1): ext4_find_entry:1455: inode #2: comm smbd: reading directory lblock 0
Nov 17 21:23:22 RPi3 kernel: [642589.541881] EXT4-fs warning (device sdb1): htree_dirblock_to_tree:995: inode #2: lblock 0: comm smbd: error -5 reading directory block
Nov 17 21:23:27 RPi3 kernel: [642594.368519] [UFW BLOCK] IN=eth0 OUT= MAC=b8:27:eb:3d:f7:ef:00:04:20:1e:dd:54:08:00:45:00:00:28:31:d9:00:00:40:06:fe:7c SRC=192.168.100.128 DST=192.168.100.16$
Nov 17 21:23:27 RPi3 kernel: [642595.072268] jbd2_journal_bmap: journal block not found at offset 13813 on sdb1-8
Nov 17 21:23:27 RPi3 kernel: [642595.072290] Aborting journal on device sdb1-8.

also there is an issue with a timeout waiting for hardware interrupt but I don't know anything about it, except there seems to be a related Github issue:
Nov 18 09:51:04 RPi3 kernel: [687451.651659] mmc0: timeout waiting for hardware interrupt.
...
Nov 18 10:22:42 RPi3 kernel: [689349.901550] [c03fe701] PRD3 b5880284 0
Nov 18 10:22:42 RPi3 kernel: [689349.901557] [c03fe702] PDM> b9738fa0 0
Nov 18 10:22:42 RPi3 kernel: [689349.901565] [c03fe703] REQ< b9738ec0 10801
Nov 18 10:22:42 RPi3 kernel: [689349.901572] [c03fe704] CMD< 17 8
Nov 18 10:22:42 RPi3 kernel: [689349.901580] [c03fe708] FCM< b9738ec0 b9738f04
Nov 18 10:22:42 RPi3 kernel: [689349.901587] [c03fe70b] RSP  900 0
Nov 18 10:22:42 RPi3 kernel: [689349.901595] [c03fe70b] CMD< 12 929e08
Nov 18 10:22:42 RPi3 kernel: [689349.901603] [c03fe70d] CMDD 8 200
Nov 18 10:22:42 RPi3 kernel: [689349.901610] [c03fe70e] SDMA b9738fa0 b9ebe840
Nov 18 10:22:42 RPi3 kernel: [689349.901618] [c03fe710] FCM< b9738ec0 b9738f38
Nov 18 10:22:42 RPi3 kernel: [689349.901625] [c03fe710] RSP  900 0
Nov 18 10:22:42 RPi3 kernel: [689349.901632] [c03fe711] FCM> b9738ec0 0
Nov 18 10:22:42 RPi3 kernel: [689349.901640] [c03fe711] FCM> b9738ec0 0
Nov 18 10:22:42 RPi3 kernel: [689349.901647] [c03fe711] CMD  12 200
Nov 18 10:22:42 RPi3 kernel: [689349.901655] [c03fe712] REQ> b9738ec0 0
Nov 18 10:22:42 RPi3 kernel: [689349.901662] [c0db9160] TIM< 0 0
Nov 18 10:22:42 RPi3 kernel: [689349.901676] mmc0: sbc op 23 arg 0x8 flags 0x15 - resp 00000900 00000000 00000000 00000000, err 0
Nov 18 10:22:42 RPi3 kernel: [689349.901688] mmc0: cmd op 18 arg 0x929e08 flags 0xb5 - resp 00000900 00000000 00000000 00000000, err 0
Nov 18 10:22:42 RPi3 kernel: [689349.901695] mmc0: data blocks 8 blksz 200 - err 0
Nov 18 10:22:42 RPi3 kernel: [689349.901706] mmc0: stop op 12 arg 0x0 flags 0x95 - resp 00000000 00000000 00000000 00000000, err 0
Nov 18 10:22:42 RPi3 kernel: [689349.901711] mmc0: =========== REGISTER DUMP ===========
Nov 18 10:22:42 RPi3 kernel: [689349.901716] mmc0: SDCMD  0x00004052
Nov 18 10:22:42 RPi3 kernel: [689349.901722] mmc0: SDARG  0x00929e08
Nov 18 10:22:42 RPi3 kernel: [689349.901727] mmc0: SDTOUT 0x017d7840
Nov 18 10:22:42 RPi3 kernel: [689349.901732] mmc0: SDCDIV 0x00000003
Nov 18 10:22:42 RPi3 kernel: [689349.901737] mmc0: SDRSP0 0x00000900
Nov 18 10:22:42 RPi3 kernel: [689349.901742] mmc0: SDRSP1 0x00001269
Nov 18 10:22:42 RPi3 kernel: [689349.901747] mmc0: SDRSP2 0x7fffffff
Nov 18 10:22:42 RPi3 kernel: [689349.901753] mmc0: SDRSP3 0x00024007
Nov 18 10:22:42 RPi3 kernel: [689349.901758] mmc0: SDHSTS 0x00000080
Nov 18 10:22:42 RPi3 kernel: [689349.901763] mmc0: SDVDD  0x00000001
Nov 18 10:22:42 RPi3 kernel: [689349.901768] mmc0: SDEDM  0x00010801
Nov 18 10:22:42 RPi3 kernel: [689349.901773] mmc0: SDHCFG 0x0000040e
Nov 18 10:22:42 RPi3 kernel: [689349.901778] mmc0: SDHBCT 0x00000200
Nov 18 10:22:42 RPi3 kernel: [689349.901783] mmc0: SDHBLC 0x00000008
Nov 18 10:22:42 RPi3 kernel: [689349.901788] mmc0: ===========================================

That sounds like it's going out of memory and is killed by the system. Especially on a low-memory device like an RPi3 this seems very likely.
For information on how to reduce bitcoind memory usage, see https://github.com/bitcoin/bitcoin/blob/master/doc/reduce-memory.md

I will check it. Especially the last comment regarding the Linux-specific thread thing seems interesting. I also added my config to my question since this already was a setup for a low-memory environment.

Read your kernel log.

@Anonymous You mean with journalctl -k, right? Did not find anything relevant around the time the last entry was in debug.log from bitcoind.


text:
If I install libbitcoin-explorer will it be seperate from other libbitcoin repositories?
I am installing libbitcoin-explorer on a Raspberry Pi with the ./install.sh script and I wonder if this does anything to my existing installation of libbitcoin-system.
Which files will be installed?
Also, I wonder what happened to my bitcoind process which is not visible any more under top and not accessible with bitcoin-cli. Is it possible it crashed because of the heavy load of the installation?

EDIT: Also, I did not yet succeed in running the script on my Raspberry and on a x64 architecture mini PC. Not sure if it works.


text:
Problem to link to libsecp256k1 on ARM architecture
Trying to compile with g++ -o addr 69_addr2.cpp $(pkg-config --cflags --libs libbitcoin) is getting me this error:
/usr/bin/ld: /home/pi/libbitcoininstall/lib/libsecp256k1.a(libsecp256k1_la-secp256k1.o): in function `secp256k1_num_mod_inverse':
/home/pi/GitBen/LibbitcoinBen/build-libbitcoin/secp256k1/src/num_gmp_impl.h:128: undefined reference to `__gmpn_gcdext'
/usr/bin/ld: /home/pi/libbitcoininstall/lib/libsecp256k1.a(libsecp256k1_la-secp256k1.o): in function `__gmpn_sub':
/usr/include/arm-linux-gnueabihf/gmp.h:2190: undefined reference to `__gmpn_sub_n'
/usr/bin/ld: /home/pi/libbitcoininstall/lib/libsecp256k1.a(libsecp256k1_la-secp256k1.o): in function `secp256k1_num_set_bin':
/home/pi/GitBen/LibbitcoinBen/build-libbitcoin/secp256k1/src/num_gmp_impl.h:49: undefined reference to `__gmpn_set_str'
/usr/bin/ld: /home/pi/GitBen/LibbitcoinBen/build-libbitcoin/secp256k1/src/num_gmp_impl.h:49: undefined reference to `__gmpn_set_str'
/usr/bin/ld: /home/pi/libbitcoininstall/lib/libsecp256k1.a(libsecp256k1_la-secp256k1.o): in function `secp256k1_num_get_bin':
/home/pi/GitBen/LibbitcoinBen/build-libbitcoin/secp256k1/src/num_gmp_impl.h:34: undefined reference to `__gmpn_get_str'
/usr/bin/ld: /home/pi/libbitcoininstall/lib/libsecp256k1.a(libsecp256k1_la-secp256k1.o): in function `secp256k1_num_set_bin':
/home/pi/GitBen/LibbitcoinBen/build-libbitcoin/secp256k1/src/num_gmp_impl.h:49: undefined reference to `__gmpn_set_str'
/usr/bin/ld: /home/pi/GitBen/LibbitcoinBen/build-libbitcoin/secp256k1/src/num_gmp_impl.h:49: undefined reference to `__gmpn_set_str'
/usr/bin/ld: /home/pi/libbitcoininstall/lib/libsecp256k1.a(libsecp256k1_la-secp256k1.o): in function `secp256k1_num_get_bin':
/home/pi/GitBen/LibbitcoinBen/build-libbitcoin/secp256k1/src/num_gmp_impl.h:34: undefined reference to `__gmpn_get_str'
collect2: error: ld returned 1 exit status

Why is there a reference to the build-libbitcoin directory?
I installed libbitcoin in /home/pi/libbitcoininstall and the other directory is just the git where the automatic install script placed all the files.
So, this process should be finished. Why do I even get a print with that directory?
The installation went without error.
I am doing this on a Raspberry (should it matter?)
The small program I try to compile is from a textbook:
#include <bitcoin/bitcoin.hpp>

int main()
{
  bc::ec_secret secret;
  bool success = bc::decode_base16(secret,"038109007313a5807b2eccc082c8c3fbb988a973cacf1a7df9ce725c31v14776");
  assert(success);

  bc::ec_point public_key = bc::secret_to_public_key(secret);
  std::cout << "Public key: " << bc::encode_hex(public_key) << std::endl;

  const bc::short_hash hash = bc::bitcoin_short_hash(public_key);

  bc::data_chunk unencoded_address;
  unencoded_address.reserve(25);
  unencoded_address.push_back(0);
  bc::extend_data(unencoded_address, hash);
  bc::append_checksum(unencoded_address);
  assert(unencoded_address.size() == 25);
  const std::string address = bc::encode_base58(unencoded_address);

  std::cout << "Address: " << address << std::endl;
  return 0;
}

how you have build the libsecp256k1?

It is part of the install script install.sh of libbitcoin and the developers there argued that using this is the best method to make sure an installation is done properly. See also https://github.com/libbitcoin/libbitcoin-system#building-icu-zlib-png-qrencode-andor-boost

add this to the compile command -lgmp ad rebuild the library

Could you please elaborate on the subject? Recompiling will take half a day on my Raspberry so I would like to think about it. :)

look this issue on github, inside it is the solution

Thanks. The install script is 100% automatic. I start ./install.sh and it finishes after several hours. I am not sure where to add the command. Actually, as you can see, I already appended a message to that closed issue. :)

The directories discussed in the issue you linked are probably special to this github project. I can not find them and also not the link.txt. Interestingly, I have the very same error message. Thanks for your input.

It seems like pkg-config found libsecp256k1 in the build-libbitcoin directory. which is part of libbitcoin, so they probably build libsecp25k61 there.
The reason your code doesn't compile is because your libsecp was compiled with libgmp enabled, now this is a dynamic link.
So if you're trying to create a binary here you need to add -lgmp and if it's not in your system libs you'll need to also give a location to the .so file
Another option would be to recompile libsecp with libgmp linking disabled.

Thank you very much for your effort! As I understand libsecp256k1 is a part of libbitcoin (as a fork) and thus build-libbitcoin should probably contain libsecp256k1. Also, when compiling libbitcoin-system I used --disable-shared so there should be no dynamic link, right?

I could solve the issue by using the --static attribute:
g++ -o addr 69_addr2.cpp $(pkg-config --cflags --libs --static libbitcoin)


text:
non-mandatory-script-verify-flag (Invalid Schnorr signature)

I try to put this into a Psbt:

Alice make payment to purchase an amount of BRC-20 from Bob
Bob request to inscribe a transfer of BRC-20 by using Burner account
Burner inscribe the transfer of BRC-20 and transfer to Bob
Bob transfer the BRC-20 to Alice

Bob create the Psbt and Burner account, and signed. Then send to Alice to make payment and sign.
Alice topup on price to cover all following transaction's network fee.
Issues facing now is how to get the required input utxo params from previous output?
Is this possible btw with bitcoinjs-lib or any recommend library?

I'm trying to inscribe a Transfer of BRC-20 send an amount of Bitcoin from and to a single address. Would this possible?

Yes you can pay from an address back to the same address, though obviously you need to make an allowance for a fee, so the returned amount is less or you need an extra input to cover the fee.
This is not what is implied by the error message. It is not the source of your problem creating a valid Schnorr signature.

    const script = [
        pubkey.toString("hex"),
        "OP_CHECKSIG",
        "OP_0",
        "OP_IF",
        toHexString(ec.encode("ord")),
        "01",
        toHexString(mimetype),
        "OP_0",
        toHexString(content),
        "OP_ENDIF",
    ].join(" ");
    const leafScript = bitcoin.script.fromASM(script);

I'm unfamiliar with this Javascript .fromASM function. Presumably it adds the appropriate opcodes for the implicit data pushes? For example the pubkey.toString("hex"), has to eventually be prefixed with opcode 0x20 as the opcode for pushing 32-bytes. I'd check what .fromASM produces.
I'm also puzzled by ec.encode("ord") - it seems to be converting a UTF-8 string to UTF-8 unless your source is actually in some encoding that is not a superset of 7-bit ASCII.

My understanding of the network encoding of the relevant script is at How to differentiate between BTC transactions and BRC20 transactions on a blockchain?

Thanks, I get this code from some github repo but can't find back the source. But it's alright, now just curious how Psbt work? Modify previous question as above.


text:
deriving the master public key and the btc address from seed phrase of electrum wallet
I am searching for an exact python code that can take a standard wallet seed as input and output the the root key or xpub master public key.
I had tried several codes but none of them gave me the 'exact same' xpub mpk as of the real electrum wallet. Can I get some help.

thanks to give me this website name but this might take some time to understand what all this site has to offer. I will answer the question my self I got any break through .Thanks again

iancoleman xpub doesn't match the electrum one

You cannot convert an Electrum seed phrase to a BIP39 seed phrase, because in the process of deriving the master private keys, both algorithms use a different salt. This means, you cannot use Electrum seed phrases to generate BIP39-phrase addresses.
However, it is possible to derive Electrum addresses from Electrum seed phrases even outside Electrum. There is a short guide here even though it is for testnet, it also works for mainnet just by switching the coin type.
To quote it:

Download bip39-standalone.html.

Go to line 28611 and replace "return h == nh;" with "return true;".

Go to line 28639 and replace "mnemonic" with "electrum".

Open bip39-standalone.html in your browser and paste your seed phrase.

Select "Bitcoin - Testnet" from "Coin".

In "Derivation Path", select BIP141, P2WPKH and use: m/0'/0

Note: To get P2PKH address use the m/0 path, m/0'/0 is only for Electrum's segwit P2WPKH.

the answer is correct and i also found a working tool right next to what you mention here https://github.com/FarCanary/ElectrumSeedTester

actually its js code also i am unable to extract any python code from it or interpret how the html is actually calculating in short no progress made