-
Notifications
You must be signed in to change notification settings - Fork 20
feat(shelley): created genesis pools from shelley genesis #1054
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
44c9937
4f59553
c44fbd3
0f9eabb
e5340d3
c874975
a90c6a1
6d696a7
e484fdb
2138a76
23c86c1
2a5b082
61a22c8
ed3850a
f18d211
492b205
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -107,24 +107,47 @@ func NewAddressFromParts( | |
paymentAddr []byte, | ||
stakingAddr []byte, | ||
) (Address, error) { | ||
// Validate network ID | ||
if networkId != AddressNetworkTestnet && networkId != AddressNetworkMainnet { | ||
return Address{}, errors.New("invalid network ID") | ||
} | ||
|
||
// Handle stake-only addresses | ||
if addrType == AddressTypeNoneKey || addrType == AddressTypeNoneScript { | ||
if len(paymentAddr) > 0 { | ||
return Address{}, errors.New("payment address must be empty for stake-only addresses") | ||
} | ||
if len(stakingAddr) != AddressHashSize { | ||
return Address{}, fmt.Errorf("staking key must be exactly %d bytes", AddressHashSize) | ||
} | ||
|
||
if addrType == AddressTypeNoneScript && networkId == AddressNetworkTestnet { | ||
header := byte(0xF1) | ||
addrBytes := append([]byte{header}, stakingAddr...) | ||
return NewAddressFromBytes(addrBytes) | ||
} | ||
|
||
header := addrType<<4 | networkId | ||
addrBytes := append([]byte{header}, stakingAddr...) | ||
return NewAddressFromBytes(addrBytes) | ||
|
||
} | ||
|
||
// Handle regular addresses | ||
if len(paymentAddr) != AddressHashSize { | ||
return Address{}, fmt.Errorf( | ||
"invalid payment address hash length: %d", | ||
len(paymentAddr), | ||
) | ||
return Address{}, fmt.Errorf("payment address must be exactly %d bytes", AddressHashSize) | ||
} | ||
|
||
if len(stakingAddr) > 0 && len(stakingAddr) != AddressHashSize { | ||
return Address{}, fmt.Errorf( | ||
"invalid staking address hash length: %d", | ||
len(stakingAddr), | ||
) | ||
return Address{}, fmt.Errorf("staking address must be empty or exactly %d bytes", AddressHashSize) | ||
} | ||
return Address{ | ||
addressType: addrType, | ||
networkId: networkId, | ||
paymentAddress: paymentAddr[:], | ||
stakingAddress: stakingAddr[:], | ||
}, nil | ||
|
||
header := addrType<<4 | networkId | ||
addrBytes := append([]byte{header}, paymentAddr...) | ||
if len(stakingAddr) > 0 { | ||
addrBytes = append(addrBytes, stakingAddr...) | ||
} | ||
|
||
return NewAddressFromBytes(addrBytes) | ||
|
||
} | ||
|
||
func NewByronAddressFromParts( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to hard-code magic values like this