UNPKG

xud

Version:
182 lines 10.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DisconnectionReason = exports.SwapFailureReason = exports.ReputationEvent = exports.SwapState = exports.SwapPhase = exports.SwapRole = exports.magicValsXuNetwork = exports.xuNetworkMagicVals = exports.XuNetwork = exports.Owner = exports.OrderSide = exports.OrderingDirection = exports.SwapClientType = void 0; /** An enumeration of payment channel network clients that support token swaps. */ var SwapClientType; (function (SwapClientType) { SwapClientType[SwapClientType["Lnd"] = 0] = "Lnd"; SwapClientType[SwapClientType["Connext"] = 2] = "Connext"; })(SwapClientType = exports.SwapClientType || (exports.SwapClientType = {})); var OrderingDirection; (function (OrderingDirection) { OrderingDirection["Desc"] = "DESC"; OrderingDirection["Asc"] = "ASC"; })(OrderingDirection = exports.OrderingDirection || (exports.OrderingDirection = {})); var OrderSide; (function (OrderSide) { OrderSide[OrderSide["Buy"] = 0] = "Buy"; OrderSide[OrderSide["Sell"] = 1] = "Sell"; OrderSide[OrderSide["Both"] = 2] = "Both"; })(OrderSide = exports.OrderSide || (exports.OrderSide = {})); var Owner; (function (Owner) { Owner[Owner["Both"] = 0] = "Both"; Owner[Owner["Own"] = 1] = "Own"; Owner[Owner["Peer"] = 2] = "Peer"; })(Owner = exports.Owner || (exports.Owner = {})); var XuNetwork; (function (XuNetwork) { // real coins. XuNetwork["MainNet"] = "mainnet"; // pre-defined testnet per currency (e.g. bitcoin: testnet3, litecoin: testnet4). XuNetwork["TestNet"] = "testnet"; // coins are minted by Exchange Union. XuNetwork["SimNet"] = "simnet"; // coins are minted privately. Seed nodes are not configurable. XuNetwork["RegTest"] = "regtest"; })(XuNetwork = exports.XuNetwork || (exports.XuNetwork = {})); /** * Magic value per XU network, indicating wire msg origin network, * and used to seek to next msg when stream state is unknown. */ exports.xuNetworkMagicVals = { [XuNetwork.MainNet]: 0xd9b4bef9, [XuNetwork.TestNet]: 0x0709110b, [XuNetwork.SimNet]: 0x12141c16, [XuNetwork.RegTest]: 0xdab5bffa, }; /** * XU network per magic value. */ exports.magicValsXuNetwork = { [exports.xuNetworkMagicVals[XuNetwork.MainNet]]: XuNetwork.MainNet, [exports.xuNetworkMagicVals[XuNetwork.TestNet]]: XuNetwork.TestNet, [exports.xuNetworkMagicVals[XuNetwork.SimNet]]: XuNetwork.SimNet, [exports.xuNetworkMagicVals[XuNetwork.RegTest]]: XuNetwork.RegTest, }; var SwapRole; (function (SwapRole) { SwapRole[SwapRole["Taker"] = 0] = "Taker"; SwapRole[SwapRole["Maker"] = 1] = "Maker"; SwapRole[SwapRole["Internal"] = 2] = "Internal"; })(SwapRole = exports.SwapRole || (exports.SwapRole = {})); var SwapPhase; (function (SwapPhase) { /** 0/5 The swap deal has been created locally. */ SwapPhase[SwapPhase["SwapCreated"] = 0] = "SwapCreated"; /** 1/5 We've made a request to a peer to accept this swap. */ SwapPhase[SwapPhase["SwapRequested"] = 1] = "SwapRequested"; /** 2/5 The terms of the swap have been agreed to, and we will attempt to execute it. */ SwapPhase[SwapPhase["SwapAccepted"] = 2] = "SwapAccepted"; /** * 3/5 We have made a request to the swap client to send payment according to the agreed terms. * The payment (and swap) could still fail due to no route with sufficient capacity, lack of * cooperation from the receiver or any intermediary node along the route, or an unexpected * error from the swap client. */ SwapPhase[SwapPhase["SendingPayment"] = 3] = "SendingPayment"; /** * 4/5 We have completed our outgoing payment and retrieved the preimage which can be used to * settle the incoming payment locked by the same hash. */ SwapPhase[SwapPhase["PreimageResolved"] = 5] = "PreimageResolved"; /** * 5/5 We have received the agreed amount of the swap and released the preimage to the * receiving swap client so it can accept payment. */ SwapPhase[SwapPhase["PaymentReceived"] = 4] = "PaymentReceived"; })(SwapPhase = exports.SwapPhase || (exports.SwapPhase = {})); var SwapState; (function (SwapState) { SwapState[SwapState["Active"] = 0] = "Active"; SwapState[SwapState["Error"] = 1] = "Error"; SwapState[SwapState["Completed"] = 2] = "Completed"; /** * A swap that was executed but wasn't formally completed. This may occur as a result of xud * crashing late in the swap process, after htlcs for both legs of the swap are set up but * before the swap is formally complete. */ SwapState[SwapState["Recovered"] = 3] = "Recovered"; })(SwapState = exports.SwapState || (exports.SwapState = {})); var ReputationEvent; (function (ReputationEvent) { ReputationEvent[ReputationEvent["ManualBan"] = 0] = "ManualBan"; ReputationEvent[ReputationEvent["ManualUnban"] = 1] = "ManualUnban"; ReputationEvent[ReputationEvent["PacketTimeout"] = 2] = "PacketTimeout"; ReputationEvent[ReputationEvent["WireProtocolErr"] = 3] = "WireProtocolErr"; ReputationEvent[ReputationEvent["InvalidAuth"] = 4] = "InvalidAuth"; ReputationEvent[ReputationEvent["SwapSuccess"] = 5] = "SwapSuccess"; /** When a swap is accepted and is attempted to be executed but fails. */ ReputationEvent[ReputationEvent["SwapFailure"] = 6] = "SwapFailure"; /** When a swap fails due to exceeding time limits. */ ReputationEvent[ReputationEvent["SwapTimeout"] = 7] = "SwapTimeout"; /** When a swap fails due to unexpected or possibly malicious behavior. */ ReputationEvent[ReputationEvent["SwapMisbehavior"] = 8] = "SwapMisbehavior"; /** * The peer has behaved dishonestly during a swap in a way that strongly * suggests it is running modified malicious code. */ ReputationEvent[ReputationEvent["SwapAbuse"] = 9] = "SwapAbuse"; /** * The peer completed a swap that was delayed beyond the expected deadline * to complete or fail the swap deal, but the delay was not so long as to * preclude the possibility of latency or lag. */ ReputationEvent[ReputationEvent["SwapDelay"] = 10] = "SwapDelay"; })(ReputationEvent = exports.ReputationEvent || (exports.ReputationEvent = {})); var SwapFailureReason; (function (SwapFailureReason) { /** Could not find the order specified by a swap request. */ SwapFailureReason[SwapFailureReason["OrderNotFound"] = 0] = "OrderNotFound"; /** The order specified by a swap request is on hold for a different ongoing swap. */ SwapFailureReason[SwapFailureReason["OrderOnHold"] = 1] = "OrderOnHold"; /** The swap request contained invalid data. */ SwapFailureReason[SwapFailureReason["InvalidSwapRequest"] = 2] = "InvalidSwapRequest"; /** We are not connected to both swap clients, or we are missing pub key identifiers for the peer's nodes. */ SwapFailureReason[SwapFailureReason["SwapClientNotSetup"] = 3] = "SwapClientNotSetup"; /** Could not find a route to complete the swap. */ SwapFailureReason[SwapFailureReason["NoRouteFound"] = 4] = "NoRouteFound"; /** A swap client call failed for an unexpected reason. */ SwapFailureReason[SwapFailureReason["UnexpectedClientError"] = 5] = "UnexpectedClientError"; /** Received a swap packet from the peer with invalid data. */ SwapFailureReason[SwapFailureReason["InvalidSwapPacketReceived"] = 6] = "InvalidSwapPacketReceived"; /** The call to send payment failed. */ SwapFailureReason[SwapFailureReason["SendPaymentFailure"] = 7] = "SendPaymentFailure"; /** The swap resolver request was invalid. */ SwapFailureReason[SwapFailureReason["InvalidResolveRequest"] = 8] = "InvalidResolveRequest"; /** The swap request attempts to reuse a payment hash. */ SwapFailureReason[SwapFailureReason["PaymentHashReuse"] = 9] = "PaymentHashReuse"; /** The swap timed out while we were waiting for it to complete execution. */ SwapFailureReason[SwapFailureReason["SwapTimedOut"] = 10] = "SwapTimedOut"; /** The deal timed out while we were waiting for the peer to respond to our swap request. */ SwapFailureReason[SwapFailureReason["DealTimedOut"] = 11] = "DealTimedOut"; /** The swap failed due to an unrecognized error. */ SwapFailureReason[SwapFailureReason["UnknownError"] = 12] = "UnknownError"; /** The swap failed due to an error or unexpected behavior on behalf of the remote peer. */ SwapFailureReason[SwapFailureReason["RemoteError"] = 13] = "RemoteError"; /** The swap failed because of a system or xud crash while the swap was being executed. */ SwapFailureReason[SwapFailureReason["Crash"] = 14] = "Crash"; /** A swap was attempted between an invalid matching of orders. */ SwapFailureReason[SwapFailureReason["InvalidOrders"] = 15] = "InvalidOrders"; /** Our payment to the peer was rejected, either deliberately or due to an error. */ SwapFailureReason[SwapFailureReason["PaymentRejected"] = 16] = "PaymentRejected"; /** The swap failed due to insufficient balance. */ SwapFailureReason[SwapFailureReason["InsufficientBalance"] = 17] = "InsufficientBalance"; })(SwapFailureReason = exports.SwapFailureReason || (exports.SwapFailureReason = {})); var DisconnectionReason; (function (DisconnectionReason) { DisconnectionReason[DisconnectionReason["ResponseStalling"] = 1] = "ResponseStalling"; DisconnectionReason[DisconnectionReason["IncompatibleProtocolVersion"] = 2] = "IncompatibleProtocolVersion"; DisconnectionReason[DisconnectionReason["UnexpectedIdentity"] = 3] = "UnexpectedIdentity"; DisconnectionReason[DisconnectionReason["ForbiddenIdentityUpdate"] = 4] = "ForbiddenIdentityUpdate"; DisconnectionReason[DisconnectionReason["ConnectedToSelf"] = 5] = "ConnectedToSelf"; DisconnectionReason[DisconnectionReason["NotAcceptingConnections"] = 6] = "NotAcceptingConnections"; DisconnectionReason[DisconnectionReason["Banned"] = 7] = "Banned"; DisconnectionReason[DisconnectionReason["AlreadyConnected"] = 8] = "AlreadyConnected"; DisconnectionReason[DisconnectionReason["Shutdown"] = 9] = "Shutdown"; DisconnectionReason[DisconnectionReason["MalformedVersion"] = 10] = "MalformedVersion"; DisconnectionReason[DisconnectionReason["AuthFailureInvalidTarget"] = 11] = "AuthFailureInvalidTarget"; DisconnectionReason[DisconnectionReason["AuthFailureInvalidSignature"] = 12] = "AuthFailureInvalidSignature"; DisconnectionReason[DisconnectionReason["WireProtocolErr"] = 13] = "WireProtocolErr"; })(DisconnectionReason = exports.DisconnectionReason || (exports.DisconnectionReason = {})); //# sourceMappingURL=enums.js.map