-
Notifications
You must be signed in to change notification settings - Fork 0
/
signsubmit.js
72 lines (60 loc) · 2.07 KB
/
signsubmit.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// ******************** GET ALGORITHM ********
function getAlgo() {
let algo;
if (document.getElementById("secp").checked) algo = "secp256k1";
if (document.getElementById("ed").checked) algo = "ed25519";
return algo;
} // End of getAlgo()
// ******************** SIGN TRANSACTION OFFLINE ********
async function sign1() {
let algo = getAlgo();
const wallet = xrpl.Wallet.fromSeed(standbySeedField.value, {
algorithm: algo,
});
const payload1 = document.getElementById("payloadField").value;
console.log(payload1);
const txJSON = JSON.parse(payload1);
const signed = wallet.sign(txJSON);
console.log("tx blob is:", signed.tx_blob);
console.log("tx hash is:", signed.hash);
standbyResultField.value =
"tx blob is: " + signed.tx_blob + "\ntx hash is: \n" + signed.hash;
} // End of sign1()
async function reload() {
window.location.reload();
}
// ************* GET NETWORK **************
function getNet() {
let net;
if (document.getElementById("tn").checked)
net = "wss://s.altnet.rippletest.net:51233";
if (document.getElementById("dn").checked)
net = "wss://s.devnet.rippletest.net:51233";
if (document.getElementById("mn").checked) net = "wss://xrplcluster.com";
return net;
} // End of getNet()
// ******************** SUBMIT TRANSACTION ONLINE ********
async function submit1() {
let net = getNet();
standbyResultField1.value = "Connecting to " + getNet() + "....";
const client = new xrpl.Client(net);
await client.connect();
const submitonline = await client.submit(txblobField.value);
console.log(submitonline);
document.getElementById("standbyResultField1").value =
"Results:" +
"\nAccepted: " +
submitonline.result.accepted +
"\nEngine_result: " +
submitonline.result.engine_result +
"\nEngine_result_message: " +
submitonline.result.engine_result_message +
`\nValidated_ledger_index: ` +
submitonline.result.validated_ledger_index +
"\nHash: " +
submitonline.result.tx_json.hash;
client.disconnect();
} // End of submit1()
async function reload2() {
window.location.reload();
}