X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning-invoice%2Fsrc%2Flib.rs;fp=lightning-invoice%2Fsrc%2Flib.rs;h=defe958a1c05406cf8eb6cdfe409c9958c26458b;hb=990e34679828ed4eca7bc8e179869f497b5dcc98;hp=4fc58271ed722f17d3b0392a7612915cbcc45a97;hpb=3f3335ac487025d0251366478b8301f65a5e8d8b;p=rust-lightning diff --git a/lightning-invoice/src/lib.rs b/lightning-invoice/src/lib.rs index 4fc58271..defe958a 100644 --- a/lightning-invoice/src/lib.rs +++ b/lightning-invoice/src/lib.rs @@ -745,7 +745,7 @@ impl SignedRawInvoice { } /// The hash of the `RawInvoice` that was signed. - pub fn hash(&self) -> &[u8; 32] { + pub fn signable_hash(&self) -> &[u8; 32] { &self.hash } @@ -853,8 +853,8 @@ impl RawInvoice { hash } - /// Calculate the hash of the encoded `RawInvoice` - pub fn hash(&self) -> [u8; 32] { + /// Calculate the hash of the encoded `RawInvoice` which should be signed. + pub fn signable_hash(&self) -> [u8; 32] { use bech32::ToBase32; RawInvoice::hash_from_parts( @@ -872,7 +872,7 @@ impl RawInvoice { pub fn sign(self, sign_method: F) -> Result where F: FnOnce(&Message) -> Result { - let raw_hash = self.hash(); + let raw_hash = self.signable_hash(); let hash = Message::from_slice(&raw_hash[..]) .expect("Hash is 32 bytes long, same as MESSAGE_SIZE"); let signature = sign_method(&hash)?; @@ -1591,7 +1591,7 @@ mod test { 0xd5, 0x18, 0xe1, 0xc9 ]; - assert_eq!(invoice.hash(), expected_hash) + assert_eq!(invoice.signable_hash(), expected_hash) } #[test]