Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add P2SH-P2WPKH support #528

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

rxbryan
Copy link

@rxbryan rxbryan commented Jul 9, 2024

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 rxbryan force-pushed the feature/segwit branch 5 times, most recently from 14092e0 to 0fd66c3 Compare July 11, 2024 12:57
@ParnikaGupta9 ParnikaGupta9 changed the base branch from main to develop July 11, 2024 14:22
apps/btc_family/btc_pub_key.c Outdated Show resolved Hide resolved
apps/btc_family/btc_txn.c Show resolved Hide resolved
tests/apps/btc_app/btc_txn_helpers_tests.c Outdated Show resolved Hide resolved
tests/apps/btc_app/btc_txn_helpers_tests.c Outdated Show resolved Hide resolved
@ParnikaGupta9 ParnikaGupta9 changed the title feat: add P2SH-P2WPKH support feat: Add P2SH-P2WPKH support Jul 11, 2024
@rxbryan rxbryan force-pushed the feature/segwit branch 3 times, most recently from 3599921 to 1d49b1a Compare July 12, 2024 09:06
@rxbryan rxbryan force-pushed the feature/segwit branch 4 times, most recently from 40bcfcb to 4cc3cd3 Compare August 8, 2024 00:24
test nested-segwit digest for 1 inputs and 2 output transactions
test nested-segwit digest for 2 inputs and 2 output transactions
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