diff --git a/lightningd/peer_control.c b/lightningd/peer_control.c index 812c88d5f..b52eb8a0c 100644 --- a/lightningd/peer_control.c +++ b/lightningd/peer_control.c @@ -2132,6 +2132,17 @@ static bool opening_funder_finished(struct subd *opening, const u8 *resp, &channel_info->remote_fundingkey, fc->change, &changekey, fc->peer->ld->wallet->bip32_base); + log_debug(fc->peer->log, "Funding tx has %zi inputs, %zu outputs:", + tal_count(fc->funding_tx->input), + tal_count(fc->funding_tx->output)); + for (size_t i = 0; i < tal_count(fc->funding_tx->input); i++) { + log_debug(fc->peer->log, "%zi: %"PRIu64" satoshi (%s) %s\n", + i, fc->utxomap[i]->amount, + fc->utxomap[i]->is_p2sh ? "P2SH" : "SEGWIT", + type_to_string(ltmp, struct sha256_double, + &fc->funding_tx->input[i].txid)); + } + fc->peer->funding_txid = tal(fc->peer, struct sha256_double); bitcoin_txid(fc->funding_tx, fc->peer->funding_txid); diff --git a/tests/test_lightningd.py b/tests/test_lightningd.py index 149d78a15..1326e8e1e 100644 --- a/tests/test_lightningd.py +++ b/tests/test_lightningd.py @@ -611,6 +611,16 @@ class LightningDTests(BaseLightningDTests): for n in [l1, l2, l3]: wait_for(lambda: len(n.rpc.getchannels()['channels']) == 4) + def test_second_channel(self): + l1 = self.node_factory.get_node() + l2 = self.node_factory.get_node() + l3 = self.node_factory.get_node() + + l1.rpc.connect('localhost', l2.info['port'], l2.info['id']) + l1.rpc.connect('localhost', l3.info['port'], l3.info['id']) + self.fund_channel(l1, l2, 10**6) + self.fund_channel(l1, l3, 10**6) + def test_routing_gossip(self): nodes = [self.node_factory.get_node() for _ in range(5)] l1 = nodes[0] diff --git a/wallet/wallet.c b/wallet/wallet.c index f0021132b..b433b1949 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -829,7 +829,13 @@ int wallet_extract_owned_outputs(struct wallet *w, const struct bitcoin_tx *tx, utxo->status = output_state_available; bitcoin_txid(tx, &utxo->txid); utxo->outnum = output; - if (!wallet_add_utxo(w, utxo, p2sh_wpkh)) { + log_debug(w->log, "Owning output %zu %"PRIu64" (%s) txid %s", + output, tx->output[output].amount, + is_p2sh ? "P2SH" : "SEGWIT", + type_to_string(ltmp, struct sha256_double, + &utxo->txid)); + + if (!wallet_add_utxo(w, utxo, is_p2sh ? p2sh_wpkh : our_change)) { tal_free(utxo); return -1; } diff --git a/wallet/wallet.h b/wallet/wallet.h index 553e2acf1..a1d423a30 100644 --- a/wallet/wallet.h +++ b/wallet/wallet.h @@ -40,7 +40,8 @@ enum wallet_output_type { p2sh_wpkh = 0, to_local = 1, htlc_offer = 3, - htlc_recv = 4 + htlc_recv = 4, + our_change = 5 }; /* A database backed shachain struct. The datastructure is