GetTransactionLineage retrieves the lineage information for a transaction. It returns the fund allocation details and any shadow transactions created for the transaction. Parameters: - ctx context.Context: The context for the operation. - transactionID string: The ID of the transaction to get linea
(ctx context.Context, transactionID string)
| 1159 | // - *TransactionLineage: The lineage information for the transaction. |
| 1160 | // - error: An error if the lineage could not be retrieved. |
| 1161 | func (l *LedgerForge) GetTransactionLineage(ctx context.Context, transactionID string) (*TransactionLineage, error) { |
| 1162 | ctx, span := tracer.Start(ctx, "GetTransactionLineage") |
| 1163 | defer span.End() |
| 1164 | |
| 1165 | txn, err := l.GetTransaction(ctx, transactionID) |
| 1166 | if err != nil { |
| 1167 | return nil, fmt.Errorf("failed to get transaction: %w", err) |
| 1168 | } |
| 1169 | |
| 1170 | lineage := &TransactionLineage{ |
| 1171 | TransactionID: transactionID, |
| 1172 | FundAllocation: l.extractFundAllocation(txn.MetaData), |
| 1173 | ShadowTransactions: make([]model.Transaction, 0), |
| 1174 | } |
| 1175 | |
| 1176 | shadowTxns, err := l.datasource.GetTransactionsByShadowFor(ctx, transactionID) |
| 1177 | if err == nil { |
| 1178 | lineage.ShadowTransactions = shadowTxns |
| 1179 | } |
| 1180 | |
| 1181 | return lineage, nil |
| 1182 | } |
| 1183 | |
| 1184 | // extractFundAllocation extracts fund allocation data from transaction metadata. |
| 1185 | // |