3.0.2 • Published 10 months ago

@secux/app-xlm v3.0.2

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
10 months ago

lerna view on npm npm module downloads

@secux/app-xlm

SecuX Hardware Wallet XLM API

Usage

import { SecuxXLM } from "@secux/app-xlm";

First, create instance of ITransport

Examples

  1. Get address of bip44 path
const address = await device.getAddress("m/44'/148'/0'");

/*

// transfer data to hardware wallet by custom transport layer.
const data = SecuxXLM.prepareAddress("m/44'/148'/0'");
const response = await device.Exchange(data);
const address = SecuxXLM.resolve(response);

*/
  1. Sign transaction
const content = {
    to: "GDATJJ7NZIQ5GR4JBZVUHOGVVSPFEQF2JQ4KIOFZMBDJCH2PJFZJU7UK",
    amount: "123.456",
    sequence: 115521361698357411,
    fee: 100,
    // for new address that don't have on-chain data
    // needCreateAccount: true
}

const { raw_tx, signature } = await device.sign("m/44'/148'/0'", content);

/*

// transfer data to hardware wallet by custom transport layer.
const { commandData, serialized } = SecuxXLM.prepareSign("m/44'/148'/0'", content);
const response = await device.Exchange(commandData);
const raw_tx = SecuxXLM.resolveTransaction(response, serialized);

*/

API Reference

XLM package for SecuX device

Kind: global class

SecuxXLM.prepareAddress ⇒ communicationData

Prepare data for XLM address.

Returns: communicationData - data for sending to device

ParamTypeDescription
pathstringBIP32 path (hardened child key), ex: m/44'/148'/0'

SecuxXLM.addressConvert(publickey) ⇒ string

Convert ED25519 publickey to XLM address.

Returns: string - XLM address

ParamTypeDescription
publickeystring | Buffered25519 publickey

SecuxXLM.resolveAddress(response) ⇒ string

Generate XLM address from response data.

Returns: string - XLM address

ParamTypeDescription
responsecommunicationDatadata from device

SecuxXLM.preparePublickey(path) ⇒ communicationData

Prepare data for ed25519 publickey.

Returns: communicationData - data for sending to device

ParamTypeDescription
pathstringBIP32 path (hardened child key), ex: m/44'/148'/0'

SecuxXLM.resolvePublickey(response) ⇒ string

Resove ed25519 publickey from response data.

Returns: string - ed2519 publickey (hex string)

ParamTypeDescription
responsecommunicationDatadata from device

SecuxXLM.prepareSign(path, content) ⇒ prepared

Prepare data for signing.

Returns: prepared - prepared object

ParamTypeDescription
pathstringBIP32 path (hardened child key), ex: m/44'/148'/0'
contenttxDetailtransaction object

SecuxXLM.resolveSignature(response) ⇒ string

Resolve signature from response data.

Returns: string - signature (hex string)

ParamTypeDescription
responsecommunicationDatadata from device

SecuxXLM.resolveTransaction(response, serialized) ⇒ string

Generate raw transaction for broadcasting.

Returns: string - signed raw transaction

ParamTypeDescription
responsecommunicationDatadata from device
serializedcommunicationDataserialized object

txDetail

Properties

NameTypeDescription
fromstringsending address
tostringreceiving address
amountstringtransfer amount
sequencestring | number
feestring | number
memomemoObj
networkPassphrasestringnetwork for XLM, default is mainnet
needCreateAccountbooleanpay for creating new account, default: false

memoObj

Properties

NameTypeDescription
TypestringMemoType
Valuestring

prepared

Properties

NameTypeDescription
commandDatacommunicationDatadata for sending to device
serializedcommunicationDataserialized object

© 2018-21 SecuX Technology Inc.

authors: andersonwu@secuxtech.com