Skip to content

Conversation

muzaffarbhat07
Copy link
Collaborator

@muzaffarbhat07 muzaffarbhat07 commented Jun 20, 2025

import { ManagerApp } from "@cypherock/sdk-app-manager";
import {
  setBitcoinJSLib,
  BtcApp,
  IGetPublicKeyParams,
  IGetXpubsParams,
  ISignTxnParams
} from "@cypherock/sdk-app-btc";
import * as bitcoinJsLib from 'bitcoinjs-lib';
import hid from '@cypherock/sdk-hw-hid';

async function create_connection (){
  const connection = await hid?.default.create();
  const managerApp = await ManagerApp.create(connection);
  setBitcoinJSLib(bitcoinJsLib);
  const btcApp = await BtcApp.create(connection)

  return {managerApp, btcApp}
}

create_connection().then(async ({managerApp, btcApp}) => {
  // Get all wallets available on device
  const allWallets = await managerApp.getWallets();

  
  const publickey_params: IGetPublicKeyParams = {
    walletId: allWallets.walletList[0].id,
    derivationPath: [0x80000000+49, 0x80000000+0, 0x80000000+0, 0, 0]
  }

  const change_publickey_params: IGetPublicKeyParams = {
    walletId: allWallets.walletList[0].id,
    derivationPath: [0x80000000+49, 0x80000000+0, 0x80000000+0, 1, 0]
  }

  const xpub_params: IGetXpubsParams = {
    walletId: allWallets.walletList[0].id,
    derivationPaths: [
      {
        path: [
          0x80000000+49, 0x80000000+0, 0x80000000+0          
        ]
      }
    ]
  }

  
  const signTxnParams: ISignTxnParams = {
    walletId: allWallets.walletList[0].id,
    derivationPath: [0x80000000+49, 0x80000000+0, 0x80000000+0],
    txn: {
      inputs: [{
        prevTxnId: "",
        prevIndex: 0,
        value: "",
        address: "",
        changeIndex: 0,
        addressIndex: 0,
      }],
      outputs: [
        {
        value: "0",
        address:"",
        isChange: true,
        addressIndex: 0
        }],
    locktime: 0,
    hashType:0x01
    }
  }

  //let xpubs = await btcApp.getXpubs(xpub_params)
  //let publickey = await btcApp.getPublicKey(publickey_params)

  //console.log("xpubs:", xpubs)
  //console.log("public_key:", publickey)
  //let sig = await btcApp.signTxn(signTxnParams)
  //console.log(sig)
})

rxbryan and others added 4 commits August 14, 2024 22:01
test nested-segwit digest for 1 inputs and 2 output transactions
test nested-segwit digest for 2 inputs and 2 output transactions
feat: Add P2SH-P2WPKH support
@muzaffarbhat07 muzaffarbhat07 merged commit cfc0f3e into develop Jul 14, 2025
8 checks passed
@muzaffarbhat07 muzaffarbhat07 deleted the feat/btc-segwit branch July 14, 2025 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants