Skip to content

Commit 6da0c2c

Browse files
committed
1 parent 5375105 commit 6da0c2c

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

crates/nostr/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
### Added
3737

38+
- Implement `ToBech32` trait for `Nip21`
3839
- Add nip47 holdinvoice methods and notification (https://github.com/rust-nostr/nostr/pull/1019)
3940
- Add `TransactionState` to `LookupInvoiceResponse` and `PaymentNotification` (https://github.com/rust-nostr/nostr/pull/1045)
4041
- Add `description`, `description_hash`, `preimage`, `amount`, `created_at` and `expires_at` optional fields to `MakeInvoiceResponse` (https://github.com/rust-nostr/nostr/pull/1045)

crates/nostr/src/nips/nip21.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,20 @@ impl Nip21 {
196196
}
197197
}
198198

199+
impl ToBech32 for Nip21 {
200+
type Err = Error;
201+
202+
fn to_bech32(&self) -> Result<String, Self::Err> {
203+
match self {
204+
Self::Pubkey(val) => Ok(val.to_bech32()?),
205+
Self::Profile(val) => Ok(val.to_bech32()?),
206+
Self::EventId(val) => Ok(val.to_bech32()?),
207+
Self::Event(val) => Ok(val.to_bech32()?),
208+
Self::Coordinate(val) => Ok(val.to_bech32()?),
209+
}
210+
}
211+
}
212+
199213
#[cfg(test)]
200214
mod tests {
201215
use core::str::FromStr;

0 commit comments

Comments
 (0)