GithubHelp home page GithubHelp logo

diem / ledger-nano-app Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 4.0 605 KB

License: Apache License 2.0

Dockerfile 0.02% C 68.37% Rust 13.46% Python 3.78% C++ 0.70% POV-Ray SDL 9.83% Assembly 1.21% HTML 2.58% Shell 0.05%

ledger-nano-app's Introduction

Note to readers: Silvergate Capital Corporation announced in January 2022 that it acquired intellectual property and other technology assets related to running a blockchain-based payment network from Diem, further investing in its platform and enhancing its existing stablecoin infrastructure.

Diem Logo

Diem Rust Crate Documentation (main) License grcov test history

Diem Core implements a decentralized, programmable distributed ledger which provides a financial infrastructure that can empower billions of people.

Note to Developers

  • Diem Core is a prototype.
  • The APIs are constantly evolving and designed to demonstrate types of functionality. Expect substantial changes before the release.
  • We’ve launched a testnet that is a live demonstration of an early prototype of the Diem Blockchain software.

Quick Links

Learn About Diem

Getting Started - Try Diem Core

Technical Papers

Governance

Blog

License

Diem Core is licensed as Apache 2.0.

ledger-nano-app's People

Contributors

ankushagarwal avatar lei2022 avatar texas16 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ledger-nano-app's Issues

Parse a bcs serialized RawTransaction and return important fields

When a RawTransaction is being signed on the ledger nano device, we want to display relevant transaction fields on the display so that the user can confirm them before signing.

Source of RawTransaction struct : https://github.com/diem/diem/blob/0bf8a9702c847bb9741b3b4747ed4e0ca5f1a827/types/src/transaction/mod.rs#L67

Fields that we want to extract:

  • sequence_number: u64
  • payload: TransactionPayload
    • If payload is of type ScriptFunction(ScriptFunction), parse
      • module: ModuleId,
      • function: Identifier,
      • ty_args: Vec,
      • args: Vec<Vec>,

Example serialized (hex-encoded) RawTransaction in bcs is:

000000000000000000000000000000016d0500000000000003000000000000000000000000000000010e5061796d656e74536372697074731a706565725f746f5f706565725f776974685f6d657461646174610107000000000000000000000000000000010358555303585553000410000000000000000000000000000000dd0801000000000000000100010048010000000000009b0300000000000003585553287412000000000004

The code for constructing this RawTransaction object and serializing it is here : https://github.com/ankushagarwal/libra/blob/test-txn-serialize/api/src/tests/transactions_test.rs#L1701

We need to take this serialized RawTransaction in our app and write a function which can extract the fields mentioned above

Step 1

Write a function in rust-app/src/utils.rs which takes as an input the raw_txn as a byte array (&[u8]) and parses returns the u64 sequence number.

Sample fn signature : fn seq_num(raw_txn: &[u8]) -> Result<u64, u8>

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.