mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 12:15:51 +00:00
BREAKING CHANGE: Use ripple-binary-codec
This commit is contained in:
36
npm-shrinkwrap.json
generated
36
npm-shrinkwrap.json
generated
@@ -132,6 +132,42 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"ripple-binary-codec": {
|
||||||
|
"version": "0.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/ripple-binary-codec/-/ripple-binary-codec-0.0.5.tgz",
|
||||||
|
"dependencies": {
|
||||||
|
"bn.js": {
|
||||||
|
"version": "3.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-3.2.0.tgz"
|
||||||
|
},
|
||||||
|
"create-hash": {
|
||||||
|
"version": "1.1.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/create-hash/-/create-hash-1.1.2.tgz",
|
||||||
|
"dependencies": {
|
||||||
|
"cipher-base": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/cipher-base/-/cipher-base-1.0.1.tgz"
|
||||||
|
},
|
||||||
|
"ripemd160": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/ripemd160/-/ripemd160-1.0.1.tgz"
|
||||||
|
},
|
||||||
|
"sha.js": {
|
||||||
|
"version": "2.4.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/sha.js/-/sha.js-2.4.4.tgz"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"decimal.js": {
|
||||||
|
"version": "4.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-4.0.3.tgz"
|
||||||
|
},
|
||||||
|
"inherits": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"ripple-keypairs": {
|
"ripple-keypairs": {
|
||||||
"version": "0.9.0",
|
"version": "0.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/ripple-keypairs/-/ripple-keypairs-0.9.0.tgz",
|
"resolved": "https://registry.npmjs.org/ripple-keypairs/-/ripple-keypairs-0.9.0.tgz",
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
"lodash": "^3.1.0",
|
"lodash": "^3.1.0",
|
||||||
"lru-cache": "~2.5.0",
|
"lru-cache": "~2.5.0",
|
||||||
"ripple-address-codec": "^2.0.1",
|
"ripple-address-codec": "^2.0.1",
|
||||||
|
"ripple-binary-codec": "^0.0.5",
|
||||||
"ripple-keypairs": "^0.9.0",
|
"ripple-keypairs": "^0.9.0",
|
||||||
"ripple-lib-transactionparser": "^0.5.1",
|
"ripple-lib-transactionparser": "^0.5.1",
|
||||||
"ripple-lib-value": "0.1.0",
|
"ripple-lib-value": "0.1.0",
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
const keypairs = require('ripple-keypairs');
|
const keypairs = require('ripple-keypairs');
|
||||||
const core = utils.common.core;
|
const binary = require('ripple-binary-codec');
|
||||||
|
const sha512 = require('hash.js').sha512;
|
||||||
const validate = utils.common.validate;
|
const validate = utils.common.validate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,20 +18,22 @@ const validate = utils.common.validate;
|
|||||||
*/
|
*/
|
||||||
const HASH_TX_ID = 0x54584E00; // 'TXN'
|
const HASH_TX_ID = 0x54584E00; // 'TXN'
|
||||||
|
|
||||||
function serialize(txJSON) {
|
// For a hash function, rippled uses SHA-512 and then truncates the result
|
||||||
return core.SerializedObject.from_json(txJSON);
|
// to the first 256 bytes. This algorithm, informally called SHA-512Half,
|
||||||
|
// provides an output that has comparable security to SHA-256, but runs
|
||||||
|
// faster on 64-bit processors.
|
||||||
|
function sha512half(buffer) {
|
||||||
|
return sha512().update(buffer).digest('hex').toUpperCase().slice(0, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
function hashSerialization(serialized, prefix) {
|
function hashSerialization(serialized, prefix) {
|
||||||
return serialized.hash(prefix || HASH_TX_ID).to_hex();
|
const hexPrefix = prefix.toString(16).toUpperCase();
|
||||||
}
|
return sha512half(new Buffer(hexPrefix + serialized, 'hex'));
|
||||||
|
|
||||||
function signingData(txJSON) {
|
|
||||||
return core.Transaction.from_json(txJSON).signingData().buffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function computeSignature(txJSON, privateKey) {
|
function computeSignature(txJSON, privateKey) {
|
||||||
return keypairs.sign(signingData(txJSON), privateKey);
|
const signingData = binary.encodeForSigning(txJSON);
|
||||||
|
return keypairs.sign(new Buffer(signingData, 'hex'), privateKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sign(txJSON: string, secret: string
|
function sign(txJSON: string, secret: string
|
||||||
@@ -44,9 +47,9 @@ function sign(txJSON: string, secret: string
|
|||||||
tx.SigningPubKey = keypair.publicKey;
|
tx.SigningPubKey = keypair.publicKey;
|
||||||
}
|
}
|
||||||
tx.TxnSignature = computeSignature(tx, keypair.privateKey);
|
tx.TxnSignature = computeSignature(tx, keypair.privateKey);
|
||||||
const serialized = serialize(tx);
|
const serialized = binary.encode(tx);
|
||||||
return {
|
return {
|
||||||
signedTransaction: serialized.to_hex(),
|
signedTransaction: serialized,
|
||||||
id: hashSerialization(serialized, HASH_TX_ID)
|
id: hashSerialization(serialized, HASH_TX_ID)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ exports._test = {
|
|||||||
UInt128: require('./uint128').UInt128,
|
UInt128: require('./uint128').UInt128,
|
||||||
UInt160: require('./uint160').UInt160,
|
UInt160: require('./uint160').UInt160,
|
||||||
UInt256: require('./uint256').UInt256,
|
UInt256: require('./uint256').UInt256,
|
||||||
|
OrderbookUtils: require('./orderbookutils'),
|
||||||
constants: require('./constants')
|
constants: require('./constants')
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ Ledger.prototype.calc_tx_hash = function() {
|
|||||||
const meta = SerializedObject.from_json(tx_json.metaData);
|
const meta = SerializedObject.from_json(tx_json.metaData);
|
||||||
|
|
||||||
const data = new SerializedObject();
|
const data = new SerializedObject();
|
||||||
stypes.VariableLength.serialize(data, tx.serialize().to_hex());
|
stypes.VariableLength.serialize(data, tx.serialize());
|
||||||
stypes.VariableLength.serialize(data, meta.to_hex());
|
stypes.VariableLength.serialize(data, meta.to_hex());
|
||||||
tx_map.add_item(tx.hash(), data, SHAMapTreeNode.TYPE_TRANSACTION_MD);
|
tx_map.add_item(tx.hash(), data, SHAMapTreeNode.TYPE_TRANSACTION_MD);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,11 +3,10 @@
|
|||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
const constants = require('./constants');
|
const constants = require('./constants');
|
||||||
const SerializedObject = require('./serializedobject').SerializedObject;
|
|
||||||
const Types = require('./serializedtypes');
|
|
||||||
const Amount = require('./amount').Amount;
|
const Amount = require('./amount').Amount;
|
||||||
const Currency = require('./currency').Currency;
|
const Currency = require('./currency').Currency;
|
||||||
const {IOUValue} = require('ripple-lib-value');
|
const {IOUValue} = require('ripple-lib-value');
|
||||||
|
const binary = require('ripple-binary-codec');
|
||||||
const OrderBookUtils = {};
|
const OrderBookUtils = {};
|
||||||
|
|
||||||
function assertValidNumber(number, message) {
|
function assertValidNumber(number, message) {
|
||||||
@@ -143,11 +142,7 @@ OrderBookUtils.getOfferQuality = function(offer, currencyGets, currency_,
|
|||||||
|
|
||||||
OrderBookUtils.convertOfferQualityToHex = function(quality) {
|
OrderBookUtils.convertOfferQualityToHex = function(quality) {
|
||||||
assert(quality instanceof Amount, 'Quality is not an amount');
|
assert(quality instanceof Amount, 'Quality is not an amount');
|
||||||
|
return OrderBookUtils.convertOfferQualityToHex(quality.to_text());
|
||||||
const so = new SerializedObject();
|
|
||||||
Types.Quality.serialize(so, quality.to_text());
|
|
||||||
|
|
||||||
return so.to_hex();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -160,14 +155,9 @@ OrderBookUtils.convertOfferQualityToHex = function(quality) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
OrderBookUtils.convertOfferQualityToHexFromText = function(quality) {
|
OrderBookUtils.convertOfferQualityToHexFromText = function(quality) {
|
||||||
|
return binary.encodeQuality(quality);
|
||||||
const so = new SerializedObject();
|
|
||||||
Types.Quality.serialize(so, quality);
|
|
||||||
|
|
||||||
return so.to_hex();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
OrderBookUtils.CURRENCY_ONE = Currency.from_json(1);
|
OrderBookUtils.CURRENCY_ONE = Currency.from_json(1);
|
||||||
|
|
||||||
OrderBookUtils.ISSUER_ONE = constants.ACCOUNT_ONE;
|
OrderBookUtils.ISSUER_ONE = constants.ACCOUNT_ONE;
|
||||||
|
|||||||
@@ -9,11 +9,11 @@ const utils = require('./utils');
|
|||||||
const sjclcodec = require('sjcl-codec');
|
const sjclcodec = require('sjcl-codec');
|
||||||
const Amount = require('./amount').Amount;
|
const Amount = require('./amount').Amount;
|
||||||
const Currency = require('./currency').Currency;
|
const Currency = require('./currency').Currency;
|
||||||
const SerializedObject = require('./serializedobject').SerializedObject;
|
|
||||||
const RippleError = require('./rippleerror').RippleError;
|
const RippleError = require('./rippleerror').RippleError;
|
||||||
const hashprefixes = require('./hashprefixes');
|
const hashprefixes = require('./hashprefixes');
|
||||||
const log = require('./log').internal.sub('transaction');
|
const log = require('./log').internal.sub('transaction');
|
||||||
const {isValidAddress, decodeAddress} = require('ripple-address-codec');
|
const {isValidAddress, decodeAddress} = require('ripple-address-codec');
|
||||||
|
const binary = require('ripple-binary-codec');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor Transaction
|
* @constructor Transaction
|
||||||
@@ -451,7 +451,7 @@ Transaction.prototype.setCanonicalFlag = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Transaction.prototype.serialize = function() {
|
Transaction.prototype.serialize = function() {
|
||||||
return SerializedObject.from_json(this.tx_json);
|
return binary.encode(this.tx_json);
|
||||||
};
|
};
|
||||||
|
|
||||||
Transaction.prototype.signingHash = function(testnet) {
|
Transaction.prototype.signingHash = function(testnet) {
|
||||||
@@ -459,22 +459,16 @@ Transaction.prototype.signingHash = function(testnet) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Transaction.prototype.signingData = function() {
|
Transaction.prototype.signingData = function() {
|
||||||
const so = new SerializedObject();
|
return binary.encodeForSigning(this.tx_json);
|
||||||
so.append(hashprefixes.HASH_TX_SIGN_BYTES);
|
|
||||||
so.parse_json(this.tx_json);
|
|
||||||
return so;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Transaction.prototype.multiSigningData = function(account) {
|
Transaction.prototype.multiSigningData = function(account) {
|
||||||
const so = new SerializedObject();
|
return binary.encodeForMultisigning(this.tx_json, account);
|
||||||
so.append(hashprefixes.HASH_TX_MULTISIGN_BYTES);
|
|
||||||
so.parse_json(this.tx_json);
|
|
||||||
so.append(decodeAddress(account));
|
|
||||||
return so;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Transaction.prototype.hash = function(prefix_, asUINT256, serialized) {
|
Transaction.prototype.hash = function(prefix_, serialized_) {
|
||||||
let prefix;
|
let prefix;
|
||||||
|
assert(serialized_ === undefined || _.isString(serialized_));
|
||||||
|
|
||||||
if (typeof prefix_ !== 'string') {
|
if (typeof prefix_ !== 'string') {
|
||||||
prefix = hashprefixes.HASH_TX_ID;
|
prefix = hashprefixes.HASH_TX_ID;
|
||||||
@@ -484,9 +478,9 @@ Transaction.prototype.hash = function(prefix_, asUINT256, serialized) {
|
|||||||
prefix = hashprefixes[prefix_];
|
prefix = hashprefixes[prefix_];
|
||||||
}
|
}
|
||||||
|
|
||||||
const hash = (serialized || this.serialize()).hash(prefix);
|
const hexPrefix = prefix.toString(16).toUpperCase();
|
||||||
|
const serialized = serialized_ || this.serialize();
|
||||||
return asUINT256 ? hash : hash.to_hex();
|
return utils.sha512half(new Buffer(hexPrefix + serialized, 'hex'));
|
||||||
};
|
};
|
||||||
|
|
||||||
Transaction.prototype.sign = function(secret) {
|
Transaction.prototype.sign = function(secret) {
|
||||||
@@ -505,7 +499,7 @@ Transaction.prototype.sign = function(secret) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const keypair = deriveKeypair(secret || this._secret);
|
const keypair = deriveKeypair(secret || this._secret);
|
||||||
this.tx_json.TxnSignature = sign(this.signingData().buffer,
|
this.tx_json.TxnSignature = sign(new Buffer(this.signingData(), 'hex'),
|
||||||
keypair.privateKey);
|
keypair.privateKey);
|
||||||
this.previousSigningHash = hash;
|
this.previousSigningHash = hash;
|
||||||
|
|
||||||
@@ -1654,7 +1648,7 @@ Transaction.prototype.multiSign = function(account, secret) {
|
|||||||
|
|
||||||
const signer = {
|
const signer = {
|
||||||
Account: account,
|
Account: account,
|
||||||
TxnSignature: sign(signingData.buffer, keypair.privateKey),
|
TxnSignature: sign(new Buffer(signingData, 'hex'), keypair.privateKey),
|
||||||
SigningPubKey: keypair.publicKey
|
SigningPubKey: keypair.publicKey
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -524,9 +524,9 @@ TransactionManager.prototype._prepareRequest = function(tx) {
|
|||||||
tx.sign();
|
tx.sign();
|
||||||
|
|
||||||
const serialized = tx.serialize();
|
const serialized = tx.serialize();
|
||||||
submitRequest.txBlob(serialized.to_hex());
|
submitRequest.txBlob(serialized);
|
||||||
|
|
||||||
const hash = tx.hash(null, null, serialized);
|
const hash = tx.hash(null, serialized);
|
||||||
tx.addId(hash);
|
tx.addId(hash);
|
||||||
} else {
|
} else {
|
||||||
if (tx.hasMultiSigners()) {
|
if (tx.hasMultiSigners()) {
|
||||||
|
|||||||
@@ -1,4 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
const sha512 = require('hash.js').sha512;
|
||||||
|
|
||||||
|
// For a hash function, rippled uses SHA-512 and then truncates the result
|
||||||
|
// to the first 256 bytes. This algorithm, informally called SHA-512Half,
|
||||||
|
// provides an output that has comparable security to SHA-256, but runs
|
||||||
|
// faster on 64-bit processors.
|
||||||
|
function sha512half(buffer) {
|
||||||
|
return sha512().update(buffer).digest('hex').toUpperCase().slice(0, 64);
|
||||||
|
}
|
||||||
|
|
||||||
// returns the mantissa from the passed in string,
|
// returns the mantissa from the passed in string,
|
||||||
// adding zeros until it has 16 sd
|
// adding zeros until it has 16 sd
|
||||||
@@ -21,7 +30,7 @@ function getMantissaDecimalString(bignum) {
|
|||||||
|
|
||||||
function trace(comment, func) {
|
function trace(comment, func) {
|
||||||
return function() {
|
return function() {
|
||||||
console.log('%s: %s', trace, arguments.toString);
|
console.log('%s: %s', comment, arguments.toString);
|
||||||
func(arguments);
|
func(arguments);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -112,7 +121,8 @@ function assert(assertion, msg) {
|
|||||||
* @return {Array} unique values (for string representation of value) in `arr`
|
* @return {Array} unique values (for string representation of value) in `arr`
|
||||||
*/
|
*/
|
||||||
function arrayUnique(arr) {
|
function arrayUnique(arr) {
|
||||||
const u = {}, a = [];
|
const u = {};
|
||||||
|
const a = [];
|
||||||
|
|
||||||
for (let i = 0, l = arr.length; i < l; i++) {
|
for (let i = 0, l = arr.length; i < l; i++) {
|
||||||
const k = arr[i];
|
const k = arr[i];
|
||||||
@@ -151,6 +161,7 @@ exports.time = {
|
|||||||
toRipple: fromTimestamp
|
toRipple: fromTimestamp
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.sha512half = sha512half;
|
||||||
exports.trace = trace;
|
exports.trace = trace;
|
||||||
exports.arraySet = arraySet;
|
exports.arraySet = arraySet;
|
||||||
exports.hexToString = hexToString;
|
exports.hexToString = hexToString;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"hash": "f8f337dee5d5b238a10af4a4d56926ba26c83ee7af5a5a6474340c56f9252df3",
|
"hash": "F8F337DEE5D5B238A10AF4A4D56926BA26C83EE7AF5A5A6474340C56F9252DF3",
|
||||||
"date": "2015-08-12T01:01:10+00:00",
|
"date": "2015-08-12T01:01:10+00:00",
|
||||||
"ledger_index": 15202439,
|
"ledger_index": 15202439,
|
||||||
"tx": {
|
"tx": {
|
||||||
@@ -60,7 +60,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"hash": "f8d5de632b1d8b64e577c46912cce483d6df4fd4e2cf4a3d586a099de3b27021",
|
"hash": "F8D5DE632B1D8B64E577C46912CCE483D6DF4FD4E2CF4A3D586A099DE3B27021",
|
||||||
"date": "2015-08-12T01:01:10+00:00",
|
"date": "2015-08-12T01:01:10+00:00",
|
||||||
"ledger_index": 15202439,
|
"ledger_index": 15202439,
|
||||||
"tx": {
|
"tx": {
|
||||||
@@ -120,7 +120,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"hash": "e9004490a92413e92dacd621ac73fd434a8950c350f7572ffeaf4d6aaf8fc288",
|
"hash": "E9004490A92413E92DACD621AC73FD434A8950C350F7572FFEAF4D6AAF8FC288",
|
||||||
"date": "2015-08-12T01:01:10+00:00",
|
"date": "2015-08-12T01:01:10+00:00",
|
||||||
"ledger_index": 15202439,
|
"ledger_index": 15202439,
|
||||||
"tx": {
|
"tx": {
|
||||||
@@ -180,7 +180,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"hash": "d44bff924d23211b82b8f604af6d92f260f8dd13103a96f03e48825c4a978fd6",
|
"hash": "D44BFF924D23211B82B8F604AF6D92F260F8DD13103A96F03E48825C4A978FD6",
|
||||||
"date": "2015-08-12T01:01:10+00:00",
|
"date": "2015-08-12T01:01:10+00:00",
|
||||||
"ledger_index": 15202439,
|
"ledger_index": 15202439,
|
||||||
"tx": {
|
"tx": {
|
||||||
@@ -240,7 +240,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"hash": "c978d915bfb17687335cbfc4b207d9e7213bcee35b468c2eee016cdce4edb6e4",
|
"hash": "C978D915BFB17687335CBFC4B207D9E7213BCEE35B468C2EEE016CDCE4EDB6E4",
|
||||||
"date": "2015-08-12T01:01:10+00:00",
|
"date": "2015-08-12T01:01:10+00:00",
|
||||||
"ledger_index": 15202439,
|
"ledger_index": 15202439,
|
||||||
"tx": {
|
"tx": {
|
||||||
@@ -372,7 +372,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"hash": "31b34fd7c90cdc6cf680a814debc6f616c69275c0e99711f904de088a8ed4b28",
|
"hash": "31B34FD7C90CDC6CF680A814DEBC6F616C69275C0E99711F904DE088A8ED4B28",
|
||||||
"date": "2015-08-12T01:01:10+00:00",
|
"date": "2015-08-12T01:01:10+00:00",
|
||||||
"ledger_index": 15202439,
|
"ledger_index": 15202439,
|
||||||
"tx": {
|
"tx": {
|
||||||
@@ -412,7 +412,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"hash": "260bc2964ffe6d81cb25c152f8054ffb2ce6ed04ff89d8d0d0559bc14bef0e46",
|
"hash": "260BC2964FFE6D81CB25C152F8054FFB2CE6ED04FF89D8D0D0559BC14BEF0E46",
|
||||||
"date": "2015-08-12T01:01:10+00:00",
|
"date": "2015-08-12T01:01:10+00:00",
|
||||||
"ledger_index": 15202439,
|
"ledger_index": 15202439,
|
||||||
"tx": {
|
"tx": {
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ const _ = require('lodash');
|
|||||||
const assert = require('assert-diff');
|
const assert = require('assert-diff');
|
||||||
const Remote = require('ripple-lib').Remote;
|
const Remote = require('ripple-lib').Remote;
|
||||||
const Currency = require('ripple-lib').Currency;
|
const Currency = require('ripple-lib').Currency;
|
||||||
|
const OrderbookUtils = require('ripple-lib')._test.OrderbookUtils;
|
||||||
const addresses = require('./fixtures/addresses');
|
const addresses = require('./fixtures/addresses');
|
||||||
const fixtures = require('./fixtures/orderbook');
|
const fixtures = require('./fixtures/orderbook');
|
||||||
const IOUValue = require('ripple-lib-value').IOUValue;
|
const IOUValue = require('ripple-lib-value').IOUValue;
|
||||||
@@ -843,4 +844,14 @@ describe('OrderBook Autobridging', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('convertOfferQualityToHexFromText', function() {
|
||||||
|
const bookDirectory =
|
||||||
|
'4627DFFCFF8B5A265EDBD8AE8C14A52325DBFEDAF4F5C32E5D06F4C3362FE1D0';
|
||||||
|
const quality = '195796912.5171664';
|
||||||
|
assert.strictEqual(
|
||||||
|
OrderbookUtils.convertOfferQualityToHexFromText(quality),
|
||||||
|
bookDirectory.slice(-16)
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -345,7 +345,7 @@ describe('Transaction', function() {
|
|||||||
remote.setSecret(src, addresses.SECRET);
|
remote.setSecret(src, addresses.SECRET);
|
||||||
|
|
||||||
assert(transaction.complete());
|
assert(transaction.complete());
|
||||||
const json = transaction.serialize().to_json();
|
const json = transaction.serialize();
|
||||||
assert.notStrictEqual(json.Fee, '66500000', 'Fee == 66500000, i.e. 66.5 XRP!');
|
assert.notStrictEqual(json.Fee, '66500000', 'Fee == 66500000, i.e. 66.5 XRP!');
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -584,7 +584,7 @@ describe('Transaction', function() {
|
|||||||
SigningPubKey: '021FED5FD081CE5C4356431267D04C6E2167E4112C897D5E10335D4E22B4DA49ED',
|
SigningPubKey: '021FED5FD081CE5C4356431267D04C6E2167E4112C897D5E10335D4E22B4DA49ED',
|
||||||
Account: 'rMWwx3Ma16HnqSd4H6saPisihX9aKpXxHJ',
|
Account: 'rMWwx3Ma16HnqSd4H6saPisihX9aKpXxHJ',
|
||||||
Flags: 0,
|
Flags: 0,
|
||||||
Fee: 10,
|
Fee: '10',
|
||||||
Sequence: 1,
|
Sequence: 1,
|
||||||
TransactionType: 'AccountSet'
|
TransactionType: 'AccountSet'
|
||||||
};
|
};
|
||||||
@@ -602,10 +602,9 @@ describe('Transaction', function() {
|
|||||||
const tx = Transaction.from_json(tx_json);
|
const tx = Transaction.from_json(tx_json);
|
||||||
const data = tx.signingData();
|
const data = tx.signingData();
|
||||||
|
|
||||||
assert.strictEqual(data.hash().to_json(),
|
assert.strictEqual(tx.signingHash(), expectedSigningHash);
|
||||||
expectedSigningHash);
|
|
||||||
|
|
||||||
assert.strictEqual(data.to_hex(),
|
assert.strictEqual(data,
|
||||||
('535458001200032200000000240000000168400000000000000' +
|
('535458001200032200000000240000000168400000000000000' +
|
||||||
'A7321021FED5FD081CE5C4356431267D04C6E2167E4112C897D' +
|
'A7321021FED5FD081CE5C4356431267D04C6E2167E4112C897D' +
|
||||||
'5E10335D4E22B4DA49ED8114E0E6E281CA324AEE034B2BB8AC9' +
|
'5E10335D4E22B4DA49ED8114E0E6E281CA324AEE034B2BB8AC9' +
|
||||||
@@ -619,7 +618,7 @@ describe('Transaction', function() {
|
|||||||
transaction.tx_json.SigningPubKey = '021FED5FD081CE5C4356431267D04C6E2167E4112C897D5E10335D4E22B4DA49ED';
|
transaction.tx_json.SigningPubKey = '021FED5FD081CE5C4356431267D04C6E2167E4112C897D5E10335D4E22B4DA49ED';
|
||||||
transaction.tx_json.Account = 'rMWwx3Ma16HnqSd4H6saPisihX9aKpXxHJ';
|
transaction.tx_json.Account = 'rMWwx3Ma16HnqSd4H6saPisihX9aKpXxHJ';
|
||||||
transaction.tx_json.Flags = 0;
|
transaction.tx_json.Flags = 0;
|
||||||
transaction.tx_json.Fee = 10;
|
transaction.tx_json.Fee = '10';
|
||||||
transaction.tx_json.Sequence = 1;
|
transaction.tx_json.Sequence = 1;
|
||||||
transaction.tx_json.TransactionType = 'AccountSet';
|
transaction.tx_json.TransactionType = 'AccountSet';
|
||||||
|
|
||||||
@@ -634,7 +633,7 @@ describe('Transaction', function() {
|
|||||||
transaction.tx_json.SigningPubKey = '021FED5FD081CE5C4356431267D04C6E2167E4112C897D5E10335D4E22B4DA49ED';
|
transaction.tx_json.SigningPubKey = '021FED5FD081CE5C4356431267D04C6E2167E4112C897D5E10335D4E22B4DA49ED';
|
||||||
transaction.tx_json.Account = 'rMWwx3Ma16HnqSd4H6saPisihX9aKpXxHJ';
|
transaction.tx_json.Account = 'rMWwx3Ma16HnqSd4H6saPisihX9aKpXxHJ';
|
||||||
transaction.tx_json.Flags = 0;
|
transaction.tx_json.Flags = 0;
|
||||||
transaction.tx_json.Fee = 10;
|
transaction.tx_json.Fee = '10';
|
||||||
transaction.tx_json.Sequence = 1;
|
transaction.tx_json.Sequence = 1;
|
||||||
transaction.tx_json.TransactionType = 'AccountSet';
|
transaction.tx_json.TransactionType = 'AccountSet';
|
||||||
|
|
||||||
@@ -650,7 +649,7 @@ describe('Transaction', function() {
|
|||||||
transaction.tx_json.SigningPubKey = '021FED5FD081CE5C4356431267D04C6E2167E4112C897D5E10335D4E22B4DA49ED';
|
transaction.tx_json.SigningPubKey = '021FED5FD081CE5C4356431267D04C6E2167E4112C897D5E10335D4E22B4DA49ED';
|
||||||
transaction.tx_json.Account = 'rMWwx3Ma16HnqSd4H6saPisihX9aKpXxHJ';
|
transaction.tx_json.Account = 'rMWwx3Ma16HnqSd4H6saPisihX9aKpXxHJ';
|
||||||
transaction.tx_json.Flags = 0;
|
transaction.tx_json.Flags = 0;
|
||||||
transaction.tx_json.Fee = 10;
|
transaction.tx_json.Fee = '10';
|
||||||
transaction.tx_json.Sequence = 1;
|
transaction.tx_json.Sequence = 1;
|
||||||
transaction.tx_json.TransactionType = 'AccountSet';
|
transaction.tx_json.TransactionType = 'AccountSet';
|
||||||
|
|
||||||
@@ -840,7 +839,7 @@ describe('Transaction', function() {
|
|||||||
|
|
||||||
const transaction = Transaction.from_json(input_json);
|
const transaction = Transaction.from_json(input_json);
|
||||||
|
|
||||||
assert.deepEqual(transaction.serialize().to_hex(), expected_hex);
|
assert.deepEqual(transaction.serialize(), expected_hex);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Sign transaction', function(done) {
|
it('Sign transaction', function(done) {
|
||||||
@@ -849,7 +848,7 @@ describe('Transaction', function() {
|
|||||||
transaction.tx_json.SigningPubKey = '021FED5FD081CE5C4356431267D04C6E2167E4112C897D5E10335D4E22B4DA49ED';
|
transaction.tx_json.SigningPubKey = '021FED5FD081CE5C4356431267D04C6E2167E4112C897D5E10335D4E22B4DA49ED';
|
||||||
transaction.tx_json.Account = 'rMWwx3Ma16HnqSd4H6saPisihX9aKpXxHJ';
|
transaction.tx_json.Account = 'rMWwx3Ma16HnqSd4H6saPisihX9aKpXxHJ';
|
||||||
transaction.tx_json.Flags = 0;
|
transaction.tx_json.Flags = 0;
|
||||||
transaction.tx_json.Fee = 10;
|
transaction.tx_json.Fee = '10';
|
||||||
transaction.tx_json.Sequence = 1;
|
transaction.tx_json.Sequence = 1;
|
||||||
transaction.tx_json.TransactionType = 'AccountSet';
|
transaction.tx_json.TransactionType = 'AccountSet';
|
||||||
|
|
||||||
@@ -2261,7 +2260,8 @@ describe('Transaction', function() {
|
|||||||
const abytes = decodeAddress(a1);
|
const abytes = decodeAddress(a1);
|
||||||
const prefix = require('ripple-lib')._test.HashPrefixes.HASH_TX_MULTISIGN_BYTES;
|
const prefix = require('ripple-lib')._test.HashPrefixes.HASH_TX_MULTISIGN_BYTES;
|
||||||
|
|
||||||
assert.deepEqual(d1.buffer, prefix.concat(tbytes, abytes));
|
assert.deepEqual(new Buffer(d1, 'hex'),
|
||||||
|
new Buffer(prefix.concat(tbytes, abytes)));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Multisign', function() {
|
it('Multisign', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user