Skip to content

Commit 0b2d6a4

Browse files
committed
wip
1 parent 3f2d849 commit 0b2d6a4

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

src/wallet/coinselection.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -461,19 +461,20 @@ util::Result<SelectionResult> KnapsackSolver(std::vector<OutputGroup>& groups, c
461461
}
462462

463463
if (inner_groups.size() == 0) {
464-
// No output groups for this asset.
465-
return std::nullopt;
464+
std::string msg = tfm::format("No output groups for this asset: %d", it->first.GetHex());
465+
return util::Error{_(msg.c_str())};
466466
}
467467

468-
if (auto inner_result = KnapsackSolver(inner_groups, it->second, change_target, rng, it->first)) {
468+
if (auto inner_result = KnapsackSolver(inner_groups, it->second, change_target, rng, max_weight, it->first)) {
469469
auto set = inner_result->GetInputSet();
470470
for (const std::shared_ptr<wallet::COutput>& ic : set) {
471471
non_policy_effective_value += ic->GetEffectiveValue();
472472
}
473473
result.AddInput(inner_result.value());
474474
} else {
475-
LogPrint(BCLog::SELECTCOINS, "Not enough funds to create target %d for asset %s\n", it->second, it->first.GetHex());
476-
return std::nullopt;
475+
std::string msg = tfm::format("Not enough funds to create target %d for asset %s\n", it->second, it->first.GetHex());
476+
LogPrint(BCLog::SELECTCOINS, msg.c_str());
477+
return util::Error{_(msg.c_str())};
477478
}
478479
}
479480

@@ -510,24 +511,24 @@ util::Result<SelectionResult> KnapsackSolver(std::vector<OutputGroup>& groups, c
510511
}
511512

512513
if (inner_groups.size() == 0) {
513-
// No output groups for this asset.
514-
return std::nullopt;
514+
return util::Error{_("No output groups for the policy asset.")};
515515
}
516516

517-
if (auto inner_result = KnapsackSolver(inner_groups, policy_target, change_target, rng, ::policyAsset)) {
517+
if (auto inner_result = KnapsackSolver(inner_groups, policy_target, change_target, rng, max_weight, ::policyAsset)) {
518518
result.AddInput(*inner_result);
519519
} else {
520-
LogPrint(BCLog::SELECTCOINS, "Not enough funds to create target %d for policy asset %s\n", policy_target, ::policyAsset.GetHex());
521-
return std::nullopt;
520+
std::string msg = tfm::format("Not enough funds to create target %d for policy asset %s\n", policy_target, ::policyAsset.GetHex());
521+
LogPrint(BCLog::SELECTCOINS, msg.c_str());
522+
return util::Error{_(msg.c_str())};
522523
}
523524
}
524525

525-
if (result.GetSelectedValue() < mapTargetValue) return std::nullopt;
526+
if (result.GetSelectedValue() < mapTargetValue) return util::Error{_("Selected value is less than target value")};
526527
return result;
527528
}
528529

529-
std::optional<SelectionResult> KnapsackSolver(std::vector<OutputGroup>& groups, const CAmount& nTargetValue,
530-
CAmount change_target, FastRandomContext& rng, const CAsset& asset)
530+
util::Result<SelectionResult> KnapsackSolver(std::vector<OutputGroup>& groups, const CAmount& nTargetValue,
531+
CAmount change_target, FastRandomContext& rng, int max_weight, const CAsset& asset)
531532
{
532533
CAmountMap map_target{{ asset, nTargetValue }};
533534
SelectionResult result(map_target, SelectionAlgorithm::KNAPSACK);

src/wallet/rpc/elements.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ RPCHelpMan getpeginaddress()
203203
// option for dynafed-enabled ones as well
204204
ChainstateManager::Options opts{
205205
.chainparams = chainparams,
206+
.datadir = gArgs.GetDataDirNet(),
206207
.adjusted_time_callback = GetAdjustedTime,
207208
.minimum_chain_work = UintToArith256(consensus.nMinimumChainWork),
208209
.assumed_valid_block = consensus.defaultAssumeValid,

test/functional/feature_confidential_transactions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ def run_test(self):
248248
address = self.nodes[2].getnewaddress()
249249
unconfidential_address = self.nodes[2].validateaddress(address)["unconfidential"]
250250
value0 = 3
251+
print(self.nodes[0].getbalance())
251252
self.nodes[0].sendtoaddress(unconfidential_address, value0)
252253
self.generate(self.nodes[0], 101)
253254
self.sync_all()

test/functional/feature_default_asset_name.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def run_test(self):
4545
assert_equal(walletinfo1["balance"]["testasset"], 21000000)
4646

4747
#Send some of the default asset to the second node
48+
print(self.nodes[0].getbalance())
4849
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1, "", "", False)
4950
self.generate(self.nodes[0], 101)
5051
self.sync_all()

0 commit comments

Comments
 (0)