Skip to content

Commit

Permalink
add documentation to account_update_transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
QuestofIranon committed Feb 20, 2020
1 parent d0c2b1e commit 1d5d879
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions account_update_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ import (
"time"
)

// AccountUpdateTransaction changes properties for the given account. Any unset field is left unchanged. This
// transaction must be signed by the existing key for this account.
type AccountUpdateTransaction struct {
TransactionBuilder
pb *proto.CryptoUpdateTransactionBody
}

// NewAccountUpdateTransaction creates an AccountUpdateTransaction builder which can be used to construct and
// execute a Crypto Update Transaction.
func NewAccountUpdateTransaction() AccountUpdateTransaction {
pb := &proto.CryptoUpdateTransactionBody{}

Expand All @@ -21,45 +25,65 @@ func NewAccountUpdateTransaction() AccountUpdateTransaction {
return builder
}

// SetAccountID sets the account ID which is being updated in this transaction
func (builder AccountUpdateTransaction) SetAccountID(id AccountID) AccountUpdateTransaction {
builder.pb.AccountIDToUpdate = id.toProto()
return builder
}

// SetKey sets the new key for the account being updated. The transaction must be signed by both the old key (from
// before the change) and the new key.
//
//The old key must sign for security. The new key must sign as a safeguard to avoid accidentally changing to an invalid
// key, and then having no way to recover.
func (builder AccountUpdateTransaction) SetKey(publicKey PublicKey) AccountUpdateTransaction {
builder.pb.Key = publicKey.toProto()
return builder
}

// SetProxyAccountID sets the ID of the account to which this account is proxy staked. If proxyAccountID is unset, is an
// invalid account, or is an account that isn't a node, then this account is automatically proxy staked to a node chosen
// by the network, but without earning payments. If the proxyAccountID account refuses to accept proxy staking, or if it
// is not currently running a node, then it will behave as if proxyAccountID was unset.
func (builder AccountUpdateTransaction) SetProxyAccountID(id AccountID) AccountUpdateTransaction {
builder.pb.ProxyAccountID = id.toProto()
return builder
}

// SetAutoRenewPeriod sets the duration in which it will automatically extend the expiration period. If it doesn't have
// enough balance, it extends as long as possible. If the balance is empty when it expires, then it is deleted.
func (builder AccountUpdateTransaction) SetAutoRenewPeriod(autoRenewPeriod time.Duration) AccountUpdateTransaction {
builder.pb.AutoRenewPeriod = durationToProto(autoRenewPeriod)
return builder
}

// SetExpirationTime sets the new expiration time to extend to (ignored if equal to or before the current one) When
// extending the expiration date, the cost is affected by the size of the list of attached claims, and of the keys
// associated with the claims and the account.
func (builder AccountUpdateTransaction) SetExpirationTime(expiration time.Time) AccountUpdateTransaction {
builder.pb.ExpirationTime = timeToProto(expiration)
return builder
}

// SetReceiverSignatureRequired sets the receiverSigRequired flag on the account.
func (builder AccountUpdateTransaction) SetReceiverSignatureRequired(required bool) AccountUpdateTransaction {
builder.pb.ReceiverSigRequiredField = &proto.CryptoUpdateTransactionBody_ReceiverSigRequired{
ReceiverSigRequired: required,
}
return builder
}

// SetSendRecordThreshold sets the threshold amount for which an account record is created for any send/withdraw
// transaction
func (builder AccountUpdateTransaction) SetSendRecordThreshold(threshold Hbar) AccountUpdateTransaction {
builder.pb.SendRecordThresholdField = &proto.CryptoUpdateTransactionBody_SendRecordThreshold{
SendRecordThreshold: uint64(threshold.AsTinybar()),
}
return builder
}

// SetReceiveRecordThreshold sets the threshold amount for which an account record is created for any receive/deposit
// transaction
func (builder AccountUpdateTransaction) SetReceiveRecordThreshold(threshold Hbar) AccountUpdateTransaction {
builder.pb.ReceiveRecordThresholdField = &proto.CryptoUpdateTransactionBody_ReceiveRecordThreshold{
ReceiveRecordThreshold: uint64(threshold.AsTinybar()),
Expand Down

0 comments on commit 1d5d879

Please sign in to comment.