Skip to content

Commit baf632d

Browse files
committed
refactor for explicit dummy payment id in get_output_enote_proposals
1 parent 8a754bc commit baf632d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/carrot_impl/carrot_tx_builder.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ void make_unsigned_transaction(std::vector<CarrotPaymentProposalV1> &normal_paym
118118
}
119119
}
120120

121+
// generate random dummy encrypted payment ID for if none of the normal payment proposals are integrated
122+
const encrypted_payment_id_t dummy_encrypted_payment_id = gen_payment_id();
123+
121124
// calculate size of tx.extra
122125
const size_t tx_extra_size = get_carrot_default_tx_extra_size(num_outs);
123126

@@ -173,6 +176,7 @@ void make_unsigned_transaction(std::vector<CarrotPaymentProposalV1> &normal_paym
173176
encrypted_payment_id_t encrypted_payment_id;
174177
get_output_enote_proposals(normal_payment_proposals_inout,
175178
selfsend_payment_proposals_inout,
179+
dummy_encrypted_payment_id,
176180
s_view_balance_dev,
177181
k_view_dev,
178182
account_spend_pubkey,

tests/unit_tests/carrot_impl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ static void subtest_multi_account_transfer_over_transaction(const unittest_trans
534534
parsed_key_images,
535535
parsed_fee,
536536
parsed_encrypted_payment_id));
537+
ASSERT_TRUE(parsed_encrypted_payment_id);
537538

538539
// sanity check that the enotes and pid_enc loaded from the transaction are equal to the enotes
539540
// and pic_enc returned from get_output_enote_proposals() when called with the modified payment
@@ -543,13 +544,13 @@ static void subtest_multi_account_transfer_over_transaction(const unittest_trans
543544
encrypted_payment_id_t rederived_encrypted_payment_id;
544545
get_output_enote_proposals(modified_normal_payment_proposals,
545546
modified_selfsend_payment_proposals,
547+
*parsed_encrypted_payment_id,
546548
ss_keys.get_view_balance_device(),
547549
&ss_keys.k_view_dev,
548550
ss_keys.account_spend_pubkey,
549551
parsed_key_images.at(0),
550552
rederived_output_enote_proposals,
551553
rederived_encrypted_payment_id);
552-
ASSERT_TRUE(parsed_encrypted_payment_id);
553554
EXPECT_EQ(*parsed_encrypted_payment_id, rederived_encrypted_payment_id);
554555
ASSERT_EQ(parsed_enotes.size(), rederived_output_enote_proposals.size());
555556
for (size_t enote_idx = 0; enote_idx < parsed_enotes.size(); ++enote_idx)

0 commit comments

Comments
 (0)