"github.com/vapor/consensus/segwit"
"github.com/vapor/crypto"
"github.com/vapor/crypto/csp"
- "github.com/vapor/crypto/ed25519"
edchainkd "github.com/vapor/crypto/ed25519/chainkd"
"github.com/vapor/crypto/sha3pool"
dbm "github.com/vapor/database/leveldb"
func createP2PKH(account *Account, path [][]byte) (*CtrlProgram, error) {
derivedXPubs := csp.DeriveXPubs(account.XPubs, path)
- derivedPK := derivedXPubs[0].PublicKey()
pubHash := make([]byte, 0)
- switch dpk := derivedPK.(type) {
- case ed25519.PublicKey:
- pubHash = crypto.Ripemd160(dpk)
+ switch dxpub := derivedXPubs[0].(type) {
+ case edchainkd.XPub:
+ derivedPK := dxpub.PublicKey()
+ pubHash = crypto.Ripemd160(derivedPK)
}
address, err := common.NewAddressWitnessPubKeyHash(pubHash, &consensus.ActiveNetParams)
"github.com/vapor/blockchain/pseudohsm"
"github.com/vapor/blockchain/signers"
"github.com/vapor/config"
- vcrypto "github.com/vapor/crypto"
+ edchainkd "github.com/vapor/crypto/ed25519/chainkd"
"github.com/vapor/database"
dbm "github.com/vapor/database/leveldb"
"github.com/vapor/errors"
func TestCreateAccountWithUppercase(t *testing.T) {
m := mockAccountManager(t)
alias := "UPPER"
- account, err := m.Create([]vcrypto.XPubKeyer{testutil.TestXPub}, 1, alias, signers.BIP0044)
+ account, err := m.Create([]edchainkd.XPub{testutil.TestXPub}, 1, alias, signers.BIP0044)
if err != nil {
t.Fatal(err)
func TestCreateAccountWithSpaceTrimed(t *testing.T) {
m := mockAccountManager(t)
alias := " with space "
- account, err := m.Create([]vcrypto.XPubKeyer{testutil.TestXPub}, 1, alias, signers.BIP0044)
+ account, err := m.Create([]edchainkd.XPub{testutil.TestXPub}, 1, alias, signers.BIP0044)
if err != nil {
t.Fatal(err)
func TestCreateAccount(t *testing.T) {
m := mockAccountManager(t)
- account, err := m.Create([]vcrypto.XPubKeyer{testutil.TestXPub}, 1, "test-alias", signers.BIP0044)
+ account, err := m.Create([]edchainkd.XPub{testutil.TestXPub}, 1, "test-alias", signers.BIP0044)
if err != nil {
testutil.FatalErr(t, err)
}
m := mockAccountManager(t)
m.createTestAccount(t, "test-alias", nil)
- _, err := m.Create([]vcrypto.XPubKeyer{testutil.TestXPub}, 1, "test-alias", signers.BIP0044)
+ _, err := m.Create([]edchainkd.XPub{testutil.TestXPub}, 1, "test-alias", signers.BIP0044)
if errors.Root(err) != ErrDuplicateAlias {
t.Errorf("expected %s when reusing an alias, got %v", ErrDuplicateAlias, err)
}
func TestDeleteAccount(t *testing.T) {
m := mockAccountManager(t)
- account1, err := m.Create([]vcrypto.XPubKeyer{testutil.TestXPub}, 1, "test-alias1", signers.BIP0044)
+ account1, err := m.Create([]edchainkd.XPub{testutil.TestXPub}, 1, "test-alias1", signers.BIP0044)
if err != nil {
testutil.FatalErr(t, err)
}
- account2, err := m.Create([]vcrypto.XPubKeyer{testutil.TestXPub}, 1, "test-alias2", signers.BIP0044)
+ account2, err := m.Create([]edchainkd.XPub{testutil.TestXPub}, 1, "test-alias2", signers.BIP0044)
if err != nil {
testutil.FatalErr(t, err)
}
t.Fatal(err)
}
- xpubs1 := []vcrypto.XPubKeyer{xpub1.XPub, xpub2.XPub}
- xpubs2 := []vcrypto.XPubKeyer{xpub2.XPub, xpub1.XPub}
+ xpubs1 := []edchainkd.XPub{xpub1.XPub, xpub2.XPub}
+ xpubs2 := []edchainkd.XPub{xpub2.XPub, xpub1.XPub}
if !reflect.DeepEqual(GetAccountIndexKey(xpubs1), GetAccountIndexKey(xpubs2)) {
// fmt.Printf("xpubs1 is: %s, xpubs2 is: %s", xpubs1, xpubs2)
t.Fatal("GetAccountIndexKey test err")
}
func (m *Manager) createTestAccount(t testing.TB, alias string, tags map[string]interface{}) *Account {
- account, err := m.Create([]vcrypto.XPubKeyer{testutil.TestXPub}, 1, alias, signers.BIP0044)
+ account, err := m.Create([]edchainkd.XPub{testutil.TestXPub}, 1, alias, signers.BIP0044)
if err != nil {
testutil.FatalErr(t, err)
}
"github.com/vapor/common"
"github.com/vapor/consensus"
"github.com/vapor/crypto/csp"
- "github.com/vapor/crypto/ed25519"
+ edchainkd "github.com/vapor/crypto/ed25519/chainkd"
"github.com/vapor/encoding/json"
"github.com/vapor/errors"
"github.com/vapor/protocol/bc"
switch address.(type) {
case *common.AddressWitnessPubKeyHash:
- derivedPK := derivedXPubs[0].PublicKey()
- switch dpk := derivedPK.(type) {
- case ed25519.PublicKey:
- sigInst.WitnessComponents = append(sigInst.WitnessComponents, txbuilder.DataWitness([]byte(dpk)))
+ switch dxpub := derivedXPubs[0].(type) {
+ case edchainkd.XPub:
+ derivedPK := dxpub.PublicKey()
+ sigInst.WitnessComponents = append(sigInst.WitnessComponents, txbuilder.DataWitness([]byte(derivedPK)))
}
case *common.AddressWitnessScriptHash:
package config
import (
+ "crypto"
"encoding/hex"
log "github.com/sirupsen/logrus"
"github.com/vapor/consensus"
- "github.com/vapor/crypto"
- "github.com/vapor/crypto/ed25519/chainkd"
+ vcrypto "github.com/vapor/crypto"
+ edchainkd "github.com/vapor/crypto/ed25519/chainkd"
"github.com/vapor/protocol/bc"
"github.com/vapor/protocol/bc/types"
"github.com/vapor/protocol/vm/vmutil"
)
func GenesisArguments(c *Config) []byte {
- pubKeys := chainkd.XPubKeys(c.Federation.Xpubs)
- fedpegScript, err := vmutil.P2SPMultiSigProgram(pubKeys, c.Federation.Quorum)
+ pubKeys := edchainkd.XPubKeys(c.Federation.Xpubs)
+ cryptoPub := make([]crypto.PublicKey, 0)
+ for _, pub := range pubKeys {
+ cryptoPub = append(cryptoPub, pub)
+ }
+ fedpegScript, err := vmutil.P2SPMultiSigProgram(cryptoPub, c.Federation.Quorum)
if err != nil {
log.Panicf("fail on decode genesis arguments for federation")
}
- scriptHash := crypto.Sha256(fedpegScript)
+ scriptHash := vcrypto.Sha256(fedpegScript)
control, err := vmutil.P2WSHProgram(scriptHash)
if err != nil {