예제 #1
0
func UnbondJob(unbond *definitions.Unbond, do *definitions.Do) (string, error) {
	// Process Variables
	unbond.Account, _ = util.PreProcess(unbond.Account, do)
	unbond.Height, _ = util.PreProcess(unbond.Height, do)

	// Use defaults
	unbond.Account = useDefault(unbond.Account, do.Package.Account)

	// Don't use pubKey if account override
	var oldKey string
	if unbond.Account != do.Package.Account {
		oldKey = do.PublicKey
		do.PublicKey = ""
	}

	// Formulate tx
	logger.Infof("Unbond Transaction =>\t\t%s:%s\n", unbond.Account, unbond.Height)
	tx, err := core.Unbond(unbond.Account, unbond.Height)
	if err != nil {
		logger.Errorf("ERROR =>\n")
		return "", err
	}

	// Don't use pubKey if account override
	if unbond.Account != do.Package.Account {
		do.PublicKey = oldKey
	}

	// Sign, broadcast, display
	return txFinalize(do, tx, unbond.Wait)
}
예제 #2
0
func UnbondJob(unbond *definitions.Unbond, do *definitions.Do) (string, error) {
	// Process Variables
	var err error
	unbond.Account, err = util.PreProcess(unbond.Account, do)
	unbond.Height, err = util.PreProcess(unbond.Height, do)
	if err != nil {
		return "", err
	}

	// Use defaults
	unbond.Account = useDefault(unbond.Account, do.Package.Account)

	// Don't use pubKey if account override
	var oldKey string
	if unbond.Account != do.Package.Account {
		oldKey = do.PublicKey
		do.PublicKey = ""
	}

	// Formulate tx
	log.WithFields(log.Fields{
		"account": unbond.Account,
		"height":  unbond.Height,
	}).Info("Unbond Transaction")

	tx, err := core.Unbond(unbond.Account, unbond.Height)
	if err != nil {
		return util.MintChainErrorHandler(do, err)
	}

	// Don't use pubKey if account override
	if unbond.Account != do.Package.Account {
		do.PublicKey = oldKey
	}

	// Sign, broadcast, display
	return txFinalize(do, tx, unbond.Wait)
}