BlockChain區塊鏈
  • 本書簡介
  • 區塊鏈運作原理
  • Bitcoin介紹
    • 簡介
    • Bitcoin其他知識
  • Bitcoin原理與實作
  • BitcoinJS
    • BTC 地址格式種類
    • 從 Mnemonic 轉為地址
  • Serverless 架構實作
  • Docker常用指令
  • ethereum初探
    • ethereum歷史
    • EVM
  • ethereum PoS 節點架設
  • ethereum(Docker)
  • ethereum(Geth)
    • Parity
  • ethereum(智能合約)
    • 合約測試 Unit Test
    • DAO
    • 可升級合約
    • 使用合約進行 multiswap
    • 合約安全
    • 開發工具
    • Hardhat 教學
      • Hardhat 寫測試
    • ERC-721 範例
      • 白名單機制
    • OpenZeppelin 合約 library
    • Truffle
    • 合約部屬
    • solidity 教學
  • ethereum(Dapp)
    • 相關 SDK
    • Multicall
    • Ethers.js 使用
    • Remix IDE
    • web3.js 使用
    • 在網頁上使用 web3 並操作區塊鏈
      • solidity筆記
  • Hyperledger Fabric
  • blockchainDB
  • 挖礦程式使用教學
    • 門羅幣/Monero (XMR)
  • Bitfinex API 使用
  • FTX API
  • CCXT 通用交易所 API
  • Solana 教學
  • Ethereum BigQuery
  • The Graph
    • yaml 定義
    • mapping 語法
    • Schema 定義
    • Query 範例
    • Unit test
  • DeFi 筆記
    • MEV 相關
    • Dex 聚合
    • Yearn
    • Curve
    • Uniswap
      • Swap 互動
    • AAVE、Compound
      • Compound 原理
      • AAVE 合約開發
Powered by GitBook
On this page

Was this helpful?

  1. BitcoinJS

BTC 地址格式種類

地址格式種類

最早的地址格式為:P2PK 但已經沒在用,目前 p2pkh 為主要,佔了 43%

主要有以下幾種

P2PKH,
P2WPKH,
P2TR,
P2SH_P2WPKH,
P2WSH,
P2SH

常見地址分辨

const p2pkh_data = {
  mainnet_address: '1...',
  testnet_address: 'm...' // 'm' or 'n' on testnet or regtest network
};

const p2wpkh_data = {
  mainnet_address: 'bc1q...', // Length of 42 (SegWit variant of P2PKH)
  testnet_address: 'tb1q...'
};

const p2sh_data = {
  mainnet_address: '3...', // Length of 34
  testnet_address: '2...'
};

const p2wsh_data = {
  mainnet_address: 'bc1q...', // Length of 62 (SegWit variant of P2SH)
}

const p2tr_data = {
  mainnet_address: 'bc1p...',
  testnet_address: 'tb1p...'
};

Convert public key to bitcoin payment object and address

PreviousBitcoinJSNext從 Mnemonic 轉為地址

Last updated 11 months ago

Was this helpful?

https://github.com/unisat-wallet/wallet-sdk/blob/master/src/address/index.ts
https://unchained.com/blog/bitcoin-address-types-compared/