From 52222b50dd6e61856c10d693f139885151f6dae3 Mon Sep 17 00:00:00 2001 From: Andrei Kuzmiankov Date: Wed, 7 Oct 2020 19:10:18 -0700 Subject: [PATCH] Added freeze_transaction --- freeze_transaction.go | 53 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 freeze_transaction.go diff --git a/freeze_transaction.go b/freeze_transaction.go new file mode 100644 index 000000000..ba3504c05 --- /dev/null +++ b/freeze_transaction.go @@ -0,0 +1,53 @@ +package hedera + +import ( + "github.com/hashgraph/hedera-sdk-go/proto" + "time" +) + +type FreezeTransaction struct { + Transaction + pb *proto.FreezeTransactionBody +} + +func NewFreezeTransaction() *FreezeTransaction { + pb := &proto.FreezeTransactionBody{} + + transaction := FreezeTransaction{ + pb: pb, + Transaction: newTransaction(), + } + + return &transaction +} + +func (transaction *FreezeTransaction) SetStartTime(startTime time.Time) *FreezeTransaction { + transaction.pb.StartHour = int32(startTime.Hour()) + transaction.pb.StartMin = int32(startTime.Minute()) + return transaction +} + +func (transaction *FreezeTransaction) GetStartTime() time.Time { + t1 := time.Date( + time.Now().Year(), time.Now().Month(), time.Now().Day(), + int(transaction.pb.StartHour), int(transaction.pb.StartMin), + 0, time.Now().Nanosecond(), time.Now().Location(), + ) + return t1 +} + +func (transaction *FreezeTransaction) SetEndTime(endTime time.Time) *FreezeTransaction { + transaction.pb.StartHour = int32(endTime.Hour()) + transaction.pb.StartMin = int32(endTime.Minute()) + return transaction +} + +func (transaction *FreezeTransaction) GetEndTime() time.Time { + t1 := time.Date( + time.Now().Year(), time.Now().Month(), time.Now().Day(), + int(transaction.pb.EndHour), int(transaction.pb.EndMin), + 0, time.Now().Nanosecond(), time.Now().Location(), + ) + return t1 +} +