@@ -224,7 +224,7 @@ macro_rules! invoice_request_derived_payer_id_builder_methods { (
224
224
} }
225
225
226
226
macro_rules! invoice_request_builder_methods { (
227
- $self: ident, $self_type: ty, $return_type: ty, $return_value: expr, $secp_context: ty
227
+ $self: ident, $self_type: ty, $return_type: ty, $return_value: expr, $secp_context: ty $ ( , $self_mut : tt ) ?
228
228
) => {
229
229
fn create_contents( offer: & Offer , metadata: Metadata ) -> InvoiceRequestContentsWithoutPayerId {
230
230
let offer = offer. contents. clone( ) ;
@@ -248,7 +248,7 @@ macro_rules! invoice_request_builder_methods { (
248
248
/// offer.
249
249
///
250
250
/// Successive calls to this method will override the previous setting.
251
- pub ( crate ) fn chain_hash( mut $self: $self_type, chain: ChainHash ) -> Result <$return_type, Bolt12SemanticError > {
251
+ pub ( crate ) fn chain_hash( $ ( $self_mut ) * $self: $self_type, chain: ChainHash ) -> Result <$return_type, Bolt12SemanticError > {
252
252
if !$self. offer. supports_chain( chain) {
253
253
return Err ( Bolt12SemanticError :: UnsupportedChain ) ;
254
254
}
@@ -263,7 +263,7 @@ macro_rules! invoice_request_builder_methods { (
263
263
/// Successive calls to this method will override the previous setting.
264
264
///
265
265
/// [`quantity`]: Self::quantity
266
- pub fn amount_msats( mut $self: $self_type, amount_msats: u64 ) -> Result <$return_type, Bolt12SemanticError > {
266
+ pub fn amount_msats( $ ( $self_mut ) * $self: $self_type, amount_msats: u64 ) -> Result <$return_type, Bolt12SemanticError > {
267
267
$self. invoice_request. offer. check_amount_msats_for_quantity(
268
268
Some ( amount_msats) , $self. invoice_request. quantity
269
269
) ?;
@@ -275,7 +275,7 @@ macro_rules! invoice_request_builder_methods { (
275
275
/// does not conform to [`Offer::is_valid_quantity`].
276
276
///
277
277
/// Successive calls to this method will override the previous setting.
278
- pub fn quantity( mut $self: $self_type, quantity: u64 ) -> Result <$return_type, Bolt12SemanticError > {
278
+ pub fn quantity( $ ( $self_mut ) * $self: $self_type, quantity: u64 ) -> Result <$return_type, Bolt12SemanticError > {
279
279
$self. invoice_request. offer. check_quantity( Some ( quantity) ) ?;
280
280
$self. invoice_request. quantity = Some ( quantity) ;
281
281
Ok ( $return_value)
@@ -284,12 +284,12 @@ macro_rules! invoice_request_builder_methods { (
284
284
/// Sets the [`InvoiceRequest::payer_note`].
285
285
///
286
286
/// Successive calls to this method will override the previous setting.
287
- pub fn payer_note( mut $self: $self_type, payer_note: String ) -> $return_type {
287
+ pub fn payer_note( $ ( $self_mut ) * $self: $self_type, payer_note: String ) -> $return_type {
288
288
$self. invoice_request. payer_note = Some ( payer_note) ;
289
289
$return_value
290
290
}
291
291
292
- fn build_with_checks( mut $self: $self_type) -> Result <
292
+ fn build_with_checks( $ ( $self_mut ) * $self: $self_type) -> Result <
293
293
( UnsignedInvoiceRequest , Option <KeyPair >, Option <& ' b Secp256k1 <$secp_context>>) ,
294
294
Bolt12SemanticError
295
295
> {
@@ -320,7 +320,7 @@ macro_rules! invoice_request_builder_methods { (
320
320
Ok ( $self. build_without_checks( ) )
321
321
}
322
322
323
- fn build_without_checks( mut $self: $self_type) ->
323
+ fn build_without_checks( $ ( $self_mut ) * $self: $self_type) ->
324
324
( UnsignedInvoiceRequest , Option <KeyPair >, Option <& ' b Secp256k1 <$secp_context>>)
325
325
{
326
326
// Create the metadata for stateless verification of a Bolt12Invoice.
@@ -366,25 +366,25 @@ macro_rules! invoice_request_builder_methods { (
366
366
367
367
#[ cfg( test) ]
368
368
macro_rules! invoice_request_builder_test_methods { (
369
- $self: ident, $self_type: ty, $return_type: ty, $return_value: expr
369
+ $self: ident, $self_type: ty, $return_type: ty, $return_value: expr $ ( , $self_mut : tt ) ?
370
370
) => {
371
- fn chain_unchecked( mut $self: $self_type, network: Network ) -> $return_type {
371
+ fn chain_unchecked( $ ( $self_mut ) * $self: $self_type, network: Network ) -> $return_type {
372
372
let chain = ChainHash :: using_genesis_block( network) ;
373
373
$self. invoice_request. chain = Some ( chain) ;
374
374
$return_value
375
375
}
376
376
377
- fn amount_msats_unchecked( mut $self: $self_type, amount_msats: u64 ) -> $return_type {
377
+ fn amount_msats_unchecked( $ ( $self_mut ) * $self: $self_type, amount_msats: u64 ) -> $return_type {
378
378
$self. invoice_request. amount_msats = Some ( amount_msats) ;
379
379
$return_value
380
380
}
381
381
382
- fn features_unchecked( mut $self: $self_type, features: InvoiceRequestFeatures ) -> $return_type {
382
+ fn features_unchecked( $ ( $self_mut ) * $self: $self_type, features: InvoiceRequestFeatures ) -> $return_type {
383
383
$self. invoice_request. features = features;
384
384
$return_value
385
385
}
386
386
387
- fn quantity_unchecked( mut $self: $self_type, quantity: u64 ) -> $return_type {
387
+ fn quantity_unchecked( $ ( $self_mut ) * $self: $self_type, quantity: u64 ) -> $return_type {
388
388
$self. invoice_request. quantity = Some ( quantity) ;
389
389
$return_value
390
390
}
@@ -403,10 +403,10 @@ impl<'a, 'b, T: secp256k1::Signing> InvoiceRequestBuilder<'a, 'b, DerivedPayerId
403
403
}
404
404
405
405
impl < ' a , ' b , P : PayerIdStrategy , T : secp256k1:: Signing > InvoiceRequestBuilder < ' a , ' b , P , T > {
406
- invoice_request_builder_methods ! ( self , Self , Self , self , T ) ;
406
+ invoice_request_builder_methods ! ( self , Self , Self , self , T , mut ) ;
407
407
408
408
#[ cfg( test) ]
409
- invoice_request_builder_test_methods ! ( self , Self , Self , self ) ;
409
+ invoice_request_builder_test_methods ! ( self , Self , Self , self , mut ) ;
410
410
}
411
411
412
412
#[ cfg( all( c_bindings, not( test) ) ) ]
@@ -498,13 +498,15 @@ impl UnsignedInvoiceRequest {
498
498
}
499
499
}
500
500
501
- macro_rules! unsigned_invoice_request_sign_method { ( $self: ident, $self_type: ty) => {
501
+ macro_rules! unsigned_invoice_request_sign_method { (
502
+ $self: ident, $self_type: ty $( , $self_mut: tt) ?
503
+ ) => {
502
504
/// Signs the [`TaggedHash`] of the invoice request using the given function.
503
505
///
504
506
/// Note: The hash computation may have included unknown, odd TLV records.
505
507
///
506
508
/// This is not exported to bindings users as functions are not yet mapped.
507
- pub fn sign<F , E >( mut $self: $self_type, sign: F ) -> Result <InvoiceRequest , SignError <E >>
509
+ pub fn sign<F , E >( $ ( $self_mut ) * $self: $self_type, sign: F ) -> Result <InvoiceRequest , SignError <E >>
508
510
where
509
511
F : FnOnce ( & Self ) -> Result <Signature , E >
510
512
{
@@ -533,7 +535,7 @@ macro_rules! unsigned_invoice_request_sign_method { ($self: ident, $self_type: t
533
535
534
536
#[ cfg( not( c_bindings) ) ]
535
537
impl UnsignedInvoiceRequest {
536
- unsigned_invoice_request_sign_method ! ( self , Self ) ;
538
+ unsigned_invoice_request_sign_method ! ( self , Self , mut ) ;
537
539
}
538
540
539
541
#[ cfg( c_bindings) ]
0 commit comments