Documentation
¶
Overview ¶
Package wire provides bidirectional conversion between Fedwire files and TableData.
This package bridges the moov-io/wire library with fileparser.TableData, enabling SQL queries on Fedwire message data via filesql.
Security Note ¶
TableData structures expose sensitive banking information including routing numbers, account numbers, names, and transaction amounts. Avoid logging or exporting TableData contents verbatim in production environments.
Table Structure ¶
A single Fedwire file contains one FEDWireMessage, which is converted to a single-row flat table with approximately 326 columns. All columns are TEXT type since the wire format stores all values as strings.
Column groups include:
- Mandatory fields: SenderSupplied, TypeSubType, IMAD, Amount, SenderDI, ReceiverDI, BusinessFunctionCode
- Financial institutions: BeneficiaryIntermediaryFI, BeneficiaryFI, OriginatorFI, InstructingFI
- Parties: Beneficiary, Originator, OriginatorOptionF
- FI-to-FI information: FIReceiverFI, FIIntermediaryFI, FIBeneficiaryFI, FIBeneficiary
- Advice records: FIDrawdownDebitAccountAdvice, FIIntermediaryFIAdvice, FIBeneficiaryFIAdvice, FIBeneficiaryAdvice
- Cover payment: OrderingCustomer, OrderingInstitution, IntermediaryInstitution, etc.
- Remittance: RemittanceOriginator, RemittanceBeneficiary, RelatedRemittance, etc.
- System: MessageDisposition, ReceiptTimeStamp, OMAD, ErrorWire, ServiceMessage
Limitations ¶
Only UPDATE operations on existing rows are supported for round-trip editing. INSERT/DELETE operations in SQL are not reflected in the output wire file. Optional message sections that were not present in the original file cannot be added via SQL modifications.
Usage ¶
import (
"github.com/nao1215/fileparser/wire"
moovwire "github.com/moov-io/wire"
)
// Read wire file
f, _ := os.Open("payment.fed")
defer f.Close()
ts, _ := wire.ParseReader(f)
// Access the flat table
table := ts.GetMessageTable()
fmt.Println("Columns:", len(table.Headers))
// After SQL modifications, write back
out, _ := os.Create("modified.fed")
defer out.Close()
ts.WriteToWriter(out)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TableSet ¶
type TableSet struct {
// Message contains all flattened fields of the FEDWireMessage (1 row)
Message *fileparser.TableData
// contains filtered or unexported fields
}
TableSet contains a flat TableData representing all fields of a Fedwire message. This structure preserves the complete message while enabling flat table-based queries.
func FromFile ¶
FromFile converts a wire.File to a TableSet with a single flat table. The returned TableSet can be used with filesql for SQL queries.
Note: The TableSet stores a reference to the original file (not a copy). ToFile() creates a deep copy before applying TableData modifications.
func ParseReader ¶
ParseReader parses a wire file from an io.Reader and returns a TableSet. This function encapsulates the moov-io/wire dependency so that callers don't need to import moov-io/wire directly. Returns an error if reader is nil.
func (*TableSet) GetMessageTable ¶
func (ts *TableSet) GetMessageTable() *fileparser.TableData
GetMessageTable returns the message TableData for use with filesql.
func (*TableSet) ToFile ¶
ToFile reconstructs a wire.File from modified TableData. This allows round-trip editing: Wire -> TableData -> SQL modifications -> Wire
The function creates a deep copy of the original wire file and applies modifications from the TableData. Sub-structs that were nil in the original file are lazily allocated when the TableData record contains non-empty values for their fields, enabling addition of new sections via SQL edits.
func (*TableSet) UpdateMessageFromTableData ¶
func (ts *TableSet) UpdateMessageFromTableData(td *fileparser.TableData)
UpdateMessageFromTableData updates the internal message data from modified TableData. Call this after making SQL modifications to prepare for ToFile().
func (*TableSet) WriteToWriter ¶
WriteToWriter writes the wire file from a TableSet to an io.Writer. This function encapsulates the moov-io/wire dependency so that callers don't need to import moov-io/wire directly. Returns an error if the TableSet or writer is nil.