func (b *backend) GenerateNewUserPaywall(user *database.User) error {
	// Check that the paywall is enabled.
	if !b.paywallIsEnabled() {
		return nil
	}

	// Check that the user either hasn't had paywall information set yet,
	// or it has expired.
	if user.NewUserPaywallAddress != "" &&
		!paywallHasExpired(user.NewUserPaywallPollExpiry) {
		return nil
	}

	if user.NewUserPaywallAddress == "" {
		address, amount, txNotBefore, err := b.derivePaywallInfo(user)
		if err != nil {
			return err
		}

		user.NewUserPaywallAddress = address
		user.NewUserPaywallAmount = amount
		user.NewUserPaywallTxNotBefore = txNotBefore
	}
	user.NewUserPaywallPollExpiry = time.Now().Add(paywallExpiryDuration).Unix()

	err := b.db.UserUpdate(*user)
	if err != nil {
		return err
	}

	b.addUserToPaywallPool(user)
	return nil
}
// GenerateNewUserPaywall generates new paywall info, if necessary, and saves
// it in the database.
GenerateNewUserPaywall generates new paywall info, if necessary, and saves
it in the database.
// GenerateNewUserPaywall generates new paywall info if necessary and saves // it in the database .
func (b *backend) GenerateNewUserPaywall(user *database.User) error {
	if !b.paywallIsEnabled() {
		return nil
	}
	if user.NewUserPaywallAddress != "" &&
		!paywallHasExpired(user.NewUserPaywallPollExpiry) {
		return nil
	}
	if user.NewUserPaywallAddress == "" {
		address, amount, txNotBefore, err := b.derivePaywallInfo(user)
		if err != nil {
			return err
		}
		user.NewUserPaywallAddress = address
		user.NewUserPaywallAmount = amount
		user.NewUserPaywallTxNotBefore = txNotBefore
	}
	user.NewUserPaywallPollExpiry = time.Now().Add(paywallExpiryDuration).Unix()
	err := b.db.UserUpdate(*user)
	if err != nil {
		return err
	}
	b.addUserToPaywallPool(user)
	return nil
}
func ( b * backend ) GenerateNewUserPaywall ( user * database . User ) error { if ! b . paywallIsEnabled ( ) { return nil } if user . NewUserPaywallAddress != " " && ! paywallHasExpired ( user . NewUserPaywallPollExpiry ) { return nil } if user . NewUserPaywallAddress == " " { address , amount , txNotBefore , err := b . derivePaywallInfo ( user ) if err != nil { return err } user . NewUserPaywallAddress = address user . NewUserPaywallAmount = amount user . NewUserPaywallTxNotBefore = txNotBefore } user . NewUserPaywallPollExpiry = time . Now ( ) . Add ( paywallExpiryDuration ) . Unix ( ) err := b . db . UserUpdate ( * user ) if err != nil { return err } b . addUserToPaywallPool ( user ) return nil }
GenerateNewUserPaywall generates new paywall info, if necessary, and saves
it in the database.
GenerateNewUserPaywall generates new paywall info if necessary and saves it in the database .
// Check that the paywall is enabled. // Check that the user either hasn't had paywall information set yet, // or it has expired.