Skip to content

Commit d71cc0c

Browse files
committed
Add AssetId::from_slice() convenience method
1 parent fc27e53 commit d71cc0c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/issuance.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::io;
1818
use std::str::FromStr;
1919

2020
use bitcoin::util::hash::BitcoinHash;
21-
use bitcoin::hashes::{hex, sha256, sha256d, Hash};
21+
use bitcoin::hashes::{self, hex, sha256, sha256d, Hash};
2222

2323
use encode::{self, Encodable, Decodable};
2424
use fast_merkle_root::fast_merkle_root;
@@ -54,6 +54,11 @@ impl AssetId {
5454
self.0
5555
}
5656

57+
/// Copies a byte slice into an AssetId object
58+
pub fn from_slice(sl: &[u8]) -> Result<AssetId, hashes::Error> {
59+
sha256::Midstate::from_slice(sl).map(AssetId)
60+
}
61+
5762
/// Generate the asset entropy from the issuance prevout and the contract hash.
5863
pub fn generate_asset_entropy(
5964
prevout: OutPoint,

0 commit comments

Comments
 (0)