Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@secux/app-bch

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@secux/app-bch

SecuX Hardware Wallet BCH API

  • 2.0.0
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
2
Weekly downloads
 
Created
Source

@secux/app-bch

SecuX Hardware Wallet BCH API

Usage

import { SecuxBCH, ScriptType } from "@secux/app-bch";

First, create instance of ITransport

  • Web Usb
  • Web Bluetooth
  • React Native Bluetooth

Examples

  1. Get address by BIP32 path
const address = SecuxBCH.getAddress(
    device,
    "m/44'/145'/0'/0/0"
);

// p2sh address
const address = SecuxBCH.getAddress(
    device,
    "m/49'/145'/0'/0/0"
);
  1. sign transaction
const inputs = [
    {
        hash: "b4a0e0afd8bf99b8360a22a091b1601dc5bdbdda1ab2ab2d7e74f60f97a1f4ad",
        vout: 0,
        // for p2pkh, the raw transaction of utxo is needed
        txHex: "01000000047aefd21c4b1bcee23c2d4fa485f06ad9e34ce779f46c8a5d4d07f27fc075fd87010000006b483045022100f7e751e707249f17b66b4b9c407b2cc897a03c5f859fad4688d20d577be8dbf9022066e4ea1ed10df2b451cb4c95a9a9103cdd1fc658f053f52eaceb36096d1eb5f0412102babf5f6350dcdb44c078ba47606ecbf23bd34b6e9e6d8e565f1cdefa18164574ffffffffb46defc8ce21fa4a97da31fafb15de77b7d174b2f4cab0b41b207ccffd0c8b6c000000006a47304402200fff5d40f5c3c7ee5d81f6944723e21a66af12540384589df32981db1d9fcf5902204ff42a0e2301570616decdf1922b3fd51c19f81b837bca8fadb78a6993c7a377412103e3e2f368eca31df413d1d0ac8c6abb1399845cea37d7f3204d5b96fc93df5692ffffffff46cb959b6de1a2c4f5f99f15cb7705dc1b329dbdb18269c250a27738f2e9d22a000000006b483045022100e74c5889a950c7f494514f905a05eda57303bc357b6dc26a387b51bfc24dcf7f022039d4d861200603089c8c9bb03b17cbc1fa2bcd357f773640d8ff4db6bc9a736a412102b561d2fab96ca8465858565d723157f2e9978992d046d74e248c067224b6bef1ffffffffe1d3ff7e5a72484421bb654c54216145435bb61420b32e7448ae0f0aa31d2daf000000006b483045022100e26261a8e8274ed4d55d5388cf6c4a3209c6c1714b3cbaddfef280794844eb8f0220084b11c8c17dc178a930828086a974249c98878a15a91fa2effa2a26b8c2052c41210265e6656f477dfe39bb831736bf2469756a0045041999b02a12d9ca72e809594affffffff01082f0100000000001976a914b78d2ccb3e89dda933c8880e0a1f616c273968c288ac00000000",
        satoshis: 77576,
        path: "m/44'/145'/0'/0/0"
    },
    {
        hash: "5b6783feca093f4051b46971a225a4ad0d85e4a7025003c33eee9228f177ae1b",
        vout: 0,
        // for p2pkh, the raw transaction of utxo is needed
        txHex: "0100000003e73c1856947f408099898a54ded58d35e34881a999739688baad2e8fc5c1c1c4010000006b483045022100ba22ff4d9aaee800a8769b65958d57bec0908911f8e13551887980f5958a03720220442f0d1241ba429aae8c11553400275e7d580dc2018736f2e4cde8dcb8ab562b412102cc59d7bc82dc0ad174e360b0443cd602c59e23eae6028a88608ed6b5450fcb15ffffffffadf4a1970ff6747e2dabb21adabdbdc51d60b191a0220a36b899bfd8afe0a0b4000000006a47304402207d1aa16635e07213a1746d94de1e151f55998b09526d041d43d4508894a9fd760220038cde113e742d82f6913eb2839cd0471f5770fe470f4227568590965bbfc22f4121030ae60670525f6b0a5d2ef12894b46ba3f87c63451f33e8e234f8494a0082966dffffffff7aefd21c4b1bcee23c2d4fa485f06ad9e34ce779f46c8a5d4d07f27fc075fd87000000006b48304502210096c1e51554f3036cc14a3ef1bc1d0470c30c130d710c81d80a69d2478f72f1b80220020aa171cb0d85e1318b555d4570f3eabd21787ea6561f4a822d4ca68177328b41210386e067ca093a4a0a24bdc6a77dc717182c531c2e477b70668c29b63257a486d4ffffffff017dcc0100000000001976a91499f662e0d633ad79c61a0c4274184aa4716fb54d88ac00000000",
        satoshis: 117885,
        path: "m/44'/145'/1'/0/0"
    }
];

const out = {
    address: "qqj3dr364rw9eyv4ke848kpu8aheuf8llc9pwu3smu",
    satoshis: 11111
};

// or send to another account
// const out = {
//     path: "m/44'/145'/1'/0/0",
//     satoshis: 11111
// };

const utxo = {
    path: "m/44'/145'/0'/0/2",
    satoshis: 16666
};


const { raw_tx, signature } = await SecuxBCH.signTransaction(
    device,
    inputs,
    {
        to: out,
        utxo: utxo
    }
);

API doc

SecuxBCH

BCH package for SecuX device

Kind: global class


SecuxBCH.getAddress(trans, path, [option])string

Get address derived by given BIP32 path

Kind: static method of SecuxBCH
Returns: string - address

ParamTypeDescription
transITransport
pathstringBIP32
[option]AddressOption


SecuxBCH.signTransaction(trans, inputs, outputs)object

Create transaction and Sign

Kind: static method of SecuxBCH
Returns: object - signed
string - signed.raw_tx
Array<Buffer> - signed.signature

ParamType
transITransport
inputsArray<txInput>
outputstxOutput

Keywords

FAQs

Package last updated on 26 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc