2

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"
}
0

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..).

7
  • 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 – monkeyUser Jun 30 '20 at 16:59
  • lightningd updates its view by parsing blocks from bitcoind : you (generally) need to have the transactions to be confirmed to see them lightningd-side. – darosior Jun 30 '20 at 17:14
  • yep, but in that case I want to understand how bcrt1qkl3aajv8x9027dqqwhf2qmae99sl0ejhs2za0shyrrdyf8qhlkwsgphj96 is generated. which public keys are used? thanks – monkeyUser Jun 30 '20 at 19:37
  • 1
    @monkeyUser responded in the answer as the derivation is quite involved :-) – darosior Jul 1 '20 at 7:53
  • 1
    Nop the node_id is the node public key, the one you use when you connect. Regarding your implem, github.com/ElementsProject/lightning/blob/master/tools/… 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. – darosior Jul 1 '20 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.