<blockquote>
<p>Why I have several address in l1?</p>
</blockquote>
<p>Maybe you mined some blocks to have the channel active ?</p>
<blockquote>
<p>How Can I get <code>bcrt1qkl3aajv8x9027dqqwhf2qmae99sl0ejhs2za0shyrrdyf8qhlkwsgphj96</code> ?</p>
</blockquote>
<p>As I detailed in <a href="https://bitcoin.stackexchange.com/questions/96627/get-public-or-private-key-from-address-with-c-lightning/96628#96628">your question regarding key derivation with C-lightning</a>, <code>lightningd</code> uses different derivation methods for different purposes.<br />
The (dev-only) RPC command you are using is listing addresses from the BIP32 tree used as your &quot;onchain wallet&quot; (used to generate addresses with <code>newaddr</code> or for channel claiming transactions, for example).</p>
<p>In order to examine channel-related transactions, you can use the <code>listtransactions</code> command. Quoting the help:</p>
<blockquote>
<p>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.</p>
</blockquote>
<hr />
<p>EDIT: follow-up of the questions in the comment. @MonkeyUser asks :</p>
<blockquote>
<p>yep, but in that case I want to understand how <code>bcrt1qkl3aajv8x9027dqqwhf2qmae99sl0ejhs2za0shyrrdyf8qhlkwsgphj96</code> is generated. which public keys are used? thanks</p>
</blockquote>
<p>During the funding process, the peers sends us a message [resp. we send the peer a message] telling &quot;hey, I want to open a channel with this configuration&quot;. The funding pubkey is part of this configuration.<br />
We then respond [resp. the peer responds] with a message telling &quot;Ok, here is my configuration. Be sure to respect it or I'll close the channel on you !&quot;. The second funding public key is part of this message <strong>(*)</strong>.</p>
<p>No matter if we are the funding or the funder, <code>lightningd</code> will use the &quot;<code>funding_basepoint</code>&quot; pubkey as our funding pubkey to construct the P2WSH multisig of the funding transaction.<br />
The basepoints are derived from deterministic informations of a channel as follows :</p>
<pre><code>channel_seed = hkdf_sha256(hkdf_sha256(hsm_secret, salt=NULL, info=&quot;peer seed&quot;), salt=peer_id | dbid, info=&quot;per-peer seed&quot;)
[funding, revocation, payment, htlc, delayed, shaseed] = expanded_hkdf_sha256(channel_seed, salt=NULL, info=&quot;c-lightning&quot;)
</code></pre>
<hr />
<p><strong>(*)</strong> In fact, we exchange a whole bunch of public keys and more specifically &quot;basepoints&quot; with this message. These are used to derive all the many keys needed for different operations (revocation, htlcs, payment, delayed payment, etc..).</p>

CC BY-SA 4.0
2020-06-30T16:59:47.477Z
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
CC BY-SA 4.0
2020-06-30T17:14:08.873Z
`lightningd` updates its view by parsing blocks from `bitcoind` : you (generally) need to have the transactions to be confirmed to see them `lightningd`-side.
Antoine Poinsot
CC BY-SA 4.0
2020-06-30T19:37:54.337Z
yep, but in that case I want to understand how `bcrt1qkl3aajv8x9027dqqwhf2qmae99sl0ejhs2za0shyrrdyf8qhlkwsgphj96` is generated. which public keys are used? thanks
monkeyUser
CC BY-SA 4.0
2020-07-01T07:53:00.927Z
@monkeyUser responded in the answer as the derivation is quite involved :-)
Antoine Poinsot
CC BY-SA 4.0
2020-07-01T14:32:12.887Z
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
monkeyUser
CC BY-SA 4.0
2020-07-01T14:41:01.023Z
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?
monkeyUser
CC BY-SA 4.0
2020-07-01T19:45:37.727Z
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.
Antoine Poinsot
CC BY-SA 4.0
2020-06-30T16:30:49.390Z
2020-07-01T07:52:32.547Z
2020-07-01T07:52:32.547Z
Antoine Poinsot
<p>I have two nodes in regtest.
the first one is:</p>
<pre><code>$ l1-cli getinfo
{
   &quot;id&quot;: &quot;02c3f99e70c8da59e428dd119d36c0a1317e5cd85218a760355b5f9b4f822f6109&quot;,
   &quot;alias&quot;: &quot;ALICE&quot;,
   &quot;color&quot;: &quot;ddff06&quot;,
   &quot;num_peers&quot;: 0,
   &quot;num_pending_channels&quot;: 0,
   &quot;num_active_channels&quot;: 0,
   &quot;num_inactive_channels&quot;: 0,
   &quot;address&quot;: [],
   &quot;binding&quot;: [
      {
         &quot;type&quot;: &quot;ipv4&quot;,
         &quot;address&quot;: &quot;127.0.0.1&quot;,
         &quot;port&quot;: 6060
      }
   ],
   &quot;version&quot;: &quot;v0.8.2-269-g6014644&quot;,
   &quot;blockheight&quot;: 1,
   &quot;network&quot;: &quot;regtest&quot;,
   &quot;msatoshi_fees_collected&quot;: 0,
   &quot;fees_collected_msat&quot;: &quot;0msat&quot;,
   &quot;lightning-dir&quot;: &quot;/tmp/l1-regtest/regtest&quot;
}
$ l1-cli  dev-listaddrs
{
   &quot;addresses&quot;: [
      {
         &quot;keyidx&quot;: 0,
         &quot;pubkey&quot;: &quot;032173996ba61da17cf20a15bbd72bc6f1e6dcace0ffa55e0a8c4de6cb1fde0cd4&quot;,
         &quot;p2sh&quot;: &quot;2N5tGiR5EkCv8gMYAs9myqQ7R6Wkgkcc1L5&quot;,
         &quot;p2sh_redeemscript&quot;: &quot;0014a0064ff5b87368717f4d7f8f7d84f8aa41de10e9&quot;,
         &quot;bech32&quot;: &quot;bcrt1q5qryladcwd58zl6d078hmp8c4fqauy8fj4vsrv&quot;,
         &quot;bech32_redeemscript&quot;: &quot;a0064ff5b87368717f4d7f8f7d84f8aa41de10e9&quot;
      }
   ]
}
</code></pre>
<p>the second is:</p>
<pre><code>$ l2-cli getinfo
{
   &quot;id&quot;: &quot;0214106517c1a81bf2dd8a3f37f6438e264ee17e270ed5c08110f584863f9bfa99&quot;,
   &quot;alias&quot;: &quot;BOB&quot;,
   &quot;color&quot;: &quot;021410&quot;,
   &quot;num_peers&quot;: 0,
   &quot;num_pending_channels&quot;: 0,
   &quot;num_active_channels&quot;: 0,
   &quot;num_inactive_channels&quot;: 0,
   &quot;address&quot;: [],
   &quot;binding&quot;: [
      {
         &quot;type&quot;: &quot;ipv4&quot;,
         &quot;address&quot;: &quot;127.0.0.1&quot;,
         &quot;port&quot;: 9090
      }
   ],
   &quot;version&quot;: &quot;v0.8.2-269-g6014644&quot;,
   &quot;blockheight&quot;: 1,
   &quot;network&quot;: &quot;regtest&quot;,
   &quot;msatoshi_fees_collected&quot;: 0,
   &quot;fees_collected_msat&quot;: &quot;0msat&quot;,
   &quot;lightning-dir&quot;: &quot;/tmp/l2-regtest/regtest&quot;
}
$ l2-cli  dev-listaddrs
{
   &quot;addresses&quot;: [
      {
         &quot;keyidx&quot;: 0,
         &quot;pubkey&quot;: &quot;03ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe62628&quot;,
         &quot;p2sh&quot;: &quot;2MsoPq7yYttm63u8yzRGgnYs44TTEe7z6ZS&quot;,
         &quot;p2sh_redeemscript&quot;: &quot;001463550e0be42780fef27416d022943739cfd06423&quot;,
         &quot;bech32&quot;: &quot;bcrt1qvd2suzlyy7q0aun5zmgz99ph888aqeprvsg6sw&quot;,
         &quot;bech32_redeemscript&quot;: &quot;63550e0be42780fef27416d022943739cfd06423&quot;
      }
   ]
}
</code></pre>
<p>Alice has 50 bitcoins in <code>bcrt1q5qryladcwd58zl6d078hmp8c4fqauy8fj4vsrv</code>
Alice connects to BOB</p>
<pre><code>$ l1-cli connect 0214106517c1a81bf2dd8a3f37f6438e264ee17e270ed5c08110f584863f9bfa99 127.0.0.1:9090
{
   &quot;id&quot;: &quot;0214106517c1a81bf2dd8a3f37f6438e264ee17e270ed5c08110f584863f9bfa99&quot;,
   &quot;features&quot;: &quot;02aaa2&quot;
}
</code></pre>
<p>Alice creates a channel with 0.05 bitcoin = 50000000000msat</p>
<pre><code>l1-cli fundchannel 0214106517c1a81bf2dd8a3f37f6438e264ee17e270ed5c08110f584863f9bfa99 5000000000msat                                │
{                                                                                                                                     │
   &quot;tx&quot;: &quot;02000000000101e5fd718b998672b2b38747f010676fc1300b8cb063649e8a922637941bbce6060000000000feffffff02404b4c0000000000220020b7e3│
dec987315eaf340075d2a06fb92961f7e6578285d7c2e418da449c17fd9d26a6b9290100000016001406d177ca4906c71db5d4240e31468ad6d93f3989024730440220│
4b35306bb23701b24102b3933289cd1e7a0b67c875d965c337cd7357946f1b9e022031f98d8f318d2b72d8f3621c2005378a78a103a6169536b940e31f51e05c8d2f01│
21032173996ba61da17cf20a15bbd72bc6f1e6dcace0ffa55e0a8c4de6cb1fde0cd400000000&quot;,                                                        │
   &quot;txid&quot;: &quot;dbb8a5f98d465c6cf438b8166a438a09c8118f2b62960ef99403be00e1ced8a6&quot;,                                                        │
   &quot;channel_id&quot;: &quot;a6d8cee100be0394f90e96622b8f11c8098a436a16b838f46c5c468df9a5b8db&quot;                                                   │
} 
</code></pre>
<p>Now I check the funding transaction</p>
<pre><code>bitcoin-cli getrawtransaction dbb8a5f98d465c6cf438b8166a438a09c8118f2b62960ef99403be00e1ced8a6 2

&quot;vout&quot;: [
    {
      &quot;value&quot;: 0.05000000,
      &quot;n&quot;: 0,
      &quot;scriptPubKey&quot;: {
        &quot;asm&quot;: &quot;0 b7e3dec987315eaf340075d2a06fb92961f7e6578285d7c2e418da449c17fd9d&quot;,
        &quot;hex&quot;: &quot;0020b7e3dec987315eaf340075d2a06fb92961f7e6578285d7c2e418da449c17fd9d&quot;,
        &quot;reqSigs&quot;: 1,
        &quot;type&quot;: &quot;witness_v0_scripthash&quot;,
        &quot;addresses&quot;: [
          &quot;bcrt1qkl3aajv8x9027dqqwhf2qmae99sl0ejhs2za0shyrrdyf8qhlkwsgphj96&quot;
        ]
      }
    },
    {
      &quot;value&quot;: 49.94999846,
      &quot;n&quot;: 1,
      &quot;scriptPubKey&quot;: {
        &quot;asm&quot;: &quot;0 06d177ca4906c71db5d4240e31468ad6d93f3989&quot;,
        &quot;hex&quot;: &quot;001406d177ca4906c71db5d4240e31468ad6d93f3989&quot;,
        &quot;reqSigs&quot;: 1,
        &quot;type&quot;: &quot;witness_v0_keyhash&quot;,
        &quot;addresses&quot;: [
          &quot;bcrt1qqmgh0jjfqmr3mdw5ys8rz3526mvn7wvf5pklnl&quot;
        ]
      }
    }
  ],
</code></pre>
<p>That address <code>bcrt1qkl3aajv8x9027dqqwhf2qmae99sl0ejhs2za0shyrrdyf8qhlkwsgphj96</code> is Segwit multisig.
Now If I check addr in l1 I can see</p>
<pre><code>$ l1-cli  dev-listaddrs
{
   &quot;addresses&quot;: [
      {
         &quot;keyidx&quot;: 0,
         &quot;pubkey&quot;: &quot;032173996ba61da17cf20a15bbd72bc6f1e6dcace0ffa55e0a8c4de6cb1fde0cd4&quot;,
         &quot;p2sh&quot;: &quot;2N5tGiR5EkCv8gMYAs9myqQ7R6Wkgkcc1L5&quot;,
         &quot;p2sh_redeemscript&quot;: &quot;0014a0064ff5b87368717f4d7f8f7d84f8aa41de10e9&quot;,
         &quot;bech32&quot;: &quot;bcrt1q5qryladcwd58zl6d078hmp8c4fqauy8fj4vsrv&quot;,
         &quot;bech32_redeemscript&quot;: &quot;a0064ff5b87368717f4d7f8f7d84f8aa41de10e9&quot;
      },
      {
         &quot;keyidx&quot;: 1,
         &quot;pubkey&quot;: &quot;03841e0be7af4049e44818cfab5248128806e22103b6177a0915e18fdb683875c8&quot;,
         &quot;p2sh&quot;: &quot;2N6aAJa7kbCVFx8cNMjRskR2beACY6AaPBA&quot;,
         &quot;p2sh_redeemscript&quot;: &quot;00146e289f089c56abb767fecd3e189489eb619ffa74&quot;,
         &quot;bech32&quot;: &quot;bcrt1qdc5f7zyu264mwel7e5lp39yfadsel7n5hnp04r&quot;,
         &quot;bech32_redeemscript&quot;: &quot;6e289f089c56abb767fecd3e189489eb619ffa74&quot;
      },
      {
         &quot;keyidx&quot;: 2,
         &quot;pubkey&quot;: &quot;020f91c2b34bc3a8cf3b56279fb7cae5a24ed3fb571cdfca2c35064e1d17d57b18&quot;,
         &quot;p2sh&quot;: &quot;2N5WmmNYJCr8eK2nJvf8N8QwV9zj9Lxree2&quot;,
         &quot;p2sh_redeemscript&quot;: &quot;0014751389f7ad7f0426e8fed655c0e40de0c06c3781&quot;,
         &quot;bech32&quot;: &quot;bcrt1qw5fcnaad0uzzd6876e2upeqdurqxcdup20v8lj&quot;,
         &quot;bech32_redeemscript&quot;: &quot;751389f7ad7f0426e8fed655c0e40de0c06c3781&quot;
      },
      {
         &quot;keyidx&quot;: 3,
         &quot;pubkey&quot;: &quot;03c2ecd5456ebf61168ef9536da277772c308798a5635f83e9ed60233bdf620958&quot;,
         &quot;p2sh&quot;: &quot;2N1rzfyGXpbPPjr7FhZsvaaaFiifvrxiEyd&quot;,
         &quot;p2sh_redeemscript&quot;: &quot;001478624d2bcd45fe2adf8c479a171634209adac754&quot;,
         &quot;bech32&quot;: &quot;bcrt1q0p3y627dghlz4huvg7dpw935yzdd4365xje7v5&quot;,
         &quot;bech32_redeemscript&quot;: &quot;78624d2bcd45fe2adf8c479a171634209adac754&quot;
      },
      {
         &quot;keyidx&quot;: 4,
         &quot;pubkey&quot;: &quot;033a1f02a7c19cba180defc087fdc0b48636a3d61adc4eb9d5ca1e8e6f21b12284&quot;,
         &quot;p2sh&quot;: &quot;2MvZeMyFSN4UWtYnTEBcTdtCjBi8kNVKKum&quot;,
         &quot;p2sh_redeemscript&quot;: &quot;001406d177ca4906c71db5d4240e31468ad6d93f3989&quot;,
         &quot;bech32&quot;: &quot;bcrt1qqmgh0jjfqmr3mdw5ys8rz3526mvn7wvf5pklnl&quot;,
         &quot;bech32_redeemscript&quot;: &quot;06d177ca4906c71db5d4240e31468ad6d93f3989&quot;
      },
      {
         &quot;keyidx&quot;: 5,
         &quot;pubkey&quot;: &quot;03c0032537904220bd32be2f8431597f4a49b23300face9212a49b469470b99ec3&quot;,
         &quot;p2sh&quot;: &quot;2NCARQgcBZzmYK6CfvTW1XMGXv2pddZnrxh&quot;,
         &quot;p2sh_redeemscript&quot;: &quot;0014a22f05c2da4a52fbef434d67b1fda4c228990145&quot;,
         &quot;bech32&quot;: &quot;bcrt1q5ghstsk6fff0hm6rf4nmrldycg5fjq29xt5gpx&quot;,
         &quot;bech32_redeemscript&quot;: &quot;a22f05c2da4a52fbef434d67b1fda4c228990145&quot;
      }
   ]
}
</code></pre>
<p>and in l2 I can see</p>
<pre><code>$ l2-cli  dev-listaddrs
{
   &quot;addresses&quot;: [
      {
         &quot;keyidx&quot;: 0,
         &quot;pubkey&quot;: &quot;03ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe62628&quot;,
         &quot;p2sh&quot;: &quot;2MsoPq7yYttm63u8yzRGgnYs44TTEe7z6ZS&quot;,
         &quot;p2sh_redeemscript&quot;: &quot;001463550e0be42780fef27416d022943739cfd06423&quot;,
         &quot;bech32&quot;: &quot;bcrt1qvd2suzlyy7q0aun5zmgz99ph888aqeprvsg6sw&quot;,
         &quot;bech32_redeemscript&quot;: &quot;63550e0be42780fef27416d022943739cfd06423&quot;
      },
      {
         &quot;keyidx&quot;: 1,
         &quot;pubkey&quot;: &quot;02e28aaf512284c08336782769b9af1eb816970f99b6fadb2faa5c0d65ddc24d7e&quot;,
         &quot;p2sh&quot;: &quot;2MvpYKgQ7hY4q86WSn5FQALFjezAtxuyvBM&quot;,
         &quot;p2sh_redeemscript&quot;: &quot;00143c67dd58505ad35c30dc19db622659dfc543566e&quot;,
         &quot;bech32&quot;: &quot;bcrt1q83na6kzsttf4cvxur8dkyfjemlz5x4nwxq9kpz&quot;,
         &quot;bech32_redeemscript&quot;: &quot;3c67dd58505ad35c30dc19db622659dfc543566e&quot;
      }
   ]
}
</code></pre>
<p>Why I have several address in l1?
How Can I get <code>bcrt1qkl3aajv8x9027dqqwhf2qmae99sl0ejhs2za0shyrrdyf8qhlkwsgphj96</code>?</p>
<p>I tried with public keys of l1 and public key of l2, but without lucky</p>
<pre><code>$  bitcoin-cli createmultisig 2 '[&quot;032173996ba61da17cf20a15bbd72bc6f1e6dcace0ffa55e0a8c4de6cb1fde0cd4&quot;,&quot;03ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe62628&quot;]' &quot;bech32&quot;
 bitcoin-cli createmultisig 2 '[&quot;03841e0be7af4049e44818cfab5248128806e22103b6177a0915e18fdb683875c8&quot;,&quot;03ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe62628&quot;]' &quot;bech32&quot;
 bitcoin-cli createmultisig 2 '[&quot;020f91c2b34bc3a8cf3b56279fb7cae5a24ed3fb571cdfca2c35064e1d17d57b18&quot;,&quot;03ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe62628&quot;]' &quot;bech32&quot;
 bitcoin-cli createmultisig 2 '[&quot;03c2ecd5456ebf61168ef9536da277772c308798a5635f83e9ed60233bdf620958&quot;,&quot;03ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe62628&quot;]' &quot;bech32&quot;
 bitcoin-cli createmultisig 2 '[&quot;033a1f02a7c19cba180defc087fdc0b48636a3d61adc4eb9d5ca1e8e6f21b12284&quot;,&quot;03ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe62628&quot;]' &quot;bech32&quot;
 bitcoin-cli createmultisig 2 '[&quot;03c0032537904220bd32be2f8431597f4a49b23300face9212a49b469470b99ec3&quot;,&quot;03ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe62628&quot;]' &quot;bech32&quot;
{
  &quot;address&quot;: &quot;bcrt1qdynj6dv4zq03ldfregnl3wwppt4gu0wm8xhn7gma48mg3s8vxswsau88sc&quot;,
  &quot;redeemScript&quot;: &quot;5221032173996ba61da17cf20a15bbd72bc6f1e6dcace0ffa55e0a8c4de6cb1fde0cd42103ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe6262852ae&quot;
}
{
  &quot;address&quot;: &quot;bcrt1q5kvw3x3gafcg83w6klfrdtdta6dmptc35fyxty58kzr7wzd3n83q46t7x6&quot;,
  &quot;redeemScript&quot;: &quot;522103841e0be7af4049e44818cfab5248128806e22103b6177a0915e18fdb683875c82103ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe6262852ae&quot;
}
{
  &quot;address&quot;: &quot;bcrt1q5fg097ujz8cl0hum4xt9x6mygzqhlvgkggkwqdlv7rvj8n0npk6qnzslpz&quot;,
  &quot;redeemScript&quot;: &quot;5221020f91c2b34bc3a8cf3b56279fb7cae5a24ed3fb571cdfca2c35064e1d17d57b182103ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe6262852ae&quot;
}
{
  &quot;address&quot;: &quot;bcrt1qhzj0jgl56uatnxdzhwczrf08ku9a6c7x7fjldsnrkam75evlzywsn4ww6w&quot;,
  &quot;redeemScript&quot;: &quot;522103c2ecd5456ebf61168ef9536da277772c308798a5635f83e9ed60233bdf6209582103ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe6262852ae&quot;
}
{
  &quot;address&quot;: &quot;bcrt1qsjm7zc0rhpzjmrldht7rxhp0y5ldu7c53da0fyr2jq3l9u03lz3q47r3r7&quot;,
  &quot;redeemScript&quot;: &quot;5221033a1f02a7c19cba180defc087fdc0b48636a3d61adc4eb9d5ca1e8e6f21b122842103ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe6262852ae&quot;
}
{
  &quot;address&quot;: &quot;bcrt1qgsp7ltzlq9qcqmqr2eqd5h8zm87ch9zfdfj256nzsuk4ys2nc4asr0sqxk&quot;,
  &quot;redeemScript&quot;: &quot;522103c0032537904220bd32be2f8431597f4a49b23300face9212a49b469470b99ec32103ac7ca112d8459dd119e83be0242f7f9f8e3c0b44286cb262d84aa3d99fe6262852ae&quot;
}
</code></pre>

<lightning-network><segregated-witness><multi-signature><core-lightning>
Retrieve address when create a channel lightning network
monkeyUser
# Retrieve address when create a channel lightning network

(Asked by: username_0 on 2020-06-30)

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

```

**Tags:** lightning-network, segregated-witness, multi-signature, core-lightning


---

## 1 answers

### Answer by username_1 on 2020-06-30. Score: 0 | Accepted answer

> 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](https://bitcoin.stackexchange.com/questions/96627/get-public-or-private-key-from-address-with-c-lightning/96628#96628), `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..).

> **Comments:**
> **username_0**: 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  
> **username_1**: `lightningd` updates its view by parsing blocks from `bitcoind` : you (generally) need to have the transactions to be confirmed to see them `lightningd`-side.  
> **username_0**: yep, but in that case I want to understand how `bcrt1qkl3aajv8x9027dqqwhf2qmae99sl0ejhs2za0shyrrdyf8qhlkwsgphj96` is generated. which public keys are used? thanks  
> **username_1**: @username_0 responded in the answer as the derivation is quite involved :-)  
> **username_0**: 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  
> **username_0**: 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?  
> **username_1**: 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.  

---

