mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Merge branch 'master' of github.com:jedmccaleb/NewCoin
This commit is contained in:
64
bin/debug_local_sign.js
Normal file
64
bin/debug_local_sign.js
Normal file
@@ -0,0 +1,64 @@
|
||||
var ripple = require('../src/js');
|
||||
|
||||
var v = {
|
||||
seed: "snoPBrXtMeMyMHUVTgbuqAfg1SUTb",
|
||||
addr: "rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh"
|
||||
};
|
||||
|
||||
var remote = ripple.Remote.from_config({
|
||||
"trusted" : true,
|
||||
"websocket_ip" : "127.0.0.1",
|
||||
"websocket_port" : 5006,
|
||||
"websocket_ssl" : false,
|
||||
"local_signing" : true
|
||||
});
|
||||
|
||||
var tx_json = {
|
||||
"Account" : v.addr,
|
||||
"Amount" : "10000000",
|
||||
"Destination" : "rEu2ULPiEQm1BAL8pYzmXnNX1aFX9sCks",
|
||||
"Fee" : "10",
|
||||
"Flags" : 0,
|
||||
"Sequence" : 3,
|
||||
"TransactionType" : "Payment"
|
||||
|
||||
//"SigningPubKey": '0396941B22791A448E5877A44CE98434DB217D6FB97D63F0DAD23BE49ED45173C9'
|
||||
};
|
||||
|
||||
remote.on('connected', function () {
|
||||
var req = remote.request_sign(v.seed, tx_json);
|
||||
req.message.debug_signing = true;
|
||||
req.on('success', function (result) {
|
||||
console.log("SERVER RESULT");
|
||||
console.log(result);
|
||||
|
||||
var sim = {};
|
||||
var tx = remote.transaction();
|
||||
tx.tx_json = tx_json;
|
||||
tx._secret = v.seed;
|
||||
tx.complete();
|
||||
var unsigned = tx.serialize().to_hex();
|
||||
tx.sign();
|
||||
|
||||
sim.tx_blob = tx.serialize().to_hex();
|
||||
sim.tx_json = tx.tx_json;
|
||||
sim.tx_signing_hash = tx.signing_hash().to_hex();
|
||||
sim.tx_unsigned = unsigned;
|
||||
|
||||
console.log("\nLOCAL RESULT");
|
||||
console.log(sim);
|
||||
|
||||
remote.connect(false);
|
||||
});
|
||||
req.on('error', function (err) {
|
||||
if (err.error === "remoteError" && err.remote.error === "srcActNotFound") {
|
||||
console.log("Please fund account "+v.addr+" to run this test.");
|
||||
} else {
|
||||
console.log('error', err);
|
||||
}
|
||||
remote.connect(false);
|
||||
});
|
||||
req.request();
|
||||
|
||||
});
|
||||
remote.connect();
|
||||
@@ -130,7 +130,11 @@ Base.decode_check = function (version, input, alphabet) {
|
||||
if (computed[i] !== checksum[i])
|
||||
return NaN;
|
||||
|
||||
return new BigInteger(buffer.slice(1, -4));
|
||||
// We'll use the version byte to add a leading zero, this ensures JSBN doesn't
|
||||
// intrepret the value as a negative number
|
||||
buffer[0] = 0;
|
||||
|
||||
return new BigInteger(buffer.slice(0, -4), 256);
|
||||
}
|
||||
|
||||
exports.Base = Base;
|
||||
|
||||
20
test/base58-test.js
Normal file
20
test/base58-test.js
Normal file
@@ -0,0 +1,20 @@
|
||||
var buster = require("buster");
|
||||
|
||||
var Seed = require("../src/js/seed").Seed;
|
||||
|
||||
var config = require('../src/js/config').load(require('./config'));
|
||||
|
||||
buster.testCase("Base58", {
|
||||
"Seed" : {
|
||||
"saESc82Vun7Ta5EJRzGJbrXb5HNYk" : function () {
|
||||
var seed = Seed.from_json("saESc82Vun7Ta5EJRzGJbrXb5HNYk");
|
||||
buster.assert.equals(seed.to_hex(), "FF1CF838D02B2CF7B45BAC27F5F24F4F");
|
||||
},
|
||||
"sp6iDHnmiPN7tQFHm5sCW59ax3hfE" : function () {
|
||||
var seed = Seed.from_json("sp6iDHnmiPN7tQFHm5sCW59ax3hfE");
|
||||
buster.assert.equals(seed.to_hex(), "00AD8DA764C3C8AF5F9B8D51C94B9E49");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// vim:sw=2:sts=2:ts=8:et
|
||||
24
test/sign-test.js
Normal file
24
test/sign-test.js
Normal file
@@ -0,0 +1,24 @@
|
||||
var buster = require("buster");
|
||||
|
||||
var Seed = require("../src/js/seed").Seed;
|
||||
|
||||
var config = require('../src/js/config').load(require('./config'));
|
||||
|
||||
buster.testCase("Signing", {
|
||||
"Keys" : {
|
||||
"SigningPubKey 1 (ripple-client issue #245)" : function () {
|
||||
var seed = Seed.from_json("saESc82Vun7Ta5EJRzGJbrXb5HNYk");
|
||||
var key = seed.get_key("rBZ4j6MsoctipM6GEyHSjQKzXG3yambDnZ");
|
||||
var pub = key.to_hex_pub();
|
||||
buster.assert.equals(pub, "0396941B22791A448E5877A44CE98434DB217D6FB97D63F0DAD23BE49ED45173C9");
|
||||
},
|
||||
"SigningPubKey 2 (master seed)" : function () {
|
||||
var seed = Seed.from_json("snoPBrXtMeMyMHUVTgbuqAfg1SUTb");
|
||||
var key = seed.get_key("rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh");
|
||||
var pub = key.to_hex_pub();
|
||||
buster.assert.equals(pub, "0330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A313222F7FD020");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// vim:sw=2:sts=2:ts=8:et
|
||||
Reference in New Issue
Block a user