Esempio n. 1
0
func RebondJob(rebond *definitions.Rebond, do *definitions.Do) (string, error) {
	// Process Variables
	rebond.Account, _ = util.PreProcess(rebond.Account, do)
	rebond.Height, _ = util.PreProcess(rebond.Height, do)

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

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

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

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

	// Sign, broadcast, display
	return txFinalize(do, tx, rebond.Wait)
}
Esempio n. 2
0
func RebondJob(rebond *definitions.Rebond, do *definitions.Do) (string, error) {
	// Process Variables
	var err error
	rebond.Account, err = util.PreProcess(rebond.Account, do)
	rebond.Height, err = util.PreProcess(rebond.Height, do)
	if err != nil {
		return "", err
	}

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

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

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

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

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

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