Exposed a hash-based API for accessing blocks

Also corrects a few panics, which shouldn't have been present, and unnecessary
Cursor uses.
This commit is contained in:
Luke Parker
2023-01-07 04:00:12 -05:00
parent 814a9a8d35
commit 1d6df0099c
4 changed files with 45 additions and 26 deletions

View File

@@ -1,5 +1,5 @@
use core::ops::BitXor;
use std::io::{self, Read, Write, Cursor};
use std::io::{self, Read, Write};
use zeroize::Zeroize;
@@ -127,7 +127,7 @@ impl Extra {
pub(crate) fn payment_id(&self) -> Option<PaymentId> {
for field in &self.0 {
if let ExtraField::Nonce(data) = field {
return PaymentId::deserialize(&mut Cursor::new(data)).ok();
return PaymentId::deserialize::<&[u8]>(&mut data.as_ref()).ok();
}
}
None