github.com/hashgraph/hedera-sdk-go/v2@v2.48.0/transaction.go (about) 1 package hedera 2 3 /*- 4 * 5 * Hedera Go SDK 6 * 7 * Copyright (C) 2020 - 2024 Hedera Hashgraph, LLC 8 * 9 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * you may not use this file except in compliance with the License. 11 * You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 * 21 */ 22 23 import ( 24 "bytes" 25 "crypto/sha512" 26 "fmt" 27 "reflect" 28 29 "github.com/pkg/errors" 30 31 "time" 32 33 "github.com/hashgraph/hedera-protobufs-go/sdk" 34 "github.com/hashgraph/hedera-protobufs-go/services" 35 protobuf "google.golang.org/protobuf/proto" 36 ) 37 38 // transaction contains the protobuf of a prepared transaction which can be signed and executed. 39 40 type ITransaction interface { 41 _ConstructScheduleProtobuf() (*services.SchedulableTransactionBody, error) 42 } 43 44 type TransactionInterface interface { 45 Executable 46 47 build() *services.TransactionBody 48 buildScheduled() (*services.SchedulableTransactionBody, error) 49 preFreezeWith(*Client) 50 regenerateID(*Client) bool 51 } 52 53 // Transaction is base struct for all transactions that may be built and submitted to Hedera. 54 type Transaction struct { 55 executable 56 57 transactionFee uint64 58 defaultMaxTransactionFee uint64 59 memo string 60 transactionValidDuration *time.Duration 61 transactionID TransactionID 62 63 transactions *_LockableSlice 64 signedTransactions *_LockableSlice 65 66 publicKeys []PublicKey 67 transactionSigners []TransactionSigner 68 69 freezeError error 70 71 regenerateTransactionID bool 72 } 73 74 func _NewTransaction() Transaction { 75 duration := 120 * time.Second 76 minBackoff := 250 * time.Millisecond 77 maxBackoff := 8 * time.Second 78 return Transaction{ 79 transactionValidDuration: &duration, 80 transactions: _NewLockableSlice(), 81 signedTransactions: _NewLockableSlice(), 82 freezeError: nil, 83 regenerateTransactionID: true, 84 executable: executable{ 85 transactionIDs: _NewLockableSlice(), 86 nodeAccountIDs: _NewLockableSlice(), 87 minBackoff: &minBackoff, 88 maxBackoff: &maxBackoff, 89 maxRetry: 10, 90 }, 91 } 92 } 93 94 func (tx *Transaction) GetSignedTransactionBodyBytes(transactionIndex int) []byte { 95 return tx.signedTransactions._Get(transactionIndex).(*services.SignedTransaction).GetBodyBytes() 96 } 97 98 // TransactionFromBytes converts transaction bytes to a related *transaction. 99 func TransactionFromBytes(data []byte) (interface{}, error) { // nolint 100 list := sdk.TransactionList{} 101 minBackoff := 250 * time.Millisecond 102 maxBackoff := 8 * time.Second 103 err := protobuf.Unmarshal(data, &list) 104 if err != nil { 105 return Transaction{}, errors.Wrap(err, "error deserializing from bytes to transaction List") 106 } 107 108 transactions := _NewLockableSlice() 109 110 for _, transaction := range list.TransactionList { 111 transactions._Push(transaction) 112 } 113 114 tx := Transaction{ 115 transactions: transactions, 116 signedTransactions: _NewLockableSlice(), 117 publicKeys: make([]PublicKey, 0), 118 transactionSigners: make([]TransactionSigner, 0), 119 freezeError: nil, 120 regenerateTransactionID: true, 121 executable: executable{ 122 transactionIDs: _NewLockableSlice(), 123 nodeAccountIDs: _NewLockableSlice(), 124 minBackoff: &minBackoff, 125 maxBackoff: &maxBackoff, 126 maxRetry: 10, 127 }, 128 } 129 130 comp, err := _TransactionCompare(&list) 131 if err != nil { 132 return Transaction{}, err 133 } 134 135 if !comp { 136 return Transaction{}, errors.New("failed to validate transaction bodies") 137 } 138 139 var first *services.TransactionBody = nil 140 // We introduce a boolean value to distinguish flow for signed tx vs unsigned transactions 141 txIsSigned := true 142 143 for i, transactionFromList := range list.TransactionList { 144 var signedTransaction services.SignedTransaction 145 var body services.TransactionBody 146 147 // If the transaction is not signed/locked: 148 if len(transactionFromList.SignedTransactionBytes) == 0 { 149 txIsSigned = false 150 if err := protobuf.Unmarshal(transactionFromList.BodyBytes, &body); err != nil { // nolint 151 return Transaction{}, errors.Wrap(err, "error deserializing BodyBytes in TransactionFromBytes") 152 } 153 } else { // If the transaction is signed/locked 154 if err := protobuf.Unmarshal(transactionFromList.SignedTransactionBytes, &signedTransaction); err != nil { 155 return Transaction{}, errors.Wrap(err, "error deserializing SignedTransactionBytes in TransactionFromBytes") 156 } 157 } 158 159 if txIsSigned { 160 tx.signedTransactions = tx.signedTransactions._Push(&signedTransaction) 161 162 if i == 0 { 163 for _, sigPair := range signedTransaction.GetSigMap().GetSigPair() { 164 key, err := PublicKeyFromBytes(sigPair.GetPubKeyPrefix()) 165 if err != nil { 166 return Transaction{}, err 167 } 168 169 tx.publicKeys = append(tx.publicKeys, key) 170 tx.transactionSigners = append(tx.transactionSigners, nil) 171 } 172 } 173 174 if err := protobuf.Unmarshal(signedTransaction.GetBodyBytes(), &body); err != nil { 175 return Transaction{}, errors.Wrap(err, "error deserializing BodyBytes in TransactionFromBytes") 176 } 177 } 178 179 if first == nil { 180 first = &body 181 } 182 var transactionID TransactionID 183 var nodeAccountID AccountID 184 185 if body.GetTransactionValidDuration() != nil { 186 duration := _DurationFromProtobuf(body.GetTransactionValidDuration()) 187 tx.transactionValidDuration = &duration 188 } 189 190 if body.GetTransactionID() != nil { 191 transactionID = _TransactionIDFromProtobuf(body.GetTransactionID()) 192 } 193 194 if body.GetNodeAccountID() != nil { 195 nodeAccountID = *_AccountIDFromProtobuf(body.GetNodeAccountID()) 196 } 197 198 // If the transaction was serialised, without setting "NodeId", or "TransactionID", we should leave them empty 199 if transactionID.AccountID.Account != 0 { 200 tx.transactionIDs = tx.transactionIDs._Push(transactionID) 201 } 202 if !nodeAccountID._IsZero() { 203 tx.nodeAccountIDs = tx.nodeAccountIDs._Push(nodeAccountID) 204 } 205 206 if i == 0 { 207 tx.memo = body.Memo 208 if body.TransactionFee != 0 { 209 tx.transactionFee = body.TransactionFee 210 } 211 } 212 } 213 214 if txIsSigned { 215 if tx.transactionIDs._Length() > 0 { 216 tx.transactionIDs.locked = true 217 } 218 219 if tx.nodeAccountIDs._Length() > 0 { 220 tx.nodeAccountIDs.locked = true 221 } 222 } 223 224 if first == nil { 225 return nil, errNoTransactionInBytes 226 } 227 228 switch first.Data.(type) { 229 case *services.TransactionBody_ContractCall: 230 return *_ContractExecuteTransactionFromProtobuf(tx, first), nil 231 case *services.TransactionBody_ContractCreateInstance: 232 return *_ContractCreateTransactionFromProtobuf(tx, first), nil 233 case *services.TransactionBody_ContractUpdateInstance: 234 return *_ContractUpdateTransactionFromProtobuf(tx, first), nil 235 case *services.TransactionBody_ContractDeleteInstance: 236 return *_ContractDeleteTransactionFromProtobuf(tx, first), nil 237 case *services.TransactionBody_CryptoAddLiveHash: 238 return *_LiveHashAddTransactionFromProtobuf(tx, first), nil 239 case *services.TransactionBody_CryptoCreateAccount: 240 return *_AccountCreateTransactionFromProtobuf(tx, first), nil 241 case *services.TransactionBody_CryptoDelete: 242 return *_AccountDeleteTransactionFromProtobuf(tx, first), nil 243 case *services.TransactionBody_CryptoDeleteLiveHash: 244 return *_LiveHashDeleteTransactionFromProtobuf(tx, first), nil 245 case *services.TransactionBody_CryptoTransfer: 246 return *_TransferTransactionFromProtobuf(tx, first), nil 247 case *services.TransactionBody_CryptoUpdateAccount: 248 return *_AccountUpdateTransactionFromProtobuf(tx, first), nil 249 case *services.TransactionBody_CryptoApproveAllowance: 250 return *_AccountAllowanceApproveTransactionFromProtobuf(tx, first), nil 251 case *services.TransactionBody_CryptoDeleteAllowance: 252 return *_AccountAllowanceDeleteTransactionFromProtobuf(tx, first), nil 253 case *services.TransactionBody_FileAppend: 254 return *_FileAppendTransactionFromProtobuf(tx, first), nil 255 case *services.TransactionBody_FileCreate: 256 return *_FileCreateTransactionFromProtobuf(tx, first), nil 257 case *services.TransactionBody_FileDelete: 258 return *_FileDeleteTransactionFromProtobuf(tx, first), nil 259 case *services.TransactionBody_FileUpdate: 260 return *_FileUpdateTransactionFromProtobuf(tx, first), nil 261 case *services.TransactionBody_SystemDelete: 262 return *_SystemDeleteTransactionFromProtobuf(tx, first), nil 263 case *services.TransactionBody_SystemUndelete: 264 return *_SystemUndeleteTransactionFromProtobuf(tx, first), nil 265 case *services.TransactionBody_Freeze: 266 return *_FreezeTransactionFromProtobuf(tx, first), nil 267 case *services.TransactionBody_ConsensusCreateTopic: 268 return *_TopicCreateTransactionFromProtobuf(tx, first), nil 269 case *services.TransactionBody_ConsensusUpdateTopic: 270 return *_TopicUpdateTransactionFromProtobuf(tx, first), nil 271 case *services.TransactionBody_ConsensusDeleteTopic: 272 return *_TopicDeleteTransactionFromProtobuf(tx, first), nil 273 case *services.TransactionBody_ConsensusSubmitMessage: 274 return *_TopicMessageSubmitTransactionFromProtobuf(tx, first), nil 275 case *services.TransactionBody_TokenCreation: 276 return *_TokenCreateTransactionFromProtobuf(tx, first), nil 277 case *services.TransactionBody_TokenFreeze: 278 return *_TokenFreezeTransactionFromProtobuf(tx, first), nil 279 case *services.TransactionBody_TokenUnfreeze: 280 return *_TokenUnfreezeTransactionFromProtobuf(tx, first), nil 281 case *services.TransactionBody_TokenGrantKyc: 282 return *_TokenGrantKycTransactionFromProtobuf(tx, first), nil 283 case *services.TransactionBody_TokenRevokeKyc: 284 return *_TokenRevokeKycTransactionFromProtobuf(tx, first), nil 285 case *services.TransactionBody_TokenDeletion: 286 return *_TokenDeleteTransactionFromProtobuf(tx, first), nil 287 case *services.TransactionBody_TokenUpdate: 288 return *_TokenUpdateTransactionFromProtobuf(tx, first), nil 289 case *services.TransactionBody_TokenMint: 290 return *_TokenMintTransactionFromProtobuf(tx, first), nil 291 case *services.TransactionBody_TokenBurn: 292 return *_TokenBurnTransactionFromProtobuf(tx, first), nil 293 case *services.TransactionBody_TokenWipe: 294 return *_TokenWipeTransactionFromProtobuf(tx, first), nil 295 case *services.TransactionBody_TokenAssociate: 296 return *_TokenAssociateTransactionFromProtobuf(tx, first), nil 297 case *services.TransactionBody_TokenDissociate: 298 return *_TokenDissociateTransactionFromProtobuf(tx, first), nil 299 case *services.TransactionBody_ScheduleCreate: 300 return *_ScheduleCreateTransactionFromProtobuf(tx, first), nil 301 case *services.TransactionBody_ScheduleSign: 302 return *_ScheduleSignTransactionFromProtobuf(tx, first), nil 303 case *services.TransactionBody_ScheduleDelete: 304 return *_ScheduleDeleteTransactionFromProtobuf(tx, first), nil 305 case *services.TransactionBody_TokenFeeScheduleUpdate: 306 return *_TokenFeeScheduleUpdateTransactionFromProtobuf(tx, first), nil 307 case *services.TransactionBody_TokenPause: 308 return *_TokenPauseTransactionFromProtobuf(tx, first), nil 309 case *services.TransactionBody_TokenUnpause: 310 return *_TokenUnpauseTransactionFromProtobuf(tx, first), nil 311 case *services.TransactionBody_EthereumTransaction: 312 return *_EthereumTransactionFromProtobuf(tx, first), nil 313 case *services.TransactionBody_UtilPrng: 314 return *_PrngTransactionFromProtobuf(tx, first), nil 315 case *services.TransactionBody_TokenUpdateNfts: 316 return *_NewTokenUpdateNftsTransactionFromProtobuf(tx, first), nil 317 case *services.TransactionBody_TokenReject: 318 return *_TokenRejectTransactionFromProtobuf(tx, first), nil 319 case *services.TransactionBody_NodeCreate: 320 return *_NodeCreateTransactionFromProtobuf(tx, first), nil 321 case *services.TransactionBody_NodeUpdate: 322 return *_NodeUpdateTransactionFromProtobuf(tx, first), nil 323 case *services.TransactionBody_NodeDelete: 324 return *_NodeDeleteTransactionFromProtobuf(tx, first), nil 325 case *services.TransactionBody_TokenAirdrop: 326 return *_TokenAirdropTransactionFromProtobuf(tx, first), nil 327 case *services.TransactionBody_TokenClaimAirdrop: 328 return *_TokenClaimAirdropTransactionFromProtobuf(tx, first), nil 329 case *services.TransactionBody_TokenCancelAirdrop: 330 return *_TokenCancelAirdropTransactionFromProtobuf(tx, first), nil 331 default: 332 return Transaction{}, errFailedToDeserializeBytes 333 } 334 } 335 336 func _TransactionCompare(list *sdk.TransactionList) (bool, error) { 337 signed := make([]*services.SignedTransaction, 0) 338 var err error 339 for _, s := range list.TransactionList { 340 temp := services.SignedTransaction{} 341 err = protobuf.Unmarshal(s.SignedTransactionBytes, &temp) 342 if err != nil { 343 return false, err 344 } 345 signed = append(signed, &temp) 346 } 347 body := make([]*services.TransactionBody, 0) 348 for _, s := range signed { 349 temp := services.TransactionBody{} 350 err = protobuf.Unmarshal(s.BodyBytes, &temp) 351 if err != nil { 352 return false, err 353 } 354 body = append(body, &temp) 355 } 356 357 for i := 1; i < len(body); i++ { 358 // #nosec G602 359 if reflect.TypeOf(body[0].Data) != reflect.TypeOf(body[i].Data) { 360 return false, nil 361 } 362 } 363 364 return true, nil 365 } 366 367 // GetSignatures Gets all of the signatures stored in the transaction 368 func (tx *Transaction) GetSignatures() (map[AccountID]map[*PublicKey][]byte, error) { 369 returnMap := make(map[AccountID]map[*PublicKey][]byte, tx.nodeAccountIDs._Length()) 370 371 if tx.signedTransactions._Length() == 0 { 372 return returnMap, nil 373 } 374 375 for i, nodeID := range tx.nodeAccountIDs.slice { 376 var sigMap *services.SignatureMap 377 var tempID AccountID 378 switch k := tx.signedTransactions._Get(i).(type) { //nolint 379 case *services.SignedTransaction: 380 sigMap = k.SigMap 381 } 382 383 switch k := nodeID.(type) { //nolint 384 case AccountID: 385 tempID = k 386 } 387 inner := make(map[*PublicKey][]byte, len(sigMap.SigPair)) 388 389 for _, sigPair := range sigMap.SigPair { 390 key, err := PublicKeyFromBytes(sigPair.PubKeyPrefix) 391 if err != nil { 392 return make(map[AccountID]map[*PublicKey][]byte), err 393 } 394 switch sigPair.Signature.(type) { 395 case *services.SignaturePair_Contract: 396 inner[&key] = sigPair.GetContract() 397 case *services.SignaturePair_Ed25519: 398 inner[&key] = sigPair.GetEd25519() 399 case *services.SignaturePair_RSA_3072: 400 inner[&key] = sigPair.GetRSA_3072() 401 case *services.SignaturePair_ECDSA_384: 402 inner[&key] = sigPair.GetECDSA_384() 403 } 404 } 405 406 returnMap[tempID] = inner 407 } 408 tx.transactionIDs.locked = true 409 410 return returnMap, nil 411 } 412 413 func (tx *Transaction) GetTransactionHash() ([]byte, error) { 414 current, err := tx._BuildTransaction(0) 415 if err != nil { 416 return nil, err 417 } 418 hash := sha512.New384() 419 _, err = hash.Write(current.GetSignedTransactionBytes()) 420 if err != nil { 421 return nil, err 422 } 423 424 return hash.Sum(nil), nil 425 } 426 427 func (tx *Transaction) GetTransactionHashPerNode() (map[AccountID][]byte, error) { 428 transactionHash := make(map[AccountID][]byte) 429 if !tx.IsFrozen() { 430 return transactionHash, errTransactionIsNotFrozen 431 } 432 433 allTx, err := tx._BuildAllTransactions() 434 if err != nil { 435 return transactionHash, err 436 } 437 tx.transactionIDs.locked = true 438 439 for i, node := range tx.nodeAccountIDs.slice { 440 switch n := node.(type) { //nolint 441 case AccountID: 442 hash := sha512.New384() 443 _, err := hash.Write(allTx[i].GetSignedTransactionBytes()) 444 if err != nil { 445 return transactionHash, err 446 } 447 448 finalHash := hash.Sum(nil) 449 450 transactionHash[n] = finalHash 451 } 452 } 453 454 return transactionHash, nil 455 } 456 457 // Sets the maxTransaction fee based on priority: 458 // 1. Explicitly set for this Transaction 459 // 2. Client has a default value set for all transactions 460 // 3. The default for this type of Transaction, which is set during creation 461 func (tx *Transaction) _InitFee(client *Client) { 462 if tx.transactionFee == 0 { 463 if client != nil && client.GetDefaultMaxTransactionFee().AsTinybar() != 0 { 464 tx.SetMaxTransactionFee(client.GetDefaultMaxTransactionFee()) 465 } else { 466 tx.SetMaxTransactionFee(tx.GetDefaultMaxTransactionFee()) 467 } 468 } 469 } 470 471 func (tx *Transaction) _InitTransactionID(client *Client) error { 472 if tx.transactionIDs._Length() == 0 { 473 if client != nil { 474 if client.operator != nil { 475 tx.transactionIDs = _NewLockableSlice() 476 tx.transactionIDs = tx.transactionIDs._Push(TransactionIDGenerate(client.operator.accountID)) 477 } else { 478 return errNoClientOrTransactionID 479 } 480 } else { 481 return errNoClientOrTransactionID 482 } 483 } 484 485 tx.transactionID = tx.transactionIDs._GetCurrent().(TransactionID) 486 return nil 487 } 488 489 func (tx *Transaction) IsFrozen() bool { 490 return tx.signedTransactions._Length() > 0 491 } 492 493 func (tx *Transaction) _RequireFrozen() { 494 if !tx.IsFrozen() { 495 tx.freezeError = errTransactionIsNotFrozen 496 } 497 } 498 499 func (tx *Transaction) _RequireNotFrozen() { 500 if tx.IsFrozen() { 501 tx.freezeError = errTransactionIsFrozen 502 } 503 } 504 505 func (tx *Transaction) _RequireOneNodeAccountID() { 506 if tx.nodeAccountIDs._Length() != 1 { 507 panic("transaction has more than one _Node ID set") 508 } 509 } 510 511 func _TransactionFreezeWith( 512 transaction *Transaction, 513 client *Client, 514 body *services.TransactionBody, 515 ) error { 516 if transaction.nodeAccountIDs._IsEmpty() { 517 if client != nil { 518 for _, nodeAccountID := range client.network._GetNodeAccountIDsForExecute() { 519 transaction.nodeAccountIDs._Push(nodeAccountID) 520 } 521 } else { 522 return errNoClientOrTransactionIDOrNodeId 523 } 524 } 525 526 if client != nil { 527 if client.defaultRegenerateTransactionIDs != transaction.regenerateTransactionID { 528 transaction.regenerateTransactionID = client.defaultRegenerateTransactionIDs 529 } 530 } 531 532 for _, nodeAccountID := range transaction.nodeAccountIDs.slice { 533 body.NodeAccountID = nodeAccountID.(AccountID)._ToProtobuf() 534 bodyBytes, err := protobuf.Marshal(body) 535 536 if err != nil { 537 // This should be unreachable 538 // From the documentation this appears to only be possible if there are missing proto types 539 panic(err) 540 } 541 transaction.signedTransactions = transaction.signedTransactions._Push(&services.SignedTransaction{ 542 BodyBytes: bodyBytes, 543 SigMap: &services.SignatureMap{ 544 SigPair: make([]*services.SignaturePair, 0), 545 }, 546 }) 547 } 548 549 return nil 550 } 551 552 func (tx *Transaction) _SignWith( 553 publicKey PublicKey, 554 signer TransactionSigner, 555 ) { 556 tx.transactions = _NewLockableSlice() 557 tx.publicKeys = append(tx.publicKeys, publicKey) 558 tx.transactionSigners = append(tx.transactionSigners, signer) 559 } 560 561 func (tx *Transaction) _KeyAlreadySigned( 562 pk PublicKey, 563 ) bool { 564 for _, key := range tx.publicKeys { 565 if key.String() == pk.String() { 566 return true 567 } 568 } 569 570 return false 571 } 572 573 // String returns a string representation of the transaction 574 func (tx *Transaction) String() string { 575 switch sig := tx.signedTransactions._Get(0).(type) { //nolint 576 case *services.SignedTransaction: 577 return fmt.Sprintf("%+v", sig) 578 } 579 580 return "" 581 } 582 583 // ToBytes Builds then converts the current transaction to []byte 584 // Requires transaction to be frozen 585 func (tx *Transaction) ToBytes() ([]byte, error) { 586 return tx.toBytes(tx) 587 } 588 589 func (tx *Transaction) toBytes(e TransactionInterface) ([]byte, error) { 590 var pbTransactionList []byte 591 var allTx []*services.Transaction 592 var err error 593 // If transaction is frozen, build all transactions and "signedTransactions" 594 if tx.IsFrozen() { 595 allTx, err = tx._BuildAllTransactions() 596 tx.transactionIDs.locked = true 597 } else { // Build only onlt "BodyBytes" for each transaction in the list 598 allTx, err = tx.buildAllUnsignedTransactions(e) 599 } 600 // If error has occurred, when building transactions 601 if err != nil { 602 return make([]byte, 0), err 603 } 604 605 pbTransactionList, err = protobuf.Marshal(&sdk.TransactionList{ 606 TransactionList: allTx, 607 }) 608 if err != nil { 609 return make([]byte, 0), errors.Wrap(err, "error serializing tx list") 610 } 611 return pbTransactionList, nil 612 } 613 614 func (tx *Transaction) buildAllUnsignedTransactions(e TransactionInterface) ([]*services.Transaction, error) { 615 // All unsigned transactions would always be exactly 1 616 allTx := make([]*services.Transaction, 0) 617 if tx.nodeAccountIDs._IsEmpty() { 618 t, err := tx.buildUnsignedTransaction(e, 0) 619 if err != nil { 620 return allTx, err 621 } 622 allTx = append(allTx, t) 623 } else { // If we have set some node account ids, we have to make one transaction copy per node account 624 for range tx.nodeAccountIDs.slice { 625 t, err := tx.buildUnsignedTransaction(e, tx.nodeAccountIDs.index) 626 tx.nodeAccountIDs._Advance() 627 if err != nil { 628 return allTx, err 629 } 630 allTx = append(allTx, t) 631 } 632 } 633 return allTx, nil 634 } 635 636 func (tx *Transaction) buildUnsignedTransaction(e TransactionInterface, index int) (*services.Transaction, error) { 637 body := e.build() 638 if body.NodeAccountID == nil && !tx.nodeAccountIDs._IsEmpty() { 639 body.NodeAccountID = tx.nodeAccountIDs._Get(index).(AccountID)._ToProtobuf() 640 } 641 642 bodyBytes, err := protobuf.Marshal(body) 643 if err != nil { 644 return &services.Transaction{}, errors.Wrap(err, "failed to update tx ID") 645 } 646 647 return &services.Transaction{BodyBytes: bodyBytes}, nil 648 } 649 650 func (tx *Transaction) _SignTransaction(index int) { 651 initialTx := tx.signedTransactions._Get(index).(*services.SignedTransaction) 652 bodyBytes := initialTx.GetBodyBytes() 653 if len(initialTx.SigMap.SigPair) != 0 { 654 for i, key := range tx.publicKeys { 655 if tx.transactionSigners[i] != nil { 656 if key.ed25519PublicKey != nil { 657 if bytes.Equal(initialTx.SigMap.SigPair[0].PubKeyPrefix, key.ed25519PublicKey.keyData) { 658 if !tx.regenerateTransactionID { 659 return 660 } 661 switch t := initialTx.SigMap.SigPair[0].Signature.(type) { //nolint 662 case *services.SignaturePair_Ed25519: 663 if bytes.Equal(t.Ed25519, tx.transactionSigners[0](bodyBytes)) && len(t.Ed25519) > 0 { 664 return 665 } 666 } 667 } 668 } 669 if key.ecdsaPublicKey != nil { 670 if bytes.Equal(initialTx.SigMap.SigPair[0].PubKeyPrefix, key.ecdsaPublicKey._BytesRaw()) { 671 if !tx.regenerateTransactionID { 672 return 673 } 674 switch t := initialTx.SigMap.SigPair[0].Signature.(type) { //nolint 675 case *services.SignaturePair_ECDSASecp256K1: 676 if bytes.Equal(t.ECDSASecp256K1, tx.transactionSigners[0](bodyBytes)) && len(t.ECDSASecp256K1) > 0 { 677 return 678 } 679 } 680 } 681 } 682 } 683 } 684 } 685 686 if tx.regenerateTransactionID && !tx.transactionIDs.locked { 687 modifiedTx := tx.signedTransactions._Get(index).(*services.SignedTransaction) 688 modifiedTx.SigMap.SigPair = make([]*services.SignaturePair, 0) 689 tx.signedTransactions._Set(index, modifiedTx) 690 } 691 692 for i := 0; i < len(tx.publicKeys); i++ { 693 publicKey := tx.publicKeys[i] 694 signer := tx.transactionSigners[i] 695 696 if signer == nil { 697 continue 698 } 699 700 modifiedTx := tx.signedTransactions._Get(index).(*services.SignedTransaction) 701 modifiedTx.SigMap.SigPair = append(modifiedTx.SigMap.SigPair, publicKey._ToSignaturePairProtobuf(signer(bodyBytes))) 702 tx.signedTransactions._Set(index, modifiedTx) 703 } 704 } 705 706 func (tx *Transaction) _BuildAllTransactions() ([]*services.Transaction, error) { 707 allTx := make([]*services.Transaction, 0) 708 for i := 0; i < tx.signedTransactions._Length(); i++ { 709 curr, err := tx._BuildTransaction(i) 710 tx.transactionIDs._Advance() 711 if err != nil { 712 return []*services.Transaction{}, err 713 } 714 allTx = append(allTx, curr) 715 } 716 717 return allTx, nil 718 } 719 720 func (tx *Transaction) _BuildTransaction(index int) (*services.Transaction, error) { 721 signedTx := tx.signedTransactions._Get(index).(*services.SignedTransaction) 722 723 txID := tx.transactionIDs._GetCurrent().(TransactionID) 724 originalBody := services.TransactionBody{} 725 _ = protobuf.Unmarshal(signedTx.BodyBytes, &originalBody) 726 727 if originalBody.NodeAccountID == nil { 728 originalBody.NodeAccountID = tx.nodeAccountIDs._GetCurrent().(AccountID)._ToProtobuf() 729 } 730 731 if originalBody.TransactionID.String() != txID._ToProtobuf().String() { 732 originalBody.TransactionID = txID._ToProtobuf() 733 } 734 735 originalBody.Memo = tx.memo 736 if tx.transactionFee != 0 { 737 originalBody.TransactionFee = tx.transactionFee 738 } else { 739 originalBody.TransactionFee = tx.defaultMaxTransactionFee 740 } 741 742 updatedBody, err := protobuf.Marshal(&originalBody) 743 if err != nil { 744 return &services.Transaction{}, errors.Wrap(err, "failed to update tx ID") 745 } 746 747 // Bellow are checks whether we need to sign the transaction or we already have the same signed 748 if bytes.Equal(signedTx.BodyBytes, updatedBody) { 749 sigPairLen := len(signedTx.SigMap.GetSigPair()) 750 // For cases where we need more than 1 signature 751 if sigPairLen > 0 && sigPairLen == len(tx.publicKeys) { 752 data, err := protobuf.Marshal(signedTx) 753 if err != nil { 754 return &services.Transaction{}, errors.Wrap(err, "failed to serialize transactions for building") 755 } 756 transaction := &services.Transaction{ 757 SignedTransactionBytes: data, 758 } 759 760 return transaction, nil 761 } 762 } 763 764 signedTx.BodyBytes = updatedBody 765 tx.signedTransactions._Set(index, signedTx) 766 tx._SignTransaction(index) 767 768 signed := tx.signedTransactions._Get(index).(*services.SignedTransaction) 769 data, err := protobuf.Marshal(signed) 770 if err != nil { 771 return &services.Transaction{}, errors.Wrap(err, "failed to serialize transactions for building") 772 } 773 774 transaction := &services.Transaction{ 775 SignedTransactionBytes: data, 776 } 777 778 return transaction, nil 779 } 780 781 // 782 // Shared 783 // 784 785 // GetMaxTransactionFee returns the maximum transaction fee the operator (paying account) is willing to pay. 786 func (tx *Transaction) GetMaxTransactionFee() Hbar { 787 return HbarFromTinybar(int64(tx.transactionFee)) 788 } 789 790 // SetMaxTransactionFee sets the maximum transaction fee the operator (paying account) is willing to pay. 791 func (tx *Transaction) SetMaxTransactionFee(fee Hbar) *Transaction { 792 tx.transactionFee = uint64(fee.AsTinybar()) 793 return tx 794 } 795 func (tx *Transaction) GetDefaultMaxTransactionFee() Hbar { 796 return HbarFromTinybar(int64(tx.defaultMaxTransactionFee)) 797 } 798 799 // SetMaxTransactionFee sets the max Transaction fee for this Transaction. 800 func (tx *Transaction) _SetDefaultMaxTransactionFee(fee Hbar) { 801 tx.defaultMaxTransactionFee = uint64(fee.AsTinybar()) 802 } 803 804 // GetRegenerateTransactionID returns true if transaction ID regeneration is enabled 805 func (tx *Transaction) GetRegenerateTransactionID() bool { 806 return tx.regenerateTransactionID 807 } 808 809 // SetRegenerateTransactionID sets if transaction IDs should be regenerated when \`TRANSACTION_EXPIRED\` is received 810 func (tx *Transaction) SetRegenerateTransactionID(regenerateTransactionID bool) *Transaction { 811 tx.regenerateTransactionID = regenerateTransactionID 812 return tx 813 } 814 815 // GetTransactionMemo returns the memo for this transaction. 816 func (tx *Transaction) GetTransactionMemo() string { 817 return tx.memo 818 } 819 820 // SetTransactionMemo sets the memo for this transaction. 821 func (tx *Transaction) SetTransactionMemo(memo string) *Transaction { 822 tx.memo = memo 823 return tx 824 } 825 826 // GetTransactionValidDuration returns the duration that this transaction is valid for. 827 func (tx *Transaction) GetTransactionValidDuration() time.Duration { 828 if tx.transactionValidDuration != nil { 829 return *tx.transactionValidDuration 830 } 831 832 return 0 833 } 834 835 // SetTransactionValidDuration sets the valid duration for this transaction. 836 func (tx *Transaction) SetTransactionValidDuration(duration time.Duration) *Transaction { 837 tx.transactionValidDuration = &duration 838 return tx 839 } 840 841 // GetTransactionID gets the TransactionID for this transaction. 842 func (tx *Transaction) GetTransactionID() TransactionID { 843 if tx.transactionIDs._Length() > 0 { 844 t := tx.transactionIDs._GetCurrent().(TransactionID) 845 return t 846 } 847 848 return TransactionID{} 849 } 850 851 // SetTransactionID sets the TransactionID for this transaction. 852 func (tx *Transaction) SetTransactionID(transactionID TransactionID) *Transaction { 853 tx.transactionIDs._Clear()._Push(transactionID)._SetLocked(true) 854 return tx 855 } 856 857 // SetNodeAccountIDs sets the node AccountID for this transaction. 858 func (tx *Transaction) SetNodeAccountIDs(nodeAccountIDs []AccountID) *Transaction { 859 for _, nodeAccountID := range nodeAccountIDs { 860 tx.nodeAccountIDs._Push(nodeAccountID) 861 } 862 tx.nodeAccountIDs._SetLocked(true) 863 return tx 864 } 865 866 // ------------ Transaction methdos --------------- 867 func (tx *Transaction) Sign(privateKey PrivateKey) TransactionInterface { 868 return tx.SignWith(privateKey.PublicKey(), privateKey.Sign) 869 } 870 func (tx *Transaction) signWithOperator(client *Client, e TransactionInterface) (TransactionInterface, error) { // nolint 871 // If the transaction is not signed by the _Operator, we need 872 // to sign the transaction with the _Operator 873 if client == nil { 874 return nil, errNoClientProvided 875 } else if client.operator == nil { 876 return nil, errClientOperatorSigning 877 } 878 879 if !tx.IsFrozen() { 880 _, err := tx.freezeWith(client, e) 881 if err != nil { 882 return tx, err 883 } 884 } 885 return tx.SignWith(client.operator.publicKey, client.operator.signer), nil 886 } 887 func (tx *Transaction) SignWith(publicKey PublicKey, signer TransactionSigner) TransactionInterface { 888 // We need to make sure the request is frozen 889 tx._RequireFrozen() 890 891 if !tx._KeyAlreadySigned(publicKey) { 892 tx._SignWith(publicKey, signer) 893 } 894 895 return tx 896 } 897 func (tx *Transaction) AddSignature(publicKey PublicKey, signature []byte) TransactionInterface { 898 tx._RequireOneNodeAccountID() 899 900 if tx._KeyAlreadySigned(publicKey) { 901 return tx 902 } 903 904 if tx.signedTransactions._Length() == 0 { 905 return tx 906 } 907 908 tx.transactions = _NewLockableSlice() 909 tx.publicKeys = append(tx.publicKeys, publicKey) 910 tx.transactionSigners = append(tx.transactionSigners, nil) 911 tx.transactionIDs.locked = true 912 913 for index := 0; index < tx.signedTransactions._Length(); index++ { 914 var temp *services.SignedTransaction 915 switch t := tx.signedTransactions._Get(index).(type) { //nolint 916 case *services.SignedTransaction: 917 temp = t 918 } 919 temp.SigMap.SigPair = append( 920 temp.SigMap.SigPair, 921 publicKey._ToSignaturePairProtobuf(signature), 922 ) 923 tx.signedTransactions._Set(index, temp) 924 } 925 926 return tx 927 } 928 929 // Building empty object as "default" implementation. All inhertents must implement their own implementation. 930 func (tx *Transaction) build() *services.TransactionBody { 931 return &services.TransactionBody{} 932 } 933 934 // Building empty object as "default" implementation. All inhertents must implement their own implementation. 935 func (tx *Transaction) buildScheduled() (*services.SchedulableTransactionBody, error) { 936 return &services.SchedulableTransactionBody{}, nil 937 } 938 939 // ------------------------------------- 940 941 func TransactionSign(transaction interface{}, privateKey PrivateKey) (interface{}, error) { // nolint 942 switch i := transaction.(type) { 943 case AccountCreateTransaction: 944 return i.Sign(privateKey), nil 945 case AccountDeleteTransaction: 946 return i.Sign(privateKey), nil 947 case AccountUpdateTransaction: 948 return i.Sign(privateKey), nil 949 case AccountAllowanceApproveTransaction: 950 return i.Sign(privateKey), nil 951 case AccountAllowanceDeleteTransaction: 952 return i.Sign(privateKey), nil 953 case ContractCreateTransaction: 954 return i.Sign(privateKey), nil 955 case ContractDeleteTransaction: 956 return i.Sign(privateKey), nil 957 case ContractExecuteTransaction: 958 return i.Sign(privateKey), nil 959 case ContractUpdateTransaction: 960 return i.Sign(privateKey), nil 961 case FileAppendTransaction: 962 return i.Sign(privateKey), nil 963 case FileCreateTransaction: 964 return i.Sign(privateKey), nil 965 case FileDeleteTransaction: 966 return i.Sign(privateKey), nil 967 case FileUpdateTransaction: 968 return i.Sign(privateKey), nil 969 case LiveHashAddTransaction: 970 return i.Sign(privateKey), nil 971 case LiveHashDeleteTransaction: 972 return i.Sign(privateKey), nil 973 case ScheduleCreateTransaction: 974 return i.Sign(privateKey), nil 975 case ScheduleDeleteTransaction: 976 return i.Sign(privateKey), nil 977 case ScheduleSignTransaction: 978 return i.Sign(privateKey), nil 979 case SystemDeleteTransaction: 980 return i.Sign(privateKey), nil 981 case SystemUndeleteTransaction: 982 return i.Sign(privateKey), nil 983 case TokenAssociateTransaction: 984 return i.Sign(privateKey), nil 985 case TokenBurnTransaction: 986 return i.Sign(privateKey), nil 987 case TokenCreateTransaction: 988 return i.Sign(privateKey), nil 989 case TokenDeleteTransaction: 990 return i.Sign(privateKey), nil 991 case TokenDissociateTransaction: 992 return i.Sign(privateKey), nil 993 case TokenFeeScheduleUpdateTransaction: 994 return i.Sign(privateKey), nil 995 case TokenFreezeTransaction: 996 return i.Sign(privateKey), nil 997 case TokenGrantKycTransaction: 998 return i.Sign(privateKey), nil 999 case TokenMintTransaction: 1000 return i.Sign(privateKey), nil 1001 case TokenRevokeKycTransaction: 1002 return i.Sign(privateKey), nil 1003 case TokenUnfreezeTransaction: 1004 return i.Sign(privateKey), nil 1005 case TokenUpdateTransaction: 1006 return i.Sign(privateKey), nil 1007 case TokenWipeTransaction: 1008 return i.Sign(privateKey), nil 1009 case TopicCreateTransaction: 1010 return i.Sign(privateKey), nil 1011 case TopicDeleteTransaction: 1012 return i.Sign(privateKey), nil 1013 case TopicMessageSubmitTransaction: 1014 return i.Sign(privateKey), nil 1015 case TopicUpdateTransaction: 1016 return i.Sign(privateKey), nil 1017 case TransferTransaction: 1018 return i.Sign(privateKey), nil 1019 case *AccountCreateTransaction: 1020 return i.Sign(privateKey), nil 1021 case *AccountDeleteTransaction: 1022 return i.Sign(privateKey), nil 1023 case *AccountUpdateTransaction: 1024 return i.Sign(privateKey), nil 1025 case *AccountAllowanceApproveTransaction: 1026 return i.Sign(privateKey), nil 1027 case *AccountAllowanceDeleteTransaction: 1028 return i.Sign(privateKey), nil 1029 case *ContractCreateTransaction: 1030 return i.Sign(privateKey), nil 1031 case *ContractDeleteTransaction: 1032 return i.Sign(privateKey), nil 1033 case *ContractExecuteTransaction: 1034 return i.Sign(privateKey), nil 1035 case *ContractUpdateTransaction: 1036 return i.Sign(privateKey), nil 1037 case *FileAppendTransaction: 1038 return i.Sign(privateKey), nil 1039 case *FileCreateTransaction: 1040 return i.Sign(privateKey), nil 1041 case *FileDeleteTransaction: 1042 return i.Sign(privateKey), nil 1043 case *FileUpdateTransaction: 1044 return i.Sign(privateKey), nil 1045 case *LiveHashAddTransaction: 1046 return i.Sign(privateKey), nil 1047 case *LiveHashDeleteTransaction: 1048 return i.Sign(privateKey), nil 1049 case *ScheduleCreateTransaction: 1050 return i.Sign(privateKey), nil 1051 case *ScheduleDeleteTransaction: 1052 return i.Sign(privateKey), nil 1053 case *ScheduleSignTransaction: 1054 return i.Sign(privateKey), nil 1055 case *SystemDeleteTransaction: 1056 return i.Sign(privateKey), nil 1057 case *SystemUndeleteTransaction: 1058 return i.Sign(privateKey), nil 1059 case *TokenAssociateTransaction: 1060 return i.Sign(privateKey), nil 1061 case *TokenBurnTransaction: 1062 return i.Sign(privateKey), nil 1063 case *TokenCreateTransaction: 1064 return i.Sign(privateKey), nil 1065 case *TokenDeleteTransaction: 1066 return i.Sign(privateKey), nil 1067 case *TokenDissociateTransaction: 1068 return i.Sign(privateKey), nil 1069 case *TokenFeeScheduleUpdateTransaction: 1070 return i.Sign(privateKey), nil 1071 case *TokenFreezeTransaction: 1072 return i.Sign(privateKey), nil 1073 case *TokenGrantKycTransaction: 1074 return i.Sign(privateKey), nil 1075 case *TokenMintTransaction: 1076 return i.Sign(privateKey), nil 1077 case *TokenRevokeKycTransaction: 1078 return i.Sign(privateKey), nil 1079 case *TokenUnfreezeTransaction: 1080 return i.Sign(privateKey), nil 1081 case *TokenUpdateTransaction: 1082 return i.Sign(privateKey), nil 1083 case *TokenWipeTransaction: 1084 return i.Sign(privateKey), nil 1085 case *TopicCreateTransaction: 1086 return i.Sign(privateKey), nil 1087 case *TopicDeleteTransaction: 1088 return i.Sign(privateKey), nil 1089 case *TopicMessageSubmitTransaction: 1090 return i.Sign(privateKey), nil 1091 case *TopicUpdateTransaction: 1092 return i.Sign(privateKey), nil 1093 case *TransferTransaction: 1094 return i.Sign(privateKey), nil 1095 default: 1096 return transaction, errors.New("(BUG) non-exhaustive switch statement") 1097 } 1098 } 1099 1100 func TransactionSignWth(transaction interface{}, publicKKey PublicKey, signer TransactionSigner) (interface{}, error) { // nolint 1101 switch i := transaction.(type) { 1102 case AccountCreateTransaction: 1103 return i.SignWith(publicKKey, signer), nil 1104 case AccountDeleteTransaction: 1105 return i.SignWith(publicKKey, signer), nil 1106 case AccountUpdateTransaction: 1107 return i.SignWith(publicKKey, signer), nil 1108 case AccountAllowanceApproveTransaction: 1109 return i.SignWith(publicKKey, signer), nil 1110 case AccountAllowanceDeleteTransaction: 1111 return i.SignWith(publicKKey, signer), nil 1112 case ContractCreateTransaction: 1113 return i.SignWith(publicKKey, signer), nil 1114 case ContractDeleteTransaction: 1115 return i.SignWith(publicKKey, signer), nil 1116 case ContractExecuteTransaction: 1117 return i.SignWith(publicKKey, signer), nil 1118 case ContractUpdateTransaction: 1119 return i.SignWith(publicKKey, signer), nil 1120 case FileAppendTransaction: 1121 return i.SignWith(publicKKey, signer), nil 1122 case FileCreateTransaction: 1123 return i.SignWith(publicKKey, signer), nil 1124 case FileDeleteTransaction: 1125 return i.SignWith(publicKKey, signer), nil 1126 case FileUpdateTransaction: 1127 return i.SignWith(publicKKey, signer), nil 1128 case LiveHashAddTransaction: 1129 return i.SignWith(publicKKey, signer), nil 1130 case LiveHashDeleteTransaction: 1131 return i.SignWith(publicKKey, signer), nil 1132 case ScheduleCreateTransaction: 1133 return i.SignWith(publicKKey, signer), nil 1134 case ScheduleDeleteTransaction: 1135 return i.SignWith(publicKKey, signer), nil 1136 case ScheduleSignTransaction: 1137 return i.SignWith(publicKKey, signer), nil 1138 case SystemDeleteTransaction: 1139 return i.SignWith(publicKKey, signer), nil 1140 case SystemUndeleteTransaction: 1141 return i.SignWith(publicKKey, signer), nil 1142 case TokenAssociateTransaction: 1143 return i.SignWith(publicKKey, signer), nil 1144 case TokenBurnTransaction: 1145 return i.SignWith(publicKKey, signer), nil 1146 case TokenCreateTransaction: 1147 return i.SignWith(publicKKey, signer), nil 1148 case TokenDeleteTransaction: 1149 return i.SignWith(publicKKey, signer), nil 1150 case TokenDissociateTransaction: 1151 return i.SignWith(publicKKey, signer), nil 1152 case TokenFeeScheduleUpdateTransaction: 1153 return i.SignWith(publicKKey, signer), nil 1154 case TokenFreezeTransaction: 1155 return i.SignWith(publicKKey, signer), nil 1156 case TokenGrantKycTransaction: 1157 return i.SignWith(publicKKey, signer), nil 1158 case TokenMintTransaction: 1159 return i.SignWith(publicKKey, signer), nil 1160 case TokenRevokeKycTransaction: 1161 return i.SignWith(publicKKey, signer), nil 1162 case TokenUnfreezeTransaction: 1163 return i.SignWith(publicKKey, signer), nil 1164 case TokenUpdateTransaction: 1165 return i.SignWith(publicKKey, signer), nil 1166 case TokenWipeTransaction: 1167 return i.SignWith(publicKKey, signer), nil 1168 case TopicCreateTransaction: 1169 return i.SignWith(publicKKey, signer), nil 1170 case TopicDeleteTransaction: 1171 return i.SignWith(publicKKey, signer), nil 1172 case TopicMessageSubmitTransaction: 1173 return i.SignWith(publicKKey, signer), nil 1174 case TopicUpdateTransaction: 1175 return i.SignWith(publicKKey, signer), nil 1176 case TransferTransaction: 1177 return i.SignWith(publicKKey, signer), nil 1178 case *AccountCreateTransaction: 1179 return i.SignWith(publicKKey, signer), nil 1180 case *AccountDeleteTransaction: 1181 return i.SignWith(publicKKey, signer), nil 1182 case *AccountUpdateTransaction: 1183 return i.SignWith(publicKKey, signer), nil 1184 case *AccountAllowanceApproveTransaction: 1185 return i.SignWith(publicKKey, signer), nil 1186 case *AccountAllowanceDeleteTransaction: 1187 return i.SignWith(publicKKey, signer), nil 1188 case *ContractCreateTransaction: 1189 return i.SignWith(publicKKey, signer), nil 1190 case *ContractDeleteTransaction: 1191 return i.SignWith(publicKKey, signer), nil 1192 case *ContractExecuteTransaction: 1193 return i.SignWith(publicKKey, signer), nil 1194 case *ContractUpdateTransaction: 1195 return i.SignWith(publicKKey, signer), nil 1196 case *FileAppendTransaction: 1197 return i.SignWith(publicKKey, signer), nil 1198 case *FileCreateTransaction: 1199 return i.SignWith(publicKKey, signer), nil 1200 case *FileDeleteTransaction: 1201 return i.SignWith(publicKKey, signer), nil 1202 case *FileUpdateTransaction: 1203 return i.SignWith(publicKKey, signer), nil 1204 case *LiveHashAddTransaction: 1205 return i.SignWith(publicKKey, signer), nil 1206 case *LiveHashDeleteTransaction: 1207 return i.SignWith(publicKKey, signer), nil 1208 case *ScheduleCreateTransaction: 1209 return i.SignWith(publicKKey, signer), nil 1210 case *ScheduleDeleteTransaction: 1211 return i.SignWith(publicKKey, signer), nil 1212 case *ScheduleSignTransaction: 1213 return i.SignWith(publicKKey, signer), nil 1214 case *SystemDeleteTransaction: 1215 return i.SignWith(publicKKey, signer), nil 1216 case *SystemUndeleteTransaction: 1217 return i.SignWith(publicKKey, signer), nil 1218 case *TokenAssociateTransaction: 1219 return i.SignWith(publicKKey, signer), nil 1220 case *TokenBurnTransaction: 1221 return i.SignWith(publicKKey, signer), nil 1222 case *TokenCreateTransaction: 1223 return i.SignWith(publicKKey, signer), nil 1224 case *TokenDeleteTransaction: 1225 return i.SignWith(publicKKey, signer), nil 1226 case *TokenDissociateTransaction: 1227 return i.SignWith(publicKKey, signer), nil 1228 case *TokenFeeScheduleUpdateTransaction: 1229 return i.SignWith(publicKKey, signer), nil 1230 case *TokenFreezeTransaction: 1231 return i.SignWith(publicKKey, signer), nil 1232 case *TokenGrantKycTransaction: 1233 return i.SignWith(publicKKey, signer), nil 1234 case *TokenMintTransaction: 1235 return i.SignWith(publicKKey, signer), nil 1236 case *TokenRevokeKycTransaction: 1237 return i.SignWith(publicKKey, signer), nil 1238 case *TokenUnfreezeTransaction: 1239 return i.SignWith(publicKKey, signer), nil 1240 case *TokenUpdateTransaction: 1241 return i.SignWith(publicKKey, signer), nil 1242 case *TokenWipeTransaction: 1243 return i.SignWith(publicKKey, signer), nil 1244 case *TopicCreateTransaction: 1245 return i.SignWith(publicKKey, signer), nil 1246 case *TopicDeleteTransaction: 1247 return i.SignWith(publicKKey, signer), nil 1248 case *TopicMessageSubmitTransaction: 1249 return i.SignWith(publicKKey, signer), nil 1250 case *TopicUpdateTransaction: 1251 return i.SignWith(publicKKey, signer), nil 1252 case *TransferTransaction: 1253 return i.SignWith(publicKKey, signer), nil 1254 default: 1255 return transaction, errors.New("(BUG) non-exhaustive switch statement") 1256 } 1257 } 1258 1259 func TransactionSignWithOperator(transaction interface{}, client *Client) (interface{}, error) { // nolint 1260 switch i := transaction.(type) { 1261 case AccountCreateTransaction: 1262 return i.SignWithOperator(client) 1263 case AccountDeleteTransaction: 1264 return i.SignWithOperator(client) 1265 case AccountUpdateTransaction: 1266 return i.SignWithOperator(client) 1267 case AccountAllowanceApproveTransaction: 1268 return i.SignWithOperator(client) 1269 case AccountAllowanceDeleteTransaction: 1270 return i.SignWithOperator(client) 1271 case ContractCreateTransaction: 1272 return i.SignWithOperator(client) 1273 case ContractDeleteTransaction: 1274 return i.SignWithOperator(client) 1275 case ContractExecuteTransaction: 1276 return i.SignWithOperator(client) 1277 case ContractUpdateTransaction: 1278 return i.SignWithOperator(client) 1279 case FileAppendTransaction: 1280 return i.SignWithOperator(client) 1281 case FileCreateTransaction: 1282 return i.SignWithOperator(client) 1283 case FileDeleteTransaction: 1284 return i.SignWithOperator(client) 1285 case FileUpdateTransaction: 1286 return i.SignWithOperator(client) 1287 case LiveHashAddTransaction: 1288 return i.SignWithOperator(client) 1289 case LiveHashDeleteTransaction: 1290 return i.SignWithOperator(client) 1291 case ScheduleCreateTransaction: 1292 return i.SignWithOperator(client) 1293 case ScheduleDeleteTransaction: 1294 return i.SignWithOperator(client) 1295 case ScheduleSignTransaction: 1296 return i.SignWithOperator(client) 1297 case SystemDeleteTransaction: 1298 return i.SignWithOperator(client) 1299 case SystemUndeleteTransaction: 1300 return i.SignWithOperator(client) 1301 case TokenAssociateTransaction: 1302 return i.SignWithOperator(client) 1303 case TokenBurnTransaction: 1304 return i.SignWithOperator(client) 1305 case TokenCreateTransaction: 1306 return i.SignWithOperator(client) 1307 case TokenDeleteTransaction: 1308 return i.SignWithOperator(client) 1309 case TokenDissociateTransaction: 1310 return i.SignWithOperator(client) 1311 case TokenFeeScheduleUpdateTransaction: 1312 return i.SignWithOperator(client) 1313 case TokenFreezeTransaction: 1314 return i.SignWithOperator(client) 1315 case TokenGrantKycTransaction: 1316 return i.SignWithOperator(client) 1317 case TokenMintTransaction: 1318 return i.SignWithOperator(client) 1319 case TokenRevokeKycTransaction: 1320 return i.SignWithOperator(client) 1321 case TokenUnfreezeTransaction: 1322 return i.SignWithOperator(client) 1323 case TokenUpdateTransaction: 1324 return i.SignWithOperator(client) 1325 case TokenWipeTransaction: 1326 return i.SignWithOperator(client) 1327 case TopicCreateTransaction: 1328 return i.SignWithOperator(client) 1329 case TopicDeleteTransaction: 1330 return i.SignWithOperator(client) 1331 case TopicMessageSubmitTransaction: 1332 return i.SignWithOperator(client) 1333 case TopicUpdateTransaction: 1334 return i.SignWithOperator(client) 1335 case TransferTransaction: 1336 return i.SignWithOperator(client) 1337 case *AccountCreateTransaction: 1338 return i.SignWithOperator(client) 1339 case *AccountDeleteTransaction: 1340 return i.SignWithOperator(client) 1341 case *AccountUpdateTransaction: 1342 return i.SignWithOperator(client) 1343 case *AccountAllowanceApproveTransaction: 1344 return i.SignWithOperator(client) 1345 case *AccountAllowanceDeleteTransaction: 1346 return i.SignWithOperator(client) 1347 case *ContractCreateTransaction: 1348 return i.SignWithOperator(client) 1349 case *ContractDeleteTransaction: 1350 return i.SignWithOperator(client) 1351 case *ContractExecuteTransaction: 1352 return i.SignWithOperator(client) 1353 case *ContractUpdateTransaction: 1354 return i.SignWithOperator(client) 1355 case *FileAppendTransaction: 1356 return i.SignWithOperator(client) 1357 case *FileCreateTransaction: 1358 return i.SignWithOperator(client) 1359 case *FileDeleteTransaction: 1360 return i.SignWithOperator(client) 1361 case *FileUpdateTransaction: 1362 return i.SignWithOperator(client) 1363 case *LiveHashAddTransaction: 1364 return i.SignWithOperator(client) 1365 case *LiveHashDeleteTransaction: 1366 return i.SignWithOperator(client) 1367 case *ScheduleCreateTransaction: 1368 return i.SignWithOperator(client) 1369 case *ScheduleDeleteTransaction: 1370 return i.SignWithOperator(client) 1371 case *ScheduleSignTransaction: 1372 return i.SignWithOperator(client) 1373 case *SystemDeleteTransaction: 1374 return i.SignWithOperator(client) 1375 case *SystemUndeleteTransaction: 1376 return i.SignWithOperator(client) 1377 case *TokenAssociateTransaction: 1378 return i.SignWithOperator(client) 1379 case *TokenBurnTransaction: 1380 return i.SignWithOperator(client) 1381 case *TokenCreateTransaction: 1382 return i.SignWithOperator(client) 1383 case *TokenDeleteTransaction: 1384 return i.SignWithOperator(client) 1385 case *TokenDissociateTransaction: 1386 return i.SignWithOperator(client) 1387 case *TokenFeeScheduleUpdateTransaction: 1388 return i.SignWithOperator(client) 1389 case *TokenFreezeTransaction: 1390 return i.SignWithOperator(client) 1391 case *TokenGrantKycTransaction: 1392 return i.SignWithOperator(client) 1393 case *TokenMintTransaction: 1394 return i.SignWithOperator(client) 1395 case *TokenRevokeKycTransaction: 1396 return i.SignWithOperator(client) 1397 case *TokenUnfreezeTransaction: 1398 return i.SignWithOperator(client) 1399 case *TokenUpdateTransaction: 1400 return i.SignWithOperator(client) 1401 case *TokenWipeTransaction: 1402 return i.SignWithOperator(client) 1403 case *TopicCreateTransaction: 1404 return i.SignWithOperator(client) 1405 case *TopicDeleteTransaction: 1406 return i.SignWithOperator(client) 1407 case *TopicMessageSubmitTransaction: 1408 return i.SignWithOperator(client) 1409 case *TopicUpdateTransaction: 1410 return i.SignWithOperator(client) 1411 case *TransferTransaction: 1412 return i.SignWithOperator(client) 1413 default: 1414 return transaction, errors.New("(BUG) non-exhaustive switch statement") 1415 } 1416 } 1417 1418 func TransactionAddSignature(transaction interface{}, publicKey PublicKey, signature []byte) (interface{}, error) { // nolint 1419 switch i := transaction.(type) { 1420 case AccountCreateTransaction: 1421 return i.AddSignature(publicKey, signature), nil 1422 case AccountDeleteTransaction: 1423 return i.AddSignature(publicKey, signature), nil 1424 case AccountUpdateTransaction: 1425 return i.AddSignature(publicKey, signature), nil 1426 case AccountAllowanceApproveTransaction: 1427 return i.AddSignature(publicKey, signature), nil 1428 case AccountAllowanceDeleteTransaction: 1429 return i.AddSignature(publicKey, signature), nil 1430 case ContractCreateTransaction: 1431 return i.AddSignature(publicKey, signature), nil 1432 case ContractDeleteTransaction: 1433 return i.AddSignature(publicKey, signature), nil 1434 case ContractExecuteTransaction: 1435 return i.AddSignature(publicKey, signature), nil 1436 case ContractUpdateTransaction: 1437 return i.AddSignature(publicKey, signature), nil 1438 case FileAppendTransaction: 1439 return i.AddSignature(publicKey, signature), nil 1440 case FileCreateTransaction: 1441 return i.AddSignature(publicKey, signature), nil 1442 case FileDeleteTransaction: 1443 return i.AddSignature(publicKey, signature), nil 1444 case FileUpdateTransaction: 1445 return i.AddSignature(publicKey, signature), nil 1446 case LiveHashAddTransaction: 1447 return i.AddSignature(publicKey, signature), nil 1448 case LiveHashDeleteTransaction: 1449 return i.AddSignature(publicKey, signature), nil 1450 case SystemDeleteTransaction: 1451 return i.AddSignature(publicKey, signature), nil 1452 case SystemUndeleteTransaction: 1453 return i.AddSignature(publicKey, signature), nil 1454 case TokenAssociateTransaction: 1455 return i.AddSignature(publicKey, signature), nil 1456 case TokenBurnTransaction: 1457 return i.AddSignature(publicKey, signature), nil 1458 case TokenCreateTransaction: 1459 return i.AddSignature(publicKey, signature), nil 1460 case TokenDeleteTransaction: 1461 return i.AddSignature(publicKey, signature), nil 1462 case TokenDissociateTransaction: 1463 return i.AddSignature(publicKey, signature), nil 1464 case TokenFeeScheduleUpdateTransaction: 1465 return i.AddSignature(publicKey, signature), nil 1466 case TokenFreezeTransaction: 1467 return i.AddSignature(publicKey, signature), nil 1468 case TokenGrantKycTransaction: 1469 return i.AddSignature(publicKey, signature), nil 1470 case TokenMintTransaction: 1471 return i.AddSignature(publicKey, signature), nil 1472 case TokenRevokeKycTransaction: 1473 return i.AddSignature(publicKey, signature), nil 1474 case TokenUnfreezeTransaction: 1475 return i.AddSignature(publicKey, signature), nil 1476 case TokenUpdateTransaction: 1477 return i.AddSignature(publicKey, signature), nil 1478 case TokenWipeTransaction: 1479 return i.AddSignature(publicKey, signature), nil 1480 case TopicCreateTransaction: 1481 return i.AddSignature(publicKey, signature), nil 1482 case TopicDeleteTransaction: 1483 return i.AddSignature(publicKey, signature), nil 1484 case TopicMessageSubmitTransaction: 1485 return i.AddSignature(publicKey, signature), nil 1486 case TopicUpdateTransaction: 1487 return i.AddSignature(publicKey, signature), nil 1488 case TransferTransaction: 1489 return i.AddSignature(publicKey, signature), nil 1490 case *AccountCreateTransaction: 1491 return i.AddSignature(publicKey, signature), nil 1492 case *AccountDeleteTransaction: 1493 return i.AddSignature(publicKey, signature), nil 1494 case *AccountUpdateTransaction: 1495 return i.AddSignature(publicKey, signature), nil 1496 case *AccountAllowanceApproveTransaction: 1497 return i.AddSignature(publicKey, signature), nil 1498 case *AccountAllowanceDeleteTransaction: 1499 return i.AddSignature(publicKey, signature), nil 1500 case *ContractCreateTransaction: 1501 return i.AddSignature(publicKey, signature), nil 1502 case *ContractDeleteTransaction: 1503 return i.AddSignature(publicKey, signature), nil 1504 case *ContractExecuteTransaction: 1505 return i.AddSignature(publicKey, signature), nil 1506 case *ContractUpdateTransaction: 1507 return i.AddSignature(publicKey, signature), nil 1508 case *FileAppendTransaction: 1509 return i.AddSignature(publicKey, signature), nil 1510 case *FileCreateTransaction: 1511 return i.AddSignature(publicKey, signature), nil 1512 case *FileDeleteTransaction: 1513 return i.AddSignature(publicKey, signature), nil 1514 case *FileUpdateTransaction: 1515 return i.AddSignature(publicKey, signature), nil 1516 case *LiveHashAddTransaction: 1517 return i.AddSignature(publicKey, signature), nil 1518 case *LiveHashDeleteTransaction: 1519 return i.AddSignature(publicKey, signature), nil 1520 case *SystemDeleteTransaction: 1521 return i.AddSignature(publicKey, signature), nil 1522 case *SystemUndeleteTransaction: 1523 return i.AddSignature(publicKey, signature), nil 1524 case *TokenAssociateTransaction: 1525 return i.AddSignature(publicKey, signature), nil 1526 case *TokenBurnTransaction: 1527 return i.AddSignature(publicKey, signature), nil 1528 case *TokenCreateTransaction: 1529 return i.AddSignature(publicKey, signature), nil 1530 case *TokenDeleteTransaction: 1531 return i.AddSignature(publicKey, signature), nil 1532 case *TokenDissociateTransaction: 1533 return i.AddSignature(publicKey, signature), nil 1534 case *TokenFeeScheduleUpdateTransaction: 1535 return i.AddSignature(publicKey, signature), nil 1536 case *TokenFreezeTransaction: 1537 return i.AddSignature(publicKey, signature), nil 1538 case *TokenGrantKycTransaction: 1539 return i.AddSignature(publicKey, signature), nil 1540 case *TokenMintTransaction: 1541 return i.AddSignature(publicKey, signature), nil 1542 case *TokenRevokeKycTransaction: 1543 return i.AddSignature(publicKey, signature), nil 1544 case *TokenUnfreezeTransaction: 1545 return i.AddSignature(publicKey, signature), nil 1546 case *TokenUpdateTransaction: 1547 return i.AddSignature(publicKey, signature), nil 1548 case *TokenWipeTransaction: 1549 return i.AddSignature(publicKey, signature), nil 1550 case *TopicCreateTransaction: 1551 return i.AddSignature(publicKey, signature), nil 1552 case *TopicDeleteTransaction: 1553 return i.AddSignature(publicKey, signature), nil 1554 case *TopicMessageSubmitTransaction: 1555 return i.AddSignature(publicKey, signature), nil 1556 case *TopicUpdateTransaction: 1557 return i.AddSignature(publicKey, signature), nil 1558 case *TransferTransaction: 1559 return i.AddSignature(publicKey, signature), nil 1560 default: 1561 return transaction, errors.New("(BUG) non-exhaustive switch statement") 1562 } 1563 } 1564 1565 func TransactionGetSignatures(transaction interface{}) (map[AccountID]map[*PublicKey][]byte, error) { // nolint 1566 switch i := transaction.(type) { 1567 case AccountCreateTransaction: 1568 return i.GetSignatures() 1569 case AccountDeleteTransaction: 1570 return i.GetSignatures() 1571 case AccountUpdateTransaction: 1572 return i.GetSignatures() 1573 case AccountAllowanceApproveTransaction: 1574 return i.GetSignatures() 1575 case AccountAllowanceDeleteTransaction: 1576 return i.GetSignatures() 1577 case ContractCreateTransaction: 1578 return i.GetSignatures() 1579 case ContractDeleteTransaction: 1580 return i.GetSignatures() 1581 case ContractExecuteTransaction: 1582 return i.GetSignatures() 1583 case ContractUpdateTransaction: 1584 return i.GetSignatures() 1585 case FileAppendTransaction: 1586 return i.GetSignatures() 1587 case FileCreateTransaction: 1588 return i.GetSignatures() 1589 case FileDeleteTransaction: 1590 return i.GetSignatures() 1591 case FileUpdateTransaction: 1592 return i.GetSignatures() 1593 case LiveHashAddTransaction: 1594 return i.GetSignatures() 1595 case LiveHashDeleteTransaction: 1596 return i.GetSignatures() 1597 case ScheduleCreateTransaction: 1598 return i.GetSignatures() 1599 case ScheduleDeleteTransaction: 1600 return i.GetSignatures() 1601 case ScheduleSignTransaction: 1602 return i.GetSignatures() 1603 case SystemDeleteTransaction: 1604 return i.GetSignatures() 1605 case SystemUndeleteTransaction: 1606 return i.GetSignatures() 1607 case TokenAssociateTransaction: 1608 return i.GetSignatures() 1609 case TokenBurnTransaction: 1610 return i.GetSignatures() 1611 case TokenCreateTransaction: 1612 return i.GetSignatures() 1613 case TokenDeleteTransaction: 1614 return i.GetSignatures() 1615 case TokenDissociateTransaction: 1616 return i.GetSignatures() 1617 case TokenFeeScheduleUpdateTransaction: 1618 return i.GetSignatures() 1619 case TokenFreezeTransaction: 1620 return i.GetSignatures() 1621 case TokenGrantKycTransaction: 1622 return i.GetSignatures() 1623 case TokenMintTransaction: 1624 return i.GetSignatures() 1625 case TokenRevokeKycTransaction: 1626 return i.GetSignatures() 1627 case TokenUnfreezeTransaction: 1628 return i.GetSignatures() 1629 case TokenUpdateTransaction: 1630 return i.GetSignatures() 1631 case TokenWipeTransaction: 1632 return i.GetSignatures() 1633 case TopicCreateTransaction: 1634 return i.GetSignatures() 1635 case TopicDeleteTransaction: 1636 return i.GetSignatures() 1637 case TopicMessageSubmitTransaction: 1638 return i.GetSignatures() 1639 case TopicUpdateTransaction: 1640 return i.GetSignatures() 1641 case TransferTransaction: 1642 return i.GetSignatures() 1643 case *AccountCreateTransaction: 1644 return i.GetSignatures() 1645 case *AccountDeleteTransaction: 1646 return i.GetSignatures() 1647 case *AccountUpdateTransaction: 1648 return i.GetSignatures() 1649 case *AccountAllowanceApproveTransaction: 1650 return i.GetSignatures() 1651 case *AccountAllowanceDeleteTransaction: 1652 return i.GetSignatures() 1653 case *ContractCreateTransaction: 1654 return i.GetSignatures() 1655 case *ContractDeleteTransaction: 1656 return i.GetSignatures() 1657 case *ContractExecuteTransaction: 1658 return i.GetSignatures() 1659 case *ContractUpdateTransaction: 1660 return i.GetSignatures() 1661 case *FileAppendTransaction: 1662 return i.GetSignatures() 1663 case *FileCreateTransaction: 1664 return i.GetSignatures() 1665 case *FileDeleteTransaction: 1666 return i.GetSignatures() 1667 case *FileUpdateTransaction: 1668 return i.GetSignatures() 1669 case *LiveHashAddTransaction: 1670 return i.GetSignatures() 1671 case *LiveHashDeleteTransaction: 1672 return i.GetSignatures() 1673 case *ScheduleCreateTransaction: 1674 return i.GetSignatures() 1675 case *ScheduleDeleteTransaction: 1676 return i.GetSignatures() 1677 case *ScheduleSignTransaction: 1678 return i.GetSignatures() 1679 case *SystemDeleteTransaction: 1680 return i.GetSignatures() 1681 case *SystemUndeleteTransaction: 1682 return i.GetSignatures() 1683 case *TokenAssociateTransaction: 1684 return i.GetSignatures() 1685 case *TokenBurnTransaction: 1686 return i.GetSignatures() 1687 case *TokenCreateTransaction: 1688 return i.GetSignatures() 1689 case *TokenDeleteTransaction: 1690 return i.GetSignatures() 1691 case *TokenDissociateTransaction: 1692 return i.GetSignatures() 1693 case *TokenFeeScheduleUpdateTransaction: 1694 return i.GetSignatures() 1695 case *TokenFreezeTransaction: 1696 return i.GetSignatures() 1697 case *TokenGrantKycTransaction: 1698 return i.GetSignatures() 1699 case *TokenMintTransaction: 1700 return i.GetSignatures() 1701 case *TokenRevokeKycTransaction: 1702 return i.GetSignatures() 1703 case *TokenUnfreezeTransaction: 1704 return i.GetSignatures() 1705 case *TokenUpdateTransaction: 1706 return i.GetSignatures() 1707 case *TokenWipeTransaction: 1708 return i.GetSignatures() 1709 case *TopicCreateTransaction: 1710 return i.GetSignatures() 1711 case *TopicDeleteTransaction: 1712 return i.GetSignatures() 1713 case *TopicMessageSubmitTransaction: 1714 return i.GetSignatures() 1715 case *TopicUpdateTransaction: 1716 return i.GetSignatures() 1717 case *TransferTransaction: 1718 return i.GetSignatures() 1719 default: 1720 return nil, errors.New("(BUG) non-exhaustive switch statement") 1721 } 1722 } 1723 1724 func TransactionSetTransactionID(transaction interface{}, transactionID TransactionID) (interface{}, error) { // nolint 1725 switch i := transaction.(type) { 1726 case AccountCreateTransaction: 1727 return i.SetTransactionID(transactionID), nil 1728 case AccountDeleteTransaction: 1729 return i.SetTransactionID(transactionID), nil 1730 case AccountUpdateTransaction: 1731 return i.SetTransactionID(transactionID), nil 1732 case AccountAllowanceApproveTransaction: 1733 return i.SetTransactionID(transactionID), nil 1734 case AccountAllowanceDeleteTransaction: 1735 return i.SetTransactionID(transactionID), nil 1736 case ContractCreateTransaction: 1737 return i.SetTransactionID(transactionID), nil 1738 case ContractDeleteTransaction: 1739 return i.SetTransactionID(transactionID), nil 1740 case ContractExecuteTransaction: 1741 return i.SetTransactionID(transactionID), nil 1742 case ContractUpdateTransaction: 1743 return i.SetTransactionID(transactionID), nil 1744 case FileAppendTransaction: 1745 return i.SetTransactionID(transactionID), nil 1746 case FileCreateTransaction: 1747 return i.SetTransactionID(transactionID), nil 1748 case FileDeleteTransaction: 1749 return i.SetTransactionID(transactionID), nil 1750 case FileUpdateTransaction: 1751 return i.SetTransactionID(transactionID), nil 1752 case LiveHashAddTransaction: 1753 return i.SetTransactionID(transactionID), nil 1754 case LiveHashDeleteTransaction: 1755 return i.SetTransactionID(transactionID), nil 1756 case ScheduleCreateTransaction: 1757 return i.SetTransactionID(transactionID), nil 1758 case ScheduleDeleteTransaction: 1759 return i.SetTransactionID(transactionID), nil 1760 case ScheduleSignTransaction: 1761 return i.SetTransactionID(transactionID), nil 1762 case SystemDeleteTransaction: 1763 return i.SetTransactionID(transactionID), nil 1764 case SystemUndeleteTransaction: 1765 return i.SetTransactionID(transactionID), nil 1766 case TokenAssociateTransaction: 1767 return i.SetTransactionID(transactionID), nil 1768 case TokenBurnTransaction: 1769 return i.SetTransactionID(transactionID), nil 1770 case TokenCreateTransaction: 1771 return i.SetTransactionID(transactionID), nil 1772 case TokenDeleteTransaction: 1773 return i.SetTransactionID(transactionID), nil 1774 case TokenDissociateTransaction: 1775 return i.SetTransactionID(transactionID), nil 1776 case TokenFeeScheduleUpdateTransaction: 1777 return i.SetTransactionID(transactionID), nil 1778 case TokenFreezeTransaction: 1779 return i.SetTransactionID(transactionID), nil 1780 case TokenGrantKycTransaction: 1781 return i.SetTransactionID(transactionID), nil 1782 case TokenMintTransaction: 1783 return i.SetTransactionID(transactionID), nil 1784 case TokenRevokeKycTransaction: 1785 return i.SetTransactionID(transactionID), nil 1786 case TokenUnfreezeTransaction: 1787 return i.SetTransactionID(transactionID), nil 1788 case TokenUpdateTransaction: 1789 return i.SetTransactionID(transactionID), nil 1790 case TokenWipeTransaction: 1791 return i.SetTransactionID(transactionID), nil 1792 case TopicCreateTransaction: 1793 return i.SetTransactionID(transactionID), nil 1794 case TopicDeleteTransaction: 1795 return i.SetTransactionID(transactionID), nil 1796 case TopicMessageSubmitTransaction: 1797 return i.SetTransactionID(transactionID), nil 1798 case TopicUpdateTransaction: 1799 return i.SetTransactionID(transactionID), nil 1800 case TransferTransaction: 1801 return i.SetTransactionID(transactionID), nil 1802 case *AccountCreateTransaction: 1803 return i.SetTransactionID(transactionID), nil 1804 case *AccountDeleteTransaction: 1805 return i.SetTransactionID(transactionID), nil 1806 case *AccountUpdateTransaction: 1807 return i.SetTransactionID(transactionID), nil 1808 case *AccountAllowanceApproveTransaction: 1809 return i.SetTransactionID(transactionID), nil 1810 case *AccountAllowanceDeleteTransaction: 1811 return i.SetTransactionID(transactionID), nil 1812 case *ContractCreateTransaction: 1813 return i.SetTransactionID(transactionID), nil 1814 case *ContractDeleteTransaction: 1815 return i.SetTransactionID(transactionID), nil 1816 case *ContractExecuteTransaction: 1817 return i.SetTransactionID(transactionID), nil 1818 case *ContractUpdateTransaction: 1819 return i.SetTransactionID(transactionID), nil 1820 case *FileAppendTransaction: 1821 return i.SetTransactionID(transactionID), nil 1822 case *FileCreateTransaction: 1823 return i.SetTransactionID(transactionID), nil 1824 case *FileDeleteTransaction: 1825 return i.SetTransactionID(transactionID), nil 1826 case *FileUpdateTransaction: 1827 return i.SetTransactionID(transactionID), nil 1828 case *LiveHashAddTransaction: 1829 return i.SetTransactionID(transactionID), nil 1830 case *LiveHashDeleteTransaction: 1831 return i.SetTransactionID(transactionID), nil 1832 case *ScheduleCreateTransaction: 1833 return i.SetTransactionID(transactionID), nil 1834 case *ScheduleDeleteTransaction: 1835 return i.SetTransactionID(transactionID), nil 1836 case *ScheduleSignTransaction: 1837 return i.SetTransactionID(transactionID), nil 1838 case *SystemDeleteTransaction: 1839 return i.SetTransactionID(transactionID), nil 1840 case *SystemUndeleteTransaction: 1841 return i.SetTransactionID(transactionID), nil 1842 case *TokenAssociateTransaction: 1843 return i.SetTransactionID(transactionID), nil 1844 case *TokenBurnTransaction: 1845 return i.SetTransactionID(transactionID), nil 1846 case *TokenCreateTransaction: 1847 return i.SetTransactionID(transactionID), nil 1848 case *TokenDeleteTransaction: 1849 return i.SetTransactionID(transactionID), nil 1850 case *TokenDissociateTransaction: 1851 return i.SetTransactionID(transactionID), nil 1852 case *TokenFeeScheduleUpdateTransaction: 1853 return i.SetTransactionID(transactionID), nil 1854 case *TokenFreezeTransaction: 1855 return i.SetTransactionID(transactionID), nil 1856 case *TokenGrantKycTransaction: 1857 return i.SetTransactionID(transactionID), nil 1858 case *TokenMintTransaction: 1859 return i.SetTransactionID(transactionID), nil 1860 case *TokenRevokeKycTransaction: 1861 return i.SetTransactionID(transactionID), nil 1862 case *TokenUnfreezeTransaction: 1863 return i.SetTransactionID(transactionID), nil 1864 case *TokenUpdateTransaction: 1865 return i.SetTransactionID(transactionID), nil 1866 case *TokenWipeTransaction: 1867 return i.SetTransactionID(transactionID), nil 1868 case *TopicCreateTransaction: 1869 return i.SetTransactionID(transactionID), nil 1870 case *TopicDeleteTransaction: 1871 return i.SetTransactionID(transactionID), nil 1872 case *TopicMessageSubmitTransaction: 1873 return i.SetTransactionID(transactionID), nil 1874 case *TopicUpdateTransaction: 1875 return i.SetTransactionID(transactionID), nil 1876 case *TransferTransaction: 1877 return i.SetTransactionID(transactionID), nil 1878 default: 1879 return transaction, errors.New("(BUG) non-exhaustive switch statement") 1880 } 1881 } 1882 1883 func TransactionGetTransactionID(transaction interface{}) (TransactionID, error) { // nolint 1884 switch i := transaction.(type) { 1885 case AccountCreateTransaction: 1886 return i.GetTransactionID(), nil 1887 case AccountDeleteTransaction: 1888 return i.GetTransactionID(), nil 1889 case AccountUpdateTransaction: 1890 return i.GetTransactionID(), nil 1891 case AccountAllowanceApproveTransaction: 1892 return i.GetTransactionID(), nil 1893 case AccountAllowanceDeleteTransaction: 1894 return i.GetTransactionID(), nil 1895 case ContractCreateTransaction: 1896 return i.GetTransactionID(), nil 1897 case ContractDeleteTransaction: 1898 return i.GetTransactionID(), nil 1899 case ContractExecuteTransaction: 1900 return i.GetTransactionID(), nil 1901 case ContractUpdateTransaction: 1902 return i.GetTransactionID(), nil 1903 case FileAppendTransaction: 1904 return i.GetTransactionID(), nil 1905 case FileCreateTransaction: 1906 return i.GetTransactionID(), nil 1907 case FileDeleteTransaction: 1908 return i.GetTransactionID(), nil 1909 case FileUpdateTransaction: 1910 return i.GetTransactionID(), nil 1911 case LiveHashAddTransaction: 1912 return i.GetTransactionID(), nil 1913 case LiveHashDeleteTransaction: 1914 return i.GetTransactionID(), nil 1915 case ScheduleCreateTransaction: 1916 return i.GetTransactionID(), nil 1917 case ScheduleDeleteTransaction: 1918 return i.GetTransactionID(), nil 1919 case ScheduleSignTransaction: 1920 return i.GetTransactionID(), nil 1921 case SystemDeleteTransaction: 1922 return i.GetTransactionID(), nil 1923 case SystemUndeleteTransaction: 1924 return i.GetTransactionID(), nil 1925 case TokenAssociateTransaction: 1926 return i.GetTransactionID(), nil 1927 case TokenBurnTransaction: 1928 return i.GetTransactionID(), nil 1929 case TokenCreateTransaction: 1930 return i.GetTransactionID(), nil 1931 case TokenDeleteTransaction: 1932 return i.GetTransactionID(), nil 1933 case TokenDissociateTransaction: 1934 return i.GetTransactionID(), nil 1935 case TokenFeeScheduleUpdateTransaction: 1936 return i.GetTransactionID(), nil 1937 case TokenFreezeTransaction: 1938 return i.GetTransactionID(), nil 1939 case TokenGrantKycTransaction: 1940 return i.GetTransactionID(), nil 1941 case TokenMintTransaction: 1942 return i.GetTransactionID(), nil 1943 case TokenRevokeKycTransaction: 1944 return i.GetTransactionID(), nil 1945 case TokenUnfreezeTransaction: 1946 return i.GetTransactionID(), nil 1947 case TokenUpdateTransaction: 1948 return i.GetTransactionID(), nil 1949 case TokenWipeTransaction: 1950 return i.GetTransactionID(), nil 1951 case TopicCreateTransaction: 1952 return i.GetTransactionID(), nil 1953 case TopicDeleteTransaction: 1954 return i.GetTransactionID(), nil 1955 case TopicMessageSubmitTransaction: 1956 return i.GetTransactionID(), nil 1957 case TopicUpdateTransaction: 1958 return i.GetTransactionID(), nil 1959 case TransferTransaction: 1960 return i.GetTransactionID(), nil 1961 case *AccountCreateTransaction: 1962 return i.GetTransactionID(), nil 1963 case *AccountDeleteTransaction: 1964 return i.GetTransactionID(), nil 1965 case *AccountUpdateTransaction: 1966 return i.GetTransactionID(), nil 1967 case *AccountAllowanceApproveTransaction: 1968 return i.GetTransactionID(), nil 1969 case *AccountAllowanceDeleteTransaction: 1970 return i.GetTransactionID(), nil 1971 case *ContractCreateTransaction: 1972 return i.GetTransactionID(), nil 1973 case *ContractDeleteTransaction: 1974 return i.GetTransactionID(), nil 1975 case *ContractExecuteTransaction: 1976 return i.GetTransactionID(), nil 1977 case *ContractUpdateTransaction: 1978 return i.GetTransactionID(), nil 1979 case *FileAppendTransaction: 1980 return i.GetTransactionID(), nil 1981 case *FileCreateTransaction: 1982 return i.GetTransactionID(), nil 1983 case *FileDeleteTransaction: 1984 return i.GetTransactionID(), nil 1985 case *FileUpdateTransaction: 1986 return i.GetTransactionID(), nil 1987 case *LiveHashAddTransaction: 1988 return i.GetTransactionID(), nil 1989 case *LiveHashDeleteTransaction: 1990 return i.GetTransactionID(), nil 1991 case *ScheduleCreateTransaction: 1992 return i.GetTransactionID(), nil 1993 case *ScheduleDeleteTransaction: 1994 return i.GetTransactionID(), nil 1995 case *ScheduleSignTransaction: 1996 return i.GetTransactionID(), nil 1997 case *SystemDeleteTransaction: 1998 return i.GetTransactionID(), nil 1999 case *SystemUndeleteTransaction: 2000 return i.GetTransactionID(), nil 2001 case *TokenAssociateTransaction: 2002 return i.GetTransactionID(), nil 2003 case *TokenBurnTransaction: 2004 return i.GetTransactionID(), nil 2005 case *TokenCreateTransaction: 2006 return i.GetTransactionID(), nil 2007 case *TokenDeleteTransaction: 2008 return i.GetTransactionID(), nil 2009 case *TokenDissociateTransaction: 2010 return i.GetTransactionID(), nil 2011 case *TokenFeeScheduleUpdateTransaction: 2012 return i.GetTransactionID(), nil 2013 case *TokenFreezeTransaction: 2014 return i.GetTransactionID(), nil 2015 case *TokenGrantKycTransaction: 2016 return i.GetTransactionID(), nil 2017 case *TokenMintTransaction: 2018 return i.GetTransactionID(), nil 2019 case *TokenRevokeKycTransaction: 2020 return i.GetTransactionID(), nil 2021 case *TokenUnfreezeTransaction: 2022 return i.GetTransactionID(), nil 2023 case *TokenUpdateTransaction: 2024 return i.GetTransactionID(), nil 2025 case *TokenWipeTransaction: 2026 return i.GetTransactionID(), nil 2027 case *TopicCreateTransaction: 2028 return i.GetTransactionID(), nil 2029 case *TopicDeleteTransaction: 2030 return i.GetTransactionID(), nil 2031 case *TopicMessageSubmitTransaction: 2032 return i.GetTransactionID(), nil 2033 case *TopicUpdateTransaction: 2034 return i.GetTransactionID(), nil 2035 case *TransferTransaction: 2036 return i.GetTransactionID(), nil 2037 default: 2038 return TransactionID{}, errors.New("(BUG) non-exhaustive switch statement") 2039 } 2040 } 2041 2042 func TransactionSetTransactionMemo(transaction interface{}, transactionMemo string) (interface{}, error) { // nolint 2043 switch i := transaction.(type) { 2044 case AccountCreateTransaction: 2045 return i.SetTransactionMemo(transactionMemo), nil 2046 case AccountDeleteTransaction: 2047 return i.SetTransactionMemo(transactionMemo), nil 2048 case AccountUpdateTransaction: 2049 return i.SetTransactionMemo(transactionMemo), nil 2050 case AccountAllowanceApproveTransaction: 2051 return i.SetTransactionMemo(transactionMemo), nil 2052 case AccountAllowanceDeleteTransaction: 2053 return i.SetTransactionMemo(transactionMemo), nil 2054 case ContractCreateTransaction: 2055 return i.SetTransactionMemo(transactionMemo), nil 2056 case ContractDeleteTransaction: 2057 return i.SetTransactionMemo(transactionMemo), nil 2058 case ContractExecuteTransaction: 2059 return i.SetTransactionMemo(transactionMemo), nil 2060 case ContractUpdateTransaction: 2061 return i.SetTransactionMemo(transactionMemo), nil 2062 case FileAppendTransaction: 2063 return i.SetTransactionMemo(transactionMemo), nil 2064 case FileCreateTransaction: 2065 return i.SetTransactionMemo(transactionMemo), nil 2066 case FileDeleteTransaction: 2067 return i.SetTransactionMemo(transactionMemo), nil 2068 case FileUpdateTransaction: 2069 return i.SetTransactionMemo(transactionMemo), nil 2070 case LiveHashAddTransaction: 2071 return i.SetTransactionMemo(transactionMemo), nil 2072 case LiveHashDeleteTransaction: 2073 return i.SetTransactionMemo(transactionMemo), nil 2074 case ScheduleCreateTransaction: 2075 return i.SetTransactionMemo(transactionMemo), nil 2076 case ScheduleDeleteTransaction: 2077 return i.SetTransactionMemo(transactionMemo), nil 2078 case ScheduleSignTransaction: 2079 return i.SetTransactionMemo(transactionMemo), nil 2080 case SystemDeleteTransaction: 2081 return i.SetTransactionMemo(transactionMemo), nil 2082 case SystemUndeleteTransaction: 2083 return i.SetTransactionMemo(transactionMemo), nil 2084 case TokenAssociateTransaction: 2085 return i.SetTransactionMemo(transactionMemo), nil 2086 case TokenBurnTransaction: 2087 return i.SetTransactionMemo(transactionMemo), nil 2088 case TokenCreateTransaction: 2089 return i.SetTransactionMemo(transactionMemo), nil 2090 case TokenDeleteTransaction: 2091 return i.SetTransactionMemo(transactionMemo), nil 2092 case TokenDissociateTransaction: 2093 return i.SetTransactionMemo(transactionMemo), nil 2094 case TokenFeeScheduleUpdateTransaction: 2095 return i.SetTransactionMemo(transactionMemo), nil 2096 case TokenFreezeTransaction: 2097 return i.SetTransactionMemo(transactionMemo), nil 2098 case TokenGrantKycTransaction: 2099 return i.SetTransactionMemo(transactionMemo), nil 2100 case TokenMintTransaction: 2101 return i.SetTransactionMemo(transactionMemo), nil 2102 case TokenRevokeKycTransaction: 2103 return i.SetTransactionMemo(transactionMemo), nil 2104 case TokenUnfreezeTransaction: 2105 return i.SetTransactionMemo(transactionMemo), nil 2106 case TokenUpdateTransaction: 2107 return i.SetTransactionMemo(transactionMemo), nil 2108 case TokenWipeTransaction: 2109 return i.SetTransactionMemo(transactionMemo), nil 2110 case TopicCreateTransaction: 2111 return i.SetTransactionMemo(transactionMemo), nil 2112 case TopicDeleteTransaction: 2113 return i.SetTransactionMemo(transactionMemo), nil 2114 case TopicMessageSubmitTransaction: 2115 return i.SetTransactionMemo(transactionMemo), nil 2116 case TopicUpdateTransaction: 2117 return i.SetTransactionMemo(transactionMemo), nil 2118 case TransferTransaction: 2119 return i.SetTransactionMemo(transactionMemo), nil 2120 case *AccountCreateTransaction: 2121 return i.SetTransactionMemo(transactionMemo), nil 2122 case *AccountDeleteTransaction: 2123 return i.SetTransactionMemo(transactionMemo), nil 2124 case *AccountUpdateTransaction: 2125 return i.SetTransactionMemo(transactionMemo), nil 2126 case *AccountAllowanceApproveTransaction: 2127 return i.SetTransactionMemo(transactionMemo), nil 2128 case *AccountAllowanceDeleteTransaction: 2129 return i.SetTransactionMemo(transactionMemo), nil 2130 case *ContractCreateTransaction: 2131 return i.SetTransactionMemo(transactionMemo), nil 2132 case *ContractDeleteTransaction: 2133 return i.SetTransactionMemo(transactionMemo), nil 2134 case *ContractExecuteTransaction: 2135 return i.SetTransactionMemo(transactionMemo), nil 2136 case *ContractUpdateTransaction: 2137 return i.SetTransactionMemo(transactionMemo), nil 2138 case *FileAppendTransaction: 2139 return i.SetTransactionMemo(transactionMemo), nil 2140 case *FileCreateTransaction: 2141 return i.SetTransactionMemo(transactionMemo), nil 2142 case *FileDeleteTransaction: 2143 return i.SetTransactionMemo(transactionMemo), nil 2144 case *FileUpdateTransaction: 2145 return i.SetTransactionMemo(transactionMemo), nil 2146 case *LiveHashAddTransaction: 2147 return i.SetTransactionMemo(transactionMemo), nil 2148 case *LiveHashDeleteTransaction: 2149 return i.SetTransactionMemo(transactionMemo), nil 2150 case *ScheduleCreateTransaction: 2151 return i.SetTransactionMemo(transactionMemo), nil 2152 case *ScheduleDeleteTransaction: 2153 return i.SetTransactionMemo(transactionMemo), nil 2154 case *ScheduleSignTransaction: 2155 return i.SetTransactionMemo(transactionMemo), nil 2156 case *SystemDeleteTransaction: 2157 return i.SetTransactionMemo(transactionMemo), nil 2158 case *SystemUndeleteTransaction: 2159 return i.SetTransactionMemo(transactionMemo), nil 2160 case *TokenAssociateTransaction: 2161 return i.SetTransactionMemo(transactionMemo), nil 2162 case *TokenBurnTransaction: 2163 return i.SetTransactionMemo(transactionMemo), nil 2164 case *TokenCreateTransaction: 2165 return i.SetTransactionMemo(transactionMemo), nil 2166 case *TokenDeleteTransaction: 2167 return i.SetTransactionMemo(transactionMemo), nil 2168 case *TokenDissociateTransaction: 2169 return i.SetTransactionMemo(transactionMemo), nil 2170 case *TokenFeeScheduleUpdateTransaction: 2171 return i.SetTransactionMemo(transactionMemo), nil 2172 case *TokenFreezeTransaction: 2173 return i.SetTransactionMemo(transactionMemo), nil 2174 case *TokenGrantKycTransaction: 2175 return i.SetTransactionMemo(transactionMemo), nil 2176 case *TokenMintTransaction: 2177 return i.SetTransactionMemo(transactionMemo), nil 2178 case *TokenRevokeKycTransaction: 2179 return i.SetTransactionMemo(transactionMemo), nil 2180 case *TokenUnfreezeTransaction: 2181 return i.SetTransactionMemo(transactionMemo), nil 2182 case *TokenUpdateTransaction: 2183 return i.SetTransactionMemo(transactionMemo), nil 2184 case *TokenWipeTransaction: 2185 return i.SetTransactionMemo(transactionMemo), nil 2186 case *TopicCreateTransaction: 2187 return i.SetTransactionMemo(transactionMemo), nil 2188 case *TopicDeleteTransaction: 2189 return i.SetTransactionMemo(transactionMemo), nil 2190 case *TopicMessageSubmitTransaction: 2191 return i.SetTransactionMemo(transactionMemo), nil 2192 case *TopicUpdateTransaction: 2193 return i.SetTransactionMemo(transactionMemo), nil 2194 case *TransferTransaction: 2195 return i.SetTransactionMemo(transactionMemo), nil 2196 default: 2197 return transaction, errors.New("(BUG) non-exhaustive switch statement") 2198 } 2199 } 2200 2201 func TransactionGetTransactionMemo(transaction interface{}) (string, error) { // nolint 2202 switch i := transaction.(type) { 2203 case AccountCreateTransaction: 2204 return i.GetTransactionMemo(), nil 2205 case AccountDeleteTransaction: 2206 return i.GetTransactionMemo(), nil 2207 case AccountUpdateTransaction: 2208 return i.GetTransactionMemo(), nil 2209 case AccountAllowanceApproveTransaction: 2210 return i.GetTransactionMemo(), nil 2211 case AccountAllowanceDeleteTransaction: 2212 return i.GetTransactionMemo(), nil 2213 case ContractCreateTransaction: 2214 return i.GetTransactionMemo(), nil 2215 case ContractDeleteTransaction: 2216 return i.GetTransactionMemo(), nil 2217 case ContractExecuteTransaction: 2218 return i.GetTransactionMemo(), nil 2219 case ContractUpdateTransaction: 2220 return i.GetTransactionMemo(), nil 2221 case FileAppendTransaction: 2222 return i.GetTransactionMemo(), nil 2223 case FileCreateTransaction: 2224 return i.GetTransactionMemo(), nil 2225 case FileDeleteTransaction: 2226 return i.GetTransactionMemo(), nil 2227 case FileUpdateTransaction: 2228 return i.GetTransactionMemo(), nil 2229 case LiveHashAddTransaction: 2230 return i.GetTransactionMemo(), nil 2231 case LiveHashDeleteTransaction: 2232 return i.GetTransactionMemo(), nil 2233 case ScheduleCreateTransaction: 2234 return i.GetTransactionMemo(), nil 2235 case ScheduleDeleteTransaction: 2236 return i.GetTransactionMemo(), nil 2237 case ScheduleSignTransaction: 2238 return i.GetTransactionMemo(), nil 2239 case SystemDeleteTransaction: 2240 return i.GetTransactionMemo(), nil 2241 case SystemUndeleteTransaction: 2242 return i.GetTransactionMemo(), nil 2243 case TokenAssociateTransaction: 2244 return i.GetTransactionMemo(), nil 2245 case TokenBurnTransaction: 2246 return i.GetTransactionMemo(), nil 2247 case TokenCreateTransaction: 2248 return i.GetTransactionMemo(), nil 2249 case TokenDeleteTransaction: 2250 return i.GetTransactionMemo(), nil 2251 case TokenDissociateTransaction: 2252 return i.GetTransactionMemo(), nil 2253 case TokenFeeScheduleUpdateTransaction: 2254 return i.GetTransactionMemo(), nil 2255 case TokenFreezeTransaction: 2256 return i.GetTransactionMemo(), nil 2257 case TokenGrantKycTransaction: 2258 return i.GetTransactionMemo(), nil 2259 case TokenMintTransaction: 2260 return i.GetTransactionMemo(), nil 2261 case TokenRevokeKycTransaction: 2262 return i.GetTransactionMemo(), nil 2263 case TokenUnfreezeTransaction: 2264 return i.GetTransactionMemo(), nil 2265 case TokenUpdateTransaction: 2266 return i.GetTransactionMemo(), nil 2267 case TokenWipeTransaction: 2268 return i.GetTransactionMemo(), nil 2269 case TopicCreateTransaction: 2270 return i.GetTransactionMemo(), nil 2271 case TopicDeleteTransaction: 2272 return i.GetTransactionMemo(), nil 2273 case TopicMessageSubmitTransaction: 2274 return i.GetTransactionMemo(), nil 2275 case TopicUpdateTransaction: 2276 return i.GetTransactionMemo(), nil 2277 case TransferTransaction: 2278 return i.GetTransactionMemo(), nil 2279 case *AccountCreateTransaction: 2280 return i.GetTransactionMemo(), nil 2281 case *AccountDeleteTransaction: 2282 return i.GetTransactionMemo(), nil 2283 case *AccountUpdateTransaction: 2284 return i.GetTransactionMemo(), nil 2285 case *AccountAllowanceApproveTransaction: 2286 return i.GetTransactionMemo(), nil 2287 case *AccountAllowanceDeleteTransaction: 2288 return i.GetTransactionMemo(), nil 2289 case *ContractCreateTransaction: 2290 return i.GetTransactionMemo(), nil 2291 case *ContractDeleteTransaction: 2292 return i.GetTransactionMemo(), nil 2293 case *ContractExecuteTransaction: 2294 return i.GetTransactionMemo(), nil 2295 case *ContractUpdateTransaction: 2296 return i.GetTransactionMemo(), nil 2297 case *FileAppendTransaction: 2298 return i.GetTransactionMemo(), nil 2299 case *FileCreateTransaction: 2300 return i.GetTransactionMemo(), nil 2301 case *FileDeleteTransaction: 2302 return i.GetTransactionMemo(), nil 2303 case *FileUpdateTransaction: 2304 return i.GetTransactionMemo(), nil 2305 case *LiveHashAddTransaction: 2306 return i.GetTransactionMemo(), nil 2307 case *LiveHashDeleteTransaction: 2308 return i.GetTransactionMemo(), nil 2309 case *ScheduleCreateTransaction: 2310 return i.GetTransactionMemo(), nil 2311 case *ScheduleDeleteTransaction: 2312 return i.GetTransactionMemo(), nil 2313 case *ScheduleSignTransaction: 2314 return i.GetTransactionMemo(), nil 2315 case *SystemDeleteTransaction: 2316 return i.GetTransactionMemo(), nil 2317 case *SystemUndeleteTransaction: 2318 return i.GetTransactionMemo(), nil 2319 case *TokenAssociateTransaction: 2320 return i.GetTransactionMemo(), nil 2321 case *TokenBurnTransaction: 2322 return i.GetTransactionMemo(), nil 2323 case *TokenCreateTransaction: 2324 return i.GetTransactionMemo(), nil 2325 case *TokenDeleteTransaction: 2326 return i.GetTransactionMemo(), nil 2327 case *TokenDissociateTransaction: 2328 return i.GetTransactionMemo(), nil 2329 case *TokenFeeScheduleUpdateTransaction: 2330 return i.GetTransactionMemo(), nil 2331 case *TokenFreezeTransaction: 2332 return i.GetTransactionMemo(), nil 2333 case *TokenGrantKycTransaction: 2334 return i.GetTransactionMemo(), nil 2335 case *TokenMintTransaction: 2336 return i.GetTransactionMemo(), nil 2337 case *TokenRevokeKycTransaction: 2338 return i.GetTransactionMemo(), nil 2339 case *TokenUnfreezeTransaction: 2340 return i.GetTransactionMemo(), nil 2341 case *TokenUpdateTransaction: 2342 return i.GetTransactionMemo(), nil 2343 case *TokenWipeTransaction: 2344 return i.GetTransactionMemo(), nil 2345 case *TopicCreateTransaction: 2346 return i.GetTransactionMemo(), nil 2347 case *TopicDeleteTransaction: 2348 return i.GetTransactionMemo(), nil 2349 case *TopicMessageSubmitTransaction: 2350 return i.GetTransactionMemo(), nil 2351 case *TopicUpdateTransaction: 2352 return i.GetTransactionMemo(), nil 2353 case *TransferTransaction: 2354 return i.GetTransactionMemo(), nil 2355 default: 2356 return "", errors.New("(BUG) non-exhaustive switch statement") 2357 } 2358 } 2359 2360 func TransactionSetMaxTransactionFee(transaction interface{}, maxTransactionFee Hbar) (interface{}, error) { // nolint 2361 switch i := transaction.(type) { 2362 case AccountCreateTransaction: 2363 return i.SetMaxTransactionFee(maxTransactionFee), nil 2364 case AccountDeleteTransaction: 2365 return i.SetMaxTransactionFee(maxTransactionFee), nil 2366 case AccountUpdateTransaction: 2367 return i.SetMaxTransactionFee(maxTransactionFee), nil 2368 case AccountAllowanceApproveTransaction: 2369 return i.SetMaxTransactionFee(maxTransactionFee), nil 2370 case AccountAllowanceDeleteTransaction: 2371 return i.SetMaxTransactionFee(maxTransactionFee), nil 2372 case ContractCreateTransaction: 2373 return i.SetMaxTransactionFee(maxTransactionFee), nil 2374 case ContractDeleteTransaction: 2375 return i.SetMaxTransactionFee(maxTransactionFee), nil 2376 case ContractExecuteTransaction: 2377 return i.SetMaxTransactionFee(maxTransactionFee), nil 2378 case ContractUpdateTransaction: 2379 return i.SetMaxTransactionFee(maxTransactionFee), nil 2380 case FileAppendTransaction: 2381 return i.SetMaxTransactionFee(maxTransactionFee), nil 2382 case FileCreateTransaction: 2383 return i.SetMaxTransactionFee(maxTransactionFee), nil 2384 case FileDeleteTransaction: 2385 return i.SetMaxTransactionFee(maxTransactionFee), nil 2386 case FileUpdateTransaction: 2387 return i.SetMaxTransactionFee(maxTransactionFee), nil 2388 case LiveHashAddTransaction: 2389 return i.SetMaxTransactionFee(maxTransactionFee), nil 2390 case LiveHashDeleteTransaction: 2391 return i.SetMaxTransactionFee(maxTransactionFee), nil 2392 case ScheduleCreateTransaction: 2393 return i.SetMaxTransactionFee(maxTransactionFee), nil 2394 case ScheduleDeleteTransaction: 2395 return i.SetMaxTransactionFee(maxTransactionFee), nil 2396 case ScheduleSignTransaction: 2397 return i.SetMaxTransactionFee(maxTransactionFee), nil 2398 case SystemDeleteTransaction: 2399 return i.SetMaxTransactionFee(maxTransactionFee), nil 2400 case SystemUndeleteTransaction: 2401 return i.SetMaxTransactionFee(maxTransactionFee), nil 2402 case TokenAssociateTransaction: 2403 return i.SetMaxTransactionFee(maxTransactionFee), nil 2404 case TokenBurnTransaction: 2405 return i.SetMaxTransactionFee(maxTransactionFee), nil 2406 case TokenCreateTransaction: 2407 return i.SetMaxTransactionFee(maxTransactionFee), nil 2408 case TokenDeleteTransaction: 2409 return i.SetMaxTransactionFee(maxTransactionFee), nil 2410 case TokenDissociateTransaction: 2411 return i.SetMaxTransactionFee(maxTransactionFee), nil 2412 case TokenFeeScheduleUpdateTransaction: 2413 return i.SetMaxTransactionFee(maxTransactionFee), nil 2414 case TokenFreezeTransaction: 2415 return i.SetMaxTransactionFee(maxTransactionFee), nil 2416 case TokenGrantKycTransaction: 2417 return i.SetMaxTransactionFee(maxTransactionFee), nil 2418 case TokenMintTransaction: 2419 return i.SetMaxTransactionFee(maxTransactionFee), nil 2420 case TokenRevokeKycTransaction: 2421 return i.SetMaxTransactionFee(maxTransactionFee), nil 2422 case TokenUnfreezeTransaction: 2423 return i.SetMaxTransactionFee(maxTransactionFee), nil 2424 case TokenUpdateTransaction: 2425 return i.SetMaxTransactionFee(maxTransactionFee), nil 2426 case TokenWipeTransaction: 2427 return i.SetMaxTransactionFee(maxTransactionFee), nil 2428 case TopicCreateTransaction: 2429 return i.SetMaxTransactionFee(maxTransactionFee), nil 2430 case TopicDeleteTransaction: 2431 return i.SetMaxTransactionFee(maxTransactionFee), nil 2432 case TopicMessageSubmitTransaction: 2433 return i.SetMaxTransactionFee(maxTransactionFee), nil 2434 case TopicUpdateTransaction: 2435 return i.SetMaxTransactionFee(maxTransactionFee), nil 2436 case TransferTransaction: 2437 return i.SetMaxTransactionFee(maxTransactionFee), nil 2438 case *AccountCreateTransaction: 2439 return i.SetMaxTransactionFee(maxTransactionFee), nil 2440 case *AccountDeleteTransaction: 2441 return i.SetMaxTransactionFee(maxTransactionFee), nil 2442 case *AccountUpdateTransaction: 2443 return i.SetMaxTransactionFee(maxTransactionFee), nil 2444 case *AccountAllowanceApproveTransaction: 2445 return i.SetMaxTransactionFee(maxTransactionFee), nil 2446 case *AccountAllowanceDeleteTransaction: 2447 return i.SetMaxTransactionFee(maxTransactionFee), nil 2448 case *ContractCreateTransaction: 2449 return i.SetMaxTransactionFee(maxTransactionFee), nil 2450 case *ContractDeleteTransaction: 2451 return i.SetMaxTransactionFee(maxTransactionFee), nil 2452 case *ContractExecuteTransaction: 2453 return i.SetMaxTransactionFee(maxTransactionFee), nil 2454 case *ContractUpdateTransaction: 2455 return i.SetMaxTransactionFee(maxTransactionFee), nil 2456 case *FileAppendTransaction: 2457 return i.SetMaxTransactionFee(maxTransactionFee), nil 2458 case *FileCreateTransaction: 2459 return i.SetMaxTransactionFee(maxTransactionFee), nil 2460 case *FileDeleteTransaction: 2461 return i.SetMaxTransactionFee(maxTransactionFee), nil 2462 case *FileUpdateTransaction: 2463 return i.SetMaxTransactionFee(maxTransactionFee), nil 2464 case *LiveHashAddTransaction: 2465 return i.SetMaxTransactionFee(maxTransactionFee), nil 2466 case *LiveHashDeleteTransaction: 2467 return i.SetMaxTransactionFee(maxTransactionFee), nil 2468 case *ScheduleCreateTransaction: 2469 return i.SetMaxTransactionFee(maxTransactionFee), nil 2470 case *ScheduleDeleteTransaction: 2471 return i.SetMaxTransactionFee(maxTransactionFee), nil 2472 case *ScheduleSignTransaction: 2473 return i.SetMaxTransactionFee(maxTransactionFee), nil 2474 case *SystemDeleteTransaction: 2475 return i.SetMaxTransactionFee(maxTransactionFee), nil 2476 case *SystemUndeleteTransaction: 2477 return i.SetMaxTransactionFee(maxTransactionFee), nil 2478 case *TokenAssociateTransaction: 2479 return i.SetMaxTransactionFee(maxTransactionFee), nil 2480 case *TokenBurnTransaction: 2481 return i.SetMaxTransactionFee(maxTransactionFee), nil 2482 case *TokenCreateTransaction: 2483 return i.SetMaxTransactionFee(maxTransactionFee), nil 2484 case *TokenDeleteTransaction: 2485 return i.SetMaxTransactionFee(maxTransactionFee), nil 2486 case *TokenDissociateTransaction: 2487 return i.SetMaxTransactionFee(maxTransactionFee), nil 2488 case *TokenFeeScheduleUpdateTransaction: 2489 return i.SetMaxTransactionFee(maxTransactionFee), nil 2490 case *TokenFreezeTransaction: 2491 return i.SetMaxTransactionFee(maxTransactionFee), nil 2492 case *TokenGrantKycTransaction: 2493 return i.SetMaxTransactionFee(maxTransactionFee), nil 2494 case *TokenMintTransaction: 2495 return i.SetMaxTransactionFee(maxTransactionFee), nil 2496 case *TokenRevokeKycTransaction: 2497 return i.SetMaxTransactionFee(maxTransactionFee), nil 2498 case *TokenUnfreezeTransaction: 2499 return i.SetMaxTransactionFee(maxTransactionFee), nil 2500 case *TokenUpdateTransaction: 2501 return i.SetMaxTransactionFee(maxTransactionFee), nil 2502 case *TokenWipeTransaction: 2503 return i.SetMaxTransactionFee(maxTransactionFee), nil 2504 case *TopicCreateTransaction: 2505 return i.SetMaxTransactionFee(maxTransactionFee), nil 2506 case *TopicDeleteTransaction: 2507 return i.SetMaxTransactionFee(maxTransactionFee), nil 2508 case *TopicMessageSubmitTransaction: 2509 return i.SetMaxTransactionFee(maxTransactionFee), nil 2510 case *TopicUpdateTransaction: 2511 return i.SetMaxTransactionFee(maxTransactionFee), nil 2512 case *TransferTransaction: 2513 return i.SetMaxTransactionFee(maxTransactionFee), nil 2514 default: 2515 return transaction, errors.New("(BUG) non-exhaustive switch statement") 2516 } 2517 } 2518 2519 func TransactionGetMaxTransactionFee(transaction interface{}) (Hbar, error) { // nolint 2520 switch i := transaction.(type) { 2521 case AccountCreateTransaction: 2522 return i.GetMaxTransactionFee(), nil 2523 case AccountDeleteTransaction: 2524 return i.GetMaxTransactionFee(), nil 2525 case AccountUpdateTransaction: 2526 return i.GetMaxTransactionFee(), nil 2527 case AccountAllowanceApproveTransaction: 2528 return i.GetMaxTransactionFee(), nil 2529 case AccountAllowanceDeleteTransaction: 2530 return i.GetMaxTransactionFee(), nil 2531 case ContractCreateTransaction: 2532 return i.GetMaxTransactionFee(), nil 2533 case ContractDeleteTransaction: 2534 return i.GetMaxTransactionFee(), nil 2535 case ContractExecuteTransaction: 2536 return i.GetMaxTransactionFee(), nil 2537 case ContractUpdateTransaction: 2538 return i.GetMaxTransactionFee(), nil 2539 case FileAppendTransaction: 2540 return i.GetMaxTransactionFee(), nil 2541 case FileCreateTransaction: 2542 return i.GetMaxTransactionFee(), nil 2543 case FileDeleteTransaction: 2544 return i.GetMaxTransactionFee(), nil 2545 case FileUpdateTransaction: 2546 return i.GetMaxTransactionFee(), nil 2547 case LiveHashAddTransaction: 2548 return i.GetMaxTransactionFee(), nil 2549 case LiveHashDeleteTransaction: 2550 return i.GetMaxTransactionFee(), nil 2551 case ScheduleCreateTransaction: 2552 return i.GetMaxTransactionFee(), nil 2553 case ScheduleDeleteTransaction: 2554 return i.GetMaxTransactionFee(), nil 2555 case ScheduleSignTransaction: 2556 return i.GetMaxTransactionFee(), nil 2557 case SystemDeleteTransaction: 2558 return i.GetMaxTransactionFee(), nil 2559 case SystemUndeleteTransaction: 2560 return i.GetMaxTransactionFee(), nil 2561 case TokenAssociateTransaction: 2562 return i.GetMaxTransactionFee(), nil 2563 case TokenBurnTransaction: 2564 return i.GetMaxTransactionFee(), nil 2565 case TokenCreateTransaction: 2566 return i.GetMaxTransactionFee(), nil 2567 case TokenDeleteTransaction: 2568 return i.GetMaxTransactionFee(), nil 2569 case TokenDissociateTransaction: 2570 return i.GetMaxTransactionFee(), nil 2571 case TokenFeeScheduleUpdateTransaction: 2572 return i.GetMaxTransactionFee(), nil 2573 case TokenFreezeTransaction: 2574 return i.GetMaxTransactionFee(), nil 2575 case TokenGrantKycTransaction: 2576 return i.GetMaxTransactionFee(), nil 2577 case TokenMintTransaction: 2578 return i.GetMaxTransactionFee(), nil 2579 case TokenRevokeKycTransaction: 2580 return i.GetMaxTransactionFee(), nil 2581 case TokenUnfreezeTransaction: 2582 return i.GetMaxTransactionFee(), nil 2583 case TokenUpdateTransaction: 2584 return i.GetMaxTransactionFee(), nil 2585 case TokenWipeTransaction: 2586 return i.GetMaxTransactionFee(), nil 2587 case TopicCreateTransaction: 2588 return i.GetMaxTransactionFee(), nil 2589 case TopicDeleteTransaction: 2590 return i.GetMaxTransactionFee(), nil 2591 case TopicMessageSubmitTransaction: 2592 return i.GetMaxTransactionFee(), nil 2593 case TopicUpdateTransaction: 2594 return i.GetMaxTransactionFee(), nil 2595 case TransferTransaction: 2596 return i.GetMaxTransactionFee(), nil 2597 case *AccountCreateTransaction: 2598 return i.GetMaxTransactionFee(), nil 2599 case *AccountDeleteTransaction: 2600 return i.GetMaxTransactionFee(), nil 2601 case *AccountUpdateTransaction: 2602 return i.GetMaxTransactionFee(), nil 2603 case *AccountAllowanceApproveTransaction: 2604 return i.GetMaxTransactionFee(), nil 2605 case *AccountAllowanceDeleteTransaction: 2606 return i.GetMaxTransactionFee(), nil 2607 case *ContractCreateTransaction: 2608 return i.GetMaxTransactionFee(), nil 2609 case *ContractDeleteTransaction: 2610 return i.GetMaxTransactionFee(), nil 2611 case *ContractExecuteTransaction: 2612 return i.GetMaxTransactionFee(), nil 2613 case *ContractUpdateTransaction: 2614 return i.GetMaxTransactionFee(), nil 2615 case *FileAppendTransaction: 2616 return i.GetMaxTransactionFee(), nil 2617 case *FileCreateTransaction: 2618 return i.GetMaxTransactionFee(), nil 2619 case *FileDeleteTransaction: 2620 return i.GetMaxTransactionFee(), nil 2621 case *FileUpdateTransaction: 2622 return i.GetMaxTransactionFee(), nil 2623 case *LiveHashAddTransaction: 2624 return i.GetMaxTransactionFee(), nil 2625 case *LiveHashDeleteTransaction: 2626 return i.GetMaxTransactionFee(), nil 2627 case *ScheduleCreateTransaction: 2628 return i.GetMaxTransactionFee(), nil 2629 case *ScheduleDeleteTransaction: 2630 return i.GetMaxTransactionFee(), nil 2631 case *ScheduleSignTransaction: 2632 return i.GetMaxTransactionFee(), nil 2633 case *SystemDeleteTransaction: 2634 return i.GetMaxTransactionFee(), nil 2635 case *SystemUndeleteTransaction: 2636 return i.GetMaxTransactionFee(), nil 2637 case *TokenAssociateTransaction: 2638 return i.GetMaxTransactionFee(), nil 2639 case *TokenBurnTransaction: 2640 return i.GetMaxTransactionFee(), nil 2641 case *TokenCreateTransaction: 2642 return i.GetMaxTransactionFee(), nil 2643 case *TokenDeleteTransaction: 2644 return i.GetMaxTransactionFee(), nil 2645 case *TokenDissociateTransaction: 2646 return i.GetMaxTransactionFee(), nil 2647 case *TokenFeeScheduleUpdateTransaction: 2648 return i.GetMaxTransactionFee(), nil 2649 case *TokenFreezeTransaction: 2650 return i.GetMaxTransactionFee(), nil 2651 case *TokenGrantKycTransaction: 2652 return i.GetMaxTransactionFee(), nil 2653 case *TokenMintTransaction: 2654 return i.GetMaxTransactionFee(), nil 2655 case *TokenRevokeKycTransaction: 2656 return i.GetMaxTransactionFee(), nil 2657 case *TokenUnfreezeTransaction: 2658 return i.GetMaxTransactionFee(), nil 2659 case *TokenUpdateTransaction: 2660 return i.GetMaxTransactionFee(), nil 2661 case *TokenWipeTransaction: 2662 return i.GetMaxTransactionFee(), nil 2663 case *TopicCreateTransaction: 2664 return i.GetMaxTransactionFee(), nil 2665 case *TopicDeleteTransaction: 2666 return i.GetMaxTransactionFee(), nil 2667 case *TopicMessageSubmitTransaction: 2668 return i.GetMaxTransactionFee(), nil 2669 case *TopicUpdateTransaction: 2670 return i.GetMaxTransactionFee(), nil 2671 case *TransferTransaction: 2672 return i.GetMaxTransactionFee(), nil 2673 default: 2674 return Hbar{}, errors.New("(BUG) non-exhaustive switch statement") 2675 } 2676 } 2677 2678 func TransactionSetTransactionValidDuration(transaction interface{}, transactionValidDuration time.Duration) (interface{}, error) { // nolint 2679 switch i := transaction.(type) { 2680 case AccountCreateTransaction: 2681 return i.SetTransactionValidDuration(transactionValidDuration), nil 2682 case AccountDeleteTransaction: 2683 return i.SetTransactionValidDuration(transactionValidDuration), nil 2684 case AccountUpdateTransaction: 2685 return i.SetTransactionValidDuration(transactionValidDuration), nil 2686 case AccountAllowanceApproveTransaction: 2687 return i.SetTransactionValidDuration(transactionValidDuration), nil 2688 case AccountAllowanceDeleteTransaction: 2689 return i.SetTransactionValidDuration(transactionValidDuration), nil 2690 case ContractCreateTransaction: 2691 return i.SetTransactionValidDuration(transactionValidDuration), nil 2692 case ContractDeleteTransaction: 2693 return i.SetTransactionValidDuration(transactionValidDuration), nil 2694 case ContractExecuteTransaction: 2695 return i.SetTransactionValidDuration(transactionValidDuration), nil 2696 case ContractUpdateTransaction: 2697 return i.SetTransactionValidDuration(transactionValidDuration), nil 2698 case FileAppendTransaction: 2699 return i.SetTransactionValidDuration(transactionValidDuration), nil 2700 case FileCreateTransaction: 2701 return i.SetTransactionValidDuration(transactionValidDuration), nil 2702 case FileDeleteTransaction: 2703 return i.SetTransactionValidDuration(transactionValidDuration), nil 2704 case FileUpdateTransaction: 2705 return i.SetTransactionValidDuration(transactionValidDuration), nil 2706 case LiveHashAddTransaction: 2707 return i.SetTransactionValidDuration(transactionValidDuration), nil 2708 case LiveHashDeleteTransaction: 2709 return i.SetTransactionValidDuration(transactionValidDuration), nil 2710 case ScheduleCreateTransaction: 2711 return i.SetTransactionValidDuration(transactionValidDuration), nil 2712 case ScheduleDeleteTransaction: 2713 return i.SetTransactionValidDuration(transactionValidDuration), nil 2714 case ScheduleSignTransaction: 2715 return i.SetTransactionValidDuration(transactionValidDuration), nil 2716 case SystemDeleteTransaction: 2717 return i.SetTransactionValidDuration(transactionValidDuration), nil 2718 case SystemUndeleteTransaction: 2719 return i.SetTransactionValidDuration(transactionValidDuration), nil 2720 case TokenAssociateTransaction: 2721 return i.SetTransactionValidDuration(transactionValidDuration), nil 2722 case TokenBurnTransaction: 2723 return i.SetTransactionValidDuration(transactionValidDuration), nil 2724 case TokenCreateTransaction: 2725 return i.SetTransactionValidDuration(transactionValidDuration), nil 2726 case TokenDeleteTransaction: 2727 return i.SetTransactionValidDuration(transactionValidDuration), nil 2728 case TokenDissociateTransaction: 2729 return i.SetTransactionValidDuration(transactionValidDuration), nil 2730 case TokenFeeScheduleUpdateTransaction: 2731 return i.SetTransactionValidDuration(transactionValidDuration), nil 2732 case TokenFreezeTransaction: 2733 return i.SetTransactionValidDuration(transactionValidDuration), nil 2734 case TokenGrantKycTransaction: 2735 return i.SetTransactionValidDuration(transactionValidDuration), nil 2736 case TokenMintTransaction: 2737 return i.SetTransactionValidDuration(transactionValidDuration), nil 2738 case TokenRevokeKycTransaction: 2739 return i.SetTransactionValidDuration(transactionValidDuration), nil 2740 case TokenUnfreezeTransaction: 2741 return i.SetTransactionValidDuration(transactionValidDuration), nil 2742 case TokenUpdateTransaction: 2743 return i.SetTransactionValidDuration(transactionValidDuration), nil 2744 case TokenWipeTransaction: 2745 return i.SetTransactionValidDuration(transactionValidDuration), nil 2746 case TopicCreateTransaction: 2747 return i.SetTransactionValidDuration(transactionValidDuration), nil 2748 case TopicDeleteTransaction: 2749 return i.SetTransactionValidDuration(transactionValidDuration), nil 2750 case TopicMessageSubmitTransaction: 2751 return i.SetTransactionValidDuration(transactionValidDuration), nil 2752 case TopicUpdateTransaction: 2753 return i.SetTransactionValidDuration(transactionValidDuration), nil 2754 case TransferTransaction: 2755 return i.SetTransactionValidDuration(transactionValidDuration), nil 2756 case *AccountCreateTransaction: 2757 return i.SetTransactionValidDuration(transactionValidDuration), nil 2758 case *AccountDeleteTransaction: 2759 return i.SetTransactionValidDuration(transactionValidDuration), nil 2760 case *AccountUpdateTransaction: 2761 return i.SetTransactionValidDuration(transactionValidDuration), nil 2762 case *AccountAllowanceApproveTransaction: 2763 return i.SetTransactionValidDuration(transactionValidDuration), nil 2764 case *AccountAllowanceDeleteTransaction: 2765 return i.SetTransactionValidDuration(transactionValidDuration), nil 2766 case *ContractCreateTransaction: 2767 return i.SetTransactionValidDuration(transactionValidDuration), nil 2768 case *ContractDeleteTransaction: 2769 return i.SetTransactionValidDuration(transactionValidDuration), nil 2770 case *ContractExecuteTransaction: 2771 return i.SetTransactionValidDuration(transactionValidDuration), nil 2772 case *ContractUpdateTransaction: 2773 return i.SetTransactionValidDuration(transactionValidDuration), nil 2774 case *FileAppendTransaction: 2775 return i.SetTransactionValidDuration(transactionValidDuration), nil 2776 case *FileCreateTransaction: 2777 return i.SetTransactionValidDuration(transactionValidDuration), nil 2778 case *FileDeleteTransaction: 2779 return i.SetTransactionValidDuration(transactionValidDuration), nil 2780 case *FileUpdateTransaction: 2781 return i.SetTransactionValidDuration(transactionValidDuration), nil 2782 case *LiveHashAddTransaction: 2783 return i.SetTransactionValidDuration(transactionValidDuration), nil 2784 case *LiveHashDeleteTransaction: 2785 return i.SetTransactionValidDuration(transactionValidDuration), nil 2786 case *ScheduleCreateTransaction: 2787 return i.SetTransactionValidDuration(transactionValidDuration), nil 2788 case *ScheduleDeleteTransaction: 2789 return i.SetTransactionValidDuration(transactionValidDuration), nil 2790 case *ScheduleSignTransaction: 2791 return i.SetTransactionValidDuration(transactionValidDuration), nil 2792 case *SystemDeleteTransaction: 2793 return i.SetTransactionValidDuration(transactionValidDuration), nil 2794 case *SystemUndeleteTransaction: 2795 return i.SetTransactionValidDuration(transactionValidDuration), nil 2796 case *TokenAssociateTransaction: 2797 return i.SetTransactionValidDuration(transactionValidDuration), nil 2798 case *TokenBurnTransaction: 2799 return i.SetTransactionValidDuration(transactionValidDuration), nil 2800 case *TokenCreateTransaction: 2801 return i.SetTransactionValidDuration(transactionValidDuration), nil 2802 case *TokenDeleteTransaction: 2803 return i.SetTransactionValidDuration(transactionValidDuration), nil 2804 case *TokenDissociateTransaction: 2805 return i.SetTransactionValidDuration(transactionValidDuration), nil 2806 case *TokenFeeScheduleUpdateTransaction: 2807 return i.SetTransactionValidDuration(transactionValidDuration), nil 2808 case *TokenFreezeTransaction: 2809 return i.SetTransactionValidDuration(transactionValidDuration), nil 2810 case *TokenGrantKycTransaction: 2811 return i.SetTransactionValidDuration(transactionValidDuration), nil 2812 case *TokenMintTransaction: 2813 return i.SetTransactionValidDuration(transactionValidDuration), nil 2814 case *TokenRevokeKycTransaction: 2815 return i.SetTransactionValidDuration(transactionValidDuration), nil 2816 case *TokenUnfreezeTransaction: 2817 return i.SetTransactionValidDuration(transactionValidDuration), nil 2818 case *TokenUpdateTransaction: 2819 return i.SetTransactionValidDuration(transactionValidDuration), nil 2820 case *TokenWipeTransaction: 2821 return i.SetTransactionValidDuration(transactionValidDuration), nil 2822 case *TopicCreateTransaction: 2823 return i.SetTransactionValidDuration(transactionValidDuration), nil 2824 case *TopicDeleteTransaction: 2825 return i.SetTransactionValidDuration(transactionValidDuration), nil 2826 case *TopicMessageSubmitTransaction: 2827 return i.SetTransactionValidDuration(transactionValidDuration), nil 2828 case *TopicUpdateTransaction: 2829 return i.SetTransactionValidDuration(transactionValidDuration), nil 2830 case *TransferTransaction: 2831 return i.SetTransactionValidDuration(transactionValidDuration), nil 2832 default: 2833 return transaction, errors.New("(BUG) non-exhaustive switch statement") 2834 } 2835 } 2836 2837 func TransactionGetTransactionValidDuration(transaction interface{}) (time.Duration, error) { // nolint 2838 switch i := transaction.(type) { 2839 case AccountCreateTransaction: 2840 return i.GetTransactionValidDuration(), nil 2841 case AccountDeleteTransaction: 2842 return i.GetTransactionValidDuration(), nil 2843 case AccountUpdateTransaction: 2844 return i.GetTransactionValidDuration(), nil 2845 case AccountAllowanceApproveTransaction: 2846 return i.GetTransactionValidDuration(), nil 2847 case AccountAllowanceDeleteTransaction: 2848 return i.GetTransactionValidDuration(), nil 2849 case ContractCreateTransaction: 2850 return i.GetTransactionValidDuration(), nil 2851 case ContractDeleteTransaction: 2852 return i.GetTransactionValidDuration(), nil 2853 case ContractExecuteTransaction: 2854 return i.GetTransactionValidDuration(), nil 2855 case ContractUpdateTransaction: 2856 return i.GetTransactionValidDuration(), nil 2857 case FileAppendTransaction: 2858 return i.GetTransactionValidDuration(), nil 2859 case FileCreateTransaction: 2860 return i.GetTransactionValidDuration(), nil 2861 case FileDeleteTransaction: 2862 return i.GetTransactionValidDuration(), nil 2863 case FileUpdateTransaction: 2864 return i.GetTransactionValidDuration(), nil 2865 case LiveHashAddTransaction: 2866 return i.GetTransactionValidDuration(), nil 2867 case LiveHashDeleteTransaction: 2868 return i.GetTransactionValidDuration(), nil 2869 case ScheduleCreateTransaction: 2870 return i.GetTransactionValidDuration(), nil 2871 case ScheduleDeleteTransaction: 2872 return i.GetTransactionValidDuration(), nil 2873 case ScheduleSignTransaction: 2874 return i.GetTransactionValidDuration(), nil 2875 case SystemDeleteTransaction: 2876 return i.GetTransactionValidDuration(), nil 2877 case SystemUndeleteTransaction: 2878 return i.GetTransactionValidDuration(), nil 2879 case TokenAssociateTransaction: 2880 return i.GetTransactionValidDuration(), nil 2881 case TokenBurnTransaction: 2882 return i.GetTransactionValidDuration(), nil 2883 case TokenCreateTransaction: 2884 return i.GetTransactionValidDuration(), nil 2885 case TokenDeleteTransaction: 2886 return i.GetTransactionValidDuration(), nil 2887 case TokenDissociateTransaction: 2888 return i.GetTransactionValidDuration(), nil 2889 case TokenFeeScheduleUpdateTransaction: 2890 return i.GetTransactionValidDuration(), nil 2891 case TokenFreezeTransaction: 2892 return i.GetTransactionValidDuration(), nil 2893 case TokenGrantKycTransaction: 2894 return i.GetTransactionValidDuration(), nil 2895 case TokenMintTransaction: 2896 return i.GetTransactionValidDuration(), nil 2897 case TokenRevokeKycTransaction: 2898 return i.GetTransactionValidDuration(), nil 2899 case TokenUnfreezeTransaction: 2900 return i.GetTransactionValidDuration(), nil 2901 case TokenUpdateTransaction: 2902 return i.GetTransactionValidDuration(), nil 2903 case TokenWipeTransaction: 2904 return i.GetTransactionValidDuration(), nil 2905 case TopicCreateTransaction: 2906 return i.GetTransactionValidDuration(), nil 2907 case TopicDeleteTransaction: 2908 return i.GetTransactionValidDuration(), nil 2909 case TopicMessageSubmitTransaction: 2910 return i.GetTransactionValidDuration(), nil 2911 case TopicUpdateTransaction: 2912 return i.GetTransactionValidDuration(), nil 2913 case TransferTransaction: 2914 return i.GetTransactionValidDuration(), nil 2915 case *AccountCreateTransaction: 2916 return i.GetTransactionValidDuration(), nil 2917 case *AccountDeleteTransaction: 2918 return i.GetTransactionValidDuration(), nil 2919 case *AccountUpdateTransaction: 2920 return i.GetTransactionValidDuration(), nil 2921 case *AccountAllowanceApproveTransaction: 2922 return i.GetTransactionValidDuration(), nil 2923 case *AccountAllowanceDeleteTransaction: 2924 return i.GetTransactionValidDuration(), nil 2925 case *ContractCreateTransaction: 2926 return i.GetTransactionValidDuration(), nil 2927 case *ContractDeleteTransaction: 2928 return i.GetTransactionValidDuration(), nil 2929 case *ContractExecuteTransaction: 2930 return i.GetTransactionValidDuration(), nil 2931 case *ContractUpdateTransaction: 2932 return i.GetTransactionValidDuration(), nil 2933 case *FileAppendTransaction: 2934 return i.GetTransactionValidDuration(), nil 2935 case *FileCreateTransaction: 2936 return i.GetTransactionValidDuration(), nil 2937 case *FileDeleteTransaction: 2938 return i.GetTransactionValidDuration(), nil 2939 case *FileUpdateTransaction: 2940 return i.GetTransactionValidDuration(), nil 2941 case *LiveHashAddTransaction: 2942 return i.GetTransactionValidDuration(), nil 2943 case *LiveHashDeleteTransaction: 2944 return i.GetTransactionValidDuration(), nil 2945 case *ScheduleCreateTransaction: 2946 return i.GetTransactionValidDuration(), nil 2947 case *ScheduleDeleteTransaction: 2948 return i.GetTransactionValidDuration(), nil 2949 case *ScheduleSignTransaction: 2950 return i.GetTransactionValidDuration(), nil 2951 case *SystemDeleteTransaction: 2952 return i.GetTransactionValidDuration(), nil 2953 case *SystemUndeleteTransaction: 2954 return i.GetTransactionValidDuration(), nil 2955 case *TokenAssociateTransaction: 2956 return i.GetTransactionValidDuration(), nil 2957 case *TokenBurnTransaction: 2958 return i.GetTransactionValidDuration(), nil 2959 case *TokenCreateTransaction: 2960 return i.GetTransactionValidDuration(), nil 2961 case *TokenDeleteTransaction: 2962 return i.GetTransactionValidDuration(), nil 2963 case *TokenDissociateTransaction: 2964 return i.GetTransactionValidDuration(), nil 2965 case *TokenFeeScheduleUpdateTransaction: 2966 return i.GetTransactionValidDuration(), nil 2967 case *TokenFreezeTransaction: 2968 return i.GetTransactionValidDuration(), nil 2969 case *TokenGrantKycTransaction: 2970 return i.GetTransactionValidDuration(), nil 2971 case *TokenMintTransaction: 2972 return i.GetTransactionValidDuration(), nil 2973 case *TokenRevokeKycTransaction: 2974 return i.GetTransactionValidDuration(), nil 2975 case *TokenUnfreezeTransaction: 2976 return i.GetTransactionValidDuration(), nil 2977 case *TokenUpdateTransaction: 2978 return i.GetTransactionValidDuration(), nil 2979 case *TokenWipeTransaction: 2980 return i.GetTransactionValidDuration(), nil 2981 case *TopicCreateTransaction: 2982 return i.GetTransactionValidDuration(), nil 2983 case *TopicDeleteTransaction: 2984 return i.GetTransactionValidDuration(), nil 2985 case *TopicMessageSubmitTransaction: 2986 return i.GetTransactionValidDuration(), nil 2987 case *TopicUpdateTransaction: 2988 return i.GetTransactionValidDuration(), nil 2989 case *TransferTransaction: 2990 return i.GetTransactionValidDuration(), nil 2991 default: 2992 return time.Duration(0), errors.New("(BUG) non-exhaustive switch statement") 2993 } 2994 } 2995 2996 func TransactionSetNodeAccountIDs(transaction interface{}, nodeAccountIDs []AccountID) (interface{}, error) { // nolint 2997 switch i := transaction.(type) { 2998 case AccountCreateTransaction: 2999 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3000 case AccountDeleteTransaction: 3001 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3002 case AccountUpdateTransaction: 3003 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3004 case AccountAllowanceApproveTransaction: 3005 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3006 case AccountAllowanceDeleteTransaction: 3007 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3008 case ContractCreateTransaction: 3009 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3010 case ContractDeleteTransaction: 3011 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3012 case ContractExecuteTransaction: 3013 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3014 case ContractUpdateTransaction: 3015 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3016 case FileAppendTransaction: 3017 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3018 case FileCreateTransaction: 3019 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3020 case FileDeleteTransaction: 3021 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3022 case FileUpdateTransaction: 3023 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3024 case LiveHashAddTransaction: 3025 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3026 case LiveHashDeleteTransaction: 3027 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3028 case ScheduleCreateTransaction: 3029 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3030 case ScheduleDeleteTransaction: 3031 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3032 case ScheduleSignTransaction: 3033 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3034 case SystemDeleteTransaction: 3035 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3036 case SystemUndeleteTransaction: 3037 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3038 case TokenAssociateTransaction: 3039 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3040 case TokenBurnTransaction: 3041 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3042 case TokenCreateTransaction: 3043 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3044 case TokenDeleteTransaction: 3045 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3046 case TokenDissociateTransaction: 3047 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3048 case TokenFeeScheduleUpdateTransaction: 3049 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3050 case TokenFreezeTransaction: 3051 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3052 case TokenGrantKycTransaction: 3053 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3054 case TokenMintTransaction: 3055 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3056 case TokenRevokeKycTransaction: 3057 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3058 case TokenUnfreezeTransaction: 3059 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3060 case TokenUpdateTransaction: 3061 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3062 case TokenWipeTransaction: 3063 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3064 case TopicCreateTransaction: 3065 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3066 case TopicDeleteTransaction: 3067 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3068 case TopicMessageSubmitTransaction: 3069 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3070 case TopicUpdateTransaction: 3071 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3072 case TransferTransaction: 3073 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3074 case *AccountCreateTransaction: 3075 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3076 case *AccountDeleteTransaction: 3077 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3078 case *AccountUpdateTransaction: 3079 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3080 case *AccountAllowanceApproveTransaction: 3081 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3082 case *AccountAllowanceDeleteTransaction: 3083 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3084 case *ContractCreateTransaction: 3085 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3086 case *ContractDeleteTransaction: 3087 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3088 case *ContractExecuteTransaction: 3089 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3090 case *ContractUpdateTransaction: 3091 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3092 case *FileAppendTransaction: 3093 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3094 case *FileCreateTransaction: 3095 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3096 case *FileDeleteTransaction: 3097 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3098 case *FileUpdateTransaction: 3099 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3100 case *LiveHashAddTransaction: 3101 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3102 case *LiveHashDeleteTransaction: 3103 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3104 case *ScheduleCreateTransaction: 3105 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3106 case *ScheduleDeleteTransaction: 3107 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3108 case *ScheduleSignTransaction: 3109 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3110 case *SystemDeleteTransaction: 3111 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3112 case *SystemUndeleteTransaction: 3113 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3114 case *TokenAssociateTransaction: 3115 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3116 case *TokenBurnTransaction: 3117 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3118 case *TokenCreateTransaction: 3119 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3120 case *TokenDeleteTransaction: 3121 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3122 case *TokenDissociateTransaction: 3123 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3124 case *TokenFeeScheduleUpdateTransaction: 3125 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3126 case *TokenFreezeTransaction: 3127 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3128 case *TokenGrantKycTransaction: 3129 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3130 case *TokenMintTransaction: 3131 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3132 case *TokenRevokeKycTransaction: 3133 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3134 case *TokenUnfreezeTransaction: 3135 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3136 case *TokenUpdateTransaction: 3137 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3138 case *TokenWipeTransaction: 3139 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3140 case *TopicCreateTransaction: 3141 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3142 case *TopicDeleteTransaction: 3143 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3144 case *TopicMessageSubmitTransaction: 3145 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3146 case *TopicUpdateTransaction: 3147 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3148 case *TransferTransaction: 3149 return i.SetNodeAccountIDs(nodeAccountIDs), nil 3150 default: 3151 return transaction, errors.New("(BUG) non-exhaustive switch statement") 3152 } 3153 } 3154 3155 func TransactionGetNodeAccountIDs(transaction interface{}) ([]AccountID, error) { // nolint 3156 switch i := transaction.(type) { 3157 case AccountCreateTransaction: 3158 return i.GetNodeAccountIDs(), nil 3159 case AccountDeleteTransaction: 3160 return i.GetNodeAccountIDs(), nil 3161 case AccountUpdateTransaction: 3162 return i.GetNodeAccountIDs(), nil 3163 case AccountAllowanceApproveTransaction: 3164 return i.GetNodeAccountIDs(), nil 3165 case AccountAllowanceDeleteTransaction: 3166 return i.GetNodeAccountIDs(), nil 3167 case ContractCreateTransaction: 3168 return i.GetNodeAccountIDs(), nil 3169 case ContractDeleteTransaction: 3170 return i.GetNodeAccountIDs(), nil 3171 case ContractExecuteTransaction: 3172 return i.GetNodeAccountIDs(), nil 3173 case ContractUpdateTransaction: 3174 return i.GetNodeAccountIDs(), nil 3175 case FileAppendTransaction: 3176 return i.GetNodeAccountIDs(), nil 3177 case FileCreateTransaction: 3178 return i.GetNodeAccountIDs(), nil 3179 case FileDeleteTransaction: 3180 return i.GetNodeAccountIDs(), nil 3181 case FileUpdateTransaction: 3182 return i.GetNodeAccountIDs(), nil 3183 case LiveHashAddTransaction: 3184 return i.GetNodeAccountIDs(), nil 3185 case LiveHashDeleteTransaction: 3186 return i.GetNodeAccountIDs(), nil 3187 case ScheduleCreateTransaction: 3188 return i.GetNodeAccountIDs(), nil 3189 case ScheduleDeleteTransaction: 3190 return i.GetNodeAccountIDs(), nil 3191 case ScheduleSignTransaction: 3192 return i.GetNodeAccountIDs(), nil 3193 case SystemDeleteTransaction: 3194 return i.GetNodeAccountIDs(), nil 3195 case SystemUndeleteTransaction: 3196 return i.GetNodeAccountIDs(), nil 3197 case TokenAssociateTransaction: 3198 return i.GetNodeAccountIDs(), nil 3199 case TokenBurnTransaction: 3200 return i.GetNodeAccountIDs(), nil 3201 case TokenCreateTransaction: 3202 return i.GetNodeAccountIDs(), nil 3203 case TokenDeleteTransaction: 3204 return i.GetNodeAccountIDs(), nil 3205 case TokenDissociateTransaction: 3206 return i.GetNodeAccountIDs(), nil 3207 case TokenFeeScheduleUpdateTransaction: 3208 return i.GetNodeAccountIDs(), nil 3209 case TokenFreezeTransaction: 3210 return i.GetNodeAccountIDs(), nil 3211 case TokenGrantKycTransaction: 3212 return i.GetNodeAccountIDs(), nil 3213 case TokenMintTransaction: 3214 return i.GetNodeAccountIDs(), nil 3215 case TokenRevokeKycTransaction: 3216 return i.GetNodeAccountIDs(), nil 3217 case TokenUnfreezeTransaction: 3218 return i.GetNodeAccountIDs(), nil 3219 case TokenUpdateTransaction: 3220 return i.GetNodeAccountIDs(), nil 3221 case TokenWipeTransaction: 3222 return i.GetNodeAccountIDs(), nil 3223 case TopicCreateTransaction: 3224 return i.GetNodeAccountIDs(), nil 3225 case TopicDeleteTransaction: 3226 return i.GetNodeAccountIDs(), nil 3227 case TopicMessageSubmitTransaction: 3228 return i.GetNodeAccountIDs(), nil 3229 case TopicUpdateTransaction: 3230 return i.GetNodeAccountIDs(), nil 3231 case TransferTransaction: 3232 return i.GetNodeAccountIDs(), nil 3233 case *AccountCreateTransaction: 3234 return i.GetNodeAccountIDs(), nil 3235 case *AccountDeleteTransaction: 3236 return i.GetNodeAccountIDs(), nil 3237 case *AccountUpdateTransaction: 3238 return i.GetNodeAccountIDs(), nil 3239 case *AccountAllowanceApproveTransaction: 3240 return i.GetNodeAccountIDs(), nil 3241 case *AccountAllowanceDeleteTransaction: 3242 return i.GetNodeAccountIDs(), nil 3243 case *ContractCreateTransaction: 3244 return i.GetNodeAccountIDs(), nil 3245 case *ContractDeleteTransaction: 3246 return i.GetNodeAccountIDs(), nil 3247 case *ContractExecuteTransaction: 3248 return i.GetNodeAccountIDs(), nil 3249 case *ContractUpdateTransaction: 3250 return i.GetNodeAccountIDs(), nil 3251 case *FileAppendTransaction: 3252 return i.GetNodeAccountIDs(), nil 3253 case *FileCreateTransaction: 3254 return i.GetNodeAccountIDs(), nil 3255 case *FileDeleteTransaction: 3256 return i.GetNodeAccountIDs(), nil 3257 case *FileUpdateTransaction: 3258 return i.GetNodeAccountIDs(), nil 3259 case *LiveHashAddTransaction: 3260 return i.GetNodeAccountIDs(), nil 3261 case *LiveHashDeleteTransaction: 3262 return i.GetNodeAccountIDs(), nil 3263 case *ScheduleCreateTransaction: 3264 return i.GetNodeAccountIDs(), nil 3265 case *ScheduleDeleteTransaction: 3266 return i.GetNodeAccountIDs(), nil 3267 case *ScheduleSignTransaction: 3268 return i.GetNodeAccountIDs(), nil 3269 case *SystemDeleteTransaction: 3270 return i.GetNodeAccountIDs(), nil 3271 case *SystemUndeleteTransaction: 3272 return i.GetNodeAccountIDs(), nil 3273 case *TokenAssociateTransaction: 3274 return i.GetNodeAccountIDs(), nil 3275 case *TokenBurnTransaction: 3276 return i.GetNodeAccountIDs(), nil 3277 case *TokenCreateTransaction: 3278 return i.GetNodeAccountIDs(), nil 3279 case *TokenDeleteTransaction: 3280 return i.GetNodeAccountIDs(), nil 3281 case *TokenDissociateTransaction: 3282 return i.GetNodeAccountIDs(), nil 3283 case *TokenFeeScheduleUpdateTransaction: 3284 return i.GetNodeAccountIDs(), nil 3285 case *TokenFreezeTransaction: 3286 return i.GetNodeAccountIDs(), nil 3287 case *TokenGrantKycTransaction: 3288 return i.GetNodeAccountIDs(), nil 3289 case *TokenMintTransaction: 3290 return i.GetNodeAccountIDs(), nil 3291 case *TokenRevokeKycTransaction: 3292 return i.GetNodeAccountIDs(), nil 3293 case *TokenUnfreezeTransaction: 3294 return i.GetNodeAccountIDs(), nil 3295 case *TokenUpdateTransaction: 3296 return i.GetNodeAccountIDs(), nil 3297 case *TokenWipeTransaction: 3298 return i.GetNodeAccountIDs(), nil 3299 case *TopicCreateTransaction: 3300 return i.GetNodeAccountIDs(), nil 3301 case *TopicDeleteTransaction: 3302 return i.GetNodeAccountIDs(), nil 3303 case *TopicMessageSubmitTransaction: 3304 return i.GetNodeAccountIDs(), nil 3305 case *TopicUpdateTransaction: 3306 return i.GetNodeAccountIDs(), nil 3307 case *TransferTransaction: 3308 return i.GetNodeAccountIDs(), nil 3309 default: 3310 return []AccountID{}, errors.New("(BUG) non-exhaustive switch statement") 3311 } 3312 } 3313 3314 func TransactionGetTransactionHash(transaction interface{}) ([]byte, error) { // nolint 3315 switch i := transaction.(type) { 3316 case AccountCreateTransaction: 3317 return i.GetTransactionHash() 3318 case AccountDeleteTransaction: 3319 return i.GetTransactionHash() 3320 case AccountUpdateTransaction: 3321 return i.GetTransactionHash() 3322 case AccountAllowanceApproveTransaction: 3323 return i.GetTransactionHash() 3324 case AccountAllowanceDeleteTransaction: 3325 return i.GetTransactionHash() 3326 case ContractCreateTransaction: 3327 return i.GetTransactionHash() 3328 case ContractDeleteTransaction: 3329 return i.GetTransactionHash() 3330 case ContractExecuteTransaction: 3331 return i.GetTransactionHash() 3332 case ContractUpdateTransaction: 3333 return i.GetTransactionHash() 3334 case FileAppendTransaction: 3335 return i.GetTransactionHash() 3336 case FileCreateTransaction: 3337 return i.GetTransactionHash() 3338 case FileDeleteTransaction: 3339 return i.GetTransactionHash() 3340 case FileUpdateTransaction: 3341 return i.GetTransactionHash() 3342 case LiveHashAddTransaction: 3343 return i.GetTransactionHash() 3344 case LiveHashDeleteTransaction: 3345 return i.GetTransactionHash() 3346 case ScheduleCreateTransaction: 3347 return i.GetTransactionHash() 3348 case ScheduleDeleteTransaction: 3349 return i.GetTransactionHash() 3350 case ScheduleSignTransaction: 3351 return i.GetTransactionHash() 3352 case SystemDeleteTransaction: 3353 return i.GetTransactionHash() 3354 case SystemUndeleteTransaction: 3355 return i.GetTransactionHash() 3356 case TokenAssociateTransaction: 3357 return i.GetTransactionHash() 3358 case TokenBurnTransaction: 3359 return i.GetTransactionHash() 3360 case TokenCreateTransaction: 3361 return i.GetTransactionHash() 3362 case TokenDeleteTransaction: 3363 return i.GetTransactionHash() 3364 case TokenDissociateTransaction: 3365 return i.GetTransactionHash() 3366 case TokenFeeScheduleUpdateTransaction: 3367 return i.GetTransactionHash() 3368 case TokenFreezeTransaction: 3369 return i.GetTransactionHash() 3370 case TokenGrantKycTransaction: 3371 return i.GetTransactionHash() 3372 case TokenMintTransaction: 3373 return i.GetTransactionHash() 3374 case TokenRevokeKycTransaction: 3375 return i.GetTransactionHash() 3376 case TokenUnfreezeTransaction: 3377 return i.GetTransactionHash() 3378 case TokenUpdateTransaction: 3379 return i.GetTransactionHash() 3380 case TokenWipeTransaction: 3381 return i.GetTransactionHash() 3382 case TopicCreateTransaction: 3383 return i.GetTransactionHash() 3384 case TopicDeleteTransaction: 3385 return i.GetTransactionHash() 3386 case TopicMessageSubmitTransaction: 3387 return i.GetTransactionHash() 3388 case TopicUpdateTransaction: 3389 return i.GetTransactionHash() 3390 case TransferTransaction: 3391 return i.GetTransactionHash() 3392 case *AccountCreateTransaction: 3393 return i.GetTransactionHash() 3394 case *AccountDeleteTransaction: 3395 return i.GetTransactionHash() 3396 case *AccountUpdateTransaction: 3397 return i.GetTransactionHash() 3398 case *AccountAllowanceApproveTransaction: 3399 return i.GetTransactionHash() 3400 case *AccountAllowanceDeleteTransaction: 3401 return i.GetTransactionHash() 3402 case *ContractCreateTransaction: 3403 return i.GetTransactionHash() 3404 case *ContractDeleteTransaction: 3405 return i.GetTransactionHash() 3406 case *ContractExecuteTransaction: 3407 return i.GetTransactionHash() 3408 case *ContractUpdateTransaction: 3409 return i.GetTransactionHash() 3410 case *FileAppendTransaction: 3411 return i.GetTransactionHash() 3412 case *FileCreateTransaction: 3413 return i.GetTransactionHash() 3414 case *FileDeleteTransaction: 3415 return i.GetTransactionHash() 3416 case *FileUpdateTransaction: 3417 return i.GetTransactionHash() 3418 case *LiveHashAddTransaction: 3419 return i.GetTransactionHash() 3420 case *LiveHashDeleteTransaction: 3421 return i.GetTransactionHash() 3422 case *ScheduleCreateTransaction: 3423 return i.GetTransactionHash() 3424 case *ScheduleDeleteTransaction: 3425 return i.GetTransactionHash() 3426 case *ScheduleSignTransaction: 3427 return i.GetTransactionHash() 3428 case *SystemDeleteTransaction: 3429 return i.GetTransactionHash() 3430 case *SystemUndeleteTransaction: 3431 return i.GetTransactionHash() 3432 case *TokenAssociateTransaction: 3433 return i.GetTransactionHash() 3434 case *TokenBurnTransaction: 3435 return i.GetTransactionHash() 3436 case *TokenCreateTransaction: 3437 return i.GetTransactionHash() 3438 case *TokenDeleteTransaction: 3439 return i.GetTransactionHash() 3440 case *TokenDissociateTransaction: 3441 return i.GetTransactionHash() 3442 case *TokenFeeScheduleUpdateTransaction: 3443 return i.GetTransactionHash() 3444 case *TokenFreezeTransaction: 3445 return i.GetTransactionHash() 3446 case *TokenGrantKycTransaction: 3447 return i.GetTransactionHash() 3448 case *TokenMintTransaction: 3449 return i.GetTransactionHash() 3450 case *TokenRevokeKycTransaction: 3451 return i.GetTransactionHash() 3452 case *TokenUnfreezeTransaction: 3453 return i.GetTransactionHash() 3454 case *TokenUpdateTransaction: 3455 return i.GetTransactionHash() 3456 case *TokenWipeTransaction: 3457 return i.GetTransactionHash() 3458 case *TopicCreateTransaction: 3459 return i.GetTransactionHash() 3460 case *TopicDeleteTransaction: 3461 return i.GetTransactionHash() 3462 case *TopicMessageSubmitTransaction: 3463 return i.GetTransactionHash() 3464 case *TopicUpdateTransaction: 3465 return i.GetTransactionHash() 3466 case *TransferTransaction: 3467 return i.GetTransactionHash() 3468 default: 3469 return nil, errors.New("(BUG) non-exhaustive switch statement") 3470 } 3471 } 3472 3473 func TransactionGetTransactionHashPerNode(transaction interface{}) (map[AccountID][]byte, error) { // nolint 3474 switch i := transaction.(type) { 3475 case AccountCreateTransaction: 3476 return i.GetTransactionHashPerNode() 3477 case AccountDeleteTransaction: 3478 return i.GetTransactionHashPerNode() 3479 case AccountUpdateTransaction: 3480 return i.GetTransactionHashPerNode() 3481 case AccountAllowanceApproveTransaction: 3482 return i.GetTransactionHashPerNode() 3483 case AccountAllowanceDeleteTransaction: 3484 return i.GetTransactionHashPerNode() 3485 case ContractCreateTransaction: 3486 return i.GetTransactionHashPerNode() 3487 case ContractDeleteTransaction: 3488 return i.GetTransactionHashPerNode() 3489 case ContractExecuteTransaction: 3490 return i.GetTransactionHashPerNode() 3491 case ContractUpdateTransaction: 3492 return i.GetTransactionHashPerNode() 3493 case FileAppendTransaction: 3494 return i.GetTransactionHashPerNode() 3495 case FileCreateTransaction: 3496 return i.GetTransactionHashPerNode() 3497 case FileDeleteTransaction: 3498 return i.GetTransactionHashPerNode() 3499 case FileUpdateTransaction: 3500 return i.GetTransactionHashPerNode() 3501 case LiveHashAddTransaction: 3502 return i.GetTransactionHashPerNode() 3503 case LiveHashDeleteTransaction: 3504 return i.GetTransactionHashPerNode() 3505 case ScheduleCreateTransaction: 3506 return i.GetTransactionHashPerNode() 3507 case ScheduleDeleteTransaction: 3508 return i.GetTransactionHashPerNode() 3509 case ScheduleSignTransaction: 3510 return i.GetTransactionHashPerNode() 3511 case SystemDeleteTransaction: 3512 return i.GetTransactionHashPerNode() 3513 case SystemUndeleteTransaction: 3514 return i.GetTransactionHashPerNode() 3515 case TokenAssociateTransaction: 3516 return i.GetTransactionHashPerNode() 3517 case TokenBurnTransaction: 3518 return i.GetTransactionHashPerNode() 3519 case TokenCreateTransaction: 3520 return i.GetTransactionHashPerNode() 3521 case TokenDeleteTransaction: 3522 return i.GetTransactionHashPerNode() 3523 case TokenDissociateTransaction: 3524 return i.GetTransactionHashPerNode() 3525 case TokenFeeScheduleUpdateTransaction: 3526 return i.GetTransactionHashPerNode() 3527 case TokenFreezeTransaction: 3528 return i.GetTransactionHashPerNode() 3529 case TokenGrantKycTransaction: 3530 return i.GetTransactionHashPerNode() 3531 case TokenMintTransaction: 3532 return i.GetTransactionHashPerNode() 3533 case TokenRevokeKycTransaction: 3534 return i.GetTransactionHashPerNode() 3535 case TokenUnfreezeTransaction: 3536 return i.GetTransactionHashPerNode() 3537 case TokenUpdateTransaction: 3538 return i.GetTransactionHashPerNode() 3539 case TokenWipeTransaction: 3540 return i.GetTransactionHashPerNode() 3541 case TopicCreateTransaction: 3542 return i.GetTransactionHashPerNode() 3543 case TopicDeleteTransaction: 3544 return i.GetTransactionHashPerNode() 3545 case TopicMessageSubmitTransaction: 3546 return i.GetTransactionHashPerNode() 3547 case TopicUpdateTransaction: 3548 return i.GetTransactionHashPerNode() 3549 case TransferTransaction: 3550 return i.GetTransactionHashPerNode() 3551 case *AccountCreateTransaction: 3552 return i.GetTransactionHashPerNode() 3553 case *AccountDeleteTransaction: 3554 return i.GetTransactionHashPerNode() 3555 case *AccountUpdateTransaction: 3556 return i.GetTransactionHashPerNode() 3557 case *AccountAllowanceApproveTransaction: 3558 return i.GetTransactionHashPerNode() 3559 case *AccountAllowanceDeleteTransaction: 3560 return i.GetTransactionHashPerNode() 3561 case *ContractCreateTransaction: 3562 return i.GetTransactionHashPerNode() 3563 case *ContractDeleteTransaction: 3564 return i.GetTransactionHashPerNode() 3565 case *ContractExecuteTransaction: 3566 return i.GetTransactionHashPerNode() 3567 case *ContractUpdateTransaction: 3568 return i.GetTransactionHashPerNode() 3569 case *FileAppendTransaction: 3570 return i.GetTransactionHashPerNode() 3571 case *FileCreateTransaction: 3572 return i.GetTransactionHashPerNode() 3573 case *FileDeleteTransaction: 3574 return i.GetTransactionHashPerNode() 3575 case *FileUpdateTransaction: 3576 return i.GetTransactionHashPerNode() 3577 case *LiveHashAddTransaction: 3578 return i.GetTransactionHashPerNode() 3579 case *LiveHashDeleteTransaction: 3580 return i.GetTransactionHashPerNode() 3581 case *ScheduleCreateTransaction: 3582 return i.GetTransactionHashPerNode() 3583 case *ScheduleDeleteTransaction: 3584 return i.GetTransactionHashPerNode() 3585 case *ScheduleSignTransaction: 3586 return i.GetTransactionHashPerNode() 3587 case *SystemDeleteTransaction: 3588 return i.GetTransactionHashPerNode() 3589 case *SystemUndeleteTransaction: 3590 return i.GetTransactionHashPerNode() 3591 case *TokenAssociateTransaction: 3592 return i.GetTransactionHashPerNode() 3593 case *TokenBurnTransaction: 3594 return i.GetTransactionHashPerNode() 3595 case *TokenCreateTransaction: 3596 return i.GetTransactionHashPerNode() 3597 case *TokenDeleteTransaction: 3598 return i.GetTransactionHashPerNode() 3599 case *TokenDissociateTransaction: 3600 return i.GetTransactionHashPerNode() 3601 case *TokenFeeScheduleUpdateTransaction: 3602 return i.GetTransactionHashPerNode() 3603 case *TokenFreezeTransaction: 3604 return i.GetTransactionHashPerNode() 3605 case *TokenGrantKycTransaction: 3606 return i.GetTransactionHashPerNode() 3607 case *TokenMintTransaction: 3608 return i.GetTransactionHashPerNode() 3609 case *TokenRevokeKycTransaction: 3610 return i.GetTransactionHashPerNode() 3611 case *TokenUnfreezeTransaction: 3612 return i.GetTransactionHashPerNode() 3613 case *TokenUpdateTransaction: 3614 return i.GetTransactionHashPerNode() 3615 case *TokenWipeTransaction: 3616 return i.GetTransactionHashPerNode() 3617 case *TopicCreateTransaction: 3618 return i.GetTransactionHashPerNode() 3619 case *TopicDeleteTransaction: 3620 return i.GetTransactionHashPerNode() 3621 case *TopicMessageSubmitTransaction: 3622 return i.GetTransactionHashPerNode() 3623 case *TopicUpdateTransaction: 3624 return i.GetTransactionHashPerNode() 3625 case *TransferTransaction: 3626 return i.GetTransactionHashPerNode() 3627 default: 3628 return nil, errors.New("(BUG) non-exhaustive switch statement") 3629 } 3630 } 3631 3632 func TransactionSetMinBackoff(transaction interface{}, minBackoff time.Duration) (interface{}, error) { // nolint 3633 switch i := transaction.(type) { 3634 case AccountCreateTransaction: 3635 return i.SetMinBackoff(minBackoff), nil 3636 case AccountDeleteTransaction: 3637 return i.SetMinBackoff(minBackoff), nil 3638 case AccountUpdateTransaction: 3639 return i.SetMinBackoff(minBackoff), nil 3640 case AccountAllowanceApproveTransaction: 3641 return i.SetMinBackoff(minBackoff), nil 3642 case AccountAllowanceDeleteTransaction: 3643 return i.SetMinBackoff(minBackoff), nil 3644 case ContractCreateTransaction: 3645 return i.SetMinBackoff(minBackoff), nil 3646 case ContractDeleteTransaction: 3647 return i.SetMinBackoff(minBackoff), nil 3648 case ContractExecuteTransaction: 3649 return i.SetMinBackoff(minBackoff), nil 3650 case ContractUpdateTransaction: 3651 return i.SetMinBackoff(minBackoff), nil 3652 case FileAppendTransaction: 3653 return i.SetMinBackoff(minBackoff), nil 3654 case FileCreateTransaction: 3655 return i.SetMinBackoff(minBackoff), nil 3656 case FileDeleteTransaction: 3657 return i.SetMinBackoff(minBackoff), nil 3658 case FileUpdateTransaction: 3659 return i.SetMinBackoff(minBackoff), nil 3660 case LiveHashAddTransaction: 3661 return i.SetMinBackoff(minBackoff), nil 3662 case LiveHashDeleteTransaction: 3663 return i.SetMinBackoff(minBackoff), nil 3664 case ScheduleCreateTransaction: 3665 return i.SetMinBackoff(minBackoff), nil 3666 case ScheduleDeleteTransaction: 3667 return i.SetMinBackoff(minBackoff), nil 3668 case ScheduleSignTransaction: 3669 return i.SetMinBackoff(minBackoff), nil 3670 case SystemDeleteTransaction: 3671 return i.SetMinBackoff(minBackoff), nil 3672 case SystemUndeleteTransaction: 3673 return i.SetMinBackoff(minBackoff), nil 3674 case TokenAssociateTransaction: 3675 return i.SetMinBackoff(minBackoff), nil 3676 case TokenBurnTransaction: 3677 return i.SetMinBackoff(minBackoff), nil 3678 case TokenCreateTransaction: 3679 return i.SetMinBackoff(minBackoff), nil 3680 case TokenDeleteTransaction: 3681 return i.SetMinBackoff(minBackoff), nil 3682 case TokenDissociateTransaction: 3683 return i.SetMinBackoff(minBackoff), nil 3684 case TokenFeeScheduleUpdateTransaction: 3685 return i.SetMinBackoff(minBackoff), nil 3686 case TokenFreezeTransaction: 3687 return i.SetMinBackoff(minBackoff), nil 3688 case TokenGrantKycTransaction: 3689 return i.SetMinBackoff(minBackoff), nil 3690 case TokenMintTransaction: 3691 return i.SetMinBackoff(minBackoff), nil 3692 case TokenRevokeKycTransaction: 3693 return i.SetMinBackoff(minBackoff), nil 3694 case TokenUnfreezeTransaction: 3695 return i.SetMinBackoff(minBackoff), nil 3696 case TokenUpdateTransaction: 3697 return i.SetMinBackoff(minBackoff), nil 3698 case TokenWipeTransaction: 3699 return i.SetMinBackoff(minBackoff), nil 3700 case TopicCreateTransaction: 3701 return i.SetMinBackoff(minBackoff), nil 3702 case TopicDeleteTransaction: 3703 return i.SetMinBackoff(minBackoff), nil 3704 case TopicMessageSubmitTransaction: 3705 return i.SetMinBackoff(minBackoff), nil 3706 case TopicUpdateTransaction: 3707 return i.SetMinBackoff(minBackoff), nil 3708 case TransferTransaction: 3709 return i.SetMinBackoff(minBackoff), nil 3710 case *AccountCreateTransaction: 3711 return i.SetMinBackoff(minBackoff), nil 3712 case *AccountDeleteTransaction: 3713 return i.SetMinBackoff(minBackoff), nil 3714 case *AccountUpdateTransaction: 3715 return i.SetMinBackoff(minBackoff), nil 3716 case *AccountAllowanceApproveTransaction: 3717 return i.SetMinBackoff(minBackoff), nil 3718 case *AccountAllowanceDeleteTransaction: 3719 return i.SetMinBackoff(minBackoff), nil 3720 case *ContractCreateTransaction: 3721 return i.SetMinBackoff(minBackoff), nil 3722 case *ContractDeleteTransaction: 3723 return i.SetMinBackoff(minBackoff), nil 3724 case *ContractExecuteTransaction: 3725 return i.SetMinBackoff(minBackoff), nil 3726 case *ContractUpdateTransaction: 3727 return i.SetMinBackoff(minBackoff), nil 3728 case *FileAppendTransaction: 3729 return i.SetMinBackoff(minBackoff), nil 3730 case *FileCreateTransaction: 3731 return i.SetMinBackoff(minBackoff), nil 3732 case *FileDeleteTransaction: 3733 return i.SetMinBackoff(minBackoff), nil 3734 case *FileUpdateTransaction: 3735 return i.SetMinBackoff(minBackoff), nil 3736 case *LiveHashAddTransaction: 3737 return i.SetMinBackoff(minBackoff), nil 3738 case *LiveHashDeleteTransaction: 3739 return i.SetMinBackoff(minBackoff), nil 3740 case *ScheduleCreateTransaction: 3741 return i.SetMinBackoff(minBackoff), nil 3742 case *ScheduleDeleteTransaction: 3743 return i.SetMinBackoff(minBackoff), nil 3744 case *ScheduleSignTransaction: 3745 return i.SetMinBackoff(minBackoff), nil 3746 case *SystemDeleteTransaction: 3747 return i.SetMinBackoff(minBackoff), nil 3748 case *SystemUndeleteTransaction: 3749 return i.SetMinBackoff(minBackoff), nil 3750 case *TokenAssociateTransaction: 3751 return i.SetMinBackoff(minBackoff), nil 3752 case *TokenBurnTransaction: 3753 return i.SetMinBackoff(minBackoff), nil 3754 case *TokenCreateTransaction: 3755 return i.SetMinBackoff(minBackoff), nil 3756 case *TokenDeleteTransaction: 3757 return i.SetMinBackoff(minBackoff), nil 3758 case *TokenDissociateTransaction: 3759 return i.SetMinBackoff(minBackoff), nil 3760 case *TokenFeeScheduleUpdateTransaction: 3761 return i.SetMinBackoff(minBackoff), nil 3762 case *TokenFreezeTransaction: 3763 return i.SetMinBackoff(minBackoff), nil 3764 case *TokenGrantKycTransaction: 3765 return i.SetMinBackoff(minBackoff), nil 3766 case *TokenMintTransaction: 3767 return i.SetMinBackoff(minBackoff), nil 3768 case *TokenRevokeKycTransaction: 3769 return i.SetMinBackoff(minBackoff), nil 3770 case *TokenUnfreezeTransaction: 3771 return i.SetMinBackoff(minBackoff), nil 3772 case *TokenUpdateTransaction: 3773 return i.SetMinBackoff(minBackoff), nil 3774 case *TokenWipeTransaction: 3775 return i.SetMinBackoff(minBackoff), nil 3776 case *TopicCreateTransaction: 3777 return i.SetMinBackoff(minBackoff), nil 3778 case *TopicDeleteTransaction: 3779 return i.SetMinBackoff(minBackoff), nil 3780 case *TopicMessageSubmitTransaction: 3781 return i.SetMinBackoff(minBackoff), nil 3782 case *TopicUpdateTransaction: 3783 return i.SetMinBackoff(minBackoff), nil 3784 case *TransferTransaction: 3785 return i.SetMinBackoff(minBackoff), nil 3786 default: 3787 return transaction, errors.New("(BUG) non-exhaustive switch statement") 3788 } 3789 } 3790 3791 func TransactionGetMinBackoff(transaction interface{}) (time.Duration, error) { // nolint 3792 switch i := transaction.(type) { 3793 case AccountCreateTransaction: 3794 return i.GetMinBackoff(), nil 3795 case AccountDeleteTransaction: 3796 return i.GetMinBackoff(), nil 3797 case AccountUpdateTransaction: 3798 return i.GetMinBackoff(), nil 3799 case AccountAllowanceApproveTransaction: 3800 return i.GetMinBackoff(), nil 3801 case AccountAllowanceDeleteTransaction: 3802 return i.GetMinBackoff(), nil 3803 case ContractCreateTransaction: 3804 return i.GetMinBackoff(), nil 3805 case ContractDeleteTransaction: 3806 return i.GetMinBackoff(), nil 3807 case ContractExecuteTransaction: 3808 return i.GetMinBackoff(), nil 3809 case ContractUpdateTransaction: 3810 return i.GetMinBackoff(), nil 3811 case FileAppendTransaction: 3812 return i.GetMinBackoff(), nil 3813 case FileCreateTransaction: 3814 return i.GetMinBackoff(), nil 3815 case FileDeleteTransaction: 3816 return i.GetMinBackoff(), nil 3817 case FileUpdateTransaction: 3818 return i.GetMinBackoff(), nil 3819 case LiveHashAddTransaction: 3820 return i.GetMinBackoff(), nil 3821 case LiveHashDeleteTransaction: 3822 return i.GetMinBackoff(), nil 3823 case ScheduleCreateTransaction: 3824 return i.GetMinBackoff(), nil 3825 case ScheduleDeleteTransaction: 3826 return i.GetMinBackoff(), nil 3827 case ScheduleSignTransaction: 3828 return i.GetMinBackoff(), nil 3829 case SystemDeleteTransaction: 3830 return i.GetMinBackoff(), nil 3831 case SystemUndeleteTransaction: 3832 return i.GetMinBackoff(), nil 3833 case TokenAssociateTransaction: 3834 return i.GetMinBackoff(), nil 3835 case TokenBurnTransaction: 3836 return i.GetMinBackoff(), nil 3837 case TokenCreateTransaction: 3838 return i.GetMinBackoff(), nil 3839 case TokenDeleteTransaction: 3840 return i.GetMinBackoff(), nil 3841 case TokenDissociateTransaction: 3842 return i.GetMinBackoff(), nil 3843 case TokenFeeScheduleUpdateTransaction: 3844 return i.GetMinBackoff(), nil 3845 case TokenFreezeTransaction: 3846 return i.GetMinBackoff(), nil 3847 case TokenGrantKycTransaction: 3848 return i.GetMinBackoff(), nil 3849 case TokenMintTransaction: 3850 return i.GetMinBackoff(), nil 3851 case TokenRevokeKycTransaction: 3852 return i.GetMinBackoff(), nil 3853 case TokenUnfreezeTransaction: 3854 return i.GetMinBackoff(), nil 3855 case TokenUpdateTransaction: 3856 return i.GetMinBackoff(), nil 3857 case TokenWipeTransaction: 3858 return i.GetMinBackoff(), nil 3859 case TopicCreateTransaction: 3860 return i.GetMinBackoff(), nil 3861 case TopicDeleteTransaction: 3862 return i.GetMinBackoff(), nil 3863 case TopicMessageSubmitTransaction: 3864 return i.GetMinBackoff(), nil 3865 case TopicUpdateTransaction: 3866 return i.GetMinBackoff(), nil 3867 case TransferTransaction: 3868 return i.GetMinBackoff(), nil 3869 case *AccountCreateTransaction: 3870 return i.GetMinBackoff(), nil 3871 case *AccountDeleteTransaction: 3872 return i.GetMinBackoff(), nil 3873 case *AccountUpdateTransaction: 3874 return i.GetMinBackoff(), nil 3875 case *AccountAllowanceApproveTransaction: 3876 return i.GetMinBackoff(), nil 3877 case *AccountAllowanceDeleteTransaction: 3878 return i.GetMinBackoff(), nil 3879 case *ContractCreateTransaction: 3880 return i.GetMinBackoff(), nil 3881 case *ContractDeleteTransaction: 3882 return i.GetMinBackoff(), nil 3883 case *ContractExecuteTransaction: 3884 return i.GetMinBackoff(), nil 3885 case *ContractUpdateTransaction: 3886 return i.GetMinBackoff(), nil 3887 case *FileAppendTransaction: 3888 return i.GetMinBackoff(), nil 3889 case *FileCreateTransaction: 3890 return i.GetMinBackoff(), nil 3891 case *FileDeleteTransaction: 3892 return i.GetMinBackoff(), nil 3893 case *FileUpdateTransaction: 3894 return i.GetMinBackoff(), nil 3895 case *LiveHashAddTransaction: 3896 return i.GetMinBackoff(), nil 3897 case *LiveHashDeleteTransaction: 3898 return i.GetMinBackoff(), nil 3899 case *ScheduleCreateTransaction: 3900 return i.GetMinBackoff(), nil 3901 case *ScheduleDeleteTransaction: 3902 return i.GetMinBackoff(), nil 3903 case *ScheduleSignTransaction: 3904 return i.GetMinBackoff(), nil 3905 case *SystemDeleteTransaction: 3906 return i.GetMinBackoff(), nil 3907 case *SystemUndeleteTransaction: 3908 return i.GetMinBackoff(), nil 3909 case *TokenAssociateTransaction: 3910 return i.GetMinBackoff(), nil 3911 case *TokenBurnTransaction: 3912 return i.GetMinBackoff(), nil 3913 case *TokenCreateTransaction: 3914 return i.GetMinBackoff(), nil 3915 case *TokenDeleteTransaction: 3916 return i.GetMinBackoff(), nil 3917 case *TokenDissociateTransaction: 3918 return i.GetMinBackoff(), nil 3919 case *TokenFeeScheduleUpdateTransaction: 3920 return i.GetMinBackoff(), nil 3921 case *TokenFreezeTransaction: 3922 return i.GetMinBackoff(), nil 3923 case *TokenGrantKycTransaction: 3924 return i.GetMinBackoff(), nil 3925 case *TokenMintTransaction: 3926 return i.GetMinBackoff(), nil 3927 case *TokenRevokeKycTransaction: 3928 return i.GetMinBackoff(), nil 3929 case *TokenUnfreezeTransaction: 3930 return i.GetMinBackoff(), nil 3931 case *TokenUpdateTransaction: 3932 return i.GetMinBackoff(), nil 3933 case *TokenWipeTransaction: 3934 return i.GetMinBackoff(), nil 3935 case *TopicCreateTransaction: 3936 return i.GetMinBackoff(), nil 3937 case *TopicDeleteTransaction: 3938 return i.GetMinBackoff(), nil 3939 case *TopicMessageSubmitTransaction: 3940 return i.GetMinBackoff(), nil 3941 case *TopicUpdateTransaction: 3942 return i.GetMinBackoff(), nil 3943 case *TransferTransaction: 3944 return i.GetMinBackoff(), nil 3945 default: 3946 return time.Duration(0), errors.New("(BUG) non-exhaustive switch statement") 3947 } 3948 } 3949 3950 func TransactionSetMaxBackoff(transaction interface{}, maxBackoff time.Duration) (interface{}, error) { // nolint 3951 switch i := transaction.(type) { 3952 case AccountCreateTransaction: 3953 return i.SetMaxBackoff(maxBackoff), nil 3954 case AccountDeleteTransaction: 3955 return i.SetMaxBackoff(maxBackoff), nil 3956 case AccountUpdateTransaction: 3957 return i.SetMaxBackoff(maxBackoff), nil 3958 case AccountAllowanceApproveTransaction: 3959 return i.SetMaxBackoff(maxBackoff), nil 3960 case AccountAllowanceDeleteTransaction: 3961 return i.SetMaxBackoff(maxBackoff), nil 3962 case ContractCreateTransaction: 3963 return i.SetMaxBackoff(maxBackoff), nil 3964 case ContractDeleteTransaction: 3965 return i.SetMaxBackoff(maxBackoff), nil 3966 case ContractExecuteTransaction: 3967 return i.SetMaxBackoff(maxBackoff), nil 3968 case ContractUpdateTransaction: 3969 return i.SetMaxBackoff(maxBackoff), nil 3970 case FileAppendTransaction: 3971 return i.SetMaxBackoff(maxBackoff), nil 3972 case FileCreateTransaction: 3973 return i.SetMaxBackoff(maxBackoff), nil 3974 case FileDeleteTransaction: 3975 return i.SetMaxBackoff(maxBackoff), nil 3976 case FileUpdateTransaction: 3977 return i.SetMaxBackoff(maxBackoff), nil 3978 case LiveHashAddTransaction: 3979 return i.SetMaxBackoff(maxBackoff), nil 3980 case LiveHashDeleteTransaction: 3981 return i.SetMaxBackoff(maxBackoff), nil 3982 case ScheduleCreateTransaction: 3983 return i.SetMaxBackoff(maxBackoff), nil 3984 case ScheduleDeleteTransaction: 3985 return i.SetMaxBackoff(maxBackoff), nil 3986 case ScheduleSignTransaction: 3987 return i.SetMaxBackoff(maxBackoff), nil 3988 case SystemDeleteTransaction: 3989 return i.SetMaxBackoff(maxBackoff), nil 3990 case SystemUndeleteTransaction: 3991 return i.SetMaxBackoff(maxBackoff), nil 3992 case TokenAssociateTransaction: 3993 return i.SetMaxBackoff(maxBackoff), nil 3994 case TokenBurnTransaction: 3995 return i.SetMaxBackoff(maxBackoff), nil 3996 case TokenCreateTransaction: 3997 return i.SetMaxBackoff(maxBackoff), nil 3998 case TokenDeleteTransaction: 3999 return i.SetMaxBackoff(maxBackoff), nil 4000 case TokenDissociateTransaction: 4001 return i.SetMaxBackoff(maxBackoff), nil 4002 case TokenFeeScheduleUpdateTransaction: 4003 return i.SetMaxBackoff(maxBackoff), nil 4004 case TokenFreezeTransaction: 4005 return i.SetMaxBackoff(maxBackoff), nil 4006 case TokenGrantKycTransaction: 4007 return i.SetMaxBackoff(maxBackoff), nil 4008 case TokenMintTransaction: 4009 return i.SetMaxBackoff(maxBackoff), nil 4010 case TokenRevokeKycTransaction: 4011 return i.SetMaxBackoff(maxBackoff), nil 4012 case TokenUnfreezeTransaction: 4013 return i.SetMaxBackoff(maxBackoff), nil 4014 case TokenUpdateTransaction: 4015 return i.SetMaxBackoff(maxBackoff), nil 4016 case TokenWipeTransaction: 4017 return i.SetMaxBackoff(maxBackoff), nil 4018 case TopicCreateTransaction: 4019 return i.SetMaxBackoff(maxBackoff), nil 4020 case TopicDeleteTransaction: 4021 return i.SetMaxBackoff(maxBackoff), nil 4022 case TopicMessageSubmitTransaction: 4023 return i.SetMaxBackoff(maxBackoff), nil 4024 case TopicUpdateTransaction: 4025 return i.SetMaxBackoff(maxBackoff), nil 4026 case TransferTransaction: 4027 return i.SetMaxBackoff(maxBackoff), nil 4028 case *AccountCreateTransaction: 4029 return i.SetMaxBackoff(maxBackoff), nil 4030 case *AccountDeleteTransaction: 4031 return i.SetMaxBackoff(maxBackoff), nil 4032 case *AccountUpdateTransaction: 4033 return i.SetMaxBackoff(maxBackoff), nil 4034 case *AccountAllowanceApproveTransaction: 4035 return i.SetMaxBackoff(maxBackoff), nil 4036 case *AccountAllowanceDeleteTransaction: 4037 return i.SetMaxBackoff(maxBackoff), nil 4038 case *ContractCreateTransaction: 4039 return i.SetMaxBackoff(maxBackoff), nil 4040 case *ContractDeleteTransaction: 4041 return i.SetMaxBackoff(maxBackoff), nil 4042 case *ContractExecuteTransaction: 4043 return i.SetMaxBackoff(maxBackoff), nil 4044 case *ContractUpdateTransaction: 4045 return i.SetMaxBackoff(maxBackoff), nil 4046 case *FileAppendTransaction: 4047 return i.SetMaxBackoff(maxBackoff), nil 4048 case *FileCreateTransaction: 4049 return i.SetMaxBackoff(maxBackoff), nil 4050 case *FileDeleteTransaction: 4051 return i.SetMaxBackoff(maxBackoff), nil 4052 case *FileUpdateTransaction: 4053 return i.SetMaxBackoff(maxBackoff), nil 4054 case *LiveHashAddTransaction: 4055 return i.SetMaxBackoff(maxBackoff), nil 4056 case *LiveHashDeleteTransaction: 4057 return i.SetMaxBackoff(maxBackoff), nil 4058 case *ScheduleCreateTransaction: 4059 return i.SetMaxBackoff(maxBackoff), nil 4060 case *ScheduleDeleteTransaction: 4061 return i.SetMaxBackoff(maxBackoff), nil 4062 case *ScheduleSignTransaction: 4063 return i.SetMaxBackoff(maxBackoff), nil 4064 case *SystemDeleteTransaction: 4065 return i.SetMaxBackoff(maxBackoff), nil 4066 case *SystemUndeleteTransaction: 4067 return i.SetMaxBackoff(maxBackoff), nil 4068 case *TokenAssociateTransaction: 4069 return i.SetMaxBackoff(maxBackoff), nil 4070 case *TokenBurnTransaction: 4071 return i.SetMaxBackoff(maxBackoff), nil 4072 case *TokenCreateTransaction: 4073 return i.SetMaxBackoff(maxBackoff), nil 4074 case *TokenDeleteTransaction: 4075 return i.SetMaxBackoff(maxBackoff), nil 4076 case *TokenDissociateTransaction: 4077 return i.SetMaxBackoff(maxBackoff), nil 4078 case *TokenFeeScheduleUpdateTransaction: 4079 return i.SetMaxBackoff(maxBackoff), nil 4080 case *TokenFreezeTransaction: 4081 return i.SetMaxBackoff(maxBackoff), nil 4082 case *TokenGrantKycTransaction: 4083 return i.SetMaxBackoff(maxBackoff), nil 4084 case *TokenMintTransaction: 4085 return i.SetMaxBackoff(maxBackoff), nil 4086 case *TokenRevokeKycTransaction: 4087 return i.SetMaxBackoff(maxBackoff), nil 4088 case *TokenUnfreezeTransaction: 4089 return i.SetMaxBackoff(maxBackoff), nil 4090 case *TokenUpdateTransaction: 4091 return i.SetMaxBackoff(maxBackoff), nil 4092 case *TokenWipeTransaction: 4093 return i.SetMaxBackoff(maxBackoff), nil 4094 case *TopicCreateTransaction: 4095 return i.SetMaxBackoff(maxBackoff), nil 4096 case *TopicDeleteTransaction: 4097 return i.SetMaxBackoff(maxBackoff), nil 4098 case *TopicMessageSubmitTransaction: 4099 return i.SetMaxBackoff(maxBackoff), nil 4100 case *TopicUpdateTransaction: 4101 return i.SetMaxBackoff(maxBackoff), nil 4102 case *TransferTransaction: 4103 return i.SetMaxBackoff(maxBackoff), nil 4104 default: 4105 return transaction, errors.New("(BUG) non-exhaustive switch statement") 4106 } 4107 } 4108 4109 func TransactionGetMaxBackoff(transaction interface{}) (time.Duration, error) { // nolint 4110 switch i := transaction.(type) { 4111 case AccountCreateTransaction: 4112 return i.GetMaxBackoff(), nil 4113 case AccountDeleteTransaction: 4114 return i.GetMaxBackoff(), nil 4115 case AccountUpdateTransaction: 4116 return i.GetMaxBackoff(), nil 4117 case AccountAllowanceApproveTransaction: 4118 return i.GetMaxBackoff(), nil 4119 case AccountAllowanceDeleteTransaction: 4120 return i.GetMaxBackoff(), nil 4121 case ContractCreateTransaction: 4122 return i.GetMaxBackoff(), nil 4123 case ContractDeleteTransaction: 4124 return i.GetMaxBackoff(), nil 4125 case ContractExecuteTransaction: 4126 return i.GetMaxBackoff(), nil 4127 case ContractUpdateTransaction: 4128 return i.GetMaxBackoff(), nil 4129 case FileAppendTransaction: 4130 return i.GetMaxBackoff(), nil 4131 case FileCreateTransaction: 4132 return i.GetMaxBackoff(), nil 4133 case FileDeleteTransaction: 4134 return i.GetMaxBackoff(), nil 4135 case FileUpdateTransaction: 4136 return i.GetMaxBackoff(), nil 4137 case LiveHashAddTransaction: 4138 return i.GetMaxBackoff(), nil 4139 case LiveHashDeleteTransaction: 4140 return i.GetMaxBackoff(), nil 4141 case ScheduleCreateTransaction: 4142 return i.GetMaxBackoff(), nil 4143 case ScheduleDeleteTransaction: 4144 return i.GetMaxBackoff(), nil 4145 case ScheduleSignTransaction: 4146 return i.GetMaxBackoff(), nil 4147 case SystemDeleteTransaction: 4148 return i.GetMaxBackoff(), nil 4149 case SystemUndeleteTransaction: 4150 return i.GetMaxBackoff(), nil 4151 case TokenAssociateTransaction: 4152 return i.GetMaxBackoff(), nil 4153 case TokenBurnTransaction: 4154 return i.GetMaxBackoff(), nil 4155 case TokenCreateTransaction: 4156 return i.GetMaxBackoff(), nil 4157 case TokenDeleteTransaction: 4158 return i.GetMaxBackoff(), nil 4159 case TokenDissociateTransaction: 4160 return i.GetMaxBackoff(), nil 4161 case TokenFeeScheduleUpdateTransaction: 4162 return i.GetMaxBackoff(), nil 4163 case TokenFreezeTransaction: 4164 return i.GetMaxBackoff(), nil 4165 case TokenGrantKycTransaction: 4166 return i.GetMaxBackoff(), nil 4167 case TokenMintTransaction: 4168 return i.GetMaxBackoff(), nil 4169 case TokenRevokeKycTransaction: 4170 return i.GetMaxBackoff(), nil 4171 case TokenUnfreezeTransaction: 4172 return i.GetMaxBackoff(), nil 4173 case TokenUpdateTransaction: 4174 return i.GetMaxBackoff(), nil 4175 case TokenWipeTransaction: 4176 return i.GetMaxBackoff(), nil 4177 case TopicCreateTransaction: 4178 return i.GetMaxBackoff(), nil 4179 case TopicDeleteTransaction: 4180 return i.GetMaxBackoff(), nil 4181 case TopicMessageSubmitTransaction: 4182 return i.GetMaxBackoff(), nil 4183 case TopicUpdateTransaction: 4184 return i.GetMaxBackoff(), nil 4185 case TransferTransaction: 4186 return i.GetMaxBackoff(), nil 4187 case *AccountCreateTransaction: 4188 return i.GetMaxBackoff(), nil 4189 case *AccountDeleteTransaction: 4190 return i.GetMaxBackoff(), nil 4191 case *AccountUpdateTransaction: 4192 return i.GetMaxBackoff(), nil 4193 case *AccountAllowanceApproveTransaction: 4194 return i.GetMaxBackoff(), nil 4195 case *AccountAllowanceDeleteTransaction: 4196 return i.GetMaxBackoff(), nil 4197 case *ContractCreateTransaction: 4198 return i.GetMaxBackoff(), nil 4199 case *ContractDeleteTransaction: 4200 return i.GetMaxBackoff(), nil 4201 case *ContractExecuteTransaction: 4202 return i.GetMaxBackoff(), nil 4203 case *ContractUpdateTransaction: 4204 return i.GetMaxBackoff(), nil 4205 case *FileAppendTransaction: 4206 return i.GetMaxBackoff(), nil 4207 case *FileCreateTransaction: 4208 return i.GetMaxBackoff(), nil 4209 case *FileDeleteTransaction: 4210 return i.GetMaxBackoff(), nil 4211 case *FileUpdateTransaction: 4212 return i.GetMaxBackoff(), nil 4213 case *LiveHashAddTransaction: 4214 return i.GetMaxBackoff(), nil 4215 case *LiveHashDeleteTransaction: 4216 return i.GetMaxBackoff(), nil 4217 case *ScheduleCreateTransaction: 4218 return i.GetMaxBackoff(), nil 4219 case *ScheduleDeleteTransaction: 4220 return i.GetMaxBackoff(), nil 4221 case *ScheduleSignTransaction: 4222 return i.GetMaxBackoff(), nil 4223 case *SystemDeleteTransaction: 4224 return i.GetMaxBackoff(), nil 4225 case *SystemUndeleteTransaction: 4226 return i.GetMaxBackoff(), nil 4227 case *TokenAssociateTransaction: 4228 return i.GetMaxBackoff(), nil 4229 case *TokenBurnTransaction: 4230 return i.GetMaxBackoff(), nil 4231 case *TokenCreateTransaction: 4232 return i.GetMaxBackoff(), nil 4233 case *TokenDeleteTransaction: 4234 return i.GetMaxBackoff(), nil 4235 case *TokenDissociateTransaction: 4236 return i.GetMaxBackoff(), nil 4237 case *TokenFeeScheduleUpdateTransaction: 4238 return i.GetMaxBackoff(), nil 4239 case *TokenFreezeTransaction: 4240 return i.GetMaxBackoff(), nil 4241 case *TokenGrantKycTransaction: 4242 return i.GetMaxBackoff(), nil 4243 case *TokenMintTransaction: 4244 return i.GetMaxBackoff(), nil 4245 case *TokenRevokeKycTransaction: 4246 return i.GetMaxBackoff(), nil 4247 case *TokenUnfreezeTransaction: 4248 return i.GetMaxBackoff(), nil 4249 case *TokenUpdateTransaction: 4250 return i.GetMaxBackoff(), nil 4251 case *TokenWipeTransaction: 4252 return i.GetMaxBackoff(), nil 4253 case *TopicCreateTransaction: 4254 return i.GetMaxBackoff(), nil 4255 case *TopicDeleteTransaction: 4256 return i.GetMaxBackoff(), nil 4257 case *TopicMessageSubmitTransaction: 4258 return i.GetMaxBackoff(), nil 4259 case *TopicUpdateTransaction: 4260 return i.GetMaxBackoff(), nil 4261 case *TransferTransaction: 4262 return i.GetMaxBackoff(), nil 4263 default: 4264 return time.Duration(0), errors.New("(BUG) non-exhaustive switch statement") 4265 } 4266 } 4267 4268 func TransactionString(transaction interface{}) (string, error) { // nolint 4269 switch i := transaction.(type) { 4270 case AccountCreateTransaction: 4271 return i.String(), nil 4272 case AccountDeleteTransaction: 4273 return i.String(), nil 4274 case AccountUpdateTransaction: 4275 return i.String(), nil 4276 case AccountAllowanceApproveTransaction: 4277 return i.String(), nil 4278 case AccountAllowanceDeleteTransaction: 4279 return i.String(), nil 4280 case ContractCreateTransaction: 4281 return i.String(), nil 4282 case ContractDeleteTransaction: 4283 return i.String(), nil 4284 case ContractExecuteTransaction: 4285 return i.String(), nil 4286 case ContractUpdateTransaction: 4287 return i.String(), nil 4288 case FileAppendTransaction: 4289 return i.String(), nil 4290 case FileCreateTransaction: 4291 return i.String(), nil 4292 case FileDeleteTransaction: 4293 return i.String(), nil 4294 case FileUpdateTransaction: 4295 return i.String(), nil 4296 case LiveHashAddTransaction: 4297 return i.String(), nil 4298 case LiveHashDeleteTransaction: 4299 return i.String(), nil 4300 case ScheduleCreateTransaction: 4301 return i.String(), nil 4302 case ScheduleDeleteTransaction: 4303 return i.String(), nil 4304 case ScheduleSignTransaction: 4305 return i.String(), nil 4306 case SystemDeleteTransaction: 4307 return i.String(), nil 4308 case SystemUndeleteTransaction: 4309 return i.String(), nil 4310 case TokenAssociateTransaction: 4311 return i.String(), nil 4312 case TokenBurnTransaction: 4313 return i.String(), nil 4314 case TokenCreateTransaction: 4315 return i.String(), nil 4316 case TokenDeleteTransaction: 4317 return i.String(), nil 4318 case TokenDissociateTransaction: 4319 return i.String(), nil 4320 case TokenFeeScheduleUpdateTransaction: 4321 return i.String(), nil 4322 case TokenFreezeTransaction: 4323 return i.String(), nil 4324 case TokenGrantKycTransaction: 4325 return i.String(), nil 4326 case TokenMintTransaction: 4327 return i.String(), nil 4328 case TokenRevokeKycTransaction: 4329 return i.String(), nil 4330 case TokenUnfreezeTransaction: 4331 return i.String(), nil 4332 case TokenUpdateTransaction: 4333 return i.String(), nil 4334 case TokenWipeTransaction: 4335 return i.String(), nil 4336 case TopicCreateTransaction: 4337 return i.String(), nil 4338 case TopicDeleteTransaction: 4339 return i.String(), nil 4340 case TopicMessageSubmitTransaction: 4341 return i.String(), nil 4342 case TopicUpdateTransaction: 4343 return i.String(), nil 4344 case TransferTransaction: 4345 return i.String(), nil 4346 case *AccountCreateTransaction: 4347 return i.String(), nil 4348 case *AccountDeleteTransaction: 4349 return i.String(), nil 4350 case *AccountUpdateTransaction: 4351 return i.String(), nil 4352 case *AccountAllowanceApproveTransaction: 4353 return i.String(), nil 4354 case *AccountAllowanceDeleteTransaction: 4355 return i.String(), nil 4356 case *ContractCreateTransaction: 4357 return i.String(), nil 4358 case *ContractDeleteTransaction: 4359 return i.String(), nil 4360 case *ContractExecuteTransaction: 4361 return i.String(), nil 4362 case *ContractUpdateTransaction: 4363 return i.String(), nil 4364 case *FileAppendTransaction: 4365 return i.String(), nil 4366 case *FileCreateTransaction: 4367 return i.String(), nil 4368 case *FileDeleteTransaction: 4369 return i.String(), nil 4370 case *FileUpdateTransaction: 4371 return i.String(), nil 4372 case *LiveHashAddTransaction: 4373 return i.String(), nil 4374 case *LiveHashDeleteTransaction: 4375 return i.String(), nil 4376 case *ScheduleCreateTransaction: 4377 return i.String(), nil 4378 case *ScheduleDeleteTransaction: 4379 return i.String(), nil 4380 case *ScheduleSignTransaction: 4381 return i.String(), nil 4382 case *SystemDeleteTransaction: 4383 return i.String(), nil 4384 case *SystemUndeleteTransaction: 4385 return i.String(), nil 4386 case *TokenAssociateTransaction: 4387 return i.String(), nil 4388 case *TokenBurnTransaction: 4389 return i.String(), nil 4390 case *TokenCreateTransaction: 4391 return i.String(), nil 4392 case *TokenDeleteTransaction: 4393 return i.String(), nil 4394 case *TokenDissociateTransaction: 4395 return i.String(), nil 4396 case *TokenFeeScheduleUpdateTransaction: 4397 return i.String(), nil 4398 case *TokenFreezeTransaction: 4399 return i.String(), nil 4400 case *TokenGrantKycTransaction: 4401 return i.String(), nil 4402 case *TokenMintTransaction: 4403 return i.String(), nil 4404 case *TokenRevokeKycTransaction: 4405 return i.String(), nil 4406 case *TokenUnfreezeTransaction: 4407 return i.String(), nil 4408 case *TokenUpdateTransaction: 4409 return i.String(), nil 4410 case *TokenWipeTransaction: 4411 return i.String(), nil 4412 case *TopicCreateTransaction: 4413 return i.String(), nil 4414 case *TopicDeleteTransaction: 4415 return i.String(), nil 4416 case *TopicMessageSubmitTransaction: 4417 return i.String(), nil 4418 case *TopicUpdateTransaction: 4419 return i.String(), nil 4420 case *TransferTransaction: 4421 return i.String(), nil 4422 default: 4423 return "", errors.New("(BUG) non-exhaustive switch statement") 4424 } 4425 } 4426 4427 func TransactionToBytes(transaction interface{}) ([]byte, error) { // nolint 4428 switch i := transaction.(type) { 4429 case AccountCreateTransaction: 4430 return i.ToBytes() 4431 case AccountDeleteTransaction: 4432 return i.ToBytes() 4433 case AccountUpdateTransaction: 4434 return i.ToBytes() 4435 case AccountAllowanceApproveTransaction: 4436 return i.ToBytes() 4437 case AccountAllowanceDeleteTransaction: 4438 return i.ToBytes() 4439 case ContractCreateTransaction: 4440 return i.ToBytes() 4441 case ContractDeleteTransaction: 4442 return i.ToBytes() 4443 case ContractExecuteTransaction: 4444 return i.ToBytes() 4445 case ContractUpdateTransaction: 4446 return i.ToBytes() 4447 case FileAppendTransaction: 4448 return i.ToBytes() 4449 case FileCreateTransaction: 4450 return i.ToBytes() 4451 case FileDeleteTransaction: 4452 return i.ToBytes() 4453 case FileUpdateTransaction: 4454 return i.ToBytes() 4455 case LiveHashAddTransaction: 4456 return i.ToBytes() 4457 case LiveHashDeleteTransaction: 4458 return i.ToBytes() 4459 case ScheduleCreateTransaction: 4460 return i.ToBytes() 4461 case ScheduleDeleteTransaction: 4462 return i.ToBytes() 4463 case ScheduleSignTransaction: 4464 return i.ToBytes() 4465 case SystemDeleteTransaction: 4466 return i.ToBytes() 4467 case SystemUndeleteTransaction: 4468 return i.ToBytes() 4469 case TokenAssociateTransaction: 4470 return i.ToBytes() 4471 case TokenBurnTransaction: 4472 return i.ToBytes() 4473 case TokenCreateTransaction: 4474 return i.ToBytes() 4475 case TokenDeleteTransaction: 4476 return i.ToBytes() 4477 case TokenDissociateTransaction: 4478 return i.ToBytes() 4479 case TokenFeeScheduleUpdateTransaction: 4480 return i.ToBytes() 4481 case TokenFreezeTransaction: 4482 return i.ToBytes() 4483 case TokenGrantKycTransaction: 4484 return i.ToBytes() 4485 case TokenMintTransaction: 4486 return i.ToBytes() 4487 case TokenRevokeKycTransaction: 4488 return i.ToBytes() 4489 case TokenUnfreezeTransaction: 4490 return i.ToBytes() 4491 case TokenUpdateTransaction: 4492 return i.ToBytes() 4493 case TokenWipeTransaction: 4494 return i.ToBytes() 4495 case TopicCreateTransaction: 4496 return i.ToBytes() 4497 case TopicDeleteTransaction: 4498 return i.ToBytes() 4499 case TopicMessageSubmitTransaction: 4500 return i.ToBytes() 4501 case TopicUpdateTransaction: 4502 return i.ToBytes() 4503 case TransferTransaction: 4504 return i.ToBytes() 4505 case *AccountCreateTransaction: 4506 return i.ToBytes() 4507 case *AccountDeleteTransaction: 4508 return i.ToBytes() 4509 case *AccountUpdateTransaction: 4510 return i.ToBytes() 4511 case *AccountAllowanceApproveTransaction: 4512 return i.ToBytes() 4513 case *AccountAllowanceDeleteTransaction: 4514 return i.ToBytes() 4515 case *ContractCreateTransaction: 4516 return i.ToBytes() 4517 case *ContractDeleteTransaction: 4518 return i.ToBytes() 4519 case *ContractExecuteTransaction: 4520 return i.ToBytes() 4521 case *ContractUpdateTransaction: 4522 return i.ToBytes() 4523 case *FileAppendTransaction: 4524 return i.ToBytes() 4525 case *FileCreateTransaction: 4526 return i.ToBytes() 4527 case *FileDeleteTransaction: 4528 return i.ToBytes() 4529 case *FileUpdateTransaction: 4530 return i.ToBytes() 4531 case *LiveHashAddTransaction: 4532 return i.ToBytes() 4533 case *LiveHashDeleteTransaction: 4534 return i.ToBytes() 4535 case *ScheduleCreateTransaction: 4536 return i.ToBytes() 4537 case *ScheduleDeleteTransaction: 4538 return i.ToBytes() 4539 case *ScheduleSignTransaction: 4540 return i.ToBytes() 4541 case *SystemDeleteTransaction: 4542 return i.ToBytes() 4543 case *SystemUndeleteTransaction: 4544 return i.ToBytes() 4545 case *TokenAssociateTransaction: 4546 return i.ToBytes() 4547 case *TokenBurnTransaction: 4548 return i.ToBytes() 4549 case *TokenCreateTransaction: 4550 return i.ToBytes() 4551 case *TokenDeleteTransaction: 4552 return i.ToBytes() 4553 case *TokenDissociateTransaction: 4554 return i.ToBytes() 4555 case *TokenFeeScheduleUpdateTransaction: 4556 return i.ToBytes() 4557 case *TokenFreezeTransaction: 4558 return i.ToBytes() 4559 case *TokenGrantKycTransaction: 4560 return i.ToBytes() 4561 case *TokenMintTransaction: 4562 return i.ToBytes() 4563 case *TokenRevokeKycTransaction: 4564 return i.ToBytes() 4565 case *TokenUnfreezeTransaction: 4566 return i.ToBytes() 4567 case *TokenUpdateTransaction: 4568 return i.ToBytes() 4569 case *TokenWipeTransaction: 4570 return i.ToBytes() 4571 case *TopicCreateTransaction: 4572 return i.ToBytes() 4573 case *TopicDeleteTransaction: 4574 return i.ToBytes() 4575 case *TopicMessageSubmitTransaction: 4576 return i.ToBytes() 4577 case *TopicUpdateTransaction: 4578 return i.ToBytes() 4579 case *TransferTransaction: 4580 return i.ToBytes() 4581 case *TokenUpdateNfts: 4582 return i.ToBytes() 4583 case *TokenRejectTransaction: 4584 return i.ToBytes() 4585 case *TokenAirdropTransaction: 4586 return i.ToBytes() 4587 case *TokenCancelAirdropTransaction: 4588 return i.ToBytes() 4589 case *TokenClaimAirdropTransaction: 4590 return i.ToBytes() 4591 default: 4592 return nil, errors.New("(BUG) non-exhaustive switch statement") 4593 } 4594 } 4595 4596 func TransactionExecute(transaction interface{}, client *Client) (TransactionResponse, error) { // nolint 4597 switch i := transaction.(type) { 4598 case AccountCreateTransaction: 4599 return i.Execute(client) 4600 case AccountDeleteTransaction: 4601 return i.Execute(client) 4602 case AccountUpdateTransaction: 4603 return i.Execute(client) 4604 case AccountAllowanceApproveTransaction: 4605 return i.Execute(client) 4606 case AccountAllowanceDeleteTransaction: 4607 return i.Execute(client) 4608 case ContractCreateTransaction: 4609 return i.Execute(client) 4610 case ContractDeleteTransaction: 4611 return i.Execute(client) 4612 case ContractExecuteTransaction: 4613 return i.Execute(client) 4614 case ContractUpdateTransaction: 4615 return i.Execute(client) 4616 case FileAppendTransaction: 4617 return i.Execute(client) 4618 case FileCreateTransaction: 4619 return i.Execute(client) 4620 case FileDeleteTransaction: 4621 return i.Execute(client) 4622 case FileUpdateTransaction: 4623 return i.Execute(client) 4624 case FreezeTransaction: 4625 return i.Execute(client) 4626 case LiveHashAddTransaction: 4627 return i.Execute(client) 4628 case LiveHashDeleteTransaction: 4629 return i.Execute(client) 4630 case ScheduleCreateTransaction: 4631 return i.Execute(client) 4632 case ScheduleDeleteTransaction: 4633 return i.Execute(client) 4634 case ScheduleSignTransaction: 4635 return i.Execute(client) 4636 case SystemDeleteTransaction: 4637 return i.Execute(client) 4638 case SystemUndeleteTransaction: 4639 return i.Execute(client) 4640 case TokenAssociateTransaction: 4641 return i.Execute(client) 4642 case TokenBurnTransaction: 4643 return i.Execute(client) 4644 case TokenCreateTransaction: 4645 return i.Execute(client) 4646 case TokenDeleteTransaction: 4647 return i.Execute(client) 4648 case TokenDissociateTransaction: 4649 return i.Execute(client) 4650 case TokenFeeScheduleUpdateTransaction: 4651 return i.Execute(client) 4652 case TokenFreezeTransaction: 4653 return i.Execute(client) 4654 case TokenGrantKycTransaction: 4655 return i.Execute(client) 4656 case TokenMintTransaction: 4657 return i.Execute(client) 4658 case TokenPauseTransaction: 4659 return i.Execute(client) 4660 case TokenRevokeKycTransaction: 4661 return i.Execute(client) 4662 case TokenUnfreezeTransaction: 4663 return i.Execute(client) 4664 case TokenUnpauseTransaction: 4665 return i.Execute(client) 4666 case TokenUpdateTransaction: 4667 return i.Execute(client) 4668 case TokenWipeTransaction: 4669 return i.Execute(client) 4670 case TopicCreateTransaction: 4671 return i.Execute(client) 4672 case TopicDeleteTransaction: 4673 return i.Execute(client) 4674 case TopicMessageSubmitTransaction: 4675 return i.Execute(client) 4676 case TopicUpdateTransaction: 4677 return i.Execute(client) 4678 case TransferTransaction: 4679 return i.Execute(client) 4680 case *AccountCreateTransaction: 4681 return i.Execute(client) 4682 case *AccountDeleteTransaction: 4683 return i.Execute(client) 4684 case *AccountUpdateTransaction: 4685 return i.Execute(client) 4686 case *AccountAllowanceApproveTransaction: 4687 return i.Execute(client) 4688 case *AccountAllowanceDeleteTransaction: 4689 return i.Execute(client) 4690 case *ContractCreateTransaction: 4691 return i.Execute(client) 4692 case *ContractDeleteTransaction: 4693 return i.Execute(client) 4694 case *ContractExecuteTransaction: 4695 return i.Execute(client) 4696 case *ContractUpdateTransaction: 4697 return i.Execute(client) 4698 case *FileAppendTransaction: 4699 return i.Execute(client) 4700 case *FileCreateTransaction: 4701 return i.Execute(client) 4702 case *FileDeleteTransaction: 4703 return i.Execute(client) 4704 case *FileUpdateTransaction: 4705 return i.Execute(client) 4706 case *FreezeTransaction: 4707 return i.Execute(client) 4708 case *LiveHashAddTransaction: 4709 return i.Execute(client) 4710 case *LiveHashDeleteTransaction: 4711 return i.Execute(client) 4712 case *ScheduleCreateTransaction: 4713 return i.Execute(client) 4714 case *ScheduleDeleteTransaction: 4715 return i.Execute(client) 4716 case *ScheduleSignTransaction: 4717 return i.Execute(client) 4718 case *SystemDeleteTransaction: 4719 return i.Execute(client) 4720 case *SystemUndeleteTransaction: 4721 return i.Execute(client) 4722 case *TokenAssociateTransaction: 4723 return i.Execute(client) 4724 case *TokenBurnTransaction: 4725 return i.Execute(client) 4726 case *TokenCreateTransaction: 4727 return i.Execute(client) 4728 case *TokenDeleteTransaction: 4729 return i.Execute(client) 4730 case *TokenDissociateTransaction: 4731 return i.Execute(client) 4732 case *TokenFeeScheduleUpdateTransaction: 4733 return i.Execute(client) 4734 case *TokenFreezeTransaction: 4735 return i.Execute(client) 4736 case *TokenGrantKycTransaction: 4737 return i.Execute(client) 4738 case *TokenMintTransaction: 4739 return i.Execute(client) 4740 case *TokenPauseTransaction: 4741 return i.Execute(client) 4742 case *TokenRevokeKycTransaction: 4743 return i.Execute(client) 4744 case *TokenUnfreezeTransaction: 4745 return i.Execute(client) 4746 case *TokenUnpauseTransaction: 4747 return i.Execute(client) 4748 case *TokenUpdateTransaction: 4749 return i.Execute(client) 4750 case *TokenWipeTransaction: 4751 return i.Execute(client) 4752 case *TopicCreateTransaction: 4753 return i.Execute(client) 4754 case *TopicDeleteTransaction: 4755 return i.Execute(client) 4756 case *TopicMessageSubmitTransaction: 4757 return i.Execute(client) 4758 case *TopicUpdateTransaction: 4759 return i.Execute(client) 4760 case *TransferTransaction: 4761 return i.Execute(client) 4762 case *TokenUpdateNfts: 4763 return i.Execute(client) 4764 case *TokenRejectTransaction: 4765 return i.Execute(client) 4766 case *TokenAirdropTransaction: 4767 return i.Execute(client) 4768 case *TokenCancelAirdropTransaction: 4769 return i.Execute(client) 4770 case *TokenClaimAirdropTransaction: 4771 return i.Execute(client) 4772 default: 4773 return TransactionResponse{}, errors.New("(BUG) non-exhaustive switch statement") 4774 } 4775 } 4776 4777 // ------------ Executable Functions ------------ 4778 func (tx *Transaction) shouldRetry(_ Executable, response interface{}) _ExecutionState { 4779 status := Status(response.(*services.TransactionResponse).NodeTransactionPrecheckCode) 4780 4781 retryableStatuses := map[Status]bool{ 4782 StatusPlatformTransactionNotCreated: true, 4783 StatusPlatformNotActive: true, 4784 StatusBusy: true, 4785 } 4786 4787 if retryableStatuses[status] { 4788 return executionStateRetry 4789 } 4790 4791 if status == StatusTransactionExpired { 4792 return executionStateExpired 4793 } 4794 4795 if status == StatusOk { 4796 return executionStateFinished 4797 } 4798 4799 return executionStateError 4800 } 4801 4802 func (tx *Transaction) makeRequest() interface{} { 4803 index := tx.nodeAccountIDs._Length()*tx.transactionIDs.index + tx.nodeAccountIDs.index 4804 built, _ := tx._BuildTransaction(index) 4805 4806 return built 4807 } 4808 4809 func (tx *Transaction) advanceRequest() { 4810 tx.nodeAccountIDs._Advance() 4811 tx.signedTransactions._Advance() 4812 } 4813 4814 func (tx *Transaction) getNodeAccountID() AccountID { 4815 return tx.nodeAccountIDs._GetCurrent().(AccountID) 4816 } 4817 4818 func (tx *Transaction) mapStatusError( 4819 _ Executable, 4820 response interface{}, 4821 ) error { 4822 return ErrHederaPreCheckStatus{ 4823 Status: Status(response.(*services.TransactionResponse).NodeTransactionPrecheckCode), 4824 //NodeID: request.transaction.nodeAccountIDs, 4825 TxID: tx.GetTransactionID(), 4826 } 4827 } 4828 4829 func (tx *Transaction) mapResponse(_ interface{}, nodeID AccountID, protoRequest interface{}) (interface{}, error) { 4830 hash := sha512.New384() 4831 _, err := hash.Write(protoRequest.(*services.Transaction).SignedTransactionBytes) 4832 if err != nil { 4833 return nil, err 4834 } 4835 4836 return TransactionResponse{ 4837 NodeID: nodeID, 4838 TransactionID: tx.transactionIDs._GetNext().(TransactionID), 4839 Hash: hash.Sum(nil), 4840 }, nil 4841 } 4842 4843 // Building empty object as "default" implementation. All inhertents must implement their own implementation. 4844 func (tx *Transaction) getMethod(ch *_Channel) _Method { 4845 return _Method{} 4846 } 4847 4848 // Building empty object as "default" implementation. All inhertents must implement their own implementation. 4849 func (tx *Transaction) getName() string { 4850 return "transaction" 4851 } 4852 4853 func (tx *Transaction) getLogID(transactionInterface Executable) string { 4854 timestamp := tx.transactionIDs._GetCurrent().(TransactionID).ValidStart 4855 return fmt.Sprintf("%s:%d", transactionInterface.getName(), timestamp.UnixNano()) 4856 } 4857 4858 // Building empty object as "default" implementation. All inhertents must implement their own implementation. 4859 func (tx *Transaction) validateNetworkOnIDs(client *Client) error { 4860 return errors.New("Function not implemented") 4861 } 4862 4863 func (tx *Transaction) preFreezeWith(*Client) { 4864 // NO-OP 4865 } 4866 4867 func (tx *Transaction) isTransaction() bool { 4868 return true 4869 } 4870 4871 func (tx *Transaction) getTransactionIDAndMessage() (string, string) { 4872 return tx.GetTransactionID().String(), "transaction status received" 4873 } 4874 4875 func (tx *Transaction) regenerateID(client *Client) bool { 4876 if !client.GetOperatorAccountID()._IsZero() && tx.regenerateTransactionID && !tx.transactionIDs.locked { 4877 tx.transactionIDs._Set(tx.transactionIDs.index, TransactionIDGenerate(client.GetOperatorAccountID())) 4878 return true 4879 } 4880 return false 4881 } 4882 4883 func (tx *Transaction) execute(client *Client, e TransactionInterface) (TransactionResponse, error) { 4884 if client == nil { 4885 return TransactionResponse{}, errNoClientProvided 4886 } 4887 4888 if tx.freezeError != nil { 4889 return TransactionResponse{}, tx.freezeError 4890 } 4891 4892 if !tx.IsFrozen() { 4893 _, err := tx.freezeWith(client, e) 4894 if err != nil { 4895 return TransactionResponse{}, err 4896 } 4897 } 4898 4899 transactionID := tx.transactionIDs._GetCurrent().(TransactionID) 4900 4901 if !client.GetOperatorAccountID()._IsZero() && client.GetOperatorAccountID()._Equals(*transactionID.AccountID) { 4902 tx.SignWith( 4903 client.GetOperatorPublicKey(), 4904 client.operator.signer, 4905 ) 4906 } 4907 4908 if tx.grpcDeadline == nil { 4909 tx.grpcDeadline = client.requestTimeout 4910 } 4911 4912 resp, err := _Execute(client, e) 4913 4914 if err != nil { 4915 return TransactionResponse{ 4916 TransactionID: tx.GetTransactionID(), 4917 NodeID: resp.(TransactionResponse).NodeID, 4918 ValidateStatus: true, 4919 }, err 4920 } 4921 originalTxID := tx.GetTransactionID() 4922 e.regenerateID(client) 4923 return TransactionResponse{ 4924 TransactionID: originalTxID, 4925 NodeID: resp.(TransactionResponse).NodeID, 4926 Hash: resp.(TransactionResponse).Hash, 4927 ValidateStatus: true, 4928 // set the tx in the response, in case of throttle error in the receipt 4929 // we can use this to re-submit the transaction 4930 Transaction: e, 4931 }, nil 4932 } 4933 4934 func (tx *Transaction) FreezeWith(client *Client, e TransactionInterface) (TransactionInterface, error) { 4935 return tx.freezeWith(client, e) 4936 } 4937 4938 func (tx *Transaction) freezeWith(client *Client, e TransactionInterface) (TransactionInterface, error) { //nolint 4939 if tx.IsFrozen() { 4940 return tx, nil 4941 } 4942 4943 e.preFreezeWith(client) 4944 4945 tx._InitFee(client) 4946 if err := tx._InitTransactionID(client); err != nil { 4947 return tx, err 4948 } 4949 4950 err := e.validateNetworkOnIDs(client) 4951 if err != nil { 4952 return &Transaction{}, err 4953 } 4954 body := e.build() 4955 4956 return tx, _TransactionFreezeWith(tx, client, body) 4957 } 4958 4959 func (tx *Transaction) schedule(e TransactionInterface) (*ScheduleCreateTransaction, error) { 4960 tx._RequireNotFrozen() 4961 4962 scheduled, err := e.buildScheduled() 4963 if err != nil { 4964 return nil, err 4965 } 4966 4967 return NewScheduleCreateTransaction()._SetSchedulableTransactionBody(scheduled), nil 4968 }