You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge #225: Make AssetId::from_inner a const function
1f3b402 Make AssetId::from_inner a const function (Pavel Kokolemin)
Pull request description:
This will allow constructing `AssetId` values like this:
```
const TESTNET_ASSET: elemets::AssetId = const_asset_id("144c654344aa716d6f3abcc1ca90e5641e4e2a7f633bc09fe3baf64585819a49");
/// Panics if the asset id string has wrong length or format
pub const fn const_asset_id(s: &str) -> elements::AssetId {
let mut data: [u8; 32] = hex_literal::decode::<32>(&[s.as_bytes()]);
let mut left = 0;
let mut right = data.len() - 1;
while left < right {
let tmp = data[left];
data[left] = data[right];
data[right] = tmp;
left += 1;
right -= 1;
}
elements::AssetId::from_inner(bitcoin::hashes::sha256::Midstate(data))
}
```
It's a bit of a hack because `hex_literal::decode` should not be used directly.
ACKs for top commit:
apoelstra:
ACK 1f3b402; successfully ran local tests; nice, good call
Tree-SHA512: 33e1353ecd0c74df2915509fe24cbd56b5fe9c7b7ce412e4adfa59245c4e4f904e514785ffa0c345b9c3bdffce4c76cb3f9d4d3ce4c9372a80f4b4ce1e9dfa48
0 commit comments