MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / GetTransactionLineage

Method GetTransactionLineage

lineage.go:1161–1182  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

1159// - *TransactionLineage: The lineage information for the transaction.
1160// - error: An error if the lineage could not be retrieved.
1161func (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//

Calls 4

GetTransactionMethod · 0.95
extractFundAllocationMethod · 0.95
StartMethod · 0.45