@@ -194,7 +194,7 @@ namespace Consensus {
194194
195195 const auto expectedRecipients = params.FundingPeriodIndex (startHeight, endHeight - 1 ) + 1 ;
196196 if (expectedRecipients > recipients.size ()) {
197- return FundingStreamError::INSUFFICIENT_ADDRESSES ;
197+ return FundingStreamError::INSUFFICIENT_RECIPIENTS ;
198198 }
199199
200200 // Lockbox output periods must not start before NU6
@@ -221,8 +221,8 @@ namespace Consensus {
221221 throw std::runtime_error (" Canopy network upgrade not active at funding stream start height." );
222222 case FundingStreamError::ILLEGAL_RANGE:
223223 throw std::runtime_error (" Illegal start/end height combination for funding stream." );
224- case FundingStreamError::INSUFFICIENT_ADDRESSES :
225- throw std::runtime_error (" Insufficient payment addresses to fully exhaust funding stream." );
224+ case FundingStreamError::INSUFFICIENT_RECIPIENTS :
225+ throw std::runtime_error (" Insufficient recipient identifiers to fully exhaust funding stream." );
226226 case FundingStreamError::NU6_NOT_ACTIVE:
227227 throw std::runtime_error (" NU6 network upgrade not active at lockbox period start height." );
228228 default :
@@ -349,7 +349,11 @@ namespace Consensus {
349349 // Funding streams are disabled if Canopy is not active.
350350 if (NetworkUpgradeActive (nHeight, Consensus::UPGRADE_CANOPY)) {
351351 for (uint32_t idx = Consensus::FIRST_FUNDING_STREAM; idx < Consensus::MAX_FUNDING_STREAMS; idx++) {
352+ // The following indexed access is safe as Consensus::MAX_FUNDING_STREAMS is used
353+ // in the definition of vFundingStreams.
352354 auto fs = vFundingStreams[idx];
355+
356+ // Funding period is [startHeight, endHeight).
353357 if (fs && nHeight >= fs.value ().GetStartHeight () && nHeight < fs.value ().GetEndHeight ()) {
354358 activeStreams.push_back (std::make_pair (FundingStreamInfo[idx], fs.value ()));
355359 }
@@ -372,16 +376,10 @@ namespace Consensus {
372376
373377 // Funding streams are disabled if Canopy is not active.
374378 if (NetworkUpgradeActive (nHeight, Consensus::UPGRADE_CANOPY)) {
375- for (uint32_t idx = Consensus::FIRST_FUNDING_STREAM; idx < Consensus::MAX_FUNDING_STREAMS; idx++) {
376- // The following indexed access is safe as Consensus::MAX_FUNDING_STREAMS is used
377- // in the definition of vFundingStreams.
378- auto fs = vFundingStreams[idx];
379- // Funding period is [startHeight, endHeight)
380- if (fs && nHeight >= fs.value ().GetStartHeight () && nHeight < fs.value ().GetEndHeight ()) {
381- requiredElements.insert (std::make_pair (
382- fs.value ().Recipient (*this , nHeight),
383- FundingStreamInfo[idx].Value (blockSubsidy)));
384- }
379+ for (const auto & [fsinfo, fs] : GetActiveFundingStreams (nHeight)) {
380+ requiredElements.insert (std::make_pair (
381+ fs.Recipient (*this , nHeight),
382+ fsinfo.Value (blockSubsidy)));
385383 }
386384 }
387385
0 commit comments