@@ -2841,18 +2841,15 @@ SilentPaymentDescriptorScriptPubKeyMan::SilentPaymentDescriptorScriptPubKeyMan(W
2841
2841
throw std::runtime_error (std::string (__func__) + " : descriptor is not a Silent Payment Descriptor" );
2842
2842
}
2843
2843
2844
- // Populate m_map_label_tweaks if descriptor is Silent Payments
2845
- if (descriptor.descriptor ->GetOutputType () == OutputType::SILENT_PAYMENT) {
2846
- auto sppubkey = GetSpPubKeyFrom (descriptor.descriptor );
2847
- if (!sppubkey.has_value ()) {
2848
- throw std::runtime_error (std::string (__func__) + " : descriptor expansion failed" );
2849
- }
2850
- auto change_label_data = BIP352::CreateLabelTweak (sppubkey->scanKey , 0 );
2851
- m_map_label_tweaks.insert (change_label_data);
2852
- for (int i = 1 ; i < descriptor.next_index ; i++) {
2853
- // Add the other generated labelled destinations
2854
- m_map_label_tweaks.insert (BIP352::CreateLabelTweak (sppubkey->scanKey , i));
2855
- }
2844
+ auto sppubkey = GetSpPubKeyFrom (descriptor.descriptor );
2845
+ if (!sppubkey.has_value ()) {
2846
+ throw std::runtime_error (std::string (__func__) + " : descriptor expansion failed" );
2847
+ }
2848
+ auto change_label_data = BIP352::CreateLabelTweak (sppubkey->scanKey , 0 );
2849
+ m_map_label_tweaks.insert (change_label_data);
2850
+ for (int i = 1 ; i < descriptor.next_index ; i++) {
2851
+ // Add the other generated labelled destinations
2852
+ m_map_label_tweaks.insert (BIP352::CreateLabelTweak (sppubkey->scanKey , i));
2856
2853
}
2857
2854
}
2858
2855
@@ -2897,6 +2894,15 @@ V0SilentPaymentDestination SilentPaymentDescriptorScriptPubKeyMan::GetLabelledDe
2897
2894
util::Result<CTxDestination> SilentPaymentDescriptorScriptPubKeyMan::GetNewLabelledDestination (uint64_t & index)
2898
2895
{
2899
2896
LOCK (cs_desc_man);
2897
+
2898
+ auto sppubkey = GetSpPubKeyFrom (m_wallet_descriptor.descriptor );
2899
+ if (!sppubkey.has_value ()) {
2900
+ throw std::runtime_error (std::string (__func__) + " : descriptor expansion failed" );
2901
+ }
2902
+ if (!sppubkey->AllowLabels ()) {
2903
+ return util::Error{ .message =Untranslated (" Failed to create new label destination. Labels not allowed" ) };
2904
+ }
2905
+
2900
2906
auto dest = GetLabelledDestination (m_wallet_descriptor.next_index );
2901
2907
index = m_wallet_descriptor.next_index ; // Return the index for this destination
2902
2908
m_wallet_descriptor.next_index ++;
0 commit comments