@secux/app-xrp
v3.0.4
Published
SecuX Hardware Wallet XRP API
Downloads
29
Maintainers
Readme
@secux/app-xrp
SecuX Hardware Wallet XRP API
Usage
import { SecuxXRP } from "@secux/app-xrp";
First, create instance of ITransport
Examples
- Get address of bip44 path
const address = await device.getAddress("m/44'/144'/0'/0/0");
/*
// transfer data to hardware wallet by custom transport layer.
const data = SecuxXRP.prepareAddress("m/44'/144'/0'/0/0");
const response = await device.Exchange(data);
const address = SecuxXRP.resolveAddress(response);
*/
- Sign transaction
let payment = {
TransactionType: "Payment",
Account: "rD17Ez7fBpuwVp6smfjYhPKD3pwiN5QGKX",
Destination: "rGNitVptpmpCNYC23LbQ9yfCnAf1Z6gq7X",
amount: 1e6
};
// fetch data from XRP api
const { BroadcastClient } = require("xrpl");
client = new BroadcastClient(["wss://s1.ripple.com"]);
await client.connect();
payment = await client.autofill(payment);
// sign
const raw_tx = await device.sign("m/44'/144'/0'/0/0", payment);
/*
// transfer data to hardware wallet by custom transport layer.
const { commandData, serialized } = SecuxXRP.prepareSign("m/44'/144'/0'/0/0", {
...payment,
SigningPubKey: "026771406ace54da2cae8b168862697ca35bc3db56c90f4270adb307ac9a38fe9c"
});
const response = await device.Exchange(data);
const raw_tx = SecuxXRP.resolveTransaction(response, serialized);
*/
// broadcast
await client.submit(raw_tx);
API Reference
XRP package for SecuX device
Kind: global class
- SecuxXRP
- .prepareAddress ⇒ communicationData
- .addressConvert(publickey) ⇒ string
- .resolveAddress(response) ⇒ string
- .preparePublickey(path) ⇒ communicationData
- .resolvePublickey(response) ⇒ string
- .prepareXPublickey(path) ⇒ communicationData
- .resolveXPublickey(response, path) ⇒ string
- .prepareSign(path, json) ⇒ prepared
- .resolveSignature(response) ⇒ string
- .resolveTransaction(response, serialized) ⇒ string
SecuxXRP.prepareAddress ⇒ communicationData
Prepare data for XRP address.
Returns: communicationData - data for sending to device
| Param | Type | Description | | --- | --- | --- | | path | string | m/44'/144'/... |
SecuxXRP.addressConvert(publickey) ⇒ string
Convert secp256k1 publickey to XRP address.
Returns: string - XRP address
| Param | Type | Description | | --- | --- | --- | | publickey | string | Buffer | secp256k1 publickey |
SecuxXRP.resolveAddress(response) ⇒ string
Generate XRP address from response data.
Returns: string - XRP address
| Param | Type | Description | | --- | --- | --- | | response | communicationData | data from device |
SecuxXRP.preparePublickey(path) ⇒ communicationData
Prepare data for secp256k1 publickey.
Returns: communicationData - data for sending to device
| Param | Type | Description | | --- | --- | --- | | path | string | m/44'/144'/... |
SecuxXRP.resolvePublickey(response) ⇒ string
Resolve secp256k1 publickey from response data.
Returns: string - secp256k1 publickey (hex string)
| Param | Type | Description | | --- | --- | --- | | response | communicationData | data from device |
SecuxXRP.prepareXPublickey(path) ⇒ communicationData
Prepare data for xpub.
Returns: communicationData - data for sending to device
| Param | Type | Description | | --- | --- | --- | | path | string | m/44'/144'/... |
SecuxXRP.resolveXPublickey(response, path) ⇒ string
Generate xpub from response data.
Returns: string - xpub
| Param | Type | Description | | --- | --- | --- | | response | communicationData | data from device | | path | string | m/44'/144'/... |
SecuxXRP.prepareSign(path, json) ⇒ prepared
Prepare data for signing.
Returns: prepared - prepared object
| Param | Type | Description | | --- | --- | --- | | path | string | m/44'/144'/... | | json | baseObject | transaction object (same as XRP api) |
SecuxXRP.resolveSignature(response) ⇒ string
Resolve signature from response data.
Returns: string - signature (hex string)
| Param | Type | Description | | --- | --- | --- | | response | communicationData | data from device |
SecuxXRP.resolveTransaction(response, serialized) ⇒ string
Generate raw transaction for broadcasting.
Returns: string - signed raw transaction
| Param | Type | Description | | --- | --- | --- | | response | communicationData | data from device | | serialized | communicationData | |
baseObject
Properties
| Name | Type | Description | | --- | --- | --- | | TransactionType | string | | | SigningPubKey | string | Buffer | ed25519 publickey | | Sequence | number | | | Fee | string | number | | | LastLedgerSequence | number | | | [Account] | string | sending address | | [Destination] | string | receiving address | | [Amount] | string | number | | | [SourceTag] | number | | | [DestinationTag] | number | |
prepared
Properties
| Name | Type | Description | | --- | --- | --- | | commandData | commandData | data for sending to device | | serialized | commandData | |
© 2018-21 SecuX Technology Inc.
authors: [email protected]