@@ -376,11 +376,23 @@ class ListCoinsTestingSetup : public TestChain100Setup
376
376
{
377
377
CTransactionRef tx;
378
378
CCoinControl dummy;
379
+ if (std::holds_alternative<V0SilentPaymentDestination>(recipient.dest )) {
380
+ dummy.m_silent_payment = true ;
381
+ }
379
382
{
380
383
auto res = CreateTransaction (*wallet, {recipient}, /* change_pos=*/ std::nullopt, dummy);
381
384
BOOST_CHECK (res);
382
385
tx = res->tx ;
383
386
}
387
+ std::map<COutPoint, Coin> spent_coins;
388
+ for (const CTxIn& txin : tx->vin ) {
389
+ spent_coins[txin.prevout ]; // Create empty map entry keyed by prevout.
390
+ }
391
+ wallet->chain ().findCoins (spent_coins);
392
+ {
393
+ LOCK (wallet->cs_wallet );
394
+ wallet->IsMine (*tx, spent_coins);
395
+ }
384
396
wallet->CommitTransaction (tx, {}, {});
385
397
CMutableTransaction blocktx;
386
398
{
@@ -492,10 +504,29 @@ BOOST_FIXTURE_TEST_CASE(BasicOutputTypesTest, ListCoinsTest)
492
504
// 2. One UTXO from the change, due to payment address matching logic
493
505
494
506
for (const auto & out_type : OUTPUT_TYPES) {
495
- if (out_type == OutputType::UNKNOWN || out_type == OutputType::SILENT_PAYMENTS) continue ;
507
+ if (out_type == OutputType::UNKNOWN) continue ;
508
+ if (out_type == OutputType::SILENT_PAYMENTS) continue ;
496
509
expected_coins_sizes[out_type] = 2U ;
497
510
TestCoinsResult (*this , out_type, 1 * COIN, expected_coins_sizes);
498
511
}
512
+
513
+ // Add a taproot UTXO to be used for creating a silent payment
514
+ util::Result<CTxDestination> dest = Assert (wallet->GetNewDestination (OutputType::BECH32M, " " ));
515
+ AddTx (CRecipient{*dest, 1 * COIN, /* fSubtractFeeFromAmount=*/ true });
516
+ CoinFilterParams filter;
517
+ filter.skip_locked = true ;
518
+ available_coins = WITH_LOCK (wallet->cs_wallet , return AvailableCoins (*wallet, nullptr , std::nullopt, filter));
519
+ BOOST_CHECK_EQUAL (available_coins.coins [OutputType::BECH32M].size (), 2U );
520
+ // Expect 4 OutputType::BECH32M UTXOs
521
+ // 1. One UTXO as the recipient because Silent Payments produce taproot scriptPubKeys
522
+ // 2. One UTXO from the change, due to payment address matching logic
523
+ // 3. Two locked UTXOs from previous OutputType::BECH32M test
524
+ expected_coins_sizes[OutputType::BECH32M] = 4U ;
525
+ // Expect 2 OutputType::BECH32M UTXOs
526
+ // 1. One UTXO from mining the previous block
527
+ // 1. One UTXO from mining the block used in the test
528
+ expected_coins_sizes[OutputType::UNKNOWN] = 2U ;
529
+ TestCoinsResult (*this , OutputType::SILENT_PAYMENTS, 1 * COIN, expected_coins_sizes);
499
530
}
500
531
501
532
BOOST_FIXTURE_TEST_CASE (wallet_disableprivkeys, TestChain100Setup)
0 commit comments