From d6a206496ede06fe29a1db5697f22880d241461b Mon Sep 17 00:00:00 2001 From: Amisha Singla Date: Mon, 29 Jul 2024 12:53:40 -0500 Subject: [PATCH 1/3] Add signatures result in transaction output --- internal/transform/schema.go | 1 + internal/transform/transaction.go | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/internal/transform/schema.go b/internal/transform/schema.go index 3098eddd..cbe190fa 100644 --- a/internal/transform/schema.go +++ b/internal/transform/schema.go @@ -74,6 +74,7 @@ type TransactionOutput struct { TotalNonRefundableResourceFeeCharged int64 `json:"non_refundable_resource_fee_charged"` TotalRefundableResourceFeeCharged int64 `json:"refundable_resource_fee_charged"` RentFeeCharged int64 `json:"rent_fee_charged"` + Signatures []string `json:"signatures"` } type LedgerTransactionOutput struct { diff --git a/internal/transform/transaction.go b/internal/transform/transaction.go index 05375791..7b4ffbd4 100644 --- a/internal/transform/transaction.go +++ b/internal/transform/transaction.go @@ -127,6 +127,12 @@ func TransformTransaction(transaction ingest.LedgerTransaction, lhe xdr.LedgerHe outputMinSequenceLedgerGap = null.IntFrom(int64(*minSequenceLedgerGap)) } + xdrSignatures := transaction.Envelope.Signatures() + signatures := make([]string, len(xdrSignatures)) + for i, sig := range xdrSignatures { + signatures[i] = base64.StdEncoding.EncodeToString(sig.Signature) + } + // Soroban fees and resources // Note: MaxFee and FeeCharged is the sum of base transaction fees + Soroban fees // Breakdown of Soroban fees can be calculated by the config_setting resource pricing * the resources used @@ -224,6 +230,7 @@ func TransformTransaction(transaction ingest.LedgerTransaction, lhe xdr.LedgerHe TotalNonRefundableResourceFeeCharged: outputTotalNonRefundableResourceFeeCharged, TotalRefundableResourceFeeCharged: outputTotalRefundableResourceFeeCharged, RentFeeCharged: outputRentFeeCharged, + Signatures: signatures, } // Add Muxed Account Details, if exists From 461c76232faa702bc66c23bb1dbc527fef5920b5 Mon Sep 17 00:00:00 2001 From: Amisha Singla Date: Mon, 29 Jul 2024 13:24:42 -0500 Subject: [PATCH 2/3] update tests --- internal/transform/transaction_test.go | 27 +++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/internal/transform/transaction_test.go b/internal/transform/transaction_test.go index 7759b3a4..e0500dc6 100644 --- a/internal/transform/transaction_test.go +++ b/internal/transform/transaction_test.go @@ -83,7 +83,7 @@ func makeTransactionTestOutput() (output []TransactionOutput, err error) { correctTime, err := time.Parse("2006-1-2 15:04:05 MST", "2020-07-09 05:28:42 UTC") output = []TransactionOutput{ { - TxEnvelope: "AAAAAgAAAACI4aa0pXFSj6qfJuIObLw/5zyugLRGYwxb7wFSr3B9eAABX5ABjydzAABBtwAAAAEAAAAAAAAAAAAAAABfBqt0AAAAAQAAABdITDVhQ2dvelFISVc3c1NjNVhkY2ZtUgAAAAABAAAAAQAAAAAcR0GXGO76pFs4y38vJVAanjnLg4emNun7zAx0pHcDGAAAAAIAAAAAAAAAAAAAAAAAAAAAAQIDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=", + TxEnvelope: "AAAAAgAAAACI4aa0pXFSj6qfJuIObLw/5zyugLRGYwxb7wFSr3B9eAABX5ABjydzAABBtwAAAAEAAAAAAAAAAAAAAABfBqt0AAAAAQAAABdITDVhQ2dvelFISVc3c1NjNVhkY2ZtUgAAAAABAAAAAQAAAAAcR0GXGO76pFs4y38vJVAanjnLg4emNun7zAx0pHcDGAAAAAIAAAAAAAAAAAAAAAAAAAAAAQIDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFjQq+PAAAAQPRri1y9nM9PVDgCRksW7TJk8p+xG/BCerYtvU4Ffxo9s+7lTCDOeg2ahZSVHfowhCxWozggLEtX4vtMBDu2hAg=", TxResult: "AAAAAAAAASz/////AAAAAQAAAAAAAAAAAAAAAAAAAAA=", TxMeta: "AAAAAQAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAwAAAAAAAAAFAQIDBAUGBwgJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFVU1NEAAAAAGtY3WxokwttAx3Fu/riPvoew/C7WMK8jZONR8Hfs75zAAAAHgAAAAAAAYagAAAAAAAAA+gAAAAAAAAB9AAAAAAAAAAZAAAAAAAAAAEAAAAAAAAABQECAwQFBgcICQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVVNTRAAAAABrWN1saJMLbQMdxbv64j76HsPwu1jCvI2TjUfB37O+cwAAAB4AAAAAAAGKiAAAAAAAAARMAAAAAAAAAfYAAAAAAAAAGgAAAAAAAAACAAAAAwAAAAAAAAAFAQIDBAUGBwgJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFVU1NEAAAAAGtY3WxokwttAx3Fu/riPvoew/C7WMK8jZONR8Hfs75zAAAAHgAAAAAAAYagAAAAAAAAA+gAAAAAAAAB9AAAAAAAAAAZAAAAAAAAAAEAAAAAAAAABQECAwQFBgcICQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVVNTRAAAAABrWN1saJMLbQMdxbv64j76HsPwu1jCvI2TjUfB37O+cwAAAB4AAAAAAAGKiAAAAAAAAARMAAAAAAAAAfYAAAAAAAAAGgAAAAAAAAAA", TxFeeMeta: "AAAAAA==", @@ -106,9 +106,10 @@ func makeTransactionTestOutput() (output []TransactionOutput, err error) { SorobanResourcesReadBytes: 0, SorobanResourcesWriteBytes: 0, TransactionResultCode: "TransactionResultCodeTxFailed", + Signatures: []string{"9GuLXL2cz09UOAJGSxbtMmTyn7Eb8EJ6ti29TgV/Gj2z7uVMIM56DZqFl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AAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAwAAAAAAAAAFAQIDBAUGBwgJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFVU1NEAAAAAGtY3WxokwttAx3Fu/riPvoew/C7WMK8jZONR8Hfs75zAAAAHgAAAAAAAYagAAAAAAAAA+gAAAAAAAAB9AAAAAAAAAAZAAAAAAAAAAEAAAAAAAAABQECAwQFBgcICQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVVNTRAAAAABrWN1saJMLbQMdxbv64j76HsPwu1jCvI2TjUfB37O+cwAAAB4AAAAAAAGKiAAAAAAAAARMAAAAAAAAAfYAAAAAAAAAGgAAAAAAAAACAAAAAwAAAAAAAAAFAQIDBAUGBwgJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFVU1NEAAAAAGtY3WxokwttAx3Fu/riPvoew/C7WMK8jZONR8Hfs75zAAAAHgAAAAAAAYagAAAAAAAAA+gAAAAAAAAB9AAAAAAAAAAZAAAAAAAAAAEAAAAAAAAABQECAwQFBgcICQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVVNTRAAAAABrWN1saJMLbQMdxbv64j76HsPwu1jCvI2TjUfB37O+cwAAAB4AAAAAAAGKiAAAAAAAAARMAAAAAAAAAfYAAAAAAAAAGgAAAAAAAAAA", TxFeeMeta: "AAAAAA==", @@ -135,9 +136,10 @@ func makeTransactionTestOutput() (output []TransactionOutput, err error) { SorobanResourcesReadBytes: 0, SorobanResourcesWriteBytes: 0, TransactionResultCode: "TransactionResultCodeTxFeeBumpInnerSuccess", //inner fee bump success + Signatures: []string{}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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAAAwAAAAAAAAAFAQIDBAUGBwgJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFVU1NEAAAAAGtY3WxokwttAx3Fu/riPvoew/C7WMK8jZONR8Hfs75zAAAAHgAAAAAAAYagAAAAAAAAA+gAAAAAAAAB9AAAAAAAAAAZAAAAAAAAAAEAAAAAAAAABQECAwQFBgcICQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVVNTRAAAAABrWN1saJMLbQMdxbv64j76HsPwu1jCvI2TjUfB37O+cwAAAB4AAAAAAAGKiAAAAAAAAARMAAAAAAAAAfYAAAAAAAAAGgAAAAAAAAACAAAAAwAAAAAAAAAFAQIDBAUGBwgJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFVU1NEAAAAAGtY3WxokwttAx3Fu/riPvoew/C7WMK8jZONR8Hfs75zAAAAHgAAAAAAAYagAAAAAAAAA+gAAAAAAAAB9AAAAAAAAAAZAAAAAAAAAAEAAAAAAAAABQECAwQFBgcICQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABVVNTRAAAAABrWN1saJMLbQMdxbv64j76HsPwu1jCvI2TjUfB37O+cwAAAB4AAAAAAAGKiAAAAAAAAARMAAAAAAAAAfYAAAAAAAAAGgAAAAAAAAAA", TxFeeMeta: "AAAAAA==", @@ -164,6 +166,7 @@ func makeTransactionTestOutput() (output []TransactionOutput, err error) { SorobanResourcesReadBytes: 0, SorobanResourcesWriteBytes: 0, TransactionResultCode: "TransactionResultCodeTxInsufficientBalance", + Signatures: []string{"9GuLXL2cz09UOAJGSxbtMmTyn7Eb8EJ6ti29TgV/Gj2z7uVMIM56DZqFlJUd+jCELFajOCAsS1fi+0wEO7aECA=="}, }, } return @@ -232,6 +235,12 @@ func makeTransactionTestInput() (transaction []ingest.LedgerTransaction, history }, }, }, + Signatures: []xdr.DecoratedSignature{ + { + Hint: xdr.SignatureHint{99, 66, 175, 143}, + Signature: xdr.Signature{244, 107, 139, 92, 189, 156, 207, 79, 84, 56, 2, 70, 75, 22, 237, 50, 100, 242, 159, 177, 27, 240, 66, 122, 182, 45, 189, 78, 5, 127, 26, 61, 179, 238, 229, 76, 32, 206, 122, 13, 154, 133, 148, 149, 29, 250, 48, 132, 44, 86, 163, 56, 32, 44, 75, 87, 226, 251, 76, 4, 59, 182, 132, 8}, + }, + }, }, }, Result: xdr.TransactionResultPair{ @@ -286,6 +295,12 @@ func makeTransactionTestInput() (transaction []ingest.LedgerTransaction, history }, }, }, + Signatures: []xdr.DecoratedSignature{ + { + Hint: xdr.SignatureHint{99, 66, 175, 143}, + Signature: xdr.Signature{244, 107, 139, 92, 189, 156, 207, 79, 84, 56, 2, 70, 75, 22, 237, 50, 100, 242, 159, 177, 27, 240, 66, 122, 182, 45, 189, 78, 5, 127, 26, 61, 179, 238, 229, 76, 32, 206, 122, 13, 154, 133, 148, 149, 29, 250, 48, 132, 44, 86, 163, 56, 32, 44, 75, 87, 226, 251, 76, 4, 59, 182, 132, 8}, + }, + }, }, }, Result: xdr.TransactionResultPair{ @@ -355,6 +370,12 @@ func makeTransactionTestInput() (transaction []ingest.LedgerTransaction, history }, }, }, + Signatures: []xdr.DecoratedSignature{ + { + Hint: xdr.SignatureHint{99, 66, 175, 143}, + Signature: xdr.Signature{244, 107, 139, 92, 189, 156, 207, 79, 84, 56, 2, 70, 75, 22, 237, 50, 100, 242, 159, 177, 27, 240, 66, 122, 182, 45, 189, 78, 5, 127, 26, 61, 179, 238, 229, 76, 32, 206, 122, 13, 154, 133, 148, 149, 29, 250, 48, 132, 44, 86, 163, 56, 32, 44, 75, 87, 226, 251, 76, 4, 59, 182, 132, 8}, + }, + }, }, }, Result: xdr.TransactionResultPair{ From ced69a340ca75d59b02c16065e33ef56d0586e82 Mon Sep 17 00:00:00 2001 From: Amisha Singla Date: Mon, 29 Jul 2024 14:47:01 -0500 Subject: [PATCH 3/3] Add signature for fee bump account as well --- internal/transform/transaction.go | 19 ++++++++++++------- internal/transform/transaction_test.go | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/internal/transform/transaction.go b/internal/transform/transaction.go index 7b4ffbd4..973935fb 100644 --- a/internal/transform/transaction.go +++ b/internal/transform/transaction.go @@ -127,12 +127,6 @@ func TransformTransaction(transaction ingest.LedgerTransaction, lhe xdr.LedgerHe outputMinSequenceLedgerGap = null.IntFrom(int64(*minSequenceLedgerGap)) } - xdrSignatures := transaction.Envelope.Signatures() - signatures := make([]string, len(xdrSignatures)) - for i, sig := range xdrSignatures { - signatures[i] = base64.StdEncoding.EncodeToString(sig.Signature) - } - // Soroban fees and resources // Note: MaxFee and FeeCharged is the sum of base transaction fees + Soroban fees // Breakdown of Soroban fees can be calculated by the config_setting resource pricing * the resources used @@ -230,7 +224,7 @@ func TransformTransaction(transaction ingest.LedgerTransaction, lhe xdr.LedgerHe TotalNonRefundableResourceFeeCharged: outputTotalNonRefundableResourceFeeCharged, TotalRefundableResourceFeeCharged: outputTotalRefundableResourceFeeCharged, RentFeeCharged: outputRentFeeCharged, - Signatures: signatures, + Signatures: getSignatures(transaction.Envelope.Signatures()), } // Add Muxed Account Details, if exists @@ -255,6 +249,8 @@ func TransformTransaction(transaction ingest.LedgerTransaction, lhe xdr.LedgerHe innerHash := transaction.Result.InnerHash() transformedTransaction.InnerTransactionHash = hex.EncodeToString(innerHash[:]) transformedTransaction.NewMaxFee = uint32(transaction.Envelope.FeeBumpFee()) + + transformedTransaction.Signatures = getSignatures(transaction.Envelope.FeeBump.Signatures) } return transformedTransaction, nil @@ -302,3 +298,12 @@ func formatSigners(s []xdr.SignerKey) pq.StringArray { return signers } + +func getSignatures(xdrSignatures []xdr.DecoratedSignature) []string { + signatures := make([]string, len(xdrSignatures)) + for i, sig := range xdrSignatures { + signatures[i] = base64.StdEncoding.EncodeToString(sig.Signature) + } + + return signatures +} diff --git a/internal/transform/transaction_test.go b/internal/transform/transaction_test.go index e0500dc6..8cad7e33 100644 --- a/internal/transform/transaction_test.go +++ b/internal/transform/transaction_test.go @@ -136,7 +136,7 @@ func makeTransactionTestOutput() (output []TransactionOutput, err error) { SorobanResourcesReadBytes: 0, SorobanResourcesWriteBytes: 0, TransactionResultCode: "TransactionResultCodeTxFeeBumpInnerSuccess", //inner fee bump success - Signatures: []string{}, + Signatures: []string{"9GuLXL2cz09UOAJGSxbtMmTyn7Eb8EJ6ti29TgV/Gj2z7uVMIM56DZqFlJUd+jCELFajOCAsS1fi+0wEO7aECA=="}, }, { TxEnvelope: "AAAAAgAAAAAcR0GXGO76pFs4y38vJVAanjnLg4emNun7zAx0pHcDGAAAAGQBpLyvsiV6gwAAAAIAAAABAAAAAAAAAAAAAAAAXwardAAAAAEAAAAFAAAACgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAMCAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAABdITDVhQ2dvelFISVc3c1NjNVhkY2ZtUgAAAAABAAAAAQAAAABrWN1saJMLbQMdxbv64j76HsPwu1jCvI2TjUfB37O+cwAAAAIAAAAAAAAAAAAAAAAAAAAAAQIDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFjQq+PAAAAQPRri1y9nM9PVDgCRksW7TJk8p+xG/BCerYtvU4Ffxo9s+7lTCDOeg2ahZSVHfowhCxWozggLEtX4vtMBDu2hAg=",