package helpers import ( "encoding/binary" "ripple/commands" "ripple/types" ) func BuildFindPath(paymentID [32]byte, amount uint64, inOrOut byte, penaltyRate uint32, fee uint64, hops byte) types.Instruction { buf := make([]byte, 54) copy(buf[:32], paymentID[:]) binary.BigEndian.PutUint64(buf[32:40], amount) buf[40] = inOrOut binary.BigEndian.PutUint32(buf[41:45], penaltyRate) binary.BigEndian.PutUint64(buf[45:53], fee) buf[53] = hops return types.Instruction{ Command: commands.ACCOUNT_FIND_PATH, Arguments: buf, } } func BuildPathRecurse(paymentID [32]byte, depth byte) types.Instruction { buf := make([]byte, 33) copy(buf[:32], paymentID[:]) buf[32] = depth return types.Instruction{ Command: commands.ACCOUNT_PATH_RECURSE, Arguments: buf, } } func BuildPathFound(paymentID [32]byte, hops byte) types.Instruction { buf := make([]byte, 33) copy(buf[:32], paymentID[:]) buf[32] = hops return types.Instruction{ Command: commands.ACCOUNT_PATH_FOUND, Arguments: buf, } } func BuildPreparePath(paymentID [32]byte) types.Instruction { return types.Instruction{ Command: commands.ACCOUNT_PREPARE_PATH, Arguments: paymentID[:], } } func BuildCommitPayment(paymentID [32]byte) types.Instruction { return types.Instruction{ Command: commands.ACCOUNT_COMMIT_PAYMENT, Arguments: paymentID[:], } } func BuildSealPayment(paymentID [32]byte) types.Instruction { return types.Instruction{ Command: commands.ACCOUNT_SEAL_PAYMENT, Arguments: paymentID[:], } } func BuildFinalizePayment(paymentID [32]byte, preimage [32]byte) types.Instruction { buf := make([]byte, 64) copy(buf[:32], paymentID[:]) copy(buf[32:64], preimage[:]) return types.Instruction{ Command: commands.ACCOUNT_FINALIZE_PAYMENT, Arguments: buf, } } func BuildCancelPayment(paymentID [32]byte, preimage [32]byte) types.Instruction { buf := make([]byte, 64) copy(buf[:32], paymentID[:]) copy(buf[32:64], preimage[:]) return types.Instruction{ Command: commands.ACCOUNT_CANCEL_PAYMENT, Arguments: buf, } } func BuildCleanupPayment(paymentID [32]byte) types.Instruction { return types.Instruction{ Command: commands.ACCOUNT_CLEANUP_PAYMENT, Arguments: paymentID[:], } } func BuildAckPreimage(paymentID [32]byte) types.Instruction { return types.Instruction{ Command: commands.ACCOUNT_ACK_PREIMAGE, Arguments: paymentID[:], } } func BuildSyncPayment(paymentID [32]byte, amount uint64) types.Instruction { buf := make([]byte, 40) copy(buf[:32], paymentID[:]) binary.BigEndian.PutUint64(buf[32:40], amount) return types.Instruction{ Command: commands.ACCOUNT_SYNC_PAYMENT, Arguments: buf, } } func BuildAckSync(paymentID [32]byte) types.Instruction { return types.Instruction{ Command: commands.ACCOUNT_ACK_SYNC, Arguments: paymentID[:], } } func BuildVerifyCommit(paymentID [32]byte) types.Instruction { return types.Instruction{ Command: commands.ACCOUNT_VERIFY_COMMIT, Arguments: paymentID[:], } } func BuildAckCommit(paymentID [32]byte, status byte) types.Instruction { buf := make([]byte, 33) copy(buf[:32], paymentID[:]) buf[32] = status return types.Instruction{ Command: commands.ACCOUNT_ACK_COMMIT, Arguments: buf, } }