Giter Club home page Giter Club logo

coins's Introduction

docs.rs docs.rs docs.rs

coins

This project aims to provide high-quality tooling for bip32, bip39, and ledger device communication. It is a toolbox for building signers for blockchain applications. The code runs both natively and in wasm targets for browser and node.

This repo previously hosted a set of transaction construction libraries for UTXO-based chains. You can find much of that work in the archive folder (for now). This is the last commit with that code in the main packages.

Building & running tests

  • install rustup
  • Run all the tests $ ./build.sh
  • build the docs: $ cargo doc

Project Goals

  • Support bip32, bip39, and Ledger device comms
  • Provide basic tooling to support these use cases
  • WASM compatibility in all packages

Project Status

This project is used extensively in the ethers-rs ecosystem. However, much of it is in an alpha/beta state. There will be rough edges, and the interfaces are subject to change.

License Notes

Some work in the ledger crate is reproduced under the APACHE 2.0 license. See that README for specific info

coins's People

Contributors

0xyyy avatar agostbiro avatar alicanc avatar cloudhead avatar danipopes avatar dependabot[bot] avatar dominiquejane avatar ewilz avatar gakonst avatar joshiedo avatar mattsse avatar poma-keeps-building avatar prestwich avatar roynalnaruto avatar rswanson avatar thomaseizinger avatar tynes avatar xjonathanlei avatar zmanian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coins's Issues

Release a new patch version

Hi folks,

Great work you're doing here ๐Ÿ‘
Wanted to ask if it would be possible to create a patch version to include the commit bb8c4fa and publish it to crates.io, to allow ethers-rs to update, since there are Ledgers Nano S and Nano X (like mine) that respond with a APDU Response error Code 9000 ([APDU_CODE_NOERROR]) before that commit.

Thanks!

Think about macros around core/src/hashes

There is a lot of copy/paste code between hash256.rs, blake2b256.rs and sha3_256.rs (handshake branch, https://github.com/summa-tx/bitcoins-rs/pull/43/files#diff-4a068cf29f566ee9c1fee95ad83ee1f0). This could likely turn into a macro, it needs part of:
https://github.com/summa-tx/bitcoins-rs/blob/53a107c3002e1a3cb1375b46ef9024cbdc6c6624/core/src/macros.rs#L191

Maybe turn the part of the macro that implements ByteFormat into another macro, impl_32_byte_format, that can be also called on its own as well as inside of mark_32_byte_hash?
https://github.com/summa-tx/bitcoins-rs/blob/53a107c3002e1a3cb1375b46ef9024cbdc6c6624/core/src/macros.rs#L224

Failed to sign PSBT using ledger

I've been building a PoC for using this lib to sign PSBTs and I've run into an issue that I can't resolve.

My PoC is here: https://github.com/thomaseizinger/rust-ledger-poc
You can run the shell script with a ledger plugged in and it should error with:

Error: failed to get signatures from device

Caused by:
    Ledger device: APDU Response error `Code 6985 ([APDU_CODE_CONDITIONS_NOT_SATISFIED] Conditions of use not satisfied)`

Any ideas of what could be the issue?

Improve ByteFormat interface

read_from has a second argument that is unused in most cases. It only gets used when we're reading a sequence like Vec<T>::read_from(source, 5). Instead, we should drop this method, avoid implementing implement something like T::read_sequence(5)

We should consider splitting up ByteFormat into an Encode and a Decode trait. Maybe consider re-using nomic's work. https://docs.rs/ed/0.1.5/ed/

tx components

  • Outpoint
  • TxIn
  • TxOut
  • WitnessStackItem
  • InputWitness
  • Tx

Remove bitcoin-spv dependency

add sha256, hash256, rmd160, and hash160 utils to core

differentiate the Hash256Digest type to be hash-function specific (newtype-wrapped [u8;32])

genericize Script

Address encoders assume things go to Script. Instead, we should make a basic trait and have it be an associated type of the encoder

Refactor ledger transport interface

sketch:

pub trait APDUTransport {
    type Result;
    fn exchange (&self, packet: APDUCommand) -> Self::Result;
}

pub trait TransportNew: Sized {
    type Error: Debug;
    fn init() -> Result<Self, Self::Error>;
}

struct TransportSync{...}
struct TransportAsync{...}

Ledger BTC protocol selection

BTC app protocol varies based on app version. We should generalize the signing functionality to query device version and select an appropriate protocol

genericize TxIns and Outpoints

Pretty much everything else about a TX is genericized to allow easy implementation of other networks. But the Builder still has Outpoint hardcoded into its type signatures. Should figure out an elegant way of genericizing this into a UTXO ID kinda thing that is instantiated as an Outpoint

utils

i2le
i2le_padded
i2le_script
le2i
be2i
i2be
i2be_padded
change_endianness
rmd160
sha256
hash160
hash256

rethink bitcoins-wasm

Bitcoins has undergone significant updates since I made this. Plus I've learned a bunch about wasm wrapping things. It would be relatively easy to restart.

  • disable CI in build.sh
  • redesign macros
  • redo all exports
  • fix the docs

This is not a blocker for initial release, I think

Secrets Management with Secrecy/Zeroize

Secrets such as Private Keys must remain in memory for as little as possible to minimize chances of extraction via side-channels and similar methods. They must also never be logged.

All such types in the repo should implement Zeroize, so that they're written with 0's once they're dropped (or manually zeroized), and they should be wrapped with Secret so that they're not accidentally logged. The internal type can be accessed via ExposeSecret.

follow prelude conventions

currently preludes are macros and other things that should be available within the module/crate

Instead, make preludes common exports and useful things for consumers of the library.

Ledger native tranport for OSX

error: cannot find macro `quick_error` in this scope
  --> /riemann-rs/ledger/src/transports/hid.rs:17:13
   |
17 |             quick_error! {
   |             ^^^^^^^^^^^
error[E0412]: cannot find type `Error` in module `nix`
  --> /riemann-rs/ledger/src/transports/hid.rs:60:24
   |
60 |     Ioctl(#[from] nix::Error),
   |                        ^^^^^ not found in `nix`
   |
help: possible candidates are found in other modules, you can import them into scope

Builder/transaction from PSBT

Write/find a PSBT encoder/decoder.
Instantiate builder and transaction objects from PSBT.
Serialize builder and transaction objects to PSBT

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.