Giter VIP home page Giter VIP logo

bip21's Introduction

Rust implementation of BIP21

Rust-idiomatic, compliant, flexible and performant BIP21 crate.

About

Important: while lot of work went into polishing the crate it's still considered early-development!

  • Rust-idiomatic: uses strong types, standard traits and other things
  • Compliant: implements all requirements of BIP21, including protections to not forget about req-. (But see features.)
  • Flexible: enables parsing/serializing additional arguments not defined by BIP21.
  • Performant: uses zero-copy deserialization and lazy evaluation wherever possible.

Serialization and deserialization is inspired by serde with these important differences:

  • Deserialization signals if the field is known so that req- fields can be rejected.
  • Much simpler API - we don't need all the features.
  • Use of [Param<'a>] to enable lazy evaluation.

The crate is no_std but does require alloc.

Features

  • std enables integration with std - mainly std::error::Error.
  • non-compliant-bytes - enables use of non-compliant API that can parse non-UTF-8 URI values.

MSRV

1.48.0

License

MITNFA

bip21's People

Contributors

aectaan avatar benthecarman avatar dangould avatar jbesraa avatar kixunil avatar realeinherjar avatar tcharding avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

bip21's Issues

ETA on next release?

When is the next release of this coming out Kix? Is there anything you need help with to get it done?

More trait impls

We could and probably should derive/implement more things:

  • Clone for Uri
  • rewrite derive on Param to print string or bytes (hex encoded?)
  • Probably also (Partial)Eq and Hash

Why not use thiserror crate?

Is there some technical reason why bip21 does not use thiserror? If the docs for thiserror are correct then the derived code should be the same (I have not looked at the generated code myself though).

Thiserror deliberately does not appear in your public API. You get the same thing as if you had written an implementation of std::error::Error by hand, and switching from handwritten impls to thiserror or vice versa is not a breaking change.

I'm interested to understand you reasoning.

Thanks

How can a BIP21 implementation support `Extras` params defined in multiple places?

Modern use of bip21 depends on an unbounded and undefined list of additional parameters beyond those defined by the bip21 spec and implemented in this crate. Supporting and maintaining them all is an increasingly difficult task.

Take MutinyWallet's Waila BIP21 decoder for example. It supports lightning, b12 (bolt12), pj, and pjos (both for Payjoin) parameters. However, there is now demand for sp and ohttp parameters in order to support Silent Payments and Payjoin V2 respectively. Who knows what will come next?

I'm thinking about how to combine distinct Uri parameter Extras without re-implementing each combination decoder from scratch for each combination. Waila doesn't take advantage of downstream dependencies, like the payjoin crate's bip21 parameter PayjoinExtras de/encoder for pj, pjos, and ohttp parameters. Instead, it duplicates source code that needs to be maintained independently. Wouldn't it be nice to depend on the existing, tested implementation inside of a shared decoder instead of duplicating source?

I long for a solution where de/encode logic lives in respective dependency crates and is composable downstream. I want to pull an off-the-shelf decoder like waila that I know handles most everything with tested production dependencies, or otherwise compose those dependencies to address application-specific needs.

It would be even better if, once Extras were composed, a generic bip21::UriBuilder could help me serialize a BIP21 supporting all of the parameters composed in Extras.

I have no proposed solution yet. The first step is to write down the problem to see if anyone else shares it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.