Skip to content

Commit 8d1bd1b

Browse files
committed
main
1 parent f1d53ff commit 8d1bd1b

File tree

16 files changed

+26
-111
lines changed

16 files changed

+26
-111
lines changed

address/core.go

Lines changed: 1 addition & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,4 @@
1-
// Package address provides utilities for working with Bitcoin address types.
2-
//
3-
// Bitcoin uses different address types, such as Pay-to-Public-Key-Hash (P2PKH),
4-
// Pay-to-Script-Hash (P2SH), and Segregated Witness (SegWit) addresses. This package
5-
// offers functions for creating, parsing, and validating addresses of these types.
6-
//
7-
// Usage:
8-
// - Use the functions in this package to generate Bitcoin addresses.
9-
// - Parse Bitcoin addresses to extract information.
10-
// - Validate Bitcoin addresses to ensure they adhere to the correct format.
11-
// - Create address from scripts p2wsh, p2tr, tapleaf, ....
12-
//
13-
// Example:
14-
// package main
15-
//
16-
// import (
17-
// "fmt"
18-
// "github.com/mrtnetwork/bitcoin/address"
19-
// )
20-
//
21-
// func main() {
22-
// P2PKH ADDRESS
23-
// address in testnet: myVMJgRi6arv4hLbeUcJYKUJWmFnpjtVme
24-
// address in mainnet: 1JyQ1dLjHZRfHaryvudviQFyemf5vjbmUf
25-
// exampleAddr1, _ := address.P2PKHAddressFromAddress("myVMJgRi6arv4hLbeUcJYKUJWmFnpjtVme")
26-
// fmt.Println("address in testnet: ", exampleAddr1.Show(address.TestnetNetwork))
27-
// fmt.Println("address in mainnet: ", exampleAddr1.Show(address.MainnetNetwork))
28-
29-
// P2TR ADDRESS
30-
// address in testnet: tb1pyhmqwlcrws4dxcgalt4mrffgnys879vs59xf6sve4hazyvmhecxq3e6sc0
31-
// address in mainnet: bc1pyhmqwlcrws4dxcgalt4mrffgnys879vs59xf6sve4hazyvmhecxqx3vlzq
32-
// exampleAddr2, _ := address.P2TRAddressFromAddress("tb1pyhmqwlcrws4dxcgalt4mrffgnys879vs59xf6sve4hazyvmhecxq3e6sc0")
33-
// fmt.Println("address in testnet: ", exampleAddr2.Show(address.TestnetNetwork))
34-
// fmt.Println("address in mainnet: ", exampleAddr2.Show(address.MainnetNetwork))
35-
36-
// P2SH(P2PKH) ADDRESS
37-
// address in testnet: 2N2yqygBJRvDzLzvPe91qKfSYnK5utGckJX
38-
// address in mainnet: 3BRduwFGpTie9DHqy1PxhiTHZxsk7jpr9x
39-
// exampleAddr3, _ := address.P2SHAddressFromAddress("2N2yqygBJRvDzLzvPe91qKfSYnK5utGckJX", address.P2PKHInP2SH)
40-
// fmt.Println("address in testnet: ", exampleAddr3.Show(address.TestnetNetwork))
41-
// fmt.Println("address in mainnet: ", exampleAddr3.Show(address.MainnetNetwork))
42-
43-
// P2PKH ADDRESS
44-
// address in testnet: mzUzciYUGsNxLCaaHwou27F4RbnDTzKomV
45-
// address in mainnet: 1Ky3KfTVTqwhZ66xaNqXCC2jZcBWZD6ppQ
46-
// exampleAddr4, _ := address.P2PKHAddressFromAddress("mzUzciYUGsNxLCaaHwou27F4RbnDTzKomV")
47-
// fmt.Println("address in testnet: ", exampleAddr4.Show(address.TestnetNetwork))
48-
// fmt.Println("address in mainnet: ", exampleAddr4.Show(address.MainnetNetwork))
49-
50-
// P2SH(P2PKH) ADDRESS
51-
// address in testnet: 2MzibgEeJYCN8mjJsZTg79AH7au4PCkHXHo
52-
// address in mainnet: 39APcViGvjrnZwgKtL4EXDHrNYrDT9YuCQ
53-
// exampleAddr5, _ := address.P2SHAddressFromAddress("2MzibgEeJYCN8mjJsZTg79AH7au4PCkHXHo", address.P2PKHInP2SH)
54-
// fmt.Println("address in testnet: ", exampleAddr5.Show(address.TestnetNetwork))
55-
// fmt.Println("address in mainnet: ", exampleAddr5.Show(address.MainnetNetwork))
56-
57-
// P2SH(P2WSH) ADDRESS
58-
// address in testnet: 2N7bNV1WPwCVHfoqqRhvtmbAfktazfjHEW2
59-
// address in mainnet: 3G3ARGaNKjywU2DHkaK29eBQYYNppD2xDE
60-
// exampleAddr6, _ := address.P2SHAddressFromAddress("2N7bNV1WPwCVHfoqqRhvtmbAfktazfjHEW2", address.P2WSHInP2SH)
61-
// fmt.Println("address in testnet: ", exampleAddr6.Show(address.TestnetNetwork))
62-
// fmt.Println("address in mainnet: ", exampleAddr6.Show(address.MainnetNetwork))
63-
64-
// P2SH(P2WPKH) ADDRESS
65-
// address in testnet: 2N38S8G9q6qyEjPWmicqxrVwjq4QiTbcyf4
66-
// address in mainnet: 3BaE4XDoVPTtXbtE3VE6EYxUciCYd5rspb
67-
// exampleAddr7, _ := address.P2SHAddressFromAddress("2N38S8G9q6qyEjPWmicqxrVwjq4QiTbcyf4", address.P2WPKHInP2SH)
68-
// fmt.Println("address in testnet: ", exampleAddr7.Show(address.TestnetNetwork))
69-
// fmt.Println("address in mainnet: ", exampleAddr7.Show(address.MainnetNetwork))
70-
71-
// P2SH(P2PK) ADDRESS
72-
// address in testnet: 2MugsNcgzLJ1HosnZyC2CfZVmgbMPK1XubR
73-
// address in mainnet: 348fJskxiqVwc6A2J4QL3cWWUF9DbWjTni
74-
// exampleAddr8, _ := address.P2SHAddressFromAddress("2MugsNcgzLJ1HosnZyC2CfZVmgbMPK1XubR", address.P2PKInP2SH)
75-
// fmt.Println("address in testnet: ", exampleAddr8.Show(address.TestnetNetwork))
76-
// fmt.Println("address in mainnet: ", exampleAddr8.Show(address.MainnetNetwork))
77-
78-
// P2WPKH ADDRESS
79-
// address in testnet: tb1q6q9halaazasd42gzsc2cvv5xls295w7kawkhxy
80-
// address in mainnet: bc1q6q9halaazasd42gzsc2cvv5xls295w7khgdyah
81-
// exampleAddr9, _ := address.P2WPKHAddresssFromAddress("tb1q6q9halaazasd42gzsc2cvv5xls295w7kawkhxy")
82-
// fmt.Println("address in testnet: ", exampleAddr9.Show(address.TestnetNetwork))
83-
// fmt.Println("address in mainnet: ", exampleAddr9.Show(address.MainnetNetwork))
84-
// }
85-
//
86-
// This package aims to simplify Bitcoin address handling and make it easier to work
87-
// with different Bitcoin address formats.
88-
1+
// Implementation of various Bitcoin address types, including P2PKH, P2SH, and SegWit
892
package address
903

914
import "github.com/mrtnetwork/bitcoin/scripts"

base58/base58.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
// / Base58 and base58Check implement
1+
// Base58 and base58Check implement
22
package base58
33

44
import (
55
"bytes"
66
"fmt"
7-
"github.com/mrtnetwork/bitcoin/digest"
87
"math/big"
8+
9+
"github.com/mrtnetwork/bitcoin/digest"
910
)
1011

1112
const (

bech32/bech32.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Reference implementation for Bech32/Bech32m and segwit addresses.
1+
// Bech32 implementation for Bitcoin addresses.
22
package bech32
33

44
import (

bip39/bip39.go

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

103
package bip39
114

constant/constant.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Bitcoin's op codes and constants
12
package constant
23

34
// Bitcoin's op codes. Complete list at: https://en.bitcoin.it/wiki/Script

digest/digest.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Implementation of Bitcoin-specific hash functions, including SHA-256, RIPEMD-160 (Hash160), and TaggedHash.
12
package digest
23

34
import (

ecc/ecc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Implementation of Bitcoin signing algorithms (ECDSA, Schnorr)
12
package ecc
23

34
// Copyright 2010 The Go Authors. All rights reserved.

formating/bitcoin_op.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Tools for handling byte manipulation, number encoding, and string conversion in the context of Bitcoin.
12
package formating
23

34
import (

hd_wallet/hd_wallet.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1+
// Implementation of Hierarchical Deterministic (HD) wallet functionality following the BIP32 standard for Bitcoin and other cryptocurrencies
12
package hdwallet
23

34
import (
45
"bytes"
56
"encoding/binary"
67
"fmt"
8+
"regexp"
9+
"strconv"
10+
"strings"
11+
712
"github.com/mrtnetwork/bitcoin/address"
813
"github.com/mrtnetwork/bitcoin/base58"
914
"github.com/mrtnetwork/bitcoin/bip39"
1015
"github.com/mrtnetwork/bitcoin/digest"
1116
"github.com/mrtnetwork/bitcoin/ecc"
1217
"github.com/mrtnetwork/bitcoin/formating"
1318
"github.com/mrtnetwork/bitcoin/keypair"
14-
"regexp"
15-
"strconv"
16-
"strings"
1719
)
1820

1921
// HdWallet represents an HD Wallet.

keypair/private_key.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// keypair management for private and public keys.
12
package keypair
23

34
import (

0 commit comments

Comments
 (0)