cli/wallet: show tx fee before relaying
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
56dd7b7364
commit
2a78ec8003
11 changed files with 104 additions and 5 deletions
|
@ -1,10 +1,13 @@
|
|||
package input
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"syscall"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
|
@ -55,3 +58,18 @@ func ReadPassword(prompt string) (string, error) {
|
|||
}
|
||||
return trm.ReadPassword(prompt)
|
||||
}
|
||||
|
||||
// ConfirmTx asks for a confirmation to send tx.
|
||||
func ConfirmTx(w io.Writer, tx *transaction.Transaction) error {
|
||||
fmt.Fprintf(w, "Network fee: %d\n", tx.NetworkFee)
|
||||
fmt.Fprintf(w, "System fee: %d\n", tx.SystemFee)
|
||||
fmt.Fprintf(w, "Total fee: %d\n", tx.NetworkFee+tx.SystemFee)
|
||||
ln, err := ReadLine("Relay transaction (y|N)> ")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if 0 < len(ln) && ln[0] == 'y' || ln[0] == 'Y' {
|
||||
return nil
|
||||
}
|
||||
return errors.New("cancelled")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue