@@ -336,6 +336,37 @@ static std::vector<RerandomizationScalars> expand_rerandomization_scalars(const
336
336
}
337
337
// -------------------------------------------------------------------------------------------------------------------
338
338
// -------------------------------------------------------------------------------------------------------------------
339
+ static std::function<carrot::InputProposalV1(const crypto::public_key&)> extend_supplemental_input_proposals_fetcher (
340
+ const std::function<carrot::InputProposalV1(const crypto::public_key&)> &supplemental_input_proposals,
341
+ const UnsignedCarrotTransactionSetV1 &unsigned_txs,
342
+ const carrot::cryptonote_hierarchy_address_device &addr_dev)
343
+ {
344
+ // fake key image device
345
+ struct dummy_key_image_device : public carrot ::key_image_device
346
+ {
347
+ crypto::key_image derive_key_image (const carrot::OutputOpeningHintVariant&) const final
348
+ { return {}; }
349
+ };
350
+
351
+ // collect new in-set transfers by one-time address (w/o correct key images)
352
+ std::unordered_map<crypto::public_key, carrot::InputProposalV1> inset_input_proposals;
353
+ for (const exported_transfer_details_variant &etd : unsigned_txs.new_transfers )
354
+ {
355
+ const wallet2_basic::transfer_details td = import_cold_output (etd, addr_dev, dummy_key_image_device ());
356
+ inset_input_proposals.emplace (td.get_public_key (), make_sal_opening_hint_from_transfer_details (td));
357
+ }
358
+
359
+ // try to find in-set first, then use backup supplemental callback
360
+ return [&, inset_input_proposals](const crypto::public_key &ota) -> carrot::InputProposalV1
361
+ {
362
+ const auto inset_it = inset_input_proposals.find (ota);
363
+ if (inset_it != inset_input_proposals.cend ())
364
+ return inset_it->second ;
365
+ return supplemental_input_proposals (ota);
366
+ };
367
+ }
368
+ // -------------------------------------------------------------------------------------------------------------------
369
+ // -------------------------------------------------------------------------------------------------------------------
339
370
static crypto::hash ki2hash (const crypto::key_image &ki)
340
371
{
341
372
return carrot::raw_byte_convert<crypto::hash>(ki);
@@ -898,28 +929,8 @@ void expand_carrot_transaction_proposals(const UnsignedCarrotTransactionSetV1 &u
898
929
tx_proposals_out.clear ();
899
930
tx_proposals_out.reserve (unsigned_txs.tx_proposals .size ());
900
931
901
- // fake key image device
902
- struct dummy_key_image_device : public carrot ::key_image_device
903
- {
904
- crypto::key_image derive_key_image (const carrot::OutputOpeningHintVariant&) const final
905
- { return {}; }
906
- };
907
-
908
- // collect new in-set transfers by one-time address (w/o correct key images)
909
- std::unordered_map<crypto::public_key, carrot::InputProposalV1> inset_input_proposals;
910
- for (const exported_transfer_details_variant &etd : unsigned_txs.new_transfers )
911
- {
912
- const wallet2_basic::transfer_details td = import_cold_output (etd, addr_dev, dummy_key_image_device ());
913
- inset_input_proposals.emplace (td.get_public_key (), make_sal_opening_hint_from_transfer_details (td));
914
- }
915
-
916
- const auto supplemental_and_inset_input_proposals = [&](const crypto::public_key &ota) -> carrot::InputProposalV1
917
- {
918
- const auto inset_it = inset_input_proposals.find (ota);
919
- if (inset_it != inset_input_proposals.cend ())
920
- return inset_it->second ;
921
- return supplemental_input_proposals (ota);
922
- };
932
+ const auto supplemental_and_inset_input_proposals = extend_supplemental_input_proposals_fetcher (
933
+ supplemental_input_proposals, unsigned_txs, addr_dev);
923
934
924
935
for (const HotColdCarrotTransactionProposalV1 &cold_tx_proposal : unsigned_txs.tx_proposals )
925
936
{
@@ -1304,6 +1315,10 @@ void sign_carrot_tx_set_v1(const UnsignedCarrotTransactionSetV1 &unsigned_txs,
1304
1315
const carrot::generate_image_key_ram_borrowed_device generate_image_dev (k_spend);
1305
1316
const carrot::key_image_device_composed key_image_dev (generate_image_dev, hybrid_addr_dev, nullptr , &addr_dev);
1306
1317
1318
+ // fetcher of input proposals / opening hints which tries provided in-set first
1319
+ const auto supplemental_and_inset_input_proposals = extend_supplemental_input_proposals_fetcher (
1320
+ supplemental_opening_hints, unsigned_txs, addr_dev);
1321
+
1307
1322
// for each hot/cold tx proposal...
1308
1323
for (const HotColdCarrotTransactionProposalV1 &tx_proposal : unsigned_txs.tx_proposals )
1309
1324
{
@@ -1312,7 +1327,7 @@ void sign_carrot_tx_set_v1(const UnsignedCarrotTransactionSetV1 &unsigned_txs,
1312
1327
std::vector<crypto::key_image> input_key_images;
1313
1328
std::vector<FcmpRerandomizedOutputCompressed> rerandomized_outputs;
1314
1329
expand_carrot_transaction_proposal_and_rerandomized_outputs (tx_proposal,
1315
- supplemental_opening_hints ,
1330
+ supplemental_and_inset_input_proposals ,
1316
1331
addr_dev,
1317
1332
key_image_dev,
1318
1333
expanded_tx_proposal,
0 commit comments