From 9219dad50e48097da353ccd55c649b356ed0a0b4 Mon Sep 17 00:00:00 2001 From: Chengcheng Zhang <943420582@qq.com> Date: Thu, 30 May 2019 20:23:30 +0800 Subject: [PATCH] delete some comments --- account/accounts.go | 9 --------- account/builder.go | 16 ---------------- blockchain/pseudohsm/pseudohsm_test.go | 8 -------- crypto/csp/util.go | 21 --------------------- crypto/ed25519/chainkd/serialize.go | 5 ----- protocol/bc/types/map.go | 3 --- 6 files changed, 62 deletions(-) diff --git a/account/accounts.go b/account/accounts.go index 4198cbfc..16240a9d 100644 --- a/account/accounts.go +++ b/account/accounts.go @@ -3,7 +3,6 @@ package account import ( "encoding/json" - "fmt" "reflect" "sort" "strings" @@ -417,7 +416,6 @@ func (m *Manager) FindByAlias(alias string) (*Account, error) { // FindByID returns an account's Signer record by its ID. func (m *Manager) FindByID(id string) (*Account, error) { - fmt.Println("FindByID start...") m.cacheMu.Lock() cachedAccount, ok := m.cache.Get(id) m.cacheMu.Unlock() @@ -436,19 +434,16 @@ func (m *Manager) FindByID(id string) (*Account, error) { } for i, xpub := range account.XPubs { if reflect.TypeOf(xpub).String() == "string" { - // fmt.Println("account xpubs type:", reflect.TypeOf(xpub).String()) if xpb, err := edchainkd.NewXPub(reflect.ValueOf(xpub).String()); err != nil { panic(err) } else { account.XPubs[i] = *xpb } - fmt.Println("account xpubs type:", reflect.TypeOf(account.XPubs[i]).String()) } } m.cacheMu.Lock() m.cache.Add(id, account) - fmt.Println("FindByID m.cache...", m.cache) m.cacheMu.Unlock() return account, nil } @@ -691,11 +686,8 @@ func CreateCtrlProgram(account *Account, addrIdx uint64, change bool) (cp *CtrlP } func createP2PKH(account *Account, path [][]byte) (*CtrlProgram, error) { - fmt.Println("createP2PKH account.XPubs is:", account.XPubs) derivedXPubs := csp.DeriveXPubs(account.XPubs, path) - fmt.Println("createP2PKH derivedXPubs is:", derivedXPubs) pubHash := make([]byte, 0) - fmt.Println("createP2PKH len(derivedXPubs) is:", len(derivedXPubs)) if len(derivedXPubs) == 0 { return nil, errors.New("no derived XPub.") } @@ -704,7 +696,6 @@ func createP2PKH(account *Account, path [][]byte) (*CtrlProgram, error) { derivedPK := dxpub.PublicKey() pubHash = crypto.Ripemd160(derivedPK) } - fmt.Println("createP2PKH ...") address, err := common.NewAddressWitnessPubKeyHash(pubHash, &consensus.ActiveNetParams) if err != nil { diff --git a/account/builder.go b/account/builder.go index 18e2a092..20b12df6 100644 --- a/account/builder.go +++ b/account/builder.go @@ -2,10 +2,7 @@ package account import ( "context" - "encoding/hex" stdjson "encoding/json" - "fmt" - "reflect" "github.com/vapor/blockchain/signers" "github.com/vapor/blockchain/txbuilder" @@ -313,7 +310,6 @@ func (a *spendUTXOAction) Build(ctx context.Context, b *txbuilder.TemplateBuilde // UtxoToInputs convert an utxo to the txinput func UtxoToInputs(signer *signers.Signer, u *UTXO) (*types.TxInput, *txbuilder.SigningInstruction, error) { - fmt.Println("UtxoToInputs...") txInput := types.NewSpendInput(nil, u.SourceID, u.AssetID, u.Amount, u.SourcePos, u.ControlProgram) sigInst := &txbuilder.SigningInstruction{} if signer == nil { @@ -333,39 +329,27 @@ func UtxoToInputs(signer *signers.Signer, u *UTXO) (*types.TxInput, *txbuilder.S if err != nil { return nil, nil, err } - fmt.Println("UtxoToInputs...will sigInst.AddRawWitnessKeys") sigInst.AddRawWitnessKeys(signer.XPubs, path, signer.Quorum) derivedXPubs := csp.DeriveXPubs(signer.XPubs, path) - fmt.Println("UtxoToInputs...finish derivedXPubs := csp.DeriveXPubs(signer.XPubs, path)") - fmt.Println("UtxoToInputs derivedXPubs:", derivedXPubs) - fmt.Println("UtxoToInputs derivedXPubs[0] type:", reflect.TypeOf(derivedXPubs[0])) - // if len(derivedXPubs) == 0 { panic("UtxoToInputs derivedXPubs is nil.") } switch address.(type) { case *common.AddressWitnessPubKeyHash: - fmt.Println("UtxoToInputs *common.AddressWitnessPubKeyHash...") switch dxpub := derivedXPubs[0].(type) { case edchainkd.XPub: - fmt.Println("UtxoToInputs dxpub", hex.EncodeToString(dxpub[:])) derivedPK := dxpub.PublicKey() - fmt.Println("UtxoToInputs derivedPK", hex.EncodeToString(derivedPK)) sigInst.WitnessComponents = append(sigInst.WitnessComponents, txbuilder.DataWitness([]byte(derivedPK))) - fmt.Println("UtxoToInputs *common.AddressWitnessPubKeyHash done...") } case *common.AddressWitnessScriptHash: - fmt.Println("UtxoToInputs *common.AddressWitnessScriptHash...") - fmt.Println("UtxoToInputs derivedXPubs", derivedXPubs) derivedPKs := csp.XPubKeys(derivedXPubs) script, err := vmutil.P2SPMultiSigProgram(derivedPKs, signer.Quorum) if err != nil { return nil, nil, err } - fmt.Println("UtxoToInputs derivedPKs:", derivedPKs) sigInst.WitnessComponents = append(sigInst.WitnessComponents, txbuilder.DataWitness(script)) default: diff --git a/blockchain/pseudohsm/pseudohsm_test.go b/blockchain/pseudohsm/pseudohsm_test.go index f1f4478b..b4196408 100644 --- a/blockchain/pseudohsm/pseudohsm_test.go +++ b/blockchain/pseudohsm/pseudohsm_test.go @@ -4,7 +4,6 @@ import ( "fmt" "io/ioutil" "os" - "reflect" "strings" "testing" @@ -87,7 +86,6 @@ func TestPseudoHSMChainKDKeys(t *testing.T) { if err != nil { t.Fatal(err) } - fmt.Println("TestPseudoHSMChainKDKeys xpub:", xpub) xpub2, _, err := hsm.XCreate("bytom", "nopassword", "en") if err != nil { t.Fatal(err) @@ -97,14 +95,8 @@ func TestPseudoHSMChainKDKeys(t *testing.T) { if err != nil { t.Fatal(err) } - fmt.Println("TestPseudoHSMChainKDKeys xpub.XPub:", xpub.XPub) - fmt.Println("TestPseudoHSMChainKDKeys xpub.XPub type:", reflect.TypeOf(xpub.XPub)) - fmt.Println("TestPseudoHSMChainKDKeys sig:", sig) - fmt.Println("TestPseudoHSMChainKDKeys sig type:", reflect.TypeOf(sig)) - switch xpubkey := xpub.XPub.(type) { case edchainkd.XPub: - fmt.Println("TestPseudoHSMChainKDKeys 1 sig:", sig) if !xpubkey.Verify(msg, sig) { t.Error("expected verify to succeed") } diff --git a/crypto/csp/util.go b/crypto/csp/util.go index 5615e843..bf5014ec 100644 --- a/crypto/csp/util.go +++ b/crypto/csp/util.go @@ -15,9 +15,7 @@ import ( func NewXKeys(r io.Reader) (xprv vcrypto.XPrvKeyer, xpub vcrypto.XPubKeyer, err error) { // TODO: if ... create sm2 xprv and xpub - // return ..... - // if ... create ed25519 xprv and xpub return edchainkd.NewXKeys(r) } @@ -32,30 +30,13 @@ func XPubKeys(xpubs []vcrypto.XPubKeyer) []crypto.PublicKey { return res } -// func DeriveXPubs(xpubs []vcrypto.XPubKeyer, path [][]byte) []vcrypto.XPubKeyer { -// res := make([]vcrypto.XPubKeyer, 0, len(xpubs)) -// for _, xpub := range xpubs { -// switch xpb := xpub.(type) { -// case edchainkd.XPub: -// d := xpb.Derive(path) -// res = append(res, d) -// fmt.Println("DeriveXPubs d is:", d) -// } -// } -// fmt.Println("DeriveXPubs len(res) is:", len(res)) -// return res -// } - func DeriveXPubs(xpubs []vcrypto.XPubKeyer, path [][]byte) []vcrypto.XPubKeyer { res := make([]vcrypto.XPubKeyer, 0, len(xpubs)) for _, xpub := range xpubs { - fmt.Println("DeriveXPubs type xpubs:", reflect.TypeOf(xpubs), "type xpubs[0]:", reflect.TypeOf(xpubs[0])) - fmt.Println("xpubs[0] is:", xpubs[0]) switch xpb := xpub.(type) { case edchainkd.XPub: d := xpb.Derive(path) res = append(res, d) - fmt.Println("DeriveXPubs d is:", d) default: newxpub, err := edchainkd.NewXPub(reflect.ValueOf(xpub).String()) if err != nil { @@ -63,10 +44,8 @@ func DeriveXPubs(xpubs []vcrypto.XPubKeyer, path [][]byte) []vcrypto.XPubKeyer { } else { d := newxpub.Derive(path) res = append(res, d) - fmt.Println("DeriveXPubs d is:", d) } } } - fmt.Println("DeriveXPubs len(res) is:", len(res)) return res } diff --git a/crypto/ed25519/chainkd/serialize.go b/crypto/ed25519/chainkd/serialize.go index 7a2231d9..70c5bde2 100644 --- a/crypto/ed25519/chainkd/serialize.go +++ b/crypto/ed25519/chainkd/serialize.go @@ -3,7 +3,6 @@ package chainkd import ( "encoding/hex" "errors" - "fmt" ) const ( @@ -63,15 +62,11 @@ func (xprv XPrv) String() string { func NewXPub(str string) (*XPub, error) { xpub := new(XPub) if len(str) != 2*64 { - fmt.Println("str length is:", len(str)) - fmt.Println("str is:", str) return nil, errors.New("string length is invalid.") } if xpubBytes, err := hex.DecodeString(str); err != nil { return nil, err } else { - fmt.Println("NewXPub xpub is:", xpub) - fmt.Println("NewXPub xpubBytes is:", xpubBytes) copy(xpub[:], xpubBytes[:]) } return xpub, nil diff --git a/protocol/bc/types/map.go b/protocol/bc/types/map.go index 89224515..1568119c 100644 --- a/protocol/bc/types/map.go +++ b/protocol/bc/types/map.go @@ -1,8 +1,6 @@ package types import ( - "fmt" - log "github.com/sirupsen/logrus" "github.com/vapor/consensus" @@ -14,7 +12,6 @@ import ( // MapTx converts a types TxData object into its entries-based // representation. func MapTx(oldTx *TxData) *bc.Tx { - fmt.Println("MapTx start...") txID, txHeader, entries := mapTx(oldTx) tx := &bc.Tx{ TxHeader: txHeader, -- 2.11.0