pub struct WalletDescriptor {
pub group_pubkey: [u8; 32],
pub external_descriptor: String,
pub internal_descriptor: String,
pub network: String,
pub created_at: u64,
pub device_registrations: Vec<DeviceRegistration>,
pub policy_hash: [u8; 32],
pub version: u32,
pub previous_descriptor_hash: Option<[u8; 32]>,
pub policy: Option<Value>,
}Expand description
A finalized wallet descriptor associated with a FROST group.
Fields§
§group_pubkey: [u8; 32]The FROST group public key this descriptor belongs to.
external_descriptor: StringThe external (receive) descriptor string.
internal_descriptor: StringThe internal (change) descriptor string.
network: StringThe Bitcoin network (e.g. “bitcoin”, “testnet”, “signet”, “regtest”).
created_at: u64Unix timestamp when the descriptor was created.
device_registrations: Vec<DeviceRegistration>Hardware signers that have registered this wallet.
policy_hash: [u8; 32]Hash of the wallet policy that produced this descriptor. Required for
canonical descriptor hashing (matches the on-wire descriptor_hash
computed as length-framed
sha256(len(ext) || ext || len(int) || int || policy_hash)).
version: u32Monotonic version of the descriptor for this group. Starts at 1 for the
initial descriptor and increments on each migration. Records persisted
before versioning materialize as 1 via #[serde(default)] +
default_descriptor_version.
previous_descriptor_hash: Option<[u8; 32]>Canonical hash of the descriptor this one supersedes, when this is a
migration. None for the initial descriptor.
policy: Option<Value>The wallet policy that produced this descriptor, persisted as an opaque
JSON value so keep-core does not depend on keep-frost-net. Callers
reconstruct WalletPolicy via serde_json::from_value. Older records
without this field deserialize with None.
Implementations§
Source§impl WalletDescriptor
impl WalletDescriptor
Sourcepub fn device_registration(
&self,
signer_pubkey: &[u8; 32],
) -> Option<&DeviceRegistration>
pub fn device_registration( &self, signer_pubkey: &[u8; 32], ) -> Option<&DeviceRegistration>
Return the registration record for a signer pubkey, if any.
Sourcepub fn upsert_device_registration(&mut self, reg: DeviceRegistration)
pub fn upsert_device_registration(&mut self, reg: DeviceRegistration)
Insert or update the registration for a signer pubkey.
Sourcepub fn canonical_hash(&self) -> [u8; 32]
pub fn canonical_hash(&self) -> [u8; 32]
Canonical descriptor hash with length framing to avoid collisions
when the split between external/internal shifts:
sha256(u64_le(ext.len) || ext || u64_le(int.len) || int || policy_hash [|| "keep/descriptor/version" || u32_le(version) when version > 1]).
The version suffix is only folded in for v2+ so v1 hashes remain
bit-identical to records written before descriptor versioning existed
(mirroring the conditional fold in hash_policy).
TODO: drop the conditional suffix in vN+1 once all v1 records are
migrated.
Must match the on-wire descriptor_hash used by the FROST PSBT
coordination protocol.
Sourcepub fn try_canonical_hash(&self) -> Result<[u8; 32], CanonicalHashError>
pub fn try_canonical_hash(&self) -> Result<[u8; 32], CanonicalHashError>
Fallible variant of [canonical_hash] that returns an error rather
than panicking when version == 0. Prefer this in code paths that
hash freshly-deserialized inputs without re-validating the version
invariant.