This commit is contained in:
nitowa
2023-08-15 22:28:03 +02:00
commit 1dae68b1c7
5529 changed files with 1659171 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
/* eslint-disable no-var, no-param-reassign */
/* these eslint rules are disabled because gulp does not support babel yet */
'use strict'
var gulp = require('gulp')
var webpack = require('webpack-stream')
var uglify = require('gulp-uglify')
var rename = require('gulp-rename')
var pkg = require('./package.json')
var name = 'ripple-transaction-parser-' + pkg.version
gulp.task('build', function() {
return gulp.src('./src/index.js')
.pipe(webpack({
output: {
library: 'rippleTransactionParser',
filename: name + '.js'
}
}))
.pipe(gulp.dest('./dist/web/'))
})
gulp.task('build-min', ['build'], function() {
return gulp.src('./dist/web/' + name + '.js')
.pipe(uglify())
.pipe(rename(name + '.min.js'))
.pipe(gulp.dest('./dist/web/'))
})
gulp.task('default', ['build-min'])
+110
View File
@@ -0,0 +1,110 @@
ripple-lib-transactionparser
----------------------------
[![NPM](https://nodei.co/npm/ripple-lib-transactionparser.png)](https://www.npmjs.org/package/ripple-lib-transactionparser)
Parses transaction objects to a higher-level view.
### parseBalanceChanges(metadata)
Takes a transaction metadata object (as returned by a ripple-lib response) and computes the balance changes that were caused by that transaction.
The return value is a javascript object in the following format:
```javascript
{ RIPPLEADDRESS: [BALANCECHANGE, ...], ... }
```
where `BALANCECHANGE` is a javascript object in the following format:
```javascript
{
counterparty: RIPPLEADDRESS,
currency: CURRENCYSTRING,
value: DECIMALSTRING
}
```
The keys in this object are the Ripple [addresses](https://wiki.ripple.com/Accounts) whose balances have changed and the values are arrays of objects that represent the balance changes. Each balance change has a counterparty, which is the opposite party on the trustline, except for XRP, where the counterparty is set to the empty string.
The `CURRENCYSTRING` is 'XRP' for XRP, a 3-letter ISO currency code, or a 160-bit hex string in the [Currency format](https://wiki.ripple.com/Currency_format).
### parseOrderbookChanges(metadata)
Takes a transaction metadata object and computes the changes in the order book caused by the transaction. Changes in the orderbook are analogous to changes in [`Offer` entries](https://wiki.ripple.com/Ledger_Format#Offer) in the ledger.
The return value is a javascript object in the following format:
```javascript
{ RIPPLEADDRESS: [ORDERCHANGE, ...], ... }
```
where `ORDERCHANGE` is a javascript object with the following format:
```javascript
{
direction: 'buy' | 'sell',
quantity: {
currency: CURRENCYSTRING,
counterparty: RIPPLEADDRESS, (omitted if currency is 'XRP')
value: DECIMALSTRING
},
totalPrice: {
currency: CURRENCYSTRING,
counterparty: RIPPLEADDRESS, (omitted if currency is 'XRP')
value: DECIMALSTRING
},
makerExchangeRate: DECIMALSTRING,
sequence: SEQUENCE,
status: ORDER_STATUS,
expirationTime: EXPIRATION_TIME (omitted if there is no expiration time)
}
```
The keys in this object are the Ripple [addresses](https://wiki.ripple.com/Accounts) whose orders have changed and the values are arrays of objects that represent the order changes.
The `SEQUENCE` is the sequence number of the transaction that created that create the orderbook change. (See: https://wiki.ripple.com/Ledger_Format#Offer)
The `CURRENCYSTRING` is 'XRP' for XRP, a 3-letter ISO currency code, or a 160-bit hex string in the [Currency format](https://wiki.ripple.com/Currency_format).
The `makerExchangeRate` field provides the original value of the ratio of what the taker pays over what the taker gets (also known as the "quality").
The `ORDER_STATUS` is a string that represents the status of the order in the ledger:
* `"created"`: The transaction created the order. The values of `quantity` and `totalPrice` represent the values of the order.
* `"partially-filled"`: The transaction modified the order (i.e., the order was partially consumed). The values of `quantity` and `totalPrice` represent the absolute value of change in value of the order.
* `"filled"`: The transaction consumed the order. The values of `quantity` and `totalPrice` represent the absolute value of change in value of the order.
* `"cancelled"`: The transaction canceled the order. The values of `quantity` and `totalPrice` are the values of the order prior to cancellation.
The `EXPIRATION_TIME` is an ISO 8601 timestamp representing the time at which the order expires (if there is an expiration time).
### parseChannelChanges(metadata)
Takes a PayChannel metadata object and computes the changes to the payment channel caused by the transaction. It also returns additional details about the payment channel.
The return value is a JavaScript object in the following format:
```javascript
{
status: 'created' | 'modified' | 'deleted',
channelId: HEX_STRING,
source: RIPPLE_ADDRESS,
destination: RIPPLE_ADDRESS,
channelAmountDrops: INTEGER_STRING,
channelBalanceDrops: INTEGER_STRING,
channelAmountChangeDrops?: INTEGER_STRING,
channelBalanceChangeDrops?: INTEGER_STRING,
previousTxnId?: TX_HASH_HEX_STRING
}
```
* `channelId` indicates the Channel ID, which is necessary to sign claims.
* `source` owns this payment channel. This comes from the sending address of the transaction that created the channel.
* `destination` is the only address that can receive XRP from the channel. This comes from the Destination field of the transaction that created the channel.
* `channelAmountDrops` is the amount of XRP drops that has been allocated to this channel. This includes XRP that has been paid to the destination address. This is initially set by the transaction that created the channel and can be increased if the source address sends a PaymentChannelFund transaction.
* `channelBalanceDrops` is the total XRP, in drops, already paid out by the channel. The difference between this value and the Amount is how much XRP can still be paid tot he destination address with PaymentChannelClaim transactions. If the channel closes, the remaining difference is returned to the source address.
* `channelAmountChangeDrops` is the change in the amount of XRP drops allocated to this channel. This is positive for a PaymentChannelFund transaction. Optional; may be omitted.
* `channelBalanceChangeDrops` is the change in the amount of XRP drops already paid out by the channel. Optional; may be omitted.
* `previousTxnId` is the previous transaction that affected this payment channel object. Optional; may be omitted.
+13
View File
@@ -0,0 +1,13 @@
#!/bin/bash -ex
lint() {
echo "eslint $(node_modules/.bin/eslint --version)"
#npm list babel-eslint | grep babel-eslint
REPO_URL="https://raw.githubusercontent.com/ripple/javascript-style-guide"
curl "$REPO_URL/es6/eslintrc" | grep -v "no-var" > ./eslintrc
#echo "parser: babel-eslint" >> ./eslintrc
node_modules/.bin/eslint --no-eslintrc -c ./eslintrc $(git --no-pager diff --name-only -M100% --diff-filter=AM --relative $(git merge-base FETCH_HEAD origin/HEAD) FETCH_HEAD | grep "\.js$")
}
lint
npm test
+195
View File
@@ -0,0 +1,195 @@
# ESLint documentation can be found at http://eslint.org/docs/
env:
browser: true
node: true
amd: false
mocha: true
jasmine: false
es6: true
rules:
no-alert: 2
no-array-constructor: 2
no-arrow-condition: 0
no-bitwise: 0
no-caller: 2
no-case-declarations: 2
no-catch-shadow: 2
no-class-assign: 2
no-cond-assign: [2, 'always']
no-console: 0
no-const-assign: 2
no-constant-condition: 2
no-continue: 0
no-control-regex: 2
no-debugger: 2
no-delete-var: 2
no-div-regex: 0
no-dupe-class-members: 2
no-dupe-keys: 2
no-dupe-args: 2
no-duplicate-case: 2
no-else-return: 0
no-empty: 2
no-empty-character-class: 2
no-empty-pattern: 2
no-eq-null: 2
no-eval: 2
no-ex-assign: 2
no-extend-native: 2
no-extra-bind: 2
no-extra-boolean-cast: 2
no-extra-parens: [2, 'functions']
no-extra-semi: 2
no-fallthrough: 2
no-floating-decimal: 0
no-func-assign: 2
no-implicit-coercion: 2
no-implied-eval: 2
no-inline-comments: 0
no-inner-declarations: [2, 'functions']
no-invalid-regexp: 2
no-invalid-this: 0 # this rule would cause problems with mocha test cases
no-irregular-whitespace: 2
no-iterator: 2
no-label-var: 2
no-labels: 2
no-lone-blocks: 2
no-lonely-if: 2
no-loop-func: 2
no-mixed-requires: [0, false]
no-mixed-spaces-and-tabs: [2, false]
linebreak-style: [2, 'unix']
no-multi-spaces: 2
no-multi-str: 2
no-multiple-empty-lines: [2, {max: 2}]
no-native-reassign: 2
no-negated-condition: 0
no-negated-in-lhs: 2
no-nested-ternary: 0
no-new: 2
no-new-func: 2
no-new-object: 2
no-new-require: 0
no-new-wrappers: 2
no-obj-calls: 2
no-octal: 2
no-octal-escape: 2
no-param-reassign: 2
no-path-concat: 0
no-plusplus: 0
no-process-env: 0
no-process-exit: 0
no-proto: 2
no-redeclare: 2
no-regex-spaces: 2
no-restricted-modules: 0
no-restricted-syntax: 0
no-return-assign: 2
no-script-url: 2
no-self-compare: 2
no-sequences: 2
no-shadow: 2
no-shadow-restricted-names: 2
no-spaced-func: 2
no-sparse-arrays: 2
no-sync: 0
no-ternary: 0
no-trailing-spaces: 2
no-this-before-super: 2
no-throw-literal: 2
no-undef: 2
no-undef-init: 2
no-undefined: 0
no-unexpected-multiline: 2
no-underscore-dangle: 0
no-unneeded-ternary: 0
no-unreachable: 2
no-unused-expressions: 2
no-unused-vars: [2, {vars: 'all', args: 'all', argsIgnorePattern: '^_'}]
no-use-before-define: 2
no-useless-call: 2
no-useless-concat: 0
no-void: 2
no-warning-comments: [0, {terms: ['todo', 'fixme', 'xxx'], location: 'start'}]
no-with: 2
no-magic-numbers: 0
array-bracket-spacing: [2, 'never']
arrow-body-style: 0
arrow-parens: [2, 'as-needed']
arrow-spacing: 2
accessor-pairs: 2
block-scoped-var: 2
block-spacing: 2
brace-style: 2
callback-return: 0
camelcase: 0
comma-dangle: 2
comma-spacing: 2
comma-style: 2
complexity: [0, 11]
computed-property-spacing: 2
consistent-return: 2
consistent-this: [2, 'self']
constructor-super: 2
curly: [2, 'all']
default-case: 0
dot-location: [2, 'property']
dot-notation: [2, {allowKeywords: true}]
eol-last: 2
eqeqeq: 2
func-names: 0
func-style: [2, 'declaration', {"allowArrowFunctions": true}]
generator-star-spacing: 2
global-require: 0
guard-for-in: 0
handle-callback-err: 2
id-length: 0
indent: [2, 2, {SwitchCase: 1}]
init-declarations: 0
jsx-quotes: 0
key-spacing: [2, {beforeColon: false, afterColon: true}]
keyword-spacing: 2
lines-around-comment: 0
max-depth: [0, 4]
max-len: [2, 96]
max-nested-callbacks: [0, 2]
max-params: [0, 4]
max-statements: [0, 10]
new-cap: 2
new-parens: 2
newline-after-var: 0
object-curly-spacing: [2, 'never']
object-shorthand: 0
one-var: [2, 'never']
operator-assignment: [0, 'always']
operator-linebreak: 0
padded-blocks: 0
prefer-arrow-callback: 0
prefer-const: 2
prefer-spread: 2
prefer-reflect: 0
prefer-template: 0
quote-props: 0
quotes: [2, 'single']
radix: 2
id-match: 0
require-jsdoc: 0
require-yield: 0
semi: [2, 'never']
semi-spacing: 2
sort-vars: 0
space-before-blocks: 2
space-before-function-paren: [2, 'never']
space-in-parens: 2
space-infix-ops: 2
space-unary-ops: [2, {words: true, nonwords: false}]
spaced-comment: 2
strict: [2, 'global']
use-isnan: 2
valid-jsdoc: 2
valid-typeof: 2
vars-on-top: 0
wrap-iife: 0
wrap-regex: 0
yoda: [2, 'never']
+35
View File
@@ -0,0 +1,35 @@
{
"name": "ripple-lib-transactionparser",
"version": "0.8.2",
"description": "Parses transaction objects to a higher-level view",
"license": "ISC",
"scripts": {
"test": "NODE_ENV=test ./node_modules/.bin/istanbul test ./node_modules/.bin/_mocha -- --reporter spec test/*-test.js",
"coveralls": "cat ./coverage/lcov.info | ./node_modules/.bin/coveralls",
"lint": "./node_modules/.bin/eslint -c ./eslintrc Gulpfile.js '**/*.js'"
},
"repository": {
"type": "git",
"url": "https://github.com/ripple/ripple-lib-extensions.git"
},
"main": "src/index.js",
"keywords": [
"ripple",
"ripple-lib",
"ripple-lib-transactionparser"
],
"dependencies": {
"bignumber.js": "^9.0.0",
"lodash": "^4.17.15"
},
"devDependencies": {
"assert-diff": "*",
"coveralls": "^3.0.9",
"eslint": "6.1.0",
"gulp": "^4.0.2",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^3.0.2",
"istanbul": "^0.4.5",
"mocha": "*"
}
}
+135
View File
@@ -0,0 +1,135 @@
'use strict'
var _ = require('lodash')
var BigNumber = require('bignumber.js')
var normalizeNodes = require('./utils').normalizeNodes
var dropsToXRP = require('./utils').dropsToXRP
function groupByAddress(balanceChanges) {
var grouped = _.groupBy(balanceChanges, function(node) {
return node.address
})
return _.mapValues(grouped, function(group) {
return _.map(group, function(node) {
return node.balance
})
})
}
function parseValue(value) {
return new BigNumber(value.value || value)
}
function computeBalanceChange(node) {
var value = null
if (node.newFields.Balance) {
value = parseValue(node.newFields.Balance)
} else if (node.previousFields.Balance && node.finalFields.Balance) {
value = parseValue(node.finalFields.Balance).minus(
parseValue(node.previousFields.Balance))
}
return value === null ? null : value.isZero() ? null : value
}
function parseFinalBalance(node) {
if (node.newFields.Balance) {
return parseValue(node.newFields.Balance)
} else if (node.finalFields.Balance) {
return parseValue(node.finalFields.Balance)
}
return null
}
function parseXRPQuantity(node, valueParser) {
var value = valueParser(node)
if (value === null) {
return null
}
return {
address: node.finalFields.Account || node.newFields.Account,
balance: {
counterparty: '',
currency: 'XRP',
value: dropsToXRP(value).toString()
}
}
}
function flipTrustlinePerspective(quantity) {
var negatedBalance = (new BigNumber(quantity.balance.value)).negated()
return {
address: quantity.balance.counterparty,
balance: {
counterparty: quantity.address,
currency: quantity.balance.currency,
value: negatedBalance.toString()
}
}
}
function parseTrustlineQuantity(node, valueParser) {
var value = valueParser(node)
if (value === null) {
return null
}
/*
* A trustline can be created with a non-zero starting balance
* If an offer is placed to acquire an asset with no existing trustline,
* the trustline can be created when the offer is taken.
*/
var fields = _.isEmpty(node.newFields) ? node.finalFields : node.newFields
// the balance is always from low node's perspective
var result = {
address: fields.LowLimit.issuer,
balance: {
counterparty: fields.HighLimit.issuer,
currency: fields.Balance.currency,
value: value.toString()
}
}
return [result, flipTrustlinePerspective(result)]
}
function parseQuantities(metadata, valueParser) {
var values = normalizeNodes(metadata).map(function(node) {
if (node.entryType === 'AccountRoot') {
return [parseXRPQuantity(node, valueParser)]
} else if (node.entryType === 'RippleState') {
return parseTrustlineQuantity(node, valueParser)
}
return []
})
return groupByAddress(_.compact(_.flatten(values)))
}
/**
* Computes the complete list of every balance that changed in the ledger
* as a result of the given transaction.
*
* @param {Object} metadata Transaction metada
* @returns {Object} parsed balance changes
*/
function parseBalanceChanges(metadata) {
return parseQuantities(metadata, computeBalanceChange)
}
/**
* Computes the complete list of every final balance in the ledger
* as a result of the given transaction.
*
* @param {Object} metadata Transaction metada
* @returns {Object} parsed balances
*/
function parseFinalBalances(metadata) {
return parseQuantities(metadata, parseFinalBalance)
}
module.exports.parseBalanceChanges = parseBalanceChanges
module.exports.parseFinalBalances = parseFinalBalances
+97
View File
@@ -0,0 +1,97 @@
'use strict'
const normalizeNodes = require('./utils').normalizeNodes
const BigNumber = require('bignumber.js')
function parsePaymentChannelStatus(node) {
if (node.diffType === 'CreatedNode') {
return 'created'
}
if (node.diffType === 'ModifiedNode') {
return 'modified'
}
if (node.diffType === 'DeletedNode') {
return 'deleted'
}
return undefined
}
function summarizePaymentChannel(node) {
const final = (node.diffType === 'CreatedNode') ?
node.newFields : node.finalFields
const prev = node.previousFields || {}
const summary = {
// Status may be 'created', 'modified', or 'deleted'.
status: parsePaymentChannelStatus(node),
// The LedgerIndex indicates the Channel ID,
// which is necessary to sign claims.
channelId: node.ledgerIndex,
// The source address that owns this payment channel.
// This comes from the sending address of the
// transaction that created the channel.
source: final.Account,
// The destination address for this payment channel.
// While the payment channel is open, this address is the only one that can receive
// XRP from the channel. This comes from the Destination field of the transaction
// that created the channel.
destination: final.Destination,
// Total XRP, in drops, that has been allocated to this channel.
// This includes XRP that has been paid to the destination address.
// This is initially set by the transaction that created the channel and
// can be increased if the source address sends a PaymentChannelFund transaction.
channelAmountDrops:
new BigNumber(final.Amount || 0).toString(10),
// Total XRP, in drops, already paid out by the channel.
// The difference between this value and the Amount field is how much XRP can still
// be paid to the destination address with PaymentChannelClaim transactions.
// If the channel closes, the remaining difference is returned to the source address.
channelBalanceDrops:
new BigNumber(final.Balance || 0).toString(10)
}
if (prev.Amount) {
// The change in the number of XRP drops allocated to this channel.
// This is positive if this is a PaymentChannelFund transaction.
summary.channelAmountChangeDrops = new BigNumber(final.Amount)
.minus(new BigNumber(prev.Amount || 0))
.toString(10)
}
if (prev.Balance) {
// The change in the number of XRP drops already paid out by the channel.
summary.channelBalanceChangeDrops = new BigNumber(final.Balance)
.minus(new BigNumber(prev.Balance || 0))
.toString(10)
}
if (node.PreviousTxnID) {
// The identifying hash of the transaction that
// most recently modified this payment channel object.
// You can use this to retrieve the object's history.
summary.previousTxnId = node.PreviousTxnID
}
return summary
}
function parseChannelChanges(metadata) {
const paymentChannels = normalizeNodes(metadata)
.filter(n => {
return n.entryType === 'PayChannel'
})
return (paymentChannels.length === 1) ?
summarizePaymentChannel(paymentChannels[0]) :
undefined
}
module.exports.parseChannelChanges = parseChannelChanges
+12
View File
@@ -0,0 +1,12 @@
'use strict'
module.exports.parseBalanceChanges =
require('./balancechanges').parseBalanceChanges
module.exports.parseFinalBalances =
require('./balancechanges').parseFinalBalances
module.exports.parseOrderbookChanges =
require('./orderbookchanges').parseOrderbookChanges
module.exports.getAffectedAccounts =
require('./utils').getAffectedAccounts
module.exports.parseChannelChanges =
require('./channelchanges').parseChannelChanges
+145
View File
@@ -0,0 +1,145 @@
'use strict'
var _ = require('lodash')
var utils = require('./utils')
var GlobalBigNumber = require('bignumber.js')
var BigNumber = GlobalBigNumber.clone({DECIMAL_PLACES: 40})
var parseQuality = require('./quality')
var lsfSell = 0x00020000 // see "lsfSell" flag in rippled source code
function removeUndefined(obj) {
return _.omitBy(obj, _.isUndefined)
}
function convertOrderChange(order) {
var takerGets = order.taker_gets
var takerPays = order.taker_pays
var direction = order.sell ? 'sell' : 'buy'
var quantity = (direction === 'buy') ? takerPays : takerGets
var totalPrice = (direction === 'buy') ? takerGets : takerPays
return removeUndefined({
direction: direction,
quantity: quantity,
totalPrice: totalPrice,
sequence: order.sequence,
status: order.status,
makerExchangeRate: order.quality,
expirationTime: order.expiration
})
}
function rippleToUnixTimestamp(rpepoch) {
return (rpepoch + 0x386D4380) * 1000
}
function getExpirationTime(node) {
var expirationTime = node.finalFields.Expiration || node.newFields.Expiration
if (expirationTime === undefined) {
return undefined
}
return (new Date(rippleToUnixTimestamp(expirationTime))).toISOString()
}
function getQuality(node) {
var takerGets = node.finalFields.TakerGets || node.newFields.TakerGets
var takerPays = node.finalFields.TakerPays || node.newFields.TakerPays
var takerGetsCurrency = takerGets.currency || 'XRP'
var takerPaysCurrency = takerPays.currency || 'XRP'
var bookDirectory = node.finalFields.BookDirectory
|| node.newFields.BookDirectory
var qualityHex = bookDirectory.substring(bookDirectory.length - 16)
return parseQuality(qualityHex, takerGetsCurrency, takerPaysCurrency)
}
function parseOrderStatus(node) {
if (node.diffType === 'CreatedNode') {
// "submitted" is more conventional, but could be confusing in the
// context of Ripple
return 'created'
}
if (node.diffType === 'ModifiedNode') {
return 'partially-filled'
}
if (node.diffType === 'DeletedNode') {
// A filled order has previous fields
if (node.previousFields.hasOwnProperty('TakerPays')) {
return 'filled'
}
// A cancelled order has no previous fields
// google search for "cancelled order" shows 5x more results than
// "canceled order", even though both spellings are correct
return 'cancelled'
}
return undefined
}
function calculateDelta(finalAmount, previousAmount) {
if (previousAmount) {
var finalValue = new BigNumber(finalAmount.value)
var previousValue = new BigNumber(previousAmount.value)
return finalValue.minus(previousValue).abs().toString()
}
return '0'
}
function parseChangeAmount(node, type) {
var status = parseOrderStatus(node)
if (status === 'cancelled') {
// Canceled orders do not have PreviousFields; FinalFields
// have positive values
return utils.parseCurrencyAmount(node.finalFields[type])
} else if (status === 'created') {
return utils.parseCurrencyAmount(node.newFields[type])
}
var finalAmount = utils.parseCurrencyAmount(node.finalFields[type])
var previousAmount = utils.parseCurrencyAmount(node.previousFields[type])
var value = calculateDelta(finalAmount, previousAmount)
return _.assign({}, finalAmount, {value: value})
}
function parseOrderChange(node) {
var orderChange = convertOrderChange({
taker_pays: parseChangeAmount(node, 'TakerPays'),
taker_gets: parseChangeAmount(node, 'TakerGets'),
sell: (node.finalFields.Flags & lsfSell) !== 0,
sequence: node.finalFields.Sequence || node.newFields.Sequence,
status: parseOrderStatus(node),
quality: getQuality(node),
expiration: getExpirationTime(node)
})
Object.defineProperty(orderChange, 'account', {
value: node.finalFields.Account || node.newFields.Account
})
return orderChange
}
function groupByAddress(orderChanges) {
return _.groupBy(orderChanges, function(change) {
return change.account
})
}
/**
* Computes the complete list of every Offer that changed in the ledger
* as a result of the given transaction.
* Returns changes grouped by Ripple account.
*
* @param {Object} metadata - Transaction metadata as return by ripple-lib
* @returns {Object} - Orderbook changes grouped by Ripple account
*
*/
exports.parseOrderbookChanges = function parseOrderbookChanges(metadata) {
var nodes = utils.normalizeNodes(metadata)
var orderChanges = _.map(_.filter(nodes, function(node) {
return node.entryType === 'Offer'
}), parseOrderChange)
return groupByAddress(orderChanges)
}
+26
View File
@@ -0,0 +1,26 @@
'use strict'
var assert = require('assert')
var BigNumber = require('bignumber.js')
/*
The quality, as stored in the last 64 bits of a directory index, is stored as
the quotient of TakerPays/TakerGets. It uses drops (1e-6 XRP) for XRP values.
*/
function adjustQualityForXRP(quality, takerGetsCurrency, takerPaysCurrency) {
var numeratorShift = (takerPaysCurrency === 'XRP' ? -6 : 0)
var denominatorShift = (takerGetsCurrency === 'XRP' ? -6 : 0)
var shift = numeratorShift - denominatorShift
return shift === 0 ? (new BigNumber(quality)).toString() :
(new BigNumber(quality)).shiftedBy(shift).toString()
}
function parseQuality(qualityHex, takerGetsCurrency, takerPaysCurrency) {
assert(qualityHex.length === 16)
var mantissa = new BigNumber(qualityHex.substring(2), 16)
var offset = parseInt(qualityHex.substring(0, 2), 16) - 100
var quality = mantissa.toString() + 'e' + offset.toString()
return adjustQualityForXRP(quality, takerGetsCurrency, takerPaysCurrency)
}
module.exports = parseQuality
+80
View File
@@ -0,0 +1,80 @@
'use strict'
var _ = require('lodash')
var BigNumber = require('bignumber.js')
// drops is a bignumber.js BigNumber
function dropsToXRP(drops) {
return drops.dividedBy(1000000)
}
function normalizeNode(affectedNode) {
var diffType = Object.keys(affectedNode)[0]
var node = affectedNode[diffType]
return Object.assign({}, node, {
diffType: diffType,
entryType: node.LedgerEntryType,
ledgerIndex: node.LedgerIndex,
newFields: node.NewFields || {},
finalFields: node.FinalFields || {},
previousFields: node.PreviousFields || {}
})
}
function normalizeNodes(metadata) {
if (!metadata.AffectedNodes) {
return []
}
return metadata.AffectedNodes.map(normalizeNode)
}
function parseCurrencyAmount(currencyAmount) {
if (currencyAmount === undefined) {
return undefined
}
if (typeof currencyAmount === 'string') {
return {
currency: 'XRP',
value: dropsToXRP(new BigNumber(currencyAmount)).toString()
}
}
return {
currency: currencyAmount.currency,
counterparty: currencyAmount.issuer,
value: currencyAmount.value
}
}
function isAccountField(fieldName) {
var fieldNames = ['Account', 'Owner', 'Destination', 'Issuer', 'Target']
return _.includes(fieldNames, fieldName)
}
function isAmountFieldAffectingIssuer(fieldName) {
var fieldNames = ['LowLimit', 'HighLimit', 'TakerPays', 'TakerGets']
return _.includes(fieldNames, fieldName)
}
function getAffectedAccounts(metadata) {
var accounts = []
_.forEach(normalizeNodes(metadata), function(node) {
var fields = node.diffType === 'CreatedNode' ?
node.newFields : node.finalFields
_.forEach(fields, function(fieldValue, fieldName) {
if (isAccountField(fieldName)) {
accounts.push(fieldValue)
} else if (isAmountFieldAffectingIssuer(fieldName) && fieldValue.issuer) {
accounts.push(fieldValue.issuer)
}
})
})
return _.uniq(accounts)
}
module.exports = {
dropsToXRP: dropsToXRP,
normalizeNodes: normalizeNodes,
parseCurrencyAmount: parseCurrencyAmount,
getAffectedAccounts: getAffectedAccounts
}
+374
View File
@@ -0,0 +1,374 @@
'use strict'
var assert = require('assert-diff')
var fs = require('fs')
var parseBalanceChanges = require('../src/index').parseBalanceChanges
// Pay 100 XRP from rKmB to rLDY to create rLDY account
var createAccountBalanceChanges = {
rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K: [
{
value: '100',
currency: 'XRP',
counterparty: ''
}
],
rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc: [
{
value: '-100.012',
currency: 'XRP',
counterparty: ''
}
]
}
// Pay 0.01 USD from rKmB to rLDY where rLDY starts with no USD
var usdFirstPaymentBalanceChanges = {
rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc: [
{
value: '-0.01',
currency: 'USD',
counterparty: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
},
{
value: '-0.012',
currency: 'XRP',
counterparty: ''
}
],
rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q: [
{
counterparty: 'rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc',
currency: 'USD',
value: '0.01'
},
{
counterparty: 'rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K',
currency: 'USD',
value: '-0.01'
}
],
rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K: [
{
counterparty: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q',
currency: 'USD',
value: '0.01'
}
]
}
// Pay 0.2 USD from rLDY to rKmB where rLDY starts with 0.2 USD
var usdFullPaymentBalanceChanges = {
rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc: [
{
value: '0.2',
currency: 'USD',
counterparty: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
}
],
rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q: [
{
value: '-0.2',
currency: 'USD',
counterparty: 'rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc'
},
{
value: '0.2',
currency: 'USD',
counterparty: 'rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K'
}
],
rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K: [
{
value: '-0.2',
currency: 'USD',
counterparty: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
},
{
value: '-0.012',
currency: 'XRP',
counterparty: ''
}
]
}
// Pay 0.01 USD from rKmB to rLDY where rLDY starts with 0.01 USD
var usdPaymentBalanceChanges = usdFirstPaymentBalanceChanges
// Set trust limit to 200 USD on rLDY when it has a trust limit of 100 USD
// and has a balance of 0.02 USD
var setTrustlineBalanceChanges = {
rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K: [
{
value: '-0.012',
currency: 'XRP',
counterparty: ''
}
]
}
var setTrustlineBalanceChanges2 = {
rsApBGKJmMfExxZBrGnzxEXyq7TMhMRg4e: [
{
counterparty: '',
currency: 'XRP',
value: '-0.00001'
}
]
}
// Set trust limit to 100 USD with balance of 10 USD
// on rLDY when it has no trustline
var createTrustlineBalanceChanges = {
rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K: [
{
counterparty: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q',
currency: 'USD',
value: '10'
},
{
counterparty: '',
currency: 'XRP',
value: '-0.012'
}
],
rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q: [
{
counterparty: 'rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K',
currency: 'USD',
value: '-10'
}
]
}
// Pay 0.02 USD from rLDY to rKmB when rLDY has a trust limit of 0
// for USD, but still has a balance of 0.02 USD; which closes the trustline
var deleteTrustlineBalanceChanges = {
rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc: [
{
value: '0.02',
currency: 'USD',
counterparty: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
}
],
rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q: [
{
value: '-0.02',
currency: 'USD',
counterparty: 'rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc'
},
{
value: '0.02',
currency: 'USD',
counterparty: 'rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K'
}
],
rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K: [
{
value: '-0.02',
currency: 'USD',
counterparty: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
},
{
value: '-0.012',
currency: 'XRP',
counterparty: ''
}
]
}
var redeemBalanceChanges = {
rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh: [
{
currency: 'USD',
counterparty: 'rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK',
value: '100'
}
],
rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK: [
{
currency: 'USD',
counterparty: 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
value: '-100'
},
{
currency: 'XRP',
counterparty: '',
value: '-0.00001'
}
]
}
var redeemThenIssueBalanceChanges = {
rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh: [
{
currency: 'USD',
counterparty: 'rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK',
value: '200'
}
],
rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK: [
{
currency: 'USD',
counterparty: 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
value: '-200'
},
{
currency: 'XRP',
counterparty: '',
value: '-0.00001'
}
]
}
var multipathBalanceChanges = {
rrnsYgWn13Z28GtRgznrSUsLfMkvsXCZSu: [
{
counterparty: 'r4nmQNH4Fhjfh6cHDbvVSsBv7KySbj4cBf',
currency: 'USD',
value: '100'
},
{
counterparty: 'rnYDWQaRdMb5neCGgvFfhw3MBoxmv5LtfH',
currency: 'USD',
value: '-100'
}
],
r4nmQNH4Fhjfh6cHDbvVSsBv7KySbj4cBf: [
{
counterparty: 'rrnsYgWn13Z28GtRgznrSUsLfMkvsXCZSu',
currency: 'USD',
value: '-100'
},
{
counterparty: '',
currency: 'XRP',
value: '-0.00001'
},
{
counterparty: 'rJsaPnGdeo7BhMnHjuc3n44Mf7Ra1qkSVJ',
currency: 'USD',
value: '-100'
},
{
counterparty: 'rGpeQzUWFu4fMhJHZ1Via5aqFC3A5twZUD',
currency: 'USD',
value: '-100'
}
],
rJsaPnGdeo7BhMnHjuc3n44Mf7Ra1qkSVJ: [
{
counterparty: 'r4nmQNH4Fhjfh6cHDbvVSsBv7KySbj4cBf',
currency: 'USD',
value: '100'
},
{
counterparty: 'rnYDWQaRdMb5neCGgvFfhw3MBoxmv5LtfH',
currency: 'USD',
value: '-100'
}
],
rGpeQzUWFu4fMhJHZ1Via5aqFC3A5twZUD: [
{
counterparty: 'r4nmQNH4Fhjfh6cHDbvVSsBv7KySbj4cBf',
currency: 'USD',
value: '100'
},
{
counterparty: 'rnYDWQaRdMb5neCGgvFfhw3MBoxmv5LtfH',
currency: 'USD',
value: '-100'
}
],
rnYDWQaRdMb5neCGgvFfhw3MBoxmv5LtfH: [
{
counterparty: 'rJsaPnGdeo7BhMnHjuc3n44Mf7Ra1qkSVJ',
currency: 'USD',
value: '100'
},
{
counterparty: 'rrnsYgWn13Z28GtRgznrSUsLfMkvsXCZSu',
currency: 'USD',
value: '100'
},
{
counterparty: 'rGpeQzUWFu4fMhJHZ1Via5aqFC3A5twZUD',
currency: 'USD',
value: '100'
}
]
}
// Set trust limit to zero on rLDY when it has a balance of 0.02 USD
var removeTrustBalanceChanges = setTrustlineBalanceChanges
function loadFixture(filename) {
var path = __dirname + '/fixtures/' + filename
return JSON.parse(fs.readFileSync(path))
}
describe('parseBalanceChanges', function() {
it('XRP create account', function() {
var paymentResponse = loadFixture('payment-xrp-create-account.json')
var result = parseBalanceChanges(paymentResponse.metadata)
assert.deepEqual(result, createAccountBalanceChanges)
})
it('USD payment to account with no USD', function() {
var filename = 'payment-iou-destination-no-balance.json'
var paymentResponse = loadFixture(filename)
var result = parseBalanceChanges(paymentResponse.metadata)
assert.deepEqual(result, usdFirstPaymentBalanceChanges)
})
it('USD payment of all USD in source account', function() {
var paymentResponse = loadFixture('payment-iou-spend-full-balance.json')
var result = parseBalanceChanges(paymentResponse.metadata)
assert.deepEqual(result, usdFullPaymentBalanceChanges)
})
it('USD payment to account with USD', function() {
var paymentResponse = loadFixture('payment-iou.json')
var result = parseBalanceChanges(paymentResponse.metadata)
assert.deepEqual(result, usdPaymentBalanceChanges)
})
it('Set trust limit to 0 with balance remaining', function() {
var paymentResponse = loadFixture('trustline-set-limit-to-zero.json')
var result = parseBalanceChanges(paymentResponse.metadata)
assert.deepEqual(result, removeTrustBalanceChanges)
})
it('Create trustline', function() {
var paymentResponse = loadFixture('trustline-create.json')
var result = parseBalanceChanges(paymentResponse.metadata)
assert.deepEqual(result, createTrustlineBalanceChanges)
})
it('Set trustline', function() {
var paymentResponse = loadFixture('trustline-set-limit.json')
var result = parseBalanceChanges(paymentResponse.metadata)
assert.deepEqual(result, setTrustlineBalanceChanges)
})
it('Set trustline 2', function() {
var paymentResponse = loadFixture('trustline-set-limit-2.json')
var result = parseBalanceChanges(paymentResponse.metadata)
assert.deepEqual(result, setTrustlineBalanceChanges2)
})
it('Delete trustline', function() {
var paymentResponse = loadFixture('trustline-delete.json')
var result = parseBalanceChanges(paymentResponse.metadata)
assert.deepEqual(result, deleteTrustlineBalanceChanges)
})
it('Redeem USD', function() {
var paymentResponse = loadFixture('payment-iou-redeem.json')
var result = parseBalanceChanges(paymentResponse.result.meta)
assert.deepEqual(result, redeemBalanceChanges)
})
it('Redeem then issue USD', function() {
var paymentResponse = loadFixture('payment-iou-redeem-then-issue.json')
var result = parseBalanceChanges(paymentResponse.result.meta)
assert.deepEqual(result, redeemThenIssueBalanceChanges)
})
it('Multipath USD payment', function() {
var paymentResponse = loadFixture('payment-iou-multipath.json')
var result = parseBalanceChanges(paymentResponse.result.meta)
assert.deepEqual(result, multipathBalanceChanges)
})
})
+68
View File
@@ -0,0 +1,68 @@
'use strict'
var assert = require('assert-diff')
var parseChannelChanges = require('../src/index').parseChannelChanges
describe('parseChannelChanges', function() {
it('parses PayChannel metadata', function() {
var metadata = {
'AffectedNodes': [
{
'ModifiedNode': {
'FinalFields': {
'Account': 'rJNa71cLCjzQG68oNjh4fCUqCZSGNkWDrM',
'Balance': '512724201',
'Flags': 0,
'OwnerCount': 98,
'Sequence': 24166
},
'LedgerEntryType': 'AccountRoot',
'LedgerIndex': 'D16BF3F23AFB01CA5AC7860F9AF8037117972D5A389DDFDBB5A1064742B154D8',
'PreviousFields': {
'Balance': '512714213',
'Sequence': 24165
},
'PreviousTxnID': '9345E3B3578F8F6C8DC55F7B39F7C48F9E79E7BD2A77ADE2714D5910C501980F',
'PreviousTxnLgrSeq': 39792515
}
},
{
'ModifiedNode': {
'FinalFields': {
'Account': 'rpyC4JM5kifsNG6YbARDAxAJQLBDZw9ZFQ',
'Amount': '10000000',
'Balance': '40000',
'Destination': 'rJNa71cLCjzQG68oNjh4fCUqCZSGNkWDrM',
'Flags': 0,
'OwnerNode': '0000000000000000',
'PublicKey': 'ED4DB1CE76AB25FAACE3E13BF57EA7767614FB52A250E1D04426A28B383A31A652',
'SettleDelay': 3600,
'SourceTag': 3382712545
},
'LedgerEntryType': 'PayChannel',
'LedgerIndex': 'EC4DACE3360DCBF76FE80874931F2C75C5B4B6A05D615FA3E62DFF2BE34A8ACB',
'PreviousFields': {
'Balance': '30000'
},
'PreviousTxnID': '5E854E78A51C45FC626C61924C20EA25670EF18E5609DA5F1F7898E833DCB257',
'PreviousTxnLgrSeq': 39749577
}
}
],
'TransactionIndex': 24,
'TransactionResult': 'tesSUCCESS'
}
var result = parseChannelChanges(metadata)
var expectedResult = {
status: 'modified',
channelId: 'EC4DACE3360DCBF76FE80874931F2C75C5B4B6A05D615FA3E62DFF2BE34A8ACB',
source: 'rpyC4JM5kifsNG6YbARDAxAJQLBDZw9ZFQ',
destination: 'rJNa71cLCjzQG68oNjh4fCUqCZSGNkWDrM',
channelBalanceChangeDrops: '10000',
channelAmountDrops: '10000000',
channelBalanceDrops: '40000',
previousTxnId: '5E854E78A51C45FC626C61924C20EA25670EF18E5609DA5F1F7898E833DCB257'
}
assert.deepEqual(result, expectedResult)
})
})
+453
View File
@@ -0,0 +1,453 @@
'use strict'
var assert = require('assert-diff')
var fs = require('fs')
var parseFinalBalances = require('../src/index').parseFinalBalances
// Pay 100 XRP from rKmB to rLDY to create rLDY account
var createAccountBalanceChanges = {
rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K: [
{
value: '100',
currency: 'XRP',
counterparty: ''
}
],
rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc: [
{
value: '339.903994',
currency: 'XRP',
counterparty: ''
}
]
}
// Pay 0.01 USD from rKmB to rLDY where rLDY starts with no USD
var usdFirstPaymentBalanceChanges = {
rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc: [
{
value: '1.535330905250352',
currency: 'USD',
counterparty: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
},
{
value: '239.807992',
currency: 'XRP',
counterparty: ''
}
],
rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q: [
{
counterparty: 'rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc',
currency: 'USD',
value: '-1.535330905250352'
},
{
counterparty: 'rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K',
currency: 'USD',
value: '-0.01'
}
],
rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K: [
{
counterparty: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q',
currency: 'USD',
value: '0.01'
}
]
}
// Pay 0.2 USD from rLDY to rKmB where rLDY starts with 0.2 USD
var usdFullPaymentBalanceChanges = {
rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc: [
{
value: '1.545330905250352',
currency: 'USD',
counterparty: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
}
],
rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q: [
{
counterparty: 'rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc',
currency: 'USD',
value: '-1.545330905250352'
},
{
counterparty: 'rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K',
currency: 'USD',
value: '0'
}
],
rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K: [
{
value: '0',
currency: 'USD',
counterparty: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
},
{
value: '99.976002',
currency: 'XRP',
counterparty: ''
}
]
}
// Pay 0.01 USD from rKmB to rLDY where rLDY starts with 0.01 USD
var usdPaymentBalanceChanges = {
rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc: [
{
value: '1.525330905250352',
currency: 'USD',
counterparty: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q'
},
{
value: '239.555992',
currency: 'XRP',
counterparty: ''
}
],
rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q: [
{
counterparty: 'rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc',
currency: 'USD',
value: '-1.525330905250352'
},
{
counterparty: 'rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K',
currency: 'USD',
value: '-0.02'
}
],
rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K: [
{
counterparty: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q',
currency: 'USD',
value: '0.02'
}
]
}
// Set trust limit to 200 USD on rLDY when it has a trust limit of 100 USD
// and has a balance of 0.02 USD
var setTrustlineBalanceChanges = {
rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K: [
{
counterparty: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q',
currency: 'USD',
value: '0.02'
},
{
value: '99.940002',
currency: 'XRP',
counterparty: ''
}
],
rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q: [
{
counterparty: 'rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K',
currency: 'USD',
value: '-0.02'
}
]
}
var setTrustlineBalanceChanges3 = {
rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K: [
{
counterparty: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q',
currency: 'USD',
value: '0.02'
},
{
counterparty: '',
currency: 'XRP',
value: '99.884302'
}
],
rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q: [
{
counterparty: 'rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K',
currency: 'USD',
value: '-0.02'
}
]
}
var setTrustlineBalanceChanges2 = {
rsApBGKJmMfExxZBrGnzxEXyq7TMhMRg4e: [
{
counterparty: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q',
currency: 'USD',
value: '0'
},
{
counterparty: '',
currency: 'XRP',
value: '9248.902096'
}
],
rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q: [
{
counterparty: 'rsApBGKJmMfExxZBrGnzxEXyq7TMhMRg4e',
currency: 'USD',
value: '0'
},
{
counterparty: '',
currency: 'XRP',
value: '149.99998'
}
]
}
// Set trust limit to 100 USD with balance of 10 USD on rLDY
// when it has no trustline
var createTrustlineBalanceChanges = {
rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K: [
{
counterparty: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q',
currency: 'USD',
value: '10'
},
{
counterparty: '',
currency: 'XRP',
value: '99.740302'
}
],
rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q: [
{
counterparty: 'rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K',
currency: 'USD',
value: '-10'
}
]
}
// Pay 0.02 USD from rLDY to rKmB when rLDY has a trust limit of 0
// for USD, but still has a balance of 0.02 USD; which closes the trustline
var deleteTrustlineBalanceChanges = {
rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc: [
{
counterparty: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q',
currency: 'USD',
value: '1.545330905250352'
}
],
rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q: [
{
counterparty: 'rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc',
currency: 'USD',
value: '-1.545330905250352'
},
{
counterparty: 'rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K',
currency: 'USD',
value: '0'
}
],
rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K: [
{
counterparty: 'rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q',
currency: 'USD',
value: '0'
},
{
counterparty: '',
currency: 'XRP',
value: '99.752302'
}
]
}
var redeemBalanceChanges = {
rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh: [
{
counterparty: 'rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK',
currency: 'USD',
value: '-100'
}
],
rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK: [
{
counterparty: 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
currency: 'USD',
value: '100'
},
{
counterparty: '',
currency: 'XRP',
value: '999.99998'
}
]
}
var redeemThenIssueBalanceChanges = {
rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh: [
{
counterparty: 'rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK',
currency: 'USD',
value: '100'
}
],
rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK: [
{
counterparty: 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh',
currency: 'USD',
value: '-100'
},
{
counterparty: '',
currency: 'XRP',
value: '999.99997'
}
]
}
var multipathBalanceChanges = {
rrnsYgWn13Z28GtRgznrSUsLfMkvsXCZSu: [
{
counterparty: 'r4nmQNH4Fhjfh6cHDbvVSsBv7KySbj4cBf',
currency: 'USD',
value: '0'
},
{
counterparty: 'rnYDWQaRdMb5neCGgvFfhw3MBoxmv5LtfH',
currency: 'USD',
value: '-100'
}
],
r4nmQNH4Fhjfh6cHDbvVSsBv7KySbj4cBf: [
{
counterparty: 'rrnsYgWn13Z28GtRgznrSUsLfMkvsXCZSu',
currency: 'USD',
value: '0'
},
{
counterparty: '',
currency: 'XRP',
value: '999.99999'
},
{
counterparty: 'rJsaPnGdeo7BhMnHjuc3n44Mf7Ra1qkSVJ',
currency: 'USD',
value: '0'
},
{
counterparty: 'rGpeQzUWFu4fMhJHZ1Via5aqFC3A5twZUD',
currency: 'USD',
value: '0'
}
],
rJsaPnGdeo7BhMnHjuc3n44Mf7Ra1qkSVJ: [
{
counterparty: 'r4nmQNH4Fhjfh6cHDbvVSsBv7KySbj4cBf',
currency: 'USD',
value: '0'
},
{
counterparty: 'rnYDWQaRdMb5neCGgvFfhw3MBoxmv5LtfH',
currency: 'USD',
value: '-100'
}
],
rGpeQzUWFu4fMhJHZ1Via5aqFC3A5twZUD: [
{
counterparty: 'r4nmQNH4Fhjfh6cHDbvVSsBv7KySbj4cBf',
currency: 'USD',
value: '0'
},
{
counterparty: 'rnYDWQaRdMb5neCGgvFfhw3MBoxmv5LtfH',
currency: 'USD',
value: '-100'
}
],
rnYDWQaRdMb5neCGgvFfhw3MBoxmv5LtfH: [
{
counterparty: 'rJsaPnGdeo7BhMnHjuc3n44Mf7Ra1qkSVJ',
currency: 'USD',
value: '100'
},
{
counterparty: 'rrnsYgWn13Z28GtRgznrSUsLfMkvsXCZSu',
currency: 'USD',
value: '100'
},
{
counterparty: 'rGpeQzUWFu4fMhJHZ1Via5aqFC3A5twZUD',
currency: 'USD',
value: '100'
}
]
}
function loadFixture(filename) {
var path = __dirname + '/fixtures/' + filename
return JSON.parse(fs.readFileSync(path))
}
describe('parseFinalBalances', function() {
it('XRP create account', function() {
var paymentResponse = loadFixture('payment-xrp-create-account.json')
var result = parseFinalBalances(paymentResponse.metadata)
assert.deepEqual(result, createAccountBalanceChanges)
})
it('USD payment to account with no USD', function() {
var filename = 'payment-iou-destination-no-balance.json'
var paymentResponse = loadFixture(filename)
var result = parseFinalBalances(paymentResponse.metadata)
assert.deepEqual(result, usdFirstPaymentBalanceChanges)
})
it('USD payment of all USD in source account', function() {
var paymentResponse = loadFixture('payment-iou-spend-full-balance.json')
var result = parseFinalBalances(paymentResponse.metadata)
assert.deepEqual(result, usdFullPaymentBalanceChanges)
})
it('USD payment to account with USD', function() {
var paymentResponse = loadFixture('payment-iou.json')
var result = parseFinalBalances(paymentResponse.metadata)
assert.deepEqual(result, usdPaymentBalanceChanges)
})
it('Set trust limit to 0 with balance remaining', function() {
var paymentResponse = loadFixture('trustline-set-limit-to-zero.json')
var result = parseFinalBalances(paymentResponse.metadata)
assert.deepEqual(result, setTrustlineBalanceChanges)
})
it('Create trustline', function() {
var paymentResponse = loadFixture('trustline-create.json')
var result = parseFinalBalances(paymentResponse.metadata)
assert.deepEqual(result, createTrustlineBalanceChanges)
})
it('Set trustline', function() {
var paymentResponse = loadFixture('trustline-set-limit.json')
var result = parseFinalBalances(paymentResponse.metadata)
assert.deepEqual(result, setTrustlineBalanceChanges3)
})
it('Set trustline 2', function() {
var paymentResponse = loadFixture('trustline-set-limit-2.json')
var result = parseFinalBalances(paymentResponse.metadata)
assert.deepEqual(result, setTrustlineBalanceChanges2)
})
it('Delete trustline', function() {
var paymentResponse = loadFixture('trustline-delete.json')
var result = parseFinalBalances(paymentResponse.metadata)
assert.deepEqual(result, deleteTrustlineBalanceChanges)
})
it('Redeem USD', function() {
var paymentResponse = loadFixture('payment-iou-redeem.json')
var result = parseFinalBalances(paymentResponse.result.meta)
assert.deepEqual(result, redeemBalanceChanges)
})
it('Redeem then issue USD', function() {
var paymentResponse = loadFixture('payment-iou-redeem-then-issue.json')
var result = parseFinalBalances(paymentResponse.result.meta)
assert.deepEqual(result, redeemThenIssueBalanceChanges)
})
it('Multipath USD payment', function() {
var paymentResponse = loadFixture('payment-iou-multipath.json')
var result = parseFinalBalances(paymentResponse.result.meta)
assert.deepEqual(result, multipathBalanceChanges)
})
})
@@ -0,0 +1,20 @@
{
"rBSZe33F5oxHTbxSF1nZJooVDpcrrqNFp3": [
{
"direction": "buy",
"quantity": {
"currency": "CNY",
"counterparty": "rnuF96W4SZoCJmbHYBFoJZpR8eCaxNvekK",
"value": "3200"
},
"totalPrice": {
"currency": "XRP",
"value": "34700.537395"
},
"sequence": 1122978,
"status": "cancelled",
"makerExchangeRate": "0.09221759200942773",
"expirationTime": "2015-01-14T18:36:52.000Z"
}
]
}
@@ -0,0 +1,93 @@
{
"Account": "rBSZe33F5oxHTbxSF1nZJooVDpcrrqNFp3",
"Fee": "11000",
"Flags": 2147483648,
"LastLedgerSequence": 11119601,
"OfferSequence": 1122978,
"Sequence": 1122979,
"SigningPubKey": "03FD8927D4450E5B6C060BF7E46D1DDA2B24C547A45D43926741095D8FCA6A71DB",
"TransactionType": "OfferCancel",
"TxnSignature": "304402207758C80B90667A407299B2D8A16F8D6DF51E7103B562529AB8242B14B737D9B10220431095B7881C4363C3A2AB966C95190DF2E438FBB394F65014B6436E56F4F6E6",
"date": 474575220,
"hash": "097B9491CC76B64831F1FEA82EAA93BCD728106D90B65A072C933888E946C40B",
"inLedger": 11119599,
"ledger_index": 11119599,
"meta": {
"AffectedNodes": [
{
"DeletedNode": {
"FinalFields": {
"Account": "rBSZe33F5oxHTbxSF1nZJooVDpcrrqNFp3",
"BookDirectory": "94A08655B7E5C048769B82A900C085FD1D8A28B2A9E7939C4D20C32421605AB5",
"BookNode": "0000000000000000",
"Expiration": 474575812,
"Flags": 0,
"OwnerNode": "0000000000000003",
"PreviousTxnID": "40FA69EF2F42729DEE5F3BE0D43FAAB63C35FF5A28C3221A385EAFE84733C208",
"PreviousTxnLgrSeq": 11119599,
"Sequence": 1122978,
"TakerGets": "34700537395",
"TakerPays": {
"currency": "CNY",
"issuer": "rnuF96W4SZoCJmbHYBFoJZpR8eCaxNvekK",
"value": "3200"
}
},
"LedgerEntryType": "Offer",
"LedgerIndex": "40A3657C011B5E1EACBEECB40B1BEAA1220645EA89EA8AEC2D562192B8E60095"
}
},
{
"ModifiedNode": {
"FinalFields": {
"Flags": 0,
"IndexPrevious": "0000000000000001",
"Owner": "rBSZe33F5oxHTbxSF1nZJooVDpcrrqNFp3",
"RootIndex": "3D3DA923D48E02DB1C0B667FA9E2777C348CBE229C7E4E83CBBDE5851D80FF32"
},
"LedgerEntryType": "DirectoryNode",
"LedgerIndex": "8EB5EC4A94AB9D4142DB695F9503CEB4E471E803A76FD563C9B0A598281D085A"
}
},
{
"ModifiedNode": {
"FinalFields": {
"ExchangeRate": "4D20C32421605AB5",
"Flags": 0,
"RootIndex": "94A08655B7E5C048769B82A900C085FD1D8A28B2A9E7939C4D20C32421605AB5",
"TakerGetsCurrency": "0000000000000000000000000000000000000000",
"TakerGetsIssuer": "0000000000000000000000000000000000000000",
"TakerPaysCurrency": "000000000000000000000000434E590000000000",
"TakerPaysIssuer": "35DD7DF146893456296BF4061FBE68735D28F328"
},
"LedgerEntryType": "DirectoryNode",
"LedgerIndex": "94A08655B7E5C048769B82A900C085FD1D8A28B2A9E7939C4D20C32421605AB5"
}
},
{
"ModifiedNode": {
"FinalFields": {
"Account": "rBSZe33F5oxHTbxSF1nZJooVDpcrrqNFp3",
"Balance": "266777347375",
"Flags": 0,
"OwnerCount": 18,
"RegularKey": "rDpVpTMogkwzoq2mkNRBmMCxbmUAwPvoFt",
"Sequence": 1122980
},
"LedgerEntryType": "AccountRoot",
"LedgerIndex": "9DE2C31C24122AEDCD6CBE74567B2AF1CE9A5B31795E60F7A6BBD48BA1304E37",
"PreviousFields": {
"Balance": "266777358375",
"OwnerCount": 19,
"Sequence": 1122979
},
"PreviousTxnID": "40FA69EF2F42729DEE5F3BE0D43FAAB63C35FF5A28C3221A385EAFE84733C208",
"PreviousTxnLgrSeq": 11119599
}
}
],
"TransactionIndex": 15,
"TransactionResult": "tesSUCCESS"
},
"validated": true
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,123 @@
{
"engine_result": "tesSUCCESS",
"engine_result_code": 0,
"engine_result_message": "The transaction was applied.",
"ledger_hash": "1B549453005A924A4EEF6DA9E1BA7D8D1E51D7B685CE8DE072667321FBA792C8",
"ledger_index": 10425094,
"status": "closed",
"type": "transaction",
"validated": true,
"metadata": {
"AffectedNodes": [
{
"ModifiedNode": {
"FinalFields": {
"Balance": {
"currency": "USD",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "1.535330905250352"
},
"Flags": 1114112,
"HighLimit": {
"currency": "USD",
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"value": "0"
},
"HighNode": "00000000000001E8",
"LowLimit": {
"currency": "USD",
"issuer": "rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc",
"value": "1000000000"
},
"LowNode": "0000000000000000"
},
"LedgerEntryType": "RippleState",
"LedgerIndex": "2F323020B4288ACD4066CC64C89DAD2E4D5DFC2D44571942A51C005BF79D6E25",
"PreviousFields": {
"Balance": {
"currency": "USD",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "1.545330905250352"
}
},
"PreviousTxnID": "CEB7B6040C2989B9849C8D7E49F710457EDDE1D95ECDF1E298FD30CF2AC5BE11",
"PreviousTxnLgrSeq": 10424776
}
},
{
"ModifiedNode": {
"FinalFields": {
"Balance": {
"currency": "USD",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "0.01"
},
"Flags": 1114112,
"HighLimit": {
"currency": "USD",
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"value": "0"
},
"HighNode": "00000000000001E8",
"LowLimit": {
"currency": "USD",
"issuer": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"value": "1000000000"
},
"LowNode": "0000000000000000"
},
"LedgerEntryType": "RippleState",
"LedgerIndex": "AAE13AF5192EFBFD49A8EEE5869595563FEB73228C0B38FED9CC3D20EE74F399",
"PreviousFields": {
"Balance": {
"currency": "USD",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "0"
}
},
"PreviousTxnID": "A788447CF5FD7108CBF49416E2335F95ED3F5A9FC016686C8F9EFB34BBEA613A",
"PreviousTxnLgrSeq": 10425088
}
},
{
"ModifiedNode": {
"FinalFields": {
"Account": "rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc",
"Balance": "239807992",
"Flags": 0,
"OwnerCount": 1,
"Sequence": 17
},
"LedgerEntryType": "AccountRoot",
"LedgerIndex": "E9A39B0BA8703D5FFD05D9EAD01EE6C0E7A15CF33C2C6B7269107BD2BD535818",
"PreviousFields": {
"Balance": "239819992",
"Sequence": 16
},
"PreviousTxnID": "3109F5A0F891CCA20B4D891EB7437973F40A7664C5176092EB2E5C0A949992AD",
"PreviousTxnLgrSeq": 10424942
}
}
],
"TransactionIndex": 3,
"TransactionResult": "tesSUCCESS"
},
"tx_json": {
"Account": "rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc",
"Amount": {
"currency": "USD",
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"value": "0.01"
},
"Destination": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"Fee": "12000",
"Flags": 2147483648,
"LastLedgerSequence": 10425102,
"Sequence": 16,
"SigningPubKey": "03F16A52EBDCA6EBF5D99828E1E6918C64D45E6F136476A8F4757512FE553D18F0",
"TransactionType": "Payment",
"TxnSignature": "3044022017DC45606103FF2CCE5D63E340D1E2B302BE16C206673B99712058CA0DBD2CC5022074A19CF5AF9CDFCEC821650A4C22E83E49E14956E1F2A094181E8E14F6881200",
"date": 471494760,
"hash": "D038C9D95926EACAA9FBDF3E6CA0675ACF1700B3CE13FF4CA52B463B58860BBA"
}
}
@@ -0,0 +1,287 @@
{
"result" : {
"Account" : "r4nmQNH4Fhjfh6cHDbvVSsBv7KySbj4cBf",
"Amount" : {
"currency" : "USD",
"issuer" : "rnYDWQaRdMb5neCGgvFfhw3MBoxmv5LtfH",
"value" : "300"
},
"Destination" : "rnYDWQaRdMb5neCGgvFfhw3MBoxmv5LtfH",
"Fee" : "10",
"Flags" : 0,
"Paths" : [
[
{
"account" : "rJsaPnGdeo7BhMnHjuc3n44Mf7Ra1qkSVJ",
"currency" : "USD",
"issuer" : "rJsaPnGdeo7BhMnHjuc3n44Mf7Ra1qkSVJ",
"type" : 49,
"type_hex" : "0000000000000031"
}
],
[
{
"account" : "rGpeQzUWFu4fMhJHZ1Via5aqFC3A5twZUD",
"currency" : "USD",
"issuer" : "rGpeQzUWFu4fMhJHZ1Via5aqFC3A5twZUD",
"type" : 49,
"type_hex" : "0000000000000031"
}
],
[
{
"account" : "rrnsYgWn13Z28GtRgznrSUsLfMkvsXCZSu",
"currency" : "USD",
"issuer" : "rrnsYgWn13Z28GtRgznrSUsLfMkvsXCZSu",
"type" : 49,
"type_hex" : "0000000000000031"
}
]
],
"Sequence" : 4,
"SigningPubKey" : "0324CAAFA2212D2AEAB9D42D481535614AED486293E1FB1380FF070C3DD7FB4264",
"TransactionType" : "Payment",
"TxnSignature" : "3044022007192E2113C236D541BA72FE628F2BDAA467120F3F61F588B63023E4EAE79E06022051813E7809F3DB07B29AEA65D61C1DD1B830C130840A15A67718ADC6FD94C44B",
"date" : 472608260,
"hash" : "029E6CF9C7962A324BD52A90732184991309DD964E7E8B2D52CAF138CB92CB29",
"inLedger" : 8,
"ledger_index" : 8,
"meta" : {
"AffectedNodes" : [
{
"ModifiedNode" : {
"FinalFields" : {
"Balance" : {
"currency" : "USD",
"issuer" : "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value" : "0"
},
"Flags" : 131072,
"HighLimit" : {
"currency" : "USD",
"issuer" : "r4nmQNH4Fhjfh6cHDbvVSsBv7KySbj4cBf",
"value" : "100"
},
"HighNode" : "0000000000000000",
"LowLimit" : {
"currency" : "USD",
"issuer" : "rrnsYgWn13Z28GtRgznrSUsLfMkvsXCZSu",
"value" : "0"
},
"LowNode" : "0000000000000000"
},
"LedgerEntryType" : "RippleState",
"LedgerIndex" : "1AC76982771D3660656D83FA7CCE8E833C42DA797BECAAB30F36D6EEF73BE91B",
"PreviousFields" : {
"Balance" : {
"currency" : "USD",
"issuer" : "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value" : "-100"
}
},
"PreviousTxnID" : "5E732D1DCC74EC0A5658FADC3B0FF7BBDDB83F630A04527A82DB671B04180FAD",
"PreviousTxnLgrSeq" : 5
}
},
{
"ModifiedNode" : {
"FinalFields" : {
"Account" : "r4nmQNH4Fhjfh6cHDbvVSsBv7KySbj4cBf",
"Balance" : "999999990",
"Flags" : 0,
"OwnerCount" : 3,
"Sequence" : 5
},
"LedgerEntryType" : "AccountRoot",
"LedgerIndex" : "5302F37F1D9290D8D92A31651FF71531504183695C2C43EC136B1CF4AC7E08FA",
"PreviousFields" : {
"Balance" : "1000000000",
"Sequence" : 4
},
"PreviousTxnID" : "60357254ABC66B61EA9B13851A2862B55D7B5CF4EBE1D5682E95EBE217037B3A",
"PreviousTxnLgrSeq" : 4
}
},
{
"ModifiedNode" : {
"FinalFields" : {
"Balance" : {
"currency" : "USD",
"issuer" : "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value" : "0"
},
"Flags" : 131072,
"HighLimit" : {
"currency" : "USD",
"issuer" : "r4nmQNH4Fhjfh6cHDbvVSsBv7KySbj4cBf",
"value" : "100"
},
"HighNode" : "0000000000000000",
"LowLimit" : {
"currency" : "USD",
"issuer" : "rJsaPnGdeo7BhMnHjuc3n44Mf7Ra1qkSVJ",
"value" : "0"
},
"LowNode" : "0000000000000000"
},
"LedgerEntryType" : "RippleState",
"LedgerIndex" : "9D9CE283FB821F2A2DA5BCA55DFB2FD7758D129F3060B1F7834B7784AF4CD15C",
"PreviousFields" : {
"Balance" : {
"currency" : "USD",
"issuer" : "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value" : "-100"
}
},
"PreviousTxnID" : "84EE2961C88A4B87A0F234CDF4C66BB488781DA2FF823814381473B40875C2AA",
"PreviousTxnLgrSeq" : 5
}
},
{
"ModifiedNode" : {
"FinalFields" : {
"Balance" : {
"currency" : "USD",
"issuer" : "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value" : "0"
},
"Flags" : 131072,
"HighLimit" : {
"currency" : "USD",
"issuer" : "r4nmQNH4Fhjfh6cHDbvVSsBv7KySbj4cBf",
"value" : "100"
},
"HighNode" : "0000000000000000",
"LowLimit" : {
"currency" : "USD",
"issuer" : "rGpeQzUWFu4fMhJHZ1Via5aqFC3A5twZUD",
"value" : "0"
},
"LowNode" : "0000000000000000"
},
"LedgerEntryType" : "RippleState",
"LedgerIndex" : "C5F104A35DB835AF4A4C4664BCDA57A88873DCEF23DF567485654FAEE5645949",
"PreviousFields" : {
"Balance" : {
"currency" : "USD",
"issuer" : "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value" : "-100"
}
},
"PreviousTxnID" : "CC0817117A0C9055E26FB2E482AC0EF8B4321D874D55428F5F22DEAEE18E0931",
"PreviousTxnLgrSeq" : 5
}
},
{
"ModifiedNode" : {
"FinalFields" : {
"Balance" : {
"currency" : "USD",
"issuer" : "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value" : "100"
},
"Flags" : 65536,
"HighLimit" : {
"currency" : "USD",
"issuer" : "rJsaPnGdeo7BhMnHjuc3n44Mf7Ra1qkSVJ",
"value" : "0"
},
"HighNode" : "0000000000000000",
"LowLimit" : {
"currency" : "USD",
"issuer" : "rnYDWQaRdMb5neCGgvFfhw3MBoxmv5LtfH",
"value" : "1000"
},
"LowNode" : "0000000000000000"
},
"LedgerEntryType" : "RippleState",
"LedgerIndex" : "CC07E55B7114FAD14663E5BDD16458E3EFA300C2C139E4E0FC9E2635E3D8099E",
"PreviousFields" : {
"Balance" : {
"currency" : "USD",
"issuer" : "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value" : "0"
}
},
"PreviousTxnID" : "8A8DE047F4A1886A2A1E8231AE3D66D162BA0ADD00B781CAAFF946F104474E63",
"PreviousTxnLgrSeq" : 4
}
},
{
"ModifiedNode" : {
"FinalFields" : {
"Balance" : {
"currency" : "USD",
"issuer" : "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value" : "-100"
},
"Flags" : 131072,
"HighLimit" : {
"currency" : "USD",
"issuer" : "rnYDWQaRdMb5neCGgvFfhw3MBoxmv5LtfH",
"value" : "1000"
},
"HighNode" : "0000000000000000",
"LowLimit" : {
"currency" : "USD",
"issuer" : "rrnsYgWn13Z28GtRgznrSUsLfMkvsXCZSu",
"value" : "0"
},
"LowNode" : "0000000000000000"
},
"LedgerEntryType" : "RippleState",
"LedgerIndex" : "FBCA655A6C287E90234BF96E8CF950B8B0DE4438C95F408A0E55D256EA2A8DD1",
"PreviousFields" : {
"Balance" : {
"currency" : "USD",
"issuer" : "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value" : "0"
}
},
"PreviousTxnID" : "CDF04C313E841ACA1103B3E2D360E5EB18236808D281B645A2BC72426FDC8EA6",
"PreviousTxnLgrSeq" : 4
}
},
{
"ModifiedNode" : {
"FinalFields" : {
"Balance" : {
"currency" : "USD",
"issuer" : "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value" : "100"
},
"Flags" : 65536,
"HighLimit" : {
"currency" : "USD",
"issuer" : "rGpeQzUWFu4fMhJHZ1Via5aqFC3A5twZUD",
"value" : "0"
},
"HighNode" : "0000000000000000",
"LowLimit" : {
"currency" : "USD",
"issuer" : "rnYDWQaRdMb5neCGgvFfhw3MBoxmv5LtfH",
"value" : "1000"
},
"LowNode" : "0000000000000000"
},
"LedgerEntryType" : "RippleState",
"LedgerIndex" : "FDBBB8BF83FF697C7F68E67AAA06A9E0774CB2727B53E95E63B6416AF0B1A2A7",
"PreviousFields" : {
"Balance" : {
"currency" : "USD",
"issuer" : "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value" : "0"
}
},
"PreviousTxnID" : "8BF77D4762500ED72F291B19D75489397EBF23D870C975B33B3C114E54F36740",
"PreviousTxnLgrSeq" : 4
}
}
],
"TransactionIndex" : 0,
"TransactionResult" : "tesSUCCESS"
},
"status" : "success",
"validated" : true
}
}
@@ -0,0 +1,83 @@
{
"result" : {
"Account" : "rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK",
"Amount" : {
"currency" : "USD",
"issuer" : "rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK",
"value" : "200"
},
"Destination" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
"Fee" : "10",
"Flags" : 2147483648,
"Sequence" : 3,
"SigningPubKey" : "02691AC5AE1C4C333AE5DF8A93BDC495F0EEBFC6DB0DA7EB6EF808F3AFC006E3FE",
"TransactionType" : "Payment",
"TxnSignature" : "304402207068EDB074FE388DB198A5D3B51A2846BB937F76F558D2D9245B11A20DFD5DAF022055A5B5D65C637A34C48361AFD0E97780D6FAED98A4221CE0838EE3598C0EECDE",
"date" : 472374260,
"hash" : "8EE52E8CC50AB0841A34E755E882BBC50F855A750AC954D7E7050E71672BE77E",
"inLedger" : 8,
"ledger_index" : 8,
"meta" : {
"AffectedNodes" : [
{
"ModifiedNode" : {
"FinalFields" : {
"Balance" : {
"currency" : "USD",
"issuer" : "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value" : "100"
},
"Flags" : 196608,
"HighLimit" : {
"currency" : "USD",
"issuer" : "rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK",
"value" : "500"
},
"HighNode" : "0000000000000000",
"LowLimit" : {
"currency" : "USD",
"issuer" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
"value" : "500"
},
"LowNode" : "0000000000000000"
},
"LedgerEntryType" : "RippleState",
"LedgerIndex" : "88DA36A0E2F92E2E3504DC7936FDB719769486A6BE1BEC4F1E3B580538D28B4A",
"PreviousFields" : {
"Balance" : {
"currency" : "USD",
"issuer" : "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value" : "-100"
}
},
"PreviousTxnID" : "951C7AB715ECF4E2B2254F336D9529783AE924E8B4784884E45EA0697ED78B61",
"PreviousTxnLgrSeq" : 7
}
},
{
"ModifiedNode" : {
"FinalFields" : {
"Account" : "rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK",
"Balance" : "999999970",
"Flags" : 0,
"OwnerCount" : 1,
"Sequence" : 4
},
"LedgerEntryType" : "AccountRoot",
"LedgerIndex" : "DE3BE7FDF6864FB024807B36BFCB4607E7CDA7D4C155C7AFB4B0973D638938BF",
"PreviousFields" : {
"Balance" : "999999980",
"Sequence" : 3
},
"PreviousTxnID" : "8D380F8548020FAF6CD42D0E9EDA92B51D4D7DDC4327644893CA1F24688F3715",
"PreviousTxnLgrSeq" : 6
}
}
],
"TransactionIndex" : 0,
"TransactionResult" : "tesSUCCESS"
},
"status" : "success",
"validated" : true
}
}
@@ -0,0 +1,83 @@
{
"result" : {
"Account" : "rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK",
"Amount" : {
"currency" : "USD",
"issuer" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
"value" : "100"
},
"Destination" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
"Fee" : "10",
"Flags" : 2147483648,
"Sequence" : 2,
"SigningPubKey" : "02691AC5AE1C4C333AE5DF8A93BDC495F0EEBFC6DB0DA7EB6EF808F3AFC006E3FE",
"TransactionType" : "Payment",
"TxnSignature" : "304402205523DC0073C7F7DB92765367526A7A2CF1B6E2A42C6B102E96F58FC69689CBF60220371264F1472C6694F8453506503351B256722274CE1324E2B3B1885C18485D59",
"date" : 472366860,
"hash" : "44AA46A2728AD7A7E856B27D8815D935D174F63CAA60E4BD90C5CC74D440E753",
"inLedger" : 6,
"ledger_index" : 6,
"meta" : {
"AffectedNodes" : [
{
"ModifiedNode" : {
"FinalFields" : {
"Balance" : {
"currency" : "USD",
"issuer" : "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value" : "-100"
},
"Flags" : 131072,
"HighLimit" : {
"currency" : "USD",
"issuer" : "rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK",
"value" : "500"
},
"HighNode" : "0000000000000000",
"LowLimit" : {
"currency" : "USD",
"issuer" : "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh",
"value" : "0"
},
"LowNode" : "0000000000000000"
},
"LedgerEntryType" : "RippleState",
"LedgerIndex" : "88DA36A0E2F92E2E3504DC7936FDB719769486A6BE1BEC4F1E3B580538D28B4A",
"PreviousFields" : {
"Balance" : {
"currency" : "USD",
"issuer" : "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value" : "-200"
}
},
"PreviousTxnID" : "C0AA2D9C82E68C06F81340B633D36EA983A834F6377FA18139D4EE7AA6A2973D",
"PreviousTxnLgrSeq" : 5
}
},
{
"ModifiedNode" : {
"FinalFields" : {
"Account" : "rPMh7Pi9ct699iZUTWaytJUoHcJ7cgyziK",
"Balance" : "999999980",
"Flags" : 0,
"OwnerCount" : 1,
"Sequence" : 3
},
"LedgerEntryType" : "AccountRoot",
"LedgerIndex" : "DE3BE7FDF6864FB024807B36BFCB4607E7CDA7D4C155C7AFB4B0973D638938BF",
"PreviousFields" : {
"Balance" : "999999990",
"Sequence" : 2
},
"PreviousTxnID" : "88CD25B9BF28097156E1EA79281994FFD002EE3D3F67E99ED791C38DA3967CB6",
"PreviousTxnLgrSeq" : 4
}
}
],
"TransactionIndex" : 0,
"TransactionResult" : "tesSUCCESS"
},
"status" : "success",
"validated" : true
}
}
@@ -0,0 +1,124 @@
{
"engine_result": "tesSUCCESS",
"engine_result_code": 0,
"engine_result_message": "The transaction was applied.",
"ledger_hash": "605F02CC71269E0C3253FC582503D0A69533DF9E744F1613CB132A67261527F2",
"ledger_index": 10458307,
"status": "closed",
"type": "transaction",
"validated": true,
"metadata": {
"AffectedNodes": [
{
"ModifiedNode": {
"FinalFields": {
"Balance": {
"currency": "USD",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "1.545330905250352"
},
"Flags": 1114112,
"HighLimit": {
"currency": "USD",
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"value": "0"
},
"HighNode": "00000000000001E8",
"LowLimit": {
"currency": "USD",
"issuer": "rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc",
"value": "1000000000"
},
"LowNode": "0000000000000000"
},
"LedgerEntryType": "RippleState",
"LedgerIndex": "2F323020B4288ACD4066CC64C89DAD2E4D5DFC2D44571942A51C005BF79D6E25",
"PreviousFields": {
"Balance": {
"currency": "USD",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "1.345330905250352"
}
},
"PreviousTxnID": "24525F80080EAC8857F1A29A47AEF23FD2B0A52DAF7DC3900A4E31831187FCB1",
"PreviousTxnLgrSeq": 10443886
}
},
{
"ModifiedNode": {
"FinalFields": {
"Balance": {
"currency": "USD",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "0"
},
"Flags": 1114112,
"HighLimit": {
"currency": "USD",
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"value": "0"
},
"HighNode": "00000000000001E8",
"LowLimit": {
"currency": "USD",
"issuer": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"value": "1000000000"
},
"LowNode": "0000000000000000"
},
"LedgerEntryType": "RippleState",
"LedgerIndex": "AAE13AF5192EFBFD49A8EEE5869595563FEB73228C0B38FED9CC3D20EE74F399",
"PreviousFields": {
"Balance": {
"currency": "USD",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "0.2"
}
},
"PreviousTxnID": "24525F80080EAC8857F1A29A47AEF23FD2B0A52DAF7DC3900A4E31831187FCB1",
"PreviousTxnLgrSeq": 10443886
}
},
{
"ModifiedNode": {
"FinalFields": {
"Account": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"Balance": "99976002",
"Flags": 0,
"OwnerCount": 1,
"Sequence": 3
},
"LedgerEntryType": "AccountRoot",
"LedgerIndex": "C24354B286600B8F28E51233B4AC41A3B4DDD0FDC9BCF96BB171573F6B40A4AE",
"PreviousFields": {
"Balance": "99988002",
"Sequence": 2
},
"PreviousTxnID": "A788447CF5FD7108CBF49416E2335F95ED3F5A9FC016686C8F9EFB34BBEA613A",
"PreviousTxnLgrSeq": 10425088
}
}
],
"TransactionIndex": 3,
"TransactionResult": "tesSUCCESS"
},
"tx_json": {
"Account": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"Amount": {
"currency": "USD",
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"value": "0.2"
},
"Destination": "rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc",
"Fee": "12000",
"Flags": 2147483648,
"LastLedgerSequence": 10458314,
"Sequence": 2,
"SigningPubKey": "039371D0465097AC8F9C02EB60D5599AAD08AADBD623D6D40D642CF2D7C0481B83",
"TransactionType": "Payment",
"TxnSignature": "304502210097A62D87FF08A050F1832B974F06FB4F0C83F6661CC916AE190A439C8DB3863202204CD27C5C6A9067BA5A1DA9BB940FDF3F7C6B073225911E567B1E37E9C29E99D4",
"date": 471639670,
"hash": "5AC7632779C3AE649236F728C2C6811D7ADDE6CCC5018B8754C6EB953FCB1BC5"
}
}
@@ -0,0 +1,123 @@
{
"engine_result": "tesSUCCESS",
"engine_result_code": 0,
"engine_result_message": "The transaction was applied.",
"ledger_hash": "F3F1416BF2E813396AB01FAA38E9F1023AC4D2368D94B0D52B2BC603CEEC01C3",
"ledger_index": 10459371,
"status": "closed",
"type": "transaction",
"validated": true,
"metadata": {
"AffectedNodes": [
{
"ModifiedNode": {
"FinalFields": {
"Balance": {
"currency": "USD",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "1.525330905250352"
},
"Flags": 1114112,
"HighLimit": {
"currency": "USD",
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"value": "0"
},
"HighNode": "00000000000001E8",
"LowLimit": {
"currency": "USD",
"issuer": "rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc",
"value": "1000000000"
},
"LowNode": "0000000000000000"
},
"LedgerEntryType": "RippleState",
"LedgerIndex": "2F323020B4288ACD4066CC64C89DAD2E4D5DFC2D44571942A51C005BF79D6E25",
"PreviousFields": {
"Balance": {
"currency": "USD",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "1.535330905250352"
}
},
"PreviousTxnID": "DC061E6F47B1B6E9A496A31B1AF87194B4CB24B2EBF8A59F35E31E12509238BD",
"PreviousTxnLgrSeq": 10459364
}
},
{
"ModifiedNode": {
"FinalFields": {
"Balance": {
"currency": "USD",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "0.02"
},
"Flags": 1114112,
"HighLimit": {
"currency": "USD",
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"value": "0"
},
"HighNode": "00000000000001E8",
"LowLimit": {
"currency": "USD",
"issuer": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"value": "1000000000"
},
"LowNode": "0000000000000000"
},
"LedgerEntryType": "RippleState",
"LedgerIndex": "AAE13AF5192EFBFD49A8EEE5869595563FEB73228C0B38FED9CC3D20EE74F399",
"PreviousFields": {
"Balance": {
"currency": "USD",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "0.01"
}
},
"PreviousTxnID": "DC061E6F47B1B6E9A496A31B1AF87194B4CB24B2EBF8A59F35E31E12509238BD",
"PreviousTxnLgrSeq": 10459364
}
},
{
"ModifiedNode": {
"FinalFields": {
"Account": "rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc",
"Balance": "239555992",
"Flags": 0,
"OwnerCount": 1,
"Sequence": 38
},
"LedgerEntryType": "AccountRoot",
"LedgerIndex": "E9A39B0BA8703D5FFD05D9EAD01EE6C0E7A15CF33C2C6B7269107BD2BD535818",
"PreviousFields": {
"Balance": "239567992",
"Sequence": 37
},
"PreviousTxnID": "DC061E6F47B1B6E9A496A31B1AF87194B4CB24B2EBF8A59F35E31E12509238BD",
"PreviousTxnLgrSeq": 10459364
}
}
],
"TransactionIndex": 2,
"TransactionResult": "tesSUCCESS"
},
"tx_json": {
"Account": "rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc",
"Amount": {
"currency": "USD",
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"value": "0.01"
},
"Destination": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"Fee": "12000",
"Flags": 2147483648,
"LastLedgerSequence": 10459379,
"Sequence": 37,
"SigningPubKey": "03F16A52EBDCA6EBF5D99828E1E6918C64D45E6F136476A8F4757512FE553D18F0",
"TransactionType": "Payment",
"TxnSignature": "3044022031D6AB55CDFD17E06DA0BAD6D6B7DC9B5CA8FFF50405F2FCD3ED8D3893B1835E02200524CC1E7D70AE3F00C9F94405C55EE179C363F534905168AE8B5BA01CF568A0",
"date": 471644150,
"hash": "34671C179737CC89E0F8BBAA83C313885ED1733488FC0F3088BAE16A3D9A5B1B"
}
}
@@ -0,0 +1,60 @@
{
"engine_result": "tesSUCCESS",
"engine_result_code": 0,
"engine_result_message": "The transaction was applied.",
"ledger_hash": "5FA9BBBE9EF6CE4BF9BB56CC3A70106C1475EA4C02EDE26651710FAA46E81F60",
"ledger_index": 10424084,
"metadata": {
"AffectedNodes": [
{
"CreatedNode": {
"LedgerEntryType": "AccountRoot",
"LedgerIndex": "C24354B286600B8F28E51233B4AC41A3B4DDD0FDC9BCF96BB171573F6B40A4AE",
"NewFields": {
"Account": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"Balance": "100000000",
"Sequence": 1
}
}
},
{
"ModifiedNode": {
"FinalFields": {
"Account": "rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc",
"Balance": "339903994",
"Flags": 0,
"OwnerCount": 0,
"Sequence": 9
},
"LedgerEntryType": "AccountRoot",
"LedgerIndex": "E9A39B0BA8703D5FFD05D9EAD01EE6C0E7A15CF33C2C6B7269107BD2BD535818",
"PreviousFields": {
"Balance": "439915994",
"Sequence": 8
},
"PreviousTxnID": "0E6CF1A13C6A804BE50B08C1D0446C7405D8461254CC6B62337CA9FEA4DF13EC",
"PreviousTxnLgrSeq": 10424064
}
}
],
"TransactionIndex": 3,
"TransactionResult": "tesSUCCESS"
},
"status": "closed",
"transaction": {
"Account": "rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc",
"Amount": "100000000",
"Destination": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"Fee": "12000",
"Flags": 2147483648,
"LastLedgerSequence": 10424091,
"Sequence": 8,
"SigningPubKey": "03F16A52EBDCA6EBF5D99828E1E6918C64D45E6F136476A8F4757512FE553D18F0",
"TransactionType": "Payment",
"TxnSignature": "304402207676FE35FF0D01E01F13531760658ADECC493181A4EF618A970E4C209FC989C102206660147F17B46469864E9E10152844C4DA62363DB70B5F610E6DAEA87A6781A9",
"date": 471490400,
"hash": "43CAAC76C95358CA2F84EA8BF5BFC327B90B21039A3C69EC4EAC7FEDC54CDB9F"
},
"type": "transaction",
"validated": true
}
@@ -0,0 +1,109 @@
{
"engine_result": "tesSUCCESS",
"engine_result_code": 0,
"engine_result_message": "The transaction was applied.",
"ledger_hash": "CA4C25E271FDB00836A091E8073F6692784BEB116B33675533F9511B17FC2B72",
"ledger_index": 10483144,
"status": "closed",
"type": "transaction",
"validated": true,
"metadata": {
"AffectedNodes": [
{
"ModifiedNode": {
"FinalFields": {
"Flags": 0,
"IndexPrevious": "00000000000001F1",
"Owner": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"RootIndex": "6319526CE8F9A8A44D7A870A89DC1B4AD848AA4F066FCB5390A9A268F6E16AEA"
},
"LedgerEntryType": "DirectoryNode",
"LedgerIndex": "58E06162628C5E2292DA172A97573FA5613C4A223810686428BF8431B3D67C58"
}
},
{
"CreatedNode": {
"LedgerEntryType": "DirectoryNode",
"LedgerIndex": "84C8F98961F2F10CB1B5C4FB649C18B05A9D3FC20C3A78B75C86CD30D7EAC39C",
"NewFields": {
"Owner": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"RootIndex": "84C8F98961F2F10CB1B5C4FB649C18B05A9D3FC20C3A78B75C86CD30D7EAC39C"
}
}
},
{
"ModifiedNode": {
"LedgerEntryType": "AccountRoot",
"LedgerIndex": "A3C1529122C3DBD6C96B9DF009FF4896023FE6B4E05A508B1E81F3DCD9A6274B",
"PreviousTxnID": "CA4BD65D1E29552B17041B219105E1BC0FE00837C798DE9F9E2EA670097ACE33",
"PreviousTxnLgrSeq": 10483128
}
},
{
"CreatedNode": {
"LedgerEntryType": "RippleState",
"LedgerIndex": "AAE13AF5192EFBFD49A8EEE5869595563FEB73228C0B38FED9CC3D20EE74F399",
"NewFields": {
"Balance": {
"currency": "USD",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "10"
},
"Flags": 65536,
"HighLimit": {
"currency": "USD",
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"value": "0"
},
"HighNode": "00000000000001F2",
"LowLimit": {
"currency": "USD",
"issuer": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"value": "100"
}
}
}
},
{
"ModifiedNode": {
"FinalFields": {
"Account": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"Balance": "99740302",
"Flags": 0,
"OwnerCount": 1,
"Sequence": 23
},
"LedgerEntryType": "AccountRoot",
"LedgerIndex": "C24354B286600B8F28E51233B4AC41A3B4DDD0FDC9BCF96BB171573F6B40A4AE",
"PreviousFields": {
"Balance": "99752302",
"OwnerCount": 0,
"Sequence": 22
},
"PreviousTxnID": "8A3F4CA1D349B4BE896DFDED6B6D0F0DCA4FCA75E082C30A4175813DDB9BCDA6",
"PreviousTxnLgrSeq": 10482869
}
}
],
"TransactionIndex": 10,
"TransactionResult": "tesSUCCESS"
},
"tx_json": {
"Account": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"Fee": "12000",
"Flags": 2147483648,
"LastLedgerSequence": 10483152,
"LimitAmount": {
"currency": "USD",
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"value": "100"
},
"Sequence": 22,
"SigningPubKey": "039371D0465097AC8F9C02EB60D5599AAD08AADBD623D6D40D642CF2D7C0481B83",
"TransactionType": "TrustSet",
"TxnSignature": "3044022048862FBF688AFFA81E8A08DB08C2559BB5D7E935B5E4597EE6ADF2E901BC9A6402200B7CDBAD2001CB9797AD56E22D9DA1C23F7F5DC1BB8DB22F013DEE78EAC46BE4",
"date": 471748760,
"hash": "8375C1ED96BB4DD66FD697F34755F9B03DB62CD098627B834028728670CF93EF"
}
}
@@ -0,0 +1,157 @@
{
"engine_result": "tesSUCCESS",
"engine_result_code": 0,
"engine_result_message": "The transaction was applied.",
"ledger_hash": "BFD12A293442E8C083A98092C7A8A199A3732B2360643E40BB8704DE3DF8EA5E",
"ledger_index": 10482869,
"status": "closed",
"type": "transaction",
"validated": true,
"metadata": {
"AffectedNodes": [
{
"ModifiedNode": {
"FinalFields": {
"Balance": {
"currency": "USD",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "1.545330905250352"
},
"Flags": 1114112,
"HighLimit": {
"currency": "USD",
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"value": "0"
},
"HighNode": "00000000000001E8",
"LowLimit": {
"currency": "USD",
"issuer": "rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc",
"value": "1000000000"
},
"LowNode": "0000000000000000"
},
"LedgerEntryType": "RippleState",
"LedgerIndex": "2F323020B4288ACD4066CC64C89DAD2E4D5DFC2D44571942A51C005BF79D6E25",
"PreviousFields": {
"Balance": {
"currency": "USD",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "1.525330905250352"
}
},
"PreviousTxnID": "D1B2B5508585E1BB48E1D76629C59F6368AAB9568457D058486DCC4DCAECCE30",
"PreviousTxnLgrSeq": 10482855
}
},
{
"ModifiedNode": {
"FinalFields": {
"Flags": 0,
"IndexPrevious": "00000000000001F1",
"Owner": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"RootIndex": "6319526CE8F9A8A44D7A870A89DC1B4AD848AA4F066FCB5390A9A268F6E16AEA"
},
"LedgerEntryType": "DirectoryNode",
"LedgerIndex": "58E06162628C5E2292DA172A97573FA5613C4A223810686428BF8431B3D67C58"
}
},
{
"DeletedNode": {
"FinalFields": {
"Flags": 0,
"Owner": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"RootIndex": "84C8F98961F2F10CB1B5C4FB649C18B05A9D3FC20C3A78B75C86CD30D7EAC39C"
},
"LedgerEntryType": "DirectoryNode",
"LedgerIndex": "84C8F98961F2F10CB1B5C4FB649C18B05A9D3FC20C3A78B75C86CD30D7EAC39C"
}
},
{
"ModifiedNode": {
"LedgerEntryType": "AccountRoot",
"LedgerIndex": "A3C1529122C3DBD6C96B9DF009FF4896023FE6B4E05A508B1E81F3DCD9A6274B",
"PreviousTxnID": "758E69A2A2F5E7713ACCA70DC82DD89D7B45B9E020A7E19B9312F0C49A8834BA",
"PreviousTxnLgrSeq": 10482869
}
},
{
"DeletedNode": {
"FinalFields": {
"Balance": {
"currency": "USD",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "0"
},
"Flags": 0,
"HighLimit": {
"currency": "USD",
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"value": "0"
},
"HighNode": "00000000000001F2",
"LowLimit": {
"currency": "USD",
"issuer": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"value": "0"
},
"LowNode": "0000000000000000",
"PreviousTxnID": "CA491349DAF4D4EB1E5D2EF1DD4BBC84640C22B4C94C3C9AD40B190151A7878B",
"PreviousTxnLgrSeq": 10482862
},
"LedgerEntryType": "RippleState",
"LedgerIndex": "AAE13AF5192EFBFD49A8EEE5869595563FEB73228C0B38FED9CC3D20EE74F399",
"PreviousFields": {
"Balance": {
"currency": "USD",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "0.02"
},
"Flags": 65536
}
}
},
{
"ModifiedNode": {
"FinalFields": {
"Account": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"Balance": "99752302",
"Flags": 0,
"OwnerCount": 0,
"Sequence": 22
},
"LedgerEntryType": "AccountRoot",
"LedgerIndex": "C24354B286600B8F28E51233B4AC41A3B4DDD0FDC9BCF96BB171573F6B40A4AE",
"PreviousFields": {
"Balance": "99764302",
"OwnerCount": 1,
"Sequence": 21
},
"PreviousTxnID": "CA491349DAF4D4EB1E5D2EF1DD4BBC84640C22B4C94C3C9AD40B190151A7878B",
"PreviousTxnLgrSeq": 10482862
}
}
],
"TransactionIndex": 9,
"TransactionResult": "tesSUCCESS"
},
"tx_json": {
"Account": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"Amount": {
"currency": "USD",
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"value": "0.02"
},
"Destination": "rKmBGxocj9Abgy25J51Mk1iqFzW9aVF9Tc",
"Fee": "12000",
"Flags": 2147483648,
"LastLedgerSequence": 10482877,
"Sequence": 21,
"SigningPubKey": "039371D0465097AC8F9C02EB60D5599AAD08AADBD623D6D40D642CF2D7C0481B83",
"TransactionType": "Payment",
"TxnSignature": "3045022100E718DDE0149F89CF58FAD1847ED7AD9D61D833E07969A71FA7918D2F6D414AAE022041226ADCB68C2B64CA37AAB4C268922F2EE09DFBF8B234B282E9104643C6351D",
"date": 471747550,
"hash": "8A3F4CA1D349B4BE896DFDED6B6D0F0DCA4FCA75E082C30A4175813DDB9BCDA6"
}
}
@@ -0,0 +1,107 @@
{
"Account": "rsApBGKJmMfExxZBrGnzxEXyq7TMhMRg4e",
"Fee": "10",
"Flags": 0,
"LimitAmount": {
"currency": "USD",
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"value": "300"
},
"Sequence": 10,
"SigningPubKey": "0337930D40B5A285B7ABC75574FAEC947D1221ABD0155E0D393223DFDA5A7905B2",
"TransactionType": "TrustSet",
"TxnSignature": "30450221009E1A07D8FD71276D776712EDCD044769C7DB0590FDFA90EC405BBFFA2A5B658402207280B2F1DFDFAEF4A52C14D3EB726CF0520FB2B79B4037C0F5FD0DF9D4166A62",
"date": 424538770,
"hash": "09A89A9DB790C553441637C677FF26D3A606C9EDF688447273B2C0B83D98383C",
"inLedger": 1046325,
"ledger_index": 1046325,
"metadata": {
"AffectedNodes": [
{
"ModifiedNode": {
"FinalFields": {
"Flags": 0,
"Owner": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"RootIndex": "6319526CE8F9A8A44D7A870A89DC1B4AD848AA4F066FCB5390A9A268F6E16AEA"
},
"LedgerEntryType": "DirectoryNode",
"LedgerIndex": "6319526CE8F9A8A44D7A870A89DC1B4AD848AA4F066FCB5390A9A268F6E16AEA"
}
},
{
"CreatedNode": {
"LedgerEntryType": "RippleState",
"LedgerIndex": "791DCC45D985B40DC7E3BFB7394B5287E8027BCFCE07F5A55A2492738724F97B",
"NewFields": {
"Balance": {
"currency": "USD",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "0"
},
"Flags": 65536,
"HighLimit": {
"currency": "USD",
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"value": "0"
},
"LowLimit": {
"currency": "USD",
"issuer": "rsApBGKJmMfExxZBrGnzxEXyq7TMhMRg4e",
"value": "300"
}
}
}
},
{
"ModifiedNode": {
"FinalFields": {
"Account": "rsApBGKJmMfExxZBrGnzxEXyq7TMhMRg4e",
"Balance": "9248902096",
"Flags": 0,
"OwnerCount": 2,
"Sequence": 11
},
"LedgerEntryType": "AccountRoot",
"LedgerIndex": "96E491543BAA99142135D2C304174585C285FA44A2896970BAA66EA460F15479",
"PreviousFields": {
"Balance": "9248902106",
"OwnerCount": 1,
"Sequence": 10
},
"PreviousTxnID": "C6175CC7CF4B4C875DE991AA2812ABA00EE795CE5547FD70023E3B170BD1030F",
"PreviousTxnLgrSeq": 1043147
}
},
{
"ModifiedNode": {
"FinalFields": {
"Account": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"Balance": "149999980",
"Flags": 0,
"OwnerCount": 0,
"Sequence": 3,
"TransferRate": 1002000000
},
"LedgerEntryType": "AccountRoot",
"LedgerIndex": "A3C1529122C3DBD6C96B9DF009FF4896023FE6B4E05A508B1E81F3DCD9A6274B",
"PreviousTxnID": "5F338A7BF4C38633C75BED1672E146898904FC8272B45DA7D188716D998B71C5",
"PreviousTxnLgrSeq": 1045132
}
},
{
"ModifiedNode": {
"FinalFields": {
"Flags": 0,
"Owner": "rsApBGKJmMfExxZBrGnzxEXyq7TMhMRg4e",
"RootIndex": "AB72F278F646031B4531BE7EC45A78F3693B9375BEA7B2A794ECC32742C87843"
},
"LedgerEntryType": "DirectoryNode",
"LedgerIndex": "AB72F278F646031B4531BE7EC45A78F3693B9375BEA7B2A794ECC32742C87843"
}
}
],
"TransactionIndex": 0,
"TransactionResult": "tesSUCCESS"
},
"validated": true
}
@@ -0,0 +1,87 @@
{
"engine_result": "tesSUCCESS",
"engine_result_code": 0,
"engine_result_message": "The transaction was applied.",
"ledger_hash": "BCA3403873155ECFEB616ED9923D94430CB26EA7206CBCC4F86EACE47B33F950",
"ledger_index": 10460919,
"status": "closed",
"type": "transaction",
"validated": true,
"metadata": {
"AffectedNodes": [
{
"ModifiedNode": {
"FinalFields": {
"Balance": {
"currency": "USD",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "0.02"
},
"Flags": 1114112,
"HighLimit": {
"currency": "USD",
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"value": "0"
},
"HighNode": "00000000000001E8",
"LowLimit": {
"currency": "USD",
"issuer": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"value": "0"
},
"LowNode": "0000000000000000"
},
"LedgerEntryType": "RippleState",
"LedgerIndex": "AAE13AF5192EFBFD49A8EEE5869595563FEB73228C0B38FED9CC3D20EE74F399",
"PreviousFields": {
"LowLimit": {
"currency": "USD",
"issuer": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"value": "100"
}
},
"PreviousTxnID": "1BBAC938211E7C2B5A0DD00153557E0A47B38F93AF0F1831C4ECE0E6387B8B96",
"PreviousTxnLgrSeq": 10460914
}
},
{
"ModifiedNode": {
"FinalFields": {
"Account": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"Balance": "99940002",
"Flags": 0,
"OwnerCount": 1,
"Sequence": 6
},
"LedgerEntryType": "AccountRoot",
"LedgerIndex": "C24354B286600B8F28E51233B4AC41A3B4DDD0FDC9BCF96BB171573F6B40A4AE",
"PreviousFields": {
"Balance": "99952002",
"Sequence": 5
},
"PreviousTxnID": "1BBAC938211E7C2B5A0DD00153557E0A47B38F93AF0F1831C4ECE0E6387B8B96",
"PreviousTxnLgrSeq": 10460914
}
}
],
"TransactionIndex": 8,
"TransactionResult": "tesSUCCESS"
},
"tx_json": {
"Account": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"Fee": "12000",
"Flags": 2147483648,
"LastLedgerSequence": 10460926,
"LimitAmount": {
"currency": "USD",
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"value": "0"
},
"Sequence": 5,
"SigningPubKey": "039371D0465097AC8F9C02EB60D5599AAD08AADBD623D6D40D642CF2D7C0481B83",
"TransactionType": "TrustSet",
"TxnSignature": "3045022100CAF0DD8A64B68CC9CD44166A381FE07B69AAC5219BB3E90D5A2BD73FB9919DBA022071BE14E0E8ABB0B1841A7A4D1A983C8AC32CFA0E7C9A45FA3565AE5477C076A8",
"date": 471650760,
"hash": "B836ADBA4D77638C5F8C99B5FC0FC6A92D5F82FF3C90759F44773835BAD2AB86"
}
}
@@ -0,0 +1,88 @@
{
"engine_result": "tesSUCCESS",
"engine_result_code": 0,
"engine_result_message": "The transaction was applied.",
"ledger_hash": "BB1814E087367EB56D7EBF0DB99481291894A53FF8B155511C6CC45D57F42E27",
"ledger_index": 10479523,
"status": "closed",
"type": "transaction",
"validated": true,
"metadata": {
"AffectedNodes": [
{
"ModifiedNode": {
"FinalFields": {
"Balance": {
"currency": "USD",
"issuer": "rrrrrrrrrrrrrrrrrrrrBZbvji",
"value": "0.02"
},
"Flags": 1114112,
"HighLimit": {
"currency": "USD",
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"value": "0"
},
"HighNode": "00000000000001E8",
"LowLimit": {
"currency": "USD",
"issuer": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"value": "200"
},
"LowNode": "0000000000000000"
},
"LedgerEntryType": "RippleState",
"LedgerIndex": "AAE13AF5192EFBFD49A8EEE5869595563FEB73228C0B38FED9CC3D20EE74F399",
"PreviousFields": {
"LowLimit": {
"currency": "USD",
"issuer": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"value": "100"
}
},
"PreviousTxnID": "A9A654F03855FEBD714E49B2C190A62C310081339AA0AA49C38F0B734E81C173",
"PreviousTxnLgrSeq": 10479514
}
},
{
"ModifiedNode": {
"FinalFields": {
"Account": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"Balance": "99884302",
"Flags": 0,
"OwnerCount": 1,
"Sequence": 11
},
"LedgerEntryType": "AccountRoot",
"LedgerIndex": "C24354B286600B8F28E51233B4AC41A3B4DDD0FDC9BCF96BB171573F6B40A4AE",
"PreviousFields": {
"Balance": "99896302",
"Sequence": 10
},
"PreviousTxnID": "BD850F01540CE35B68C1125E2055BBFEEF961D65AEFBC0CE39CF814685144117",
"PreviousTxnLgrSeq": 10479508
}
}
],
"TransactionIndex": 10,
"TransactionResult": "tesSUCCESS"
},
"tx_json": {
"Account": "rLDYrujdKUfVx28T9vRDAbyJ7G2WVXKo4K",
"Fee": "12000",
"Flags": 2147483648,
"LastLedgerSequence": 10479530,
"LimitAmount": {
"currency": "USD",
"issuer": "rMwjYedjc7qqtKYVLiAccJSmCwih4LnE2q",
"value": "200"
},
"Sequence": 10,
"SigningPubKey": "039371D0465097AC8F9C02EB60D5599AAD08AADBD623D6D40D642CF2D7C0481B83",
"TransactionType": "TrustSet",
"TxnSignature": "304502210088A7B69070516F1456AE93CC7189C213E60F1E5276F0FFEB64419CFD3A75FDBA02202E852593523240D5BD59B4DF3FAC97E112F75DF712B07E9C9FC64D824E2E0CB2",
"date": 471732720,
"hash": "9F54793122AD0CF1552A4E76991CB481E6FAD467176976500E11EA76CAC9D9EA"
}
}
@@ -0,0 +1,19 @@
'use strict'
var assert = require('assert-diff')
var fixture = require('./fixtures/payment-iou-multipath.json')
var getAffectedAccounts = require('../src').getAffectedAccounts
var accounts = [
'r4nmQNH4Fhjfh6cHDbvVSsBv7KySbj4cBf',
'rrnsYgWn13Z28GtRgznrSUsLfMkvsXCZSu',
'rJsaPnGdeo7BhMnHjuc3n44Mf7Ra1qkSVJ',
'rGpeQzUWFu4fMhJHZ1Via5aqFC3A5twZUD',
'rnYDWQaRdMb5neCGgvFfhw3MBoxmv5LtfH'
]
describe('getAffectedAccounts', function() {
it('Multipath payment', function() {
var result = getAffectedAccounts(fixture.result.meta)
assert.deepEqual(result, accounts)
})
})
@@ -0,0 +1,40 @@
'use strict'
var assert = require('assert-diff')
var parseOrderbookChanges = require('../src/index').parseOrderbookChanges
var fixtures = require('./fixtures/orderbookchanges.js')
var orderWithExpiration = require('./fixtures/order-with-expiration.json')
var orderWithExpirationResult =
require('./fixtures/order-with-expiration-parsed.json')
describe('parseOrderbookChanges', function() {
it('parse OfferCreate -- consumed and partially consumed offer', function() {
var meta = fixtures.offerCreateConsumedOffer().meta
var expected = fixtures.parsedOfferCreate()
assert.deepEqual(parseOrderbookChanges(meta), expected)
})
it('parse OfferCreate -- created offer', function() {
var meta = fixtures.offerCreateCreatedOffer().meta
var expected = fixtures.parsedOfferCreateCreated()
assert.deepEqual(parseOrderbookChanges(meta), expected)
})
it('parse OfferCancel', function() {
var meta = fixtures.offerCancel().meta
var expected = fixtures.parsedOfferCancel()
assert.deepEqual(parseOrderbookChanges(meta), expected)
})
it('parse OfferCreate -- consumed offer, no changes to TakerGets',
function() {
var meta = fixtures.offerCreateNoChangeTakerGets().meta
var expected = fixtures.parsedOfferCreateNoChangeTakerGets()
assert.deepEqual(parseOrderbookChanges(meta), expected)
})
it('order with expiration', function() {
var meta = orderWithExpiration.meta
var expected = orderWithExpirationResult
assert.deepEqual(parseOrderbookChanges(meta), expected)
})
})