From 1ea44fe7f4821b3bd93d99d599e357551cb5b1d2 Mon Sep 17 00:00:00 2001 From: Chih Cheng Liang Date: Wed, 11 Nov 2020 12:55:26 +0800 Subject: [PATCH] fix rebase --- cmd/flags.go | 3 --- cmd/tx.go | 19 ++++++++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/cmd/flags.go b/cmd/flags.go index 0f0b75b..86d503c 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -7,8 +7,5 @@ const ( FlagPubKey = "pubkey" FlagAmount = "amount" FlagFee = "fee" - FlagSignature = "sig" - FlagNonce = "nonce" - FlagTokenID = "token" FlagDatabaseName = "dbname" ) diff --git a/cmd/tx.go b/cmd/tx.go index 648a5ad..4fded3b 100644 --- a/cmd/tx.go +++ b/cmd/tx.go @@ -56,9 +56,13 @@ func sendTransferTx() *cobra.Command { cmd.Flags().StringP(FlagPrivKey, "", "", "--privkey=") cmd.Flags().StringP(FlagAmount, "", "", "--amount=") err := cmd.MarkFlagRequired(FlagToID) + common.PanicIfError(err) err = cmd.MarkFlagRequired(FlagFromID) + common.PanicIfError(err) err = cmd.MarkFlagRequired(FlagPubKey) + common.PanicIfError(err) err = cmd.MarkFlagRequired(FlagPrivKey) + common.PanicIfError(err) err = cmd.MarkFlagRequired(FlagAmount) common.PanicIfError(err) return cmd @@ -172,9 +176,18 @@ func validateAndTransfer(db core.DB, bazooka core.Bazooka, fromIndex, toIndex, a return } - tx := core.NewPendingTx(fromIndex, toIndex, core.TX_TRANSFER_TYPE, []byte(""), txData) - tx.SignTx(priv, pub, common.Keccak256(tx.GetSignBytes())) - tx.AssignHash() + tx, err := core.NewPendingTx(fromIndex, toIndex, core.TX_TRANSFER_TYPE, []byte(""), txData) + if err != nil { + return + } + err = tx.SignTx(priv, pub, common.Keccak256(tx.GetSignBytes())) + if err != nil { + return + } + err = tx.AssignHash() + if err != nil { + return + } fmt.Println("Sending new tx", tx.String())