25
25
//!
26
26
//! use bitcoin::network::constants::Network;
27
27
//! use bitcoin::secp256k1::{KeyPair, PublicKey, Secp256k1, SecretKey};
28
- //! use core::convert::Infallible;
29
28
//! use lightning::ln::features::OfferFeatures;
30
29
//! use lightning::offers::invoice_request::UnsignedInvoiceRequest;
31
30
//! use lightning::offers::offer::Offer;
48
47
//! .quantity(5)?
49
48
//! .payer_note("foo".to_string())
50
49
//! .build()?
51
- //! .sign(|message: &UnsignedInvoiceRequest| -> Result<_, Infallible> {
50
+ //! .sign(|message: &UnsignedInvoiceRequest|
52
51
//! Ok(secp_ctx.sign_schnorr_no_aux_rand(message.as_ref().as_digest(), &keys))
53
- //! } )
52
+ //! )
54
53
//! .expect("failed verifying signature")
55
54
//! .write(&mut buffer)
56
55
//! .unwrap();
@@ -62,7 +61,7 @@ use bitcoin::blockdata::constants::ChainHash;
62
61
use bitcoin:: network:: constants:: Network ;
63
62
use bitcoin:: secp256k1:: { KeyPair , PublicKey , Secp256k1 , self } ;
64
63
use bitcoin:: secp256k1:: schnorr:: Signature ;
65
- use core:: convert:: { AsRef , Infallible , TryFrom } ;
64
+ use core:: convert:: { AsRef , TryFrom } ;
66
65
use core:: ops:: Deref ;
67
66
use crate :: sign:: EntropySource ;
68
67
use crate :: io;
@@ -228,9 +227,9 @@ macro_rules! invoice_request_derived_payer_id_builder_methods { (
228
227
let secp_ctx = secp_ctx. unwrap( ) ;
229
228
let keys = keys. unwrap( ) ;
230
229
let invoice_request = unsigned_invoice_request
231
- . sign( |message: & UnsignedInvoiceRequest | -> Result <_ , Infallible > {
230
+ . sign( |message: & UnsignedInvoiceRequest |
232
231
Ok ( secp_ctx. sign_schnorr_no_aux_rand( message. as_ref( ) . as_digest( ) , & keys) )
233
- } )
232
+ )
234
233
. unwrap( ) ;
235
234
Ok ( invoice_request)
236
235
}
@@ -496,31 +495,24 @@ pub struct UnsignedInvoiceRequest {
496
495
497
496
/// A function for signing an [`UnsignedInvoiceRequest`].
498
497
pub trait SignInvoiceRequestFn {
499
- /// Error type returned by the function.
500
- type Error ;
501
-
502
498
/// Signs a [`TaggedHash`] computed over the merkle root of `message`'s TLV stream.
503
- fn sign_invoice_request ( & self , message : & UnsignedInvoiceRequest ) -> Result < Signature , Self :: Error > ;
499
+ fn sign_invoice_request ( & self , message : & UnsignedInvoiceRequest ) -> Result < Signature , ( ) > ;
504
500
}
505
501
506
- impl < F , E > SignInvoiceRequestFn for F
502
+ impl < F > SignInvoiceRequestFn for F
507
503
where
508
- F : Fn ( & UnsignedInvoiceRequest ) -> Result < Signature , E > ,
504
+ F : Fn ( & UnsignedInvoiceRequest ) -> Result < Signature , ( ) > ,
509
505
{
510
- type Error = E ;
511
-
512
- fn sign_invoice_request ( & self , message : & UnsignedInvoiceRequest ) -> Result < Signature , E > {
506
+ fn sign_invoice_request ( & self , message : & UnsignedInvoiceRequest ) -> Result < Signature , ( ) > {
513
507
self ( message)
514
508
}
515
509
}
516
510
517
- impl < F , E > SignFn < UnsignedInvoiceRequest > for F
511
+ impl < F > SignFn < UnsignedInvoiceRequest > for F
518
512
where
519
- F : SignInvoiceRequestFn < Error = E > ,
513
+ F : SignInvoiceRequestFn ,
520
514
{
521
- type Error = E ;
522
-
523
- fn sign ( & self , message : & UnsignedInvoiceRequest ) -> Result < Signature , Self :: Error > {
515
+ fn sign ( & self , message : & UnsignedInvoiceRequest ) -> Result < Signature , ( ) > {
524
516
self . sign_invoice_request ( message)
525
517
}
526
518
}
@@ -556,7 +548,7 @@ macro_rules! unsigned_invoice_request_sign_method { (
556
548
/// Note: The hash computation may have included unknown, odd TLV records.
557
549
pub fn sign<F : SignInvoiceRequestFn >(
558
550
$( $self_mut) * $self: $self_type, sign: F
559
- ) -> Result <InvoiceRequest , SignError < F :: Error > > {
551
+ ) -> Result <InvoiceRequest , SignError > {
560
552
let pubkey = $self. contents. payer_id;
561
553
let signature = merkle:: sign_message( sign, & $self, pubkey) ?;
562
554
@@ -1111,7 +1103,7 @@ mod tests {
1111
1103
use bitcoin:: blockdata:: constants:: ChainHash ;
1112
1104
use bitcoin:: network:: constants:: Network ;
1113
1105
use bitcoin:: secp256k1:: { KeyPair , Secp256k1 , SecretKey , self } ;
1114
- use core:: convert:: { Infallible , TryFrom } ;
1106
+ use core:: convert:: TryFrom ;
1115
1107
use core:: num:: NonZeroU64 ;
1116
1108
#[ cfg( feature = "std" ) ]
1117
1109
use core:: time:: Duration ;
@@ -1744,7 +1736,7 @@ mod tests {
1744
1736
. sign ( fail_sign)
1745
1737
{
1746
1738
Ok ( _) => panic ! ( "expected error" ) ,
1747
- Err ( e) => assert_eq ! ( e, SignError :: Signing ( ( ) ) ) ,
1739
+ Err ( e) => assert_eq ! ( e, SignError :: Signing ) ,
1748
1740
}
1749
1741
1750
1742
match OfferBuilder :: new ( "foo" . into ( ) , recipient_pubkey ( ) )
@@ -2155,9 +2147,9 @@ mod tests {
2155
2147
. build ( ) . unwrap ( )
2156
2148
. request_invoice ( vec ! [ 1 ; 32 ] , keys. public_key ( ) ) . unwrap ( )
2157
2149
. build ( ) . unwrap ( )
2158
- . sign ( |message : & UnsignedInvoiceRequest | -> Result < _ , Infallible > {
2150
+ . sign ( |message : & UnsignedInvoiceRequest |
2159
2151
Ok ( secp_ctx. sign_schnorr_no_aux_rand ( message. as_ref ( ) . as_digest ( ) , & keys) )
2160
- } )
2152
+ )
2161
2153
. unwrap ( ) ;
2162
2154
2163
2155
let mut encoded_invoice_request = Vec :: new ( ) ;
0 commit comments