-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a70be87
commit 996f1db
Showing
1 changed file
with
99 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<img src="https://user-images.githubusercontent.com/4631227/191834116-59cf590e-25cc-4956-ae5c-812ea464f324.png" height="100" /> | ||
|
||
## coderofstuff/hw-app-kaspa | ||
|
||
Ledger Hardware Wallet Kaspa JavaScript bindings. | ||
|
||
|
||
## API | ||
|
||
<!-- Generated by documentation.js. Update this documentation by updating the source code. --> | ||
|
||
#### 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 | ||
|
||
|