UNPKG

triam-base

Version:
1,227 lines (1,179 loc) 1.37 MB
var StellarBase = /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) /******/ return installedModules[moduleId].exports; /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ exports: {}, /******/ id: moduleId, /******/ loaded: false /******/ }; /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ // Flag the module as loaded /******/ module.loaded = true; /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ // Load entry module and return exports /******/ return __webpack_require__(0); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; module.exports = __webpack_require__(1); // Ignore lodash from js-xdr /*globals _*/ _.noConflict(); /***/ }), /* 1 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function _interopExportWildcard(obj, defaults) { var newObj = defaults({}, obj); delete newObj["default"]; return newObj; } function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } var _generatedStellarXdr_generated = __webpack_require__(2); var _generatedStellarXdr_generated2 = _interopRequireDefault(_generatedStellarXdr_generated); exports.xdr = _generatedStellarXdr_generated2["default"]; var _hashing = __webpack_require__(41); Object.defineProperty(exports, "hash", { enumerable: true, get: function get() { return _hashing.hash; } }); var _signing = __webpack_require__(51); Object.defineProperty(exports, "sign", { enumerable: true, get: function get() { return _signing.sign; } }); Object.defineProperty(exports, "verify", { enumerable: true, get: function get() { return _signing.verify; } }); Object.defineProperty(exports, "FastSigning", { enumerable: true, get: function get() { return _signing.FastSigning; } }); var _keypair = __webpack_require__(54); Object.defineProperty(exports, "Keypair", { enumerable: true, get: function get() { return _keypair.Keypair; } }); var _jsXdr = __webpack_require__(3); Object.defineProperty(exports, "UnsignedHyper", { enumerable: true, get: function get() { return _jsXdr.UnsignedHyper; } }); Object.defineProperty(exports, "Hyper", { enumerable: true, get: function get() { return _jsXdr.Hyper; } }); var _transaction = __webpack_require__(117); Object.defineProperty(exports, "Transaction", { enumerable: true, get: function get() { return _transaction.Transaction; } }); var _transaction_builder = __webpack_require__(318); Object.defineProperty(exports, "TransactionBuilder", { enumerable: true, get: function get() { return _transaction_builder.TransactionBuilder; } }); var _asset = __webpack_require__(119); Object.defineProperty(exports, "Asset", { enumerable: true, get: function get() { return _asset.Asset; } }); var _operation = __webpack_require__(118); Object.defineProperty(exports, "Operation", { enumerable: true, get: function get() { return _operation.Operation; } }); Object.defineProperty(exports, "AuthRequiredFlag", { enumerable: true, get: function get() { return _operation.AuthRequiredFlag; } }); Object.defineProperty(exports, "AuthRevocableFlag", { enumerable: true, get: function get() { return _operation.AuthRevocableFlag; } }); Object.defineProperty(exports, "AuthImmutableFlag", { enumerable: true, get: function get() { return _operation.AuthImmutableFlag; } }); var _memo = __webpack_require__(222); _defaults(exports, _interopExportWildcard(_memo, _defaults)); var _account = __webpack_require__(319); Object.defineProperty(exports, "Account", { enumerable: true, get: function get() { return _account.Account; } }); var _network = __webpack_require__(55); Object.defineProperty(exports, "Network", { enumerable: true, get: function get() { return _network.Network; } }); Object.defineProperty(exports, "Networks", { enumerable: true, get: function get() { return _network.Networks; } }); var _strkey = __webpack_require__(60); Object.defineProperty(exports, "StrKey", { enumerable: true, get: function get() { return _strkey.StrKey; } }); exports["default"] = module.exports; /***/ }), /* 2 */ /***/ (function(module, exports, __webpack_require__) { // Automatically generated on 2017-02-08T14:45:22+01:00 // DO NOT EDIT or your changes may be overwritten /* jshint maxstatements:2147483647 */ /* jshint esnext:true */"use strict";Object.defineProperty(exports,"__esModule",{value:true});function _interopRequireWildcard(obj){if(obj && obj.__esModule){return obj;}else {var newObj={};if(obj != null){for(var key in obj) {if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key] = obj[key];}}newObj["default"] = obj;return newObj;}}var _jsXdr=__webpack_require__(3);var XDR=_interopRequireWildcard(_jsXdr);var types=XDR.config(function(xdr){ // === xdr source ============================================================ // // typedef opaque Value<>; // // =========================================================================== xdr.typedef("Value",xdr.varOpaque()); // === xdr source ============================================================ // // struct SCPBallot // { // uint32 counter; // n // Value value; // x // }; // // =========================================================================== xdr.struct("ScpBallot",[["counter",xdr.lookup("Uint32")],["value",xdr.lookup("Value")]]); // === xdr source ============================================================ // // enum SCPStatementType // { // SCP_ST_PREPARE = 0, // SCP_ST_CONFIRM = 1, // SCP_ST_EXTERNALIZE = 2, // SCP_ST_NOMINATE = 3 // }; // // =========================================================================== xdr["enum"]("ScpStatementType",{scpStPrepare:0,scpStConfirm:1,scpStExternalize:2,scpStNominate:3}); // === xdr source ============================================================ // // struct SCPNomination // { // Hash quorumSetHash; // D // Value votes<>; // X // Value accepted<>; // Y // }; // // =========================================================================== xdr.struct("ScpNomination",[["quorumSetHash",xdr.lookup("Hash")],["votes",xdr.varArray(xdr.lookup("Value"),2147483647)],["accepted",xdr.varArray(xdr.lookup("Value"),2147483647)]]); // === xdr source ============================================================ // // struct // { // Hash quorumSetHash; // D // SCPBallot ballot; // b // SCPBallot* prepared; // p // SCPBallot* preparedPrime; // p' // uint32 nC; // c.n // uint32 nH; // h.n // } // // =========================================================================== xdr.struct("ScpStatementPrepare",[["quorumSetHash",xdr.lookup("Hash")],["ballot",xdr.lookup("ScpBallot")],["prepared",xdr.option(xdr.lookup("ScpBallot"))],["preparedPrime",xdr.option(xdr.lookup("ScpBallot"))],["nC",xdr.lookup("Uint32")],["nH",xdr.lookup("Uint32")]]); // === xdr source ============================================================ // // struct // { // SCPBallot ballot; // b // uint32 nPrepared; // p.n // uint32 nCommit; // c.n // uint32 nH; // h.n // Hash quorumSetHash; // D // } // // =========================================================================== xdr.struct("ScpStatementConfirm",[["ballot",xdr.lookup("ScpBallot")],["nPrepared",xdr.lookup("Uint32")],["nCommit",xdr.lookup("Uint32")],["nH",xdr.lookup("Uint32")],["quorumSetHash",xdr.lookup("Hash")]]); // === xdr source ============================================================ // // struct // { // SCPBallot commit; // c // uint32 nH; // h.n // Hash commitQuorumSetHash; // D used before EXTERNALIZE // } // // =========================================================================== xdr.struct("ScpStatementExternalize",[["commit",xdr.lookup("ScpBallot")],["nH",xdr.lookup("Uint32")],["commitQuorumSetHash",xdr.lookup("Hash")]]); // === xdr source ============================================================ // // union switch (SCPStatementType type) // { // case SCP_ST_PREPARE: // struct // { // Hash quorumSetHash; // D // SCPBallot ballot; // b // SCPBallot* prepared; // p // SCPBallot* preparedPrime; // p' // uint32 nC; // c.n // uint32 nH; // h.n // } prepare; // case SCP_ST_CONFIRM: // struct // { // SCPBallot ballot; // b // uint32 nPrepared; // p.n // uint32 nCommit; // c.n // uint32 nH; // h.n // Hash quorumSetHash; // D // } confirm; // case SCP_ST_EXTERNALIZE: // struct // { // SCPBallot commit; // c // uint32 nH; // h.n // Hash commitQuorumSetHash; // D used before EXTERNALIZE // } externalize; // case SCP_ST_NOMINATE: // SCPNomination nominate; // } // // =========================================================================== xdr.union("ScpStatementPledges",{switchOn:xdr.lookup("ScpStatementType"),switchName:"type",switches:[["scpStPrepare","prepare"],["scpStConfirm","confirm"],["scpStExternalize","externalize"],["scpStNominate","nominate"]],arms:{prepare:xdr.lookup("ScpStatementPrepare"),confirm:xdr.lookup("ScpStatementConfirm"),externalize:xdr.lookup("ScpStatementExternalize"),nominate:xdr.lookup("ScpNomination")}}); // === xdr source ============================================================ // // struct SCPStatement // { // NodeID nodeID; // v // uint64 slotIndex; // i // // union switch (SCPStatementType type) // { // case SCP_ST_PREPARE: // struct // { // Hash quorumSetHash; // D // SCPBallot ballot; // b // SCPBallot* prepared; // p // SCPBallot* preparedPrime; // p' // uint32 nC; // c.n // uint32 nH; // h.n // } prepare; // case SCP_ST_CONFIRM: // struct // { // SCPBallot ballot; // b // uint32 nPrepared; // p.n // uint32 nCommit; // c.n // uint32 nH; // h.n // Hash quorumSetHash; // D // } confirm; // case SCP_ST_EXTERNALIZE: // struct // { // SCPBallot commit; // c // uint32 nH; // h.n // Hash commitQuorumSetHash; // D used before EXTERNALIZE // } externalize; // case SCP_ST_NOMINATE: // SCPNomination nominate; // } // pledges; // }; // // =========================================================================== xdr.struct("ScpStatement",[["nodeId",xdr.lookup("NodeId")],["slotIndex",xdr.lookup("Uint64")],["pledges",xdr.lookup("ScpStatementPledges")]]); // === xdr source ============================================================ // // struct SCPEnvelope // { // SCPStatement statement; // Signature signature; // }; // // =========================================================================== xdr.struct("ScpEnvelope",[["statement",xdr.lookup("ScpStatement")],["signature",xdr.lookup("Signature")]]); // === xdr source ============================================================ // // struct SCPQuorumSet // { // uint32 threshold; // PublicKey validators<>; // SCPQuorumSet innerSets<>; // }; // // =========================================================================== xdr.struct("ScpQuorumSet",[["threshold",xdr.lookup("Uint32")],["validators",xdr.varArray(xdr.lookup("PublicKey"),2147483647)],["innerSets",xdr.varArray(xdr.lookup("ScpQuorumSet"),2147483647)]]); // === xdr source ============================================================ // // typedef PublicKey AccountID; // // =========================================================================== xdr.typedef("AccountId",xdr.lookup("PublicKey")); // === xdr source ============================================================ // // typedef opaque Thresholds[4]; // // =========================================================================== xdr.typedef("Thresholds",xdr.opaque(4)); // === xdr source ============================================================ // // typedef string string32<32>; // // =========================================================================== xdr.typedef("String32",xdr.string(32)); // === xdr source ============================================================ // // typedef string string64<64>; // // =========================================================================== xdr.typedef("String64",xdr.string(64)); // === xdr source ============================================================ // // typedef uint64 SequenceNumber; // // =========================================================================== xdr.typedef("SequenceNumber",xdr.lookup("Uint64")); // === xdr source ============================================================ // // typedef opaque DataValue<64>; // // =========================================================================== xdr.typedef("DataValue",xdr.varOpaque(64)); // === xdr source ============================================================ // // enum AssetType // { // ASSET_TYPE_NATIVE = 0, // ASSET_TYPE_CREDIT_ALPHANUM4 = 1, // ASSET_TYPE_CREDIT_ALPHANUM12 = 2 // }; // // =========================================================================== xdr["enum"]("AssetType",{assetTypeNative:0,assetTypeCreditAlphanum4:1,assetTypeCreditAlphanum12:2}); // === xdr source ============================================================ // // struct // { // opaque assetCode[4]; // 1 to 4 characters // AccountID issuer; // } // // =========================================================================== xdr.struct("AssetAlphaNum4",[["assetCode",xdr.opaque(4)],["issuer",xdr.lookup("AccountId")]]); // === xdr source ============================================================ // // struct // { // opaque assetCode[12]; // 5 to 12 characters // AccountID issuer; // } // // =========================================================================== xdr.struct("AssetAlphaNum12",[["assetCode",xdr.opaque(12)],["issuer",xdr.lookup("AccountId")]]); // === xdr source ============================================================ // // union Asset switch (AssetType type) // { // case ASSET_TYPE_NATIVE: // Not credit // void; // // case ASSET_TYPE_CREDIT_ALPHANUM4: // struct // { // opaque assetCode[4]; // 1 to 4 characters // AccountID issuer; // } alphaNum4; // // case ASSET_TYPE_CREDIT_ALPHANUM12: // struct // { // opaque assetCode[12]; // 5 to 12 characters // AccountID issuer; // } alphaNum12; // // // add other asset types here in the future // }; // // =========================================================================== xdr.union("Asset",{switchOn:xdr.lookup("AssetType"),switchName:"type",switches:[["assetTypeNative",xdr["void"]()],["assetTypeCreditAlphanum4","alphaNum4"],["assetTypeCreditAlphanum12","alphaNum12"]],arms:{alphaNum4:xdr.lookup("AssetAlphaNum4"),alphaNum12:xdr.lookup("AssetAlphaNum12")}}); // === xdr source ============================================================ // // struct Price // { // int32 n; // numerator // int32 d; // denominator // }; // // =========================================================================== xdr.struct("Price",[["n",xdr.lookup("Int32")],["d",xdr.lookup("Int32")]]); // === xdr source ============================================================ // // enum ThresholdIndexes // { // THRESHOLD_MASTER_WEIGHT = 0, // THRESHOLD_LOW = 1, // THRESHOLD_MED = 2, // THRESHOLD_HIGH = 3 // }; // // =========================================================================== xdr["enum"]("ThresholdIndices",{thresholdMasterWeight:0,thresholdLow:1,thresholdMed:2,thresholdHigh:3}); // === xdr source ============================================================ // // enum LedgerEntryType // { // ACCOUNT = 0, // TRUSTLINE = 1, // OFFER = 2, // DATA = 3 // }; // // =========================================================================== xdr["enum"]("LedgerEntryType",{account:0,trustline:1,offer:2,datum:3}); // === xdr source ============================================================ // // struct Signer // { // SignerKey key; // uint32 weight; // really only need 1byte // }; // // =========================================================================== xdr.struct("Signer",[["key",xdr.lookup("SignerKey")],["weight",xdr.lookup("Uint32")]]); // === xdr source ============================================================ // // enum AccountFlags // { // masks for each flag // // // Flags set on issuer accounts // // TrustLines are created with authorized set to "false" requiring // // the issuer to set it for each TrustLine // AUTH_REQUIRED_FLAG = 0x1, // // If set, the authorized flag in TrustLines can be cleared // // otherwise, authorization cannot be revoked // AUTH_REVOCABLE_FLAG = 0x2, // // Once set, causes all AUTH_* flags to be read-only // AUTH_IMMUTABLE_FLAG = 0x4 // }; // // =========================================================================== xdr["enum"]("AccountFlags",{authRequiredFlag:1,authRevocableFlag:2,authImmutableFlag:4}); // === xdr source ============================================================ // // union switch (int v) // { // case 0: // void; // } // // =========================================================================== xdr.union("AccountEntryExt",{switchOn:xdr.int(),switchName:"v",switches:[[0,xdr["void"]()]],arms:{}}); // === xdr source ============================================================ // // struct AccountEntry // { // AccountID accountID; // master public key for this account // int64 balance; // in stroops // SequenceNumber seqNum; // last sequence number used for this account // uint32 numSubEntries; // number of sub-entries this account has // // drives the reserve // AccountID* inflationDest; // Account to vote for during inflation // uint32 flags; // see AccountFlags // // string32 homeDomain; // can be used for reverse federation and memo lookup // // // fields used for signatures // // thresholds stores unsigned bytes: [weight of master|low|medium|high] // Thresholds thresholds; // // Signer signers<20>; // possible signers for this account // // // reserved for future use // union switch (int v) // { // case 0: // void; // } // ext; // }; // // =========================================================================== xdr.struct("AccountEntry",[["accountId",xdr.lookup("AccountId")],["balance",xdr.lookup("Int64")],["seqNum",xdr.lookup("SequenceNumber")],["numSubEntries",xdr.lookup("Uint32")],["inflationDest",xdr.option(xdr.lookup("AccountId"))],["flags",xdr.lookup("Uint32")],["homeDomain",xdr.lookup("String32")],["thresholds",xdr.lookup("Thresholds")],["signers",xdr.varArray(xdr.lookup("Signer"),20)],["ext",xdr.lookup("AccountEntryExt")]]); // === xdr source ============================================================ // // enum TrustLineFlags // { // // issuer has authorized account to perform transactions with its credit // AUTHORIZED_FLAG = 1 // }; // // =========================================================================== xdr["enum"]("TrustLineFlags",{authorizedFlag:1}); // === xdr source ============================================================ // // union switch (int v) // { // case 0: // void; // } // // =========================================================================== xdr.union("TrustLineEntryExt",{switchOn:xdr.int(),switchName:"v",switches:[[0,xdr["void"]()]],arms:{}}); // === xdr source ============================================================ // // struct TrustLineEntry // { // AccountID accountID; // account this trustline belongs to // Asset asset; // type of asset (with issuer) // int64 balance; // how much of this asset the user has. // // Asset defines the unit for this; // // int64 limit; // balance cannot be above this // uint32 flags; // see TrustLineFlags // // // reserved for future use // union switch (int v) // { // case 0: // void; // } // ext; // }; // // =========================================================================== xdr.struct("TrustLineEntry",[["accountId",xdr.lookup("AccountId")],["asset",xdr.lookup("Asset")],["balance",xdr.lookup("Int64")],["limit",xdr.lookup("Int64")],["flags",xdr.lookup("Uint32")],["ext",xdr.lookup("TrustLineEntryExt")]]); // === xdr source ============================================================ // // enum OfferEntryFlags // { // // issuer has authorized account to perform transactions with its credit // PASSIVE_FLAG = 1 // }; // // =========================================================================== xdr["enum"]("OfferEntryFlags",{passiveFlag:1}); // === xdr source ============================================================ // // union switch (int v) // { // case 0: // void; // } // // =========================================================================== xdr.union("OfferEntryExt",{switchOn:xdr.int(),switchName:"v",switches:[[0,xdr["void"]()]],arms:{}}); // === xdr source ============================================================ // // struct OfferEntry // { // AccountID sellerID; // uint64 offerID; // Asset selling; // A // Asset buying; // B // int64 amount; // amount of A // // /* price for this offer: // price of A in terms of B // price=AmountB/AmountA=priceNumerator/priceDenominator // price is after fees // */ // Price price; // uint32 flags; // see OfferEntryFlags // // // reserved for future use // union switch (int v) // { // case 0: // void; // } // ext; // }; // // =========================================================================== xdr.struct("OfferEntry",[["sellerId",xdr.lookup("AccountId")],["offerId",xdr.lookup("Uint64")],["selling",xdr.lookup("Asset")],["buying",xdr.lookup("Asset")],["amount",xdr.lookup("Int64")],["price",xdr.lookup("Price")],["flags",xdr.lookup("Uint32")],["ext",xdr.lookup("OfferEntryExt")]]); // === xdr source ============================================================ // // union switch (int v) // { // case 0: // void; // } // // =========================================================================== xdr.union("DataEntryExt",{switchOn:xdr.int(),switchName:"v",switches:[[0,xdr["void"]()]],arms:{}}); // === xdr source ============================================================ // // struct DataEntry // { // AccountID accountID; // account this data belongs to // string64 dataName; // DataValue dataValue; // // // reserved for future use // union switch (int v) // { // case 0: // void; // } // ext; // }; // // =========================================================================== xdr.struct("DataEntry",[["accountId",xdr.lookup("AccountId")],["dataName",xdr.lookup("String64")],["dataValue",xdr.lookup("DataValue")],["ext",xdr.lookup("DataEntryExt")]]); // === xdr source ============================================================ // // union switch (LedgerEntryType type) // { // case ACCOUNT: // AccountEntry account; // case TRUSTLINE: // TrustLineEntry trustLine; // case OFFER: // OfferEntry offer; // case DATA: // DataEntry data; // } // // =========================================================================== xdr.union("LedgerEntryData",{switchOn:xdr.lookup("LedgerEntryType"),switchName:"type",switches:[["account","account"],["trustline","trustLine"],["offer","offer"],["datum","data"]],arms:{account:xdr.lookup("AccountEntry"),trustLine:xdr.lookup("TrustLineEntry"),offer:xdr.lookup("OfferEntry"),data:xdr.lookup("DataEntry")}}); // === xdr source ============================================================ // // union switch (int v) // { // case 0: // void; // } // // =========================================================================== xdr.union("LedgerEntryExt",{switchOn:xdr.int(),switchName:"v",switches:[[0,xdr["void"]()]],arms:{}}); // === xdr source ============================================================ // // struct LedgerEntry // { // uint32 lastModifiedLedgerSeq; // ledger the LedgerEntry was last changed // // union switch (LedgerEntryType type) // { // case ACCOUNT: // AccountEntry account; // case TRUSTLINE: // TrustLineEntry trustLine; // case OFFER: // OfferEntry offer; // case DATA: // DataEntry data; // } // data; // // // reserved for future use // union switch (int v) // { // case 0: // void; // } // ext; // }; // // =========================================================================== xdr.struct("LedgerEntry",[["lastModifiedLedgerSeq",xdr.lookup("Uint32")],["data",xdr.lookup("LedgerEntryData")],["ext",xdr.lookup("LedgerEntryExt")]]); // === xdr source ============================================================ // // enum EnvelopeType // { // ENVELOPE_TYPE_SCP = 1, // ENVELOPE_TYPE_TX = 2, // ENVELOPE_TYPE_AUTH = 3 // }; // // =========================================================================== xdr["enum"]("EnvelopeType",{envelopeTypeScp:1,envelopeTypeTx:2,envelopeTypeAuth:3}); // === xdr source ============================================================ // // typedef opaque UpgradeType<128>; // // =========================================================================== xdr.typedef("UpgradeType",xdr.varOpaque(128)); // === xdr source ============================================================ // // union switch (int v) // { // case 0: // void; // } // // =========================================================================== xdr.union("StellarValueExt",{switchOn:xdr.int(),switchName:"v",switches:[[0,xdr["void"]()]],arms:{}}); // === xdr source ============================================================ // // struct StellarValue // { // Hash txSetHash; // transaction set to apply to previous ledger // uint64 closeTime; // network close time // // // upgrades to apply to the previous ledger (usually empty) // // this is a vector of encoded 'LedgerUpgrade' so that nodes can drop // // unknown steps during consensus if needed. // // see notes below on 'LedgerUpgrade' for more detail // // max size is dictated by number of upgrade types (+ room for future) // UpgradeType upgrades<6>; // // // reserved for future use // union switch (int v) // { // case 0: // void; // } // ext; // }; // // =========================================================================== xdr.struct("StellarValue",[["txSetHash",xdr.lookup("Hash")],["closeTime",xdr.lookup("Uint64")],["upgrades",xdr.varArray(xdr.lookup("UpgradeType"),6)],["ext",xdr.lookup("StellarValueExt")]]); // === xdr source ============================================================ // // union switch (int v) // { // case 0: // void; // } // // =========================================================================== xdr.union("LedgerHeaderExt",{switchOn:xdr.int(),switchName:"v",switches:[[0,xdr["void"]()]],arms:{}}); // === xdr source ============================================================ // // struct LedgerHeader // { // uint32 ledgerVersion; // the protocol version of the ledger // Hash previousLedgerHash; // hash of the previous ledger header // StellarValue scpValue; // what consensus agreed to // Hash txSetResultHash; // the TransactionResultSet that led to this ledger // Hash bucketListHash; // hash of the ledger state // // uint32 ledgerSeq; // sequence number of this ledger // // int64 totalCoins; // total number of stroops in existence. // // 10,000,000 stroops in 1 RIA // // int64 feePool; // fees burned since last inflation run // uint32 inflationSeq; // inflation sequence number // // uint64 idPool; // last used global ID, used for generating objects // // uint32 baseFee; // base fee per operation in stroops // uint32 baseReserve; // account base reserve in stroops // // uint32 maxTxSetSize; // maximum size a transaction set can be // // Hash skipList[4]; // hashes of ledgers in the past. allows you to jump back // // in time without walking the chain back ledger by ledger // // each slot contains the oldest ledger that is mod of // // either 50 5000 50000 or 500000 depending on index // // skipList[0] mod(50), skipList[1] mod(5000), etc // // // reserved for future use // union switch (int v) // { // case 0: // void; // } // ext; // }; // // =========================================================================== xdr.struct("LedgerHeader",[["ledgerVersion",xdr.lookup("Uint32")],["previousLedgerHash",xdr.lookup("Hash")],["scpValue",xdr.lookup("StellarValue")],["txSetResultHash",xdr.lookup("Hash")],["bucketListHash",xdr.lookup("Hash")],["ledgerSeq",xdr.lookup("Uint32")],["totalCoins",xdr.lookup("Int64")],["feePool",xdr.lookup("Int64")],["inflationSeq",xdr.lookup("Uint32")],["idPool",xdr.lookup("Uint64")],["baseFee",xdr.lookup("Uint32")],["baseReserve",xdr.lookup("Uint32")],["maxTxSetSize",xdr.lookup("Uint32")],["skipList",xdr.array(xdr.lookup("Hash"),4)],["ext",xdr.lookup("LedgerHeaderExt")]]); // === xdr source ============================================================ // // enum LedgerUpgradeType // { // LEDGER_UPGRADE_VERSION = 1, // LEDGER_UPGRADE_BASE_FEE = 2, // LEDGER_UPGRADE_MAX_TX_SET_SIZE = 3 // }; // // =========================================================================== xdr["enum"]("LedgerUpgradeType",{ledgerUpgradeVersion:1,ledgerUpgradeBaseFee:2,ledgerUpgradeMaxTxSetSize:3}); // === xdr source ============================================================ // // union LedgerUpgrade switch (LedgerUpgradeType type) // { // case LEDGER_UPGRADE_VERSION: // uint32 newLedgerVersion; // update ledgerVersion // case LEDGER_UPGRADE_BASE_FEE: // uint32 newBaseFee; // update baseFee // case LEDGER_UPGRADE_MAX_TX_SET_SIZE: // uint32 newMaxTxSetSize; // update maxTxSetSize // }; // // =========================================================================== xdr.union("LedgerUpgrade",{switchOn:xdr.lookup("LedgerUpgradeType"),switchName:"type",switches:[["ledgerUpgradeVersion","newLedgerVersion"],["ledgerUpgradeBaseFee","newBaseFee"],["ledgerUpgradeMaxTxSetSize","newMaxTxSetSize"]],arms:{newLedgerVersion:xdr.lookup("Uint32"),newBaseFee:xdr.lookup("Uint32"),newMaxTxSetSize:xdr.lookup("Uint32")}}); // === xdr source ============================================================ // // struct // { // AccountID accountID; // } // // =========================================================================== xdr.struct("LedgerKeyAccount",[["accountId",xdr.lookup("AccountId")]]); // === xdr source ============================================================ // // struct // { // AccountID accountID; // Asset asset; // } // // =========================================================================== xdr.struct("LedgerKeyTrustLine",[["accountId",xdr.lookup("AccountId")],["asset",xdr.lookup("Asset")]]); // === xdr source ============================================================ // // struct // { // AccountID sellerID; // uint64 offerID; // } // // =========================================================================== xdr.struct("LedgerKeyOffer",[["sellerId",xdr.lookup("AccountId")],["offerId",xdr.lookup("Uint64")]]); // === xdr source ============================================================ // // struct // { // AccountID accountID; // string64 dataName; // } // // =========================================================================== xdr.struct("LedgerKeyData",[["accountId",xdr.lookup("AccountId")],["dataName",xdr.lookup("String64")]]); // === xdr source ============================================================ // // union LedgerKey switch (LedgerEntryType type) // { // case ACCOUNT: // struct // { // AccountID accountID; // } account; // // case TRUSTLINE: // struct // { // AccountID accountID; // Asset asset; // } trustLine; // // case OFFER: // struct // { // AccountID sellerID; // uint64 offerID; // } offer; // // case DATA: // struct // { // AccountID accountID; // string64 dataName; // } data; // }; // // =========================================================================== xdr.union("LedgerKey",{switchOn:xdr.lookup("LedgerEntryType"),switchName:"type",switches:[["account","account"],["trustline","trustLine"],["offer","offer"],["datum","data"]],arms:{account:xdr.lookup("LedgerKeyAccount"),trustLine:xdr.lookup("LedgerKeyTrustLine"),offer:xdr.lookup("LedgerKeyOffer"),data:xdr.lookup("LedgerKeyData")}}); // === xdr source ============================================================ // // enum BucketEntryType // { // LIVEENTRY = 0, // DEADENTRY = 1 // }; // // =========================================================================== xdr["enum"]("BucketEntryType",{liveentry:0,deadentry:1}); // === xdr source ============================================================ // // union BucketEntry switch (BucketEntryType type) // { // case LIVEENTRY: // LedgerEntry liveEntry; // // case DEADENTRY: // LedgerKey deadEntry; // }; // // =========================================================================== xdr.union("BucketEntry",{switchOn:xdr.lookup("BucketEntryType"),switchName:"type",switches:[["liveentry","liveEntry"],["deadentry","deadEntry"]],arms:{liveEntry:xdr.lookup("LedgerEntry"),deadEntry:xdr.lookup("LedgerKey")}}); // === xdr source ============================================================ // // struct TransactionSet // { // Hash previousLedgerHash; // TransactionEnvelope txs<>; // }; // // =========================================================================== xdr.struct("TransactionSet",[["previousLedgerHash",xdr.lookup("Hash")],["txes",xdr.varArray(xdr.lookup("TransactionEnvelope"),2147483647)]]); // === xdr source ============================================================ // // struct TransactionResultPair // { // Hash transactionHash; // TransactionResult result; // result for the transaction // }; // // =========================================================================== xdr.struct("TransactionResultPair",[["transactionHash",xdr.lookup("Hash")],["result",xdr.lookup("TransactionResult")]]); // === xdr source ============================================================ // // struct TransactionResultSet // { // TransactionResultPair results<>; // }; // // =========================================================================== xdr.struct("TransactionResultSet",[["results",xdr.varArray(xdr.lookup("TransactionResultPair"),2147483647)]]); // === xdr source ============================================================ // // union switch (int v) // { // case 0: // void; // } // // =========================================================================== xdr.union("TransactionHistoryEntryExt",{switchOn:xdr.int(),switchName:"v",switches:[[0,xdr["void"]()]],arms:{}}); // === xdr source ============================================================ // // struct TransactionHistoryEntry // { // uint32 ledgerSeq; // TransactionSet txSet; // // // reserved for future use // union switch (int v) // { // case 0: // void; // } // ext; // }; // // =========================================================================== xdr.struct("TransactionHistoryEntry",[["ledgerSeq",xdr.lookup("Uint32")],["txSet",xdr.lookup("TransactionSet")],["ext",xdr.lookup("TransactionHistoryEntryExt")]]); // === xdr source ============================================================ // // union switch (int v) // { // case 0: // void; // } // // =========================================================================== xdr.union("TransactionHistoryResultEntryExt",{switchOn:xdr.int(),switchName:"v",switches:[[0,xdr["void"]()]],arms:{}}); // === xdr source ============================================================ // // struct TransactionHistoryResultEntry // { // uint32 ledgerSeq; // TransactionResultSet txResultSet; // // // reserved for future use // union switch (int v) // { // case 0: // void; // } // ext; // }; // // =========================================================================== xdr.struct("TransactionHistoryResultEntry",[["ledgerSeq",xdr.lookup("Uint32")],["txResultSet",xdr.lookup("TransactionResultSet")],["ext",xdr.lookup("TransactionHistoryResultEntryExt")]]); // === xdr source ============================================================ // // union switch (int v) // { // case 0: // void; // } // // =========================================================================== xdr.union("LedgerHeaderHistoryEntryExt",{switchOn:xdr.int(),switchName:"v",switches:[[0,xdr["void"]()]],arms:{}}); // === xdr source ============================================================ // // struct LedgerHeaderHistoryEntry // { // Hash hash; // LedgerHeader header; // // // reserved for future use // union switch (int v) // { // case 0: // void; // } // ext; // }; // // =========================================================================== xdr.struct("LedgerHeaderHistoryEntry",[["hash",xdr.lookup("Hash")],["header",xdr.lookup("LedgerHeader")],["ext",xdr.lookup("LedgerHeaderHistoryEntryExt")]]); // === xdr source ============================================================ // // struct LedgerSCPMessages // { // uint32 ledgerSeq; // SCPEnvelope messages<>; // }; // // =========================================================================== xdr.struct("LedgerScpMessages",[["ledgerSeq",xdr.lookup("Uint32")],["messages",xdr.varArray(xdr.lookup("ScpEnvelope"),2147483647)]]); // === xdr source ============================================================ // // struct SCPHistoryEntryV0 // { // SCPQuorumSet quorumSets<>; // additional quorum sets used by ledgerMessages // LedgerSCPMessages ledgerMessages; // }; // // =========================================================================== xdr.struct("ScpHistoryEntryV0",[["quorumSets",xdr.varArray(xdr.lookup("ScpQuorumSet"),2147483647)],["ledgerMessages",xdr.lookup("LedgerScpMessages")]]); // === xdr source ============================================================ // // union SCPHistoryEntry switch (int v) // { // case 0: // SCPHistoryEntryV0 v0; // }; // // =========================================================================== xdr.union("ScpHistoryEntry",{switchOn:xdr.int(),switchName:"v",switches:[[0,"v0"]],arms:{v0:xdr.lookup("ScpHistoryEntryV0")}}); // === xdr source ============================================================ // // enum LedgerEntryChangeType // { // LEDGER_ENTRY_CREATED = 0, // entry was added to the ledger // LEDGER_ENTRY_UPDATED = 1, // entry was modified in the ledger // LEDGER_ENTRY_REMOVED = 2, // entry was removed from the ledger // LEDGER_ENTRY_STATE = 3 // value of the entry // }; // // =========================================================================== xdr["enum"]("LedgerEntryChangeType",{ledgerEntryCreated:0,ledgerEntryUpdated:1,ledgerEntryRemoved:2,ledgerEntryState:3}); // === xdr source ============================================================ // // union LedgerEntryChange switch (LedgerEntryChangeType type) // { // case LEDGER_ENTRY_CREATED: // LedgerEntry created; // case LEDGER_ENTRY_UPDATED: // LedgerEntry updated; // case LEDGER_ENTRY_REMOVED: // LedgerKey removed; // case LEDGER_ENTRY_STATE: // LedgerEntry state; // }; // // =========================================================================== xdr.union("LedgerEntryChange",{switchOn:xdr.lookup("LedgerEntryChangeType"),switchName:"type",switches:[["ledgerEntryCreated","created"],["ledgerEntryUpdated","updated"],["ledgerEntryRemoved","removed"],["ledgerEntryState","state"]],arms:{created:xdr.lookup("LedgerEntry"),updated:xdr.lookup("LedgerEntry"),removed:xdr.lookup("LedgerKey"),state:xdr.lookup("LedgerEntry")}}); // === xdr source ============================================================ // // typedef LedgerEntryChange LedgerEntryChanges<>; // // =========================================================================== xdr.typedef("LedgerEntryChanges",xdr.varArray(xdr.lookup("LedgerEntryChange"),2147483647)); // === xdr source ============================================================ // // struct OperationMeta // { // LedgerEntryChanges changes; // }; // // =========================================================================== xdr.struct("OperationMeta",[["changes",xdr.lookup("LedgerEntryChanges")]]); // === xdr source ============================================================ // // union TransactionMeta switch (int v) // { // case 0: // OperationMeta operations<>; // }; // // =========================================================================== xdr.union("TransactionMeta",{switchOn:xdr.int(),switchName:"v",switches:[[0,"operations"]],arms:{operations:xdr.varArray(xdr.lookup("OperationMeta"),2147483647)}}); // === xdr source ============================================================ // // enum ErrorCode // { // ERR_MISC = 0, // Unspecific error // ERR_DATA = 1, // Malformed data // ERR_CONF = 2, // Misconfiguration error // ERR_AUTH = 3, // Authentication failure // ERR_LOAD = 4 // System overloaded // }; // // =========================================================================== xdr["enum"]("ErrorCode",{errMisc:0,errDatum:1,errConf:2,errAuth:3,errLoad:4}); // === xdr source ============================================================ // // struct Error // { // ErrorCode code; // string msg<100>; // }; // // =========================================================================== xdr.struct("Error",[["code",xdr.lookup("ErrorCode")],["msg",xdr.string(100)]]); // === xdr source ============================================================ // // struct AuthCert // { // Curve25519Public pubkey; // uint64 expiration; // Signature sig; // }; // // =========================================================================== xdr.struct("AuthCert",[["pubkey",xdr.lookup("Curve25519Public")],["expiration",xdr.lookup("Uint64")],["sig",xdr.lookup("Signature")]]); // === xdr source ============================================================ // // struct Hello // { // uint32 ledgerVersion; // uint32 overlayVersion; // uint32 overlayMinVersion; // Hash networkID; // string versionStr<100>; // int listeningPort; // NodeID peerID; // AuthCert cert; // uint256 nonce; // }; // // =========================================================================== xdr.struct("Hello",[["ledgerVersion",xdr.lookup("Uint32")],["overlayVersion",xdr.lookup("Uint32")],["overlayMinVersion",xdr.lookup("Uint32")],["networkId",xdr.lookup("Hash")],["versionStr",xdr.string(100)],["listeningPort",xdr.int()],["peerId",xdr.lookup("NodeId")],["cert",xdr.lookup("AuthCert")],["nonce",xdr.lookup("Uint256")]]); // === xdr source ============================================================ // // struct Auth // { // // Empty message, just to confirm // // establishment of MAC keys. // int unused; // }; // // =========================================================================== xdr.struct("Auth",[["unused",xdr.int()]]); // === xdr source ============================================================ // // enum IPAddrType // { // IPv4 = 0, // IPv6 = 1 // }; // // =========================================================================== xdr["enum"]("IpAddrType",{iPv4:0,iPv6:1}); // === xdr source ============================================================ // // union switch (IPAddrType type) // { // case IPv4: // opaque ipv4[4]; // case IPv6: // opaque ipv6[16]; // } // // =========================================================================== xdr.union("PeerAddressIp",{switchOn:xdr.lookup("IpAddrType"),switchName:"type",switches:[["iPv4","ipv4"],["iPv6","ipv6"]],arms:{ipv4:xdr.opaque(4),ipv6:xdr.opaque(16)}}); // === xdr source ============================================================ // // struct PeerAddress // { // union switch (IPAddrType type) // { // case IPv4: // opaque ipv4[4]; // case IPv6: // opaque ipv6[16]; // } // ip; // uint32 port; // uint32 numFailures; // }; // // =========================================================================== xdr.struct("PeerAddress",[["ip",xdr.lookup("PeerAddressIp")],["port",xdr.lookup("Uint32")],["numFailures",xdr.lookup("Uint32")]]); // === xdr source ============================================================ // // enum MessageType // { // ERROR_MS