text:
Does potential misuse of the Blockchain enable any cryptocurrency to be ruined in the long term?
According to this article from the Guardian

unknown persons are using bitcoin’s blockchain to store and link to child abuse imagery

and

“Since all blockchain data is downloaded and persistently stored by users, they are liable for any objectionable content added to the blockchain by others. Consequently, it would be illegal to participate in a blockchain-based systems as soon as it contains illegal content,” the researchers wrote.

This as well as other possibilities (the article also mentioned distribution of malware) shows that blockchains can be used to store illegal information, making downloading and possessing it potentially illegal. While it is quite possible that blockchain users wouldn't all automatically be arrested, it provides a simple case for arrest against individuals possessing such a blockchain if needed. Therefore, the use of this technology would become a legal gamble, because investors who are not programmers or can't afford to hire some (or lawyers) would face a certain risk of imprisonment, at least in some countries.
Does this mean that most or all current cryptocurrencies could become potentially illegal/useless?
This question is different from that one because I focus on the legal implications of end users. While a company that unintentionally hosts illegal material may be protected by ISP-like laws in the U.S., users of the blockchain provided by the company can basically come from any nation of the world, and in some the mere possession of illegal material in digital form by private people is forbidden (e.g. the Guardian article explicitly lists Germany, the U.K. and the U.S. as such nations). The accepted answer in the other article also seems to assume that illegal content could be detected before it is downloaded, which is simply not true. The assumption we have to make here is that by using the service the user unintentionally downloads illegal content.
The reason I ask this here instead of Law.SE is simply because I thought it would be more on-topic here, be of high interest for the community of this site and surely someone law-experienced is also found here. It would also be interesting to hear the opinion of people which may make more or less a living of this technology or are about to and the opinion of people who have a deeper understanding of the financial markets.

@NateEldredge I just noticed that the other question is only about Bitcoin and concentrates on the legality of the company rather than the legal issues for users using this service.

The usual convention on SE is that if your question was previously asked, but the answers are unsatisfactory, you can leave comments on the previous question, or start a bounty, but you should not ask a new question.  It seems to me the other question does ask exactly your question: "Would it be possible to make using Bitcoin illegal...?"  And I don't see any reason to think that other currencies would be treated any differently from Bitcoin.

@NateEldredge Other currencies could be treated differently alone when their companies are not located within the jurisdiction of the U.S., which was an important fact for the accepted answer.

I don't understand the reference to "companies" at all.  Bitcoin doesn't have a company.  There's a nonprofit foundation which attempts to propose standards and offer guidance to users, but it doesn't "own" the currency - there is nothing to own.

@NateEldredge As far as I know, there is a transaction cost for bitcoin and that money has to go somewhere. There are servers hosting the blockchains for others to download that belong to someone. I have little idea how Bitcoin works, but you are free to replace "companies" by "server owners". Makes one wonder if the U.S. ISP laws apply for them, too. It doesn't matter for my question anyway since I'm interested in end users.

Transaction costs go to miners, who can be anybody in the world with appropriate hardware.  The blockchain is downloaded in a peer-to-peer fashion.  One of the major design goals of Bitcoin is decentralization - that no single organization should control it.  And I think you may have a hard time making sense of any answers you get without first having a clear understanding of how the technology works, and how it is (and isn't) controlled.

@NateEldredge But I'm quite willing to learn and please don't make this Bitcoin-specific. When a government releases a crypto currency (as it recently happend), your argument doesn't apply anymore. In addition, P2P makes even less sense of the answer in the other question and distributing illegal material over there would incriminate the sender and the receiver in some countries. That is worse than distributing pirated games by P2P. But I enjoy the irony of the situation being worse than I originally thought.

@SK19 keep in mind that it is possible to encode illegal images/data into just about ANY data structure. A blockchain is a data structure that is downloaded and stored redundantly many times, so I think it is an easy target to point to and say "that contains illegal data!". Consider this: what if a malicious actor injected an obscure encoding of illegal data into a popular website's html code? Everyone accessing that site would unknowingly download the data, even if they don't know it/can't see it. As mentioned in the answer on the linked question, intent is probably important here.

@chytrik I am aware of this. Here browser technology comes into play and can make a difference (which doesn't apply to the crypto currency): There are rulings (e.g. in Germany) that make a difference if you just merely "watched" something through your browser (thus caching it temporarily on your computer to be automatically deleted) or if you actively downloaded it or copied it from the cache. As the article stated, there are no rulings yet for blockchains. I'm asking how negative rulings would influence crypto currencies using blockchains. Would they be avoided? What about assets?

@SK19 I think you misunderstood me, I didn't mean that the illegal image would be automatically presented to the user, just that it would be loaded quietly in the backend. If the user knew about it, and had an application that could extract and interpret that data, they could view the illegal image. This is a different situation than streaming vs downloading pirated content, in that the user does not necessarily know the illegal data is there/have no intent to access it. In general though: in regards to your Q, obviously a negative ruling not be a good thing for cryptocurrencies.


text:
Where can I Buy any Single Pizza Using Bitcoins?
I would like to purchace this notorious Pizza that is talked about , I would like that the bitcoin not be a come-on for a coupon for a pizza, but an actual pizza that I can eat?
Can I buy a Pizza directly and wholey without any additional cash or credit added  with a Bitcoin?  or only a virtual emptyness in my virtual stomach?

Related question: http://bitcoin.stackexchange.com/questions/2089/where-can-i-go-to-find-a-list-of-merchants-who-accept-bitcoins

You could just use pizzaforcoins.

conversion site with come-on.  I get Spam from them, I wanted a Pizza ""•We may periodically send promotional emails about new products, special offers or other information which we think you may find interesting using the email address which you have provided.""

oh i see didn't know that...well my offer still stands lol

And you still  deserve an up-vote, if only I could up-vote.  Because you did indeed find a place where I could convert hours and hours of GPU use into a delivered pizza.  Which sounds rather tempting, even with years of unwanted spam added to the mix. :-)  Uhh THANKS

Unless you know a local restaurant that accepts bitcoins directly, you will have to use a service, such as pizzaforcoins, which will basically accept your bitcoins and then order the for you.
There are a few restuarants, such as lean crusts in Brooklyn which directly accepts bitcoin, so you should google for restaurants in your area.
Hope that helps!

There are some order-services like Foodler which allow you to pay with bitcoin for food. Whether there is a brick and mortar store in your vicinity that directly accepts bitcoin for pizza is hard to tell without knowing your location.
You could try to see by looking through one of the lists of places that accept bitcoin such as found at https://en.bitcoin.it/wiki/Trade#Consumables or spendbitcoins.com

source: Stack Exchange

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

sort: votes


text:
How to obtain the private key of an Armory wallet?
I have a paper backup, a digital wallet backup and all the passwords: how do I retrieve the private key for a watch-only wallet so I can send some coins out of it (created in armory and imported into, for example, blockchain.info)?
If that's not possible, is using passphrase from within armory the only way to send coins out of an armory watch-only wallet?

This is how you obtain the private key for an Armory wallet:
In Armory-Qt, click on Wallet Properties (or in the newer versions, double click on your wallet to open your Wallet Properties), then click Backup this wallet>See other backup options>Export Key Lists then click the button Export Key Lists. Enter your passphrase and Armory will show your wallet's list of public addresses and private keys. If you are --offline or didn't download the blockchain, the list may be empty (Armory thinks no addresses were used), but checking "include unused" will allow you to see the entire list. Note that a watch-only copy of a wallet uses the same private key as the original wallet it was created from.
This is useful if you want to send coins from an Armory wallet without using Armory, for example from an armory wallet address you imported into blockchain.info. In order to do so, you need to enter into the chosen service the private keys to the wallet you want to send from. In the case of BlockChain.info, the key it accepts is the one in PrivHexBE format, after you remove the spaces.
Word of caution: after you enter a wallet's private key into any online service that wallet is no longer secure. You should considering transferring all the coins it holds out - do not use that wallet again.

That option doesn't seem to exist in the latest version : /

NM, figured it out and updated the answer to be a little clearer

Used this to move keys into Electrum. Some addresses i had to use "include unused" to find some keys even though was up to update on client.

You will need to import the paper backup if you wish to spend from it. Click "import" in the upper right of the window and type in the contents of your paper wallet's root key and chain code (if it has one). You'll have to wait for Armory to rescan if you're not at the lastest beta version.

seems to me that if compared to getting a new regular wallet address every time it's used, watch-only wallets add an extra layer of inconvenience with no extra safety.

Do both the root key and the chain code look the same (about a dozen four letter words each)?

The intention of Armory is that you have a completely separate computer that never touches the internet containing the non-watchonly wallet, and you ferry transactions between the two using a USB drive. It's extremely high security if done properly, but incredibly inconvenient.

Yes, the root key and chain code are two lines of 4 character keys. Armory will try and correct any typos you make, but try to have them as correct as possible, and verify that the wallet ID matches that of your paper backup.

Unfortunately, (it seems to me) neither the Armory paper backup nor the Export Keys does not contain the private key (only the Root key is shown)

I had to use this option right now, because I couldn't handle my armory wallet. With my blockchain.info wallet, in order to send BTCs from my 'watch only' armory wallet to my blockchain.info wallet I had to use as private key the string for the PrivBase58 without spaces instead the PrivHexBE. Hope that helps
BR P

worked for me in Armory 0.93.3 on a Mac:
Backup this wallet >
See other backup options >
Export Key Lists

While this sounds like a valid answer, it would be helpful if you clarified whether this worked for watch-only addresses and added a little more explanation in general.

I was using a regular address, not watch-only

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


text:
What would be the value of Bitcoin if coin generation was complete and Bitcoin was strongly accepted today?
Bare with me for a moment during this thought experiment. Currently, there is about $1.18 trillion US dollars in circulation at the moment. With that said, my one dollar bill currently represents about 1.18 trillionth of the US economy.
It is estimated that the last block to generate coins will be generated in the year 2140. At that time, there will be about 21 million bitcoins in circulation. And thereby, my one bitcoin would represent about one 21-millionth of the bitcoin economy.
Now let's say the following were true today:

Bitcoins have been completely generated
There is about 21 million bitcoins in circulation
There is about $1.18 trillion US dollars in circulation
Bitcoin is as widely accepted as a form of currency as the US dollar
The strength of the US dollar is on par with Bitcoin

Due to the large amount of circulated dollars compared to the amount of circulated bitcoin, can we assume that 1 BTC would be similarly valued at one 21-millionth of the $1.18 trillion circulated US dollars? This would equate to around $56,000. I know a lot is being assumed here, but does anyone see any major flaws in this logic?

If it so happens that bitcoins are as widely accepted as USD are today, then yes that's a roughly reasonable estimate.
You might enjoy the following link for some more thoughts along these lines:
http://falkvinge.net/2013/03/06/the-target-value-for-bitcoin-is-not-some-50-or-100-it-is-100000-to-1000000/
(One side note: just because new bitcoins are slated to stop being created in 2140, that doesn't mean no more new blocks will be created. Blocks are essential to record transactions, and they'll continue being appended to the blockchain even after the bounty drops to 0.)

You are forgeting the rest of the world, bitcoin isn't just for the US.  You are also assuming that the current number of USD in circulation will be the same in 2140 when bitcoin maxes out.  In all probability, if the dollar still exists at all then, the dollar supply will have been inflated somewhere just shy of infinity. You are also only considering M0 dollar supply, if you include M1, M2 and the rest then the supply of USD is 10X your number.
In short $56,000 / btc is a massive *under*estimate.

Not sure I follow you. I realize that Bitcoin is an international currency. But you seem to assume that Bitcoin will replace all currency in the global economy.  Additionally, you imply that the USD (and other national currencies) will be worthless by 2140 and only Bitcoin will prevail. With that, governments would be powerless. A far more likely scenario would be that Bitcoin becomes a major player in the global economy just as the US dollar, the Euro, or any other major currency are today.


text:
Why the address changes after each transaction?
Could you please help me understand these observations related to Bitcoin transaction?
I have setup a brand new wallet from scratch and I sent 0.0246 BTC to it (well, slightly more but after the fees are deducted, that is the amount I see in my wallet). So it looks like this.
(Bunch of other addresses here) => 14xEotnA... 0.0246 BTC

That one on the right side being my wallet.
Then I have sent 0.0125 BTC to a friend, and this is what I see:
(My address) => 1PkhkZ...  0.0125
                1MRQY...   0.0119056 BTC

So that second bit shows how much is left in my wallet, but the wallet address is now a totally different string?
UPDATE:
Yes, this is a duplicate. The answer suggested at the top of the page is a valid answer and was helpful.

Note: a wallet is a collection of addresses. A good wallet will create a new address for very transaction.

So at the end of each transaction, the current wallet goes to zero and all the rest of the funds that were not sent will appear in a new address?

@symbolix a transaction will spend one or more UTXOs (and each one is spent entirely, you cannot only spend half a UTXO, etc). Any excess BTC beyond what was transacted is sent to a new address, called a change address.

But that address is just a variant of our original public address? Can I reuse the old address?

it is not a ‘variant’, it is a new address. You can reuse the old address but this is highly discouraged for privacy reasons, and for security reasons as well (though perhaps less pertinently). A good wallet will automatically give you a new address for every transaction.

Ok. I understand now. Everytime I send BTC to someone my funds keep moving to new addresses (the change). What about receiving? Me receiving address is changing again in that case? What if someone sends me BTC to one of the previous addresses?

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


text:
Does a 2009 node sync the whole bitcoin blockchain
So does a 2009 node sync the whole bitcoin blockchain and does the temporary split of 2013 have any impact on that?

In theory it can as the explicit consensus rules have not changed. However in practice, it will not be able to sync without some special modifications.
First of all, the network version is so old that no modern node software will accept connections from it. Furthermore, the format of the network messages has changed since the first release so that it now contains a checksum of the message. The first version of the Bitcoin client did not have a checksum for messages. This difference in the network protocol will result in messages that do not make sense to either node in a connection.
In addition to the network message change, the original Bitcoin client will be unable to find nodes to connect to. It was only able to connect solely through using IRC node discovery which has since been disabled and removed. So you will need to specially construct the peers.dat file so that it will be able to find a peer to connect to.
Lastly, the original Bitcoin client will be unable to sync past the 2013 fork unless the number of BDB locks is increased. Using the default settings, it will run out of locks when it reaches around that time and thus fail to sync.
If you can to avoid all of these issues (e.g. by using a special node software specifically to sync off of) and increase the number of BDB locks, then the original Bitcoin client should be able to sync the current blockchain, albeit very slowly and possibly never be able to sync to the tip. Towards the current tip of the blockchain, it will probably take longer to validate a block than it takes for a new block to be found.

Several months ago I modified a version of Bitcoin Core to be compatible with Bitcoin 0.1.0 and to then try to sync it. The code for that is here. I stopped that experiment after a few days when it was able to only sync ~25,000 blocks.

(yes/no/sort of... see better answer by Andrew Chow)
Yes, it will sync. Although it will be really slow as the blockchain is pretty big these days and the code wasn't as well optimized back then.
The 2013 event won't have any effect as it will sync with the longest (most work) chain.

Actually, it won't, but for a stupid reason. Checksums were introduced in the P2P protocol in v0.2.10 (June 2010), and in 2012 the no-checksum support was removed. You will need some node from between those dates to act as a bridge between the two.

The 2013 hard fork will still cause a problem because not enough BDB locks are available to the original Bitcoin client.

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


text:
blockcypher shows much higher amount transacted
I sent bitcoin from my localbitcoins.com account to my coinbase.com account. It showed up as 0.00147276 BTC in coinbase but the transaction shows as 0.953 BTC on blockcypher:

Is there a way for me to actually receive that amount?
Thanks

This is a very vague question, you’re going to need to provide more details on the tx. If you are not the rightful owner of the 0.95.. btc, why do you think you should receive it?

I sent bitcoin from my localbitcoins.com account to my coinbase.com account. It showed up as 0.00147276 BTC in coinbase but the transaction shows as 0.953 BTC on blockcypher.

It sounds like you withdrew 0.0014.. btc, not 0.953 btc. The reason you’re seeing the larger amount reported is that the tx localbitcoins sent to coinbase likely paid out to multiple users, your payout bundled with some others, for efficiency. If your coinbase account was credited with the proper amount (0.0014..btc), then no, there is no way to claim the larger amount transacted.

Oh. All of my other transactions displayed correctly on blockcypher. I didn't know it could clump together my transaction with other people's so I was super excited that some kind of mistake was made and I'd be receiving more bitcoin than what I sent. :/

There are other possibilities too (such as localbtc spending a large utxo to pay you out, with the majority being sent to a change address), but without more details I wouldn’t be able to tell you for sure. Don’t feel bad, btc works in ways that are a little different than people are used to, and you’ll never learn if you don’t ask :)

I sent a lot of bitcoin to the silk road just a few hours before it got shut down years ago, I obviously didn't get any of my bitcoin back. So when I transferred my whole balance from localbitcoins to coinbase I was hoping that some of those lost bitcoins made their way back to me.

I am making the presumption that localbitcoins.com does as many web wallet providers do, amalgamate transactions.
Most likely your transaction was combined by the wallet provider with some others before being broadcast. No, you cannot claim the additional value of the transfer.


text:
How to get sending address of a deposit using coinbase api
I am trying to integrate the Coinbase API to my website. I need to communicate with Coinbase's wallets (bitcoin, bitcoin cash etc.) programmatically. Currently I can create different wallet addresses using the API and also I get notified when buy or sell transactions happen.
But I need to know is it possible to get incoming address when a deposit occur to one of my address from outside or another account of Coinbase.

No it is not possible because to get the "sending address" because such things do not exist in Bitcoin. There is not "send from" address in Bitcoin transactions. Furthermore many transactions will "send from" multiple addresses (i.e. they have multiple inputs).


text:
how to validate rawTx in bitcoinCash
I am implementing Bitcoincash by bitcoincashjs module using Nodejs.
Referring site from below,
https://github.com/bitcoincashjs/bitcoincashjs/blob/master/docs/examples.md#create-a-transaction
In that all API's works fine but when I am trying to do transactions it returns me an rawtx string as,

01000000016889302ea03e.............................ffffffff01983a0000000000001976a914ad618cf4333b3b248f9744e8e81db2964d0ae39788ac00000000

But I want,
1) to decode this rawtx to get what actually message it returns ?
2) & how to determine the transaction is successfull or fails ?


text:
How to secure my Electrum wallet?
What I did is put a password on word document and put the seed words in there and then put the file in google drive.
I can't think of any way I can lose it. I can't think of anyone stealing the money either without knowing my password.
The Electrum wallet is also encrypted with the same password.
Are there any ways to improve my security?

What if you lose access to your google account? It happens.

Then the file is in my computer

https://en.wikipedia.org/wiki/Microsoft_Office_password_protection
Password protected word docs only use 128 AES encryption. An improvement you could easily make is upping this encryption level to 256. Another suggestion you could also PGP encrypt the seed words inside the document itself.
I also think putting this information in a cloud environment would be sacrificing security. I assuming you are counting on google drive being around in the event of your hard-drive crashing. Unless you need this information on the go though I would think writing the information on a piece of paper and locking that away would be more secure, depending on your locations physical security.
You should also have multiple backup points in the event of a loss, even if you are counting on google drive being there you don't want that to be a single point of failure. I would suggest at least having one paper copy and possibly a thumb-drive/DVD copy.


text:
Looking for a place to buy bitcoin with a credit card
I'm trying to find a fast, reliable and secure place/service I can buy Bitcoins using a credit/debit card.
I googled and saw a few websites but most are a little sketchy and the rest don't seem to accept cards anymore.
Any suggestions?

We would need to know what country you are in to be able to suggest an appropriate place.

I'm currently in Brazil but i have international credit/debit cards.

To understand why people are reluctant to accept cards when selling bitcoin, see http://bitcoin.stackexchange.com/questions/3952/why-is-bitcoin-so-susceptible-to-credit-card-fraud?rq=1

Thanks that was really helpful. It makes a lot of sense... even though i would still prefer to buy with a prepaid credit card... that way i dont have to use my bank info etc online.

you can try Cubits, they are Bitcoin payment processor based in UK and Germany.

I love using https://localbitcoins.com/, a buyers and sellers marketplace. The range of payment types you can use are amazing. (I.e.: cash, PayPal, direct deposit, credit card, etc)

I've tried few places and by far http://247exchange.com is the best - their fees are reasonable, the process is quite simple and although I had to verify myself it was quite fast and easy

Try CoinCorner - all major credit cards and debit cards accepted.

Circle.com Is a great place to buy bitcoin via credit card

authors: ธัชชัย บุญภาย


text:
Bitcoind stopped working
Hello i have been running Bitcoind and Dogecoind for more than 2 month and all has been working great but today bitcoind has stopped working
I am receiving the error:
Warning: fopen(http://...@127.0.0.1:3333/): failed to open stream: Connection refused
Fatal error: Uncaught exception 'Exception' with message 'Unable to connect to http://bitcoin:pass@127.0.0.1:3333/' in /script/jsonRPCClient.php:140

I have disabled firewall but still am receiving the error
Bitcoin.conf
server=1
daemon=1
rpcuser=user
rpcpassword=pass
rpcport=3333
port=3334
txindex=1

Thanks

Any chance the port 3333 is closed? Also what happens if you try navigating to the URL that is in the error?

I switch iptables policy to ACCEPT but not work. With url i have 'ERR_CONNECTION_REFUSED' message. I tested with other port but nothing fopen(http://...@127.0.0.1:3633/): failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error  in /example.com/jsonRPCClient.php on line 132

i think the probleme is from sendtoaddress() because getnewaddress() work

Humor me and try typing "curl http://user:pass@127.0.0.1:3333/" and let me know what you receive.

There's probably something relevant in your debug.log file.  Have you checked?

Thanks for reply all, i installed new version and reindex chain and now all work fine

Problem is not stated clearly enough to be answered, also asker has resolved his problem and probably isn’t interested anymore. Placing it on hold.


text:
namecoin name_firstupdate
Hey I am trying to connect to my namecoin server. I have hosted and done the first name_firstupdate. I am using easybitcoin.php. I have stored the rnd and txid I need from the name_new step but when I execute the code the server doesn't respond with anything. I checked my namecoind name_list the domain that's being registered doesn't show up. Any help would be awesome, thank you.
http://allaboutbit.com/dotbitaddress for an example of the prior steps.
$d = 'd/';
$space = " ";
require_once('easybitcoin.php');
$bitcoin = new Bitcoin('username','password','159.206.21.47','8336');
$domainQuery = mysqli_query($conn, "SELECT domain_name from dotbitdomains WHERE status = '13'");
$domainLevel = mysqli_fetch_row($domainQuery);
            $url = $domainLevel[0];
//select rnd
$rndQuery = mysqli_query($conn, "SELECT rnd from dotbitdomains WHERE status = '13'");
$rndLevel = mysqli_fetch_row($rndQuery);
            $rnd = $rndLevel[0];
//select txid
$txidQuery = mysqli_query($conn, "SELECT txid from dotbitdomains WHERE status = '13'");
$txidLevel = mysqli_fetch_row($txidQuery);
            $txid = $txidLevel[0];
//select username
$userQuery = mysqli_query($conn, "SELECT username from dotbitdomains WHERE status = '13'");
$userLevel = mysqli_fetch_row($userQuery);
            $username = $userLevel[0];
$bitcoin->name_firstupdate($d.$url.$space.$rnd.$space.$txid);

Unfortunately you didn't provide enough information:

Which OS?
Version number of your Namecoin server?
Does this Namecoin server run on your local machine? If not, how is it connected physically?
Did you apply any command line params when starting the server?
What is the content of your namecoin.conf file?

Generally speaking, the most common causes for RPC connection problems are:

Mismatch of the provided data (rpcuser, rpcpassword, rpcport) with the contents of namecoin.conf
Command line parameter -server is missing


text:
Why doesn't Lightning have DNS bootstrapping?
Bitcoin uses a DNS-based bootstrapping mechanism to help new nodes find peers. As far as I'm aware, Lightning doesn't have such mechanism, and new users are supposed to just search for node addresses on the web (or use nodes maintained / recommended by their wallet developers, or whatever).
What is the rationale behind this design decision?

It does!
There is even a BOLT for it (check out: https://github.com/lightningnetwork/lightning-rfc/blob/master/10-dns-bootstrap.md )
from there you have the following example:
dig lseed.bitcoinstats.com AAAA
lseed.bitcoinstats.com. 60      IN      AAAA    2a02:aa16:1105:4a80:1234:1234:37c1:9c9

Christian Decker is maintaining the dns seed list. I even used this in my autopilot (the c-lightning wrapper). check out:
  def __get_seed_keys(self):
        """
        retrieve the nodeids of the ln seed nodes from lseed.bitcoinstats.com
        """
        domain = "lseed.bitcoinstats.com"
        srv_records = dns.resolver.query(domain,"SRV")
        res = []
        for srv in srv_records:
            bech32 = str(srv.target).rstrip(".").split(".")[0]
            data = bech32_decode(bech32)[1]
            decoded = convertbits(data, 5, 4)
            res.append("".join(
                ['{:1x}'.format(integer) for integer in decoded])[:-1])
        return res

    def __connect_to_seeds(self):
        """
        sets up peering connection to seed nodes of the lightning network

        This is necessary in case the node operating the autopilot has never
        been connected to the lightning network.
        """
        try:
            for nodeid in random.shuffle(self.__get_seed_keys()):
                self.__clogger.info("peering with node: " + nodeid)
                self.__rpc_interface.connect(nodeid)
                # FIXME: better strategy than sleep(2) for building up
                time.sleep(2)
        except:
            pass

Nice, thanks! So the logical continuation of my question would then be - why isn't it used as the default connection mechanism, as in Bitcoin? (Or is it? I'm experimenting with Eclair and it I don't see that option; do c-lightning or LND have it?)

That I don't know :( When you use my autopilot plugin it is being used. I guess in lightning the process is different. You only peer with a node when you want to create a channel anyway. So I guess the indirect answer is that the power of choice was left to the user

Got it! The last thing I don't quite understand is how to specify the DNS query to get a testnet node. BOLT10 says that the "realm byte" r is "used to specify what realm the returned nodes must support" with the default value of "0 (Bitcoin)", but it doesn't mention the values for other networks...


text:
Can I test Lightning on Bitcoin regtest?
I want to do some Lightning experiments, but want to avoid the burden of synchronizing the blockchain (even testnet). Can I experiment with Lightning using regtest? Is there a manual for setting it up?

Yes this is possible and (at least with clightning) very easy to do. I always use this script by Nadav Ivgi from his spark wallet. The key part is this : (MIT license by Nadav Ivgi)
$ mkdir -p /tmp/spark-env/{btc,ln1,ln2}

$ bitcoind --regtest --datadir=/tmp/spark-env/btc --printtoconsole
$ lightningd --network regtest --lightning-dir /tmp/spark-env/ln1 --bitcoin-datadir /tmp/spark-env/btc --addr 127.0.0.1:9600
$ lightningd --network regtest --lightning-dir /tmp/spark-env/ln2 --bitcoin-datadir /tmp/spark-env/btc --addr 127.0.0.1:9601

$ alias btc='bitcoin-cli --regtest --datadir=/tmp/spark-env/btc' \
        ln1='lightning-cli --lightning-dir /tmp/spark-env/ln1' \
        ln2='lightning-cli --lightning-dir /tmp/spark-env/ln2'

$ btc generate 101 && btc sendtoaddress $(ln1 newaddr | jq -r .address) 5 && btc generate 1

# wait for onchain funds to show up on `ln1 listfunds` (updated every 30s)

$ ln1 connect $(ln2 getinfo | jq -r .id) 127.0.0.1 9601 && \
  ln1 fundchannel $(ln2 getinfo | jq -r .id) 16777215 1100perkb && btc generate 1

If you use docker you can even spin up Nadavs docker image with:
$ docker run -e NETWORK=regtest -e API_TOKEN=1234 -p 9112:9112 shesek/lightning-charge

but if you want more lightning nodes fired up that already form a network you can use lnet by Christian Decker. With that script you can provide a weighed graph and get the lightning nodes as the graph defines.

Is lnet supposed to be used only with c-lightning?

I think so. But I think it would be possible to extend to other lightning implementations (: maybe you find something in the test cases of each implementation. I think I remember that a fair fraction of lnet code comes from clightning test cases.

I did some experiments with lnd in regtest mode. Just normally start bitcoind with zmq in regtest. Put the zmq connection and lnd chain mode to regtest. I will post an in-depth answer with exact configuration and commands later


text:
UTXO model vs. account/balance model
I understand that Bitcoin uses unspent tx output and Ethereum account balance based. However, recently there are lots of discussions on that Bitcoin's UTXO database has become too big. Does this mean account balance based transactions are better in scaling than UTXO based?

I dont know so much about how Ethereums account balance works. But the set of UTXO in Bitcoin may be optimized, e.g. as Peter Todd describes here: https://petertodd.org/2016/delayed-txo-commitments

The choice between the UTXO model and the balance model is primarily one between privacy incentives and apparent intuitiveness.
If one follows the standard advice of not reusing addresses/outputs/scripts, as to not gratuitously reveal which coins belong to the sender and which belong to the receiver, the two models are actually equivalent. In this case balances would be single use anyway, and there would be as many balances as there would otherwise be UTXOs, removing both the apparent size advantage and convenience.
However, the balance model effectively incentivizes reuse. As the cost to the system (possibly in fees, but certainly in node operation costs) for a balance update is lower than the creation of a new balance, such a system inherently incentives revelation of transaction sources.
And even though balances are more intuitive, they do complicate reasoning about the security of the system. One issue is the problem of replay attacks. Assume X paid Y, and Y pays Z. Now W pays Y again. In a naive implementation, Z can rebroadcast his earlier transaction from Y, and could take the money from W's payment to Y. One solution is by putting sequence numbers on balances, and requiring transactions to list the sequence number of the transactions they take money of. Unfortunately, this requires maintaining the sequence number even for balances that went to zero, meaning that the balance database needs to maintain some data for every balance that was ever nonzero; a result that's far less scalable than the UTXO model was in the first place (which can forget outputs as soon as they're spent).
In short, my view is that the balance model reduces the fungibility of the currency as a whole for a short term gain that disappears.

The balance database doesn't need to maintain the sequence number for balances that went to zero. Among other solutions, you can assign an account a pseudo-random sequence number when it's created that has to go in each transaction. There are other solutions to this problem too.

That's fair; I was only explaining how the account model introduces additional complications - several solutions are possible to it. The primary issue in my view is how accounts inherently encourage revealing linkage of transactions, which IMHO is a no-go for any currency that aims for fungibility.

@DavidSchwartz could you please explain a little more details of how "assign an account a pseudo-random sequence number" would prevent replay attacks?

If the account is re-created, it will have a new sequence number. This will make every previous transaction invalid for that account since the sequence number won't match.

This is a highly biased answer. Not that it's bad, but I'd encourage people to also read the reason Ethereum went with their model: https://github.com/ethereum/wiki/wiki/Design-Rationale#accounts-and-not-utxos They also say UTXOs support more scaling paradigms, but I've yet to find any more info on that.

In UTXO model, each transaction spends output from previous transactions and creates new output that can be spent by transactions later on operated by full nodes. Your wallet maintains a list of UTXOs associated with all addresses owned by the user, and the balance of the wallet is calculated as the sum of these unspent transactions. Take a look at this example :
A has 2.5 btc i.e. one UTXO of 2.5 btc. A wish to send B 1.0 btc. A uses 2.5 btc as input to the trxn and sends 1.0 bitcoin to B, 1.5 btc sent back to A as a new UTXO with new address. So If  B has 1 btc then total is 2 btc (sent by A) and having two UTXOs: one already of 1 btc and other one is of 1 btc by A.
Bitcoin blockchain uses this model, there is another model which is being used by Ethereum blockchain i.e. Account Model which is quite simpler than the previous model. Lets see the example :
A has 2 ethers, A wish to send B 1 ether, so the network will reduce 1 ether from A i.e. A has 1 ether now and network adds 1 ether to B. If B has 2 ethers already then total is 3 ethers.
Both models has different pros and cons.
Every transaction in account model make one output which leads to space savings. Any space savings is a benefit. As the network full nodes are meant to be operated by individuals rather then data centers the lower the data requirements the more potential participants.
But UTXO provides a higher level of privacy as the users use new addresses for each transaction and will be difficult to link accounts to each other.


text:
wireshark packet analysis missing checksum in version msg
I'm trying to send a raw bitcoin transaction through a raw socket connection in python. To debug I'm using wireshark to sniff the packets.
Wireshark figures out that the packet is for Bitcoin and that it's a 'version' message, and gets the first couple fields right, but then neglects the checksum field and instead assigns what should be the checksum to the protocol version, throwing everything else off.  I can't seem to get to the bottom of it.
Other message types, like 'tx', include the checksum but have other issues (I'll get to later).  Any ideas why wireshark isn't picking up on the checksum for the version message?

Does Wireshark correctly parse transactions sent by the standard Bitcoin client?

I think the issue might be an old bitcoin dissector, since checksums were only added into the version msg recently.  building from source now with updates dissector.  don't have the cpp-client right now so can't check.

I believe the dissector for Bitcoin is broke in Wireshark, there are more issues.

super.  is there an alternative.  how can I debug my packets?

Yes, the Bitcoin plugin for Wireshark is very old and doesn't include some types of messages. Your best bet is to just filter by the port and do the work manually, the types are identified correctly and are not encrypted so it's fairly easy going.


text:
What does score tell me in getnetworkinfo?
Using bitcoin-cli getnetworkinfo;
Or, going into Help>Debug>Console in bitcoin-qt and typing getnetworkinfo;
What does localaddresses:score tell me?

It's about the network reliability to other nodes, score keeps increasing the longer your node is reachable.


text:
error : incorrect rpcuser or rpcpassword (authorization failed)
I started bitcoind -datadir=/mnt/btc but everytime I try to use bitcoin-cli it says :

error : incorrect rpcuser or rpcpassword (authorization failed)

I can't find bitcoin.conf (neither in the default datadir ~/.bitcoin neither in /mnt/btc).
Any idea how I can generate one and if it will help the original problem ?

I was having the same problem and just managed to fix it now.
Since the file bitcoin.conf does not exist inside ~/.bitcoin, Just create one.
Here's what did:
 vi ~/.bitcoin/bitcoin.conf

Enter letter 'a' (to edit the file). Then type:
 rpcpassword=any_long_random_password

Press the ESC key, and press ZZ to exit vi
Apparently the password that bitcoind started with is (for one reason or the other) different from the one you are trying. (i also have a feeling that bitcoind misbehaves like that because no password was defined; since there was no bitcoin.conf)
Now, even though you have changed the password, it will NOT be effective until bitcoind has been re-started. But since it won't even accept the stop command (./bitcoin-cli stop) due to the authentication issue;
You will need to kill the process, and restart bitcoind. It will work fine afterwards:
pkill -9 -f bitcoind

then
./bitcoind -daemon

Hope this is helpful


text:
pyminer for getblocktemplate/segwit?
I'm trying to resurrect my simpleminer.py script, based on pyminer, for use with Bitcoin 0.13.2 but the changes to the code over the last few years are overwhelming. I found out how to use getblocktemplate using the excellent Python examples in the wiki (https://en.bitcoin.it/wiki/Getblocktemplate), but that doesn't explain what to do with the "segwit" stuff, e.g. the "default_witness_commitment" value.
can anyone point me to some documentation that has kept up with the code changes? right now it looks like I'm going to have to grok the source, and I'm not even sure I'm up to the task any more.


text:
how to insert new checkpoints in a bitcoin clone
I know Checkpoints are old blocks hardcoded into the source: What are checkpoints?
{11111, uint256S("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")},
{33333, uint256S("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6")},
{74000, uint256S("0x0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20")},
{105000, uint256S("0x00000000000291ce28027faea320c8d2b054b2e0fe44a773f3eefb151d6bdc97")},
{134444, uint256S("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe")},
{168000, uint256S("0x000000000000099e61ea72015e79632f216fe6cb33d7899acb35b75c8303b763")},
{193000, uint256S("0x000000000000059f452a5f7340de6682a977387c17010ff6e6c3bd83ca8b1317")},
{210000, uint256S("0x000000000000048b95347e83192f69cf0366076336c639f9b7228e9ba171342e")},
{216116, uint256S("0x00000000000001b4f4b433e81ee46494af945cf96014816a4e2370f11b23df4e")},
{225430, uint256S("0x00000000000001c108384350f74090433e7fcf79a606b8e797f065b130575932")},
{250000, uint256S("0x000000000000003887df1f29024b06fc2200b55f8af8f35453d7be294df2d214")},
{279000, uint256S("0x0000000000000001ae8c72a0b0c301f67e3afca10e819efa9041e458e9bd7e40")},
{295000, uint256S("0x00000000000000004d9b4ef50f0f9d686fd69db2e03af35a100370c64632a983")},

these are blocks mined by the chain right?
how can I get these blocks and insert in my next build?
what these number are?  11111, 33333, 74000
so let me understand I insert this checkpoints and rebuild the app again?
so if i insert 10 checkpoints the blockchain will start with 10 blocks mined right?
how can I get theses blocks hash?
edit:
New Proof-of-Work block found
 Block hash: 00000bbbcb87a6d709ec944f6bdccdc41a59240d27ba3bbb759ef933c93bc890
     Target: 00007fffff000000000000000000000000000000000000000000000000000000

CBlock(hash=00000bbbcb87a6d709ec, ver=1, hashPrevBlock=00000d7e8a80fec4057c, hashMerkleRoot=c5912b6765, nTime=1523401728, nBits=1e7fffff, nNonce=84537, vtx=1, vchBlockSig=3045022054f16ce64dbc74934f59bef40cc20d08d9a01ac7b43308f6aeecb9321eff56ac022100c96e1b59a7b7d4c6b2436b34f6559d24b2997fc77d7a64588b20997aa632eeb6)
CBlock General PoB(nBurnBits=1f00ffff nEffectiveBurnCoins=0 (formatted 0.00))
  Coinbase(hash=c5912b6765, nTime=1523401728, ver=1, vin.size=1, vout.size=1, nLockTime=0)
    CTxIn(COutPoint(0000000000000000000000000000000000000000000000000000000000000000, -1), coinbase 040044cd5a0101062f503253482f)
    CTxOut(nValue=42.04, scriptPubKey=0325fa33db34946070c7efb69e8fdfa74b9174e3abc2ec4232926bdf47725ac377 OP_CHECKSIG)
  vMerkleTree: c5912b6765
2018-04-10 23:08:48 UTC generated 42.04
AddToWallet c5912b6765  new
SetBestChain: new best=00000bbbcb87a6d709ec  height=1  trust=2  moneysupply=42.04 nEffectiveBurnCoins=0.00
ProcessBlock: ACCEPTED
Running  with 1 transaction in block

in my case I supose mine the coins manually, get the heigh and hash and insert in the checkpoints and rebuild the wallet right? so the wallet starts with a certain o blocks mined right?
so giving that info about will be like that?:
{1, uint256S("0x00000bbbcb87a6d709ec944f6bdccdc41a59240d27ba3bbb759ef933c93bc890")},

It's in form of
{block_height, uint256S("0xblock_hash")},

For example,
{134444, uint256S("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe")},

If you search for "00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe", that block's hash on Blockchair,
you'll find the block with the height 134444.
Simple, huh?
EDIT: Your edit is partly corrected. Note that when you add a checkpoint, you don't hardcode the block into the client. When a user opens it for the first time, they'll download all blocks starting with the first block. Checkpoints allow the clients to verify if someone who created his/her block chain completely different than the main chain is sending you the fake chain. The clients do download the whole chain and verify the blocks with checkpoints (also see: assumevalid)

yes very simple, I edit my question, can please confirm what i said make sense? thank you for you time


text:
How the process “ lock a certain amount of coins into the network as their stake” achieved technically in the Proof of stake algorithm
i am trying to understand deeper the proof of stake algorithm. i think i understand the basics but i am struggling to understand how this achieved thoroughly under blockchain network and how the nodes interact. So to get started, when a node wants to participate in the forging or minted process are required to lock a certain amount of coins into the network as their stake. The size of the stake determines the chances for a node to be selected as the next validator to forge the next block. My main question now is how this can be achieved technically.
Does every node have Deposit storage for the staked money?
Does every node propagate the staked money to the other nodes?
Let's Assume, that there are N nodes that stake money and i is the node that is selected to propose block. How this node i became known to the others (N-1) nodes (if it is possible  just don't answer me through a leader election process but how can this achieved what are the steps to figure it out).


text:
64: non-mandatory-script-verify-flag while broadcasting P2WPKH Bech32 with specific inputs

Note: This happens with specific input, even though I've used the same
  code for other inputs and it works.

I have created a raw transaction using the following unspent:
Array
(
    [0] => Array
        (
            [txid] => 108544730bfaeccca0de66eda8546a33403899fb508bee582f1d9e1628ec0695
            [vout] => 1
            [scriptPubKey] => 0014194eef88d8428a4af66177779d0844d66d743e5d
            [amount] => 0.000560
            [address] => tb1qr98wlzxcg29y4anpwame6zzy6ekhg0jadfmrgr
            [redeemScript] =>
        ) // this i'm not able to spend.

    [1] => Array
        (
            [txid] => 5bda1b65ff7cb3c80f09f797debb2bf1749d22332e984ba6377a0c7cac30aed9
            [vout] => 0
            [scriptPubKey] => 00141f09edebd56ffadd0c1834d048c8a416d5418f68
            [amount] => 0.100000
            [address] => tb1qruy7m674dlad6rqcxngy3j9yzm25rrmgm9x3d5
            [redeemScript] =>
        )

)

https://testnet.blockchain.info/tx/108544730bfaeccca0de66eda8546a33403899fb508bee582f1d9e1628ec0695
Created Transaction Hex:
02000000029506ec28169e1d2f58ee8b50fb993840336a54a8ed66dea0ccecfa0b734485100100000000ffffffffd9ae30ac7c0c7a37a64b982e33229d74f12bbbde97f7090fc8b37cff651bda5b0000000000ffffffff02404b4c0000000000160014943a52d24537d96360fb533fdc7183a92963f9c7e8c54c0000000000160014f41ddffe9582cdf5841b332f8f3751f8c1514dd300000000

SignrawTransaction Response:
Array
(
    [hex] => 020000000001029506ec28169e1d2f58ee8b50fb993840336a54a8ed66dea0ccecfa0b734485100100000000ffffffffd9ae30ac7c0c7a37a64b982e33229d74f12bbbde97f7090fc8b37cff651bda5b0000000000ffffffff02404b4c0000000000160014943a52d24537d96360fb533fdc7183a92963f9c7e8c54c0000000000160014f41ddffe9582cdf5841b332f8f3751f8c1514dd302473044022042cb0cd01181cb2ec915bd5d981dbb197d2febb8acfbeae3c653747c8cf2b4b8022001e4ee55c7daa7197b4cd0948f4fb49b7660ecedb96e08e2220422e6485a0591012102b4592cc61c94b91c866ea6201885ce41f0f9cbc4a762c614799dfb854b6e18d50247304402204b475a5a61184aa46d1db9e22797c3084d409fffe608ceedaf3b6af7e2a9c2a002206404b55c0ba8b902d4bd48db115dd7d10befdc3cab57fdb42e2631e31c35070801210387844ba61f400e181004900f1ec59a3b310e4afd9a22d51cc8bc1a6631c057f500000000
    [complete] => 1
)

Sendrawtrasnaction response: 64: non-mandatory-script-verify-flag (Signature must be zero for failed CHECK(MULTI)SIG operation)

I've spent the second input but not the first one.

First of all, these are not P2SH-P2WPKH, these are normal P2WPKH outputs. They are not related to P2SH at all.
The problem here is probably that the amount is incorrect. If you are providing the previous output data yourself, then the amounts is incorrect. You have it as 0.000560 but the actual amount is 0.00055999. Since Segwit commits to the amount in the signature, having the wrong amount means that the signature signrawtransaction creates will be invalid which thus results in this error.

Thanks for taking time looking into that, I have fixed the amount and it did work.


text:
Bitcoin core - Listtransactions doesn't show fee of received transactions
I'm using bitcoin core full node on ubuntu. When I call listtransactions some transactions coming up with no fee key.
  [8] => Array
    (
        [account] =>
        [address] => 1MTLEprpnQwLHMeYh51CQrCWxSuZPGSZ6T
        [category] => send
        [amount] => -0.0028107
        [vout] => 0
        [fee] => -1.13E-5
        [confirmations] => 0
        [trusted] => 1
        [txid] => 6c74d8ac3b9b57184ed5dff72d48474c5ecf8dac4ec9388cb0ff33bf8e3bfcbc
        [walletconflicts] => Array
            (
            )

        [time] => 1511008107
        [timereceived] => 1511008107
        [bip125-replaceable] => no
        [abandoned] =>
    )

[9] => Array
    (
        [account] =>
        [address] => 12zJ7ZbDW59mmNBPrxBAEjtWf8JzwgLNum
        [category] => receive
        [amount] => 0.00240164
        [label] =>
        [vout] => 0
        [confirmations] => 0
        [trusted] =>
        [txid] => 25d0812c7dcf3c938430dc5c61566b8346b6e6d300b1e3cd3fc7d4031eb93cbe
        [walletconflicts] => Array
            (
            )

        [time] => 1511010977
        [timereceived] => 1511010977
        [bip125-replaceable] => no
    )

)
Transaction on blockchain: https://blockchain.info/tx/25d0812c7dcf3c938430dc5c61566b8346b6e6d300b1e3cd3fc7d4031eb93cbe
I have read that just now on bitcoin.org,

If sending payment, the fee paid as a negative bitcoins value. May be
  0. Not returned if receiving payment or for move category payments

Which answers my question, but now i'm wondering how to get the fee of received transaction.

To find the fee of the transaction, you need to know the value of the inputs and outputs and find the difference between those two values.
Unfortunately this is much more difficult for receiving transactions, because by default bitcoin core only holds the information for transactions which are related to your wallet, not all transactions (this can be enabled with txindex=1 argument).
What this means is that, to find the fee for a receive transaction, you can call getrawtransaction "txid" true with the txid you obtain from listtransactions. The last argument, true is set to make the output "verbose" so that it includes more information about the transaction than just the hex encoded transaction itself. It will return a JSON object with vin and vout arrays which you can iterate over. You can simply sum the output values. The trouble is finding the input values. Input values are not given in transactions, so you must look them up individually. This is a problem for receiving transactions because the transactions they spend from are usually unrelated to your wallet and thus cannot be looked up without txindex=1.

You are right, The trouble in here finding the input values!! How does blockchain.info and other chains get these info?

I assume blockchain.info and similar sites use their own databases of information rather than querying it from a node every time

Yeah I guess they update each new transaction to their database.


text:
What happens in an extreme case if Ripple fails to make a consensus? Will that part of the network be segmented off?
What if the Ripple trust network becomes many trust hubs and spokes, and the hubs don't trust each other?
In this extreme case, that could exist due to extreme network segregation, massive trust-mismanagement, or something to this effect...
Is the likely outcome that two hubs will be created, double spends would be possible, and it would be difficult or impossible to recombine the networks?

This is probably answered on the consensus wiki page.

If everyone chooses a completely disparate sets of validators the network will be unlikely to reach consensus that a particular version of the ledger is the one true and accurate ledger. But, in practice, people's UNL lists will overlap. This overlap causes the honest validators to come to the same consensus.
Every honest user of the system wants the system to reach a consensus. Validators will choose which other validators they trust specifically because they also wish to reach a consensus. Essentially, all honest users of the system cooperate to ensure a consensus is reached and maintained. And, of course, a lack of consensus is easily detectable.
To achieve unique node list:
The validators run Ripple nodes which process validations on their behalf. The list of validators that we trust not to collude to defraud us is called our Unique Node List (UNL).
For stronger assurance that something is true, we add more validators to our UNL. For example, we could add Itchy and Scratchy. Who are also not very trustworthy, but are also unlikely to collude to defraud us.

If we replace if everyone choose different sets with clusters of people choose the same different sets, what is the impact on consensus? Is that possible? If it's possible, is it a good idea?


text:
How to accept payments via Ripple on a website
A web search led to Ripple.com.
Is it possible to add the payments via Ripple payment to an e-commerce website?
Where can i find source code to implement such Ripple payments?
For example, there are few websites which offer payment via Ripple such as PrivateInternetAccess.

You may want to start with https://ripple.com/partners/#merchants or https://ripple.com/merchants/. And then move on to https://ripple.com/wiki/Main_Page#Merchants

@dchapes But what if the merchant's goods is the curency? Similar to bonus systems some merchants offer. Then the merchant should act as gateway, shouldn't they? And redeem real goods for their IOUs. And their IOUs can be traded by other people for other currencies, the price depending on how much the goods from this merchant are wanted, and how much they trust the merchant (that the merchant will keep the promise). I believe this is possible with ripple, and also looks like an interesting system.

@imz--IvanZakharyaschev it sounds like you're talking about something like gift cards redeemable at purchase time. If so, with Ripple a merchant can just accept their own issued USD (or whatever unit/name they want to use) and just arrange to distribute/give/sell those. Unlike physical gift cards, Ripple makes it easy for others to trade/sell these. For further discussion on such things I'd suggest ripple.com/forum as SE comments aren't the best place for discussions.

@dchapes Yes, "gift card" is a good word for what I meant. I see now the option that you mentioned: accept their own issued USD. The option I thought about was like nominating the currency in the kind of goods one will be able to redeem: e.g., a promise to give 1 kg of potatoes or 1 Gb of network storage in exchange for the "gift card". Then we let the market determine the price for our goods...

There are some existing sources of information for merchants wishing to use Ripple:

Brief introduction and overview of Ripple for merchants
Merchant's section/pages on the Ripple wiki

If you are looking for something pre-implemented and easy to add to an existing automated web commerce check-out page, there isn't much available along those lines at the moment. Ripple is still in beta and the server and client code still appear to be the focus of attention. However, there has been a recent small bounty offered for the community to develop shopping cart plug-ins that use Ripple.
It's easier for sites that have a manual check-out process as they can just add a Ripple URI for customers to use and the merchant can manually check for received payments with the existing Ripple client (or use a third party tool such as wasipaid).
The basic process for a merchant to use Ripple is:

Create a Ripple address to receive funds (one time setup).
Create payment paths in Ripple for the funds you wish to receive (e.g. trust a gateway for USD or EUR, etc) (one time setup).
Supply a Ripple URI, possibly with a nice "Pay via Ripple" button that customers can use to initiate Ripple payments with their Ripple client. This can use a unique "destination tag" and/or "invoice ID" to distinguish individual Ripple payments. The Ripple client will offer the customer payment options using whatever assets they have for which it can find a payment path.
Manually or automatically watch for updates to the Ripple ledger to detect when payments are made. Make sure to handle partial payments (e.g. update a balance payable field) and to handle over-payments (e.g. return the excess, since Ripple payments are non-reversible and a reverse path may not exist for the currency being used this can be non-trivial). This is the "big" step where automation or plug-ins would be helpful, especially in handling all the corner cases.
Release/ship the thing being sold.
Periodically extract the received funds via Ripple, e.g. withdraw your balance in Ripple through a gateway into a bank account. Alternative, use the funds within Ripple.

can u please provide an example code for ripple URI

From the description of ripple, I believe that an unusual system of payments for merchant's goods is possible, not quite like the ususal one in a fixed currency.
(So here I'll describe this interesting system, leaving the answer concerning organizing a traditional payment system for a customer to other people.)
What if the merchant's goods is the curency? Similar to bonus systems some merchants offer. Then the merchant should actually act as a gateway (shouldn't they?), and redeem real goods for their IOUs. And their IOUs can be traded by other people for other currencies, the price depending on how much the goods from this merchant are wanted, and how much they trust the merchant (that the merchant will keep the promise).
So, the merchant would initially sell their IOUs for other money, or give them out according to their wishes, and then these IOUs can be traded, and returned back to the merchant for the goods.
If the merchant constantly sells these IOUs, it shouldn't be a problem for someone to pay with other money, because he would be able to immediately buy the merchant's IOUs in ripple, and then redee, them for the goods.

The problem with this approach is that the trust process in Ripple is still quite 'scary'. So to ask your customers to trust you for XYZ 'Strange Coin (STR)' may prove difficult. The idea of Ripple seems to be that eventually banks would act as gateways and potentially automatically have you trust them for the amount of USD/EUR or whatever you have in your account. Think about it: your money is already in that bank so implicitly you are already trusting them with that amount. But would you put your money in 'Small Company Inc'?


text:
Is Merkle tree pruning described in the whitepaper feasible/useful? If not, would there be any alternative?
When I was reading bitcoin-paper-errata-and-details.md written by David A. Harding, I realized that there's probably a common misunderstanding or over-simplification about Merkle tree pruning. What Nick ODell had said might be a live example:

A leaf (transaction) can be pruned when all of its outputs have been spent.

This once seemed to be true for me, until I read what David had written:

there is currently no way in Bitcoin to prove that a transaction has not been spent

I'm not sure whether I have grasped it, so firstly I made a diagram to illustrate (part of) my understanding to this problem:

Still, I don't think merely this problem can kill the whole idea of Merkle tree pruning yet, I think it just means that "the reclaimable disk capacity is much lower than expectation". In other words, if I'm not mistaken, Nick ODell's claim could be "corrected" like:

A leaf (transaction) can be pruned when all of its outputs have been spent, and all of its previous transactions have been pruned.

However, I then think that, even if the "corrected" claim is taken into consideration, the idea of Merkle tree pruning still doesn't seem to be feasible/useful:

Even if the problem mentioned above can be avoided by honest nodes, a malicious node can still deceive the new full node by hiding/picking some merkle branches. A malicious node can lie about the actual ownership of coins (spent/unspent state) without breaking the Merkle tree structure at all. In other words, a new full node joining the network still needs to download & verify everything, otherwise, it could be deceived by a malicious node.

If a full node needs to enable pruning to reduce disk space requirement for itself, directly reading/modifying the blockchain files seems to be much less efficient than the current implementation that the UTXO set is completely separated from the blockchain storage, so that a full node (no matter it's pruning or not) only needs to query and update the UTXO set database during the downloading & validation process. The blockchain itself doesn't need to be touched once again for validation purposes at all, which is the reason why the old blocks can be simply deleted when "pruning" (not Merkle tree pruning) is enabled.

However, I'm still not sure about this conclusion. Is this related to the idea of fraud proofs, in the sense that as long as there's still at least one honest full node, the new node would be able to spot which piece of data is the correct one? What if the UTXO set is also committed to the blockchain? What if some more commitments like the block height of previous transaction are also added to the blockchain?
Furthermore, I've heard that the Mimblewimble protocol enables secure blockchain pruning. I'm also curious how Mimblewimble could achieve this, and whether similar goal could be eventually achieved in Bitcoin?

You are right, completely discarding transactions whose outputs have been spent would not work. New full nodes would still need all data to be able to process the blockchain and build the current UTXO set. So, the Merkle tree pruning idea doesn't seem beneficial and maintaining the UTXO set separately in combination with pruning old blocks is more efficient.
Fraud Proofs are another thing that never has been implemented. They were meant as a way for full nodes to tell SPV clients when a blockchain tip is invalid. They are related in so far, that they suffer from the same issue: there is no good way how to prove the non-existence of a UTXO, yet. If someone just doublespent a UTXO it would be easy to point out where the UTXO was spent already, but if a block contains a transaction spending a UTXO that never was created, it's non-trivial to prove that—a full node can just tell because they calculated the complete UTXO set themselves, which in turn is hard to prove as well. It would get much easier, if we did commit to the UTXO set somewhere, but even then, the smallest proof might consist of a proof of absence in the last UTXO set commitment (which with a canonical ordered UTXO set could be as simple as the two neighboring UTXOs between which the UTXO should have appeared), and all the blocks since that commitment. Fraud proofs might be possible if we committed to the UTXO set in every block.

Furthermore, I've heard that the Mimblewimble protocol enables secure blockchain pruning. I'm also curious how Mimblewimble could achieve this, and whether similar goal could be eventually achieved in Bitcoin?

Mimblewimble transactions can be non-interactively aggregated. Any outputs that were spent by subsequent inputs cancel out at that point (which is referred to as transaction cut-through). The only data that cannot be pruned are the kernels which are a combination of signature and proof that no new funds were created. In effect, the whole Mimblewimble blockchain is a single large coinjoin transaction unless you observed/recorded the original transaction before it was aggregated. The approach cannot be ported to Bitcoin without vast redesign of the transaction format and consensus rules. In this context, it may be interesting to glance at Litecoin's Mimblewimble extension block protocol update.

Regards "how to prove the non-existence of a UTXO", AFAIK maybe it could be achieved by adding a new consensus rule, which requires each transaction input must explicitly point to where the coins came from (block height etc). If it's just already spent rather than never existed, then maybe a node can maintain a index for S(pent)TxO locally to handle this.

AFAIK what really blocks (even kills) fraud proofs is the difficulty (maybe impossibility?) to prove data unavailability. IIRC Luke Dashjr once illustrated an example that a block has an inconsistent Merkle tree which contains "hash" that is not a hash (of subtree or leaf node/tx) at all, but just random meaningless gibberish. Ironically even the malicious miner himself who created such block cannot prove it's "invalidity", because the possiblity that there might be a valid preimage cannot be ruled out. Full node will eventually ignore it, while SPV can do nothing execpt becoming a full node.

From what I understand, a full node will download everything, verify everything first. Then only the pruning starts. Thus, the issue of inconsistent pruning does not arise. As off now, there is no common consensus on the UTXO sets. For example, up to block 500,000, the UTXO set is "XXXX".  Just download "XXXX",it should be fine. I believe we will have this feature in the future. As off now, fullnode have to download everything, verify and then only prune.


text:
How does Bitcoin Core manage its peer nodes? Is it possible to let it automatically switch to faster nodes?
It's usually frustrating when my Bitcoin Core full node is syncing, especially just catching up from merely several hours/days ago.
I wonder how does Bitcoin Core manage its peers? Will it disconnect with slower nodes, and then turn to faster ones?
I once heard of the eclipse attack issue. However, as far as I know, Bitcoin Core syncs the block headers first, then it will always download full block data. It doesn't seem to hurt if Bitcoin Core could behave in such way (switching to faster nodes) when it's downloading blocks.
EDIT: According to my rough observation, fast nodes often seemed to be "stuck", as long as slow peers were still not disconnected, in other words, manually disconnecting slow peers often seemed to "accelerate" the syncing process.
Is that merely some sort of illusion, or a real phenomenon? Will manually disconnecting nodes introduce any risk?

One thing to note is when you're syncing the blockchain, you're both downloading the blockchain and also validating all of the transactions. So that is also a possible bottleneck on your end that could be causing a slow sync.

I wonder how does Bitcoin Core manage its peers? Will it disconnect with slower nodes, and then turn to faster ones?

This question addresses how peers are initially discovered. If you're interested in connecting to a different node you know of, you can use the rpc to disconnectnode and addnode.

I'm quite sure that validation is not the bottleneck, since I'm not running Bitcoin Core on a constrained environment like RaspPi. I actually asked about the "role" of peer nodes during different stages. I thought that my node can try its best to reach as many nodes as possible firstly, only to fetch block headers; then it could try to download block data as fast as possible, which doesn't seem to require reaching nodes of broader scope.

This is incorrect. During IBD, sufficiently slow peers will get disconnected.

@PieterWuille According to my observation, fast nodes often seemed to be "stuck", as long as slow peers were still not disconnected.

@ChrisChen The mechanism for finding good peers is certainly not perfect, but it exists. The answer here claims that nodes are only disconnected when peers go offline or when manually disconnecting, which is completely false. When one peer is preventing us from making progress, they are disconnected (see "stalling block download" messages in debug.log), but there are various other reasons why peers would be disconnected too (e.g. misbehavior, or for incoming connections, better peers taking the slots for worse peers).

Additionally, after the first "header-sync" and the second "catching up" stage were complete, I think the full node could then go into the third "steady" stage, which would work in a way that's similar to the current situation (keep connections with randomly-selected nodes - which are also required to be distributed among several different CIDRs, if I recalled corrrectly).

That's already what is done. Only during IBD are peers kicked for being slow.

Let us continue this discussion in chat.


text:
Is there a list of core Bitcoin committers?
Where can I find a list of people that can commit directly to the github project?

Here is a list of people who have had commit access to Bitcoin Core. This list can also be found on Bitcointalk and on Reddit (it's the same list just in two different places). All lists are kept up to date and in sync.
This list contains the names and usernames of everyone who I can find evidence for ever having commit access to Bitcoin Core, the dates during which they had commit access, sources for all of this information, and reasoning for the access. Those who currently have commit access are in bold.

Satoshi Nakamoto (satoshi, s_nakamoto): 2009-01-03 - 2011-09-13^[1] Creator, first Lead Maintainer
Martii Malmi (Sirius, sirius_m): 2009-08-30 - 2011-09-13^[1][2]    Creator of first SVN repo
Laszlo (laszloh) 2010-08-04 - 2011-09-13^[1]    Original OSX Builds and support
Gavin Andresen (gavinandresen): 2010-10-11 - 2016-05-02^[3]    Frequent contributor; later Lead Maintainer
Chris Moore (dooglus): 2011-01-21 - 2011-03-31    Frequent contributor for some time; Still contributes occasionally
Pieter Wuille (sipa): 2011-05-01 - 2022-07-07    Frequent contributor
Jeff Garzik (jgarzik): 2011-05-06 - July/Aug 2016^[4]   Frequent Contributor
Wladimir J van der Laan (laanwj, wumpus): 2011-06-05 - present^[5]    Frequent contributor; later Lead Maintainer
Nils Schneider (tcatm): 2011-09-19 - 2012-05-31    Frequent contributor for some time
Greg Maxwell (gmaxwell): 2012-02-11 - 2015-12-17    Frequent contributor; Gave up commit access due to toxicity and drama from the community
Jonas Schnelli (jonasschnelli): 2015-11-13 - 2021-10-21^[6]    Frequent contributor; given access after becoming GUI Maintainer; Stepped down for personal reasons.
Marco Falke (MarcoFalke): 2016-04-13 - present^[7]    Frequent Contributor; given access after becoming QA/Testing Maintainer
Samuel Dobson (meshcollider): 2018-12-06 - 2021-12-09^[8]    Frequent Contributor: given access after volunteering to be the Wallet Maintainer; Stepped down to focus on his PhD
Michael Ford (fanquake): 2019-06-08 - present^[9]    Frequent Contributor; given access after being nominated by several other frequent contributors and maintainers to become a maintainer.
Hennadii Stepanov (hebasto): 2021-04-19 - present  Frequent Contributor; given access after volunteering to help maintain the GUI
Andrew Chow (achow101): 2021-12-20 - present^[10]  Frequent Contributor; given access after volunteering to be the wallet maintainer.
Gloria Zhao (glozow): 2022-07-07 - presentt^[11]    Frequent contributor, given access after being nominated by several frequent contributors and maintainers to become a maintainer.

Footnotes:

[1] The move to Github occurred before the last SourceForge commit, but the last SourceForge commit declares sourceforge as dead. Presumably those who only committed to SourceForge no longer had commit access after the move
[2] Sirius was the one who created the original SVN repo on SourceForge.
[3] gavinandresen was the Lead Maintainer from 2011-02-23 until 2014-04-07
[4] I was informed via IRC PM by some of the Core devs that jgarzik was removed around August 2016 after he had been inactive for several months.
[5] laanwj is the current Lead Maintainer. After participating in that role for a long time, he was officially given the position by gavinandresen on 2014-04-07
[6] jonasschnelli was the GUI Maintainer. After participating in that role for a long time, he was officially given the position by laanwj on 2015-11-13. He stepped down for personal reasons.
[7] MarcoFalke is currently the QA/Testing Maintainer. After participating in that role for a long time, he was officially given the position by laanwj on 2016-04-13
[8] meshcollider was the Wallet Maintainer. He had been contributing for a while, particularly to wallet related things. When laanwj asked if anyone would like to be the role of Wallet Maintainer, meshcollider volunteered. He stepped down to focus on his PhD.
[9] fanquake is currently the Build System Maintainer as well as a general maintainer. He had been contributing for a while, particularly with updating dependency versions and build system related things. He also had been doing a lot of janitorial things in the repo such as tagging issues, closing old issues and PRs, nominating things to be merged, etc. At the CoreDev event in Amsterdam which several maintainers and contributors attended, he was nominated to be a maintainer by the entire group.
[10] achow101 has contributed to the project for many years, especially in wallet and PSBT-related areas. After meshcollider stepped down from the Wallet Maintainer role, achow101 volunteered to take up the role.
[11] glozow has contributed to the project for a few years, particularly in the mempool and node policy areas. She was nominated by fanquake to be a maintainer with focus in those areas.

Other Notes:

Dates are Year-Month-Day
There may be people missing and dates may be slightly incorrect. These are all that I can determine by looking at old emails and the commit history. Please let me know if anything is incorrect
The start date is determined by the first merge commit made by that person. The end date is determined by the date of the last merge commit made by that person or other announcements of commit access revocation.

After scrolling through nearly the entire git merges history, I have found a couple of interesting things.
Satoshi did not use a Version Control System originally. The releases and source code were originally in a rar file that was uploaded to bitcoin.org. Sirius had to setup the original SVN repository on SourceForge for him. This was then later migrated to GitHub by gavinandresen. Originally patches were authored by developers and then emailed to Satoshi, Sirius, or gavinandresen who then committed the changes to the source tree with the commit message containing the attribution, but not the actual commit itself.
Another interesting fact is that the giving out of commit access has become more strict. It is now a privilege held by those given maintainer positions and those whose privilege was grandfathered in (i.e. they had it previously and kept it, until otherwise revoked). Previously it was simply given out to those who contributed frequently and revoked after they stopped contributing. This appears to be no longer the case, although there are still multiple people who can commit to the repository so that there is not any reliance on one person. The maintainers are still given to frequent contributors as the maintainers are frequent contributors to the set of functionality for which they are maintainers of. They received the positions because of frequent contributions to those functionalities. Of those whose commit access was grandfathered, only Pieter Wuille remains - the rest were revoked eventually primarily for the lack of contributions (see each individual for their specific reason).
Lastly, I could not find any evidence for Satoshi ever publicly announcing that gavinandresen was to be the Lead Maintainer after him. It seems that Gavin was already a frequent contributor and already had commit access for a while before Satoshi disappeared. After Satoshi disappeared and Sirius stopped contributing as much, gavinandresen simply took over the role as lead maintainer as he was the only frequent contributor with commit access.

I think this is a bit out of date. Wladimir and Marco stepped back, Ryan of Sky got added.

There is a incomplete list in the wiki.
Sadly, the list of people who have push access to the GitHub repository is not public viewable.
Core developers are listed on Bitcoin.org in terms of number of commits.

Is there a reason that is not public knowledge? (other than no one has gotten around to making it so?) seems like an important thing for folks to be able to know, if they wanted to

Mike Hearn - Google engineer and BitCoinJ developer, created a quick reference guide to some of the communities top contributors, based on publicly available information, Real Names, to make Bitcoin come across as a more professional, trustworthy project.

People who have push access (as of September 27th, 2011) are according to this message on the Bitcoin development mailing list:

Gavin Andresen
Nils Schneider (a.k.a. tcatm)
Pieter Wuille (a.k.a. sipa)
Jeff Garzik
Alex Waters

Some more info on these people can be found on the wiki.

Doesnt sound like decentralization to me. How hard is it for 5 people to collude, when there is that much money at stake?

This should be a comment rather than an answer. Anyways, you are conflating the title of a maintainer with being a leader of the project, which really isn’t what the role entails.

According to a comment by Pieter Wuille posted to this article, there are five people with write access to the repo:

Gavin Andresen
Wladimir J. van der Laan
Greg Maxwell
Jeff Garzik
Pieter Wuille

This list matches the one published here:
https://bitcoin.org/en/development

This is correct as of may 2015.

However, you spelled my name wrong :)

Sorry about that. Fixed.

This chat transcript has the developers listed as
[06:55] <noagendamarket>     Satoshi Nakamoto
[06:55] <noagendamarket>     Gavin Andresen - (PGP)
[06:55] <noagendamarket>     Amir Taaki - (PGP)
[06:55] <noagendamarket>     Pieter Wuille
[06:55] <noagendamarket>     Nils Schneider - nils.schneider@gmail.com
[06:55] <noagendamarket>     Jeff Garzik - jgarzik@exmulti.com (PGP)

Note that the reported date of that transcript is 2011-09-04.

Just to clarify: September 4th.

(13 Dec 2010) Satoshi's Last Bitcoin Mailing List E-Mail (SourceForge)
(13 Dec 2020) Satoshi's Last BitcoinTalk Post (BitcoinTalk)
(15 Dec 2010) Satoshi's Last SourceForge Commit r202 (SourceForge)
(19 Dec 2010) Andresen says 'With Satoshi's blessing, and with great reluctance, I'm going to start doing more active project management for bitcoin' (BitcoinTalk).
You are right, Satoshi did not make any public statements about a successor, but Andresen's announcement probably counts as the 'formalisation' of his new role as Lead Maintainer.


text:
How can I restore my wallet?
I just purchased a new laptop and I want to decommission my old one.  I have a back-up of my wallet.dat file copied to my new PC.  What do I need to do to restore it to my Bitcoin (Windows) client?  Please note, this is a wallet.dat file that is about 6 months old and I haven't loaded it in at least four months.  I'm not sure if that makes a difference or not, contingent on the original version of the client that created the file.

You need to put the old wallet.dat in your bitcoin data directory.
The default for Windows is:
C:\Documents and Settings\YourUserName\Application data\Bitcoin (XP)

C:\Users\YourUserName\Appdata\Roaming\Bitcoin (Vista and 7)

Then run the bitcoin client with the -rescan option.
Alternatively you can run the bitcoin client with the -datadir=<location of backup wallet.dat> as well as the -rescan option if you do not want to move/backup the new wallet.dat.
The default for Mac OS X is:
~/Library/Application\Support\Bitcoin

The default for Linux is:
~/.bitcoin

It worked on Ubuntu too, but the wallet file was located at ~/.bitcoin

And on OS X in ~/Library/Application\ Support/Bitcoin/

Note that since 0.3.21 it is not necessary anymore to specify -rescan when moving a wallet file to a new installation.

That requires that you wipe out the other wallet. How can you merge the two?


text:
How should I go about allowing specific miners to submit to the network?
I have forked bitcoin, and I want to only allow mining submissions from specific public keys (I can verify the signature). Where would the best place to look in the bitcoin source? Would it be best to do it right at the rpc level, or somewhere else (i.e in a script, or in the consensus ~ validation.cpp)?
Alternativly, maybe I could check the coinbase tx and base validations on that?

This is similar to how Bitcoin Signet operates. Signet was introduced in BIP-325, and the code is found in Pull Request #18267 which was merged into release v0.21 in late 2020.
You can look at that pull request for guidance on how it was done, or simply use the existing Signet code itself.


text:
What is the alt stack?
I noticed in the bitcoin wiki script page (https://en.bitcoin.it/wiki/Script) that there were two opcodes named:
OP_TOALTSTACK
OP_FROMALTSTACK

It looks like there is another stack that can be used separately as a data store, simply pushing and popping data. I've never heard of this before, but it seems like a very useful feature.
Can anyone verify that this is what the alt stack is actually meant to be used for? If not for just pushing and popping data, what is it for? Do any specific use cases come to mind?

Here's where they're defined:
            case OP_TOALTSTACK:
            {
                if (stack.size() < 1)
                    return false;
                altstack.push_back(stacktop(-1));
                popstack(stack);
            }
            break;

            case OP_FROMALTSTACK:
            {
                if (altstack.size() < 1)
                    return false;
                stack.push_back(altstacktop(-1));
                popstack(altstack);
            }
            break;

Example:
Stack:
Alternate Stack:
Script: OP_1 OP_2 OP_TOALTSTACK

.
Stack: 01
Alternate Stack:
Script: OP_2 OP_TOALTSTACK

.
Stack: 01 02
Alternate Stack:
Script: OP_TOALTSTACK

.
Stack: 01
Alternate Stack: 02
Script:

what is it for? Do any specific use cases come to mind?

It's... use-impaired. 99% of the time, you can avoid using OP_(TO|FROM)ALTSTACK by putting things onto the stack in a different order. There are 18 stack manipulation operators, but only one (OP_DUP) is used with any regularity. I'm of the opinion that Bitcoin scripting is overcomplicated for its intended use.

+1, but in stack-based languages, whether or not necessary, it is often convenient to have access to a second stack.  For example, in Forth, it is a common idiom to (ab)use the return stack (>R, R>) for storing temporary data.  See http://www.forth.com/starting-forth/sf5/sf5.html for an example.  The designers may have had this in mind.  Anyway, given the difficulty (chain fork) of adding additional features to the scripting language, one can understand that the designers had an incentive to overdesign.

@Nick, I see where you're coming from when there are really only a few types of standard transactions, but some think the Bitcoin scripting language is too simple for its intended use. e.g. Ethereum. I think Satoshi found a good balance with the Bitcoin scripting language, making it flexible but also statically analyzable.


text:
What are the advantages of using Secp256k1?
Bitcoin uses secp256k1 as the specification for it's address system (https://en.bitcoin.it/wiki/Secp256k1). What are the advantages (and disadvantages) of using this over other specifications such as secp256r1?
Edit: I found this page (https://bitcointalk.org/index.php?topic=151120.0) which speculates on some possible differences, but I'm hoping to find something concrete.

What are the advantages (and disadvantages) of using this over other specifications such as secp256r1?

Secp256k1 is less widely used than secp256r1 so for some time there were faster implementations of r1 than k1.  That isn't true today, and the fastest implementations of k1 are considerably faster than r1.
Secp256k1's security critical parameters are essentially fixed by its design criteria, while r1's parameters are generated based on a 'random number' with no documented origin, causing some to worry that it might have been intentionally weakened.
I don't believe a new application would standardize on a 256-bit curve at this time, but if I had to pick between k1 and r1 for something where compatibility wasn't a concern picking k1 would be an easy decision.

I believe Satoshi was once asked this question, and answered that it was just some curve that existed and was presumed to be efficiently implemented.
I'll try to find a reference.

Thanks for that, but that makes it seem like Satoshi just randomly choose one of the many specifications available -- which may in fact be true. Nonetheless, I'm looking for specific differences between specifications that might effect things like signature performance, overall security, etc... – John Henry 1 hour ago

I had heard that he had a very good reason to choose this one over another, I'll also try to find the reference, though this was perhaps just a rumor when there was the big thing with the NSA having backdoor in some SHA algorithms. I would love to see this answered!


text:
Inv message structure
I am reading the Bitcoin wiki, and I see the inv message structure. I see it has a counter field for the objects and an inventory field. This inventory field has a list of objects (transactions or blocks), and I do wonder what it sends to the neighbors as to check if they have the transaction or block relayed. For example, is the block sent with its hash or with an id?

A block's hash is its id.

As you can see in the protocol documentation the inv-object contains a field inventory (Inventory Vector).
Inv-Object:

Inventory Vector:

You need to check the type field to know what the other node is sending. You will always receive a hash value, which is the identifier of a block or transaction.


text:
How does Bitcoin Core sort memory pool transactions by fee?
I'm trying to understand the algorithm Bitcoin Core uses to sort memory pool transactions by fee.
Gavin's fee rework proposal states:

Next, sort all remaining memory pool transactions by fee-paid-per-kilobyte, and include as many as will fit until the block is maximum block size bytes big, not including "free" transactions (transactions with fee-per-kb of less than the default spam threshold of 0.0001 BTC/kilobyte).

This makes sense, because a miner should want to load a block with transactions carrying the most "fee density", or fee per byte.
However, reviewing the CreateNewBlock function in miner.cpp, it's not clear how Bitcoin Core accounts for transaction length when prioritizing memory pool items:
// Prioritise by fee once past the priority size or we run out of high-priority
// transactions:
if (!fSortedByFee &&
    ((nBlockSize + nTxSize >= nBlockPrioritySize) || !AllowFree(dPriority)))
{
    fSortedByFee = true;
    comparer = TxPriorityCompare(fSortedByFee);
    std::make_heap(vecPriority.begin(), vecPriority.end(), comparer);
}

TXPriorityCompare seems to just look at absolute fee:
public:
    TxPriorityCompare(bool _byFee) : byFee(_byFee) { }

    bool operator()(const TxPriority& a, const TxPriority& b)
    {
        if (byFee)
        {
            if (a.get<1>() == b.get<1>())
                return a.get<0>() < b.get<0>();
            return a.get<1>() < b.get<1>();
        }
        else
        {
            if (a.get<0>() == b.get<0>())
                return a.get<1>() < b.get<1>();
            return a.get<0>() < b.get<0>();
        }
    }
};

In other words, this looks like a sort on absolute transaction fee, not fee density. What am I missing?

The excerpt you're showing is for the priority area in blocks. The concept of "priority" in the source code corresponds modified bitcoin-days-destroyed per kilobyte. It is only used for a small portion of the block size (max 50kB by default in Bitcoin Core 0.11.x, and max 0kB by default in 0.12.x, it can be changed with a configuration setting).
Look at the rest of CreateNewBlock, which uses sorting by feerate, by iterating an index on the mempool that is pre-sorted by feerate (=satoshi per kB).


text:
Witness program hash mismatch while signing bech32 transaction
I'm trying to sign a transaction using signrawtransactionwithkey on bitcoin-core 0.17 but I'm getting the following error:
{"ERROR":"[{"txid":"c7e5bc9c9662384464182c713a6a6e20a2da72adb2b2a5799457be643d764139","vout":0,"witness":[],"scriptSig":"","sequence":4294967295,"error":"Witness program hash mismatch"}]

parameters sent correctly since it's working on the testnet network
it's just the mainnet
anyway the params sent as:
["transaction_in_hex",["private_key"],[inputs]

the inputs are
[{"txid":"c7e5bc9c9662384464182c713a6a6e20a2da72adb2b2a5799457be643d764139","vout":0,"scriptPubKey":"0014f3dd9523e2a801770513e00ed717fd610ea634af","amount":"0.00099784","address":"bc1q70we2glz4qqhwpgnuq8dw9lavy82vd903k7hpe","redeemScript":""}]]

I have been reading the bitcoin source code trying to understand what's the problem and it's obvious that the exception been thrown on here
  if (memcmp(hashScriptPubKey.begin(), program.data(), 32)) {
                return set_error(serror, SCRIPT_ERR_WITNESS_PROGRAM_MISMATCH);
            }

and here
if (witness.stack.size() != 2) {
                return set_error(serror, SCRIPT_ERR_WITNESS_PROGRAM_MISMATCH); // 2 items in witness
            }

Could you please try removing the redeemScript parameter entirely?

I have tried that but exact same error. what makes me wonder that current exact code is working for testnet but not for mainnet.

Are you sure you're using the correct private key?

This error means that the transaction wasn't signed, which given that all of the inputs look correct, means that you are providing the wrong private key to sign the transaction with.

Thanks a lot it's was a rare error caused by an update to mysql server, which caused the problem. Thanks again and I wish that bitcoin-core make the errors a little bit cleaner.


text:
How to get transaction fee from raw transaction?
I know that we have to calc inputs total minus outputs to get transaction fee, but using getrawtrasnaction RPC call, inputs values are not attached. how is it possible to get transaction fee?
Array
(
    [txid] => 318abc03cfa52c996b01d6ff10faf86447341d78acdf849026dd4c22ebd56cab
    [hash] => 318abc03cfa52c996b01d6ff10faf86447341d78acdf849026dd4c22ebd56cab
    [version] => 2
    [size] => 226
    [vsize] => 226
    [locktime] => 0
    [vin] => Array
        (
            [0] => Array
                (
                    [txid] => 71c6f340ef5f4688136e8b308393ff74a89b4bf780bf0e3c3611fa34dc858c07
                    [vout] => 0
                    [scriptSig] => Array
                        (
                            [asm] => 30450221009c305ffb2f04517ba1f422f22f0eded5afb855f0ee8cdd2634259774dfb0846b022019e05a9d25f21e808a0be320e3956a1e6fcb57cc4d725404db0bbab0ced78a88[ALL] 0221b96462902141e297804981ebc5465e475ebf0f4f4d7a4e558edc4856b33e75
                            [hex] => 4830450221009c305ffb2f04517ba1f422f22f0eded5afb855f0ee8cdd2634259774dfb0846b022019e05a9d25f21e808a0be320e3956a1e6fcb57cc4d725404db0bbab0ced78a8801210221b96462902141e297804981ebc5465e475ebf0f4f4d7a4e558edc4856b33e75
                        )

                    [sequence] => 4294967295
                )

        )

    [vout] => Array
        (
            [0] => Array
                (
                    [value] => 0.01
                    [n] => 0
                    [scriptPubKey] => Array
                        (
                            [asm] => OP_DUP OP_HASH160 e673381ba3ce7fa72520a09ee4e3ad68cd5d6528 OP_EQUALVERIFY OP_CHECKSIG
                            [hex] => 76a914e673381ba3ce7fa72520a09ee4e3ad68cd5d652888ac
                            [reqSigs] => 1
                            [type] => pubkeyhash
                            [addresses] => Array
                                (
                                    [0] => n2XTjk57QJgjevmYb75tJHy7AJGGeoJv2e
                                )

                        )

                )

            [1] => Array
                (
                    [value] => 0.089981
                    [n] => 1
                    [scriptPubKey] => Array
                        (
                            [asm] => OP_DUP OP_HASH160 108e2c445972c2561d8cff8ee487cfe6e054ab59 OP_EQUALVERIFY OP_CHECKSIG
                            [hex] => 76a914108e2c445972c2561d8cff8ee487cfe6e054ab5988ac
                            [reqSigs] => 1
                            [type] => pubkeyhash
                            [addresses] => Array
                                (
                                    [0] => mh2VRUG7BA8Rutz9tqTuhinqZxRo3QinGi
                                )

                        )

                )

        )

    [hex] => 0200000001078c85dc34fa11363c0ebf80f74b9ba874ff9383308b6e1388465fef40f3c671000000006b4830450221009c305ffb2f04517ba1f422f22f0eded5afb855f0ee8cdd2634259774dfb0846b022019e05a9d25f21e808a0be320e3956a1e6fcb57cc4d725404db0bbab0ced78a8801210221b96462902141e297804981ebc5465e475ebf0f4f4d7a4e558edc4856b33e75ffffffff0240420f00000000001976a914e673381ba3ce7fa72520a09ee4e3ad68cd5d652888acd44c8900000000001976a914108e2c445972c2561d8cff8ee487cfe6e054ab5988ac00000000
    [blockhash] => eb31cb0c8de0e8b3219537e9304ee7d09d5dc7092ef17caed470b9a1aed2485e
    [confirmations] => 2269
    [time] => 1522693379
    [blocktime] => 1522693379
)

To get the input values, you need to look up the values of the outputs that they spend from. So call getrawtransaction one each input's txid and then find the output at index vout. The value of that output is the input value. Do that for all of the inputs and sum them. That is the total input value. Sum the values of the outputs to get the total output value. Subtract the total output value from the total input value and you will get the transaction fee paid.

Does bitcoin-core make this effort for each transaction to get transaction fee?

@Adam as part of the validation rules, every full node needs to check that the fee of a transaction is not negative. So: yes, implicitly.

Yes, but not in the way that you have to do it over RPC. Instead of pulling up each previous transaction, Bitcoin Core maintains an internal database of unspent transaction outputs. So it actually just pulls the UTXO from that database instead of pulling the transaction from the blockchain.

Yeah doing that over RPC is so expensive, if you could add input value for each input for getrawtransaction, could much better.

It can't be added to getrawtransaction as looking up that information for any arbitrary transaction is expensive. Bitcoin Core can do the lookup for new transactions which spends UTXOs. But once an output is spent, it becomes much more expensive to lookup that output, and maintaining a separate database for this is a waste of space and computational effort.

Expensive or impossible. Bitcoin Core can run in pruning mode, in which case it literally does not have that information anywhere. It would be highly unfortunate if people are forced to keep the whole blockchain around just to be able to compute fees. Using watch-only addresses to make the wallet track transactions you're interested in (including their fee information) is much more scalable.