Coder Social home page Coder Social logo

hw-app-kaspa's Introduction

coderofstuff/hw-app-kaspa

Ledger Hardware Wallet Kaspa JavaScript bindings.

API

Table of Contents

Kaspa

Kaspa API

Parameters

  • transport Transport a transport for sending commands to a device

Examples

import Kaspa from "hw-app-kaspa";
const kaspa = new Kaspa(transport);

getPublicKey

Get Kaspa Public Key for a BIP32 path.

Parameters
  • path string a BIP32 path
  • display boolean flag to show display (optional, default false)
Examples
kaspa.getPublicKey("44'/111111'/0'")

Returns Promise<Buffer> the public key buffer with chain code

signTransaction

Sign a Kaspa transaction.

Parameters
  • transaction Transaction from src/transaction.js
Examples
import Kaspa from 'hw-app-kaspa';
import { TransactionInput, TransactionOutput, Transaction } from 'hw-app-kaspa';

...

const kaspa = new Kaspa(transport);

const txin = new TransactionInput({
    prevTxId: "40b022362f1a303518e2b49f86f87a317c87b514ca0f3d08ad2e7cf49d08cc70",
    value: 1100000,
    addressType: 0,
    addressIndex: 0,
    outpointIndex: 0,
});

const txout = new TransactionOutput({
    value: 1000000,
    scriptPublicKey: "2011a7215f668e921013eb7aac9b7e64b9ec6e757c1b648e89388c919f676aa88cac",
});

// By convention, the second output MUST be the change address
// It MUST set both addressType and addressIndex
const txoutchange = new TransactionOutput({
    value: 90000,
    scriptPublicKey: "2011a7215f668e921013eb7aac9b7e64b9ec6e757c1b648e89388c919f676aa88cac",
});

const tx = new Transaction({
    version: 0,
    changeAddressType: 0,
    changeAddressIndex: 0,
    inputs: [txin],
    outputs: [txout, txoutchange],
});

kaspa.signTransaction(tx);

Updates the transaction by filling in the signature property of each TransactionInput in the Transaction object.

hw-app-kaspa's People

Contributors

coderofstuff avatar

Stargazers

starkbamse avatar

Watchers

 avatar

Forkers

biluohc

hw-app-kaspa's Issues

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.