pub struct ArkNote { /* private fields */ }Expand description
ArkNote is a bearer token that can be redeemed by revealing its preimage.
The note encodes:
- A 32-byte preimage (the secret)
- A value in satoshis (up to u32::MAX)
The on-chain representation is a hash-locked taproot script that checks
SHA256(witness) == hash(preimage).
Implementations§
Source§impl ArkNote
impl ArkNote
Sourcepub fn new(preimage: [u8; 32], value: Amount) -> Result<Self, Error>
pub fn new(preimage: [u8; 32], value: Amount) -> Result<Self, Error>
Create a new ArkNote with the default HRP.
Sourcepub fn new_with_hrp(
preimage: [u8; 32],
value: Amount,
hrp: String,
) -> Result<Self, Error>
pub fn new_with_hrp( preimage: [u8; 32], value: Amount, hrp: String, ) -> Result<Self, Error>
Create a new ArkNote with a custom HRP.
Sourcepub fn from_string(s: &str) -> Result<Self, Error>
pub fn from_string(s: &str) -> Result<Self, Error>
Parse an ArkNote from its string representation.
Sourcepub fn from_string_with_hrp(s: &str, hrp: &str) -> Result<Self, Error>
pub fn from_string_with_hrp(s: &str, hrp: &str) -> Result<Self, Error>
Parse an ArkNote from its string representation with a custom HRP.
Sourcepub fn to_encoded_string(&self) -> String
pub fn to_encoded_string(&self) -> String
Encode the ArkNote to its string representation.
Sourcepub fn preimage_hash(&self) -> Hash
pub fn preimage_hash(&self) -> Hash
Get the preimage hash.
Sourcepub fn script(&self) -> ScriptBuf
pub fn script(&self) -> ScriptBuf
Get the script that locks this note (spendable by revealing the preimage).
Sourcepub fn txid(&self) -> Txid
pub fn txid(&self) -> Txid
Get a synthetic txid derived from the preimage hash.
This is used to create a unique identifier for the note in the VTXO system.
Sourcepub fn to_intent_input(&self) -> Result<Input, Error>
pub fn to_intent_input(&self) -> Result<Input, Error>
Convert this ArkNote to an intent input for settlement.
The note creates a fake VTXO with a hash-lock script. When settling, the preimage is revealed as the witness instead of a signature.