@@ -2898,18 +2898,15 @@ SilentPaymentDescriptorScriptPubKeyMan::SilentPaymentDescriptorScriptPubKeyMan(W
2898
2898
throw std::runtime_error (std::string (__func__) + " : descriptor is not a Silent Payment Descriptor" );
2899
2899
}
2900
2900
2901
- // Populate m_map_label_tweaks if descriptor is Silent Payments
2902
- if (descriptor.descriptor ->GetOutputType () == OutputType::SILENT_PAYMENT) {
2903
- auto sppubkey = GetSpPubKeyFrom (descriptor.descriptor );
2904
- if (!sppubkey.has_value ()) {
2905
- throw std::runtime_error (std::string (__func__) + " : descriptor expansion failed" );
2906
- }
2907
- auto change_label_data = bip352::CreateLabelTweak (sppubkey->scanKey , 0 );
2908
- m_map_label_tweaks.insert (change_label_data);
2909
- for (int i = 1 ; i < descriptor.next_index ; i++) {
2910
- // Add the other generated labelled destinations
2911
- m_map_label_tweaks.insert (bip352::CreateLabelTweak (sppubkey->scanKey , i));
2912
- }
2901
+ auto sppubkey = GetSpPubKeyFrom (descriptor.descriptor );
2902
+ if (!sppubkey.has_value ()) {
2903
+ throw std::runtime_error (std::string (__func__) + " : descriptor expansion failed" );
2904
+ }
2905
+ auto change_label_data = bip352::CreateLabelTweak (sppubkey->scanKey , 0 );
2906
+ m_map_label_tweaks.insert (change_label_data);
2907
+ for (int i = 1 ; i < descriptor.next_index ; i++) {
2908
+ // Add the other generated labelled destinations
2909
+ m_map_label_tweaks.insert (bip352::CreateLabelTweak (sppubkey->scanKey , i));
2913
2910
}
2914
2911
}
2915
2912
@@ -2954,7 +2951,16 @@ V0SilentPaymentDestination SilentPaymentDescriptorScriptPubKeyMan::GetLabeledDes
2954
2951
util::Result<CTxDestination> SilentPaymentDescriptorScriptPubKeyMan::GetNewLabeledDestination (uint64_t & index)
2955
2952
{
2956
2953
LOCK (cs_desc_man);
2957
- auto dest = GetLabeledDestination (m_wallet_descriptor.next_index );
2954
+
2955
+ auto sppubkey = GetSpPubKeyFrom (m_wallet_descriptor.descriptor );
2956
+ if (!sppubkey.has_value ()) {
2957
+ throw std::runtime_error (std::string (__func__) + " : descriptor expansion failed" );
2958
+ }
2959
+ if (!sppubkey->AllowLabels ()) {
2960
+ return util::Error{ .message =Untranslated (" Failed to create new label destination. Labels not allowed" ) };
2961
+ }
2962
+
2963
+ auto dest{GetLabeledDestination (m_wallet_descriptor.next_index )};
2958
2964
index = m_wallet_descriptor.next_index ; // Return the index for this destination
2959
2965
m_wallet_descriptor.next_index ++;
2960
2966
WalletBatch (m_storage.GetDatabase ()).WriteDescriptor (GetID (), m_wallet_descriptor);
0 commit comments