diff --git a/internal/transform/schema.go b/internal/transform/schema.go index cbe190fa..981006c6 100644 --- a/internal/transform/schema.go +++ b/internal/transform/schema.go @@ -74,7 +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"` + TxSigners []string `json:"tx_signers"` } type LedgerTransactionOutput struct { diff --git a/internal/transform/transaction.go b/internal/transform/transaction.go index 973935fb..d0ee1415 100644 --- a/internal/transform/transaction.go +++ b/internal/transform/transaction.go @@ -12,6 +12,7 @@ import ( "github.com/stellar/stellar-etl/internal/utils" "github.com/stellar/go/ingest" + "github.com/stellar/go/strkey" "github.com/stellar/go/xdr" ) @@ -188,6 +189,11 @@ func TransformTransaction(transaction ingest.LedgerTransaction, lhe xdr.LedgerHe outputTxResultCode := transaction.Result.Result.Result.Code.String() + txSigners, err := getTxSigners(transaction.Envelope.Signatures()) + if err != nil { + return TransactionOutput{}, err + } + outputSuccessful := transaction.Result.Successful() transformedTransaction := TransactionOutput{ TransactionHash: outputTransactionHash, @@ -224,7 +230,7 @@ func TransformTransaction(transaction ingest.LedgerTransaction, lhe xdr.LedgerHe TotalNonRefundableResourceFeeCharged: outputTotalNonRefundableResourceFeeCharged, TotalRefundableResourceFeeCharged: outputTotalRefundableResourceFeeCharged, RentFeeCharged: outputRentFeeCharged, - Signatures: getSignatures(transaction.Envelope.Signatures()), + TxSigners: txSigners, } // Add Muxed Account Details, if exists @@ -249,8 +255,12 @@ func TransformTransaction(transaction ingest.LedgerTransaction, lhe xdr.LedgerHe innerHash := transaction.Result.InnerHash() transformedTransaction.InnerTransactionHash = hex.EncodeToString(innerHash[:]) transformedTransaction.NewMaxFee = uint32(transaction.Envelope.FeeBumpFee()) + txSigners, err := getTxSigners(transaction.Envelope.FeeBump.Signatures) + if err != nil { + return TransactionOutput{}, err + } - transformedTransaction.Signatures = getSignatures(transaction.Envelope.FeeBump.Signatures) + transformedTransaction.TxSigners = txSigners } return transformedTransaction, nil @@ -299,11 +309,16 @@ func formatSigners(s []xdr.SignerKey) pq.StringArray { return signers } -func getSignatures(xdrSignatures []xdr.DecoratedSignature) []string { - signatures := make([]string, len(xdrSignatures)) +func getTxSigners(xdrSignatures []xdr.DecoratedSignature) ([]string, error) { + signers := make([]string, len(xdrSignatures)) + for i, sig := range xdrSignatures { - signatures[i] = base64.StdEncoding.EncodeToString(sig.Signature) + signerAccount, err := strkey.Encode(strkey.VersionByteAccountID, sig.Signature) + if err != nil { + return nil, err + } + signers[i] = signerAccount } - return signatures + return signers, nil } diff --git a/internal/transform/transaction_test.go b/internal/transform/transaction_test.go index 8cad7e33..cc024954 100644 --- a/internal/transform/transaction_test.go +++ b/internal/transform/transaction_test.go @@ -106,7 +106,7 @@ func makeTransactionTestOutput() (output []TransactionOutput, err error) { SorobanResourcesReadBytes: 0, SorobanResourcesWriteBytes: 0, TransactionResultCode: "TransactionResultCodeTxFailed", - Signatures: []string{"9GuLXL2cz09UOAJGSxbtMmTyn7Eb8EJ6ti29TgV/Gj2z7uVMIM56DZqFlJUd+jCELFajOCAsS1fi+0wEO7aECA=="}, + TxSigners: []string{"GD2GXC24XWOM6T2UHABEMSYW5UZGJ4U7WEN7AQT2WYW32TQFP4ND3M7O4VGCBTT2BWNILFEVDX5DBBBMK2RTQIBMJNL6F62MAQ53NBAIXUDA"}, }, { TxEnvelope: "AAAABQAAAQAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHCAAAAACAAAAAIjhprSlcVKPqp8m4g5svD/nPK6AtEZjDFvvAVKvcH14AAAAAAIU9jYAAAB9AAAAAQAAAAAAAAAAAAAAAF8Gq3QAAAABAAAAF0hMNWFDZ296UUhJVzdzU2M1WGRjZm1SAAAAAAEAAAABAAAAABxHQZcY7vqkWzjLfy8lUBqeOcuDh6Y26fvMDHSkdwMYAAAAAgAAAAAAAAAAAAAAAAAAAAABAgMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABY0KvjwAAAED0a4tcvZzPT1Q4AkZLFu0yZPKfsRvwQnq2Lb1OBX8aPbPu5UwgznoNmoWUlR36MIQsVqM4ICxLV+L7TAQ7toQI", @@ -136,7 +136,7 @@ func makeTransactionTestOutput() (output []TransactionOutput, err error) { SorobanResourcesReadBytes: 0, SorobanResourcesWriteBytes: 0, TransactionResultCode: "TransactionResultCodeTxFeeBumpInnerSuccess", //inner fee bump success - Signatures: []string{"9GuLXL2cz09UOAJGSxbtMmTyn7Eb8EJ6ti29TgV/Gj2z7uVMIM56DZqFlJUd+jCELFajOCAsS1fi+0wEO7aECA=="}, + TxSigners: []string{"GD2GXC24XWOM6T2UHABEMSYW5UZGJ4U7WEN7AQT2WYW32TQFP4ND3M7O4VGCBTT2BWNILFEVDX5DBBBMK2RTQIBMJNL6F62MAQ53NBAIXUDA"}, }, { TxEnvelope: "AAAAAgAAAAAcR0GXGO76pFs4y38vJVAanjnLg4emNun7zAx0pHcDGAAAAGQBpLyvsiV6gwAAAAIAAAABAAAAAAAAAAAAAAAAXwardAAAAAEAAAAFAAAACgAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAMCAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAABdITDVhQ2dvelFISVc3c1NjNVhkY2ZtUgAAAAABAAAAAQAAAABrWN1saJMLbQMdxbv64j76HsPwu1jCvI2TjUfB37O+cwAAAAIAAAAAAAAAAAAAAAAAAAAAAQIDAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFjQq+PAAAAQPRri1y9nM9PVDgCRksW7TJk8p+xG/BCerYtvU4Ffxo9s+7lTCDOeg2ahZSVHfowhCxWozggLEtX4vtMBDu2hAg=", @@ -166,7 +166,7 @@ func makeTransactionTestOutput() (output []TransactionOutput, err error) { SorobanResourcesReadBytes: 0, SorobanResourcesWriteBytes: 0, TransactionResultCode: "TransactionResultCodeTxInsufficientBalance", - Signatures: []string{"9GuLXL2cz09UOAJGSxbtMmTyn7Eb8EJ6ti29TgV/Gj2z7uVMIM56DZqFlJUd+jCELFajOCAsS1fi+0wEO7aECA=="}, + TxSigners: []string{"GD2GXC24XWOM6T2UHABEMSYW5UZGJ4U7WEN7AQT2WYW32TQFP4ND3M7O4VGCBTT2BWNILFEVDX5DBBBMK2RTQIBMJNL6F62MAQ53NBAIXUDA"}, }, } return