@secux/protocol-transaction
v3.1.5
Published
SecuX Hardware Wallet transcation related protocol API
Downloads
59
Maintainers
Readme
@secux/protocol-transaction
SecuX Hardware Wallet transcation related protocol API
Usage
import { EllipticCurve, SecuxTransactionTool } from "@secux/protocol-transaction";
First, create instance of ITransport
Examples
- Query publickey from SecuX Hardware Wallet
const data = SecuxTransactionTool.getPublickey("m/44'/0'/0'/0/0", EllipticCurve.SECP256K1);
const response = await device.Exchange(data);
const publickey = SecuxTransactionTool.resolvePublickey(
response,
EllipticCurve.SECP256K1,
true // SECP256K1 compress flag
);
- Query extended publickey from SecuX Hardware Wallet
const data = SecuxTransactionTool.getXPublickey("m/44'/0'/0'/0/0");
const response = await device.Exchange(data);
const xpub = SecuxTransactionTool.resolveXPublickey(response, "m/44'/0'/0'/0/0");
API Reference
Protocol layer of transaction related method
Kind: global class
- SecuxTransactionTool
- .resolveResponse(response) ⇒ IAPDUResponse
- .getPublickey(path, curve) ⇒ communicationData
- .resolvePublickey(response, curve, compressed) ⇒ string
- .getXPublickey(path) ⇒ communicationData
- .resolveXPublickey(response, path) ⇒ string
- .signTransaction(path, tx, [option]) ⇒ communicationData
- .resolveSignature(response) ⇒ string
- .signTransactionList(paths, txs, [otpion]) ⇒ communicationData
- .resolveSignatureList(response) ⇒ Array.<string>
- .signRawTransaction(path, tx, [option]) ⇒ communicationData
- .signRawTransactionList(paths, txs, [confirm], [otpion]) ⇒ communicationData
- .signMessage(path, msg, [option]) ⇒ communicationData
- .signTypedMessage(path, typedMessageHash, [option]) ⇒ communicationData
- ~~.txPrepare(path, inputId, tx, confirm, [isToken]) ⇒ communicationData~~
- ~~.txBegin(amount, toAddress, [showConfirm]) ⇒ communicationData~~
- ~~.txEnd() ⇒ communicationData~~
- ~~.txSign(inputId) ⇒ communicationData~~
SecuxTransactionTool.resolveResponse(response) ⇒ IAPDUResponse
Resolve response from device.
Returns: IAPDUResponse - response object
| Param | Type | Description | | --- | --- | --- | | response | communicationData | data from device |
SecuxTransactionTool.getPublickey(path, curve) ⇒ communicationData
Query publickey (uncompressed) command.
Returns: communicationData - data for sending to device
| Param | Type | Description | | --- | --- | --- | | path | string | BIP32 | | curve | EllipticCurve | 0: SECP256K1, 1: ED25519 |
SecuxTransactionTool.resolvePublickey(response, curve, compressed) ⇒ string
Reslove publickey from SecuX device.
Returns: string - publickey (base64 encoded)
| Param | Type | Default | Description | | --- | --- | --- | --- | | response | communicationData | | data from device | | curve | EllipticCurve | | 0: SECP256K1, 1: ED25519 | | compressed | boolean | true | setting for secp256k1 |
SecuxTransactionTool.getXPublickey(path) ⇒ communicationData
Query extended publickey command.
Returns: communicationData - data for sending to device
| Param | Type | Description | | --- | --- | --- | | path | string | BIP32 |
SecuxTransactionTool.resolveXPublickey(response, path) ⇒ string
Reslove extended publickey from SecuX device.
Returns: string - xpub
| Param | Type | Description | | --- | --- | --- | | response | communicationData | data from device | | path | string | BIP32 |
SecuxTransactionTool.signTransaction(path, tx, [option]) ⇒ communicationData
Sign a hashed transcation command.
Returns: communicationData - data for sending to device
| Param | Type | Description | | --- | --- | --- | | path | string | BIP32 | | tx | communicationData | prepared transaction data | | [option] | TransactionOption | |
SecuxTransactionTool.resolveSignature(response) ⇒ string
Reslove signature from SecuX device.
Returns: string - signature (base64 encoded)
| Param | Type | Description | | --- | --- | --- | | response | communicationData | data from device |
SecuxTransactionTool.signTransactionList(paths, txs, [otpion]) ⇒ communicationData
Sign hashed transactions command.
Returns: communicationData - data for sending to device
| Param | Type | Description | | --- | --- | --- | | paths | Array.<string> | BIP32 | | txs | Array.<Buffer> | prepared transaction data corresponding to above path | | [otpion] | TransactionOption | |
SecuxTransactionTool.resolveSignatureList(response) ⇒ Array.<string>
Reslove signature from SecuX device.
Returns: Array.<string> - signature array of base64 string
| Param | Type | Description | | --- | --- | --- | | response | communicationData | data from device |
SecuxTransactionTool.signRawTransaction(path, tx, [option]) ⇒ communicationData
Sign a transcation command.
Returns: communicationData - data for sending to device
| Param | Type | Description | | --- | --- | --- | | path | string | BIP32 | | tx | communicationData | prepared transaction data | | [option] | TransactionOption | |
SecuxTransactionTool.signRawTransactionList(paths, txs, [confirm], [otpion]) ⇒ communicationData
Sign transactions command.
Returns: communicationData - data for sending to device
| Param | Type | Description | | --- | --- | --- | | paths | Array.<string> | BIP32 | | txs | Array.<Buffer> | prepared transaction data corresponding to above path | | [confirm] | communicationData | | | [otpion] | TransactionOption | |
SecuxTransactionTool.signMessage(path, msg, [option]) ⇒ communicationData
Sign message command.
Returns: communicationData - data for sending to device
| Param | Type | Description | | --- | --- | --- | | path | string | BIP32 | | msg | communicationData | | | [option] | MessageOption | |
SecuxTransactionTool.signTypedMessage(path, typedMessageHash, [option]) ⇒ communicationData
Sign typed message command.
Returns: communicationData - data for sending to device
| Param | Type | Description | | --- | --- | --- | | path | string | BIP32 | | typedMessageHash | communicationData | | | [option] | MessageOption | |
~~SecuxTransactionTool.txPrepare(path, inputId, tx, confirm, [isToken]) ⇒ communicationData~~
Deprecated
Send utxo command.
Returns: communicationData - data for sending to device
| Param | Type | Default | Description | | --- | --- | --- | --- | | path | string | | BIP32 | | inputId | number | | uint8 | | tx | communicationData | | | | confirm | communicationData | | | | [isToken] | boolean | false | |
~~SecuxTransactionTool.txBegin(amount, toAddress, [showConfirm]) ⇒ communicationData~~
Deprecated
Begin signing command.
Returns: communicationData - data for sending to device
| Param | Type | Default | | --- | --- | --- | | amount | string | | | toAddress | string | | | [showConfirm] | boolean | false |
~~SecuxTransactionTool.txEnd() ⇒ communicationData~~
Deprecated
End signing command.
Returns: communicationData - data for sending to device
~~SecuxTransactionTool.txSign(inputId) ⇒ communicationData~~
Deprecated
Sign command.
Returns: communicationData - data for sending to device
| Param | Type | Description | | --- | --- | --- | | inputId | number | uint8 |
IAPDUResponse
Properties
| Name | Type | Description | | --- | --- | --- | | status | number | StatusCode | | data | string | base64 encoded | | dataLength | number | length of the data |
StatusCode
Properties
| Name | Type | Description | | --- | --- | --- | | DATA_ERROR | number | 0x5001 | | CLA_ERROR | number | 0x5002 | | INS_ERROR | number | 0x5003 | | SUCCESS | number | 0x9000 |
TransactionType
Properties
| Name | Type | Description | | --- | --- | --- | | NORMAL | number | 0 | | TOKEN | number | 1 | | NFT | number | 2 |
EllipticCurve
Properties
| Name | Type | Description | | --- | --- | --- | | SECP256K1 | number | 0 | | ED25519 | number | 1 |
TransactionOption
Properties
| Name | Type | | --- | --- | | tp | TransactionType | | curve | EllipticCurve | | chainId | number |
© 2018-21 SecuX Technology Inc.
authors: [email protected]