From c95aa933e3e1cd96a5c64b3974d825498084873e Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Fri, 29 Apr 2022 09:38:52 -0700 Subject: [PATCH 1/2] services/friendbot: include txhash in logs --- services/friendbot/internal/minion.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/services/friendbot/internal/minion.go b/services/friendbot/internal/minion.go index f1f2b1b5ce..5a56667d25 100644 --- a/services/friendbot/internal/minion.go +++ b/services/friendbot/internal/minion.go @@ -44,7 +44,7 @@ func (minion *Minion) Run(destAddress string, resultChan chan SubmitResult) { } return } - txStr, err := minion.makeTx(destAddress) + txHash, txStr, err := minion.makeTx(destAddress) if err != nil { resultChan <- SubmitResult{ maybeTransactionSuccess: nil, @@ -55,7 +55,7 @@ func (minion *Minion) Run(destAddress string, resultChan chan SubmitResult) { succ, err := minion.SubmitTransaction(minion, minion.Horizon, txStr) resultChan <- SubmitResult{ maybeTransactionSuccess: succ, - maybeErr: errors.Wrap(err, "submitting tx to minion"), + maybeErr: errors.Wrapf(err, "submitting tx to minion %x", txHash), } } @@ -105,7 +105,7 @@ func (minion *Minion) checkHandleBadSequence(err *horizonclient.Error) { minion.forceRefreshSequence = true } -func (minion *Minion) makeTx(destAddress string) (string, error) { +func (minion *Minion) makeTx(destAddress string) ([32]byte, string, error) { createAccountOp := txnbuild.CreateAccount{ Destination: destAddress, SourceAccount: minion.BotAccount.GetAccountID(), @@ -121,23 +121,28 @@ func (minion *Minion) makeTx(destAddress string) (string, error) { }, ) if err != nil { - return "", errors.Wrap(err, "unable to build tx") + return [32]byte{}, "", errors.Wrap(err, "unable to build tx") } tx, err = tx.Sign(minion.Network, minion.Keypair, minion.BotKeypair) if err != nil { - return "", errors.Wrap(err, "unable to sign tx") + return [32]byte{}, "", errors.Wrap(err, "unable to sign tx") } txe, err := tx.Base64() if err != nil { - return "", errors.Wrap(err, "unable to serialize") + return [32]byte{}, "", errors.Wrap(err, "unable to serialize") + } + + txh, err := tx.HashHex(minion.Network) + if err != nil { + return [32]byte{}, "", errors.Wrap(err, "unable to hash") } // Increment the in-memory sequence number, since the tx will be submitted. _, err = minion.Account.IncrementSequenceNumber() if err != nil { - return "", errors.Wrap(err, "incrementing minion seq") + return [32]byte{}, "", errors.Wrap(err, "incrementing minion seq") } - return txe, err + return txh, txe, err } From 485b978fd331d551e6de65cff9ba5ec09b12a67f Mon Sep 17 00:00:00 2001 From: Leigh McCulloch <351529+leighmcculloch@users.noreply.github.com> Date: Fri, 29 Apr 2022 09:41:51 -0700 Subject: [PATCH 2/2] fix --- services/friendbot/internal/minion.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/friendbot/internal/minion.go b/services/friendbot/internal/minion.go index 5a56667d25..b8359b2c23 100644 --- a/services/friendbot/internal/minion.go +++ b/services/friendbot/internal/minion.go @@ -134,7 +134,7 @@ func (minion *Minion) makeTx(destAddress string) ([32]byte, string, error) { return [32]byte{}, "", errors.Wrap(err, "unable to serialize") } - txh, err := tx.HashHex(minion.Network) + txh, err := tx.Hash(minion.Network) if err != nil { return [32]byte{}, "", errors.Wrap(err, "unable to hash") }