diff --git a/README.md b/README.md new file mode 100644 index 0000000..661ea68 --- /dev/null +++ b/README.md @@ -0,0 +1,99 @@ + + +## coderofstuff/hw-app-kaspa + +Ledger Hardware Wallet Kaspa JavaScript bindings. + + +## API + + + +#### Table of Contents + +* [Kaspa](#kaspa) + * [Parameters](#parameters) + * [Examples](#examples) + * [getAddress](#getaddress) + * [Parameters](#parameters-1) + * [Examples](#examples-1) + * [signTransaction](#signtransaction) + * [Parameters](#parameters-2) + * [Examples](#examples-2) + +### Kaspa + +Kaspa API + +#### Parameters + +* `transport` **Transport** a transport for sending commands to a device + +#### Examples + +```javascript +import Kaspa from "@ledgerhq/hw-app-kaspa"; +const kaspa = new Kaspa(transport); +``` + +#### getAddress + +Get Kaspa address (public key) for a BIP32 path. + +##### Parameters + +* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a BIP32 path +* `display` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** flag to show display (optional, default `false`) + +##### Examples + +```javascript +kaspa.getAddress("44'/501'/0'").then(r => r.address) +``` + +Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<{address: [Buffer](https://nodejs.org/api/buffer.html)}>** an object with the address field + +#### signTransaction + +Sign a Kaspa transaction. + +##### Parameters + +* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a BIP32 path +* `transaction` **Transaction** from `src/transaction.js` + +##### Examples + +```javascript +const Kaspa = require("../src/kaspa"); +const { TransactionInput, TransactionOutput, Transaction } = require("../src/transaction"); + +... + +const kaspa = new Kaspa(transport); + +const txin = new TransactionInput({ + prevTxId: "40b022362f1a303518e2b49f86f87a317c87b514ca0f3d08ad2e7cf49d08cc70", + value: 1100000, + addressType: 0, + addressIndex: 0, + outpointIndex: 0, +}); + +const txout = new TransactionOutput({ + value: 1090000, + scriptPublicKey: "2011a7215f668e921013eb7aac9b7e64b9ec6e757c1b648e89388c919f676aa88cac", +}); + +const tx = new Transaction({ + version: 0, + inputs: [txin], + outputs: [txout], +}); + +kaspa.signTransaction(tx); +``` + +Updates the + +