Skip to content

Commit

Permalink
main
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtnetwork committed Sep 27, 2023
1 parent f1d53ff commit 8d1bd1b
Show file tree
Hide file tree
Showing 16 changed files with 26 additions and 111 deletions.
89 changes: 1 addition & 88 deletions address/core.go
Original file line number Diff line number Diff line change
@@ -1,91 +1,4 @@
// Package address provides utilities for working with Bitcoin address types.
//
// Bitcoin uses different address types, such as Pay-to-Public-Key-Hash (P2PKH),
// Pay-to-Script-Hash (P2SH), and Segregated Witness (SegWit) addresses. This package
// offers functions for creating, parsing, and validating addresses of these types.
//
// Usage:
// - Use the functions in this package to generate Bitcoin addresses.
// - Parse Bitcoin addresses to extract information.
// - Validate Bitcoin addresses to ensure they adhere to the correct format.
// - Create address from scripts p2wsh, p2tr, tapleaf, ....
//
// Example:
// package main
//
// import (
// "fmt"
// "github.com/mrtnetwork/bitcoin/address"
// )
//
// func main() {
// P2PKH ADDRESS
// address in testnet: myVMJgRi6arv4hLbeUcJYKUJWmFnpjtVme
// address in mainnet: 1JyQ1dLjHZRfHaryvudviQFyemf5vjbmUf
// exampleAddr1, _ := address.P2PKHAddressFromAddress("myVMJgRi6arv4hLbeUcJYKUJWmFnpjtVme")
// fmt.Println("address in testnet: ", exampleAddr1.Show(address.TestnetNetwork))
// fmt.Println("address in mainnet: ", exampleAddr1.Show(address.MainnetNetwork))

// P2TR ADDRESS
// address in testnet: tb1pyhmqwlcrws4dxcgalt4mrffgnys879vs59xf6sve4hazyvmhecxq3e6sc0
// address in mainnet: bc1pyhmqwlcrws4dxcgalt4mrffgnys879vs59xf6sve4hazyvmhecxqx3vlzq
// exampleAddr2, _ := address.P2TRAddressFromAddress("tb1pyhmqwlcrws4dxcgalt4mrffgnys879vs59xf6sve4hazyvmhecxq3e6sc0")
// fmt.Println("address in testnet: ", exampleAddr2.Show(address.TestnetNetwork))
// fmt.Println("address in mainnet: ", exampleAddr2.Show(address.MainnetNetwork))

// P2SH(P2PKH) ADDRESS
// address in testnet: 2N2yqygBJRvDzLzvPe91qKfSYnK5utGckJX
// address in mainnet: 3BRduwFGpTie9DHqy1PxhiTHZxsk7jpr9x
// exampleAddr3, _ := address.P2SHAddressFromAddress("2N2yqygBJRvDzLzvPe91qKfSYnK5utGckJX", address.P2PKHInP2SH)
// fmt.Println("address in testnet: ", exampleAddr3.Show(address.TestnetNetwork))
// fmt.Println("address in mainnet: ", exampleAddr3.Show(address.MainnetNetwork))

// P2PKH ADDRESS
// address in testnet: mzUzciYUGsNxLCaaHwou27F4RbnDTzKomV
// address in mainnet: 1Ky3KfTVTqwhZ66xaNqXCC2jZcBWZD6ppQ
// exampleAddr4, _ := address.P2PKHAddressFromAddress("mzUzciYUGsNxLCaaHwou27F4RbnDTzKomV")
// fmt.Println("address in testnet: ", exampleAddr4.Show(address.TestnetNetwork))
// fmt.Println("address in mainnet: ", exampleAddr4.Show(address.MainnetNetwork))

// P2SH(P2PKH) ADDRESS
// address in testnet: 2MzibgEeJYCN8mjJsZTg79AH7au4PCkHXHo
// address in mainnet: 39APcViGvjrnZwgKtL4EXDHrNYrDT9YuCQ
// exampleAddr5, _ := address.P2SHAddressFromAddress("2MzibgEeJYCN8mjJsZTg79AH7au4PCkHXHo", address.P2PKHInP2SH)
// fmt.Println("address in testnet: ", exampleAddr5.Show(address.TestnetNetwork))
// fmt.Println("address in mainnet: ", exampleAddr5.Show(address.MainnetNetwork))

// P2SH(P2WSH) ADDRESS
// address in testnet: 2N7bNV1WPwCVHfoqqRhvtmbAfktazfjHEW2
// address in mainnet: 3G3ARGaNKjywU2DHkaK29eBQYYNppD2xDE
// exampleAddr6, _ := address.P2SHAddressFromAddress("2N7bNV1WPwCVHfoqqRhvtmbAfktazfjHEW2", address.P2WSHInP2SH)
// fmt.Println("address in testnet: ", exampleAddr6.Show(address.TestnetNetwork))
// fmt.Println("address in mainnet: ", exampleAddr6.Show(address.MainnetNetwork))

// P2SH(P2WPKH) ADDRESS
// address in testnet: 2N38S8G9q6qyEjPWmicqxrVwjq4QiTbcyf4
// address in mainnet: 3BaE4XDoVPTtXbtE3VE6EYxUciCYd5rspb
// exampleAddr7, _ := address.P2SHAddressFromAddress("2N38S8G9q6qyEjPWmicqxrVwjq4QiTbcyf4", address.P2WPKHInP2SH)
// fmt.Println("address in testnet: ", exampleAddr7.Show(address.TestnetNetwork))
// fmt.Println("address in mainnet: ", exampleAddr7.Show(address.MainnetNetwork))

// P2SH(P2PK) ADDRESS
// address in testnet: 2MugsNcgzLJ1HosnZyC2CfZVmgbMPK1XubR
// address in mainnet: 348fJskxiqVwc6A2J4QL3cWWUF9DbWjTni
// exampleAddr8, _ := address.P2SHAddressFromAddress("2MugsNcgzLJ1HosnZyC2CfZVmgbMPK1XubR", address.P2PKInP2SH)
// fmt.Println("address in testnet: ", exampleAddr8.Show(address.TestnetNetwork))
// fmt.Println("address in mainnet: ", exampleAddr8.Show(address.MainnetNetwork))

// P2WPKH ADDRESS
// address in testnet: tb1q6q9halaazasd42gzsc2cvv5xls295w7kawkhxy
// address in mainnet: bc1q6q9halaazasd42gzsc2cvv5xls295w7khgdyah
// exampleAddr9, _ := address.P2WPKHAddresssFromAddress("tb1q6q9halaazasd42gzsc2cvv5xls295w7kawkhxy")
// fmt.Println("address in testnet: ", exampleAddr9.Show(address.TestnetNetwork))
// fmt.Println("address in mainnet: ", exampleAddr9.Show(address.MainnetNetwork))
// }
//
// This package aims to simplify Bitcoin address handling and make it easier to work
// with different Bitcoin address formats.

// Implementation of various Bitcoin address types, including P2PKH, P2SH, and SegWit
package address

import "github.com/mrtnetwork/bitcoin/scripts"
Expand Down
5 changes: 3 additions & 2 deletions base58/base58.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// / Base58 and base58Check implement
// Base58 and base58Check implement
package base58

import (
"bytes"
"fmt"
"github.com/mrtnetwork/bitcoin/digest"
"math/big"

"github.com/mrtnetwork/bitcoin/digest"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion bech32/bech32.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Reference implementation for Bech32/Bech32m and segwit addresses.
// Bech32 implementation for Bitcoin addresses.
package bech32

import (
Expand Down
9 changes: 1 addition & 8 deletions bip39/bip39.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
// Package bip39_example demonstrates the usage of the bip39 package to work with BIP-39 mnemonic phrases,
// entropy generation, and mnemonic conversion. BIP-39 is a widely used standard for creating human-readable
// representations of cryptographic keys.
//
// This example script showcases how to generate a new BIP-39 mnemonic, derive its entropy, and convert it back
// to a mnemonic. It also includes error handling and helpful comments to guide you through the process.
//
// For more information on BIP-39, refer to the official specification: https://github.com/github.com/mrtnetwork/bitcoin/bips/blob/master/bip-0039.mediawiki
// "BIP39 multi-language support implementation for mnemonic phrases.

package bip39

Expand Down
1 change: 1 addition & 0 deletions constant/constant.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Bitcoin's op codes and constants
package constant

// Bitcoin's op codes. Complete list at: https://en.bitcoin.it/wiki/Script
Expand Down
1 change: 1 addition & 0 deletions digest/digest.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Implementation of Bitcoin-specific hash functions, including SHA-256, RIPEMD-160 (Hash160), and TaggedHash.
package digest

import (
Expand Down
1 change: 1 addition & 0 deletions ecc/ecc.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Implementation of Bitcoin signing algorithms (ECDSA, Schnorr)
package ecc

// Copyright 2010 The Go Authors. All rights reserved.
Expand Down
1 change: 1 addition & 0 deletions formating/bitcoin_op.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Tools for handling byte manipulation, number encoding, and string conversion in the context of Bitcoin.
package formating

import (
Expand Down
8 changes: 5 additions & 3 deletions hd_wallet/hd_wallet.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
// Implementation of Hierarchical Deterministic (HD) wallet functionality following the BIP32 standard for Bitcoin and other cryptocurrencies
package hdwallet

import (
"bytes"
"encoding/binary"
"fmt"
"regexp"
"strconv"
"strings"

"github.com/mrtnetwork/bitcoin/address"
"github.com/mrtnetwork/bitcoin/base58"
"github.com/mrtnetwork/bitcoin/bip39"
"github.com/mrtnetwork/bitcoin/digest"
"github.com/mrtnetwork/bitcoin/ecc"
"github.com/mrtnetwork/bitcoin/formating"
"github.com/mrtnetwork/bitcoin/keypair"
"regexp"
"strconv"
"strings"
)

// HdWallet represents an HD Wallet.
Expand Down
1 change: 1 addition & 0 deletions keypair/private_key.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// keypair management for private and public keys.
package keypair

import (
Expand Down
1 change: 1 addition & 0 deletions keypair/public_key.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// keypair management for private and public keys.
package keypair

import (
Expand Down
10 changes: 2 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
// Package main is the entry point for your project and manages the overall
// control flow. It relies on several sub-packages for specific functionality.
// The main Bitcoin package does not have any methods or operations.
// Please refer to the sub-packages for documentation..
package main

// The main Bitcoin package does not have any methods or operations.
// Please refer to the sub-packages for documentation.
func main() {

}

// The main Bitcoin package does not have any methods or operations.
// Please refer to the sub-packages for documentation.
func ExplaneDoc() {

}
4 changes: 3 additions & 1 deletion provider/api_config.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// access BlockCypher and Mempool APIs for fetching UTXos, transaction data, network fees, and sending transactions in the Bitcoin network
package provider

import (
"github.com/mrtnetwork/bitcoin/address"
"strings"

"github.com/mrtnetwork/bitcoin/address"
)

type APIType int
Expand Down
1 change: 1 addition & 0 deletions scripts/script.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Implementation of Bitcoin script handling, transaction creation, and Bitcoin script features.
package scripts

import (
Expand Down
2 changes: 2 additions & 0 deletions secret_wallet/secret_wallet.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Implementation of the Web3 Secret Storage Definition to protect private keys.
package secretwallet

import (
Expand All @@ -7,6 +8,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"

"github.com/mrtnetwork/bitcoin/digest"
"github.com/mrtnetwork/bitcoin/formating"
"github.com/mrtnetwork/bitcoin/uuid"
Expand Down
1 change: 1 addition & 0 deletions uuid/uuid.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Implementation of a Universally Unique Identifier (UUID) generator
package uuid

import (
Expand Down

0 comments on commit 8d1bd1b

Please sign in to comment.