wire

package
v0.48.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package wire provides bidirectional conversion between Fedwire files and TableData.

This package bridges the moov-io/wire library with parser.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/filesql/parser/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

Examples

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 *parser.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 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.

Example
package main

import (
	"fmt"
	"os"

	"github.com/nao1215/filesql/parser/wire"
)

func main() {
	file, err := os.Open("testdata/fedWireMessage-CustomerTransfer.fed")
	if err != nil {
		fmt.Println("Error:", err)
		return
	}
	defer file.Close()

	tableSet, err := wire.ParseReader(file)
	if err != nil {
		fmt.Println("Error:", err)
		return
	}

	// A Fedwire message is one row of one wide table rather than a set of
	// tables: every tag the format defines is a column, present or not.
	message := tableSet.GetMessageTable()
	fmt.Println("rows:", len(message.Records))
	fmt.Println("columns:", len(message.Headers))
	fmt.Println("first columns:", message.Headers[:3])
}
Output:
rows: 1
columns: 326
first columns: [sender_supplied_format_version sender_supplied_user_request_correlation sender_supplied_test_production_code]

func (*TableSet) GetMessageTable

func (ts *TableSet) GetMessageTable() *parser.TableData

GetMessageTable returns the message TableData for use with filesql.

func (*TableSet) UpdateMessageFromTableData

func (ts *TableSet) UpdateMessageFromTableData(td *parser.TableData)

UpdateMessageFromTableData updates the internal message data from modified TableData. Call this after making SQL modifications to prepare for WriteToWriter.

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