wire

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2026 License: MIT Imports: 5 Imported by: 0

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

func FromFile(file *wire.File) *TableSet

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

func ParseReader(reader io.Reader) (*TableSet, error)

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

func (ts *TableSet) ToFile() (*wire.File, error)

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.

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

func (ts *TableSet) WriteToWriter(writer io.Writer) error

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL