ebellocchia / bip_utils

Generation of mnemonics, seeds, private/public keys and addresses for different types of cryptocurrencies

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generate correct taproot addresses for both wallets

jjhesk opened this issue · comments

I am looking to solve the problems of finding the correct P2TR (m/86'/0'/0'/0) address starting from the given 12 words mnemonic.

Generate to bitcoin address with P2TR standard as mentioned works of OKX wallet and the works of unisats wallet they both have different ways to generate the bitcoin taproot address.

The basic concept:
A pay-to-taproot (P2TR), also known as a Taproot or Bech32m address, is the most recent and advanced bitcoin address format. Taproot introduces more advanced security, privacy, flexibility and scaling to bitcoin. Like SegWit, Taproot addresses are opt-in and not currently widely supported. Taproot adoption can be tracked here.

Benefits of Taproot include the ability to use Schnorr Signatures, offering better security, lower fees, and more flexible multi-key transactions. Multi-key addresses using P2TR look the same as single-key addresses giving users of multi-key increased privacy. Taproot also enables more advanced scripting, enabling more complex smart contracts to be built on bitcoin.

Taproot addresses start with bc1p with total length of 62 and are case insensitive. specification

step 2:
After I have done studying the generation mechanism, I try to integrate the python coding into the hd-wallet repo for better code management.

I want to express my gratitude for the excellent package you have created. I extensively used your package code to develop a wallet package in EXX.

Hi, do you know in which way that wallet generates the address differently?

This is the research direction. I have opened their wallet libraries and the the core library in OKEX is crypto-lib.js @okxweb3/crypto-lib with the design bip-0341 and unisats is using another internal library bitcoin-core that I have no information. Both wallets have generated different addresses on testnet format (tb) and the mainnet (bc1) format given by the same mnemonic and HD path starting from m/86'/0'/0'/0. The chrome extensions for OKXWeb3 and Unisats

Reading some scratches from the given doc that could be helpful..

The actual implementations from okx is in here as described. Now I want to make this code base a python version..

The difference maybe the actual mentioned in here

const OPS = bscript.OPS;
const TAPROOT_WITNESS_VERSION = 0x01;
const ANNEX_PREFIX = 0x50;

Hi,
I made a test using the "typical" 12-word mnemonic abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about with OKX, Unisats and bip_utils.
They all generated the same Taproot address bc1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxqkedrcr for that mnemonic, so I don't understand why you saw a difference.

Screenshot 2024-02-09 113411 Screenshot 2024-02-09 113703 Screenshot 2024-02-09 113526

I see that changes coming.. maybe they have fixed the error already.

Ok, maybe it was a bug