How to derive the private key associated with a Coinbase multi-sig vault address When I created a multi-sig vault on Coinbase, I obtained:

A master public key in BIP32 extended format, of depth 0, parent fingerprint 00000000 and child index 0.
A private key in WIF format ("user seed"), which I don't know if it has been hardened, derived from a public key, nor the depth or index.

I am trying to prove ownership of an address derived from the master public key at index 14. So using bip32.org I have been able to derive the public key in BIP32 extended format at index m/14, that corresponds exactly to the address for which I need to prove ownership.

My objective now is therefore to derive the private key for which the address is the same as the address of the derived public key at index m/14, based on the information I have. If possible with pybitcointools.

I tried asking a more general question here, but it was a good case of XY problem (I asked about my attempted solution rather than actual problem).

I did some digging into Coinbase's offline multisig tool to figure out what the user seed actually was and their derivation paths. It turns out the user seed is just that, a seed that is used to get the Master Private Key. This is done by hashing it with HMAC-SHA512 where the key is the string Bitcoin seed and the data is the binary form of the user seed (which means decode it and get the binary data).

To do this with pybitcointools, we first decode the WIF user seed with decode_privkey and re-encode it with encode_privkey in order to get the binary form. Then we pass that into bip32_master_key to get the bip32 master key from that seed. And from there, just call bip32_ckd to get the extended private key of whichever index child we want. Lastly we extract the actual private key with bip32_bin_extract_key and encode that with encode_privkey in order to get it into WIF form which can be imported and used in other wallet software.

The below code does all of this for you and will print out the extended master private key derived from the seed, the extended public key derived from the master key (which should match the public key you have), the extended child private key, and that child key in WIF.

Replace the values for USER_PUB, USER_SEED, and I with your actual user public key, user seed, and child index that you want. The values I have here are real and will work.

from pybitcointools.deterministic import bip32_ckd, bip32_master_key, bip32_bin_extract_key, bip32_privtopub
from pybitcointools.main import decode_privkey, encode_privkey

USER_PUB = 'xpub661MyMwAqRbcEzdGMFKZXuVwbyHY2zKhiw6YFTrULfNBF53QVfXyoAiKMZKWkQA5444NXtLj9HPmgyN1xLCiJJ9dKAy4nLZJ87trHRnwUDb'
USER_SEED = 'L3XCYcQ2pwY3YTuwyPXzWsvVtGnCp4zL2ajP3XQt2pVhPuKiVM7r'
I = 14

user_seed = encode_privkey(decode_privkey(USER_SEED), 'bin')
priv = bip32_master_key(user_seed)
derived_pub = bip32_privtopub(priv)
child_priv = bip32_ckd(priv, I)
assert USER_PUB == derived_pub
print "Master Private Key corresponding to seed: " + priv
print "Master Public Key corresponding to seed: " + derived_pub
print "Extended Private key at index " + str(I) + ": " + child_priv
print "WIF format of that key: " + encode_privkey(bip32_bin_extract_key(child_priv), 'wif_compressed')


I have a merchant that only takes bitcoins can I just put the correct amount in the wallet and then pay them? I want to pay a merchant who only takes bitcoin payments. Do I create a wallet and only put in the amount of the price and pay with it? If so then what do I do after I send it to the merchant?

Create a wallet, and pay the merchant their Bitcoin price.

It would be much easier to clarify if you link to the merchant, so that we can actually see where you need to send it.


How to download wallet from coinbase I got some newbie questions;

I bought some bitcoin on Coinbase.

I want to download the wallet, I'll probably put it on a USB then throw it in the safe. Could someone advise how I can download the wallet?

Once downloaded is it still also mirrored on coinbase?

I think you can't do that.. it's another type of wallet

https://community.coinbase.com/t/saving-all-bitcoins-on-usb-stick-so-they-are-safe-from-usg-confiscation/233/5 <-- there are some info as well..


Website with trading and Ripple wallet? I plan to start crypto trading with Ripple and other coins.

What litebit.eu type of site you recommend which support Ripple and many other coins and has wallet for Ripple too? If i use litebit i need to have gatehub too and i would like to have only one website.

It's hard to find such site because that would require to create account to all of these sites. :-(

That's why i ask here if anybody knows such site.

Thanks

I know Poloniex and Bittrex is good, i use Poloniex my self to trade currencies.. http://coinmarketlist.com/ <-- maybe there you find some other exchange platforms.. there are lot of platforms out there.

About wallet i don't know :(


Will there be 21 million bitcoins eventually? Every x blocks the mining reward is halved. Will the reward be halved forever such that we never quite reach 21 million bitcoins, or will we reach 21 million bitcoins at some point and will the reward cease to exist altogether?

Extra points for pointing to the relevant code!

People say the total will be 21000000 BTC.

... however:

The 1st 210000 blocks each allow creating 50 BTC.
The 2nd 210000 blocks each allow creating 25 BTC.
The 3rd 210000 blocks each allow creating 12.5 BTC.
...
The 10th 210000 blocks each allow creating 0.09765625 BTC.
The 11th 210000 blocks each allow creating 0.04882812 BTC, and not 0.048828125 BTC, because only 8 decimals of precision are supported.
...
The 33rd 210000 blocks each allow creating 0.00000001 BTC.

After that, the reward is 0.

If you sum all these numbers together, you get 20999999.9769 BTC.

... however, either due to an oversight or intentionally, the coins created in the genesis block cannot be spent.

This leaves us with 20999949.9769 BTC.

... however, due to an early problem in Bitcoin, fixed by BIP30, it was possible to create a coinbase transaction identical to a previous coinbase. This caused the coins created by that older coinbase to be irreversibly "overwritten". This happened in block 91842 (overwriting the coinbase of block 91812) and 91880 (overwriting the coinbase of block 91722). Each time, 50 BTC was lost.

This leaves us with 20999849.9769 BTC.

... however, the protocol rules allow creating up to the amounts listed above. Due to various bugs and miners experimenting with code, some blocks claim less than allowed. Those coins can never be recovered.

Block 124724 tried to intentionally claim 0.00000001 BTC less than allowed, but accidentally also failed to claim the fees, losing 0.01000001 BTC.
Between block 162705 and block 169899, 193 blocks claimed less than allowed due to a bug, resulting in a total loss of 9.66184623 BTC.
Between block 180324 and block 249185, another 836 blocks claimed less than allowed, resulting in a total loss of 0.52584193 BTC.
Block 501726 had no transaction outputs (except a 0-value commitment), losing the entire 12.5 BTC subsidy.
Block 526591 didn't claim half of the block reward, losing 6.25 BTC.

This leaves us with 20999821.02921183 BTC.

... however, since recently there is a concept of provably unspendable coins. Coins can be sent to an "address" which provably burns them (using OP_RETURN). Bitcoin Core tracks these and removes them from its database, so they are easily accounted for. At least 3.71612692 BTC were burned this way.

This leaves us with 20999817.31308491 BTC (taking everything up to block 528333 into account)

... However, various wallets have been lost or stolen, transactions have been sent to the wrong address, people forgot they owned bitcoin. The totals of this may well be millions. People have tried to tally known losses up here.

This leaves us with: ??? BTC.


Possible to restore an Electrum wallet with partial (12/13) seed? Long story, but I need to restore an Electrum wallet (version 2.x). I have the seed, except the first word which got ripped off a legal pad.

So with 12 of the 13 seed words, what can I do to restore the wallet? I've tried to look at the word list and test possible 1st seed words, but haven't had any luck. Is there another way to skin this?

Any ideas / help would be very much appreciated. Hoping this isn't a costly mistake.

There are only 2048 possible first words, if your other 12 words are correct, this guarantees that you will find the seed. Here is the list of possible words for English:

https://github.com/bitcoin/bips/blob/master/bip-0039/english.txt

There is also a checksum involved in the seed, so it's possible to narrow down the list further if you can program a bit. Best of luck.


How to redeem Non-standard script Tx (testnet instance) Th testnet TxID 8d897ca91774a7fafa086a3275e679248d6bffee015d3b2efefd5dab00df152d has the following scriptPubKey:

  scriptPubKey: "OP_DUP OP_HASH160
  5f1426c2ce4a8e1abaa9dbe819b6303eb8a25a26 OP_EQUALVERIFY
  OP_CHECKSIGVERIFY OP_IF OP_DUP OP_HASH160
  6c7ceafe76c56843c9d2868f616fdc9370355eb9 OP_EQUALVERIFY OP_CHECKSIG
  OP_ELSE OP_HASH256
  644d79d87e0907833e888e272e5d7b925deb261a8499a65cbc0bf26797a15e8e
  OP_EQUAL OP_ENDIF"

Looking at the script of the redeeming Tx (TxID: 2d0daa01da8294a54178f8111eb2a02010c425fd15957d8baee8717edcfbe105) we see:

7e 10 3ceb50edd0282cd99dc59351f513dcdf 00 der sig

So I can see essentially that because sha256(sha256(3ceb50edd0282cd99dc59351f513dcdf)) = 644d79d87e0907833e888e272e5d7b925deb261a8499a65cbc0bf26797a15e8e the script is validated as True.

I'm attempting to understand how this is working but am consistently getting an error code 26 (OP_EQUALVERIFY failure) for this attempt at sendrawtransaction:

01000000013261e80001cbcc53101036792dcc8edc6802940b81a06e6e38f34765a4a5e4e5000000008b483045022100fe3890cfe091789b8300e563bbad402421a8dc07096ba04bcaaa4dd3537e7ce302204a1d7d1d33b6101599385f74164d95fdd8c00f62062a339e6d4907334b17df5f0141042daa93315eebbe2cb9b5c3505df4c6fb6caca8b756786098567550d4820c09db988fe9997d049d687292f815ccd6e7fb5c1b1a91137999818d17c73d0f80aef9ffffffff0220402c00000000001976a914dd6cce9f255a8cc17bda8ba0373df8e861cb866e88ac20402c00000000005876a914e900510876cb689f1db6fa982376c301362b740c88ad6376a914dd6cce9f255a8cc17bda8ba0373df8e861cb866e88ac67aa20644d79d87e0907833e888e272e5d7b925deb261a8499a65cbc0bf26797a15e8e876800000000

Where exactly is this problem occurring?

Also, in general, if one needs to push data onto the stack before the der signature, how is it done? Is the data added to the scriptSig field then signed, or signed, then added to the scriptSig? (I'm having trouble visualising the stack even with this interactive scenario at webbtc)

The first redeeming transaction has a scriptSig in the form:

<value to be double hashed> 0 <signature> <public key>

That 7e is a red herring - it's the size of the scriptSig. Similarly, the 10 is the size of the data to be hashed.

The second transaction appears to be attempting to spend a standard output. It appears to be trying to spend this using a key that doesn't hash to the right value.

You can see this by pasting the following script into Bitcoin Script IDE:

042daa93315eebbe2cb9b5c3505df4c6fb6caca8b756786098567550d4820c09db988fe9997d049d687292f815ccd6e7fb5c1b1a91137999818d17c73d0f80aef9 OP_DUP OP_HASH160 e900510876cb689f1db6fa982376c301362b740c OP_EQUALVERIFY OP_CHECKSIG


What are the differences from the 2 main mimblewimble implementations, BEAM vs GRIN? Beam is being released tomorrow, but Grin has not yet. What are the main differences from these 2 mimblewimble implementations?

Given the alleged goal of creating a politically independent means of value exchange, the fundamental differences between the projects are extremely dramatic.

Grin has no investors, and every aspect of its development is voluntary, from the mathematics to the aesthetics. There is one paid developer who volunteered for the project and subsequently the community has raised money through donations to pay for him to continue to work full time on the project [1]. There is no incentive to donate to grin except to see the project continue to be developed. The grin community skews toward idealistic/cynical, paranoid, inspired cypherpunk types. Grin is a bonafide ad-hocracy. No one can get grin coins without mining or trading them; there is no premine, presale, ico, instamine or anything else of the sort [1.5]. The core developers of grin have no advantage over anyone else for getting grin coins. It's nobody's business why they are doing it, but as far as anyone can tell it's not for a quick buck.

On the other hand...

Beam pre-sold an unknown amount of tokens for an unknown amount of millions of dollars to investors in a private ICO. Unfortunately a source for this is difficult to find, because BEAM specifically does not mention any details anywhere on their site about this private ICO; we can only speculate as to why they feel the need to be opaque. If you email them or ask their team members on twiter or telegram however if they pre-sold tokens to investors, they will tell you they did.

BEAM is a for-profit tech company that exists to enrich its shareholders, team members, investors and/or whoever stands to be enriched (they are not required to share this information). Beam for this reason has full-time, paid developers, marketers, advisors. CEOs, CTOs, CFOs and the rest of the heavy bureaucracy needed to get rich as quickly as possible are the key community members of BEAM [1.6125]. BEAM literally solicits people to become "ambassadors" to help simulate a community [1.725].

Beam has less interest than grin, for these reasons, in being "fair." In fact being fair is almost entirely antithetical to the goals of for-profit company, profit being specifically to make money at another's expense. At launch BEAM blocks were being mined every second, heavily enriching early miners. One of the core advisors to beam, a man named guy corem, is also the owner of an ASIC development company [2]: Guy is in a position to enrich himself twice, once from selling BEAM tokens allotted to him by the 20% centralized tax taken from miners securing the network, and again by using insider information to develop secret (and/or public) ASICs to mine BEAM at a severe advantage [3].

People who overlook the delicate premise of a truly sovreign currency, and misunderstand how neutral  and transparent the actual mechanics of such a network must be to even begin to be viable, can see that BEAM has a lot of things working against it to ever be useful.

Bitcoin came around to programatically and transparently remove the need for a "Federal Reserve" and provide the method for indepentent power/organization enough to maintain a high value, public ledger. BEAM appears to just be replacing the Fed with their own 20% tax and oversight. It is absurd if you imagined some central entity taking 20% of every single dollar in the entire economy and using it to pay a group of profit-oriented early investors (and of course, to maintain its own power). There is no oversight whatsoever except what BEAM says. If you ask about their transparency they will remind you that, of course, their code is "open-source (TM)" (except the wallet update they released right after they rushed to launch their mainnet, albeit for understandable reasonings.) [3.333333]

At the end of the day the people you have to trust to use grin have less power over the network than the ones you have to trust to use BEAM. This is the most important distinction for me personally.

[1] https://www.grin-forum.org/t/funding-campaign-yeastplume-march-to-aug-2019/1697

[1.5] https://github.com/mimblewimble/docs/wiki/No-this%2C-no-that

[1.6125] They have hilarious twitter handles too. I haven't looked into where they got these people. https://twitter.com/BeamCTO

[1.725] https://medium.com/beam-mw/join-beams-ambassador-program-24905b61dba4

[2] https://www.crunchbase.com/person/guy-corem#section-overview

[3] There is no evidence except thousands of years of human nature that Guy is already planning to do this (well that and the bare evidence that he runs a cryptocurrency ASIC company and is a lead advisor and insider to a for-profit cryptocurrency). That he is in a position to become corrupted by greed is dangerous enough given overarching premises we're dealing with. There is of course a chance Guy is a one in a trillion saint beyond human temptation, but then, why does he spend so much time on twitter?

[3.3333] https://www.reddit.com/r/Mimblewimble/comments/aej0gt/beam_is_currently_asking_everyone_to_download_and/


What is the structure of bitcoin block? If I understand correctly block consists of:

block header,
transactions counter,
list of signed transactions.

Each signed transaction consists of transaction itself and appended signature.

Each transaction consists of:

transaction version no,
number of inputs,
inputs themselves,
number of outputs,
outputs themselves and
locktime.

Each input consists of:

Reference to its outputing transaction
index of output in that transaction
scriptSig

Each output consists of:

output value
scriptPubKey

Is this structure correct?

I'd like to partially answer your question on the tx structure: in general you are right, here some more detail, and yes, you can have several TX_INs and TX_OUTs:

VERSION
TX_IN COUNT
  TX_IN[0] OutPoint hash
  TX_IN[0] OutPoint index
  TX_IN[0] Script Length
  TX_IN[0] Script Sig
  TX_IN[0] Sequence

TX_OUT COUNT
  TX_OUT[0] Value/Amount in Satoshi
  TX_OUT[0] PK_Script Length
  TX_OUT[0] pk_script
 LOCK_TIME

So in general the VERSION field at the very beginning and the LOCKTIME at the end is an additional piece. For sure you find further details in the developper section of bitcoin.org, and in Andreas' book "Mastering Bitcoin" (also online available). Avery good overview of the details was also provided here: http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html
I am not experienced enough to answer the part on the blocks, but it is also mentioned in the links.


Within the Bitcoin ecosystem where are wallet addresses stored/reserved? I understand that Bitcoin is a distributed system based on the blockchain, and I understand that transfers/transactions are stored in the blockchain, which exists on many servers around the internet.

But where are wallet/account addresses stored?

I understand that there are different kinds of wallet apps, local, online, etc. But the number/string that represents the wallet address within the Bitcoin ecosystem: where does that primarily live? When you create a wallet and produce that address number, do you take dibs on it in some way such that nobody else can get the same address number? What prevents duplication? Is there a null transaction recorded in the blockchain everytime a new wallet is created for the purpose of taking dibs on the wallet address?

I have no idea what I'm saying or talking about--please elucidate!

When you create an address, it is stored in your wallet. It is not recorded on the blockchain until someone executes a transaction that includes the address.

It is not necessary to reserve your address since it is statistically impossible that someone else will generate the same address (with some caveats, see below). Here is what happens when you create a new address in your wallet:

Your private key (for spending funds) is derived from a random number between 1 and 115792089237316195423570985008687907852837564279074904382605163141518161494337. Assuming the number was truly random, you don't need to worry about someone guessing this number since the number of possibilities is so ridiculously large.
The matching public key (for receiving funds) is derived from the private key in a way that is irreversible, and is used to generate the address where you can receive payments. There are 2^160 possible addresses (1461501637330902918203684832716283019655932542976).
The private and public keys are saved together as a "pair" in your wallet.


Can I make Bitcoin transactions without the involvement of a bank account whatsoever? I am a web designer and I don't have access to a bank-account (and therefore, credit/debit-card) and I am not old enough to open a bank-account yet. Could I use a Bitcoin wallet to receive money and store it there as long as I want (and possibly, send those Bitcoins) ? Paypal would be ok except they only allow you to receive a limited amount before you are required to connect your Paypal account to a bank-account.

Could I use a Bitcoin wallet to receive money and store it there as long as I want (and possibly, send those Bitcoins) ?

Yes. You can buy Bitcoin at Bitcoin ATM where is located some places. You can find a Bitcoin ATM here.
Some ATMs allow you to buy and sell coins, but some does not allow you to sell.


Block confirmation speed Based upon any standard you think relevant, how quickly are current blocks being verified for rule-following such as correct balance tallies, true transactions, correct rewards & fees?

Is this an onerous process?  Would a database quicken this process?

Do you have any suggestions for improving block verification speed?

The bulk of the work lies in verifying each transaction within the block.  This means that the signatures need to be checked for each transaction input, which requires a lot of CPU processing.  So, one way to improve the verification speed would be to have a hardware-assist for the verification process (such as a specialized ASIC chip).  I don't know if a miner ASIC could be used, but it is an interesting thought.


Repeated sha256 on brain wallet The writer of this article https://pastebin.com/raw/jCDFcESz explains that

Sha256('sender') x 2  yields the address    18aMGf2AxQ3YXyNv9sKxiHYCXcBJeJv9d1

I am however getting the address 1DcTtaa37w971TmoafPpE9Pk16xc42YA87

What am I doing wrong?

A few things to check:

Make sure you are computing the HASH256 on the decoded byte values of the string. In other words, HASH256(0x73656e646572)
Make sure you are doing 2 rounds of SHA256
Using secp256k1 to generate a compressed public key
This is a P2PKH address (prefix is 1) so the steps to generate the address from the public key are:

pubkeyhash = HASH160(compressed pubkey) i.e.RIPEMD160(SHA256(compressed pubkey)
prepend 00 byte prefix for P2PKH
BASE58CHECK(pubkeyhash)

$ echo -n sender | openssl sha256
(stdin)= 0a367b92cf0b037dfd89960ee832d56f7fc151681bb41e53690e776f5786998a

$ echo 0a367b92cf0b037dfd89960ee832d56f7fc151681bb41e53690e776f5786998a | xxd -r -p | openssl sha256
(stdin)= 098f6d68ce86adb2d8ba672a06227f7d177baca3568092e4cda159acca5eb0c7

$ openssl ec -inform DER -text -noout -in <(cat <(echo -n "302e0201010420") <(echo -n "098f6d68ce86adb2d8ba672a06227f7d177baca3568092e4cda159acca5eb0c7") <(echo -n "a00706052b8104000a") | xxd -r -p) 2>/dev/null | tail -6 | head -5 | sed 's/[ :]//g' | tr -d '\n' && echo
04f4e5977bcb050452289ebc750b56be65086bfdf3411bb9c346430716545d66b8dede7516256f34fa362b10b3ec85ccdf58c25733e00e5d33120fb66a79e596f6

# result is even (ends in 0xf6) so prefix first 32 bytes with 02 (for odd use 03)
$ echo 02f4e5977bcb050452289ebc750b56be65086bfdf3411bb9c346430716545d66b8 | xxd -r -p | openssl sha256
(stdin)= cb59a26ae2e385719a66f568476bace40a8789c5fe91d74be6381e29feb20ecb

$ echo cb59a26ae2e385719a66f568476bace40a8789c5fe91d74be6381e29feb20ecb | xxd -r -p | openssl ripemd160
(stdin)= 53178717ab3d70c50fe8ec8598a9c2a8a703abc5

$ echo 0053178717ab3d70c50fe8ec8598a9c2a8a703abc5 | xxd -r -p | base58 -c && echo
18aMGf2AxQ3YXyNv9sKxiHYCXcBJeJv9d1

using base58


Will the miner be provided with reward if a hard fork occurs? When will the miner be provide with reward(if at all) when a hard fork occurs?
When will the miner be provide with reward(if at all) when a soft fork occurs?

Miners are rewarded iff they produce valid blocks that become a part of the blockchain record. The reward is included in the block itself, so the only way to receive a block reward is by publishing a valid block to the network.
Miners cannot force a hardfork upon the network, doing so would just mean that the network's nodes would ignore those blocks, since they would be invalid by the network's rules. The hard fork blocks would be effectively creating a new network, that only(?) the miner is on, making the blocks worthless. If some users happened to join the hardfork network, so that both the legacy and hardfork networks remained active after the fork, then miners on either side of the fork would be creating blocks that contain rewards of some value.
A majority of miners can force a soft fork onto the network though, if they work to make all non-soft-fork-compliant blocks stale. In that case, any miner that wanted to participate in the network (ie, receive rewards) would need to create soft-fork-compliant blocks. If a minority of miners wants to activate a soft fork, they will not be able to do so. The minority could still mine softfork-compliant blocks, and receive the block rewards for them, but the rules of the softfork would not be enforced on the network at large.


This particular error message on bc.i means that the transaction is invalid due to OP_EQUALVERIFY operation failed

scriptSig is:

493046022100e484f5550ced311af2efb111237a54d0d93e68ac03ed5d084c669ae69afc36c902210087e69ce39c91936a4ec6fd66fb3b98d920a5ce4c3660a5519f9aa802787b09bb01
41047920bd57b7b0dbf7ac242879ee1f1c4b87cbe30a1c31baa4d111850865042415d84f0a433174b3b17f41e280bfef85ff885dd8a1f25bf0823cfd77ec81bfc080

So the public key is:

047920bd57b7b0dbf7ac242879ee1f1c4b87cbe30a1c31baa4d111850865042415d84f0a433174b3b17f41e280bfef85ff885dd8a1f25bf0823cfd77ec81bfc080

This is uncompressed public key and its address is 1Lj3WeRAmyN98jyiWE6AtnMKfzUzrPUL9z

But 1a67415e9f892c31cdaec29f6bf7e8e7ffd5a7cdca52fc565ad345313f85b222:0 sends bitcoins to the another address: 1LCrg6DSqbcK5vh7XRAGEQA4jBpNigjwyV

Are you sure that you use uncompressed public key instead of compressed one?


Upper bound on transaction confirmation time Today I saw a case where a transaction had a very low fee, so it got stuck in the mempool for days. The original wallet refused to allow a new transaction to be created with the same input, and in a case of mempool getting empty again, someone could rebroadcast that transaction and it would be accepted again.

So, the question: with current Script language, is it possible to create a transaction that becomes invalid if not included in a block before a certain time (or before a certain block height)? If so, how many bytes it would take up?

Such a transaction would be broadcast by common nodes, or they expect a certain specific signature format?

So, the question: with current Script language, is it possible to create a transaction that becomes invalid if not included in a block before a certain time (or before a certain block height)?

No, by design this is not possible.

The problem is that such a output would be very hard to assess the value of, when the timeout is close to being reached. Is the transaction going to be included, or become invalid? Even after it's confirmed, there are chances of it being reorganized out, and becoming invalid.

So by design no script features exist which depend on the context. A transaction is valid, or invalid. To deal with timing transactions can specify an nLockTime field which specifies the earliest possible time or height the transaction can be included in the chain at. The script language can introspect the nLockTime value, but not the actual time.


Lightning payments: peer versus channel (LND) I understand that in order to be able to send a LN invoice my node should be connect to at least 1 channel.

Should both nodes have an equal "stake" in the channel?

Is it correct that it isn't necessary that this channel is directly linked (without relay nodes) to receiver's node?

Do I have to connect with the receiver via "connect to peer"? (I think it's not necessary).

Thank you.

To be more precise in order to be able to pay on the lightning network you need to have at least one channel with another node.

This other node does not have to have a direct channel with the person you are about to pay.

A mandatory condition for you to pay a node is that there is a path consisting of payment channels from your node to the recipient. That path must not be longer than 20 hops. In practice it will be much shorter.

However having such a path is not sufficient. Every node on the path needs to have enough liquidity in their channel to forward the payment. This condition is not possible for you to proof before selecting the path (and a reason why in practise when routing payments several paths will be tested or a payment might fail anyway)

In particular you don't need to be connected to the recipient. Only thing that currently has to happen is that you need to get an invoice from the recipient but also that could come to you over an arbitrary medium of communication including pen and paper.


Port forwarding for pooled mining? It does not seem to be necessary but does it help to use port forwarding for pooled mining? I mean forwarding the same port as the pool port on the incoming side of my router to the rig.

When the miner needs work, it contacts the pool. So the miner makes the connection.

The only time the pool needs to contact the miner is when a new block is found, to invalidate existing work units so the miner doesn't waste time finishing a work unit when the block wouldn't be accepted anyway. But this case is handled with long polling -- the miner keeps an open outbound connection to the pool manager at all times to receive this notification.

So there is no need to forward the port, and such a forward would never be used anyway. The mining program isn't listening for inbound connections.


Does total size of the transaction affect confirmation time? Suppose one pays 1 satoshi/byte for their transactions.

Will the confirmation of the two transaction below be different?

A) a transaction of 1 inputs and 1 output (~192 bytes)

B) a transaction of 1000 inputs and 1 output (~148044 bytes)

Yes, but for a different reason than you think. ;)

Transactions bigger than 100,000 bytes are considered non-standard and won't be relayed by most nodes and probably not included by most miners in their block candidates.

Besides that, especially for a transaction paying a thrifty fee, a larger transaction might take longer to confirm. Block templates are by default populated by highest fee rate first as this maximizes revenue. It's more likely to have 192 bytes of block space left than 148,044 bytes after all transactions with higher fee rates have been considered. It's thus more likely for a bigger transaction to be delayed from inclusion in a block due to taking up more space.


What does Bitcoin Core's "Coin Control Features" do and how do I use it? What is Bitcoin Core's "Coin Control Features"?

How do I use it, and what can I do with it?

From the "Yet another Coin Control Release [CLOSED]" BitcoinTalk thread:

  What is coin control?
  When you send bitcoins to someone else, the bitcoin client chooses kinda randomly which of your addresses will send the coins. With coin control you can exactly choose, which of your addresses will be the sending addresses. And even more specific which of your unspent outputs will be the sending inputs.


How to generate recovery phrase from private key I created a brain wallet with a non standard phrase.

So I have that, the private and public keys.

Now this wallet app wants a 12 word recovery phrase to set up the wallet.

How can I convert what I have into a 12-word phrase that it can use?

Firstly, it is highly recommended not to use a brainwallet, your coins will be stolen.

But in general, if you have a private key, there is no way to obtain the 12 word recovery phrase from it. That is because the 12 word phrase is used as a seed to generate a hierarchical deterministic master extended private key, as described in BIP 39 and BIP 32 and this process is not reversible. Also, your private key is not an extended private key which is needed for an HD wallet, so the best you can do is simply import that single address manually. Some wallets do not support importing of individual addresses for safety, because they wouldn't be covered by the 12 word mnemonic backup. So I would suggest just generating a new wallet and everything and forgetting about your brain wallet.


How to Enable Port Forwarding for Litecoin Mining? I've just started Litecoin mining, and I've realized that my blockchain takes eons to download, even though its only less than 4GB.  I've read several other posts on the same problem, but none of them seem to give a comprehensive step by step tutorial on how to port forward.  Could someone please explain to me the details on how to port forward for Litecoin mining? I've gotten this far:

Thanks!

EDIT: Ok, I've set up a rule for my firewall to allow the Litecoin ports, but now I'm stuck at setting up a reserved address.  Here's a picture:

EDIT: Alright, I've found my device on the list of devices on my LAN (Tim-W) and clicked the button saying always use the same IP Address. Is that what I'm supposed to do?  BTW, there has been no real change in the number of connections, or connection speed with the Litecoin Network since I had done this.  It seems that the peak was about 13 connections after I set a rule for my firewall to allow the Litecoin ports, then it just went downwards - I'm stuck at around 39 weeks left to download off the blockchain:

Something else I noted was that I couldn't assign the Litecoin port settings to my device either.

There are countless router port forwarding guides on the Internet, this isn't Bitcoin/Litecoin specific.

Anyway, you've got the port right, you need to set your computer up on a reserved local address so that your internal IP address doesn't change when you reboot. Then you need to assign that custom "game or application" you have created to your newly reserved local IP. You may need to allow the port on your computer's firewall too. That should do it.

Saying that, Bitcoin/Litecoin is peer-to-peer and doesn't require the port opening it will function fine without it. The only difference will be that people are able to connect to you which will give your node more peer options so it could make it sync faster. Of course it could also make you sync slower because you'll be helping more peers sync.

Depending on your Internet speed it could be the uploads that are making your downloads take aeons, or it could be a slow/busy disk. Remember, it's not a website - you're not going to download 4Gb from the other volunteer peers at the same rate you might for other downloads.


Is there a website / api where I can access historic coinbase data? Is there a website / api where I can access historic coinbase data for Bitcoin?

I know about blockchair.com but they charge for the coinbase data.

Anywhere that supplies this for free?

You can request this data via the API.

A request could look like that
https://api.pro.coinbase.com/products/BTC-EUR/candles?granularity=60&start=2018-11-09T17:11:08Z&end=2018-11-09T18:11:08Z


Private key of a specific bitcoin address I need to find out the private key of a specific bitcoin address '1FVoAyGnHueH1uNR4dAQgRZcsBkAd3Mo3K'. This is the bitcoin address of a scammer who made me lose my last savings in the name of cryptocurrency trading. I recovered the fund with the help of a special intelligence unit but it is still 'Non-spendable'. Please help me recover my funds and save my life.

You cannot.  If you could, the cryptography on which Bitcoin relies would be worthless.

I don't know who this "special intelligence unit" is, but if all they did was find the address, then that is no help.  (If the "intelligence unit" took money from you to find out this address, and told you that they had recovered your funds, then you've been scammed again.)

You have not recovered your funds and you are not going to.  Your time will be better spent figuring out how to do without them.  Sorry.


How to use two-factor authentication at btc-e? btc-e has a very confusing process of enabling 2-factor.
How should I use it?

Should I generate a one time password with a Yubikey?
Should I backup the private key / base32 ?

What does this auth process do?

(P.S. btc-e - you need to hire some better UX people)

it was easy to set up for me using an android phone ... just install the google auth, scan the code they give you on btc

new users should take a screen shot of the QR code and print it out and save in secure location.  You can't get back to that QR code, so save it from the beginning.

Here is a more general info on the topic:

http://cadince.com/3-ways-to-move-google-authenticator/


Is there any way to track an individual bitcoin (or satoshi)? For example, if I wanted to "collect" important bitcoins is there any way to track a coin rather than a series of transactions? If I wanted one of the bitcoins from the infamous "Bitcoin pizza" purchase, for example, is there any way to do so?

Perhaps the question I should be asking is more like "Do bitcoins themselves even exist or just the records of transactions?"

Here is a possible schema describing transactions from two addresses A and B that contain initially 50 BTC each:
     (A) 50 btc --tx1-----------------------> 25 btc (C)
                   \
                    `-> 25 btc (D) --.
                                      \
                                       tx3--> 50 btc (*)
                                      /
                    .-> 25 btc (E) --'
                   /
     (B) 50 btc --tx2-----------------------> 25 btc (F)

There are three transactions here, and they mention only values: those transactions are stored in the block chain like:

tx1: (input on A: 50BTC; output on D: 25BTC, output on C: 25BTC)
tx2: (input on B: 50BTC; output on E: 25BTC, output on F: 25BTC)
tx3: (input on D: 25BTC,  input on E: 25BTC; output on *: 50BTC)

Only global amounts are involved, not individual satoshis. Could you tell where each of the satoshis in * came from? A or B? Just impossible.
Conclusion: There is no such thing as individual satoshis, they don't have identities in the Bitcoin framework.
(And it's the same, or even worse, for bitcoins. An individual bitcoin is not well defined. It might be a grouping of smaller amounts in the same place (wallet), or at the same address, or in the same transaction, but at a given point in time.)
It is however possible to track money flows between addresses, which may “dilute” into other flows, as illustrated in this answer.


How does Wanna Cry verify payment Reports indicate that there are three default addresses to which victims of Wanna Cry are asked to send funds.

Assuming that Wanna Cry actually does decrypt once payment is verified, how can the software know that the specific computer is the one that should be decrypted in association with the victim's payment?

IIRC WannaCry requires you to contact the malware authors (via their built in chat system thing) and then tell them the address that you used to send the payment. Then they will manually decrypt your files for you. Otherwise there is no way for them to track who sent what payment. This of course is fraught with issues and is very unreliable. I have heard some people say that their files were decrypted even without paying, and others say that they have paid but their files were not decrypted.


How does one "authenticate" a bitcoin user? What is the minimum standard for authenticating a bitcoin user. Would it be enough, for instance to verify that someone named "Tom Au" will answer to that name at this email address? Or are more detailed checks required?

Edit: Authentication would mean that I am what I say I am, that I am a human being and not a robot,and that I can do what I purport to be doing (trading Bitcoin).

Is there a public, or central registry for computer users?

In this event, would something as strong as "hashing" be needed for data storage and retrieval?

Would a web of trust concept work for the bitcoin community?

There are different KYC (Know Your Customer) laws in different jurisdictions, but generally it takes information that is difficult or very time consuming to falsify. License/ID scans, utility bills, and SSNs are examples

Suggesting "hashing" as a KYC solution suggests you do not know what hashing is (unless you were referring to the way a server should store such confidential information). I suggest you use the search function or explore bitcoin wikipedia to learn more.


Sent BTC to BCC Wallet In hopes of claiming BCC I sent BTC (Mycellium wallet) to a recently generated BCC wallet (Bitcoin.com). The transaction was confirmed, however, I don't see the BCC in my BCC wallet (or BTC in my BTC wallet!). How can I retrieve my BTC and BCC?

Because BTC and BCC have the same address type, it this is an easy mistake to make. Try finding the mnemonic or seed used to restore your BCC wallet from bitcoin.com, and instead use it to generate the BTC version of your wallet. Not all wallets provide support for BTC and BCC; some online exchanges don't give users their mnemonic recovery and worse still, a lot of wallets implement BIP 39 mnemonic differently.

This is one of the problems with forks, having multiple chains causes confusion, and people lose their money.


If the bitcoin address changes every time, why there is more than one transaction for an address in the ledger? I was checking a random address in blockchain.com, there are alot of transactions that is done over this address. While in the website it is mentioned that the address is changing everytime! So it means that every address should hold at most one transaction!

You need to differentiate between the website's wallet (Blockchain.info-wallet) and the blockchain itself.

You are allowed (by the bitcoin protocol) to make as many transactions per adress as you want.

But wallets try to make it as comfortable as possible for you and use one adress only one time so that you are acting as pseudonymously as possible.

You have probably seen an adress that has not been handled within such a "only one time"-wallet.


How to install Electrum wallet in an offline Linux computer? So I want to play with the Electrum wallet, but as Cold Storage.

Then what I plan to do is to install a raw Ubuntu 16.04 LTS into a computer "A" which I will never plug to the internet.

So, with computer "B" that has internet connection, I first download all dependencies of electrum from apt guided by this related answer:

sudo apt-get --print-uris --yes -d --reinstall install python-qt4 python-pip $(sudo apt-cache depends yourpackage | grep "  Depends:" |  sed 's/  Depends://' | sed ':a;N;$!ba;s/\n//g') | grep ^\' | cut -d\' -f2 >downloads.list
wget --input-file downloads.list

Now I download Electrum's tar.gz file. The last version when writing this is:

wget https://download.electrum.org/2.7.12/Electrum-2.7.12.tar.gz

Then I download its pip dependencies:

pip download Electrum-2.7.12.tar.gz

Now I copy all the files to a USB disk and then from this disk, to computer A.

And I run:

sudo dpkg --install *.deb
sudo pip install Electrum-2.7.12.tar.gz

However, the second command fails. It seems that even if I downloaded its pip dependencies, it doesn't pick them up and still tries to connect to the internet.

How to go on here then?

I needed a special command to use local storage, which at last worked:

sudo pip install Electrum-2.7.12.tar.gz --no-index --find-links `pwd`

UPDATE: Whenever I've had to do this for the second time, even the first instructions (posted in my question), to get the apt-get dependencies recursively, didn't work. So finally I decided to create a script that does everything for you: https://github.com/knocte/offlineElectrum/blob/master/downloadElectrumAndDeps.fsx


How to get the list of transactions of input/outputs for a bitcoin address in JSON format? Is there an example of how to get all the transaction data for a bitcoin address in json format?

As answered above you can use blockchain.info for extracting the results. Here I would like to add to the solution provided by m1xolyd1an, his code works fine but it extracts only latest 50 results/transactions made by the address that you are trying to retrieve the data for.

In order to extract the complete details of the transaction right from the beginning, some minor tweaks have to be made to the code. Below is my solution

<?php
$address = $_POST['Address'];
$url = "https://blockchain.info/address/".$address."?format=json&offset=0";
$json = json_decode(file_get_contents($url), true);

$totalTxs = $json["n_tx"];
echo "Total transaction : $totalTxs";
for($ex=0;$ex<$totalTxs;$ex+=50){
//$address = "1HB5XMLmzFVj8ALj6mfBsbifRoD4miY36v";
$url = "https://blockchain.info/address/".$address."?format=json&offset=$ex";
$json = json_decode(file_get_contents($url), true);

//total transactions
$totalTxs = $json["n_tx"];
//final balance
$balanceSatoshis = $json["final_balance"];
$balanceBitcoins = $balanceSatoshis / 100000000;
$balanceBitcoins = number_format($balanceBitcoins, 8);

//loop through each transaction and display all inputs and outs
for($i=0;$i<50;$i++){

echo "

";
echo "HASH OF TX:
";
$hash=$json["txs"][$i]["hash"];
echo "&nbsp;".$hash;

echo "	SENT FROM:
";
$n_inputs = count($json["txs"][$i]["inputs"]);

for($ii = 0; $ii < $n_inputs; $ii++){
    $inValue = $json["txs"][$i]["inputs"][$ii]["prev_out"]["value"];
    $inValueCalc = $inValue / 100000000;
    $inAddy = $json["txs"][$i]["inputs"][$ii]["prev_out"]["addr"];
    echo "&nbsp;". rtrim(number_format($inValueCalc, 8), '0') ."&nbsp;". $inAddy ."&nbsp;";
    echo "
";
    }

echo "	SENT TO:
";
$n_outputs = count($json["txs"][$i]["out"]);

for($io = 0; $io < $n_outputs; $io++){
    $outValue = $json["txs"][$i]["out"][$io]["value"];
    $outValueCalc = $outValue / 100000000;
    $outAddy = $json["txs"][$i]["out"][$io]["addr"];
    echo "&nbsp;". rtrim(number_format($outValueCalc, 8), '0') ."&nbsp;". $outAddy ."&nbsp;";
    echo "
";
    }
echo "

";
}
}
?>


Game Theory in Blockchain? The blockchain consensus seems to be very related to the Game Theory, when each participant tries to achieve their "favorites", where defining "what favorites means" is not very easy, since a participant may ex. intends to gain more coins, while another one tries to destroy the system and decrease its reputation as a "competitor crypto-currency" etc.

However, in the Game theory Wikipedia page, there is a list of "Game types" such as :

Cooperative / Non-cooperative,
Symmetric / Asymmetric,
Zero-sum / Non-zero-sum,
Simultaneous / Sequential,
Perfect information and imperfect information,
Combinatorial games,
Infinitely long games,
Discrete and continuous games,
Differential games,
Evolutionary game theory,
Stochastic outcomes,
Metagames, Pooling games,
Mean field game theory ...

Regarding to above explanations, what types of these Game Theory are more involved in the blockchain consensus?

I believe your question is flawed. Consensus isn't about game theory, it's an agreement. While game theory is analysis of strategies dealing with competition. Yes game theory has been applied outside of gaming. It's been used in war, business, even biology. Also it's not far from decision theory. While each individual in a consensus may have opinions facts to validate their positions they're still being judged by people. Game theory attempts to reduce decision making to mathematics, but ultimately we're talking about people here not calculators. Sometimes your best answer is just to eat the grapes & not pick side A or B. Meaning sometimes during a competition there is a winner. In consensus it's not always about a winner as much as it's about reaching an effective agreement which may be a 3rd option not yet revealed. Ultimately people can be irrational & do unexpected things.


How Do I Calculate the profit of the value of my bitcoin? Lets say I buy $50 of a bitcoin for 3916.74, And then the price goes up to $4200. How Do I calculate how much I have made in profit?
As in What type of formula do I use to see how much more my $50 is worth now that the price is higher than when I bought it?

The simplest way to calculate would be:

averagecost = ((BTC[t0] x USD[t0]) + (BTC[t1] x USD[t1]) + (so on))/total_BTC

where t0,t1 and so on are different time when you bought.

The above gives you the average cost for all your BTC

Now to know the profit, use the below formula:

profitloss = (current_BTC_price - averagecost) x total_BTC

If profitloss is negative, then you have a loss.

If profitloss is positive, then you have a profit.


Bitcoin Core 0.13 How many addresses it can **effectively** manage? I want to know, what's the maximum amount of addresses that Bitcoin Core 0.13 can manage?
All addresses should belong to the default account.

I want to use walletnotify feature
How startup time depends from the number of addresses my wallet holds?
How all other JSONRPC calls behave if my wallet holds many addresses?

Try it yourself. In Tools, Debug Console, try getnewaddress. Create as many as you want. See if your wallet performance changes. wallet.dat size will grow, but I can't 4MB vs 32MB has made much of a difference.

DASH wallet when it generates 1,000 addresses at a time for its PrivateSend feature, I can't notice any difference in performance.

"Effectively" manage is really seeking an opinion where the system components the node is running on will tell you what it can handle "effectively".


Transaction shows up as sent, but was never recieved I sent 0.002 BTC to 15bPd9YSB3kpuAFFz2tBZh39A3XdnN5UoX (I paid the transaction fee), but Bitcoin-Qt crashed when I pressed send. When I reopened it the transaction showed up, but it isn't in Blockexplorer.com or Blockchain.info or the reciving client. I tried rescanning both the sending and recieving clients.

I just had to run getrawtransaction on the transaction ID (from the transaction list) then run sendrawtransaction on the result.


Are there RPC calls for correct RBF calculations in Bitcoin Core? Imagine I have a "stuck" transaction using Bitcoin Core (with correct BIP125 signalling), and I want to "unstuck" it using RBF.

Is there some RPC call for the correct fee calculation?

Meaning, is there a call that would help me with creating a transaction that will be accepted in a certain block target, given the current fee estimations? Ideally in the same way the GUI version already does it.

I know it is possible to calculate that using getmempoolentry (ancestorfees and ancestorsize) and estimatesmartfee, but that is non-trivial.

If your transaction is from Bitcoin Core's wallet, you can use the bumpfee command. It should do the same thing that the GUI does in order to create a replacement transaction with a higher fee.


Do parties in a Lightning Network channel need to be online? I'm thinking of a scenario where users on mobile devices using a LN client will rarely be online.

Let's say Alice opens a channel with Bob and they make 10 LN transactions. After Alice has received the 10th, she goes offline for longer than the channel's lifetime.

So if the channel was setup to last for 3 days, she'll be offline for say, 5 days.

My question is, when Alice comes back online, how does she know whether Bob commited to the blockchain the 10th and not an earlier transaction (which is in favor of Bob).

I understand that if Alice was online she could check this behavior herself, and readily commit the 10th to get her money. But the key point here is that she's offline longer than the channel's lifetime.

Is there a solution to this in LN? Because frankly, most users will not have a node that is online 24/7. And also, I don't want to trust a third-party to commit the 10th transaction at the right time -- what if they don't? Who's to say they will also act honestly and not commit an earlier transaction from the channel?

The lightning network is comprised of bi-directional payment channels between two nodes.  This means that either one of those nodes should be able to initialize a transaction at any time.  These transactions require both parties to be actively participating in updating the smart contracts that keep the channel alive.  If one party fails to respond, they are essentially in violation of the smart contract, and are forfeiting their claim to any of the funds in the channel.

Non-responsive clients are a liability to anyone opening up a channel.  It means that their bitcoin may be tied up in the channel until the timeout period.  That bitcoin was typically put there either to make a payment (which now is delayed), or to earn network fees for being a hub of other people's transactions.  An unresponsive node means the channel is wasted.  It's similar to a denial of service attack, except it's tying up bitcoin rather than bandwidth.

To illustrate how this works, consider that Alice and Bob have each contributed 1BTC to a shared channel.  The entire channel now has a total of 2BTC in it, but it has a cap in each direction.  Because Alice only put in 1BTC, the most that will ever flow from Alice to Bob is 1BTC.  This is the same for total transactions from Bob to Alice.

Let's say that more money has flowed from Alice to Bob during the lifetime of the channel, so that if it were closed right now, Alice would get 0.5BTC, and Bob would get 1.5BTC (excluding fees for simplicity).  Now let's say Bob all of a sudden went offline, leaving the channel useless.

Due to how the smart contracts work, Alice will have a valid bitcoin transaction from earlier, that was signed by Bob, and could close the channel leaving Alice with more than the 0.5BTC she is owed.  Alice can broadcast this transaction to the Bitcoin network, and after a timeout period, will get Bob's rightful money.  The only thing that prevents this, is that Bob will see the transaction propagate on the network, and can submit the final transaction that he has (already signed by Alice) to get his full payment before Alice's transaction is valid.  If Bob isn't paying attention, then Alice can steal what is rightfully his.

Penalizing unresponsive nodes is a feature of the lightning network, intended to keep it functional.  By leaving the channel unattended, Bob is doing Alice a disservice.  Making that behavior financially disastrous is what makes the system work in the first place.


How to save bitcoins as paper? I would like to save some of my bitcoins on a piece of paper with QR code printed on it. What would be the easiest way to do it without using Mt Gox. or similar. Just bitcoins (I'm not afraid of some programming if it's needed).

Currently the most popular method is to use something like pywallet to export your public/private keys and simply generate a text QR code for them. Typically separate QR codes are generated for the public key and private key so that one code may be used to receive payment without giving away the private key which allows spending from the account. There are some alternatives, however, depending on your paper wallet needs.

Casascius' Bitcoin Address Tool is an excellent way of saving bitcoins in an easy to recover format. Though it doesn't yet support QR codes it does have the ability to generate a paper wallet from any passphrase. Once generated you could store the public and private keys as QR codes using any of a number of applications or online generators. Additionally, you could store the passphrase in a QR code and use it to recover your addresses at any time.

I specifically suggest this as opposed to simply exporting keys with pywallet and QR-ing them because this method would let you store more than one wallet address using a single QR code since any passphrase can generate up to 999 addresses deterministically in such a manner. Of course having a simple public key in QR code form also lets you scan the address with a smartphone or computer to send coins, so ultimately the solution depends on your usage.


Unconfirmed Transaction using Blockchain.info wallet I sent 0.08 BTC yesterday using the blockchain.info wallet on the iPhone.

It's been 24 hours and my money is still unsent; I really don't know what to do. It still says unconfirmed. Why is this? What can I do?

Transaction in question.

The previous transaction that you are using to spend the coin is also unconfirmed. See below. Looks like this is a problem with the blockchain wallet that you want to email their tech support about. It doesn't even seem to be broadcasting the transactions anymore.

https://blockchain.info/tx/2bf18c5ba2fe56f3d9ada4880181518e905f275bfc9826fdbebd07dca34f2ef2

If you want to fix the problem yourself, you could manually broadcast the transactions out by first getting the transaction hex :

https://blockchain.info/tx/2bf18c5ba2fe56f3d9ada4880181518e905f275bfc9826fdbebd07dca34f2ef2?format=hex

And using:

https://blockchain.info/pushtx


Could the BGP attack be used to split the Bitcoin network? I just learnt about the BGP attack:

http://www.wired.com/2014/08/isp-bitcoin-theft/

http://www.secureworks.com/cyber-threat-intelligence/threats/bgp-hijacking-for-cryptocurrency-profit/

The attacker was able to redirect the miners to its own pool to effectively "steal" (defraud them of) their mining rewards.

I don't know enough about the Border Gateway Protocol, but I'm wondering if this sort of an attack could be used to split the Bitcoin network itself, essentially by hijacking the node discovery process. If an attacker could hold the split for a few hours (assuming enough hash power), it could successfully execute a double-spend on its target.

Does the client use any kind of authentication with its peers?

P.S. Of course, there would have to be enough economic or political motivation to carry out such an expensive attack (such as to bring down a popular exchange and create media panic).

Having control over BGP and being able to split the Internet in two pieces can indeed be used to carry out an attack against some Bitcoin users. It might not even be that economically infeasible as you may think.

The adversary does not necessary need to have a control over a big portion of the Internet backbone infrastructure - he only needs to cut off a (small) region. This would effectively cause a split of the blockchain, without the victims noticing any problems with their connectivity to other peers as the communication is not signed (nor encrypted). In other words, if you can redirect the traffic going to a well-known Bitcoin node (by "stealing" his IP), you can easily replace him and act in his name.

Of course, that's not to say that this would go totally undetected by the public. People operating nodes in the cut off region would see a dramatic downfall in the Difficulty, and they could also see their inter-regional transactions not getting cleared and confirmed by their recipients. However, this kind of attack can still be efficient against a targeted victim, providing that it's performed carefully.


Mining as a screensaver Strongly inspired by the SETI program, I was considering putting together a mining client that mines when a computer switches to screensaver. I know this would cost some PGU when the computer takes a nap, and would kind of defeat the purpose.

But would such a product be of interest to the bitcoin crowd ?

Would people be interested in a piece of software like this ?

I understand that serious miners would not be interested in this, but maybe, just maybe, the whole BitCoin thing would be easier to explain to some, if there was a piece of software that resembled the SETI program (which many people know or remember.)

In the interests of keeping people's power bills low, I'd recommend not bothering to write anything that uses CPU mining as the bitcoins earned will not even come close to recovering the cost of the electricity.

If you can get it working with ATI graphics cards though, it would be quite a neat idea. It would also be a good way for charitable organisations to earn donations without people needing to put in their credit card details. Eg a donate-to-wikileaks screensaver.

However, there are also ethical issues to consider - not only does mining have a substantial electricity cost (where I live, it can be as high as $45 a month with my 5850 card), it also has a substantial effect of shortening the life of the hardware doing the processing. The average Joe Bloggs should really be made aware of those issues before they install & run mining software.


How to estimate mining fee for raw transaction? In our application we are generating a trasaction hex using the createrawtransaction call to "handcraft" a transaction. The problem we are facing is that we would like to estimate the mining fee for this transaction. I realize that we could call estimatefee x to estimate the mining fee per byte. But the problem is we are generating the transaction, so we don't know the size of the transaction yet! Chicken or egg?! I realize that we can generate a transaction and then account for the mining fee based on the hex, but this sounds like a hack to me.

So the question is: what's the best way to estimate the optimal mining fee while using createrawtransaction ?

Have a look at fundrawtransaction (if you are okay using the internal wallet).
fundrawtransaction will give you back the used fee (next to the hex byte-array of the funded transaction) before signing or broadcasting the transaction.
The ideal workflow is:

createrawtransaction '[]' '{"<addr>": <amount>}' //set no inputs
fundrawtransaction <hex>
you'll get back {"hex":<tx>, "fee": <amount>, "changepos": <pos of the change output>}
Check the fee, maybe increase it (requires Bitcoin Core 0.14, use the feeRate of fundrawtransaction.
signrawtransaction <hex>
sendrawtransaction <hex>


Do unconfirmed transactions expire? Do they just sit there unconfirmed (e.g. when you be evil and don't pay a tx fee) forever? Or do they get deleted after a few days?

Most clients on the network have a transaction pool in their memory. The same basically applies to miners: they just dump the top 500KB (or some other value) transactions into a block, sorted by transaction fee (descending, of course). When there aren't many transactions, maybe because of a series of block in a short amount of time, it will be confirmed anyway.

But to answer your actual question: yes, transactions (sort of) expire. When you send a transaction, it sends a tx frame to all connected peers. These peers store the transaction in their memory pools and tell all their connections that they have a new transaction. When those connections don't have it yet, they ask for it, and that's how a transaction spreads over the network.

At some point every node in the network will have the transaction in their memory pool, and at that point it will no longer be sent over the network. Now when a user restarts their client, the memory pool is wiped, and the transaction is deleted from that computer. (Plus a few other ways to delete transactions from the pool)

Because of that it's very unlikely for the transaction to be gone from the entire network, but in case it does happen: the reference client will automatically re-send the transaction every x hours(/minutes?) when it's still not confirmed.

Oh, and I forgot the most important part: transactions on Bitcoin (tx frames in the protocol) don't have a 'time' field, which means that transaction expiration can't be a feature of Bitcoin.

To summarize: yes, the transaction can expire, but that is really unlikely.


Antminer U3 not detecting in cgminer nor bfgminer? I am using windows 7. I have installed the driver successfully by zadig.

In cgminer when I open the .bat file, it just doesn't open and gets closed immediately.

When I open in bfgminer it says no device connected.

Command:

cgminer.exe -o xxx -u abc.worker -p x

From BFGMiner's README.ASIC file:

  The U3 does not support autodetection, so you will want to use
  --scan-serial to manually probe it. For example, to scan all devices, you can use:

  -S antminer:all --set antminer:chip=BM1382

  Additionally, for optimal performance you will need to set voltage,
  clock, and timing. Voltage format for the U3 is not documented by the
  manufacturer, thus must be provided as hexadecimal configuration
  codes. Timing is provided in the number of nanoseconds each hash takes
  at the given configuration. A known-working configuration is:

  --set antminer:voltage=x800 --set antminer:clock=237.5
  --set antminer:timing=0.022421


Someone stole my bitcoin. Help? I have been a victim of a phishing attack today, and the perpetrator stole my bitcoin hosted at coinbase.com. I have an IP address that the attacker used. Is there anything I can do? Any info would be helpful.

If you have the private keys for your addresses that were holding your bitcoin, transfer them immediately to a new address. On the compromised computer, cease all online work until you are certain the phishing malware has been removed.

If they have already been removed by the thief, then there is not much you can do. You can file a police report, but the likelihood of getting your coin back is about the same as if someone stole your physical wallet out of your pocket.

In theory, there is a lot more you can do, but the justice departments of the world have not laid down any protocols for bitcoin theft and are likely never really investigated (most cops probably don't know much more than the average person about bitcoin, anyway).


is target a 256 bit field or a 32 bit field first, do we talk about fields or values. is it correct to say that it is a 32 or 256 bit value ? or should we call it a 32 or 256 bit field ?

Why do some authors like say that the size is 32 bit .
The bitcoin wiki states that it is 256 bit. See https://en.bitcoin.it/wiki/Difficulty  it says  (target is a 256 bit number)
.

who is correct and where in the core can i take a look at it ?

The target is a 256 bit integer. However it is stored and represented in block headers as a 32 bit integer. This is a compact representation of the actual 256 bit value.

Operations involving the target are done as both 256 bit integers. However because the target is stored as a 32 bit integer in the block header, calculations involving the previous block use the 32 bit integer expanded out to the 256 bit representation. Unfortunately this compression is lossy so some data is lost in this process.

The code relevant to target adjustment can be found here: https://github.com/bitcoin/bitcoin/blob/master/src/pow.cpp


How do you set txindex to 1? I am using bitcoin.rpc.RawProxy to connect to bitcoind and scrape the data. But I am getting an error when I gettransaction and I have to reindex the blockchain. Thus I am wondering how I set the txindex to 1 so I can reindex and continue.

You can enable the txindex by either adding it to your bitcoin.conf file:

txindex=1

or

You can run bitcoind with the -txindex flag:

$ bitcoind -txindex

See:

$ bitcoind --help

    -txindex
       Maintain a full transaction index, used by the getrawtransaction rpc
       call (default: 0)


Why same output address is invalid in a transaction on Bitcoin Core? I'm studying Bitcoin Core currently. I found incomprehensible code, that shows making a transaction is rejected if there are same output addresses in a transaction.

See Fig1, Fig2

Origin source code : https://github.com/bitcoin/bitcoin/blob/8aac85d71e218783bc7ce06e5bf8bc660e24079d/src/rpc/rawtransaction_util.cpp#L95

So, the transaction illustrated in Fig1 will be rejected as shown Fig3.

Can you give reason about the policy of described in this post ?

It is not invalid.

The code you are looking it is unrelated to validation and relay of actual transactions. You are looking at the code for RPCs which are just things for users. The RPC disallows sending to an address multiple times because this is not efficient and usually a mistake by the user.

But this is only for creating a raw transaction using the Bitcoin Core RPC. A transaction received over the network or in a block that has dupllicate addresses in the outputs would not be rejected or be invalid in any way.


after hard fork won't every new transaction go on both chains? I don't understand why I'm reading that after a hard fork, the existing transactions would be on both chains but the new transactions will only be on one or the other (resulting in 2 different chains, thus an altcoin).  Won't even new transactions eventually end up on both chains?

Transactions don't care about block size, so both versions should accept them.  Even if one chain has already included it, software for the 2nd chain won't care about the first chain, so the 2nd should still have those transactions in its pool, resulting in it being put into the 2nd chain as well.

I don't see how this will result in 2 separate chains... it seems like both chains will always have approximately the same exact transactions, just possibly in a different order and grouped into different blocks.

The only exception to this I can think of is if a double-spend is attempted.  Then it's possible that one of the chains will accept one of the double-spend transactions and the other chain will accept the other.

But otherwise, I don't see how there would be a difference.

This actually happened on Ethereum when they had a hard fork.  If a transaction is valid on both chains (spends outputs from before the fork), and gets propagated to both chains, then yes, there is no reason it won't be added to blocks on both chains.

However, there are still two chains.  When the same transaction gets added to both chains, they are included in two separate blocks; one block from chain A and one block from chain B.  The outputs of such transactions can only be spent on their corresponding chain, even though the transaction that created them was identical.

Lets say that we have a chain that hard forks at block height 100.  We now have chain A and chain B.  A transaction is created using UTXOs from the block at height 90, and propagates on both networks.  Chain A includes it in its block at height 108, and chain B includes it in its block at height 110 (although it could just as well be 108 on its chain too).  Now a new transaction is created spending a UTXO from the first transaction on chain A.  That second transaction can only ever propagate on chain B if it exclusively spends from UTXOs on both chains.  This becomes increasingly less likely over time.

Since most new transactions on a chain are only valid for that chain, it won't take long before the two chains have barely any transactions in common.

It's also important to note that bitcoin clients will drop connections to clients that propagate blocks from the other chain.  This will help to segregate the network, and prevent transactions from propagating on both chains, even when they are valid on both.  There could be malicious entities that "bridge" the two networks, looking for transactions that are valid on both, but there isn't any real incentive for that sort of misbehavior.


Does a thin client testnet wallet exist which allows offline signing? I appreciate I can do offline singing with bitcoin-core, but it's complex.  To make it easier, I would have to download the entire blockchain.

I have searched up electrum, but can't seem to find a testnet option.

Any ideas?

Testnet transactions have the same format as mainnet transactions, so you can just create a raw transaction on your online testnet wallet, and get it signed by Electrum with a private key it thinks is associated with a mainnet address (the version byte is different, so the same hexadecimal private key will generate a different address on the testnet and on the mainnet, but the signature will still be valid).


Which parts of a bitcoin script are embedded in the blockchain? I assume the scriptPubKey is contained in a UTXO, and therefore embedded in the blockchain. Since, this is the script used to unlock the input.

Is a scriptSig also embedded in the blockchain? Or is it only held in memory by miners to verify signatures before confirming a block, then discarded?

I assume the scriptPubKey is contained in a UTXO, and therefore embedded in the blockchain. Since, this is the script used to unlock the input.

Yes, absolutely.

  Is a scriptSig also embedded in the blockchain?

They're part of transactions, and transactions in their entirety are part of the blockchain. All data that is directly or indirectly needed to validate blocks must be part of the blockchain, or the network wouldn't necessarily come to an agreement.

For example, if scriptSigs were not part of the chain, you could create a valid and invalid version of a transaction, broadcast the valid one, but then once you saw it in a block, replace it with the invalid one. Now the node you're passing it onto would think that block was invalid, while others thought it was valid - leading to a permanent fork in the chain.

  Or is it only held in memory by miners to verify signatures before confirming a block, then discarded?

That's an implementation detail, and completely independent from the rest your question.

Yes, some nodes only download (all) blocks, validate them fully, and then throw them away after validation ("pruning"). Those blocks and everything in them are still part of the blockchain - these nodes simply don't store the full blockchain.


How do you know that Block, the Merket Root & the hashes in the path are authentic? I went through this Q & A on Merkle Root
What is the Merkle root?

And several others on the Merkle Root & the Merkle Tree. I understand what is a Merkle Tree & how you can take use your transaction hash & other hashes in the path to the root to verify if it's consistent.

However, you get the Merkle Root & all of all other path nodes from a node you don't essentially trust, right? So what's the point of this verification? The whole block itself or the Merkle Root or the path hashes may be fake. The only way this verification makes sense is if you already have a later block you trust & the previous hash from that points to this Merkle Root. However, this does not make sense to me - how will you trust that block in the first place?

What am I missing?

Forget about the Merkle tree. Assume that instead, the block header would just contain a hash of the concatenation of all transactions.

A lightweight node could then download all headers, verify their proof of work, and make the assumption it has seen the longest chain. It is now convinced it has seen the chain the network accept. This is different from a full node, which does not assume a chain is accepted until it has seen all block data and verified every single transaction.

Now the lightweight client decides to ask peers for the actual block data. When it receives a blocks' transactions, it knows they actually match what the block header committed to, as it can recompute the hash, and compare it to the value in the header.

But what if the lightweight node is not interested in all transactions? BIP37 introduces the concept Bloom filtered blocks, where a lightweight node can reveal what keys/transactions/addresses it is interested in, and the full node it is downloading from will only give the transactions that match the filter.

Unfortunately, if the lightweight node does not download all transactions, there is no way to know whether they match the hash in the header, and as such, the full node could lie, and include transactions that are not actually present in the chain.

Enter the Merkle tree.

Instead of just storing a hash, we store the root of a Merkle tree. The full node can now for each matched transaction include the hash values that transaction's hash is combined with, to prove that the transaction is in fact included in the tree, despite the fact that the lightweight node only knows the root.


After receiving bitcoin, they were sent to an unknown address 16 minutes later I received BTC payment from my friend by qr code scaning on date 31st July (1 day before 1st August HF).

https://www.blocktrail.com/BTC/tx/8710bdb6f1d34e882bab7fbbdb4b94266032672c54a042df88e25d1518ab40a8

The incoming transaction has shown on my wallet (Mycelium) as unconfirmed with another transaction says all BTC has sent out immediately to a address I never known before.

https://www.blocktrail.com/BTC/tx/176dfd5d7f28fafef60e071588bb464a6426382d8ef5315d57e5b5852c1e0e48) (as non standard transaction with version 2)

After I reload it says network error and the most of my transaction history disappeared from wallet till now.

This make all my BTC has stuck in address 1MDJk9xhPVyVH3RcXmhYBRL9bJrwgAbsN3 without move till date 4th November (nearly segwit2x) all BTC has sent to another address again.

This is huge amount of BTC for me, I tried so hard to find the answer what happen with my BTC but really has no idea. But I'm sure my wallet not compromised and my BTC still sit in that address without used.

I have 0.5 BTC and 0.5 BCH for reward if I can get it back. It's not so much but please help me...

I apologize for my poor English language skill, You can ask me for more information to understand clearly.

I tried so hard to find the answer what happen with my BTC but really has no idea.

One possible explanation is that the BTC were stolen by someone who, at some time in the past, helped generate your private-keys and vanity-address or had access to your wallet and extracted your private keys or who otherwise compromised the security of your computer, perhaps using malware.


Cheating on pooled mining What is stopping me from hacking the mining software such that if I do happen to get the right hash I keep it for myself, but if not then I just submit my work done and get my share of the mined income.

The only way I can think of to check this is for the pools to monitor the block chain and look for suspicious activity, but I'm not sure what this activity would like in practice and that wouldn't just be a higher than elevated rate of whatever they're looking at.

It seems to me that this would be especially attractive on pools like Eligius that do CPPSRB and even more attractive the higher my hash rate as then I have a high chance of getting blocks all to myself.

The way you describe it it's not possible. The pool sends you the template of the block that you ought to be working on. Should you really find a block it is bound to the block template you received from the pool, i.e., the nonce that satisfies the proof-of-work difficulty is only valid because it is valid in combination with the template. Since the block template also includes the coinbase transaction, transferring the reward to the pool operator, you cannot steal the reward.

Hence you cannot work for the pool, creating valid shares, and at the same time work for yourself. You could only not submit the nonce for the valid block to the mining pool, but that would reduce your share of the reward as well.


What are the network requirements of running a bitcoin node? I have been hosting my bitcion node in a simple Kuberenetes setup (without istio). I recently learnt about istio https://istio.io/ and want to use it for hosting my bitcoin node.

However, I am not sure about the egress values that need to be configured for the bitcoin node to discover and communicate to other peers. What's the correct way of istio egress configuration for bitcoind?
More specifically, what are the hosts that I should allow bitcoind to communicate to?

To operate, Bitcoin Core needs to:

make DNS queries to a number of public domains in order to find peers to connect to, a full list of these is in chainparams.cpp
make arbitrary outgoing connections on TCP port 8333 on IPv4, IPv6, or both
optionally accept incoming connections on TCP port 8333


Can anyone explain this pseudocode to find a returning address? I was reading a popular answer which explains how to find the address of the person who sent a transaction and the pseudocode in that answer does not make much sense to me.

txid = <relevant transaction id>
addresses = []
raw_tx = decoderawtransaction(getrawtransaction(txid))
for(input in raw_tx['vin']) {
  input_raw_tx = decoderawtransaction(getrawtransaction(input['txid']))
  addresses.push(input_raw_tx['vout'][input['vout']]['scriptPubKey']['addresses'][0])
}

Here is the part which I understood. A wallet which created txid can use many inputs from different addresses to send that amount of money. This is why we iterate over input in raw_tx['vin'] and create a list of addresses addresses = [].

Here is a part which is unclear for me:

input_raw_tx['vout'][input['vout']]['scriptPubKey']['addresses'][0]

input_raw_tx['vout'] returns the list. So input['vout'] should return the index of that list. But it also returns a list. Can anyone explain what is going on?

Also that answer was written in old 2013. Has anything changed in these 4 years and is there an easier way to find the returning address as of the beginning of 2918?

Repeat after me: Bitcoin transactions do not have a return address. Bitcoin transactions do not have a return address.

As you say, a transaction can have multiple inputs. Each input spends a coin that was previously controlled a particular address/key or script. However, these "input addressee" are not return addresses, for multiple reasons:

The different inputs could belong to different people/entities, for example if they use CoinJoin or simar protocols. You don't know which is the sender of your payment (the pseudocode above will just return all of the sender addresses).
There may not be a recognizable address for every input (for example if it was sent through a high-level protocol), but only an arbitrary script (the pseudocode above will fail in this case).
Even if there is a clear address, it may belong to a service the sender used - and sending coins back to it would credit the service or an arbitrary user of it rather than the sender of your transaction (the pseudocode would give the service's address in this case).
Even if there is an address that indeed belonged to the sender, they may not expect a payment to it, and perhaps not have kept the private keys for it around.

In general, if you want to refund some money, there is only one solution: ask the sender ahead of time for a refund address.


What does UpdateTip mean? Example the debug log:

2014-06-27 12:59:10 UpdateTip: new best=00000000000000002a03b175f183c3bbc440f5c2a171e958bfd504582f711f70  height=308004  log2_work=79.405055  tx=41447698  date=2014-06-27 00:04:17 progress=0.998105

There could be dozens of those.

Whatever bitcoin is doing with this 'UpdateTip', it seems very CPU consuming. So what is going on, and is there any way to skip this/make it less CPU intense?

In an earlier Version of bitcoin-qt the line was the following:

  SetBestChain: new best=0000000000000419f719  height=212580  work=666804971104474944731

From: https://bitcointalk.org/index.php?topic=136628.0

  In the log messages, new best is the start of the hash of the block
  that it considers to be the head of the best chain, height is the
  length of the path through the tree, and work is the sum of the work
  embedded in that path.

It basically means that your client received a new best blockchain, so a new block was found. You can compare those log entries, they will allways increase in height and its always followed by ProcessBlock: ACCEPTED

I'm not sure why this is CPU intense for you, i didn't recognized this at my client yet. There is no way to remove this function because its a fundamental one of bitcoin-qt client and the bitcoin protocol. Also making it less CPU intense can only be done by changing the source of the client.


How does solving a block work in relation to the first letter/number after the 0's? I did a terrible job of explaining it in the title so I'll explain here. Say the target hash to solve for a block is 00004aef... etc. does that mean that you can't solve the block if you get 00005fad (since 5 is more than 4 so technically you didn't get lower or equal to the hash)? Or is the only thing that matters in relation to the less or equal when it comes to solving the hash the amount of 0's you get?
Also, what if you get a letter after the 0's, for example 0000ba2... does that mean you need to get 0000a... or does it not matter?
Thanks.

The comparison used is numeric
These are numbers not strings of characters. You can see this by looking at the code in the 2009 main.cpp of the Bitcoin reference implementation:
        uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();
        uint256 hash;

[...]

           if (hash <= hashTarget)
            {
                pblock->nNonce = tmp.block.nNonce;
                assert(hash == pblock->GetHash());

                    //// debug print
                    printf("BitcoinMiner:\n");
                    printf("proof-of-work found  \n  hash: %s  \ntarget: %s\n", hash.GetHex().c_str(), hashTarget.GetHex().c_str());

Note that if (hash <= hashTarget) is a numeric comparison. Both hash and hashTarget are type uint256 - an unsigned integer.
Numbers expressed in hexadecimal are still numbers
There is a choice of visual representations but the choice made does not change the underlying nature of the number or the way in which numbers are compared arithmetically or at a machine level in a computer.
Your example, 00005fad, is a number expressed in hexadecimal (base 16), the same number can be written in normal decimal (base 10) as 24493. Anyone unfamiliar with non-decimal representations such as hexadecimal, octal and binary can check this using something like the Windows 10 calculator, in the menu choose "Programmer Mode" then click on "hex" and enter 5fad - it shows the same value in several different representations.
Leading zeroes
The notion that Bitcoin cares about the number of leading zeroes in, say, a hexadecimal representation, is a commonly repeated mistake (don't ask me how I know this).
If you insist on writing numbers with leading zeroes it is still obviously true that 000015 (fifteen) with four leading zeroes is smaller than 000150 (a hundred and fifty) with only three leading zeroes. It would however be a mistake to think that smaller numbers always have more leading zeroes. Both you and Bitcoin know that 000017 (seventeen) is smaller than 000019 (nineteen) even though both have the same number of leading zeroes.
It is true that a is less than b in exactly the same way that 7 is less than 8 or that 2 is less than 3. But it is probably a mistake to start comparing individual digits in a particular visual representation. The hash and hash targets are ordinary numbers (though large) that are compared in an ordinary way.
So where does this talk of leading zeroes come from? It is part of a method of encoding the target value as a difficulty in a compact representation. Bitcoin has some rather arcane methods of saving space in data that are transmitted.
See

Difficulty - Bitcoin Wiki
Target - Bitcoin Wiki
Difficulty Representation - O'Reilly, Mastering Bitcoin

Examples
Lets look at some recent blocks (most recent at top, reverse chronological order)

Block
Mined on
Difficulty
Hash
bits

669315
2021-02-06 02:48
21434395961349
0000000000000000000bbefe7b336aab05ef49c9c6ccd70a895b3cc4669ac924

669314
2021-02-06 02:36
21434395961349
0000000000000000000ae88c36b136ef612f0a0622bdf614854a7810e3f781cf

669313
2021-02-06 02:34
21434395961349
0000000000000000000acd9e8fd6512d3832e98a8c87d049afbd805abd44d8c2

669312
2021-02-06 02:25
21434395961349
0000000000000000000beb9d24f999168c79fa58394868f9fcc5367c28f137dc

669311
2021-02-06 02:22
20823531150112
00000000000000000004f29390852281bae27d3662f648020bb47cced0d883b8

669310
2021-02-06 02:18
20823531150112
00000000000000000000cd7ef96b5f6687c8b49df40c2dec2128adc39827707e

669309
2021-02-06 01:54
20823531150112
00000000000000000009d6c5902b0b8598f2ebd0fe076581b039fe789b4daca6

669308
2021-02-06 01:37
20823531150112
0000000000000000000be631fd1026989a86cf9dae421e7eca0f80d77b6bba5e

Notice that the difficulty increased after block 669311 but the number of leading zeroes in the hashes has not increased (not in hexadecimal and not in binary).
Implementations
If you want to see exact details you could look at early versions of the Bitcoin reference implementation in C++. However I would suggest instead looking at the current BTCD implementation in go-lang because that is well commented and, in my opinion, an easier language to read.
e.g. https://github.com/btcsuite/btcd/blob/master/chaincfg/params.go
    // TargetTimespan is the desired amount of time that should elapse
    // before the block difficulty requirement is examined to determine how
    // it should be changed in order to maintain the desired block
    // generation rate.
    TargetTimespan time.Duration

    // TargetTimePerBlock is the desired amount of time to generate each
    // block.
    TargetTimePerBlock time.Duration

and https://github.com/btcsuite/btcd/blob/master/blockchain/difficulty.go
    // Calculate new target difficulty as:
    //  currentDifficulty * (adjustedTimespan / targetTimespan)
    // The result uses integer division which means it will be slightly
    // rounded down.  Bitcoind also uses integer division to calculate this
    // result.
    oldTarget := CompactToBig(lastNode.bits)
    newTarget := new(big.Int).Mul(oldTarget, big.NewInt(adjustedTimespan))
    targetTimeSpan := int64(b.chainParams.TargetTimespan / time.Second)
    newTarget.Div(newTarget, big.NewInt(targetTimeSpan))

Calculating the hash target
See

How is a block header hash compared to the target (bits)?
Mining Difficulty and Leading Zeros
What keeps the average block time at 10 minutes?
How to calculate new "bits" value?
Chain with most proof of work - hash target or block header hash?


How does nSequence/Check Sequence Verify work? How does relative timelock work? I mean, I know the theoretical description, but how to use nSequence concretely ? Can you do me a practical example with 2 sample transactions one of which locked with nSequence from another?

In order to use a relative time lock, you need to provide the requirements in the scriptPubKey to which the Bitcoin is sent.

Example

scriptPubKey for escrow with 30 day timeout:

IF
    2 <Alice's pubkey> <Bob's pubkey> <Escrow's pubkey> 3 CHECKMULTISIG
ELSE
    "30d" CHECKSEQUENCEVERIFY DROP
    <Alice's pubkey> CHECKSIG
ENDIF

Then, in order to spend it before 30 days, the scriptSig that satisfies the first conditional statement (multisig script) must be provided, i.e.:

scriptSig: 0 <signature1> <signature2>

Or after 30 days, alice can provide:

scriptSig: <signature>

See BIP112

Sequence

Note that in order to set a relative locktime: the tx must have the following properties:

version must be 2 or greater
nSequence must not have 32nd bit set
nSequence must have the 23rd bit set (0x400000) if it is a lock-time type, unset for block height type
for relative lock-time type the granularity of each bit is 512 seconds
for relative block height type each bit represents 1 block

For 30 days, I believe it would be as follows:

30 * 24 * 60 * 60 = 2592000 seconds
2592000 / 512 = 5062.5 ~= 5063 or 0x13C7
sequence = 0x13C7 | 0x400000 = 0x4013C7 or 4199367
nSequence = 0xC7134000 (little endian)

The sequence is the very last 4 bytes of the transaction, see https://en.bitcoin.it/wiki/Transaction


How complex can my bitcoin wallet encryption key be? What are the requirements and limitations of the password that the satoshi bitcoin wallet allows the user to set?

The password must be at least 1 character long.  I've not been able to find a maximum length.  I set the passphrase to be a 100,000 character string, and that worked fine.  Missing the last character off the end of the long string didn't work, so the 100,000th character is significant.

When first setting a passphrase the satoshi client requests that your passphrase be at least 10 random characters or 8 random words.  But it doesn't attempt to enforce its request.


How are Fees Charged at Kraken? How are fees charged when I initiate a trade?

Are they subtracted from my order's volume? Are the fees applied separately from my account's balance? Can I set the currency I want my fees to be charged in?

I have provided the Answer below, including the information given in a support ticket I sent to Kraken Support.

How are fees charged?
They are charged in the currency fee set during a trade.

Due to a discreet nature of trade matching process, it's rather tricky to give a definite answer on how each individual fee is applied. However, a good rule of thumb is to choose a fee currency when placing an order, as this is the one in which fee will be subtracted.

Are the fees applied separately from my account's balance? Or are they included in trade costs?
Usually the former is the case - but the latter can occur under certain circumstances:

Normally, fees are NOT included in a trade and are subtracted from the remaining account balance.
However, if you quote your order in a chosen fee currency (for example, you Buy 500 EUR worth of XBT in XBT/EUR pair), then fee will be included in an order*.

*This means: if your account's balance is 500€, you'll be able to buy bitcoins worth 500€ minus transaction fees.
Can I set the currency I want my fees to be charged in? Can I choose to be always charged in a single Currency?
Yes to the first, no to the second.

Fees can be chosen to get applied in either quote or base currency. So if you're trading LTC/XBT, then it's either XBT or LTC. If, however, you're trading XBT/USD, it's either XBT or USD.

All quotes taken from the Kraken Support Ticket.
Cheers!


Range proof's Confidential Transaction understanding I've some doubt about Greg Maxwell Confidential transaction and hope someone can help to make it clear.
A commitment using Elliptic Curve math is:

                                  P=xG + aH

where G,H are public value and x,a are private.

My questions are:

xG is public or private value?
if xG is a public value  why an attacker cannot simply  make a brute force attack trying all possible value of a checking for the equality with the P value?
if xG is a private value the CT paper tell: can be proven to be a commitment to a zero by just signing a hash of the commitment with the commitment as the public or if if you want to prove a=1 make C' = C - 1H
and then sign the hash of C'. How signing C or C' can I prove the value and also how can I verify a sign if I dont know xG?

Only the overall commitment (P) is revealed. G and H are constants known to everyone. x (the blinding factor) and a (the value) are secret.

if xG is a private value the CT paper tell: can be proven to be a commitment to a zero by just signing a hash of the commitment with the commitment as the public or if if you want to prove a=1 make C' = C - 1H and then sign the hash of C'. How signing C or C' can I prove the value and also how can I verify a sign if I dont know xG?

You can only sign with a point if it's a known multiple of G. By definition, a signature with private key k can be verified with public key kG. If P = xG + aH with a nonzero, it is impossible to find a k such that kG = xG + aH - that would require knowing the ratio between G and H (and H is constructed in such a way that this ratio is unknown to everyone).


Are any miners still considering priority in their transaction selection? A new answer on Who gets Bitcoin transaction fees? has spawned discussion on the paradigm shift from selection by priority (= coin age × spent value) to selection by fee rate (= fee / transaction size).
It's clear that Bitcoin Core v0.12.0 has turned selection by priority off by default, but I am wondering whether it follows that all miners have discontinued using it.
Is it known whether any miners are still selecting the transactions to go into their blocks using selection by priority?

Generally, no miners still use the priority system for selecting transactions. You can easily test this by spending a very old UTXO (e.g. 1 BTC that has remained unspent for several years) and paying no transaction fee. If miners still are using priority, your transaction should be confirmed relatively quickly (hint: it won't be). Otherwise, your transaction will not confirm for several weeks.


What would be the consequence of a constant network difficulty? Say the difficulty of the bitcoin network was not variable. Then regardless of the network hash-rate, the mining puzzle will be the same. What would that mean in terms of the security and economics of the bitcoin network?

If everything else remains equal, then I'm assuming that mining a block becomes easier and easier and we will have mined all 21 million bitcoins much sooner. Besides this, will anything change security wise? And if so, can anything be done to maintain the decentralised consensus and fiscal policy of the network with a constant difficulty? For example, the block reward payed to the miner becomes inversely proportional to the number of parent blocks.

You would eventually be up against network propagation speed, since miners would get powerful enough to mine faster that the blocks can propagate across the network. The nodes with the lowest latency between each other would always be ahead with the longest chain, penalizing those with higher latency.

You're correct that the 21 million will be reached much sooner.

You can observe this on the testnet when the block times are high enough, after it resets to the initial difficulty and blocks come flying in multiple times a second (basically as fast as the network can handle it). For more info see Testnet difficulty change