(node_factory, bitcoind)
| 2129 | |
| 2130 | @unittest.skipIf(TEST_NETWORK != 'regtest', 'elementsd doesnt yet support PSBT features we need') |
| 2131 | def test_funder_contribution_limits(node_factory, bitcoind): |
| 2132 | opts = {'experimental-dual-fund': None, |
| 2133 | 'feerates': (5000, 5000, 5000, 5000)} |
| 2134 | l1, l2, l3 = node_factory.get_nodes(3, opts=opts) |
| 2135 | |
| 2136 | # We do a lot of these, so do them all then mine all at once. |
| 2137 | addr, txid = l1.fundwallet(10**8, mine_block=False) |
| 2138 | l1msgs = ['Owning output .* txid {} CONFIRMED'.format(txid)] |
| 2139 | |
| 2140 | # Give l2 lots of utxos |
| 2141 | l2msgs = [] |
| 2142 | for amt in (10**3, # this one is too small to add |
| 2143 | 10**5, 10**4, 10**4, 10**4, 10**4, 10**4): |
| 2144 | addr, txid = l2.fundwallet(amt, mine_block=False) |
| 2145 | l2msgs.append('Owning output .* txid {} CONFIRMED'.format(txid)) |
| 2146 | |
| 2147 | # Give l3 lots of utxos |
| 2148 | l3msgs = [] |
| 2149 | for amt in (10**3, # this one is too small to add |
| 2150 | 10**4, 10**4, 10**4, 10**4, 10**4, 10**4, 10**4, 10**4, 10**4, 10**4, 10**4): |
| 2151 | addr, txid = l3.fundwallet(amt, mine_block=False) |
| 2152 | l3msgs.append('Owning output .* txid {} CONFIRMED'.format(txid)) |
| 2153 | |
| 2154 | bitcoind.generate_block(1) |
| 2155 | l1.daemon.wait_for_logs(l1msgs) |
| 2156 | l2.daemon.wait_for_logs(l2msgs) |
| 2157 | l3.daemon.wait_for_logs(l3msgs) |
| 2158 | |
| 2159 | # Contribute 100% of available funds to l2, all 6 utxos (smallest utxo |
| 2160 | # 10**3 is left out) |
| 2161 | l2.rpc.call('funderupdate', |
| 2162 | {'policy': 'available', |
| 2163 | 'policy_mod': 100, |
| 2164 | 'min_their_funding_msat': '1000msat', |
| 2165 | 'per_channel_min_msat': '1000000msat', |
| 2166 | 'fund_probability': 100, |
| 2167 | 'fuzz_percent': 0, |
| 2168 | 'leases_only': False}) |
| 2169 | |
| 2170 | # Set our contribution to 50k sat, should only use 6 of 12 available utxos |
| 2171 | l3.rpc.call('funderupdate', |
| 2172 | {'policy': 'fixed', |
| 2173 | 'policy_mod': '50000sat', |
| 2174 | 'min_their_funding_msat': '1000msat', |
| 2175 | 'per_channel_min_msat': '1000sat', |
| 2176 | 'per_channel_max_msat': '500000sat', |
| 2177 | 'fund_probability': 100, |
| 2178 | 'fuzz_percent': 0, |
| 2179 | 'leases_only': False}) |
| 2180 | |
| 2181 | l1.rpc.connect(l2.info['id'], 'localhost', l2.port) |
| 2182 | l1.fundchannel(l2, 10**7) |
| 2183 | assert l2.daemon.is_in_log('Policy .* returned funding amount of 107470sat') |
| 2184 | assert l2.daemon.is_in_log(r'calling `signpsbt` .* inputs') |
| 2185 | |
| 2186 | l1.rpc.connect(l3.info['id'], 'localhost', l3.port) |
| 2187 | l1.fundchannel(l3, 10**7) |
| 2188 | assert l3.daemon.is_in_log('Policy .* returned funding amount of 50000sat') |
nothing calls this directly
no test coverage detected