diff --git a/plugins/spender/multifundchannel.c b/plugins/spender/multifundchannel.c index ecaaa579a4d7..fccf0a4b6f6a 100644 --- a/plugins/spender/multifundchannel.c +++ b/plugins/spender/multifundchannel.c @@ -1259,6 +1259,19 @@ after_fundpsbt(struct command *cmd, || !amount_msat_to_sat(&all->amount, msat)) goto fail; + /* Subtract amounts we're using for the other outputs */ + for (size_t i = 0; i < tal_count(mfc->destinations); i++) { + if (mfc->destinations[i].all) + continue; + if (!amount_sat_sub(&all->amount, + all->amount, + mfc->destinations[i].amount)) { + return mfc_fail(mfc, JSONRPC2_INVALID_PARAMS, + "Insufficient funds for `all`" + " output"); + } + } + /* Remove the 'all' flag. */ all->all = false; diff --git a/tests/test_opening.py b/tests/test_opening.py index 8b5bee496ba6..6470c15106b1 100644 --- a/tests/test_opening.py +++ b/tests/test_opening.py @@ -2682,7 +2682,6 @@ def test_opening_explicit_channel_type(node_factory, bitcoind): assert only_one(l3.rpc.listpeerchannels()['channels'])['channel_type']['bits'] == [STATIC_REMOTEKEY] -@pytest.mark.xfail(strict=True) def test_multifunding_all_amount(node_factory, bitcoind): l1, l2, l3 = node_factory.get_nodes(3)