text:
address in listaddressgroupings and getnewaddress
I don't understand the differents between listaddressgroupings and getnewaddress
For example, I have a local blockchain ( regtest ) with 0 Block.
I create 101 block (generate 101)
I can see with listaddressgroupings this output
[
  [
    [
      "mvAH7VsxifvQdEZ46Rdt2oN3nB5BzaPqS8",
      50.00000000
    ]
  ]
]

What address is it?
If dump the priv key dumpprivkey mvAH7VsxifvQdEZ46Rdt2oN3nB5BzaPqS8
I have this result MVA_PRIVATEKEY
ok, If I search this privkey in dumpwallet test.txt that key in associate to this address
MVA_PRIVATEKEY 2019-01-19T10:26:19Z change=1 # addr=2NAoHv7kDBhHND7YHcQKuDS8wCbEz87xLrv hdkeypath=m/0'/0'/0'
Why is not mvAH7VsxifvQdEZ46Rdt2oN3nB5BzaPqS8 ?
Now I want create a new address getnewaddress =>
2NCGuG2v4RbaAKsZp1RQJ2ZpDM6WtW79Mu3
Why this address begin with 2 and not with m or n ? its pk is different from mvAH7VsxifvQdEZ46Rdt2oN3nB5BzaPqS8
If I create another 101 block, I have a new address in listaddressgroupings
anytime I create a new block, I have a new address in listaddressgroupings

I don't understand the difference between listaddressgroupings and getnewaddress

listaddressgroupings is very different from getnewaddress. listaddressgroupings just shows you addresses from your wallet that have been used. getnewaddress gives you a new address for you to receive Bitcoin at.

What address is it?

That address is an address in your wallet. The reason you see it listed in listaddressgroupings is because you used generate. generate mines blocks and sends the block reward to a newly generated address. So after using generate, you will see a new address in your wallet which has the Bitcoin received from the block that was just mined.
listaddressgroupings is not giving you a new address every time you call it. If you just call it without mining any blocks and without using getnewaddress, then you will see the same addresses there. No new addresses will be created.

Why this address begin with 2 and not with m or n ?

The address that generate uses is a P2PKH address which begins with m or n. However the wallet will give you, by default, addresses that are P2SH segwit addresses which will begin with 2. This can be changed by setting the -addresstype option to change the address type that getnewaddress will give you. This discrepancy is largely due to legacy reasons; there's no reason that generate couldn't use P2SH segwit addresses (or whatever you have set addresstype to) but no one bothered to change it.
(Note that generate doesn't actually use P2PKH outputs. Rather it uses a P2PK output which does not have an address type. For convenience, this is displayed as a P2PKH address)

thanks for your reply. I am little confusion. listaddressgroupings give the wallet after generatecommand. But these wallets are different from dumpwallet.
Where Can I see all address from generate? because with dumpwallet help I can read Dumps all wallet keys in a human-readable format to a server-side file., but I can't find the address generate after mine block. These address have same Master priv key?

The private keys for addresses that are used by generate are in the dumpwallet output. They just aren't shown in the same form as listaddressgroupings because of the way that Bitcoin core stores addresses internally. The addresses from generate aren't actually addresses and are not stored as addresses. But their keys are stored, and that's what matters. When you use dumpwallet, the address form for those keys are not found, so it defaults to outputting it as the current default address type which is P2SH segwit.

thanks again for your reply. The addresses from generate aren't actually addresses and are not stored as addresses. Not address because miss some hash o check like base58check or what? for example If I create a transaction with MVA_PRIVATEKEYwith which Public key check my signature? with mvAH7VsxifvQdEZ46Rdt2oN3nB5BzaPqS8 or  2NCGuG2v4RbaAKsZp1RQJ2ZpDM6WtW79Mu3`
Thanks

MVA_PRIVATEKEY has only one public key. That public key corresponds to different addresses. When hashed with hash160 and base58 check encoded with version number 111, you get mvAH7VsxifvQdEZ46Rdt2oN3nB5BzaPqS8. When hashed with hash160, built into a segwit script, that script hashed with hash160, and then base58 check encoded with version number 196, you get 2NCGuG2v4RbaAKsZp1RQJ2ZpDM6WtW79Mu3. It's the same public key in both, just different addresses representing different output scripts.

However, generate does not use either of those output scripts in the block it mined. It uses a P2PK script which has no address.


text:
Checksum P2WSH failed
My goal is replicate the same P2WSH of https://en.bitcoin.it/wiki/BIP_0173

tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7

I'm able to generate the "first" part before checksum.
There are my binary

00000 00011 00001 10001 10001 01000 01111 00000 10100 11000 10100
  01011 00110 10000 00001 00101 11101 00011 00100 10000 00011 00110
  10101 10110 11010 00010 01101 10110 01001 10000 10101 10011 11000
  11001 10101 00110 10010 01111 01000 01101 11000 11000 11000 11001
  01001 01100 00001 00100 10000 00110 01001 10001

And Their values in base10

0, 3, 1, 17, 17, 8, 15, 0, 20, 24, 20, 11, 6, 16, 1, 5, 29, 3, 4, 16,
  3, 6, 21, 22, 26, 2, 13, 22, 9, 16, 21, 19, 24, 25, 21, 6, 18, 15, 8,
  13, 24, 24, 24, 25, 9, 12, 1, 4, 16, 6, 9, 17

After that I use Python function
python -c "import bech32; print bech32.bech32_create_checksum('tb', [0, 3, 1, 17, 17, 8, 15, 0, 20, 24, 20, 11, 6, 16, 1, 5, 29, 3, 4, 16, 3, 6, 21, 22, 26, 2, 13, 22, 9, 16, 21, 19, 24, 25, 21, 6, 18, 15, 8, 13, 24, 24, 24, 25, 9, 12, 1, 4, 16, 6, 9, 17] )"

And I get that result:
[3, 1, 3, 10, 2, 25]

After that I can map on charset ("qpzry9x8gf2tvdw0s3jn54khce6mua7l")
The final result is:
My address is:
tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3rpr2ze

the address of https://en.bitcoin.it/wiki/BIP_0173
tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3q0sl5k7

As you can see the problem is only the checksum, the first part tb1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3 is the same.

I am actually getting the same result as you. I am using the python implementation here https://github.com/sipa/bech32/tree/master/ref/python

Ok, I've found the problem.
Input has 52 5-bit groups. 260 bits. Remember that every encode calls convertBits to convert from 8 bit groups to 5-bit groups. But 260 bits made of bytes is impossible! So there were 264 bits originally, = 33bytes. 264 bits need to be padded by convertBits (convertBits can/will pad when encoding but won't while decoding). So we have 265 bits. 53 5-bit groups. So you need to add a zero at the end of your input to achieve the intended result.
While decoding, convertBits will, until the number of bits is a multiple of 8, check that the last bit is 0, drop it. In your case, the last bit is not zero, so the only way not to discard it is to pad it, which it's not allowed to do while decoding.
TLDR all 5-bit groups as input are converted from 8-bit groups (addresses are designed for hash outputs and hashes output full bytes). If decoding can't decode to 8-bit groups without padding, the address is considered invalid.

Let's try to do what convertBits does to decode!
First, to simplify ignore first few multiples of 40 bits in the input. The last few bits remaining are:
10000 00110 01001 10001

Convertbits, while decoding converts from 5 to 8:
10000001 10010011 0001

Does the last group have exactly 8 bits? (In that case no further action would be needed) No.
Does the last group have zeros only? (In that case we can just erase the last group) No.
Throw an error. We either need to discard bits or pad, which is not allowed while decoding.
This is why the address you generated is can't be decoded. (Try it)

thanks very nice answer, I fix it. anyway I don't understand when Drop last 5 bits. I create another address and last 5 bits are 00000. I paste the address tb1qgw3wu3a67tk7p4ltpxxfm6np6y78m5c4wp0qlpy8c4qaydus7s5qsva89z in (http://bitcoin.sipa.be/bech32/demo/demo.html) I don't receive any errors.  Anyway my procedure seems "inverse" of BIP_0173. First of all I create scriptHash, then convert script hash and re-arrange in 8bit adding 0 at the end. Add Witness program (5 bits of 0) and re-arrange in 5 bit. create checksum and create address. in BIP_0173 seems that before use 5 bits after 8 bits

It's correct. Adding 8 times 0 at the end makes the decoder think some of it as coming from padding. Apart from your description of padding, that's exactly BIP 173. Converting from 5 bits to 8 bits is for decoding.

ok, add 8 zero ad the end because i need of 1 megabyte I presume. Very similar to calculate the seed.

source: Stack Exchange

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

sort: votes


text:
Retrieve address when create a channel lightning network
I have two nodes in regtest.
the first one is:
$ l1-cli getinfo
{
   "id": "02c3f99e70c8da59e428dd119d36c0a1317e5cd85218a760355b5f9b4f822f6109",
   "alias": "ALICE",
   "color": "ddff06",
   "num_peers": 0,
   "num_pending_channels": 0,
   "num_active_channels": 0,
   "num_inactive_channels": 0,
   "address": [],
   "binding": [
      {
         "type": "ipv4",
         "address": "127.0.0.1",
         "port": 6060
      }
   ],
   "version": "v0.8.2-269-g6014644",
   "blockheight": 1,
   "network": "regtest",
   "msatoshi_fees_collected": 0,
   "fees_collected_msat": "0msat",
   "lightning-dir": "/tmp/l1-regtest/regtest"
}
$ l1-cli  dev-listaddrs
{
   "addresses": [
      {
         "keyidx": 0,
         "pubkey": "032173996ba61da17cf20a15bbd72bc6f1e6dcace0ffa55e0a8c4de6cb1fde0cd4",
         "p2sh": "2N5tGiR5EkCv8gMYAs9myqQ7R6Wkgkcc1L5",
         "p2sh_redeemscript": "0014a0064ff5b87368717f4d7f8f7d84f8aa41de10e9",
         "bech32": "bcrt1q5qryladcwd58zl6d078hmp8c4fqauy8fj4vsrv",
         "bech32_redeemscript": "a0064ff5b87368717f4d7f8f7d84f8aa41de10e9"
      }
   ]
}

the second is:
$ l2-cli getinfo
{
   "id": "0214106517c1a81bf2dd8a3f37f6438e264ee17e270ed5c08110f584863f9bfa99",
   "alias": "BOB",
   "color": "021410",
   "num_peers": 0,
   "num_pending_channels": 0,
   "num_active_channels": 0,
   "num_inactive_channels": 0,
   "address": [],
   "binding": [
      {
         "type": "ipv4",
         "address": "127.0.0.1",
         "port": 9090
      }
   ],
   "version": "v0.8.2-269-g6014644",
   "blockheight": 1,
   "network": "regtest",
   "msatoshi_fees_collected": 0,
   "fees_collected_msat": "0msat",
   "lightning-dir": "/tmp/l2-regtest/regtest"
}
$ l2-cli  dev-listaddrs
{
   "addresses": [
      {
         "keyidx": 0,
         "pubkey": "03ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe62628",
         "p2sh": "2MsoPq7yYttm63u8yzRGgnYs44TTEe7z6ZS",
         "p2sh_redeemscript": "001463550e0be42780fef27416d022943739cfd06423",
         "bech32": "bcrt1qvd2suzlyy7q0aun5zmgz99ph888aqeprvsg6sw",
         "bech32_redeemscript": "63550e0be42780fef27416d022943739cfd06423"
      }
   ]
}

Alice has 50 bitcoins in bcrt1q5qryladcwd58zl6d078hmp8c4fqauy8fj4vsrv
Alice connects to BOB
$ l1-cli connect 0214106517c1a81bf2dd8a3f37f6438e264ee17e270ed5c08110f584863f9bfa99 127.0.0.1:9090
{
   "id": "0214106517c1a81bf2dd8a3f37f6438e264ee17e270ed5c08110f584863f9bfa99",
   "features": "02aaa2"
}

Alice creates a channel with 0.05 bitcoin = 50000000000msat
l1-cli fundchannel 0214106517c1a81bf2dd8a3f37f6438e264ee17e270ed5c08110f584863f9bfa99 5000000000msat                                │
{                                                                                │
   "tx": "02000000000101e5fd718b998672b2b38747f010676fc1300b8cb063649e8a922637941bbce6060000000000feffffff02404b4c0000000000220020b7e3│
dec987315eaf340075d2a06fb92961f7e6578285d7c2e418da449c17fd9d26a6b9290100000016001406d177ca4906c71db5d4240e31468ad6d93f3989024730440220│
4b35306bb23701b24102b3933289cd1e7a0b67c875d965c337cd7357946f1b9e022031f98d8f318d2b72d8f3621c2005378a78a103a6169536b940e31f51e05c8d2f01│
21032173996ba61da17cf20a15bbd72bc6f1e6dcace0ffa55e0a8c4de6cb1fde0cd400000000",                                                        │
   "txid": "dbb8a5f98d465c6cf438b8166a438a09c8118f2b62960ef99403be00e1ced8a6",                                                        │
   "channel_id": "a6d8cee100be0394f90e96622b8f11c8098a436a16b838f46c5c468df9a5b8db"                                                   │
}

Now I check the funding transaction
bitcoin-cli getrawtransaction dbb8a5f98d465c6cf438b8166a438a09c8118f2b62960ef99403be00e1ced8a6 2

"vout": [
    {
      "value": 0.05000000,
      "n": 0,
      "scriptPubKey": {
        "asm": "0 b7e3dec987315eaf340075d2a06fb92961f7e6578285d7c2e418da449c17fd9d",
        "hex": "0020b7e3dec987315eaf340075d2a06fb92961f7e6578285d7c2e418da449c17fd9d",
        "reqSigs": 1,
        "type": "witness_v0_scripthash",
        "addresses": [
          "bcrt1qkl3aajv8x9027dqqwhf2qmae99sl0ejhs2za0shyrrdyf8qhlkwsgphj96"
        ]
      }
    },
    {
      "value": 49.94999846,
      "n": 1,
      "scriptPubKey": {
        "asm": "0 06d177ca4906c71db5d4240e31468ad6d93f3989",
        "hex": "001406d177ca4906c71db5d4240e31468ad6d93f3989",
        "reqSigs": 1,
        "type": "witness_v0_keyhash",
        "addresses": [
          "bcrt1qqmgh0jjfqmr3mdw5ys8rz3526mvn7wvf5pklnl"
        ]
      }
    }
  ],

That address bcrt1qkl3aajv8x9027dqqwhf2qmae99sl0ejhs2za0shyrrdyf8qhlkwsgphj96 is Segwit multisig.
Now If I check addr in l1 I can see
$ l1-cli  dev-listaddrs
{
   "addresses": [
      {
         "keyidx": 0,
         "pubkey": "032173996ba61da17cf20a15bbd72bc6f1e6dcace0ffa55e0a8c4de6cb1fde0cd4",
         "p2sh": "2N5tGiR5EkCv8gMYAs9myqQ7R6Wkgkcc1L5",
         "p2sh_redeemscript": "0014a0064ff5b87368717f4d7f8f7d84f8aa41de10e9",
         "bech32": "bcrt1q5qryladcwd58zl6d078hmp8c4fqauy8fj4vsrv",
         "bech32_redeemscript": "a0064ff5b87368717f4d7f8f7d84f8aa41de10e9"
      },
      {
         "keyidx": 1,
         "pubkey": "03841e0be7af4049e44818cfab5248128806e22103b6177a0915e18fdb683875c8",
         "p2sh": "2N6aAJa7kbCVFx8cNMjRskR2beACY6AaPBA",
         "p2sh_redeemscript": "00146e289f089c56abb767fecd3e189489eb619ffa74",
         "bech32": "bcrt1qdc5f7zyu264mwel7e5lp39yfadsel7n5hnp04r",
         "bech32_redeemscript": "6e289f089c56abb767fecd3e189489eb619ffa74"
      },
      {
         "keyidx": 2,
         "pubkey": "020f91c2b34bc3a8cf3b56279fb7cae5a24ed3fb571cdfca2c35064e1d17d57b18",
         "p2sh": "2N5WmmNYJCr8eK2nJvf8N8QwV9zj9Lxree2",
         "p2sh_redeemscript": "0014751389f7ad7f0426e8fed655c0e40de0c06c3781",
         "bech32": "bcrt1qw5fcnaad0uzzd6876e2upeqdurqxcdup20v8lj",
         "bech32_redeemscript": "751389f7ad7f0426e8fed655c0e40de0c06c3781"
      },
      {
         "keyidx": 3,
         "pubkey": "03c2ecd5456ebf61168ef9536da277772c308798a5635f83e9ed60233bdf620958",
         "p2sh": "2N1rzfyGXpbPPjr7FhZsvaaaFiifvrxiEyd",
         "p2sh_redeemscript": "001478624d2bcd45fe2adf8c479a171634209adac754",
         "bech32": "bcrt1q0p3y627dghlz4huvg7dpw935yzdd4365xje7v5",
         "bech32_redeemscript": "78624d2bcd45fe2adf8c479a171634209adac754"
      },
      {
         "keyidx": 4,
         "pubkey": "033a1f02a7c19cba180defc087fdc0b48636a3d61adc4eb9d5ca1e8e6f21b12284",
         "p2sh": "2MvZeMyFSN4UWtYnTEBcTdtCjBi8kNVKKum",
         "p2sh_redeemscript": "001406d177ca4906c71db5d4240e31468ad6d93f3989",
         "bech32": "bcrt1qqmgh0jjfqmr3mdw5ys8rz3526mvn7wvf5pklnl",
         "bech32_redeemscript": "06d177ca4906c71db5d4240e31468ad6d93f3989"
      },
      {
         "keyidx": 5,
         "pubkey": "03c0032537904220bd32be2f8431597f4a49b23300face9212a49b469470b99ec3",
         "p2sh": "2NCARQgcBZzmYK6CfvTW1XMGXv2pddZnrxh",
         "p2sh_redeemscript": "0014a22f05c2da4a52fbef434d67b1fda4c228990145",
         "bech32": "bcrt1q5ghstsk6fff0hm6rf4nmrldycg5fjq29xt5gpx",
         "bech32_redeemscript": "a22f05c2da4a52fbef434d67b1fda4c228990145"
      }
   ]
}

and in l2 I can see
$ l2-cli  dev-listaddrs
{
   "addresses": [
      {
         "keyidx": 0,
         "pubkey": "03ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe62628",
         "p2sh": "2MsoPq7yYttm63u8yzRGgnYs44TTEe7z6ZS",
         "p2sh_redeemscript": "001463550e0be42780fef27416d022943739cfd06423",
         "bech32": "bcrt1qvd2suzlyy7q0aun5zmgz99ph888aqeprvsg6sw",
         "bech32_redeemscript": "63550e0be42780fef27416d022943739cfd06423"
      },
      {
         "keyidx": 1,
         "pubkey": "02e28aaf512284c08336782769b9af1eb816970f99b6fadb2faa5c0d65ddc24d7e",
         "p2sh": "2MvpYKgQ7hY4q86WSn5FQALFjezAtxuyvBM",
         "p2sh_redeemscript": "00143c67dd58505ad35c30dc19db622659dfc543566e",
         "bech32": "bcrt1q83na6kzsttf4cvxur8dkyfjemlz5x4nwxq9kpz",
         "bech32_redeemscript": "3c67dd58505ad35c30dc19db622659dfc543566e"
      }
   ]
}

Why I have several address in l1?
How Can I get bcrt1qkl3aajv8x9027dqqwhf2qmae99sl0ejhs2za0shyrrdyf8qhlkwsgphj96?
I tried with public keys of l1 and public key of l2, but without lucky
$  bitcoin-cli createmultisig 2 '["032173996ba61da17cf20a15bbd72bc6f1e6dcace0ffa55e0a8c4de6cb1fde0cd4","03ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe62628"]' "bech32"
 bitcoin-cli createmultisig 2 '["03841e0be7af4049e44818cfab5248128806e22103b6177a0915e18fdb683875c8","03ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe62628"]' "bech32"
 bitcoin-cli createmultisig 2 '["020f91c2b34bc3a8cf3b56279fb7cae5a24ed3fb571cdfca2c35064e1d17d57b18","03ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe62628"]' "bech32"
 bitcoin-cli createmultisig 2 '["03c2ecd5456ebf61168ef9536da277772c308798a5635f83e9ed60233bdf620958","03ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe62628"]' "bech32"
 bitcoin-cli createmultisig 2 '["033a1f02a7c19cba180defc087fdc0b48636a3d61adc4eb9d5ca1e8e6f21b12284","03ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe62628"]' "bech32"
 bitcoin-cli createmultisig 2 '["03c0032537904220bd32be2f8431597f4a49b23300face9212a49b469470b99ec3","03ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe62628"]' "bech32"
{
  "address": "bcrt1qdynj6dv4zq03ldfregnl3wwppt4gu0wm8xhn7gma48mg3s8vxswsau88sc",
  "redeemScript": "5221032173996ba61da17cf20a15bbd72bc6f1e6dcace0ffa55e0a8c4de6cb1fde0cd42103ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe6262852ae"
}
{
  "address": "bcrt1q5kvw3x3gafcg83w6klfrdtdta6dmptc35fyxty58kzr7wzd3n83q46t7x6",
  "redeemScript": "522103841e0be7af4049e44818cfab5248128806e22103b6177a0915e18fdb683875c82103ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe6262852ae"
}
{
  "address": "bcrt1q5fg097ujz8cl0hum4xt9x6mygzqhlvgkggkwqdlv7rvj8n0npk6qnzslpz",
  "redeemScript": "5221020f91c2b34bc3a8cf3b56279fb7cae5a24ed3fb571cdfca2c35064e1d17d57b182103ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe6262852ae"
}
{
  "address": "bcrt1qhzj0jgl56uatnxdzhwczrf08ku9a6c7x7fjldsnrkam75evlzywsn4ww6w",
  "redeemScript": "522103c2ecd5456ebf61168ef9536da277772c308798a5635f83e9ed60233bdf6209582103ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe6262852ae"
}
{
  "address": "bcrt1qsjm7zc0rhpzjmrldht7rxhp0y5ldu7c53da0fyr2jq3l9u03lz3q47r3r7",
  "redeemScript": "5221033a1f02a7c19cba180defc087fdc0b48636a3d61adc4eb9d5ca1e8e6f21b122842103ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe6262852ae"
}
{
  "address": "bcrt1qgsp7ltzlq9qcqmqr2eqd5h8zm87ch9zfdfj256nzsuk4ys2nc4asr0sqxk",
  "redeemScript": "522103c0032537904220bd32be2f8431597f4a49b23300face9212a49b469470b99ec32103ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe6262852ae"
}

Why I have several address in l1?

Maybe you mined some blocks to have the channel active ?

How Can I get bcrt1qkl3aajv8x9027dqqwhf2qmae99sl0ejhs2za0shyrrdyf8qhlkwsgphj96 ?

As I detailed in your question regarding key derivation with C-lightning, lightningd uses different derivation methods for different purposes.
The (dev-only) RPC command you are using is listing addresses from the BIP32 tree used as your "onchain wallet" (used to generate addresses with newaddr or for channel claiming transactions, for example).
In order to examine channel-related transactions, you can use the listtransactions command. Quoting the help:

Returns transactions tracked in the wallet. This includes deposits, withdrawals and transactions related to channels. A transaction may have multiple types, e.g., a transaction may both be a close and a deposit if it closes the channel and returns funds to the wallet.

EDIT: follow-up of the questions in the comment. @MonkeyUser asks :

yep, but in that case I want to understand how bcrt1qkl3aajv8x9027dqqwhf2qmae99sl0ejhs2za0shyrrdyf8qhlkwsgphj96 is generated. which public keys are used? thanks

During the funding process, the peers sends us a message [resp. we send the peer a message] telling "hey, I want to open a channel with this configuration". The funding pubkey is part of this configuration.
We then respond [resp. the peer responds] with a message telling "Ok, here is my configuration. Be sure to respect it or I'll close the channel on you !". The second funding public key is part of this message (*).
No matter if we are the funding or the funder, lightningd will use the "funding_basepoint" pubkey as our funding pubkey to construct the P2WSH multisig of the funding transaction.
The basepoints are derived from deterministic informations of a channel as follows :
channel_seed = hkdf_sha256(hkdf_sha256(hsm_secret, salt=NULL, info="peer seed"), salt=peer_id | dbid, info="per-peer seed")
[funding, revocation, payment, htlc, delayed, shaseed] = expanded_hkdf_sha256(channel_seed, salt=NULL, info="c-lightning")

(*) In fact, we exchange a whole bunch of public keys and more specifically "basepoints" with this message. These are used to derive all the many keys needed for different operations (revocation, htlcs, payment, delayed payment, etc..).

thanks darosior, I create a script to get BIP32. No I don't mined any blocks. The fund transaction is not mined. If I understand it's bcrt1qkl3aajv8x9027dqqwhf2qmae99sl0ejhs2za0shyrrdyf8qhlkwsgphj96 a multisig between Alice a Bob but I don't understand how it is created. Even with listtransactions I Don't find any informations. thanks

lightningd updates its view by parsing blocks from bitcoind : you (generally) need to have the transactions to be confirmed to see them lightningd-side.

yep, but in that case I want to understand how bcrt1qkl3aajv8x9027dqqwhf2qmae99sl0ejhs2za0shyrrdyf8qhlkwsgphj96 is generated. which public keys are used? thanks

@monkeyUser responded in the answer as the derivation is quite involved :-)

Amazing answer, I'm trying to generate channel_seed with my function python, But I don't have peer_id or I don't understand what is. I don't find any documentation, do you have some links? I can read the code https://github.com/ElementsProject/lightning/blob/0eda6a5ce768513acedc3e1f930e2b3ad4936f81/common/derive_basepoints.h

oh maybe the peer id is: private_key_node = hkdf(32, hsm_secret, b"\x00", b"nodeid"). Last question, How can I analyse the message between two nodes during open the channel?

Nop the node_id is the node public key, the one you use when you connect. Regarding your implem, https://github.com/ElementsProject/lightning/blob/master/tools/hsmtool.c might inspire you :-) . If you have any question about it feel free to ask here or on IRC (#c-lightning).
About your last question, you can set log-level (iirc, or loglevel) to io to everything that comes in or out each node.

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


text:
nSequence doesn't block my transaction
I'm studying how Timelock works.
I'm able to create transaction with absolute time, nLocktime and OP_CLTV. Now I want to understand the relative part, and I start with nSequence.
At the moment I use createrawtransaction to create my raw transaction, where
bitcoin-cli createrawtransaction '[{"txid":"'$TXID'","vout":'$VOUT',"sequence":'$TIME'}]' '[{"'$ADDR_DEST'":'$AMOUNT'}]'

Where $TIME is:
$ gdate --date 'now + 512 seconds' +%s
1589189045

Human Readable: Mon May 11 11:08:44 CEST 2020
I mined some blocks and my median time is Mon May 11 11:13:05 CEST 2020, When I try to send my Transaction I get this error:
error code: -26
error message:
non-BIP68-final (code 64)

Here my raw transaction
020000000001012d343a729ac2addc97ebdfd6e086b4c31060546b51134f208360fb2e3989c9cc00000000001c16b95e016036f829010000001600147163053fa92512e2fb2004e9173e564bbdeb8ed40247304402203cd801bc04a71e14b08445357a2f542758cc0cf32f573a6e5489109bfa31a5b90220429c3aa40e670d1fdfee5e8f910604a3c9aa7e656e886dd8ba2591e6f22787440121037bc7eb8a954817f1b95f55f79b0927c7f42f71d461da845c08b0858d125df23400000000

  {
  "txid": "f6cb3d437858ea1ddd81d45c1b391d27faf1b594e65d7f0ae312fc55f67aff12",
  "hash": "b833a701caaba372cdd87e01c08c18755d40bd9fc20568571f2d45be3d219781",
  "version": 2,
  "size": 191,
  "vsize": 110,
  "weight": 437,
  "locktime": 0,
  "vin": [
    {
      "txid": "ccc989392efb6083204f13516b546010c3b486e0d6dfeb97dcadc29a723a342d",
      "vout": 0,
      "scriptSig": {
        "asm": "",
        "hex": ""
      },
      "txinwitness": [
        "304402203cd801bc04a71e14b08445357a2f542758cc0cf32f573a6e5489109bfa31a5b90220429c3aa40e670d1fdfee5e8f910604a3c9aa7e656e886dd8ba2591e6f227874401",
        "037bc7eb8a954817f1b95f55f79b0927c7f42f71d461da845c08b0858d125df234"
      ],
      "sequence": 1589188124
    }
  ],
  "vout": [
    {
      "value": 49.991,
      "n": 0,
      "scriptPubKey": {
        "asm": "0 7163053fa92512e2fb2004e9173e564bbdeb8ed4",
        "hex": "00147163053fa92512e2fb2004e9173e564bbdeb8ed4",
        "reqSigs": 1,
        "type": "witness_v0_keyhash",
        "addresses": [
          "bcrt1qw93s20afy5fw97eqqn53w0jkfw77hrk5vtmsdk"
        ]
      }
    }
  ]
}

The same logic works with nLocktime.

See What does the sequence in a transaction input mean?
1) You need to set bit 22 in the nSequence to indicate the value is a timestamp, not a number of bocks.
2) You are trying to put an absolute timestamp into nSequence, but nSequence is used for relative time.
So if you want the relative timelock to be 512 seconds, your nSequence should be:
1 |= (1 << 22)
or 4194305

thanks for reply, I can't put hex formato in createrawtransaction, I need to use number. I tried even with 0x00400001 (512 seconds) But without lucky

I updated my answer, does that help?

thanks again. I tried with 4194305 or with 4194312 (more time) But I can send the transaction immediately bitcoin-cli createrawtransaction '[{"txid":"'$TXID'","vout":'$VOUT',"sequence":4194314}]' '[{"'$ADDR_DEST'":'$AMOUNT'}]'

What is the nLocktime of the TX? https://bitcoin.stackexchange.com/questions/88289/what-is-transaction-finality

00000000, I need to change nLocktine If I use CLTV, Or I mistake?

read the question I just posted and make sure you understand the difference between nSequence and nLockTime. Your question is about relative locktime so I assume CLTV is not invovled.


text:
How to find xPub from wallet address
I'm trying to find a master public key (I believe this is the xPub) of an electrum wallet I no longer have access to. This is ok, I've moved all BTC from there. The thing is, I need the public key to keep track of my transactions.
Given the single wallet address I can find all the transactions on blockchain.com, but I'm not able to understand where some of the transactions sent BTC to. Is this possible?
For example, this addresses latest transaction: https://www.blockchain.com/btc/address/3DnByQ6HVhcFLj452uxWDZ7ZefSxQ6SsWE
states that 0.01403834 was sent somewhere, but it then lists 100's of addresses.
Which one of these was the 0.01403834 sent to?
Recap
To recap, I need a way to know either

the xPub key from a single wallet address OR

be able to read all transactions on an address on something like blockchain.com - That said this doesn't cover all the transactions on that wallet, it only covers transactions at that single address correct? So this leads me to believe I still need the xPub.

Knowing the xpub won't help you understand that transaction
An address used 46699 times receiving hundreds of millions of dollars is probably one that belongs to an exchange.
Addresses that start with 3 are P2SH. The H means hash. You can't find the xPub key from a hash.

Even if you somehow knew the public key used in the comstruction of an address, that would still not permit you to find the xpub it was generated by.

You need to be able to recover the wallet in order to get the xPub.
An xPub is what derives all the receive addresses, the process cannot be reversed.


text:
Withdrawal Transaction Went to Mempool
I am very noob in bitcoin world and I have invested at one of the BTC trader.
After trading and making profit I did the withdrawal  transaction of rupees 5220$ And suddenly it went in pending state.
After sometime I got email my transaction went in Mempool.
Can any one tell me what is Mempool and how can I get my withdrawal clear from it.

I believe your BTC trader is a fake. They are a confidence trickster. They are trying to confuse you. They will ask you to pay an extra fee, they will keep inventing fees until you realise they do nothing but take money.
For reference, all Bitcoin transactions are copied across the Bitcoin network and every computer in the network keeps a list of unconfirmed transactions. This list is often called the mempool. Every computer with normal Bitcoin software has its own mempool. All transactions go into the mempool until they are confirmed. This is an unimportant detail. Your fake trader is only mentioning it in order to confuse you.
If a genuine trader was negligent and specified a very low transaction fee, the transaction might take longer than normal to be confirmed. It is the trader's responsibility to take whatever action is needed. A genuine trader would not need to tell you about this and would not need to increase any fee you are paying - all withdrawal fees should be fixed in their terms and conditions and should never come as a surprise to their customers.
No genuine business ever need to initiate email communication with a customer for such matters.
See

How do I recover from a cryptocurrency scam?

The mempool is the queue of unconfirmed transactions. If the message is accurate, it means that the sender submitted the transaction to the network and it is in queue to be included in the blockchain. If the sender included the transaction identifier (or "txid") for the transaction that pays you, you can use that txid to check the status of the transaction, e.g. on mempool.space.


text:
Multisig with existing single sig + passphrase
If I take 2 brand new HW wallets (like a Coldcards), plus an existing hw single sig wallet that has a passphrase and finds already assigned to it (like a Trezor)and then create a new multisig 2 of 3 set up, will the passphrase be required to use the existing Wallet within the multisig (to send, for instance)?
If I don’t want the passphrase to be required, but have funds on the existing wallet already, how would I go about moving the funds and creating the multisig with these 3 wallets, where no passphrase is required for that existing wallet?
Hope this is clear and thank you.

will the passphrase be required to use the existing Wallet within the multisig (to send, for instance)?

If you don't choose to sign with the Trezor's key, then no. Given that you have 2 master private keys out of the total 3, you don't have to access the Trezor one, and thus, no need to type the passphrase. However, if you want to spend using a signature from Trezor, you'll need the passphrase, because master private keys with a passphrase aren't stored in the device.
Quoting wiki.trezor.io/Passphrase:

The passphrase is not stored anywhere on the device. It is only used temporarily whenever you enter it.

If I don’t want the passphrase to be required, but have funds on the existing wallet already, how would I go about moving the funds and creating the multisig with these 3 wallets, where no passphrase is required for that existing wallet?

Not sure I understand what you mean here. If you want to move funds from your 2-of-3 multi-sig (with the passphrase) to a 2-of-3 multi-sig (without the passphrase) you don't need to access the Trezor, as I've said above.

Sorry if I’m not being clear.
How can I use the single sig + passphrase in multisig, but not require the paraphrase when using that wallet doing MS transactions (only use when doing single sig)?  Or is this not possible to exclude existing passphrase from multisig if it’s part of the existing wallet? Thx

And I mean use for signing transactions.

Again, if you want to sign from the 2-of-3 multi-sig, you need 2 out of 3 signatures. If one of them has to come from Trezor, you need to type the passphrase.

Got it. So pasphrase has to be included if it was part of the original set up.
However, when it was set up, there is an “account” from just the 12 word seed, and the one that has the added passphrase.
How can I get the non passphrase account to be used in the MS set up and not the passphrase one (if possible)?


text:
If Multisig Xpub is compromised, but not the seeds or wallets
I have a multisig set up.
My seeds and hardware wallets are secure.
However, what would happen if someone got a hold of my Xpub file only?
Am I correct they could view my holdings and transactions, but without the minimum number of seeds/wallets, they could not send?
If I’m not sure Xpub file has been compromised, is it still a good idea to update my multisig set up?
Thank you

A multisig setup needs all cosigners' extended public keys because any of them, at any time, without the real time manifestation of the others, can derive the child public keys and generate all the addresses of this multisig.

However, what would happen if someone got a hold of my Xpub file only?

The multisig has N extended keys, where N is obtained from the format M-of-N multisig. If someone gets all of the extended public keys, they can generate all the addresses (watch-only wallet).

Am I correct they could view my holdings and transactions

You are.

but without the minimum number of seeds/wallets, they could not send?

Sending imply having the private key able to sign, which signature matches one of the public keys that construct the address. From the xpub file we cannot extract the private key, so no signing is possible.

If I’m not sure Xpub file has been compromised, is it still a good idea to update my multisig set up?

Sure is a strong word. If you think someone is sniffing your wallet operations you could do that but as said, they could not sign any transaction.


text:
Why this witness doesn't seems to contain a public key?
I am learning how transactions are coded in the blockchain, so I used a python script to compute bitcoin address from public key. This works with the public key:
03416fe9ba17be8fe3f88011923135e83c6a0666fcb575de6ab337c7d6c8f41a5f
within the sigscript if this transaction:
https://www.blockchain.com/btc/tx/56beef8afe5a4b5b41225211e62c3e7bce5747c4c8dcdd982173e8496687794b
I correctly get the corresponding address:
15nrxBDLts1tEbowH1dLm5z84RVas7USmP
I tried with the same python code to check where is the public key of the first input of this transaction:
https://www.blockchain.com/btc/tx/01e7c525a5759cde1d04d2e9a363424053ace3ff1d2dde9cd1b368493254bd0d
I tried to check if I get the address of this input:
34xp4vRoCGJym3xR7yCVPFHoCNxv4Twseo
Unfortunately, I didn't manage to end with this address when I use the second field of the witness of this input, which should be the public key of the address I am trying to get (the one starting with 34xp):
02a720e54e39b28434a4c55462718b4584db973331a834141b8cad7e52c317f695
SHA256+RIPEMD160+b58encode on this data doesn't correspond to the address above (the one starting with 34xp), and I didn't figured out why, and where is the public key of this address in this transaction input.
Could anyone please give me a clue about it?

I found my answer in this post: Find sender's public key in SegWit Transaction
Without witness:
address = base58check( 0x00 + hash160(publicKey) )
With witness:
address = base58check( 0x05 + hash160( 0x00 + 0x14 + hash160(publicKey) ) )
With:

"+" operator is concatenation
hash160() is SHA256 + RIPEMD160
publicKey is the second element of the witness (the one I correctly identified in my question above), or the second element of sigscript if no witness

Well note that this is not a global rule, but the rule for the transactions I mentioned.


text:
Where Is Signature Data Stored In Post-SegWit Transactions?
If i'm correct, i am pretty sure that signature data such as the scriptsigsize
and scriptsig is stored outside the Tx_Data of a Bitcoin transaction. But then where is it stored? Is it in the block or is it somehow connected to the transaction-data?
Also, how is it possible that this Bitcoin included in the transaction can be unlocked if the signature data is external from the transaction?

From the perspective of new post-segwit nodes, the witness data is part of the transaction data. It is serialized in a new field, after all the transaction outputs, before the locktime field.
However, this field is stripped out before relaying to old pre-segwit nodes. So from the perspective of those old nodes, the witness data isn't just external - it just doesn't exist. They don't care about the witness data, as to them, these outputs are the equivalent of "True": anyone can spend them without any signatures.


text:
Online BTC wallet implemention with bitcoin-core
I have written a php code to register users and create wallet for them on bitcoin-core full node.My question is how can i manage users wallets.if i use loadwallet to load USER A wallet and get address and other managements what happen if USER B call it on same time?. how can i seperates users!

See: BIP 32, BIP 44.

@chytrik should i manage accounts on db?


text:
How Crypto Payment Processors Handle Wallet Balance Privacy?
If an online store accepts crypto payments directly into its wallet there is a problem:
"Anyone can make a small transfer to any BTC address derived from the MPK so they can watch the store's and its client's funds as soon as the owner transfers funds from her wallet. I suppose possibly that the person who did this wanted to know if cracking the store worth the effort."
In a previous question a user replied that a solution to this is to use a crypto payment processor like BitPay but:

How they handle wallet privacy? Isn't it the same? The BTC only gets
to make a higher number of transactions between different addresses
but still, they can be traced to the store owner's wallet and her
client's afaik.
Or if the transaction is too small to match the price of the
purchase, BitPay returns the transaction to the originating address
and the BitPay address that accepted the transaction gets dumped so
it can't be used to trace BitPay's customer real address?
Another way I think this could be avoided as well is if BitPay
converts the payment to fiat, then to BTC again and then transfer the
funds to the customer wallet.
Wouldn't it be easier just to avoid payment processors and convert
the BTC to a privacy coin like Monero? For example using a
transitional wallet in the store to accept payments, making smaller
transactions to an exchange, converting to Monero and back to BTC and
then transfer to the owner's real wallet?
Could this method conceal the store owner and her client's wallet
balance to any potential hacker who makes a small transaction to any
store wallet MPK derived address?
Or the only way is to use a payment processor? If so, then how they
conceal their customer's wallet balance?

Thanks for your attention, it's a confusing subject for me and I hope to have written my questions as succinctly & understandably as possible.

TL;DR: your question is a valid one; there is no easy solution but CoinJoin and XMR swaps will help.
The 3rd party payment processors use wallet that is shared for all customers so this specific attack against specific merchant is not effective. But then you have another problem: the payment processor itself will leak your data, 1) ~legally to multiple partners, surveillance companies, regulators and LE 2) accidentally due to security breach, ransomware, etc 3) illegally, the data will simply be sold at some point. So it's a big no-no.
So what are the options?
To start with, use open source, self-hosted payment processors running against your own node. Examples include https://btcpayserver.org/ or https://cypherpunkpay.org/ (disclousure: author).
Then either:

pass coins through JoinMarket or Whirlpool
swap coins to XMR via near-instant, no-KYC exchanges (then wait because you cannot simply swap the same amount back to BTC)

The important thing is to work with individual coins (UTXO-s) or very small groupings of these - just to fit minimal thresholds required by the privacy tool of your choice.
Another important consideration is to use separate Tor circuits (IP addresses) for each coin or group, because the whole point is to avoid linking them together.

First of all the initial assumption is incorrect. Just because you sent coins to one of my addresses doesn't mean you will see my whole wallet. My wallet software may incorporate those coins in a transaction but it may or may not include all the other unspent coins in my wallet. It'll select unspent coins according the amount I wish to send and incorporate only the ones needed to meet that amount.
The second thing is that it's hard to tell from the blockchain which addresses are part of my wallet and which ones aren't. So for example you may not be able to tell which outputs are change and which are intended for the recipient.
As for bitpay they generate their own addresses and don't ask you for your MPK. To get paid you have to initiate a withdrawal. They pay you in fiat if that's what you request or they send bitcoin to your wallet. They don't pay you after every transaction. Only the total amount when you ask for it.
Bitpay is totally regulated so you will have to comply with anti money laundering and know your customer laws.
There are no originating addresses in bitcoin. You certainly can't safely assume that sending money to the address where the transaction's inputs were previously sent is the same as refunding the sender. To refund the sender you ask them for their address.

So, if you can't see the whole wallet. What is the purpose of this transaction?:
Someone purchased a product in my store, he saw my public address but only made a 2k satoshi transaction to it instead the full price of the product. He also made two more purchases to see my LTC and ETH public addresses but made no transaction to them, only to the BTC. Someone answered in a previous question I made that it was to see my wallet and my client's, the volume of my crypto sells so to speak. You can check my profile if you need additional info about that question and the transaction link itself.

@ManjaroDan It could have been a mistake. For example electrum defaults to mbtc as the unit of account. new users think they are spending in btc so the amount they send ends up being 1/1000th of the intended amount. if you multiply the amount she sent you with 1000 do you get the correct amount?

no I'm completely sure they were three transactions with ill intent. It used a fake name, disposable email, fake phone number, fake IP, and the BTC amount is not 1/1000th of the intended amount.

@ManjaroDan mark these specific tiny UTXO-s as spam in your Bitcoin wallet. The wallet won't spend them and so the attack will be ineffective.

@CypherpunkDev which wallet supports marking utxos as spam?


text:
Imported Address
I had some btc in a hardware and I transferred to my new blockchain account. But now it shows in a imported address.
Do I have access from my blockchain? Can I sell, exchange … or watch only?

How did you transfer? By sending coins, or by importing an address?

I think importing. I’m new at this

In that case, there is no way that your blockchain.info can spend the coins, as it does not have the key.

Can I put the key somewhere? I n the blockchain i mean

That would defeat the purpose of a hardware wallet. If it functions correctly, there should be no way to extract the private keys from it. If you want to move the coins off the device, move them by creating a transaction. I'm also a bit puzzled why you'd want this in the first place, given that you already appear to have a hardware wallet (a very decent option for self custody), and would be moving to the very flimsy security an online wallet provides.

The hardware it’s actually my father’s and he has others wallets there. And he wants to give me one

An imported address is watch-only and cannot be used to spend money.
See

I am new to Bitcoin, how can I get started?
Watch Only Wallets
What kinds of wallets are there?
https://bitcoin.org/en/choose-your-wallet

So I can learn. Why people use this?

One use for imported addresses is for a  wallet you can use to monitor your balance without any risk that someone could use the wallet to steal your money or that a virus or malware infection of the PC can steal money. Meanwhile you keep the private keys in a separate "cold wallet" on a PC or device that is not ever connected to any network (Wifi, bluetooth, ethernet, etc) and is therefore much safer. A watch-only wallet can receive money and calculate a balance but cannot spend it.

Thank you so much for the information! So if I want to use or spend the only way it’s to transfer?

The way I understand what you describe is that your father can spend the money but you can't. If your father wants to give you the ability to spend this money, the easiest way is for him to create a normal bitcoin transaction paying you by sending money to a receiving address you generated using a wallet you created yourself - preferably not a custodial wallet like a blockchain account unless you plan to lose all the money in learning day trading or something :-)

That’s exactly what I need! So I need to ask for a transaction. What is a custodial wallet? I’m not going to lose it I promise lol

See third link re custodial wallet


text:
Why do I need to download the entire blockchain for a wallet when I can make one one with open source java like bitaddress.org
Like title said. And when i will have to use the btc I can login the wallet with the private key on a hot wallet.

Downloading the blockchain makes it possible for your wallet to verify transactions and therefore protect you against some types of deception and theft. It is how Bitcoin achieves its inventor's main goal that one party can pay a second party without any need for a trusted third party.
Yes you can have separate cold and hot or watch-only wallets.

Related:

What kinds of wallets are there?
Why does bitcoin core need to download the blockchain


text:
How to identify a transaction input type?
I am currently working on a tool parsing every transaction of the bitcoin blockchain, using the getrawtransaction RPC call in verbose mode.
My goal is to store them all in a database, while keeping some useful information about them (i.e., not everything that is given by the RPC call).
Something I am having trouble to understand though is how to precisely "tag" an input with a type? The outputs all have a "type" string that allows me to tag them as P2SH, P2PK, P2WSH, etc, but the inputs don't.
What I tried up to now is to parse the content of the scriptSig attribute of the inputs. For example, to know if an input is P2PK, I read somewhere that the ASM code of the scriptSig of the input should start with 30. When I compare with some online tools that have already tagged every transaction inputs/outputs, it looks like it's accurate, but I don't have any proof that what I am doing is right.
Is there some kind of online resources with precise specifications allowing me to identify an input? I cannot manage to find any.
Another idea I had is that each output is, obviously, linked to an output.
Could I suppose that the type of input is the same as the one of the output it is linked to?
It would make sense to me, but I would rather not jump to conclusions; I still have a lot to learn about Bitcoin.
Thank you very much!

Looking at the transaction in raw (serialized) format, neither inputs nor outputs have their own type. In other words, it is not indicated anywhere what type they are. However, there are certain standard output formats such as P2PKH, P2SH, P2WPKH etc. You can see the complete list of all standard formats at the following link. What getrawtransaction (like many other functions within Bitcoin RPC) does is generate additional fields in the JSON result based on the actual content of the transaction to make it easier for end users. Unfortunately, one of those additional fields is not an input type.
The way to see what type of output a certain input unlocks (and therefore implicitly what type that input is) is to look at a pair of transaction-output referenced by a certain input and based on the content/format of that referenced output (link above) determine the type of input.

Thank you very much for your answer, Filip, it will be very useful to me.
However, one of the additional JSON fields in the outputs of a transaction is type, and after testing with a few transactions, using the table you provided me, this field seems accurate (e.g., a P2WSH output will have the type witness_v0_scripthash and the format is the one from the table).
Do you know how this type field is generated? Would the other fields be parsed to deduce the type?

@Lev The type field is not an actual part of the transaction, Bitcoin RPC determined this field based on the content of the output script (scriptPubKey). For example, if it sees the content OP_HASH160 OP_PUSHBYTES_20 32-bytes OP_EQUAL in the output script (scriptPubKey), it knows that the type is P2SH, etc. No, it is only necessary to read the content of the output script, ie. the content of scriptPubKey inside the output, to determine its type.


text:
Is there a cache mechanism with getrawtransaction?
I am currently working on a script that parses every BTC transaction from the beginning of the blockchain. My goal is to record summaries about each transaction in database, after synthesizing it.
While working on this, I observed that the first time I am using getrawtransaction, for 1000 transactions (i.e., 1000 RPCs), it takes between 20 and 30 seconds.
The second time I do the RPCs, for the same 1000 transactions, it takes less than 1 second.
My conclusion is that there is some caching mechanism set up, somewhere. I do not know if it is caching at the OS layer or at the software layer, though, and cannot manage to find any documentation on this.
Incidentally, I would like to be able to manage this mechanism to allow me to make requests more quickly.
Does anyone have an idea?
Thank you very much.

I'm pretty sure you're observing the disk cache. When you call getrawtransaction, Bitcoin Core first needs to check the transaction index (enabled by -txindex) and then load the transaction from its blk*.dat file (and rev*.dat file if you're also requesting prevouts), all of which are operations that access the disk. As far as I know, Bitcoin Core itself doesn't have a cache that would help in this situation.
Side note, if you want to process the entire blockchain with an external program, I'd recommend using getblock instead of getrawtransaction.

The database system Bitcoin Core uses for the txindex is LevelDB, which does have a small in-memory cache in user space. Still, I'd expect that the majority of what OP is observing is indeed the operating system's disk cache.

Thank you very much for your answer! The disk cache theory makes sense, and I noted your advice about getblock.

@vojtěch-strnad just to let you know that using getblock and parsing the transactions from there, instead of using getrawtransaction, has divided the time of my program by 3. Many thanks again!


text:
Why is it that some software crypto wallets are restricted to certain networks only?
My basic understanding so far is that crypto wallets are nothing more than a collection of the owner/user's public keys derived from the unique seed or mnemonic using different hashing algorithms. If that is the case, are there any technical factors that restrict certain crypto wallets from generating public keys for all public networks?

Are there any technical factors that restrict certain crypto wallets from generating public keys for all public networks?

Sort of.
There is an infinite amount of alternative chains, and there is an infinite amount of different mining algorithms that can be used, generally and technically speaking there is an infinite amount of different crypto-systems to be supported.
The infinite amount of crypto-systems to code support for, requires an infinitely large binary program for the wallet application.
As an infinitely large binary program is impossible, that is a technical factor that restricts every crypto wallets from generating public keys for every public network.

Now for the answer you probably really need, one can most definitely compile a binary program large enough so that almost every major cryptocurrency is supported. That's a very long shot, so what exchanges normally do is to build and run parallel "core" wallets for those many chains.

Networks as distinct cryptocurrencies
It is off-topic to discuss other cryptocurrencies but some wallet software that can be used for Bitcoin can also be used for other cryptocurrencies. However each cryptocurrency is different and it is often the case that even if they use some form of public-key cryptography, the specific form of keys can differ and so are usually not interchangeable. So yes, there are technical factors that make it more work to create multi-currency wallets. Arguably it would also be poor security practise to use the same seeds or private key for several currencies that have compatible keys.
Different cryptocurrencies often have completely different network protocols and completely different technical underpinnings. For example Proof-of-Work vs Proof-of-Stake.

Bitcoin networks
Bitcoin has several networks, mainnet, testnet and so on. I believe most Bitcoin wallets support them all.

Public networks
I don't know of any Bitcoin implementations for any public network other than the Internet and the Internet Protocol (TCP/IP). So far as I know, most of the competing public networks are now defunct: Minitel, X25 and soon ISDN and even the venerable PSTN.


text:
How are newly generated key-pairs kept unique to a single cryptocurrency?
As an extension to this question and some quick searches on software crypto wallets - my understanding is that any newly generated key-pair is unique to a specific cryptocurrency.
Assuming this is correct, how is this realized? In other words, how is this restriction imposed?

Key pairs are not unique to a specific cryptocurrency but addresses are. You can have the same key pair but it will lead to different addresses in Bitcoin and Litecoin for example, one starting with bc1 and the other one starting with L

I see, so if a public/private key pair were generated via some wallet app, the public key would then be hashed using an algorithm specific to a cryptocurrency in order to create an address?

yes pretty much, you would add a prefix to differentiate your coin after hashing

Thanks vm. And I assume that prefix is somehow pre-set before deployment of the coin or token?

Doesn't this sort of question  and this imply that, at some time, BTC, BCH and LTC had compatible and indistinguishable addresses that were not unique to a specific cryptocurrency?


text:
Why does an attacker need 51% mining power to overtake the blockchain?
I am really struggling to understand this thing about the 51% attack.
Usually whoever mines a block first wins.
My understanding is that mining is like a race. In a race, an athlete does not need to be faster than 50% of all the athletes combined. He just needs to be the fastest.
It's not like the entire network is working together as a single unit to solve the puzzle. They are working as separate entities, so their computational power isn't being added up.
So, if there are miners M1, M2, ...Mn and mining Pools P1, P2, ..Pm in the network with Pi (1<=i<= m) having the highest hash power Hi, I as a dishonest miner (or pool) would need to have a mining power Hx > Hi to eventually mine blocks quicker than than the rest of the network if I were working on a sidechain privately.
And when the time is apt, I can broadcast my sidechain which will became the main chain.
I understand my reasoning is flawed somehow, but I don't understand which part and why.
Can someone please shed some light on it?

In a race, an athlete does not need to be faster than 50% of all the athletes combined. He just needs to be the fastest.

Mining is simply not analogous to a race. Racers make progress towards the finish line, with the fastest racer eventually winning. There is no progress in bitcoin mining though: with each attempt (hash) you either find a correct block, or not.
So bitcoin mining is more akin to a dice-rolling game, with a poisson-distributed random chance of success for each attempt. The more hashpower you have, the more attempts you can make per second.
If you want to reliably out-compete the rest of the network (ie, 51% attack), you will need to have more hashpower than the rest of the network (ie, you'll need to control >50% of the total hashpower pointed at the network).

So, if there are miners M1, M2, ...Mn and mining Pools P1, P2, ..Pm in the network with Pi (1<=i<= m) having the highest hash power Hi, I as a dishonest miner (or pool) would need to have a mining power Hx > Hi to eventually mine blocks quicker than than the rest of the network if I were working on a sidechain privately.

In order to 51% attack, Hx > ((H1 + H2 + H3 + ... + Hm) / 2).
Considering only if Hx > Hi is insufficient, since Hi is not the only other entity mining. Any miner with any amount of hashpower can win the next block (with a probability proportional to their share of the hashpower), so you need to consider all miners together in you calculation.

"Considering only if Hx > Hi is insufficient, since Hi is not the only other entity mining".
I understand this when I am competing with the other miners on the original chain.
But, would the statement  also apply when I am mining on a secret sidechain?
For the honest miners, the algorithm works that a block takes 10 minutes on an average to be mined.
But, if I am working on a secret sidechain, I could take less than 10 minutes, and I will be the only one working on the sidechain, so I don't need to worry abt others.
So, I can build up faster than others?
I apologize if I am being thick

Yes, the statement still applies. You can mine on your secret chain, but everyone else will be mining on the public chain, and if they collectively have more hashpower than you, then they will (on average) find more blocks per unit of time than you will on your secret chain. You could take less than ten minutes to find a secret block (or more), but so could they. Its a game of averages, and those averages are contingent upon the proportion of hashpower each miner controls.

I still don't get the concept of "collective hashpower". That would have made sense to me if mining was a parallel process. But it's not. As soon as a block is mined, all the work done(on finding that block) by the other miners is discarded. Only 1 miner's work wins..It is the mining power of THAT 1 miner that was eventually harnessed.
So, I don't get it.
Been reading lots on this, and still remain unclear on it.
I guess, I will have to cram this 51% hashing power thing, and forego the quest of actually understanding the WHY of it. At least for now.
Thnx for your help and @RedGrittyBrick

Only one miner wins any given block, but that win only comes after all the miners have collectively attempted some number of hashes (on average). Failed attempts at finding a block are not 'wasted' work, they are not 'discarded', so to speak. See for example: https://bitcoin.stackexchange.com/a/113520/63872 , or this great article: https://grisha.org/blog/2018/01/23/explaining-proof-of-work/ (perhaps the "Difficulty is intergalactic" and subsequent sections in particular).

@chyrik. I think I understand it now.
I will try to phrase it as a separate answer to see if I get it correct.

My understanding is that mining is like a race.

This is the misunderstanding.
It is more like a sandy beach where someone scattered some small diamonds. The miners rush along the beach repeatedly picking up grains of sand to see if they are worthless quartz or valuable diamond. As soon as one diamond is found the beach is closed and all miners rush to a new beach. There are a fixed number of diamonds on the beach so the more miners, the less chance one miner has. A miner with a huge fleet of $100000 500 hp sand sifting machines has a big advantage over a miner that is one man with a magnifying glass and a pair of tweezers.

I hear you. My racing analogy was bad. What would be analogous to a miner working on a private sidechain in your each-diamond example?

Analogies always break down somewhere. Bitcoin mining is a unique game with unique characteristics. I could apply my imagination to the challenge but the result would be increasingly bizarre.

In short, you don't. But in order to have a probability approaching 1 at time infinity, you need 50% + epsilon. There is actually a table of calculations of the chain lenghth vs overtaking probability at the end of the original white paper. Check it out!

I read a lot of answers and articles to try to understand it. Thankfully, it was @chytrik's answer that clicked for me.
Going to post my understanding here.
Just for this discussion, say there are 1200 possible hashes. The fastest (also the dishonest one) miner produces 60 hashes per second. Say the others are at 20 hashes per second. Further, let's assume there are a total of 11 miners (including the dishonest/fastest one) in the network.
The dishonest miner working on a secret sidechain alone would need 20 (1200/60) seconds to try out all possible hashes.
OTOH, the rest of the honest network is trying 200 (20*10) hashes per second. So, they would need only 6 seconds (1200/200) to try out all hashes.
[Sidenote] This is an oversimplified assumption though because not all of these hashes will be unique. BUT, not all of them would be identical either because one of the parameters (for generating hashes) is timestamp.
And timestamps can and will be unique for a number of nodes, because
a) not all miners start mining at the exact same moment
b) timestamps are picked from the users' machines and can be changed
c) in the real world, miners will have separate hashrate which means they will be trying the same nonce at different timestamps, resulting in different hashes.
So, even if all 200 hashes are not unique, many of them will still be unique, and hence even if the number of unique hashes produced by all the miners (even though working independently) might not be 200 (in the above example), they would still be much much more than the lone dishonest miner.
[/Sidenote]
In other words, the chances of one of the hashes produced by the honest miners being the right one are much higher than that of the dishonest miner being right.
For the dishonest miner to try out all the hashes before the rest of the network, they would have to produce more than 200 hashes per second i.e. (<= 200 + x) hashes/sec . With the upgrade in the capacity of the dishonest miner, the collective capacity of the network is 200 (from the 10 honest miners) + (200 + x) from the dishonest miner = 400 + x
50 percent of the network power = (400 + x)/2 = 200 + (x/2)
And dishonest miner's hashing power = 200 + x  > 200 + x/2
Hence, the term 51% attack


text:
Is It Possible to Prove Ownership of Public Key Hash without Public Key?
I am building a system where I would like the user to specify a public key hash of a wallet that they have control over in the event of tips, refunds, and/or otherwise needing to send value back to them.
From there, I would like to further provide a feature that lets the user verify that they own this hashed address.
If I understand correctly, they can prove this by signing a message that I send them, and then they could send the signature back to me along with the public key.
However, I also understand that exposing your public key is considered less than ideal.
So, I am curious if there is some solution somewhere that will allow me to verify ownership based on the hashed address alone, without the use of a public key.
I suppose that since this verification process is transient and will not be permanently stored in a public blockchain (or anywhere else), it is not as potentially harmful of a scenario (or rather, more "trustworthy" for the user).  However, I am wanting to be as mindful to their privacy and security as possible and provide them with the opportunity to verify their ownership to this hashed address in the least invasive way available.
Is it enough to simply state somewhere in the user interface that this verification process will not store the public key in any way?  This is all assuming a HTTPS connection, but of course the risk is that since bad actors will know that public keys are being transmitted, it opens up one more potential vector of possible attack.
Also, I am very much interested in other approaches that are preferred/known here, as well as any examples of other sites and/or services that have tackled this problem in an elegant way.

Is using a central authority acceptable?

Sure @DavidSchwartz, please feel free to share.  I am new to this space and am interested in learning different approaches.  As this will be my first project it will probably have a hybrid approach to get my feet under me, so some elements will be central.

The simple answer is no.
A hashing algorithm is ment to be a one-way function. If it is possible to recreate the public key from the hash, this means that the hashing algorithm is broken.
However there is one aspect that you might find useful. For message signatures, bitcoin uses a custom encoding (compared to the DER encoded signature found in transactions).
Given a custom encoded message signature, the message and a public key hash, you can verify that the signature is correct. However, please note that this is because the custom encoded signature supports public key recovery. Therefore this results in the same security aspects as just supplying the public key, but with the benefit that the user does not need to specifically transfer the public key to you.
If you would like to test the custom encoded signatures, they are returned by the "signmessage" function in the bitcoin core client. They can then be verified by the "verifymessage" function, or by multiple online tools, such as this one:
https://blockexplorer.com/messages/verify

1) Generate a random private key just to be used to prove ownership.
2) Create a message with the corresponding public key to the key generated in step one and the public key you wish to prove ownership of.
3) Sign it with both private keys.
4) Send it to a central authority.
5) Receive from the central authority a signed statement saying that the owner of the public key corresponding to the private key you generated in step 1 belongs to the account you wish to prove ownership of.
6) You can now use the key you generated in step 1 to prove ownership of the account without revealing the account's public key to anyone since the signed statement from the central authority binds the key you generated in step 1 to the account, proving common control.

Alright I think I have my head mostly wrapped around this, @david-schwartz. Thank you for providing this workflow.  My confusion is in the 2nd step.  Should that read "and the public key hash you wish to prove ownership of."?  If the user is sending the public key of the account in question, they are still using their public key to prove ownership of a hashed address, which is what I am trying to avoid.  Or, is the implication/assumption here that this signed statement is to be stored somewhere by the user for use at a later date such as this scenario?

@Mike-EEE The user has to provide their public key to the central authority, otherwise the central authority can't check the signature on the request. But when providing proof to others, they can just use the statement from the authority without having to disclose the public key.


text:
Sending BCH from Copay
I have some BCH on copay, but I can't figure out how to send it out! If I send BTC I can easily select/type recipient(address) but in case of BCH recipient is my wallet and I can't change it? so my BCH is stucked in this wallet.
Any ideas please

Duplicate of https://bitcoin.stackexchange.com/q/76839/13866. You should edit your original question rather than repeat it. You may need to register and merge your multiple user-identities/accounts.

To send Bitcoin or Bitcoin Cash from the BitPay wallet, please follow the steps below:

Navigate to the Send tab in the BitPay app and paste the address you want to send funds to into the field at top.
Once on the Send tab, there will be a screen where you will put how much you want to send. Click on the ... option on the top right and tap on Max if you want to send the max amount which also includes the network/mining fees.
The last step will be confirming the address you want to send to and how much to send before sliding to confirm.


text:
how to stop bitcoin transfers from unknown parties?
How can you prevent bitcoins from unknown parties being transferred to any of your bitcoin addresses? if so, how? If not, why not?

Why would you want to do this?

@NateEldredge - i was contemplating what "services" might be "layered" over the prevailing bitcoin infrastructure; a couple of "proto-designs" needed some level of "control" over inputs to one's bitcoin addresses; obviously i need to better grasp the subtleties of the bitcoin protocol :(  however, as an aside, one would possibly not like to be receiving nefarious bitcoins from some spiteful drug dealer who might be inclined to want to take you (or your organisation) down when he goes down? scenarios like that?

Receiving Bitcoins is entirely passive. The receiver plays no part in the process whatsoever. There is no way to refuse a Bitcoin transaction, other than to transfer the Bitcoins back to the sender.

Bear in mind also that transactions do not have a "sender" as such. You can send the coins to the address they came from, but there's no guarantee that they will notice or even be able to spend them again.

@Anonymous Yep. And if it's a coinbase transaction, there's no sender at all.

thanx! figured that :(  likely this is well answered elsewhere? but is there a definitive set of documents fully explaining the bitcoin protocol somewhere? and by documents i mean a complete set of formal design documents in the one place! that provide everythin! data models, pseudocode & the like, so one can get a complete handle on the whole transaction design? note i do not mean wading through source code!  thanx in advance

bitcoin.it is the best place to start researching this topic, jTA, but unfortunately there is no master documentation online that spells it out clearly. however, there are many with technical knowledge on this forum as well as bitcointalk.org, so if you're adept at searching you can mostly find what you're looking for (or ask and post a bounty and someone will respond).

@bvpx Thank you! "there is no master ... " - I find this abs bl astounding :( and doing the strawdog-thing here or elsewhere seems the most fraught tactic, ever? :(  i've browsed bitcoin.it - obviously not in sufficient detail :( - i was contemplating what "services" might be "layered" over the bitcoin infrastructure but (unknown) subtleties within the protocol itself will clearly derail any/every design draft? v disappointing :(

No way.
But you can detect what coins transferred from one address and what coins transferred from another.
Look for example at the first address in the network:
12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX
http://blockchain.info/address/12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX
https://blockexplorer.com/address/12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX
Nobody can stop people to send bitcoins to Satoshi's address, first bitcoin address in the network.

I believe the first address in the network was this one: https://blockchain.info/address/1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa

By requiring identity before giving out a Bitcoin address, you can help to reduce the chances that a payment will be made by an unknown party.
Obviously, if you are using a static address, like how many charities do, then you won't know who the party was that sent the funds.
A related topic is the Bitcoin payment protocol (coming in Bitcoin v0.9) that is useful when issuing a payment request.  Depending on why you asked your question, that feature might be useful to you.

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


text:
What service does Multibit connect to?
Multibit is clearly a faster desktop wallet since it's a thin client that doesn't download and process the entire *8GB blockchain.
My question is, what service does Multibit connect to in order to process transactions? Are there security concerns to be aware of compared to using a thick client with its own blockchain? What benefits are there using a thick client (like Bitcoin-QT) compared to a thin client?

Multibit uses SPV, which is a peer-to-peer protocol consisting of two parts.

It downloads the block headers from peers (not the whole block). This allows it to verify that the blocks have a lot of hashing power behind them, and get the merkle root for each of them.
It asks peers for transactions matching the addresses it cares about. It can verify that the transactions belong to one of the blocks it knows about by using the merkle root.

See here for a discussion of the security tradeoffs.

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


text:
Can a miner's hashrate be derived from shares submitted at a given difficulty?
Trying to generate useful stats about client activity in a pool. If a quantity of submitted (timestamped) shares is known, and the difficulty of each share is known, how can the client's aggregate hashrate be determined?

hashes = shares * share_difficulty * 2**48 / 65535

thus:
megahash_per_second = shares_per_second * share_difficulty * 4295.032833

Conceptually: Compute the expected number of hashes required to find each share that is actually found and sum them. Divide by the amount of time to get the hash rate.


text:
Scripting multiple cgminer processes / running on a router
I'm running TomatoUSB (a Linux-based firmware) on a Broadcom-based home router. Connected to the router's USB port is a 7-port D-Link hub and a number of Asicminer USB Block Erupters.
Am finding some curious behaviors using this cgminer 3.3.1 binary as so:
./cgminer -o pool:port -u username.worker -p password

A single cgminer instantiation will crunch at the advertised 333 MH/s rate if one USB device is connected. But that number drops off precipitously when additional devices are added.
Interestingly, adding the "--usb :1" flag (which restricts the process to using one hotplug device) and then firing n processes this way gives me 333*n as hoped.
(I think) I need a worker for each process (not a huge issue I suppose). However on a headless system as this is, running these separately can get unwieldy very quickly. Currently I'm running one SSH client window for each process and firing each from the command line.
Is there a convenient way to script a number of these to be fired at once, each using one hotplug device, and hopefully redirecting the numerous console outputs somewhere useful? Maybe somehow share a configuration file among many processes?

That's an interesting approach. It's probably cheaper than a Raspberry Pi.

Put your startup script in a file:
./cgminer -o pool:port -u username.worker -p password --usb :$1

Save to start_single.sh, then
$ chmod u+x start_single.sh

Make the final script:
NUM_MINERS = 7
cd "$(dirname "$0")"
parallel -j $NUM_MINERS -- ./start_single.sh $(seq 1 $NUM_MINERS)

Save as start_all.sh, then
$ chmod u+x start_all.sh

Run ./start_all.sh to mine.

If you want to start the script on startup, google 'TomatoUSB start program on startup'

Script works well and I have a number of Block Erupters connected, each feeding one process. Though I am getting a higher-than-expected error rate. For example, for every 1000 accepted blocks I'm getting only one or two rejected blocks but anywhere between 25 and 50 "HW" (hardware I suppose?) errors.  According to my pool I am still producing at the advertised rate. I may try to turn up debugging in cgminer to see what's happening.


text:
Is there an Android Bitcoin app that can interact with other Android Apps on the same device?
Suppose I'm developing a Bitcoin-based Android app.  It could do anything: user pays Bitcoins to play a game, order a pizza, accept charitable donations.  Whatever it does, it does it in Bitcoins, and it's targeted to people who are Bitcoin savvy and probably already have the ability to access Bitcoins on their Android device.  I don't want to deal with the user's wallet, nor do I want the user to have to trust their wallet to my app.
I can think of two ways to do this:

1) there already is a Bitcoin wallet app that runs an  Android Provider that my app can access.  When I need to send Bitcoins from the wallet, my app communicates with the Provider, and the other app gets the user's approval and protects their wallet from my app stealing their Bitcoins.
2) There is a Bitcoin wallet app that I can send an Android Intent to, and as in #1 that other app confirms the user's approval before any Bitcoins leave the wallet.

So I have two questions:

Am I missing another way to do this?  To make an app that can send the user's Bitcoins without me touching the wallet directly but using some other app they already trust?  (And without cutting and pasting a Bitcoin address.)
Assuming this is the way to do it, are there any such Android apps?

A search of Google Play for "Bitcoin" turns up many results, but from a small sample the only ones I've seen that actually transfer Bitcoins seem to work off QR codes or NFC.  They will interact with other Android devices, but I don't see one that interacts with other Android apps on the same device.  But then again, I doubt the description for end users would have information like that.

The answer is the integration-android subproject of bitcoin-wallet.
Start with the source repository for
the Bitcoin Wallet.
The source code for in-app payments is in the BitcoinIntegration.java file, which is under the integration-android directory.
Instructions for compiling this subproject and example source code for using it are given in this slide presentation by Mr. Schildbach
There is also a sample android app that demonstrates this feature.
My thanks to Andreas Schildbach for personally sending me the answer to this question!

Which jar files are needed for compile 'integration-android' ?

Have you seen some apps using barcode scanner?
I would definitely do it via intent to such app.
I haven't seen such a feature, but it should be in some wallets.
Please note that people are using QR codes to create Donate! button, so there must be a popular wallet that scans them in order to donate, so it's plausible that you can send an intent to this wallet.
Alternatively, you can create QR code (hidden) in your app, send it to wallet app, which will scan it :).
It is not clear solution, but you see it is possible right now.
Best regards

Sounds good.  What's the app?

bitcoin-wallet from Schildbach. It's OS and is also available on Android Market. It can scan QR codes or use NFC to send payments. This is presumably the most popular android wallet: 1st place on Market and 1st place on bitcoin.org in category Mobile Wallets

And how, exactly, does one use an Android device to scan a QR code from the same device?  Are you suggesting the user display a QR code on the device then stand in front of a mirror to take a picture or something?  Please share your thinking on this matter!

There's no need to go via qr codes. For example, a pizza app could just display an address as text, which you can copy and paste into the wallet app.


text:
Can't get into my MultibitHD wallet. I have the 18 recovery words but can't recover the wallet
I'm trying to login to my MultibitHD wallet and its saying the password won't unlock the wallet. I might have forgot the password, but I have a feeling I'm using the right password.
I have the 18 words to recover the wallet (I regret making it 18 words, I should have stuck with 12 words so I could import it using another wallet) but heres what happens when I try to recover the password:

It just gets stuck on that last page, nothing happens. Over the years I'm always running into problems like this with MultibitHD, usually I can recover it with the words though. This time I can't. I have about €100 of bitcoins in there so this is a problem. I tried to restore the wallet from a backup point but that didn't work either. Is there anything else I can do?

Since MultiBit HD uses BIP 39 for its "wallet words" (everywhere else these are known as the mnemonic or the seed phrase), you can import them into any wallet that supports BIP 39 mnemonics.
I suggest that you import your mnemonic into Electrum. Note that by default Electrum does not use BIP 39 nor does it use the same BIP 32 derivation paths as MultiBit HD.
To import, download Electrum and create a new standard Electrum wallet. Choose the option for "I already have a seed". Then enter your seed phrase. Before clicking "Next", click the "Options" button and in the pop up dialog, choose "BIP 39 Seed". On the next page where it asks about derivation, delete everything in the text box and enter exactly m/0'. Continue the rest of the wallet setup as normal. In the end, you should have an Electrum wallet with your MultiBit HD seed phrase for the private keys. You should see your Bitcoin in your wallet now.
Here is a video produced by MultiBit that shows this entire process.


text:
Multiple input address to a single output address in one transaction?
If I have Wallet A with one address (call it A1) and Wallet B with 2 addresses (B1, B2), can I send BTC from A1 AND B1 to B2 in a single transaction thus incurring a network fee only once?

can I send BTC from A1 AND B1 to B2 in a single transaction thus
  incurring a network fee only once?

Absolutely. A transaction may contain multiple inputs and multiple outputs. The trick will be to get the wallet to do this for you. It will need to be aware of both address's private keys, and be able to let you select which inputs to use. Alternatively, you could construct the transaction manually.
See http://en.bitcoin.it/wiki/transaction


text:
Stablecoin / Fiat trading
I was exploring recent crypto news and it seems that i don't get a point in the stable coins trading.
Is there any logical reason to trade (with leverage) stable coins over fiat?


text:
Maidsafecoin sent to Ledger Nano S
I sent maidsafecoin to a segwit Bitcoin address generated by my Ledger Nano S.  My understanding is the coin is safe at the address and the Nano recorded the transaction as a very small amount of btc.  I have the bitcoin address.  Can I extract the private key from the Nano S that corresponds to the bitcoin address and so move the maidsafe coin?

The whole point of using a hardware wallet is that private keys can never leave the device, so no, there is no 'extract private key' function on the ledger.
The only way to gain access to individual keys is by using the recovery seed, but doing that is extremely unsafe.  The scheme used to derive child keys on a hardware wallet is incompatible with private key export as a single private key leaking could compromise the entire wallet.
Relevant BIP32 section

Note however that the following properties does not exist:

Given a parent extended public key (Kpar,cpar) and a child public key    (Ki), it is hard to find i.
Given a parent extended public key (Kpar,cpar) and a non-hardened child private key (ki), it is hard to    find kpar.


text:
How do I backup my wallet with bitcoin-cli over RPC?
hendry@knuckles ~ $ bitcoin-cli backupwallet /home/hendry/backup.dat
error code: -1
error message:
boost::filesystem::status: Permission denied: "/home/hendry/backup.dat"

Reddit couldn't help me https://www.reddit.com/r/BitcoinBeginners/comments/aftb91/am_i_running_bitcoin_core/
This is no permission problem.
hendry@knuckles ~ $ touch backup.dat
hendry@knuckles ~ $ ls backup.dat
backup.dat
hendry@knuckles ~ $ rm backup.dat

I suspect the bitcoind -server which runs in isolation as "nobody" is trying to access my home directory, which is a bit of a concern. My user's .bitcoin directory looks fine:
hendry@knuckles ~ $ find .bitcoin/
.bitcoin/
.bitcoin/mempool.dat
.bitcoin/wallets
.bitcoin/wallets/wallet.dat
.bitcoin/wallets/db.log
.bitcoin/wallets/.walletlock
.bitcoin/.lock
.bitcoin/chainstate
.bitcoin/chainstate/000003.log
.bitcoin/chainstate/CURRENT
.bitcoin/chainstate/MANIFEST-000002
.bitcoin/chainstate/LOCK
.bitcoin/fee_estimates.dat
.bitcoin/banlist.dat
.bitcoin/blocks
.bitcoin/blocks/index
.bitcoin/blocks/index/000003.log
.bitcoin/blocks/index/CURRENT
.bitcoin/blocks/index/000004.log
.bitcoin/blocks/index/MANIFEST-000002
.bitcoin/blocks/index/LOCK
.bitcoin/blocks/index/000005.ldb
.bitcoin/blocks/rev00000.dat
.bitcoin/blocks/blk00000.dat
.bitcoin/peers.dat
.bitcoin/bitcoin.conf
.bitcoin/debug.log

The process writing the file is bitcoind, not bitcoin-cli, which is simply issuing RPC commands to the server.bitcoind needs to be able to write to the destination, which can’t be another users home folders unless you explicitly give it permission.

I don't understand this model. I have my private ~/.bitcoin directory with my private stuff there I hope. I interact with the blockchain with bitcoind. It makes no sense for the bitcoind to be able to write to my home folder from my perspective.

The file list you posted is not of a synchronised node, by the way.

synchronized afaict https://s.natalian.org/2019-01-19/1547890087_2548x1398.png


text:
How to implement difficulty calculation in my code
So let's say we have to produce a hash that start with "0000"
I hash a block over and over by changing the nonce inside it.
Eventualy I will find a hash that start with "0000".
What is difficulty here? Is it the ammount of zéros we require the hash to start with?
More zero's would be more difficult? Does it have to do with the nonce?
I understand that the higher the difficulty the more hashes it will take to find it.
If my difficulty is one how do I apply the difficulty in the hashing process.
Right now all im doing is hashihing a block everytime I add 1 to the nonce wich represent the number of hash.
So how do I implement the difficulty in the hash calculation.
I am programming a blockchain from scratch!
Exemple of my code;
generateHash(block) {

     let hash = sha256(block.key)       // key contain the block data

     while(!hash.startsWith("f07a")) {  // we hash until the hash start with f07a
       block.nonce += 1                 // add 1 to nonce for each try
       hash = sha256(block.key)         // Trying with the new nonce
       //console.log(hash)
     }

     return hash

   }

So how would I implement difficulty here? I know i would have to do more math acording to network hashrate but to understand it in my case how would I use a difficulty of 1 here?


text:
Total Bitcoins in circulation on any given day?
I'm creating a spreadsheet to track total bitcoins in circulation from day 1.
This would be to add up each Bitcoin per day created and add to an accumulating total.
For example, if we picked any day we could then see what the total amount of Bitcoins created was.
If we picked the 1st January 2014 we could say the total Bitcoins mined equals X.
If we pick today (3rd June 2019) we could say the total Bitcoins mined equals X.
By definition, that would also mean we could calculate how many Bitcoins are left to be mined on any given day.
Could some one assist me to find the way to create this spreadsheet?
Thanks.

AFAIK the Bitcoin rules are tuned to produce a new block every 10 mins. The mining reward per block is a fixed amount which is halved at the end of each four-year period (210,000 blocks) . So the amount of BTC mined so far per day is a very simple function of time of day. -- Is that what you are asking about?

From command line the piping to date command needs a 2nd eye.  Bit late for me here, but it's a unix timestamp conversion to whatever format you want.
You can find out by:

getting the hash of each block at height X using the RPC or bitcoin-cli getblockhash X
using the blockhash to get information about that block using RPC or bitcoin-cli getblock <HASH>
get the timestamp of that block
convert timestamp into the date format you want
get the first transaction of the block (coinbase transaction) for the amount of newly mined coins using RPC or bitcoin-cli gettransaction <TX>

And run it through every block in a loop.
e.g.
bitcoin-cli getblockhash 1
00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048

 bitcoin-cli getblock 00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048 | jq '.time' | date
Mon Jun  3 18:54:45 UTC 2019

bitcoin-cli getrawtransaction `bitcoin-cli getblock 00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048 | jq -r '.tx[0]'` true | jq '.vout[0].value'
50

Here is block #1 on a btc explorer showing the same data, 50 new coins.
You can loop like that on command line but probably better to do with RPC and a real programming language.

This is not entirely correct. Coinbase transaction also pays out the fees of all the transactions in the block apart from the newly minted coins. So, in essence we will be double counting the number of coins generated if we follow your analogy.

I guess you're right.   The script will need to have some knowledge of block numbers of the halving intervals and know what the block reward is at a given height and ignore amounts greater than the block reward.

why complicate stuff? Every 210K blocks the block reward is reduced in half. Check the answer which is marked as duplicate to this question

Because the question is asking for a daily amount of coins created, different number of blocks mined on different days.

yes. Just multiply the number of blocks mined in the day * block reward (you know the block rewards if you know the block number). You don't have to go in the coinbase transaction.

It's not a dupe question anyway - different number of blocks mined per day.

There is at least one block where the coinbase transaction didn't claim the full block reward. Similarly, there are blocks where the transaction fees weren't claimed. These two things result in the number of coins being created not being what you'd expect, @UgamKamat, and coins being destroyed.


text:
Locate bitcoin from 11+ years ago
I bought bitcoin along time ago. It was at minimum 11 years ago. My bitcoin purchase info was emailed.
I remember the following after buying: getting an email which indicated the bitcoin info. I remember looking at the "garbled" text code I received indicating my bitcoin info. I just don't remember the exact details of the email other than basically don't lose this! (Wow has crypto buying and trading has seen some serious change)
Fast forward, I remember deleting the email and copying the info in a file (not sure which kind either .pdf or word probably) and naming the file under something unassuming. Well, now don't remember the file name and can only hope it is somewhere on my old computer backup before I bought my new computer. I tried searching "account" "bitcoin" "key" "access" but can locate anything.
Assuming I copied the info directly as it was in the email, what can I search for to find what I need? Anyone remember how it was back in the day?? This was so long ago and things have changed so much I really don't remember how it was or what I need to search for.

Try "seed", "recovery", "passphrase", "BIP39" and the like? https://en.bitcoin.it/wiki/Seed_phrase

@C-Otto iirc the keywords you mentioned all came into being at a later time than Zee has mentioned. It may be more helpful to simply search for 'private', 'key', 'paper wallet', 'bitcoin'-- assuming the mentioned timeline is correct.

It is possible that you might have used blockchain.info. They would email you your wallet ID after creating a wallet. If you still have access to the email account you used at that time, you can verify whether you will receive an email by inputting your address at the following link:
https://login.blockchain.com/en/#/login?product=wallet


text:
If I scanned my QR Code once with my android phone from a paper wallet, but now it wont..Why
I can no longer scan QR code from my paper wallet that I purchased from kiosk atm machine. I was able to scan it once, now the paper wallet has smears, rubbed off sections, etc. The kiosk machine's paper type resembles that of the slick paper used in an old fax machine and toner that smeared, smudged, etc just handling it a handful of times. Well, now I can only read by sight and a magnifying glass-all but 6/7 characters of the private key. I was able to make out the public address.
My thoughts are is it possible that my phone kept a copy of that one scan? If so, where & could I utilize it to gain access to move my bitcoin from paper wallet to my mobile wallet?

"I was able to scan it once" - with what did you scan it? A wallet app? Do you still have that app on your phone?

Does this answer your question? My bitcoin atm purchased paper wallet QR code & private key is not working from paper wallet to mobile wallet... why

I scanned it once just with my andriod ... no specific app. Even worse, I had to get an entire new phone..I could read the screen at all.

You used your phone's default camera app then? We can't give you a definite answer without knowing details to your device and Android version used. If you used a specific QR code scanner, s.a. Google Lens, there will most likely be some sort of history.

No app. Just samsung galaxy a21...which I had to replace with new phone since screen became unreadable...bunch of colored lines was all it would shhow.


text:
A wrong wallet situation
On 9th of this month I have my dad send me some bitcoin and I gave him my wallet for the payment.. after a while he told me he sent it I didn’t see it and I taught it was network and I would get it anytime soon it’s been 3 days before I realized he sent the bitcoin to my address buh a wrong letter match or something I really don’t understand the situation my wallet was written at the stop of the transaction and underneath where it says to: it was a different ending from my own just 1 later mixed up .. the question is can I get hold on the coin ? At any chance ?
So please guys anyone tell me what my chances are. Thank you

The address bc1qt9exjzedr9tzrlx3h6ckcjhtu2lk8w6ypny9jk appears to be a valid address which is basically impossible on a single letter mixup. Did you check whether it might actually be the correct address, but your wallet is just not properly synchronized with the network?

Bitcoin addresses have a checksum, so that mistyping a single letter should be detected as a mistake and money not sent.
If money was sent to an address neither you nor anyone else controls, the money is gone forever.
You can check exactly what transactions have occurred for a Bitcoin address at any of many blockchain explorers -- for example Blockchair shows no transactions relating to the address in the screenshot

Thank you for letting me know about that


text:
Convert public address to large integer
I need single integer converted from public BTC address. Is it enough to Base58Check decode the address and I will get hex/binary format of that integer or do I need to do something more?
What will be the format of Base58Check decoded data? Will there be any checksums, additional bytes?
I can write a script in Bash/Perl/Python if I would have instructions.

NOTE: This applies only to LEGACY ADDRESSES that start with a "1". Addresses starting with "3" have 0x0014 appended to the beginning and are Base58Check encoded, while addresses starting with "bc1q" have 0x0014 appended to the beginning but are encoded with Bech32 Encoding.
You will get Hex/binary after decoding from Base58Check. There should be 20 bytes after decoding the Address to get the public key's hash. If whatever process or function you're using to Base58Check decode doesn't remove the version byte and checksum, you will have 25 bytes instead: The first byte will be 0x00 (the version), and the last 4 bytes (the chscksum) will be the first 4 bytes of the double SHA256 hash of the other 21 bytes.
What you'd be converting to a large integer is the HASH160 of the Public Key; aka, the result of taking the public key in compressed format (33 bytes) and running it through SHA256 then running that hash through RIPEMD-160.
More information about legacy addresses can be found here. Additionally, I've written a breakdown on how addresses are created here.


text:
Why is Bitcoin core deleting my blk files while downloading blockchain?
I want to download the bitcoin blockchain to actually be able to parse it using the blk files, but as I'm seeing right now while installing, bitcoin core is deleting them and keeps downloading newer ones but I want to have everything related to block headers not transaction data. Is there a way to keep everything or only block headers ?
Thanks,

This sounds like you have pruning enabled. If pruning is off, no blk*.dat file should ever be deleted.