mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
[NOD-514] Change dagcoin to kaspa, dagtest to kaspatest, dagreg to kaspareg, and dagsim to kaspasim (#538)
* [NOD-514] Change dagcoin to kaspa, dagtest to kaspatest, etc. * [NOD-514] Remove no-longer-relevant link in doc.
This commit is contained in:
parent
3a12fe9b1d
commit
c1f7ae72e0
@ -674,7 +674,7 @@ func TestCheckTransactionSanity(t *testing.T) {
|
||||
&txSubnetworkData{subnetworkid.SubnetworkIDCoinbase, 0, make([]byte, MaxCoinbasePayloadLen+1)},
|
||||
nil,
|
||||
ruleError(ErrBadCoinbasePayloadLen, "")},
|
||||
{"non-zero gas in DAGCoin", 1, 1, 0,
|
||||
{"non-zero gas in Kaspa", 1, 1, 0,
|
||||
*subnetworkid.SubnetworkIDNative,
|
||||
&txSubnetworkData{subnetworkid.SubnetworkIDNative, 1, []byte{}},
|
||||
nil,
|
||||
@ -684,7 +684,7 @@ func TestCheckTransactionSanity(t *testing.T) {
|
||||
&txSubnetworkData{subnetworkid.SubnetworkIDNative, 1, []byte{}},
|
||||
nil,
|
||||
ruleError(ErrInvalidGas, "")},
|
||||
{"non-zero payload in DAGCoin", 1, 1, 0,
|
||||
{"non-zero payload in Kaspa", 1, 1, 0,
|
||||
*subnetworkid.SubnetworkIDNative,
|
||||
&txSubnetworkData{subnetworkid.SubnetworkIDNative, 0, []byte{1}},
|
||||
nil,
|
||||
|
@ -238,7 +238,7 @@ var MainNetParams = Params{
|
||||
AcceptUnroutable: false,
|
||||
|
||||
// Human-readable part for Bech32 encoded addresses
|
||||
Prefix: util.Bech32PrefixDAGCoin,
|
||||
Prefix: util.Bech32PrefixKaspa,
|
||||
|
||||
// Address encoding magics
|
||||
PrivateKeyID: 0x80, // starts with 5 (uncompressed) or K (compressed)
|
||||
@ -299,7 +299,7 @@ var RegressionNetParams = Params{
|
||||
AcceptUnroutable: false,
|
||||
|
||||
// Human-readable part for Bech32 encoded addresses
|
||||
Prefix: util.Bech32PrefixDAGReg,
|
||||
Prefix: util.Bech32PrefixKaspaReg,
|
||||
|
||||
// Address encoding magics
|
||||
PrivateKeyID: 0xef, // starts with 9 (uncompressed) or c (compressed)
|
||||
@ -358,7 +358,7 @@ var TestNetParams = Params{
|
||||
AcceptUnroutable: false,
|
||||
|
||||
// Human-readable part for Bech32 encoded addresses
|
||||
Prefix: util.Bech32PrefixDAGTest,
|
||||
Prefix: util.Bech32PrefixKaspaTest,
|
||||
|
||||
// Address encoding magics
|
||||
PrivateKeyID: 0xef, // starts with 9 (uncompressed) or c (compressed)
|
||||
@ -424,7 +424,7 @@ var SimNetParams = Params{
|
||||
|
||||
PrivateKeyID: 0x64, // starts with 4 (uncompressed) or F (compressed)
|
||||
// Human-readable part for Bech32 encoded addresses
|
||||
Prefix: util.Bech32PrefixDAGSim,
|
||||
Prefix: util.Bech32PrefixKaspaSim,
|
||||
|
||||
// BIP32 hierarchical deterministic extended key magics
|
||||
HDKeyIDPair: hdkeychain.HDKeyPairSimNet,
|
||||
@ -480,7 +480,7 @@ var DevNetParams = Params{
|
||||
AcceptUnroutable: true,
|
||||
|
||||
// Human-readable part for Bech32 encoded addresses
|
||||
Prefix: util.Bech32PrefixDAGTest,
|
||||
Prefix: util.Bech32PrefixKaspaTest,
|
||||
|
||||
// Address encoding magics
|
||||
PrivateKeyID: 0xef, // starts with 9 (uncompressed) or c (compressed)
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
// Node repesents a node in the DAGCoin network
|
||||
// Node repesents a node in the Kaspa network
|
||||
type Node struct {
|
||||
Addr *wire.NetAddress
|
||||
Services wire.ServiceFlag
|
||||
|
@ -630,7 +630,7 @@ func TestProcessTransaction(t *testing.T) {
|
||||
|
||||
addrHash := [20]byte{0x01}
|
||||
addr, err := util.NewAddressPubKeyHash(addrHash[:],
|
||||
util.Bech32PrefixDAGTest)
|
||||
util.Bech32PrefixKaspaTest)
|
||||
if err != nil {
|
||||
t.Fatalf("NewAddressPubKeyHash: unexpected error: %v", err)
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ func TestCheckTransactionStandard(t *testing.T) {
|
||||
Sequence: wire.MaxTxInSequenceNum,
|
||||
}
|
||||
addrHash := [20]byte{0x01}
|
||||
addr, err := util.NewAddressPubKeyHash(addrHash[:], util.Bech32PrefixDAGTest)
|
||||
addr, err := util.NewAddressPubKeyHash(addrHash[:], util.Bech32PrefixKaspaTest)
|
||||
if err != nil {
|
||||
t.Fatalf("NewAddressPubKeyHash: unexpected error: %v", err)
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ func ExamplePayToAddrScript() {
|
||||
// which is useful to ensure the accuracy of the address and determine
|
||||
// the address type. It is also required for the upcoming call to
|
||||
// PayToAddrScript.
|
||||
addressStr := "dagcoin:qqfgqp8l9l90zwetj84k2jcac2m8falvvy9uastr55"
|
||||
address, err := util.DecodeAddress(addressStr, util.Bech32PrefixDAGCoin)
|
||||
addressStr := "kaspa:qqfgqp8l9l90zwetj84k2jcac2m8falvvyy8xjtnhd"
|
||||
address, err := util.DecodeAddress(addressStr, util.Bech32PrefixKaspa)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
@ -71,5 +71,5 @@ func ExampleExtractScriptPubKeyAddress() {
|
||||
|
||||
// Output:
|
||||
// Script Class: pubkeyhash
|
||||
// Address: dagcoin:qqfgqp8l9l90zwetj84k2jcac2m8falvvy9uastr55
|
||||
// Address: kaspa:qqfgqp8l9l90zwetj84k2jcac2m8falvvyy8xjtnhd
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
pk := (*ecc.PublicKey)(&key.PublicKey).
|
||||
SerializeUncompressed()
|
||||
address, err := util.NewAddressPubKeyHash(
|
||||
util.Hash160(pk), util.Bech32PrefixDAGTest)
|
||||
util.Hash160(pk), util.Bech32PrefixKaspaTest)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make address for %s: %v",
|
||||
msg, err)
|
||||
@ -186,7 +186,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
pk := (*ecc.PublicKey)(&key.PublicKey).
|
||||
SerializeUncompressed()
|
||||
address, err := util.NewAddressPubKeyHash(
|
||||
util.Hash160(pk), util.Bech32PrefixDAGTest)
|
||||
util.Hash160(pk), util.Bech32PrefixKaspaTest)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make address for %s: %v",
|
||||
msg, err)
|
||||
@ -247,7 +247,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
pk := (*ecc.PublicKey)(&key.PublicKey).
|
||||
SerializeCompressed()
|
||||
address, err := util.NewAddressPubKeyHash(
|
||||
util.Hash160(pk), util.Bech32PrefixDAGTest)
|
||||
util.Hash160(pk), util.Bech32PrefixKaspaTest)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make address for %s: %v",
|
||||
msg, err)
|
||||
@ -285,7 +285,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
pk := (*ecc.PublicKey)(&key.PublicKey).
|
||||
SerializeCompressed()
|
||||
address, err := util.NewAddressPubKeyHash(
|
||||
util.Hash160(pk), util.Bech32PrefixDAGTest)
|
||||
util.Hash160(pk), util.Bech32PrefixKaspaTest)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make address for %s: %v",
|
||||
msg, err)
|
||||
@ -346,7 +346,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
pk := (*ecc.PublicKey)(&key.PublicKey).
|
||||
SerializeUncompressed()
|
||||
address, err := util.NewAddressPubKeyHash(
|
||||
util.Hash160(pk), util.Bech32PrefixDAGTest)
|
||||
util.Hash160(pk), util.Bech32PrefixKaspaTest)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make address for %s: %v",
|
||||
msg, err)
|
||||
@ -361,7 +361,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
}
|
||||
|
||||
scriptAddr, err := util.NewAddressScriptHash(
|
||||
scriptPubKey, util.Bech32PrefixDAGTest)
|
||||
scriptPubKey, util.Bech32PrefixKaspaTest)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make p2sh addr for %s: %v",
|
||||
msg, err)
|
||||
@ -402,7 +402,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
pk := (*ecc.PublicKey)(&key.PublicKey).
|
||||
SerializeUncompressed()
|
||||
address, err := util.NewAddressPubKeyHash(
|
||||
util.Hash160(pk), util.Bech32PrefixDAGTest)
|
||||
util.Hash160(pk), util.Bech32PrefixKaspaTest)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make address for %s: %v",
|
||||
msg, err)
|
||||
@ -417,7 +417,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
}
|
||||
|
||||
scriptAddr, err := util.NewAddressScriptHash(
|
||||
scriptPubKey, util.Bech32PrefixDAGTest)
|
||||
scriptPubKey, util.Bech32PrefixKaspaTest)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make p2sh addr for %s: %v",
|
||||
msg, err)
|
||||
@ -484,7 +484,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
pk := (*ecc.PublicKey)(&key.PublicKey).
|
||||
SerializeCompressed()
|
||||
address, err := util.NewAddressPubKeyHash(
|
||||
util.Hash160(pk), util.Bech32PrefixDAGTest)
|
||||
util.Hash160(pk), util.Bech32PrefixKaspaTest)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make address for %s: %v",
|
||||
msg, err)
|
||||
@ -498,7 +498,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
}
|
||||
|
||||
scriptAddr, err := util.NewAddressScriptHash(
|
||||
scriptPubKey, util.Bech32PrefixDAGTest)
|
||||
scriptPubKey, util.Bech32PrefixKaspaTest)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make p2sh addr for %s: %v",
|
||||
msg, err)
|
||||
@ -540,7 +540,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
pk := (*ecc.PublicKey)(&key.PublicKey).
|
||||
SerializeCompressed()
|
||||
address, err := util.NewAddressPubKeyHash(
|
||||
util.Hash160(pk), util.Bech32PrefixDAGTest)
|
||||
util.Hash160(pk), util.Bech32PrefixKaspaTest)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make address for %s: %v",
|
||||
msg, err)
|
||||
@ -554,7 +554,7 @@ func TestSignTxOutput(t *testing.T) {
|
||||
}
|
||||
|
||||
scriptAddr, err := util.NewAddressScriptHash(
|
||||
scriptPubKey, util.Bech32PrefixDAGTest)
|
||||
scriptPubKey, util.Bech32PrefixKaspaTest)
|
||||
if err != nil {
|
||||
t.Errorf("failed to make p2sh addr for %s: %v",
|
||||
msg, err)
|
||||
|
@ -32,7 +32,7 @@ func mustParseShortForm(script string) []byte {
|
||||
// as a helper since the only way it can fail is if there is an error in the
|
||||
// test source code.
|
||||
func newAddressPubKeyHash(pkHash []byte) util.Address {
|
||||
addr, err := util.NewAddressPubKeyHash(pkHash, util.Bech32PrefixDAGCoin)
|
||||
addr, err := util.NewAddressPubKeyHash(pkHash, util.Bech32PrefixKaspa)
|
||||
if err != nil {
|
||||
panic("invalid public key hash in test source")
|
||||
}
|
||||
@ -46,7 +46,7 @@ func newAddressPubKeyHash(pkHash []byte) util.Address {
|
||||
// test source code.
|
||||
func newAddressScriptHash(scriptHash []byte) util.Address {
|
||||
addr, err := util.NewAddressScriptHashFromHash(scriptHash,
|
||||
util.Bech32PrefixDAGCoin)
|
||||
util.Bech32PrefixKaspa)
|
||||
if err != nil {
|
||||
panic("invalid script hash in test source")
|
||||
}
|
||||
@ -283,7 +283,7 @@ func TestPayToAddrScript(t *testing.T) {
|
||||
|
||||
// 1MirQ9bwyQcGVJPwKUgapu5ouK2E2Ey4gX
|
||||
p2pkhMain, err := util.NewAddressPubKeyHash(hexToBytes("e34cce70c86"+
|
||||
"373273efcc54ce7d2a491bb4a0e84"), util.Bech32PrefixDAGCoin)
|
||||
"373273efcc54ce7d2a491bb4a0e84"), util.Bech32PrefixKaspa)
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to create public key hash address: %v", err)
|
||||
}
|
||||
@ -291,7 +291,7 @@ func TestPayToAddrScript(t *testing.T) {
|
||||
// Taken from transaction:
|
||||
// b0539a45de13b3e0403909b8bd1a555b8cbe45fd4e3f3fda76f3a5f52835c29d
|
||||
p2shMain, _ := util.NewAddressScriptHashFromHash(hexToBytes("e8c300"+
|
||||
"c87986efa84c37c0519929019ef86eb5b4"), util.Bech32PrefixDAGCoin)
|
||||
"c87986efa84c37c0519929019ef86eb5b4"), util.Bech32PrefixKaspa)
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to create script hash address: %v", err)
|
||||
}
|
||||
|
@ -41,24 +41,24 @@ const (
|
||||
Bech32PrefixUnknown Bech32Prefix = iota
|
||||
|
||||
// Prefix for the main network.
|
||||
Bech32PrefixDAGCoin
|
||||
Bech32PrefixKaspa
|
||||
|
||||
// Prefix for the regression test network.
|
||||
Bech32PrefixDAGReg
|
||||
Bech32PrefixKaspaReg
|
||||
|
||||
// Prefix for the test network.
|
||||
Bech32PrefixDAGTest
|
||||
Bech32PrefixKaspaTest
|
||||
|
||||
// Prefix for the simulation network.
|
||||
Bech32PrefixDAGSim
|
||||
Bech32PrefixKaspaSim
|
||||
)
|
||||
|
||||
// Map from strings to Bech32 address prefix constants for parsing purposes.
|
||||
var stringsToBech32Prefixes = map[string]Bech32Prefix{
|
||||
"dagcoin": Bech32PrefixDAGCoin,
|
||||
"dagreg": Bech32PrefixDAGReg,
|
||||
"dagtest": Bech32PrefixDAGTest,
|
||||
"dagsim": Bech32PrefixDAGSim,
|
||||
"kaspa": Bech32PrefixKaspa,
|
||||
"kaspareg": Bech32PrefixKaspaReg,
|
||||
"kaspatest": Bech32PrefixKaspaTest,
|
||||
"kaspasim": Bech32PrefixKaspaSim,
|
||||
}
|
||||
|
||||
// ParsePrefix attempts to parse a Bech32 address prefix.
|
||||
|
@ -28,11 +28,11 @@ func TestAddresses(t *testing.T) {
|
||||
// Positive P2PKH tests.
|
||||
{
|
||||
name: "mainnet p2pkh",
|
||||
addr: "dagcoin:qr35ennsep3hxfe7lnz5ee7j5jgmkjswss74as46gy",
|
||||
encoded: "dagcoin:qr35ennsep3hxfe7lnz5ee7j5jgmkjswss74as46gy",
|
||||
addr: "kaspa:qr35ennsep3hxfe7lnz5ee7j5jgmkjswsslwxj42ta",
|
||||
encoded: "kaspa:qr35ennsep3hxfe7lnz5ee7j5jgmkjswsslwxj42ta",
|
||||
valid: true,
|
||||
result: util.TstAddressPubKeyHash(
|
||||
util.Bech32PrefixDAGCoin,
|
||||
util.Bech32PrefixKaspa,
|
||||
[ripemd160.Size]byte{
|
||||
0xe3, 0x4c, 0xce, 0x70, 0xc8, 0x63, 0x73, 0x27, 0x3e, 0xfc,
|
||||
0xc5, 0x4c, 0xe7, 0xd2, 0xa4, 0x91, 0xbb, 0x4a, 0x0e, 0x84}),
|
||||
@ -40,17 +40,17 @@ func TestAddresses(t *testing.T) {
|
||||
pkHash := []byte{
|
||||
0xe3, 0x4c, 0xce, 0x70, 0xc8, 0x63, 0x73, 0x27, 0x3e, 0xfc,
|
||||
0xc5, 0x4c, 0xe7, 0xd2, 0xa4, 0x91, 0xbb, 0x4a, 0x0e, 0x84}
|
||||
return util.NewAddressPubKeyHash(pkHash, util.Bech32PrefixDAGCoin)
|
||||
return util.NewAddressPubKeyHash(pkHash, util.Bech32PrefixKaspa)
|
||||
},
|
||||
prefix: util.Bech32PrefixDAGCoin,
|
||||
prefix: util.Bech32PrefixKaspa,
|
||||
},
|
||||
{
|
||||
name: "mainnet p2pkh 2",
|
||||
addr: "dagcoin:qq80qvqs0lfxuzmt7sz3909ze6camq9d4gwzqeljga",
|
||||
encoded: "dagcoin:qq80qvqs0lfxuzmt7sz3909ze6camq9d4gwzqeljga",
|
||||
addr: "kaspa:qq80qvqs0lfxuzmt7sz3909ze6camq9d4g0emmlzty",
|
||||
encoded: "kaspa:qq80qvqs0lfxuzmt7sz3909ze6camq9d4g0emmlzty",
|
||||
valid: true,
|
||||
result: util.TstAddressPubKeyHash(
|
||||
util.Bech32PrefixDAGCoin,
|
||||
util.Bech32PrefixKaspa,
|
||||
[ripemd160.Size]byte{
|
||||
0x0e, 0xf0, 0x30, 0x10, 0x7f, 0xd2, 0x6e, 0x0b, 0x6b, 0xf4,
|
||||
0x05, 0x12, 0xbc, 0xa2, 0xce, 0xb1, 0xdd, 0x80, 0xad, 0xaa}),
|
||||
@ -58,17 +58,17 @@ func TestAddresses(t *testing.T) {
|
||||
pkHash := []byte{
|
||||
0x0e, 0xf0, 0x30, 0x10, 0x7f, 0xd2, 0x6e, 0x0b, 0x6b, 0xf4,
|
||||
0x05, 0x12, 0xbc, 0xa2, 0xce, 0xb1, 0xdd, 0x80, 0xad, 0xaa}
|
||||
return util.NewAddressPubKeyHash(pkHash, util.Bech32PrefixDAGCoin)
|
||||
return util.NewAddressPubKeyHash(pkHash, util.Bech32PrefixKaspa)
|
||||
},
|
||||
prefix: util.Bech32PrefixDAGCoin,
|
||||
prefix: util.Bech32PrefixKaspa,
|
||||
},
|
||||
{
|
||||
name: "testnet p2pkh",
|
||||
addr: "dagtest:qputx94qseratdmjs0j395mq8u03er0x3ucluj5qam",
|
||||
encoded: "dagtest:qputx94qseratdmjs0j395mq8u03er0x3ucluj5qam",
|
||||
addr: "kaspatest:qputx94qseratdmjs0j395mq8u03er0x3u2xu3wvh9",
|
||||
encoded: "kaspatest:qputx94qseratdmjs0j395mq8u03er0x3u2xu3wvh9",
|
||||
valid: true,
|
||||
result: util.TstAddressPubKeyHash(
|
||||
util.Bech32PrefixDAGTest,
|
||||
util.Bech32PrefixKaspaTest,
|
||||
[ripemd160.Size]byte{
|
||||
0x78, 0xb3, 0x16, 0xa0, 0x86, 0x47, 0xd5, 0xb7, 0x72, 0x83,
|
||||
0xe5, 0x12, 0xd3, 0x60, 0x3f, 0x1f, 0x1c, 0x8d, 0xe6, 0x8f}),
|
||||
@ -76,9 +76,9 @@ func TestAddresses(t *testing.T) {
|
||||
pkHash := []byte{
|
||||
0x78, 0xb3, 0x16, 0xa0, 0x86, 0x47, 0xd5, 0xb7, 0x72, 0x83,
|
||||
0xe5, 0x12, 0xd3, 0x60, 0x3f, 0x1f, 0x1c, 0x8d, 0xe6, 0x8f}
|
||||
return util.NewAddressPubKeyHash(pkHash, util.Bech32PrefixDAGTest)
|
||||
return util.NewAddressPubKeyHash(pkHash, util.Bech32PrefixKaspaTest)
|
||||
},
|
||||
prefix: util.Bech32PrefixDAGTest,
|
||||
prefix: util.Bech32PrefixKaspaTest,
|
||||
},
|
||||
|
||||
// Negative P2PKH tests.
|
||||
@ -91,15 +91,15 @@ func TestAddresses(t *testing.T) {
|
||||
0x00, 0x0e, 0xf0, 0x30, 0x10, 0x7f, 0xd2, 0x6e, 0x0b, 0x6b,
|
||||
0xf4, 0x05, 0x12, 0xbc, 0xa2, 0xce, 0xb1, 0xdd, 0x80, 0xad,
|
||||
0xaa}
|
||||
return util.NewAddressPubKeyHash(pkHash, util.Bech32PrefixDAGCoin)
|
||||
return util.NewAddressPubKeyHash(pkHash, util.Bech32PrefixKaspa)
|
||||
},
|
||||
prefix: util.Bech32PrefixDAGCoin,
|
||||
prefix: util.Bech32PrefixKaspa,
|
||||
},
|
||||
{
|
||||
name: "p2pkh bad checksum",
|
||||
addr: "dagcoin:qr35ennsep3hxfe7lnz5ee7j5jgmkjswss74as46gx",
|
||||
addr: "kaspa:qr35ennsep3hxfe7lnz5ee7j5jgmkjswss74as46gx",
|
||||
valid: false,
|
||||
prefix: util.Bech32PrefixDAGCoin,
|
||||
prefix: util.Bech32PrefixKaspa,
|
||||
},
|
||||
|
||||
// Positive P2SH tests.
|
||||
@ -108,11 +108,11 @@ func TestAddresses(t *testing.T) {
|
||||
// output: 3c9018e8d5615c306d72397f8f5eef44308c98fb576a88e030c25456b4f3a7ac
|
||||
// input: 837dea37ddc8b1e3ce646f1a656e79bbd8cc7f558ac56a169626d649ebe2a3ba
|
||||
name: "mainnet p2sh",
|
||||
addr: "dagcoin:pruptvpkmxamee0f72sq40gm70wfr624zq8mc2ujcn",
|
||||
encoded: "dagcoin:pruptvpkmxamee0f72sq40gm70wfr624zq8mc2ujcn",
|
||||
addr: "kaspa:pruptvpkmxamee0f72sq40gm70wfr624zqxqrguzm2",
|
||||
encoded: "kaspa:pruptvpkmxamee0f72sq40gm70wfr624zqxqrguzm2",
|
||||
valid: true,
|
||||
result: util.TstAddressScriptHash(
|
||||
util.Bech32PrefixDAGCoin,
|
||||
util.Bech32PrefixKaspa,
|
||||
[ripemd160.Size]byte{
|
||||
0xf8, 0x15, 0xb0, 0x36, 0xd9, 0xbb, 0xbc, 0xe5, 0xe9, 0xf2,
|
||||
0xa0, 0x0a, 0xbd, 0x1b, 0xf3, 0xdc, 0x91, 0xe9, 0x55, 0x10}),
|
||||
@ -139,20 +139,20 @@ func TestAddresses(t *testing.T) {
|
||||
0xdb, 0xfb, 0x1e, 0x75, 0x4e, 0x35, 0xfa, 0x1c, 0x78, 0x44,
|
||||
0xc4, 0x1f, 0x32, 0x2a, 0x18, 0x63, 0xd4, 0x62, 0x13, 0x53,
|
||||
0xae}
|
||||
return util.NewAddressScriptHash(script, util.Bech32PrefixDAGCoin)
|
||||
return util.NewAddressScriptHash(script, util.Bech32PrefixKaspa)
|
||||
},
|
||||
prefix: util.Bech32PrefixDAGCoin,
|
||||
prefix: util.Bech32PrefixKaspa,
|
||||
},
|
||||
{
|
||||
// Taken from transactions:
|
||||
// output: b0539a45de13b3e0403909b8bd1a555b8cbe45fd4e3f3fda76f3a5f52835c29d
|
||||
// input: (not yet redeemed at time test was written)
|
||||
name: "mainnet p2sh 2",
|
||||
addr: "dagcoin:pr5vxqxg0xrwl2zvxlq9rxffqx00sm44ksj47shjr6",
|
||||
encoded: "dagcoin:pr5vxqxg0xrwl2zvxlq9rxffqx00sm44ksj47shjr6",
|
||||
addr: "kaspa:pr5vxqxg0xrwl2zvxlq9rxffqx00sm44ksnw9jhzqr",
|
||||
encoded: "kaspa:pr5vxqxg0xrwl2zvxlq9rxffqx00sm44ksnw9jhzqr",
|
||||
valid: true,
|
||||
result: util.TstAddressScriptHash(
|
||||
util.Bech32PrefixDAGCoin,
|
||||
util.Bech32PrefixKaspa,
|
||||
[ripemd160.Size]byte{
|
||||
0xe8, 0xc3, 0x00, 0xc8, 0x79, 0x86, 0xef, 0xa8, 0x4c, 0x37,
|
||||
0xc0, 0x51, 0x99, 0x29, 0x01, 0x9e, 0xf8, 0x6e, 0xb5, 0xb4}),
|
||||
@ -160,17 +160,17 @@ func TestAddresses(t *testing.T) {
|
||||
hash := []byte{
|
||||
0xe8, 0xc3, 0x00, 0xc8, 0x79, 0x86, 0xef, 0xa8, 0x4c, 0x37,
|
||||
0xc0, 0x51, 0x99, 0x29, 0x01, 0x9e, 0xf8, 0x6e, 0xb5, 0xb4}
|
||||
return util.NewAddressScriptHashFromHash(hash, util.Bech32PrefixDAGCoin)
|
||||
return util.NewAddressScriptHashFromHash(hash, util.Bech32PrefixKaspa)
|
||||
},
|
||||
prefix: util.Bech32PrefixDAGCoin,
|
||||
prefix: util.Bech32PrefixKaspa,
|
||||
},
|
||||
{
|
||||
name: "testnet p2sh",
|
||||
addr: "dagtest:przhjdpv93xfygpqtckdc2zkzuzqeyj2pg6ghunlhx",
|
||||
encoded: "dagtest:przhjdpv93xfygpqtckdc2zkzuzqeyj2pg6ghunlhx",
|
||||
addr: "kaspatest:przhjdpv93xfygpqtckdc2zkzuzqeyj2pgg3hlfnac",
|
||||
encoded: "kaspatest:przhjdpv93xfygpqtckdc2zkzuzqeyj2pgg3hlfnac",
|
||||
valid: true,
|
||||
result: util.TstAddressScriptHash(
|
||||
util.Bech32PrefixDAGTest,
|
||||
util.Bech32PrefixKaspaTest,
|
||||
[ripemd160.Size]byte{
|
||||
0xc5, 0x79, 0x34, 0x2c, 0x2c, 0x4c, 0x92, 0x20, 0x20, 0x5e,
|
||||
0x2c, 0xdc, 0x28, 0x56, 0x17, 0x04, 0x0c, 0x92, 0x4a, 0x0a}),
|
||||
@ -178,9 +178,9 @@ func TestAddresses(t *testing.T) {
|
||||
hash := []byte{
|
||||
0xc5, 0x79, 0x34, 0x2c, 0x2c, 0x4c, 0x92, 0x20, 0x20, 0x5e,
|
||||
0x2c, 0xdc, 0x28, 0x56, 0x17, 0x04, 0x0c, 0x92, 0x4a, 0x0a}
|
||||
return util.NewAddressScriptHashFromHash(hash, util.Bech32PrefixDAGTest)
|
||||
return util.NewAddressScriptHashFromHash(hash, util.Bech32PrefixKaspaTest)
|
||||
},
|
||||
prefix: util.Bech32PrefixDAGTest,
|
||||
prefix: util.Bech32PrefixKaspaTest,
|
||||
},
|
||||
|
||||
// Negative P2SH tests.
|
||||
@ -193,9 +193,9 @@ func TestAddresses(t *testing.T) {
|
||||
0x00, 0xf8, 0x15, 0xb0, 0x36, 0xd9, 0xbb, 0xbc, 0xe5, 0xe9,
|
||||
0xf2, 0xa0, 0x0a, 0xbd, 0x1b, 0xf3, 0xdc, 0x91, 0xe9, 0x55,
|
||||
0x10}
|
||||
return util.NewAddressScriptHashFromHash(hash, util.Bech32PrefixDAGCoin)
|
||||
return util.NewAddressScriptHashFromHash(hash, util.Bech32PrefixKaspa)
|
||||
},
|
||||
prefix: util.Bech32PrefixDAGCoin,
|
||||
prefix: util.Bech32PrefixKaspa,
|
||||
},
|
||||
}
|
||||
|
||||
@ -311,18 +311,18 @@ func TestDecodeAddressErrorConditions(t *testing.T) {
|
||||
"decoded address's prefix could not be parsed",
|
||||
},
|
||||
{
|
||||
"dagreg:qpm2qsznhks23z7629mms6s4cwef74vcwvtmvqeszh",
|
||||
util.Bech32PrefixDAGTest,
|
||||
"kaspareg:qpm2qsznhks23z7629mms6s4cwef74vcwv4w75h796",
|
||||
util.Bech32PrefixKaspaTest,
|
||||
"decoded address is of wrong network",
|
||||
},
|
||||
{
|
||||
"dagreg:raskzctpv9skzctpv9skzctpv9skzctpvyd070wnqg",
|
||||
util.Bech32PrefixDAGReg,
|
||||
"kaspareg:raskzctpv9skzctpv9skzctpv9skzctpvyn6vmqa89",
|
||||
util.Bech32PrefixKaspaReg,
|
||||
"unknown address type",
|
||||
},
|
||||
{
|
||||
"dagreg:raskzcg5egs6nnj",
|
||||
util.Bech32PrefixDAGReg,
|
||||
"kaspareg:raskzcgrjj7l73l",
|
||||
util.Bech32PrefixKaspaReg,
|
||||
"decoded address is of unknown size",
|
||||
},
|
||||
}
|
||||
@ -344,10 +344,10 @@ func TestParsePrefix(t *testing.T) {
|
||||
expectedPrefix util.Bech32Prefix
|
||||
expectedError bool
|
||||
}{
|
||||
{"dagcoin", util.Bech32PrefixDAGCoin, false},
|
||||
{"dagreg", util.Bech32PrefixDAGReg, false},
|
||||
{"dagtest", util.Bech32PrefixDAGTest, false},
|
||||
{"dagsim", util.Bech32PrefixDAGSim, false},
|
||||
{"kaspa", util.Bech32PrefixKaspa, false},
|
||||
{"kaspareg", util.Bech32PrefixKaspaReg, false},
|
||||
{"kaspatest", util.Bech32PrefixKaspaTest, false},
|
||||
{"kaspasim", util.Bech32PrefixKaspaSim, false},
|
||||
{"blabla", util.Bech32PrefixUnknown, true},
|
||||
{"unknown", util.Bech32PrefixUnknown, true},
|
||||
{"", util.Bech32PrefixUnknown, true},
|
||||
@ -372,10 +372,10 @@ func TestPrefixToString(t *testing.T) {
|
||||
prefix util.Bech32Prefix
|
||||
expectedPrefixStr string
|
||||
}{
|
||||
{util.Bech32PrefixDAGCoin, "dagcoin"},
|
||||
{util.Bech32PrefixDAGReg, "dagreg"},
|
||||
{util.Bech32PrefixDAGTest, "dagtest"},
|
||||
{util.Bech32PrefixDAGSim, "dagsim"},
|
||||
{util.Bech32PrefixKaspa, "kaspa"},
|
||||
{util.Bech32PrefixKaspaReg, "kaspareg"},
|
||||
{util.Bech32PrefixKaspaTest, "kaspatest"},
|
||||
{util.Bech32PrefixKaspaSim, "kaspasim"},
|
||||
{util.Bech32PrefixUnknown, ""},
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,5 @@ Package bech32 provides a Go implementation of the bech32 format.
|
||||
Bech32 strings consist of a prefix, followed by the
|
||||
separator :, then a checksummed data part encoded using the 32 characters
|
||||
"qpzry9x8gf2tvdw0s3jn54khce6mua7l".
|
||||
|
||||
More info: https://github.com/daglabs/spec/blob/master/dagcoin.pdf
|
||||
*/
|
||||
package bech32
|
||||
|
@ -118,12 +118,12 @@ func Example_defaultWalletLayout() {
|
||||
|
||||
// Get and show the address associated with the extended keys for the
|
||||
// main kaspa network.
|
||||
acct0ExtAddr, err := acct0Ext10.Address(util.Bech32PrefixDAGCoin)
|
||||
acct0ExtAddr, err := acct0Ext10.Address(util.Bech32PrefixKaspa)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
}
|
||||
acct0IntAddr, err := acct0Int0.Address(util.Bech32PrefixDAGCoin)
|
||||
acct0IntAddr, err := acct0Int0.Address(util.Bech32PrefixKaspa)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return
|
||||
@ -132,8 +132,8 @@ func Example_defaultWalletLayout() {
|
||||
fmt.Println("Account 0 Internal Address 0:", acct0IntAddr)
|
||||
|
||||
// Output:
|
||||
// Account 0 External Address 10: dagcoin:qz6wkeydwnmhsf0w9ac4rwhnx8jmlqsp9yyvhchtuw
|
||||
// Account 0 Internal Address 0: dagcoin:qzak20c4paxssre0a2zvgk8e0r22p06j9szsxadlgy
|
||||
// Account 0 External Address 10: kaspa:qz6wkeydwnmhsf0w9ac4rwhnx8jmlqsp9y9hv6hmlh
|
||||
// Account 0 Internal Address 0: kaspa:qzak20c4paxssre0a2zvgk8e0r22p06j9srtald0ta
|
||||
}
|
||||
|
||||
// This example demonstrates the audits use case in BIP0032.
|
||||
|
@ -575,7 +575,7 @@ func TestExtendedKeyAPI(t *testing.T) {
|
||||
parentFP: 0,
|
||||
privKey: "e8f32e723decf4051aefac8e2c93c9c5b214313817cdb01a1494b917c8436b35",
|
||||
pubKey: "0339a36013301597daef41fbe593a02cc513d0b55527ec2df1050e2e8ff49c85c2",
|
||||
address: "dagcoin:qq6yyxf7rwmsj9hfz32jzukdfckme80czym4azehfm",
|
||||
address: "kaspa:qq6yyxf7rwmsj9hfz32jzukdfckme80czy6wxqe82z",
|
||||
},
|
||||
{
|
||||
name: "test vector 1 chain m/0H/1/2H public",
|
||||
@ -584,7 +584,7 @@ func TestExtendedKeyAPI(t *testing.T) {
|
||||
parentFP: 3203769081,
|
||||
privKeyErr: ErrNotPrivExtKey,
|
||||
pubKey: "0357bfe1e341d01c69fe5654309956cbea516822fba8a601743a012a7896ee8dc2",
|
||||
address: "dagcoin:qrh84wgvmet23s8zhvyx43yhfzudh8wwwgdmec4q2f",
|
||||
address: "kaspa:qrh84wgvmet23s8zhvyx43yhfzudh8wwwgvqz64sfs",
|
||||
},
|
||||
}
|
||||
|
||||
@ -649,7 +649,7 @@ func TestExtendedKeyAPI(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
|
||||
addr, err := key.Address(util.Bech32PrefixDAGCoin)
|
||||
addr, err := key.Address(util.Bech32PrefixKaspa)
|
||||
if err != nil {
|
||||
t.Errorf("Address #%d (%s): unexpected error: %v", i,
|
||||
test.name, err)
|
||||
@ -960,8 +960,8 @@ func TestZero(t *testing.T) {
|
||||
return false
|
||||
}
|
||||
|
||||
wantAddr := "dagcoin:qz689gnx6z7cnsfhq6jpxtx0k9hhcwulevtzqltud6"
|
||||
addr, err := key.Address(util.Bech32PrefixDAGCoin)
|
||||
wantAddr := "kaspa:qz689gnx6z7cnsfhq6jpxtx0k9hhcwulev2ematvwr"
|
||||
addr, err := key.Address(util.Bech32PrefixKaspa)
|
||||
if err != nil {
|
||||
t.Errorf("Addres s #%d (%s): unexpected error: %v", i,
|
||||
testName, err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user