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

@secux/app-btc

Package Overview
Dependencies
Maintainers
2
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@secux/app-btc

SecuX Hardware Wallet BTC API

  • 2.0.1
  • npm
  • Socket score

Version published
Weekly downloads
47
decreased by-44.05%
Maintainers
2
Weekly downloads
 
Created
Source

@secux/app-btc

SecuX Hardware Wallet BTC API

Usage

import { CoinType, SecuxBTC, ScriptType } from "@secux/app-btc";

First, create instance of ITransport

  • Web Usb
  • Web Bluetooth
  • React Native Bluetooth

Examples

  1. Get address by purpose and script type
// native segwit address (default script: P2WPKH)
const address = SecuxBTC.getAddress(
    device, 
    "m/84'/0'/0'/0/0", 
    // optional object
    { 
        // define cointype for checking path
        coin: CoinType.BITCOIN,  

        // define specific script
        script: ScriptType.P2WPKH  
    }
);

// segwit address (default script: P2SH_P2WPKH)
const address = SecuxBTC.getAddress(
    device, 
    "m/49'/0'/0'/0/0"
);

// legacy address (default script: P2PKH)
const address = SecuxBTC.getAddress(
    device, 
    "m/44'/0'/0'/0/0"
);
  1. For bitcoin ecosystem, you can use specific cointype by the coin
// native segwit address for dogecoin
const address = SecuxBTC.getAddress(
    device, 
    "m/84'/3'/0'/0/0"
);

// segwit address for litecoin
const address = SecuxBTC.getAddress(
    device, 
    "m/49'/2'/0'/0/0",
);

// legacy address for bitcoincash
const address = SecuxBTC.getAddress(
    device, 
    "m/44'/145'/0'/0/0"
);
  1. sign transaction
const inputs = [
    {
        hash: "0b062e71e165fba9634d9fb1b5ba703e774bf374815b1f5a617c8d1e7d43dc01",
        vout: 0,
        // optional, give raw transaction data for checking
        txHex: "0100000001b103a004f672080ceae8277e83c296b5ac090ae78157979211da3e2d41399d1b010000006b483045022100f19d88e6a17789dc399ff2a93b4516bb44af32928d4986138f1a4f7f37ab277b022046fc14c958bc8aa97fea1d2fbf80982534cf51634d46c4d5178e5ca6698bca07012102f8667cfb5b80c3695e3f0c9078589cb04e8d15e71bdae89ebf24b82f9d663d5cffffffff02bc020000000000001976a9145c592f40134c6179a1ce5b06b28d5c2ae443113188ac00040000000000001976a9146d65ced4ef49e23cdbb4be9d510b38e5be28e10688ac00000000",
        satoshis: 700,
        path: "m/44'/0'/0'/0/0"
    },
    {
        hash: "07ad0a13e501d292bc8b9e16a3a8b62f99f77ab9e37ea8d3b8453984a2899984",
        vout: 0,
        // optional, you can use specific script for each input
        script: ScriptType.P2SH_P2WPKH,
        satoshis: 6000,
        path: "m/49'/0'/0'/0/0"
    },
    {
        hash: "8686aee2b9dcf559798b9718ed26ca92e0c64bef11c433e576cae658678c497d",
        vout: 1,
        satoshis: 1083,
        path: "m/84'/0'/0'/1/0"
    }
];

const out = {
    address: "bc1qs0k3ekx0z7a7yuq3lse7prw373s8cr8lhxvccd",
    satoshis: 1500
};
// or send to another account
// const out = {
//     path: "m/84'/0'/1'/0/3",
//     satoshis: 1500
// };

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


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

API doc

SecuxBTC

BTC package for SecuX device

Kind: global class


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

Get address derived by given BIP32 path

Kind: static method of SecuxBTC
Returns: string - address

ParamTypeDescription
transITransport
pathstringBIP32
[option]AddressOption


SecuxBTC.signTransaction(trans, inputs, outputs) ⇒ object

Create transaction and Sign

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

ParamType
transITransport
inputsArray<txInput>
outputstxOutput

Keywords

FAQs

Package last updated on 22 Dec 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