generated from bsv-blockchain/go-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.go
More file actions
32 lines (26 loc) · 962 Bytes
/
example.go
File metadata and controls
32 lines (26 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Package examples provides example code for various functionalities.
package examples
import (
"fmt"
"os"
"github.com/bsv-blockchain/go-wire"
chaincfg "github.com/bsv-blockchain/go-chaincfg"
)
// ExampleIsPubKeyHashAddrID demonstrates how to verify the legacy public key hash
// (P2PKH) address identifier bytes for a specific Bitcoin SV network.
//
// The helper reports whether the provided identifier is valid for the supplied
// network magic value. This is useful when parsing external configuration or
// performing sanity checks on user-supplied address metadata.
func ExampleIsPubKeyHashAddrID() {
write := func(value bool) {
if _, err := fmt.Fprintf(os.Stdout, "%t\n", value); err != nil {
panic(err)
}
}
write(chaincfg.IsPubKeyHashAddrID(wire.MainNet, chaincfg.MainNetParams.LegacyPubKeyHashAddrID))
write(chaincfg.IsPubKeyHashAddrID(wire.MainNet, chaincfg.TestNetParams.LegacyPubKeyHashAddrID))
// Output:
// true
// false
}