├── src ├── unused │ ├── messenger_credits.js │ ├── otc_listener_config.js │ ├── async_test.html │ ├── big_int_test.js │ ├── secrets.js │ ├── async_test.js │ ├── total_coins.js │ ├── lost_channel_state.js │ ├── channels_interface.js │ ├── active_oracles.js │ ├── active_oracles.html │ ├── explorer_title.js │ ├── add.js │ ├── channels_lookup.js │ ├── add_modifications.js │ ├── delete_account_tx.js │ ├── binary_id.js │ ├── loop.js │ ├── lightning.js │ ├── channel_with_server.html │ ├── otc_finisher_old.html │ ├── teach_binary_contract.js │ ├── binary_derivative.js │ ├── otc_finisher.html │ ├── otc_listener.html │ ├── new_contract.js │ ├── uniswap.html │ ├── otc_derivatives.html │ ├── unused.js │ ├── trading.html │ ├── resolve_binary_contract.js │ ├── wallet.html │ └── binary_contract_winnings.js ├── js │ ├── explorers │ │ ├── recent_oracle_explorer.html │ │ ├── jobs_explorer.html │ │ ├── block_explorer.html │ │ ├── account_explorer.html │ │ ├── market_explorer.html │ │ ├── explorer.html │ │ ├── oracle_explorer.html │ │ ├── tx_explorer.html │ │ ├── contracts_list.html │ │ ├── contract_explorer.html │ │ ├── recent_oracle_explorer.js │ │ ├── oracles_by_stake_explorer.js │ │ ├── block_explorer.js │ │ ├── lookup_account.js │ │ ├── jobs_explorer.js │ │ ├── lookup.html │ │ ├── offer_explorer.html │ │ ├── account_explorer.js │ │ └── lookup_block.js │ ├── vm │ │ ├── example2 │ │ ├── example │ │ └── example3 │ ├── favicon.ico │ ├── logo_512x512.png │ ├── scraper_example.html │ ├── crypto │ │ ├── crypto.js │ │ └── codecBytes.js │ ├── verkle │ │ ├── hash.js │ │ ├── ed.js │ │ ├── multi_exponent.js │ │ ├── codecBytes.js │ │ ├── test.html │ │ ├── binary.js │ │ ├── finite_inverse.js │ │ ├── precomputes.js │ │ ├── main.js │ │ └── fq.js │ ├── verkle_original │ │ ├── hash.js │ │ ├── ed.js │ │ ├── multi_exponent.js │ │ ├── binary.js │ │ ├── codecBytes.js │ │ ├── test.html │ │ ├── precomputes.js │ │ ├── finite_inverse.js │ │ ├── main.js │ │ └── fq.js │ ├── glossary.js │ ├── glossary2.js │ ├── files.js │ ├── market_id_test.js │ ├── peer_scan.html │ ├── recent_oracles.html │ ├── oracles_by_stake.html │ ├── wallet_tests.js │ ├── market_liquidity_balance.js │ ├── sell_veo_contract.js │ ├── oracle_close.js │ ├── oracle_winnings.js │ ├── scraper_example.js │ ├── sign_tx.js │ ├── oracles_by_stake_explorer.js │ ├── height.js │ ├── peer_scan.js │ ├── rpc.js │ ├── check_binary_contract.js │ ├── subcurrency_spender.js │ ├── market_liquidity.js │ ├── oracle_bet.js │ ├── server.js │ ├── encryption_interface.js │ ├── subcurrency_balance.js │ ├── scalar_id.js │ ├── teach_scalar_contract.js │ ├── sub_accounts.js │ ├── market_swap.js │ ├── market_viewer.js │ ├── encryption.html │ ├── wallet │ │ ├── create_binary_tab_builder.js │ │ ├── create_scalar_tab_builder.js │ │ └── spend_tab_builder.js │ ├── create_account_tx.js │ ├── scalar_derivative.js │ ├── txs.html │ ├── employment.html │ ├── examples │ │ └── functions.js │ ├── oracle_bet.html │ ├── oracle_close.html │ ├── subcurrency_combiner.js │ ├── new_oracle.html │ ├── simplified_scalar_oracle_creation.js │ ├── subcurrency_set_buy.js │ ├── new_scalar_contract.js │ ├── oracle_winnings.html │ ├── publish_swap_offer.js │ ├── scalar_oracle_creation.js │ ├── home.html │ └── new_market.js ├── light_node_app.erl ├── light_node_sup.erl └── light_node.app.src ├── rebar.config ├── rebar3 ├── .gitignore └── README.md /src/unused/messenger_credits.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/unused/otc_listener_config.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/js/explorers/recent_oracle_explorer.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /rebar.config: -------------------------------------------------------------------------------- 1 | {erl_opts, [debug_info]}. 2 | {deps, []}. -------------------------------------------------------------------------------- /rebar3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zack-bitcoin/light-node-amoveo/HEAD/rebar3 -------------------------------------------------------------------------------- /src/js/vm/example2: -------------------------------------------------------------------------------- 1 | 2 | macro test_macro 3 4 5 ; 3 | 4 | test_macro 1234 test_macro -------------------------------------------------------------------------------- /src/js/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zack-bitcoin/light-node-amoveo/HEAD/src/js/favicon.ico -------------------------------------------------------------------------------- /src/js/logo_512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zack-bitcoin/light-node-amoveo/HEAD/src/js/logo_512x512.png -------------------------------------------------------------------------------- /src/unused/async_test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/js/scraper_example.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/unused/big_int_test.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var A = bigInt(100); 3 | var D = bigInt(6);//can also be 5. 4 | var B = A.times(D); 5 | var C = B.toJSNumber(); 6 | console.log(C); 7 | })(); 8 | -------------------------------------------------------------------------------- /src/light_node_app.erl: -------------------------------------------------------------------------------- 1 | -module(light_node_app). 2 | -behaviour(application). 3 | -export([start/2, stop/1]). 4 | start(_StartType, _StartArgs) -> 5 | light_node_sup:start_link(). 6 | stop(_State) -> 7 | ok. 8 | -------------------------------------------------------------------------------- /src/js/crypto/crypto.js: -------------------------------------------------------------------------------- 1 | function hash(input) {//array of bytes -- array of bytes 2 | var b = sjcl.codec.bytes.toBits(input); 3 | var x = sjcl.hash.sha256.hash(b); 4 | return sjcl.codec.bytes.fromBits(x); 5 | } 6 | -------------------------------------------------------------------------------- /src/js/verkle/hash.js: -------------------------------------------------------------------------------- 1 | function verkle_hash(input) {//array of bytes -- array of bytes 2 | var b = sjcl.codec.bytes.toBits(input); 3 | var x = sjcl.hash.sha256.hash(b); 4 | return sjcl.codec.bytes.fromBits(x); 5 | } 6 | -------------------------------------------------------------------------------- /src/js/verkle_original/hash.js: -------------------------------------------------------------------------------- 1 | function hash(input) {//array of bytes -- array of bytes 2 | var b = sjcl.codec.bytes.toBits(input); 3 | var x = sjcl.hash.sha256.hash(b); 4 | return sjcl.codec.bytes.fromBits(x); 5 | } 6 | -------------------------------------------------------------------------------- /src/light_node_sup.erl: -------------------------------------------------------------------------------- 1 | -module(light_node_sup). 2 | -behaviour(supervisor). 3 | -export([start_link/0]). 4 | -export([init/1]). 5 | -define(SERVER, ?MODULE). 6 | start_link() -> 7 | supervisor:start_link({local, ?SERVER}, ?MODULE, []). 8 | init([]) -> 9 | {ok, { {one_for_all, 0, 1}, []} }. 10 | -------------------------------------------------------------------------------- /src/unused/secrets.js: -------------------------------------------------------------------------------- 1 | var secrets = (function () { 2 | var db = {}; 3 | function add(code, ss, amount){ 4 | db[code] = [ss, amount]; 5 | } 6 | function dump() { 7 | db = {}; 8 | } 9 | function read() { 10 | return db[code]; 11 | } 12 | return {add: add, dump: dump, read: read}; 13 | })(); 14 | -------------------------------------------------------------------------------- /src/unused/async_test.js: -------------------------------------------------------------------------------- 1 | async function test1(){ 2 | console.log("test1"); 3 | return(5); 4 | }; 5 | 6 | async function test2(){ 7 | const x = await test1(); 8 | const y = await test1(); 9 | let z = await test1(); 10 | 11 | console.log(x); 12 | console.log(y); 13 | console.log(z); 14 | }; 15 | test2(); 16 | -------------------------------------------------------------------------------- /src/light_node.app.src: -------------------------------------------------------------------------------- 1 | {application, light_node, 2 | [{description, "An OTP application"}, 3 | {vsn, "0.1.0"}, 4 | {registered, []}, 5 | {mod, { light_node_app, []}}, 6 | {applications, 7 | [kernel, 8 | stdlib 9 | ]}, 10 | {env,[]}, 11 | {modules, []}, 12 | 13 | {maintainers, []}, 14 | {licenses, ["Apache 2.0"]}, 15 | {links, []} 16 | ]}. -------------------------------------------------------------------------------- /src/js/vm/example: -------------------------------------------------------------------------------- 1 | 2 | % awk 110 141 142 143 111 2 0 0 0 32 143 80 67 73 12 149 186 163 179 3 166 116 31 227 36 53 231 250 186 151 24 4 92 196 9 50 145 169 227 7 84 21 3 | % js "110,141,142,143,111,2,0,0,0,32,196,216,166,112,46,54,133,106,134,24,138,243,173,141,194,50,38,101,88,151,75,226,189,10,121,81,184,90,123,190,178,27" 4 | 5 | % js: 114, 141, 142, 143, 111 6 | : nums 1 2 3 ; 7 | nums -------------------------------------------------------------------------------- /src/js/glossary.js: -------------------------------------------------------------------------------- 1 | var glossary = (function(){ 2 | function helper(div, name) { 3 | var x = document.createElement("a"); 4 | x.innerHTML = "(?)"; 5 | x.href = "https://github.com/zack-bitcoin/amoveo/tree/master/docs/light_node/glossary/".concat(name).concat(".md"); 6 | x.target = "_blank"; 7 | div.appendChild(x); 8 | }; 9 | return {link: helper} 10 | })(); 11 | -------------------------------------------------------------------------------- /src/unused/total_coins.js: -------------------------------------------------------------------------------- 1 | var total_coins = document.createElement("div"); 2 | total_coins.id = "total_coins"; 3 | document.body.appendChild(total_coins); 4 | function total_coins_f(x) { 5 | var h = document.getElementById("total_coins"); 6 | console.log(x); 7 | b = (x).toString(); 8 | h.innerHTML = "current total coins: ".concat(b); 9 | } 10 | rpc.post(["total_coins"], function(x) {total_coins_f(x)}); 11 | -------------------------------------------------------------------------------- /src/js/glossary2.js: -------------------------------------------------------------------------------- 1 | var glossary = (function(){ 2 | function helper(div, name) { 3 | return helper2(div, name, "(?)"); 4 | }; 5 | function helper2(div, name, s) { 6 | var x = document.createElement("a"); 7 | x.innerHTML = s; 8 | x.href = "https://github.com/zack-bitcoin/amoveo/tree/master/docs/light_node/glossary/".concat(name).concat(".md"); 9 | x.target = "_blank"; 10 | // div.appendChild(x); 11 | }; 12 | return {link: helper, link2: helper2} 13 | })(); 14 | -------------------------------------------------------------------------------- /src/unused/lost_channel_state.js: -------------------------------------------------------------------------------- 1 | (function otc_function() { 2 | var fee = 152050; 3 | var div = document.createElement("div"); 4 | document.body.appendChild(div); 5 | var status = document.createElement("p"); 6 | status.innerHTML = "status: ready"; 7 | div.appendChild(status); 8 | var cid = text_input("channel id: ", div); 9 | div.appendChild(br()); 10 | var our_balance = text_input("The total veo you will receive from this channel: ", div); 11 | div.appendChild(br()); 12 | 13 | })(); 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .edts 3 | *.iml 4 | _build 5 | /rel/ 6 | *.db 7 | *~ 8 | .#* 9 | \#* 10 | .rebar 11 | erl_crash.dump 12 | keys_backup 13 | lib/ 14 | bin/ 15 | .Python 16 | include/ 17 | *.pyc 18 | nosetests.xml 19 | pip-selfcheck.json 20 | config/*/sys.config 21 | man 22 | compile_commands.json 23 | deps/* 24 | rebar.lock 25 | .DS_Store 26 | .rebar3 27 | _* 28 | .eunit 29 | *.o 30 | *.beam 31 | *.plt 32 | *.swp 33 | *.swo 34 | .erlang.cookie 35 | ebin 36 | log 37 | erl_crash.dump 38 | .rebar 39 | logs 40 | _build 41 | .idea 42 | *.iml 43 | rebar3.crashdump -------------------------------------------------------------------------------- /src/unused/channels_interface.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var refresh_channels_button = button_maker2("refresh channels interfaces. Useful if you swich channel servers", function() { 3 | rpc.post(["pubkey"], function(pubkey) { 4 | channels_object.load_button.onchange = function() {return channels_object.load_channels(pubkey) }; 5 | return channels_object.refresh(pubkey); 6 | }); 7 | }); 8 | var div = document.createElement("div"); 9 | document.body.appendChild(div); 10 | div.appendChild(refresh_channels_button); 11 | })(); 12 | -------------------------------------------------------------------------------- /src/js/verkle/ed.js: -------------------------------------------------------------------------------- 1 | var ed = (function(){ 2 | var Order = fq.order(); 3 | var EllipticGroupOrder = 7237005577332262213973186563042994240857116359379907606001950938285454250989n;//order of the elliptic curve group ed25519, div 8. 4 | var Extended = nobleEd25519.ExtendedPoint; 5 | var Point = nobleEd25519.Point; 6 | 7 | function add(a, b){ 8 | return(a.add(b)); 9 | }; 10 | function mul(a, b){ 11 | //b is the scalar 12 | return(a.multiplyUnsafe(b)); 13 | }; 14 | return({ 15 | add: add, 16 | mul: mul 17 | }); 18 | })(); 19 | -------------------------------------------------------------------------------- /src/js/verkle_original/ed.js: -------------------------------------------------------------------------------- 1 | var ed = (function(){ 2 | var Order = fq.order(); 3 | var EllipticGroupOrder = 7237005577332262213973186563042994240857116359379907606001950938285454250989n;//order of the elliptic curve group ed25519, div 8. 4 | var Extended = nobleEd25519.ExtendedPoint; 5 | var Point = nobleEd25519.Point; 6 | 7 | function add(a, b){ 8 | return(a.add(b)); 9 | }; 10 | function mul(a, b){ 11 | //b is the scalar 12 | return(a.multiplyUnsafe(b)); 13 | }; 14 | return({ 15 | add: add, 16 | mul: mul 17 | }); 18 | })(); 19 | -------------------------------------------------------------------------------- /src/js/files.js: -------------------------------------------------------------------------------- 1 | function download(data, filename, type) { 2 | var file = new Blob([data], {type: type}); 3 | if (window.navigator.msSaveOrOpenBlob) // IE10+ 4 | window.navigator.msSaveOrOpenBlob(file, filename); 5 | else { // Others 6 | var a = document.createElement("a"), 7 | url = URL.createObjectURL(file); 8 | a.href = url; 9 | a.download = filename; 10 | document.body.appendChild(a); 11 | a.click(); 12 | setTimeout(function() { 13 | document.body.removeChild(a); 14 | window.URL.revokeObjectURL(url); 15 | }, 0); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/unused/active_oracles.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var div = document.createElement("div"); 3 | document.body.appendChild(div); 4 | rpc.post(["oracle_list", 2], function(X) { 5 | //console.log(JSON.stringify(X)); 6 | return display_oracles(X.slice(1)); 7 | }); 8 | function display_oracles(L) { 9 | if ((JSON.stringify(L)) == "[]") { 10 | return []; 11 | } 12 | var L1 = L[0]; 13 | var p = document.createElement("p"); 14 | p.innerHTML = ("").concat(L1[2][1]).concat(" ").concat(atob(L1[1])); 15 | div.appendChild(p); 16 | return display_oracles(L.slice(1)); 17 | }; 18 | })(); 19 | -------------------------------------------------------------------------------- /src/js/explorers/jobs_explorer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Amoveo - Job Explorer

6 | main menu for this light node.
7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/js/explorers/block_explorer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Amoveo - Block Explorer

6 | main menu for this light node.
7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/js/market_id_test.js: -------------------------------------------------------------------------------- 1 | var market_id_test = function(){ 2 | 3 | async function test(){ 4 | var cid = "/RXSnfzNwbWPIfVKrfaHvW+rxc+4FucrL52+X9DlAgM="; 5 | var contract = await rpc.apost( 6 | ["contracts", cid]); 7 | var SourceCID = contract[8]; 8 | var SourceType = contract[9]; 9 | console.log(JSON.stringify([SourceCID, SourceType])); 10 | var mid1 = new_market.mid(SourceCID, cid, SourceType, 1); 11 | var mid2 = new_market.mid(SourceCID, cid, SourceType, 2); 12 | var mid3 = new_market.mid(cid, cid, 1, 2); 13 | console.log(JSON.stringify([mid1, mid2, mid3])); 14 | }; 15 | 16 | return({ 17 | test:test 18 | }); 19 | }(); 20 | -------------------------------------------------------------------------------- /src/js/explorers/account_explorer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Amoveo - Account Explorer

6 | main menu for this light node.
7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/js/explorers/market_explorer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Amoveo - Market Explorer

6 | main menu for this light node.
7 | 8 | 9 | 10 |
11 |
12 | 13 | 14 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/js/peer_scan.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Light Wallet - Scan Peers - Amoveo

7 | main menu for this light node.
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/js/recent_oracles.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Amoveo - Recent Oracle

6 | main menu for this light node.
7 | oracles by stake
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/js/oracles_by_stake.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Amoveo - Oracles by Stake

6 | main menu for this light node.
7 | recent_oracles
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/unused/active_oracles.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Amoveo oracles explorer - home

6 | Here is a light node tool in your browser, you can use it to make derivatives for any of these oracles 7 |
8 | Return to the page for exploring available P2P derivative bets. 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | -------------------------------------------------------------------------------- /src/js/explorers/explorer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 |

Blockchain Explorer Amoveo

9 | github 10 |

11 | home 12 |

13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/js/explorers/oracle_explorer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Amoveo - Oracle Explorer

6 | main menu for this light node.
7 | recent_oracles.
8 | oracles by stake
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/js/explorers/tx_explorer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Amoveo - Tx Explorer

6 | main menu for this light node.
7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/unused/explorer_title.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var title = document.createElement("h1"); 3 | title.innerHTML = "Blockchain Explorer Amoveo"; 4 | document.body.appendChild(title); 5 | 6 | var github = document.createElement("p"); 7 | github.innerHTML = "home page"; 8 | document.body.appendChild(github); 9 | 10 | var reddit = document.createElement("p"); 11 | reddit.innerHTML = ("discuss on reddit"); 12 | document.body.appendChild(reddit); 13 | 14 | var wallet = document.createElement("p"); 15 | wallet.innerHTML = ("").concat("Wallet on same server").concat(""); 16 | document.body.appendChild(wallet); 17 | 18 | var blockchain_title = document.createElement("h3"); 19 | blockchain_title.innerHTML = "blockchain "; 20 | document.body.appendChild(blockchain_title); 21 | })(); 22 | -------------------------------------------------------------------------------- /src/js/wallet_tests.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | /* 3 | tabs.create.website("qtrade.io"); 4 | tabs.create.amount("0.01"); 5 | tabs.create.ticker("BTC"); 6 | tabs.create.starting_price("0.0035"); 7 | tabs.create.coll("1.1"); 8 | */ 9 | tabs.tabs.create_futarchy.tab.oracle_text("Amoveo's block reward is above 0.2 VEO on January 1st 2021."); 10 | tabs.tabs.create_futarchy.tab.probability_text("0.1"); 11 | tabs.tabs.create_futarchy.tab.amount_text("0.1"); 12 | tabs.tabs.create_futarchy.tab.scalar_amounts_text("0.1"); 13 | tabs.tabs.create_futarchy.tab.scalar_oracle_text("The price of VEO in USD according to qtrade on January 15th 2021. get the btc/usd part of the price conversion from coinmarketcap."); 14 | tabs.tabs.create_futarchy.tab.true_guess_text("20"); 15 | tabs.tabs.create_futarchy.tab.false_guess_text("30"); 16 | tabs.tabs.create_futarchy.tab.min_text("10"); 17 | tabs.tabs.create_futarchy.tab.max_text("50"); 18 | })(); 19 | -------------------------------------------------------------------------------- /src/js/explorers/contracts_list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Amoveo - Contracts List

6 | main menu for this light node.
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/js/verkle/multi_exponent.js: -------------------------------------------------------------------------------- 1 | var multi_exponent = (function(){ 2 | 3 | function remove_zero_terms(rs, gs){ 4 | var rs2 = []; 5 | var gs2 = []; 6 | for(var i = 0; iready"; 7 | div.appendChild(status); 8 | var oid_element = text_input("oid: ", div); 9 | div.appendChild(br()); 10 | var button = button_maker2("close the oracle", function(){ 11 | return make_bet(oid_element.value); 12 | }); 13 | div.appendChild(button); 14 | div.appendChild(br()); 15 | async function make_bet(oid) { 16 | var from = keys.pub(); 17 | var acc = await rpc.apost(["account", from]); 18 | var nonce = acc[2] + 1; 19 | var tx = ["oracle_close", from, nonce, fee, oid]; 20 | var stx = keys.sign(tx); 21 | var txs = [stx]; 22 | var x = await rpc.apost(["txs", [-6].concat(txs)]); 23 | status.innerHTML = "status: successfully attempted to make a oracle_close tx."; 24 | return 0; 25 | }; 26 | })(); 27 | -------------------------------------------------------------------------------- /src/js/verkle_original/binary.js: -------------------------------------------------------------------------------- 1 | 2 | function string_to_array(x) { 3 | var a = new Uint8Array(x.length); 4 | for (var i=0; i>> 24); 20 | tmp <<= 8; 21 | } 22 | return out; 23 | }, 24 | /** Convert from an array of bytes to a bitArray. */ 25 | toBits: function (bytes) { 26 | var out = [], i, tmp=0; 27 | for (i=0; i>> 24); 20 | tmp <<= 8; 21 | } 22 | return out; 23 | }, 24 | /** Convert from an array of bytes to a bitArray. */ 25 | toBits: function (bytes) { 26 | var out = [], i, tmp=0; 27 | for (i=0; i>> 24); 20 | tmp <<= 8; 21 | } 22 | return out; 23 | }, 24 | /** Convert from an array of bytes to a bitArray. */ 25 | toBits: function (bytes) { 26 | var out = [], i, tmp=0; 27 | for (i=0; iready"; 7 | div.appendChild(status); 8 | var oid_element = text_input("oid: ", div); 9 | div.appendChild(br()); 10 | var button = button_maker2("publish tx", function(){ 11 | return make_bet(oid_element.value); 12 | }); 13 | div.appendChild(button); 14 | div.appendChild(br()); 15 | async function make_bet(oid) { 16 | var from = keys.pub(); 17 | var acc = await rpc.apost(["account", from]); 18 | var nonce = acc[2] + 1; 19 | var tx = ["oracle_winnings", from, nonce, fee, oid]; 20 | var tx2 = ["unmatched", from, nonce+1, fee, oid]; 21 | var stx = keys.sign(tx); 22 | var stx2 = keys.sign(tx2); 23 | var msg1 = await apost_txs([stx]); 24 | status.innerHTML = msg1; 25 | var msg2 = await apost_txs([stx2]); 26 | status.innerHTML = msg1 27 | .concat("
") 28 | .concat(msg2); 29 | }; 30 | })(); 31 | -------------------------------------------------------------------------------- /src/js/verkle/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/js/verkle_original/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/js/explorers/contract_explorer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Amoveo - Contract Explorer

6 | main menu for this light node.
7 | a list of Amoveo contracts
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 19 | 20 |

chart of price and liquidity over time

21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/unused/add.js: -------------------------------------------------------------------------------- 1 | (function add() { 2 | var div = document.createElement("div"); 3 | // document.body.appendChild(div); 4 | var status = document.createElement("p"); 5 | status.innerHTML = "add offer status: ready"; 6 | // div.appendChild(status); 7 | // div.appendChild(br()); 8 | var contract = text_input("channel offer: ", div); 9 | // div.appendChild(br()); 10 | //var question_text = text_input("if the oracle does not yet exist, put the question text here: ", div); 11 | //div.appendChild(br()); 12 | //var expires = text_input("if the oracle does not yet exist, put the height when it becomes possible to trade here: ", div); 13 | //div.appendChild(br()); 14 | var Button = button_maker2("publish the channel offer", publish); 15 | // div.appendChild(Button); 16 | function publish() { 17 | status.innerHTML = "add offer status: failed"; 18 | var c = JSON.parse(contract.value); 19 | //c = c.concat([[-7, 20 | // btoa(question_text.value), 21 | // parseInt(expires.value)]]); 22 | rpc.post(["add", c], function(X) { 23 | status.innerHTML = "add offer status: successfully posted a trade"; 24 | }); 25 | }; 26 | })(); 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Amoveo light node 2 | ======== 3 | 4 | This is a light node for the Amoveo cryptocurrency. 5 | 6 | [Click this link to download a zip file of the light node](https://github.com/zack-bitcoin/light-node-amoveo/archive/master.zip) 7 | 8 | To connect to the mainnet with the light node, open src/js/home.html in a browser. 9 | 10 | here is a list of full nodes that you can download headers from: [here](http://64.227.21.70:8080/peer_scan.html) 11 | put the IP address of a full node into the light node so it knows where to download headers from. 12 | 13 | This is the IP of a full node that I maintain: 64.227.21.70 14 | 15 | It is easier, but less secure, to access the light node from [this link](http://64.227.21.70:8080/home.html) 16 | 17 | Trade Explorer 18 | ======== 19 | 20 | To connect to the mainnet with the trade explorer, open src/js/main.html in a browser. Usually just double clicking main.html works. 21 | 22 | "My positions" will only show positions that are in a block. until then, you will see an unconfirmed negative balance so you know the trade was successfully sent out. press "show" to see your positions after the unconfirmed balance disappears. 23 | 24 | A small percentage of your winnings will pay someone else to settle your trade, so you don't have to do anything after you accept. this is customizable. 25 | 26 | for now, the trades you see will be winner-take-all. 27 | 28 | -------------------------------------------------------------------------------- /src/js/verkle_original/precomputes.js: -------------------------------------------------------------------------------- 1 | var precomputes = (function(){ 2 | function range(a, b){ 3 | //exclusive of b. 4 | if(a >= b){return([]);}; 5 | return([BigInt(a)].concat(range(a+1, b))); 6 | }; 7 | function calc_domain(many){ 8 | return(range(1, many+1)); 9 | }; 10 | 11 | var cached_domain; 12 | function domain(){ 13 | if(cached_domain){ 14 | return(cached_domain); 15 | }; 16 | var x = calc_domain(256); 17 | cached_domain = x; 18 | return(x); 19 | }; 20 | 21 | var cached_da; 22 | function da(){ 23 | if(cached_da){ 24 | return(cached_da); 25 | }; 26 | var x = poly.calc_da(domain()); 27 | cached_da = x; 28 | return(x); 29 | }; 30 | 31 | var cached_a; 32 | function a(){ 33 | if(cached_a){ 34 | return(cached_a); 35 | }; 36 | var x = poly.calc_a(domain()); 37 | cached_a = x; 38 | return(x); 39 | }; 40 | 41 | var cached_ghq; 42 | function ghq(){ 43 | if(cached_ghq){ 44 | return(cached_ghq); 45 | }; 46 | var x = points.basis(256); 47 | cached_ghq = x; 48 | return(x); 49 | }; 50 | 51 | return({ 52 | ghq: ghq, 53 | da: da, 54 | a: a, 55 | domain: domain 56 | }); 57 | })(); 58 | -------------------------------------------------------------------------------- /src/js/explorers/recent_oracle_explorer.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | var div = document.createElement("div"); 3 | document.body.appendChild(div); 4 | server_port.value = "8080"; 5 | if (server_ip.value == "") { 6 | server_ip.value = default_ip(); 7 | }; 8 | div.appendChild(br()); 9 | (async function(){ 10 | var oracles = await rpc.apost(["oracles", 3], get_ip(), 8091); 11 | oracles = oracles.slice(1); 12 | loop(oracles); 13 | })(); 14 | 15 | function loop(oracles) { 16 | if(oracles.length === 0){ 17 | return(0); 18 | }; 19 | oracle = oracles[0]; 20 | var height = oracle[2]; 21 | var question = atob(oracle[4]); 22 | var closed = oracle[7]; 23 | var info = document.createElement("div"); 24 | info.innerHTML = "oracle asks: " 25 | .concat(question) 26 | .concat("
last referenced in block height: ") 27 | .concat(height.toString()); 28 | div.appendChild(info); 29 | 30 | link = document.createElement("a"); 31 | link.href = "oracle_explorer.html?oid=" 32 | .concat(oracle[1]); 33 | link.innerHTML = "view details"; 34 | link.target = "_blank"; 35 | div.appendChild(link); 36 | div.appendChild(br()); 37 | div.appendChild(br()); 38 | loop(oracles.slice(1)); 39 | }; 40 | })(); 41 | -------------------------------------------------------------------------------- /src/js/scraper_example.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | 3 | 4 | (async () => { 5 | var response = await fetch('https://www.sportsbookreview.com/betting-odds/'); 6 | switch (response.status) { 7 | // status "OK" 8 | case 200: 9 | var template = await response.text(); 10 | 11 | console.log(template); 12 | break; 13 | // status "Not Found" 14 | case 404: 15 | console.log('Not Found'); 16 | break; 17 | } 18 | })(); 19 | 20 | 21 | 22 | let xmlhttp = new XMLHttpRequest(); 23 | xmlhttp.open("GET", "https://www.sportsbookreview.com/betting-odds/", false);//false for synchronous 24 | console.log("here 0"); 25 | xmlhttp.send(); 26 | console.log(xmlhttp.responseText); 27 | xmlhttp.onload = function() { 28 | console.log("here"); 29 | console.log(xmlhttp.response); 30 | }; 31 | 32 | 33 | function makeHttpObject() { 34 | if("XMLHttpRequest" in window)return new XMLHttpRequest(); 35 | else if("ActiveXObject" in window)return new ActiveXObject("Msxml2.XMLHTTP"); 36 | } 37 | 38 | var request = makeHttpObject(); 39 | request.open("GET", "https://www.sportsbookreview.com/betting-odds/", true); 40 | request.send(null); 41 | request.onreadystatechange = function() { 42 | if (request.readyState == 4) 43 | console.log(request.responseText); 44 | }; 45 | 46 | })(); 47 | -------------------------------------------------------------------------------- /src/js/sign_tx.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var div = document.createElement("div"); 3 | document.body.appendChild(div); 4 | div.appendChild(document.createElement("br")); 5 | 6 | var tx = document.createElement("INPUT"); 7 | tx.setAttribute("type", "text"); 8 | var info = document.createElement("h8"); 9 | info.innerHTML = "sign transaction"; 10 | div.appendChild(info); 11 | div.appendChild(tx); 12 | var button = button_maker2("sign tx ", sign_tx); 13 | div.appendChild(button); 14 | div.appendChild(document.createElement("br")); 15 | 16 | var tx_push = document.createElement("INPUT"); 17 | tx.setAttribute("type", "text"); 18 | var push_info = document.createElement("h8"); 19 | push_info.innerHTML = "publish transaction"; 20 | div.appendChild(push_info); 21 | div.appendChild(tx_push); 22 | var push_button = button_maker2("push tx ", push_tx); 23 | div.appendChild(push_button); 24 | div.appendChild(document.createElement("br")); 25 | 26 | var signed_tx = document.createElement("h8"); 27 | div.appendChild(signed_tx); 28 | div.appendChild(document.createElement("br")); 29 | function sign_tx() { 30 | var t = JSON.parse(tx.value); 31 | var t2 = keys.sign(t); 32 | var s = JSON.stringify(t2); 33 | signed_tx.innerHTML = s; 34 | tx.value = ""; 35 | } 36 | async function push_tx() { 37 | var t = JSON.parse(tx_push.value); 38 | var c = apost_txs([t]); 39 | tx_push.value = ""; 40 | } 41 | })(); 42 | -------------------------------------------------------------------------------- /src/js/vm/example3: -------------------------------------------------------------------------------- 1 | %from javascript's compiler 2 | (141,144,120,110,21,52,111,110,131,22,32,113,24,130,22,132,58,70,20,20,136,71,20,112,113,72,111,132,145,22,130,146,22,130,147,22,130,136,2,0,0,0,32,239,24,7,129,222,179,141,148,74,245,17,98,234,191,250,140,154,220,86,199,215,149,149,53,130,241,24,154,110,163,211,166,10,10,10,30,132,22,2,0,0,0,32,36,89,210,27,16,40,123,32,237,64,118,219,245,76,144,40,190,218,209,124,96,64,58,217,108,213,16,84,89,92,250,40,113,31,20,132,165,22,130,3,36,22,130,3,49,22,130,136,58,30,20,20,31) 3 | 4 | %from the awk compiler 5 | (132 142 4 0 4 21 131 22 32 113 24 130 22 132 70 20 20 136 71 20 112 113 72 132 4 0 5 22 130 4 0 6 22 130 0 0 0 0 0 22 130 136 2 0 0 0 32 1e5e740033ce4ec79de021d7b37828515d1bc38672283e28329a931ccebe719a10 10 10 30 132 22 2 0 0 0 32 a6303892b99653042c1d67b5d23bc6521d572795553ca81459650299ea195252113 31 20 132 142 22 130 4 0 36 22 130 4 0 49 22 130 136 30 20 20 31 ) 6 | 7 | ( a b c 8 | multiline comment 9 | ) 10 | var foo bar ; %variable declaration 11 | foo 4 ! %storing a value in the variable 12 | macro [ nil ; forth style comment 13 | macro , swap cons ; 14 | macro ] , reverse ; 15 | : square dup * ; 16 | : map2 17 | car swap r@ call rot cons swap 18 | nil == 19 | if 20 | drop drop reverse 21 | else 22 | drop recurse call 23 | then ; 24 | macro map 25 | >r nil swap map2 call r> drop 26 | 27 | ; 28 | macro test 29 | [ 5,6, 7] 30 | square print print print map 31 | [25, 36, 49] 32 | == >r drop drop r> 33 | ; 34 | test -------------------------------------------------------------------------------- /src/js/explorers/oracles_by_stake_explorer.js: -------------------------------------------------------------------------------- 1 | (async function(){ 2 | var div = document.createElement("div"); 3 | document.body.appendChild(div); 4 | server_port.value = "8080"; 5 | if (server_ip.value == "") { 6 | server_ip.value = default_ip(); 7 | }; 8 | div.appendChild(br()); 9 | var oracles = await rpc.apost(["oracles", 4], get_ip(), 8091); 10 | oracles = oracles.slice(1); 11 | loop(oracles); 12 | 13 | function loop(oracles) { 14 | if(oracles.length === 0){ 15 | return(0); 16 | }; 17 | oracle = oracles[0]; 18 | var height = oracle[2]; 19 | var question = atob(oracle[4]); 20 | var stake = oracle[5]; 21 | var closed = oracle[7]; 22 | var info = document.createElement("div"); 23 | info.innerHTML = "oracle asks: " 24 | .concat(question) 25 | .concat("
stake: ") 26 | .concat((stake/100000000).toFixed(8)) 27 | .concat("
last referenced in block height: ") 28 | .concat(height.toString()); 29 | div.appendChild(info); 30 | 31 | link = document.createElement("a"); 32 | link.href = "oracle_explorer.html?oid=" 33 | .concat(oracle[1]); 34 | link.innerHTML = "view details"; 35 | link.target = "_blank"; 36 | div.appendChild(link); 37 | div.appendChild(br()); 38 | div.appendChild(br()); 39 | loop(oracles.slice(1)); 40 | }; 41 | 42 | })(); 43 | -------------------------------------------------------------------------------- /src/js/oracles_by_stake_explorer.js: -------------------------------------------------------------------------------- 1 | (async function(){ 2 | var div = document.createElement("div"); 3 | document.body.appendChild(div); 4 | server_port.value = "8080"; 5 | if (server_ip.value == "") { 6 | server_ip.value = default_ip(); 7 | }; 8 | div.appendChild(br()); 9 | var oracles = await rpc.apost(["oracles", 4], get_ip(), 8091); 10 | oracles = oracles.slice(1); 11 | loop(oracles); 12 | 13 | function loop(oracles) { 14 | if(oracles.length === 0){ 15 | return(0); 16 | }; 17 | oracle = oracles[0]; 18 | var height = oracle[2]; 19 | var question = atob(oracle[4]); 20 | var stake = oracle[5]; 21 | var closed = oracle[7]; 22 | var info = document.createElement("div"); 23 | info.innerHTML = "oracle asks: " 24 | .concat(question) 25 | .concat("
stake: ") 26 | .concat((stake/100000000).toFixed(8)) 27 | .concat("
last referenced in block height: ") 28 | .concat(height.toString()); 29 | div.appendChild(info); 30 | 31 | link = document.createElement("a"); 32 | link.href = "explorers/oracle_explorer.html?oid=" 33 | .concat(oracle[1]); 34 | link.innerHTML = "view details"; 35 | link.target = "_blank"; 36 | div.appendChild(link); 37 | div.appendChild(br()); 38 | div.appendChild(br()); 39 | loop(oracles.slice(1)); 40 | }; 41 | 42 | })(); 43 | -------------------------------------------------------------------------------- /src/unused/channels_lookup.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | var div = document.createElement("div"); 3 | document.body.appendChild(div); 4 | var title = document.createElement("h3"); 5 | title.innerHTML = "channels"; 6 | div.appendChild(title); 7 | var cid = text_input("channel id: ", div); 8 | var b = button_maker2("lookup channel", lookup); 9 | div.appendChild(b); 10 | div.appendChild(br()); 11 | var Output = document.createElement("div"); 12 | div.appendChild(Output); 13 | div.appendChild(br()); 14 | 15 | function lookup() { 16 | Output.innerHTML = ""; 17 | var v = cid.value; 18 | console.log(v); 19 | merkle.request_proof("channels", v, function(x) { 20 | console.log(JSON.stringify(x));//["channel","fMU1uaBpWrHpNs7CtR87K6Celt1U9kLTW8v8YCrvIo0=","BFvtRZzoY6e7Nr5ZvfPJjJu/BE66LoX29kAvYvBUYVziU1UExVdkLziNL7O0CWXnFiu5hEzZx3YhBSsg3r9hUH4=","BCjdlkTKyFh7BBx4grLUGFJCedmzo4e0XT1KJtbSwq5vCJHrPltHATB+maZ+Pncjnfvt9CsCcI9Rn1vO+fPLIV4=",1000000000,1050000000,0,1,55290,1000,0] 21 | Output.appendChild(text("account 1: ".concat(x[2]))); 22 | Output.appendChild(br()); 23 | Output.appendChild(text("account 2: ".concat(x[3]))); 24 | Output.appendChild(br()); 25 | Output.appendChild(text("account 1 balance: ".concat(x[4] + x[6]))); 26 | Output.appendChild(br()); 27 | Output.appendChild(text("account 2 balance: ".concat(x[5] - x[6]))); 28 | Output.appendChild(br()); 29 | }); 30 | }; 31 | })(); 32 | -------------------------------------------------------------------------------- /src/js/verkle/binary.js: -------------------------------------------------------------------------------- 1 | var verkle_binary = (function(){ 2 | 3 | function string_to_array(x) { 4 | var a = new Uint8Array(x.length); 5 | for (var i=0; iready"; 7 | // div.appendChild(status); 8 | // div.appendChild(br()); 9 | var contract = text_input("trade: ", div); 10 | div.appendChild(br()); 11 | //var question_text = text_input("if the oracle does not yet exist, put the question text here: ", div); 12 | //div.appendChild(br()); 13 | //var expires = text_input("if the oracle does not yet exist, put the height when it becomes possible to trade here: ", div); 14 | //div.appendChild(br()); 15 | var Button = button_maker2("put the trade on this local page", publish); 16 | div.appendChild(Button); 17 | function publish() { 18 | // status.innerHTML = "add offer status: failed"; 19 | var c = JSON.parse(contract.value); 20 | //c = c.concat([[-7, 21 | // btoa(question_text.value), 22 | // parseInt(expires.value)]]); 23 | 24 | // console.log(contract.value); 25 | ABC.display_oracles(c); 26 | console.log(contract.value); 27 | rpc.post(["add", c], function(X) { 28 | 29 | //l2.slice(1) 30 | 31 | 32 | // status.innerHTML = "add offer status: successfully posted a trade"; 33 | }); 34 | }; 35 | })(); 36 | -------------------------------------------------------------------------------- /src/js/height.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | var height = document.createElement("div"); 3 | height.id = "height"; 4 | document.body.appendChild(height); 5 | var height_button = document.createElement("BUTTON"); 6 | var button_text_node = document.createTextNode("update height"); 7 | height_button.appendChild(button_text_node); 8 | height_button.onclick = height_helper; 9 | document.body.appendChild(height_button); 10 | async function height_helper() { 11 | var x = await rpc.apost(["height"]); 12 | height_f(x); 13 | } 14 | async function height_f(x) { 15 | height.innerHTML = ""; 16 | b = (x).toString(); 17 | var p1 = document.createElement("h"); 18 | p1.innerHTML = "current height: ".concat(b); 19 | height.appendChild(p1); 20 | height.appendChild(document.createElement("br")); 21 | var d = await rpc.apost(["f", 1]); 22 | var hpb = Math.round(d[1]/1000); 23 | var hpb2 = document.createElement("h"); 24 | hpb2.innerHTML = "terahashes per block: ".concat((hpb).toString()); 25 | height.appendChild(hpb2); 26 | height.appendChild(document.createElement("br")); 27 | var hps = d[2]; 28 | var hps2 = document.createElement("h"); 29 | hps2.innerHTML = "gigahashes per second: ".concat((hps).toString()); 30 | height.appendChild(hps2); 31 | height.appendChild(document.createElement("br")); 32 | var bp = d[3]; 33 | var bp2 = document.createElement("h"); 34 | bp2.innerHTML = "seconds per block: ".concat((bp).toString()); 35 | height.appendChild(bp2); 36 | height.appendChild(document.createElement("br")); 37 | }; 38 | })(); 39 | -------------------------------------------------------------------------------- /src/unused/delete_account_tx.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | var div = document.createElement("div"); 3 | document.body.appendChild(div); 4 | div.appendChild(document.createElement("br")); 5 | 6 | var create_address = document.createElement("INPUT"); 7 | create_address.setAttribute("type", "text"); 8 | var create_info = document.createElement("h8"); 9 | create_info.innerHTML = "to pubkey: "; 10 | div.appendChild(create_info); 11 | div.appendChild(create_address); 12 | var create_button = button_maker2("send all your money to this account", create_account); 13 | div.appendChild(create_button); 14 | div.appendChild(document.createElement("br")); 15 | var ca_fee = 152050; 16 | function create_account() { 17 | var to = create_address.value.trim(); 18 | var from = keys.pub(); 19 | rpc.post(["delete_acc_tx", to, from, ca_fee], 20 | function(x) { create_tokens2(x, to, from, ca_fee);} 21 | ); 22 | } 23 | function create_tokens2(tx, to, from, ca_fee) { 24 | console.log("create account tx is "); 25 | console.log(tx); 26 | var from0 = tx[1]; 27 | var fee0 = tx[3]; 28 | var to0 = tx[4]; 29 | if (!(to == to0)) { 30 | console.log("abort: server changed who we are sending money to."); 31 | } else if (!(ca_fee == fee0)) { 32 | console.log("abort: server changed the fee."); 33 | } else { 34 | var stx = keys.sign(tx); 35 | rpc.post(["txs", [-6, stx]], function(x) {}); 36 | } 37 | } 38 | })(); 39 | -------------------------------------------------------------------------------- /src/js/peer_scan.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | var view = document.createElement("div"); 3 | var div = document.createElement("div"); 4 | document.body.appendChild(div); 5 | function list_to_string(x) { 6 | if(x.length == 1){ return(x[0].toString());} 7 | return (x[0].toString().concat(".").concat( 8 | list_to_string(x.slice(1)))); 9 | }; 10 | async function view_peers(p) { 11 | if(p.length == 0){ return([]);} 12 | var ip = p[0][1][1]; 13 | var port = p[0][1][2]; 14 | var height = p[0][2][1]; 15 | console.log(ip); 16 | if((ip[1] === 127) && 17 | (ip[2] === 0) && 18 | (ip[3] === 0) && 19 | (ip[4] === 1)){ 20 | 21 | } else { 22 | var r = await rpc.apost(["version", 3], list_to_string(ip.slice(1)), 8080); 23 | var m = ""; 24 | m += "

ip: ".concat(JSON.stringify(ip.slice(1))).concat("height: ").concat(JSON.stringify(height)).concat(", port: ").concat(JSON.stringify(port)); 25 | if(r) { 26 | m += (", fork number: ").concat(JSON.stringify(r)); 27 | }; 28 | m += "

"; 29 | view.innerHTML += m; 30 | } 31 | view_peers(p.slice(1)); 32 | }; 33 | async function main() { 34 | view.innerHTML = ""; 35 | var p = await rpc.apost(["peers", 2]); 36 | view_peers(p.slice(1)); 37 | }; 38 | var button = button_maker2("refresh", main); 39 | div.appendChild(button); 40 | div.appendChild(view); 41 | })(); 42 | -------------------------------------------------------------------------------- /src/js/rpc.js: -------------------------------------------------------------------------------- 1 | var rpc = (function() { 2 | function url(port, ip) { 3 | return "http://".concat(ip).concat(":"). 4 | concat(port.toString()).concat("/"); } 5 | function messenger(cmd, callback){ 6 | var u = url(8088, get_ip()); 7 | return talk(cmd, u, callback, 10000); 8 | }; 9 | async function main2(cmd, ip, port) { 10 | if (ip == undefined){ 11 | ip = get_ip(); 12 | } 13 | if (port == undefined){ 14 | port = get_port(); 15 | } 16 | var u = url(port, ip); 17 | return atalk(cmd, u);//use up to 10 seconds for this request 18 | } 19 | async function atalk(cmd, u) { 20 | return new Promise(function(resolve, reject){ 21 | let xmlhttp = new XMLHttpRequest(); 22 | xmlhttp.open("POST", u); 23 | xmlhttp.onload = function() { 24 | if (this.status >= 200 && this.status < 300) { 25 | resolve(JSON.parse(xmlhttp.response)[1]); 26 | } else { 27 | reject({ 28 | status: this.status, 29 | statusText: xmlhttp.statusText 30 | }); 31 | } 32 | }; 33 | xmlhttp.onerror = function () { 34 | reject({ 35 | status: this.status, 36 | statusText: xmlhttp.statusText 37 | }); 38 | }; 39 | xmlhttp.send(JSON.stringify(cmd)); 40 | }); 41 | }; 42 | return { 43 | apost: main2 44 | }; 45 | })(); 46 | -------------------------------------------------------------------------------- /src/js/explorers/block_explorer.js: -------------------------------------------------------------------------------- 1 | (async function(){ 2 | var div = document.createElement("div"); 3 | document.body.appendChild(div); 4 | server_port.value = "8080"; 5 | if (server_ip.value == "") { 6 | server_ip.value = default_ip(); 7 | }; 8 | const urlParams = new URLSearchParams(window.location.search); 9 | var hash = urlParams.get('hash'); 10 | hash = hash.replace(/\ /g, "+"); 11 | 12 | div.appendChild(br()); 13 | 14 | var hash_text = document.createElement("div"); 15 | hash_text.innerHTML = "block hash: " 16 | .concat(hash); 17 | div.appendChild(hash_text); 18 | 19 | var block = await rpc.apost(["block", hash], get_ip(), 8091); 20 | console.log(JSON.stringify(block)); 21 | var block = block[1]; 22 | var height = block[1]; 23 | var height_div = document.createElement("div"); 24 | height_div.innerHTML = "block height: " 25 | .concat(height); 26 | div.appendChild(br()); 27 | div.appendChild(height_div); 28 | div.appendChild(br()); 29 | var txs = block[3]; 30 | make_tx_links(txs.slice(1)); 31 | //}, get_ip(), 8091); 32 | 33 | function make_tx_links(txs){ 34 | if(txs.length === 0){ 35 | return(0); 36 | }; 37 | var txid = txs[0]; 38 | var link = document.createElement("a"); 39 | link.href = "tx_explorer.html?txid=" 40 | .concat(txid); 41 | link.innerHTML = txid; 42 | link.target = "_blank"; 43 | div.appendChild(link); 44 | div.appendChild(br()); 45 | return(make_tx_links(txs.slice(1))); 46 | }; 47 | 48 | })(); 49 | -------------------------------------------------------------------------------- /src/js/explorers/lookup_account.js: -------------------------------------------------------------------------------- 1 | lookup_account1(); 2 | function lookup_account1() { 3 | document.body.appendChild(document.createElement("br")); 4 | document.body.appendChild(document.createElement("br")); 5 | var lookup_account = document.createElement("div"); 6 | document.body.appendChild(lookup_account); 7 | var lookup_account_address = document.createElement("INPUT"); 8 | lookup_account_address.setAttribute("type", "text"); 9 | var input_info = document.createElement("h8"); 10 | input_info.innerHTML = "pubkey: "; 11 | document.body.appendChild(input_info); 12 | document.body.appendChild(lookup_account_address); 13 | 14 | var lookup_account_button = document.createElement("BUTTON"); 15 | var lookup_account_text_node = document.createTextNode("lookup account"); 16 | lookup_account_button.appendChild(lookup_account_text_node); 17 | lookup_account_button.onclick = lookup_account_helper; 18 | document.body.appendChild(lookup_account_button); 19 | 20 | var zeroth_confirmation = document.createElement("p"); 21 | zeroth_confirmation.innerHTML = "this shows your balance including 0th confirmation txs which are not yet included in a block."; 22 | document.body.appendChild(zeroth_confirmation); 23 | document.body.appendChild(document.createElement("br")); 24 | 25 | async function lookup_account_helper() { 26 | var x = lookup_account_address.value.trim(); 27 | var y = await rpc.apost(["account", x]); 28 | lookup_account_helper2(y); 29 | } 30 | function lookup_account_helper2(x) { 31 | lookup_account.innerHTML = "balance: ".concat(x[1] / token_units()).concat(" VEO"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/unused/binary_id.js: -------------------------------------------------------------------------------- 1 | var binary_id = (function(){ 2 | //generate the id for a binary contract 3 | var div = document.getElementById("binary_id"); 4 | var display = document.createElement("p"); 5 | div.appendChild(display); 6 | var oracle_start_height = text_input("when it becomes possible to report on the outcome of the oracle question. a block height: ", div); 7 | div.appendChild(br()); 8 | var oracle_text = text_input("the question we ask the oracle", div); 9 | div.appendChild(br()); 10 | var source = text_input("source contract (leave blank for veo): ", div); 11 | div.appendChild(br()); 12 | var source_type = text_input("source subcurrency type (leave blank for veo): ", div); 13 | div.appendChild(br()); 14 | 15 | var button = button_maker2("make contract id", doit); 16 | div.appendChild(button); 17 | function doit(){ 18 | var Start = parseInt(oracle_start_height.value); 19 | var Text = oracle_text.value; 20 | var oracle_id = id_maker(Start, 0, 0, Text);//from format 21 | var CH = binary_derivative.hash(oracle_id); 22 | var MT = 3; 23 | var Source, SourceType; 24 | if(source.value == ""){ 25 | Source = btoa(array_to_string(integer_to_array(0, 32))); 26 | SourceType = 0; 27 | } else { 28 | Source = source.value; 29 | SourceType = parseInt(source_type.value); 30 | }; 31 | var cid = binary_derivative.id_maker(CH, MT, Source, SourceType); 32 | display.innerHTML = cid; 33 | return(0); 34 | }; 35 | return({ 36 | start: function(x){oracle_start_height.value = x}, 37 | text: function(x){oracle_text.value = x}, 38 | doit:doit 39 | }); 40 | })(); 41 | -------------------------------------------------------------------------------- /src/js/check_binary_contract.js: -------------------------------------------------------------------------------- 1 | var check_binary_contract = (function(){ 2 | var div = document.getElementById("check_binary_contract"); 3 | var display = document.createElement("p"); 4 | div.appendChild(display); 5 | 6 | var s_ip = text_input("server ip: ", div); 7 | div.appendChild(br()); 8 | s_ip.value = get_ip(); 9 | 10 | var s_port = text_input("server port: ", div); 11 | div.appendChild(br()); 12 | s_port.value = "8090"; 13 | 14 | 15 | var cid = text_input("contract id: ", div); 16 | div.appendChild(br()); 17 | var button = button_maker2("lookup", lookup); 18 | div.appendChild(button); 19 | async function lookup(){ 20 | var z = await rpc.apost(["read", 3, cid.value], s_ip.value, parseInt(s_port.value));//i think it is looking in the p2p derivatives tool. 21 | if(z == 0){ 22 | display.innerHTML = "the server does not yet know about that contract"; 23 | return(0); 24 | }; 25 | var oracle_text = atob(z[1]); 26 | var start_height = z[2]; 27 | if(z.length == 5) { 28 | display.innerHTML = "scalar contract
oracle start height: " 29 | .concat(start_height) 30 | .concat("
oracle text: ") 31 | .concat(oracle_text) 32 | .concat("
max price: ") 33 | .concat(z[3]); 34 | 35 | } else { 36 | display.innerHTML = "binary contract
oracle start height: " 37 | .concat(start_height) 38 | .concat("
oracle text: ") 39 | .concat(oracle_text); 40 | }; 41 | }; 42 | return({ 43 | cid: function(x){cid.value = x}, 44 | lookup: lookup 45 | }); 46 | })(); 47 | -------------------------------------------------------------------------------- /src/js/subcurrency_spender.js: -------------------------------------------------------------------------------- 1 | var subcurrency_spender = (function(){ 2 | 3 | var div = document.getElementById("subcurrency_spender"); 4 | var display = document.createElement("p"); 5 | div.appendChild(display); 6 | 7 | var contract_id = text_input("contract_id: ", div); 8 | div.appendChild(contract_id); 9 | div.appendChild(br()); 10 | var type = text_input("type: ", div); 11 | div.appendChild(type); 12 | div.appendChild(br()); 13 | var to = text_input("to: ", div); 14 | div.appendChild(to); 15 | div.appendChild(br()); 16 | var amount = text_input("amount: ", div); 17 | div.appendChild(amount); 18 | div.appendChild(br()); 19 | 20 | var button = button_maker2("send", send); 21 | div.appendChild(button); 22 | div.appendChild(br()); 23 | 24 | async function send(){ 25 | var cid_key = contract_id.value; 26 | var Type = parseInt(type.value); 27 | var account = await merkle.arequest_proof("accounts", keys.pub()); 28 | var nonce = account[2] + 1; 29 | var fee = 152050; 30 | var tx = ["sub_spend_tx", 31 | keys.pub(), 32 | nonce, 33 | fee, 34 | to.value, 35 | parseInt(amount.value), 36 | contract_id.value, 37 | Type]; 38 | console.log(tx); 39 | console.log(JSON.stringify(tx)); 40 | var stx = keys.sign(tx); 41 | var msg = await apost_txs([stx]); 42 | display.innerHTML = msg; 43 | }; 44 | return({contract_id: function(x) {contract_id.value = x}, 45 | to: function(x) { to.value = x }, 46 | amount: function(x) { amount.value = x }, 47 | type: function(x) {type.value = x } 48 | }); 49 | })(); 50 | -------------------------------------------------------------------------------- /src/js/market_liquidity.js: -------------------------------------------------------------------------------- 1 | var market_liquidity = (function(){ 2 | //-record(market_liquidity_tx, {from, nonce, fee, mid, amount, cid1, type1, cid2, type2}). 3 | var div = document.getElementById("market_liquidity"); 4 | var display = document.createElement("p"); 5 | div.appendChild(display); 6 | 7 | var mid = text_input("market id: ", div); 8 | div.appendChild(br()); 9 | var amount = text_input("amount: ", div); 10 | div.appendChild(br()); 11 | var button = button_maker2("buy liquidity", doit); 12 | div.appendChild(button); 13 | async function doit(){ 14 | var Fee = 152050; 15 | var Acc = await rpc.apost(["accounts", keys.pub()]); 16 | if(Acc == "empty") { 17 | display.innerHTML = "load an account first"; 18 | return(0); 19 | }; 20 | var market = await merkle.arequest_proof("markets", mid.value); 21 | if(market === "empty"){ 22 | display.innerHTML = "that market does not exist"; 23 | return(0); 24 | }; 25 | //-record(market, {id, cid1, type1, amount1, cid2, type2, amount2, shares}). 26 | var CID1 = market[2]; 27 | var Type1 = market[3]; 28 | var CID2 = market[5]; 29 | var Type2 = market[6]; 30 | var Nonce = Acc[2] + 1; 31 | var tx = ["market_liquidity_tx", keys.pub(), 32 | Nonce, Fee, 33 | mid.value, parseInt(amount.value), 34 | CID1, Type1, CID2, Type2]; 35 | var txs = [tx]; 36 | var stx = keys.sign(tx); 37 | var msg = await apost_txs([stx]); 38 | display.innerHTML = msg; 39 | keys.update_balance(); 40 | }; 41 | return({ 42 | mid: function(x){mid.value = x}, 43 | amount: function(x){amount.value = x} 44 | }); 45 | })(); 46 | -------------------------------------------------------------------------------- /src/js/oracle_bet.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | var fee = 152050; 3 | var div = document.createElement("div"); 4 | document.body.appendChild(div); 5 | var status = document.createElement("p"); 6 | status.innerHTML = "status: ready"; 7 | div.appendChild(status); 8 | var oid_element = text_input("oid: ", div); 9 | div.appendChild(br()); 10 | var direction_element = text_input("true/false/bad: ", div); 11 | div.appendChild(br()); 12 | var amount_element = text_input("amount: ", div); 13 | div.appendChild(br()); 14 | var button = button_maker2("make bet", function(){ 15 | console.log(parseFloat(amount_element.value)); 16 | console.log(direction_element.value); 17 | return make_bet(oid_element.value, direction_element.value, Math.floor(parseFloat(amount_element.value) * token_units())); 18 | }); 19 | div.appendChild(button); 20 | div.appendChild(br()); 21 | async function make_bet(oid, direction0, amount) { 22 | var direction; 23 | if (direction0 == "true") { 24 | direction = 1; 25 | } else if (direction0 == "false") { 26 | direction = 2; 27 | } else if (direction0 == "bad") { 28 | direction = 3; 29 | } else { 30 | status.innerHTML = "status: bet type must be true, false, or bad."; 31 | return 0; 32 | } 33 | var from = keys.pub(); 34 | var acc = await rpc.apost(["account", from]); 35 | var nonce = acc[2] + 1; 36 | var tx = ["oracle_bet", from, nonce, fee, oid, direction, amount]; 37 | var stx = keys.sign(tx); 38 | var txs = [stx]; 39 | var msg = await apost_txs(txs); 40 | status.innerHTML = msg; 41 | keys.update_balance(); 42 | }; 43 | })(); 44 | -------------------------------------------------------------------------------- /src/unused/loop.js: -------------------------------------------------------------------------------- 1 | var loop_start_height; 2 | var globalnonce = 0; 3 | var loop_finish_height; 4 | 5 | var localBool; 6 | 7 | 8 | function runtheloop(){ 9 | console.log("refreshing blocks"); 10 | headers_object.more_headers(); 11 | console.log("refreshing oracle list"); 12 | // abcd.oracles.innerHTML = ""; 13 | 14 | rpc.default_explorer(["oracle_list"], function(Y) { 15 | console.log("oracle_list attempt:"); 16 | console.log(JSON.stringify(Y)); 17 | var l = Y.slice(1); 18 | abcd.display_oracles(l); 19 | }); 20 | 21 | firstTimeBool = 0; 22 | 23 | 24 | 25 | //abcd.display_positions(window.localStorage.getItem("positionData"+keys.pub())); 26 | 27 | 28 | console.log("seeing if we can update balance"); 29 | console.log(keys.pub()); 30 | console.log("privkey"); 31 | console.log(localStorage.getItem('privkey')); 32 | 33 | if (keys.pub().length > 0){ 34 | console.log("updating balance"); 35 | // keys.update_balance(); 36 | // keys.update_pubkey(); 37 | } 38 | //console.log("refreshing blocks"); 39 | 40 | } 41 | 42 | 43 | setInterval(function(){ runtheloop() }, 1000*10) 44 | 45 | //setInterval(console.log(globalBalance), 150*30); 46 | 47 | 48 | function copyToClipboard(text) { 49 | var selected = false; 50 | var el = document.createElement('textarea'); 51 | el.value = text; 52 | el.setAttribute('readonly', ''); 53 | el.style.position = 'absolute'; 54 | el.style.left = '-9999px'; 55 | document.body.appendChild(el); 56 | if (document.getSelection().rangeCount > 0) { 57 | selected = document.getSelection().getRangeAt(0) 58 | } 59 | el.select(); 60 | document.execCommand('copy'); 61 | document.body.removeChild(el); 62 | if (selected) { 63 | document.getSelection().removeAllRanges(); 64 | document.getSelection().addRange(selected); 65 | } 66 | }; 67 | -------------------------------------------------------------------------------- /src/unused/lightning.js: -------------------------------------------------------------------------------- 1 | function lightning_main() { 2 | var secrets = {}; 3 | function read(code) { 4 | return secrets[code]; 5 | } 6 | function add(code, ss, amount) { 7 | //code should be base64 encoded? 8 | secrets[code] = [ss, amount]; 9 | } 10 | 11 | function make(amount) { 12 | var s = Array.prototype.slice.call(elliptic.rand(32)); 13 | var sh = hash(s); 14 | var ss_code = ([2, 0,0,0,32]).concat(s); 15 | var ss = new_ss(ss_code, [], []); 16 | var code = [20,90,0,0,0,0,0,58, 17 | 70, 18 | 0,0,0,0,100,0,0,0,0,1,0,0,0,0,0,11, 19 | 71,72,20,20, 20 | 40,31, 21 | 58,22,20,22,20, 22 | 70,0,0,0,0,0,0,0,0,0,2,0,0,0,39,16, 23 | 71,0,0,0,0,100,0,0,0,0,1,0,0,0,0,0, 24 | 72,11]; 25 | var a = ([2, 0,0,0,32]).concat( 26 | sh).concat([30]).concat( 27 | code); 28 | var contract = btoa(array_to_string(a)); 29 | var codekey = ""; 30 | var meta = [-6]; 31 | return {ss: ss, bet: ["bet", contract, amount, codekey, meta]}; 32 | }; 33 | function test() { 34 | var m = make(10); 35 | var ss = m.ss; 36 | var cid = 1; 37 | var amount = 27000; 38 | var delay = 11; 39 | var spk = ["spk", 1, 2, [-6, m.bet], 10000,10000,cid, amount, 0, delay]; 40 | var height = headers_object.top()[1]; 41 | spk_object.spk_run("fast", [ss], spk, height, 0, 1000, 1000, function(ran) { 42 | console.log(JSON.stringify(ran)); 43 | }); 44 | }; 45 | return {test: test, make: make, read: read, add: add}; 46 | } 47 | var lightning_object = lightning_main(); 48 | //setTimeout(function() { 49 | // JSON.stringify(lightning_object.test()); 50 | //}, 500); 51 | -------------------------------------------------------------------------------- /src/unused/channel_with_server.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Light Wallet - Channel With Server - Amoveo

7 | mainnet mode
8 | testnet mode
9 | test mode
10 | main menu for this light node.
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 | -------------------------------------------------------------------------------- /src/js/server.js: -------------------------------------------------------------------------------- 1 | //make ip and port as input things. 2 | 3 | local_ip = [127,0,0,1]; 4 | local_port = 8081; 5 | var server_ip = document.createElement("INPUT"); 6 | server_ip.setAttribute("type", "text"); 7 | server_ip.value = document.URL.split("/")[2].split(":")[0]; 8 | var server_ip_info = document.createElement("h8"); 9 | server_ip_info.innerHTML = "channel node IP: "; 10 | var server_port = document.createElement("INPUT"); 11 | //server_port.value = "8080";// server 12 | var URL_REGEX = /^(https?)?(?:[\:\/]*)([a-z0-9\.-]*)(?:\:([0-9]+))?(\/[^?#]*)?(?:\?([^#]*))?(?:#(.*))?$/i; 13 | var match = document.URL.match(URL_REGEX); 14 | //console.log(match); 15 | if (match !== null){ 16 | var host = match[2]; 17 | var port = match[3]; 18 | console.log(port); 19 | if (document.URL[0] == 'f') { 20 | console.log("running stand-alone light node"); 21 | } else { 22 | console.log("running light node served from a full node"); 23 | server_port.value = port; 24 | // server_port.value = document.URL.split(":")[2].substring(0, 4); 25 | }; 26 | }; 27 | server_port.setAttribute("type", "text"); 28 | var server_port_info = document.createElement("h8"); 29 | server_port_info.innerHTML = "port: "; 30 | /* 31 | document.body.appendChild(server_ip_info); 32 | document.body.appendChild(server_ip); 33 | document.body.appendChild(server_port_info); 34 | document.body.appendChild(server_port); 35 | 36 | document.body.appendChild(document.createElement("br")); 37 | document.body.appendChild(document.createElement("br")); 38 | */ 39 | 40 | function get_port() { 41 | var p = parseInt(server_port.value, 10); 42 | return(p || 8080); 43 | } 44 | function get_ip() { 45 | //return JSON.parse(server_ip.value); 46 | var s = server_ip.value; 47 | if(s.length === 0){ 48 | s = default_ip(); 49 | }; 50 | if(s === "zack-bitcoin.github.io"){ 51 | s = default_ip(); 52 | }; 53 | return s; 54 | } 55 | -------------------------------------------------------------------------------- /src/js/encryption_interface.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | var div = document.createElement("div"); 3 | document.body.appendChild(div); 4 | var title = document.createElement("h3"); 5 | title.innerHTML = "encryption"; 6 | div.appendChild(title); 7 | var b = button_maker2("encrypt", encrypt); 8 | div.appendChild(b); 9 | var msg_to_send = document.createElement("INPUT"); 10 | msg_to_send.type = "text"; 11 | var msg_to = document.createElement("INPUT"); 12 | msg_to.type = "text"; 13 | var encrypted_to_send = document.createElement("div"); 14 | var to_instructions = document.createElement("h8"); 15 | to_instructions.innerHTML = "to pubkey"; 16 | div.appendChild(to_instructions); 17 | div.appendChild(msg_to); 18 | var msg_instructions = document.createElement("h8"); 19 | msg_instructions.innerHTML = "message to send"; 20 | div.appendChild(msg_instructions); 21 | div.appendChild(msg_to_send); 22 | div.appendChild(br()); 23 | div.appendChild(encrypted_to_send); 24 | div.appendChild(br()); 25 | var b2 = button_maker2("decrypt", decrypt); 26 | var encrypted_received = document.createElement("INPUT"); 27 | encrypted_received.type = "text"; 28 | var decrypted_received = document.createElement("div"); 29 | div.appendChild(b2); 30 | div.appendChild(encrypted_received); 31 | div.appendChild(br()); 32 | div.appendChild(decrypted_received); 33 | div.appendChild(br()); 34 | function encrypt() { 35 | var t = msg_to_send.value; 36 | var to = msg_to.value; 37 | var t2 = keys.encrypt(t, to); 38 | encrypted_to_send.innerHTML = JSON.stringify(t2); 39 | } 40 | function decrypt() { 41 | var t = encrypted_received.value; 42 | var t2 = keys.decrypt(JSON.parse(t)); 43 | decrypted_received.innerHTML = 44 | ("message from address: ") 45 | .concat(t2[1]) 46 | .concat("
") 47 | .concat(t2[0]); 48 | } 49 | })(); 50 | -------------------------------------------------------------------------------- /src/js/subcurrency_balance.js: -------------------------------------------------------------------------------- 1 | var subcurrency_balance = (function(){ 2 | 3 | var div = document.getElementById("subcurrency_balance"); 4 | var display = document.createElement("p"); 5 | div.appendChild(display); 6 | 7 | var contract_id = text_input("contract_id: ", div); 8 | // contract_id.value = "smNS5nh9+rYThL095bt6oQIi6jQYbL2FZtleyxxroyM="; 9 | div.appendChild(contract_id); 10 | div.appendChild(br()); 11 | var button = button_maker2("update balance", balance); 12 | div.appendChild(button); 13 | div.appendChild(br()); 14 | async function balance(){ 15 | var cid_key = contract_id.value; 16 | var c = await merkle.arequest_proof("contracts", cid_key); 17 | var many_types; 18 | if(c == "empty"){ 19 | many_types = 10; 20 | //display.innerHTML = "that contract does not exist" 21 | //return(0); 22 | } else { 23 | many_types = c[2]; 24 | } 25 | balance2(many_types, cid_key, c, ""); 26 | }; 27 | async function balance2(type, cid, contract, s) { 28 | if(type < 1){ 29 | display.innerHTML = s; 30 | return(0); 31 | }; 32 | var trie_key = sub_accounts.key(keys.pub(), cid, type); 33 | trie_key = btoa(array_to_string(trie_key)); 34 | var x = await rpc.apost(["sub_accounts", trie_key]);//this version is to see your zeroth confirmation balance. 35 | //var x = await merkle.arequest_proof( 36 | // "sub_accounts", trie_key); 37 | var amount = 0; 38 | if(x[0] == "sub_acc"){ 39 | amount = x[1]; 40 | }; 41 | s = ("") 42 | .concat("
type ") 43 | .concat(type) 44 | .concat(" balance: ") 45 | .concat(amount) 46 | .concat(s); 47 | balance2(type-1, cid, contract, s); 48 | }; 49 | return({value: function(x) { contract_id.value = x} 50 | }); 51 | })(); 52 | -------------------------------------------------------------------------------- /src/unused/otc_finisher_old.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Light Wallet - OTC Derivatives Finisher - Amoveo

7 | mainnet mode
8 | testnet mode
9 | test mode
10 | main menu for this light node.
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 | -------------------------------------------------------------------------------- /src/unused/teach_binary_contract.js: -------------------------------------------------------------------------------- 1 | var teach_binary_contract = (function(){ 2 | //take oracle text and start height. sends to server. 3 | var div = document.getElementById("teach_binary_contract"); 4 | var display = document.createElement("p"); 5 | div.appendChild(display); 6 | 7 | var s_ip = text_input("server ip: ", div); 8 | div.appendChild(br()); 9 | s_ip.value = get_ip(); 10 | 11 | var s_port = text_input("server port: ", div); 12 | div.appendChild(br()); 13 | s_port.value = "8090"; 14 | 15 | var oracle_text = text_input("oracle text: ", div); 16 | div.appendChild(br()); 17 | var oracle_height = text_input("oracle height: ", div); 18 | div.appendChild(br()); 19 | var source = text_input("source contract (leave blank for veo): ", div); 20 | div.appendChild(br()); 21 | var source_type = text_input("source subcurrency type (leave blank for veo): ", div); 22 | div.appendChild(br()); 23 | 24 | var button = button_maker2("teach", teach); 25 | div.appendChild(button); 26 | 27 | function teach() { 28 | var msg = ["add", 2, 29 | btoa(oracle_text.value), 30 | parseInt(oracle_height.value)]; 31 | //added source and source_type to the p2p server. now we need to use the new api. 32 | if(!(source.value == "")){ 33 | msg = msg.concat( 34 | [source.value, 35 | parseInt(source_type.value)]); 36 | }; 37 | rpc.post(msg, 38 | function(x){ 39 | console.log(x); 40 | display.innerHTML = "success"; 41 | return(0); 42 | }, 43 | s_ip.value, 44 | parseInt(s_port.value)); 45 | }; 46 | return({ 47 | oracle_text: function(x){oracle_text.value = x}, 48 | oracle_height: function(x){oracle_height.value = x}, 49 | teach: teach 50 | }); 51 | })(); 52 | -------------------------------------------------------------------------------- /src/js/explorers/jobs_explorer.js: -------------------------------------------------------------------------------- 1 | (async function(){ 2 | var div = document.createElement("div"); 3 | document.body.appendChild(div); 4 | server_port.value = "8080"; 5 | if (server_ip.value == "") { 6 | server_ip.value = default_ip(); 7 | }; 8 | const urlParams = new URLSearchParams(window.location.search); 9 | var jid = urlParams.get('jid'); 10 | jid = jid.replace(/\ /g, "+"); 11 | 12 | div.appendChild(br()); 13 | 14 | var jid_text = document.createElement("div"); 15 | jid_text.innerHTML = "job id: " 16 | .concat(jid); 17 | div.appendChild(jid_text); 18 | 19 | var job = await rpc.apost(["jobs", jid]); 20 | var id = job[1]; 21 | var worker = job[2]; 22 | var boss = job[3]; 23 | var value = job[4]; 24 | var salary = job[5]; 25 | var balance = job[6]; 26 | var time = job[7]; 27 | var N64 = 18446744073709551616;//2^64 28 | var salary_per_block = value * salary / N64; 29 | var s = ""; 30 | //s = s.concat("job id: ").concat(id); 31 | //s = s.concat("
"); 32 | s = s.concat("worker: "); 34 | s = s.concat(worker); 35 | s = s.concat("
"); 36 | s = s.concat("boss: "); 38 | s = s.concat(boss); 39 | s = s.concat("
"); 40 | s = s.concat("value: ").concat(write_veo(value)); 41 | s = s.concat("
"); 42 | s = s.concat("salary per block: ").concat(write_veo(salary_per_block)); 43 | s = s.concat("
"); 44 | s = s.concat("balance: ").concat(write_veo(balance)); 45 | s = s.concat("
"); 46 | s = s.concat("time: ").concat(time); 47 | var info = document.createElement("div"); 48 | info.innerHTML = s; 49 | div.appendChild(info); 50 | 51 | var explorer_info = await rpc.apost( 52 | ["job", jid]); 53 | console.log(explorer_info); 54 | 55 | })(); 56 | 57 | -------------------------------------------------------------------------------- /src/js/scalar_id.js: -------------------------------------------------------------------------------- 1 | var scalar_id = (function(){ 2 | var div = document.getElementById("scalar_id"); 3 | var display = document.createElement("p"); 4 | div.appendChild(display); 5 | 6 | //var oracle_start_height = text_input("when it becomes possible to report on the outcome of the oracle question. a block height: ", div); 7 | //div.appendChild(br()); 8 | var oracle_text = text_input("the question we ask the oracle", div); 9 | div.appendChild(br()); 10 | var max_price_text = text_input("maximum value we can measure with this oracle", div); 11 | div.appendChild(br()); 12 | var source = text_input("source contract (leave blank for veo): ", div); 13 | div.appendChild(br()); 14 | var source_type = text_input("source subcurrency type (leave blank for veo): ", div); 15 | div.appendChild(br()); 16 | 17 | var button = button_maker2("make contract id", doit); 18 | div.appendChild(button); 19 | function doit(){ 20 | //var Start = parseInt(oracle_start_height.value); 21 | var Text = oracle_text.value; 22 | var Max = parseInt(max_price_text.value); 23 | var contract = scalar_derivative.maker(Text, Max, 0); 24 | var CH = scalar_derivative.hash(contract); 25 | 26 | var MT = 2; 27 | var Source, SourceType; 28 | if(source.value == ""){ 29 | Source = btoa(array_to_string(integer_to_array(0, 32))); 30 | SourceType = 0; 31 | } else { 32 | Source = source.value; 33 | SourceType = parseInt(source_type.value); 34 | }; 35 | console.log([CH, MT, Source, SourceType]); 36 | var cid = merkle.contract_id_maker(CH, MT, Source, SourceType); 37 | display.innerHTML = cid; 38 | return(0); 39 | }; 40 | return({ 41 | //height: function(x){oracle_start_height.value = x}, 42 | text: function(x){oracle_text.value = x}, 43 | max: function(x){max_price_text.value = x}, 44 | doit: doit 45 | }); 46 | })(); 47 | -------------------------------------------------------------------------------- /src/js/teach_scalar_contract.js: -------------------------------------------------------------------------------- 1 | var teach_scalar_contract = (function(){ 2 | var div = document.getElementById("teach_scalar_contract"); 3 | var display = document.createElement("p"); 4 | div.appendChild(display); 5 | 6 | var s_ip = text_input("server ip: ", div); 7 | div.appendChild(br()); 8 | s_ip.value = get_ip(); 9 | 10 | var s_port = text_input("server port: ", div); 11 | div.appendChild(br()); 12 | s_port.value = "8090"; 13 | 14 | var oracle_text = text_input("what is being measured, and at what time?: ", div); 15 | div.appendChild(br()); 16 | // var oracle_height = text_input("oracle height, an integer: ", div); 17 | //div.appendChild(br()); 18 | var max_val = text_input("maximum value that can be measured, an integer: ", div); 19 | div.appendChild(br()); 20 | var source = text_input("source contract (leave blank for veo): ", div); 21 | div.appendChild(br()); 22 | var source_type = text_input("source subcurrency type (leave blank for veo): ", div); 23 | div.appendChild(br()); 24 | var button = button_maker2("teach", teach); 25 | div.appendChild(button); 26 | async function teach() { 27 | var msg = ["add", 3, 28 | btoa(oracle_text.value), 29 | 0, 30 | parseInt(max_val.value) 31 | ]; 32 | if(!(source.value == "")){ 33 | msg = msg.concat( 34 | [source.value, 35 | parseInt(source_type.value)]); 36 | }; 37 | console.log(msg); 38 | var x = await rpc.apost( 39 | msg, 40 | s_ip.value, 41 | parseInt(s_port.value)); 42 | console.log(x); 43 | display.innerHTML = "successfully taught contract with id: " 44 | .concat(x); 45 | return(0); 46 | }; 47 | return({ 48 | oracle_text: function(x){oracle_text.value = x}, 49 | max_val: function(x){max_val.value = x}, 50 | teach: teach 51 | }); 52 | })(); 53 | -------------------------------------------------------------------------------- /src/js/sub_accounts.js: -------------------------------------------------------------------------------- 1 | sub_accounts = (function(){ 2 | function key(pub, cid, type) { 3 | return(hash( 4 | (string_to_array(atob(pub))) 5 | .concat(string_to_array(atob(cid))) 6 | .concat(integer_to_array(type, 32)))); 7 | }; 8 | function normal_key(p, c, t){ 9 | return(btoa(array_to_string(key(p, c, t)))) 10 | }; 11 | var merklized_sub_accounts = {}; 12 | async function memoized_merkle_rpc(id){ 13 | var x = memoized_sub_accounts[id]; 14 | if(x){ 15 | return(x); 16 | } else { 17 | //todo, maybe this should be checking merkle proofs. 18 | var sa; 19 | var dip = default_ip(); 20 | if(dip === "0.0.0.0"){ 21 | sa = await rpc.apost(["sub_accounts", id]); 22 | } else { 23 | sa = await merkle.arequest_proof("sub_accounts", id); 24 | }; 25 | if((sa === "c3RvcCBzcGFtbWluZyB0aGUgc2VydmVy")){ 26 | console.log("spam filter triggered."); 27 | return(sa); 28 | } else { 29 | memoized_sub_accounts[id] = sa; 30 | return(sa); 31 | }; 32 | }; 33 | }; 34 | var memoized_sub_accounts = {}; 35 | async function amemoized_rpc(id){ 36 | var x = memoized_sub_accounts[id]; 37 | if(x){ 38 | return(x); 39 | } else { 40 | //todo, maybe this should be checking merkle proofs. 41 | let sa = await rpc.apost(["sub_accounts", id]); 42 | if((sa === "c3RvcCBzcGFtbWluZyB0aGUgc2VydmVy")){ 43 | console.log("spam filter triggered."); 44 | return(sa); 45 | } else { 46 | memoized_sub_accounts[id] = sa; 47 | return(sa); 48 | }; 49 | }; 50 | }; 51 | return({key: key, 52 | normal_key: normal_key, 53 | amrpc: memoized_merkle_rpc, 54 | arpc: amemoized_rpc 55 | }); 56 | })(); 57 | -------------------------------------------------------------------------------- /src/unused/binary_derivative.js: -------------------------------------------------------------------------------- 1 | var binary_derivative = (function(){ 2 | //binary derivative contract based on a single oracle. 3 | var static_binary_derivative = atob("AAAAAAF4gxSDFhSDFhSDFKyHAAAAAAF5OkZHDUgUFI2HFhQCAAAAAwAAABaGjzpGhIwWgowWggD/////FoKIjAQD6EcUjTpGhAD/////FoKMFoKMFoKIjAQD6EcUjjpGhIwWggD/////FoKMFoKIjAQD6EcUFIQAgAAAABaCAH////8WgowWgogEE4iWSEhI"); 4 | // static_binary_derivative = array_to_string( 5 | // [1,255,255,255,255,3,0,132,130,130,3,0,3,100]); 6 | //int 0, max, nil, cons, cons, 0, 100 7 | function contract_maker2(oracle_id) { 8 | var serialized_oracle_id = string_to_array(atob(oracle_id)); 9 | var full_code = array_to_string(([2,0,0,0,32]).concat(serialized_oracle_id)).concat(static_binary_derivative); 10 | return(btoa(full_code)); 11 | }; 12 | function contract_hash_maker2(oracle_id){ 13 | var c = contract_maker2(oracle_id); 14 | return(btoa(array_to_string(hash(string_to_array(atob(c)))))); 15 | }; 16 | function id_maker2(oracle_id, many_types) { 17 | var ch = contract_hash_maker2(oracle_id); 18 | return(id_maker(ch, many_types)); 19 | }; 20 | function id_maker( 21 | contract_hash, many_types, 22 | source_id, source_type) 23 | { 24 | if(!(source_id)){ 25 | source_id = btoa(array_to_string(integer_to_array(0, 32))); 26 | source_type = 0; 27 | }; 28 | var to_hash = 29 | string_to_array(atob(contract_hash)) 30 | .concat(string_to_array(atob(source_id))) 31 | .concat(integer_to_array(many_types, 2)) 32 | .concat(integer_to_array(source_type, 2)); 33 | return(btoa(array_to_string(hash(to_hash)))); 34 | }; 35 | function contract_hash_maker2(oracle_id){ 36 | var c = contract_maker2(oracle_id); 37 | return(btoa(array_to_string(hash(string_to_array(atob(c)))))); 38 | }; 39 | 40 | 41 | return({ 42 | id_maker: id_maker, 43 | id_maker2: id_maker2, 44 | contract2: contract_maker2, 45 | hash: contract_hash_maker2, 46 | }); 47 | })(); 48 | -------------------------------------------------------------------------------- /src/unused/otc_finisher.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Light Wallet - OTC Derivatives Finisher - Amoveo

8 | mainnet mode
9 | testnet mode
10 | test mode
11 | main menu for this light node.
12 | 13 | 14 | 15 | 16 | 17 | 18 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/unused/otc_listener.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Light Wallet - OTC Derivatives Listener - Amoveo

8 | mainnet mode
9 | testnet mode
10 | test mode
11 | main menu for this light node.
12 | 13 | 14 | 15 | 16 | 17 | 18 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/js/market_swap.js: -------------------------------------------------------------------------------- 1 | var market_swap = (function(){ 2 | var div = document.getElementById("market_swap"); 3 | var display = document.createElement("p"); 4 | div.appendChild(display); 5 | 6 | var mid = text_input("market id: ", div); 7 | div.appendChild(br()); 8 | var give = text_input("amount to spend: ", div); 9 | div.appendChild(br()); 10 | var take = text_input("recieve at least this much: ", div); 11 | div.appendChild(br()); 12 | var direction = text_input("direction of swap: ", div); 13 | div.appendChild(br()); 14 | var button = button_maker2("swap", doit); 15 | div.appendChild(button); 16 | 17 | async function doit(){ 18 | var Fee = 152050; 19 | //merkle.request_proof("accounts", keys.pub(), function(Acc){ 20 | var Acc = await merkle.arequest_proof("accounts", keys.pub()); 21 | //merkle.request_proof("markets", mid.value, async function(market){ 22 | var market = await merkle.arequest_proof("markets", mid.value); 23 | //-record(market, {id, cid1, type1, amount1, cid2, type2, amount2, shares}). 24 | var CID1 = market[2]; 25 | var Type1 = market[3]; 26 | var CID2 = market[5]; 27 | var Type2 = market[6]; 28 | var Nonce = Acc[2] + 1; 29 | //-record(market_swap_tx, {from, nonce, fee, mid, give, take, direction, cid1, type1, cid2, type2}). 30 | var tx = ["market_swap_tx", keys.pub(), 31 | Nonce, Fee, 32 | mid.value, parseInt(give.value), 33 | parseInt(take.value), 34 | parseInt(direction.value), 35 | CID1, Type1, 36 | CID2, Type2]; 37 | console.log(tx); 38 | var stx = keys.sign(tx); 39 | //post_txs([stx], function(msg){ 40 | var msg = await apost_txs([stx]); 41 | display.innerHTML = msg 42 | //}); 43 | //}); 44 | //}); 45 | }; 46 | return({ 47 | mid: function(x){mid.value = x}, 48 | give: function(x){give.value = x}, 49 | take: function(x){take.value = x}, 50 | direction: function(x){direction.value = x}, 51 | doit: doit 52 | }); 53 | })(); 54 | -------------------------------------------------------------------------------- /src/unused/new_contract.js: -------------------------------------------------------------------------------- 1 | var new_contract = (function(){ 2 | var div = document.getElementById("new_contract"); 3 | if(!(div)){ 4 | var div = document.createElement("div"); 5 | } 6 | var display = document.createElement("p"); 7 | div.appendChild(display); 8 | var full = btoa(array_to_string([255,255,255,255])); 9 | var empty = btoa(array_to_string([0,0,0,0])); 10 | 11 | var oracle_start_height = text_input("when it becomes possible to report on the outcome of the oracle question. a block height: ", div); 12 | div.appendChild(br()); 13 | var oracle_text = text_input("the question we ask the oracle", div); 14 | div.appendChild(br()); 15 | var button = button_maker2("make contract", make_contract); 16 | div.appendChild(button); 17 | function make_tx(Start, Text, Source, SourceType) { 18 | var oracle_id = id_maker(Start, 0, 0, Text);//from format 19 | var CH = binary_derivative.hash(oracle_id); 20 | var Fee = 152050; 21 | var MT = 3; 22 | if(!(Source)){ 23 | Source = btoa(array_to_string(integer_to_array(0, 32))); 24 | SourceType = 0; 25 | }; 26 | var tx = ["contract_new_tx", keys.pub(), CH, Fee, MT, Source, SourceType]; 27 | return(tx); 28 | } 29 | function make_contract(){ 30 | var Start = parseInt(oracle_start_height.value); 31 | var Text = oracle_text.value; 32 | 33 | var tx = make_tx(Start, Text); 34 | console.log(tx); 35 | var stx = keys.sign(tx); 36 | post_txs([stx], function(msg){ 37 | var CH = tx[2]; 38 | var MT = tx[4]; 39 | var Source = tx[5]; 40 | var SourceType = tx[6]; 41 | var cid = binary_derivative.id_maker(CH, MT, Source, SourceType); 42 | display.innerHTML = msg 43 | .concat("
the contract id is: ") 44 | .concat(cid); 45 | }); 46 | }; 47 | return({ 48 | start_height: function(x){oracle_start_height.value = x}, 49 | oracle_text: function(x){oracle_text.value = x}, 50 | make_tx: make_tx, 51 | make_publish_tx: make_contract 52 | }); 53 | })(); 54 | 55 | 56 | -------------------------------------------------------------------------------- /src/unused/uniswap.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Uniswap Tool - Amoveo

6 | mainnet mode
7 | testnet mode
8 | test mode
9 | main menu for this light node.
10 | 11 | 12 | 13 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |
34 | 35 | 36 | 37 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/js/market_viewer.js: -------------------------------------------------------------------------------- 1 | var market_viewer = (function(){ 2 | var div = document.getElementById("market_viewer"); 3 | var display = document.createElement("p"); 4 | div.appendChild(display); 5 | 6 | var mid = text_input("market id: ", div); 7 | div.appendChild(br()); 8 | var button = button_maker2("lookup market", doit); 9 | div.appendChild(button); 10 | 11 | async function doit(){ 12 | //merkle.request_proof("markets", mid.value, function(c) { 13 | var c = await merkle.arequest_proof("markets", mid.value); 14 | if(c == "empty") { 15 | display.innerHTML = "that market does not exist"; 16 | return(0); 17 | }; 18 | //-record(market, {id, cid1, type1, amount1, cid2, type2, amount2, shares}). 19 | //["market","7VcDtMRdZ0vTy9kzDoiMCiqveix/bs0t5qBla4fIWYE=","AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",0,1010000,"vWSumtEl1WBhxaeVzu/MdBQtdmnuWTXMtupnKTDJ+vI=",2,990099,1000000] 20 | console.log(c); 21 | var sub1 = ("") 22 | .concat("
contract 1: ") 23 | .concat(c[2]) 24 | .concat("
type 1: ") 25 | .concat(c[3]); 26 | if(c[2] == btoa(array_to_string(integer_to_array(0, 32)))){ 27 | sub1 = "
currency 1: veo "; 28 | }; 29 | var sub2 = ("") 30 | .concat("
cid 2: ") 31 | .concat(c[5]) 32 | .concat("
type 2: ") 33 | .concat(c[6]); 34 | if(c[5] == btoa(array_to_string(integer_to_array(0, 32)))){ 35 | sub1 = "
currency 2: veo "; 36 | }; 37 | 38 | display.innerHTML = ("market id: ") 39 | .concat(c[1]) 40 | .concat(sub1) 41 | .concat("
amount 1: ") 42 | .concat(c[4]) 43 | .concat(sub2) 44 | .concat("
amount 2: ") 45 | .concat(c[7]) 46 | .concat("
shares: ") 47 | .concat(c[8]); 48 | //display.innerHTML = JSON.stringify(c); 49 | //console.log(JSON.stringify(c)); 50 | //}); 51 | }; 52 | return({ 53 | mid: function(x){mid.value = x}, 54 | doit: doit 55 | }); 56 | })(); 57 | -------------------------------------------------------------------------------- /src/js/encryption.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Light Wallet - encryption - Amoveo

7 | mainnet mode
8 | testnet mode
9 | test mode
10 | main menu for this light node.
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 41 | 42 | -------------------------------------------------------------------------------- /src/unused/otc_derivatives.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Light Wallet - OTC Derivatives - Amoveo

7 | mainnet mode
8 | testnet mode
9 | test mode
10 | main menu for this light node.
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 41 | 42 | 43 | 44 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/js/wallet/create_binary_tab_builder.js: -------------------------------------------------------------------------------- 1 | function create_binary_tab_builder(div, selector){ 2 | var ZERO = btoa(array_to_string(integer_to_array(0, 32))); 3 | var display = document.createElement("div"); 4 | var title = document.createElement("h3"); 5 | title.innerHTML = "Create a new binary derivative and a market for it "; 6 | div.appendChild(title); 7 | div.appendChild(br()); 8 | div.appendChild(display); 9 | div.appendChild(br()); 10 | var selector_label = document.createElement("span"); 11 | selector_label.innerHTML = "source currency (i.e. the collateral backing the contract): "; 12 | div.appendChild(selector_label); 13 | div.appendChild(selector); 14 | div.appendChild(br()); 15 | 16 | var oracle_text = text_input("A statement that will be either true or false (i.e. trump is elected for second consecutive term as president)", div); 17 | div.appendChild(br()); 18 | var probability_text = text_input("initial probability of TRUE outcome. should be between 0 and 1.", div); 19 | div.appendChild(br()); 20 | var amount_text = text_input("amount of source currency to put into the market as liquidity", div); 21 | div.appendChild(br()); 22 | var button = button_maker2("make contract", make_contract); 23 | div.appendChild(button); 24 | 25 | function make_contract(){ 26 | var Text = oracle_text.value; 27 | var MP = 1; 28 | var price = parseFloat(probability_text.value); 29 | if(price<0){ 30 | console.log("price must be greater than 0"); 31 | return(0); 32 | }; 33 | if(price>1){ 34 | console.log("price must be less than 1"); 35 | return(0); 36 | }; 37 | var amount = Math.round(parseFloat(amount_text.value)*token_units()); 38 | //return(tabs.create.make_contract2(Text, MP, price, amount, display)); 39 | return(tabs.tabs.create.tab.make_contract2(Text, MP, price, amount, display, selector));//todo. this is from create_tab_builder.js Maybe we should add that module to a more usable namespace. Maybe move this pure function to a library file if possible. 40 | }; 41 | return({ 42 | oracle:(function(x){oracle_text.value = x}), 43 | probability:(function(x){probability_text.value = x}) 44 | }); 45 | }; 46 | -------------------------------------------------------------------------------- /src/js/verkle/finite_inverse.js: -------------------------------------------------------------------------------- 1 | var finite_inverse = (function(){ 2 | 3 | function mul(a, b, N){ 4 | var c = a * b % N; 5 | return(c); 6 | }; 7 | function pis(l, N){ 8 | var a = 1n; 9 | var r = []; 10 | for(var i = 0; i= b){return([]);}; 5 | return([BigInt(a)].concat(range(a+1, b))); 6 | }; 7 | function calc_domain(many){ 8 | return(range(1, many+1)); 9 | }; 10 | 11 | var cached_domain; 12 | function stringify_bigint_list(d){ 13 | var d2 = []; 14 | d.map(function(x){ 15 | d2 = d2.concat(x.toString()); 16 | }); 17 | return(JSON.stringify(d2)); 18 | }; 19 | function parse_bigint_list(d){ 20 | var d2 = JSON.parse(d); 21 | return(d2.map(function(x){ 22 | return(BigInt(x)); 23 | })); 24 | }; 25 | function domain(){ 26 | var result = cache_helper( 27 | cached_domain, "precompute_domain", 28 | function(){return(calc_domain(256))}, 29 | stringify_bigint_list, parse_bigint_list); 30 | cached_domain = result; 31 | return(result); 32 | }; 33 | 34 | function cache_helper( 35 | cache, ls_string, calc, stringify, parse){ 36 | if(cache){return(cache)}; 37 | var ls = localStorage.getItem(ls_string); 38 | if(ls){return(parse(ls));}; 39 | var x = calc(); 40 | localStorage.setItem(ls_string, stringify(x)); 41 | return(x); 42 | }; 43 | 44 | var cached_da;//256 big integers 45 | function da(){ 46 | var result = cache_helper( 47 | cached_da, "precompute_da", 48 | function(){return(poly.calc_da(domain()))}, 49 | stringify_bigint_list, parse_bigint_list); 50 | cached_da = result; 51 | return(result); 52 | }; 53 | 54 | var cached_a; 55 | function a(){ 56 | var result = cache_helper( 57 | cached_a, "precompute_a", 58 | function(){return(poly.calc_a(domain()))}, 59 | stringify_bigint_list, parse_bigint_list); 60 | cached_a = result; 61 | return(result); 62 | }; 63 | 64 | var cached_ghq; 65 | function ghq(){ 66 | if(cached_ghq){ 67 | return(cached_ghq); 68 | }; 69 | var x = points.basis(256); 70 | cached_ghq = x; 71 | return(x); 72 | }; 73 | 74 | return({ 75 | ghq: ghq, 76 | da: da, 77 | a: a, 78 | domain: domain 79 | }); 80 | })(); 81 | -------------------------------------------------------------------------------- /src/js/txs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Light Wallet - Txs - Amoveo

7 | mainnet mode
8 | testnet mode
9 | test mode
10 | main menu for this light node.
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 | -------------------------------------------------------------------------------- /src/js/employment.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Employment

7 | mainnet mode
8 | testnet mode
9 | test mode
10 | main menu for this light node.
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 | -------------------------------------------------------------------------------- /src/js/explorers/lookup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Light Wallet - Lookup - Amoveo

7 | mainnet mode
8 | testnet mode
9 | test mode
10 | main menu for this light node.
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 | -------------------------------------------------------------------------------- /src/js/examples/functions.js: -------------------------------------------------------------------------------- 1 | 2 | function hash2integer(h) { 3 | function hash2integer2(h, i, n) { 4 | var x = h[i]; 5 | if ( x == 0 ) { 6 | return hash2integer2(h, i+1, n+(256*8)); 7 | } else { 8 | return n + hash2integer3(x, h[i+1]); 9 | } 10 | } 11 | function dec2bin(dec){ 12 | n = (dec).toString(2); 13 | n="00000000".substr(n.length)+n; 14 | return n; 15 | } 16 | function hash2integer3(byte1, byte2) { 17 | var x = dec2bin(byte1).concat(dec2bin(byte2)); 18 | return hash2integer4(x, 0, 0); 19 | } 20 | function hash2integer4(binary, i, n) { 21 | var x = binary[i]; 22 | if ( x == "0" ) { return hash2integer4(binary, i+1, n+256) } 23 | else { 24 | var b2 = binary.slice(i, i+8); 25 | var y = hash2integer5(b2) + n; 26 | return y; 27 | } 28 | } 29 | function hash2integer5(bin) { 30 | var x = 0; 31 | for (var i=0; i < bin.length; i++) { 32 | var y = bin[i]; 33 | if ( y == "0" ) { x = x * 2; } 34 | else { x = 1 + (x * 2) } 35 | } 36 | return x; 37 | } 38 | return hash2integer2(h.concat([255]), 0, 0); 39 | } 40 | function newhash2integer(h) { 41 | function hash2integer2(h, i, n) { 42 | var x = h[i]; 43 | if ( x == 0 ) { 44 | return hash2integer2(h, i+1, n+(256*8)); 45 | } else { 46 | return n + hash2integer3(x, h[i+1]); 47 | } 48 | } 49 | function dec2bin(dec){ 50 | n = (dec).toString(2); 51 | n="00000000".substr(n.length)+n; 52 | return n; 53 | } 54 | function hash2integer3(byte1, byte2) { 55 | var x = dec2bin(byte1).concat(dec2bin(byte2)); 56 | return hash2integer4(x, 0, 0); 57 | } 58 | function hash2integer4(binary, i, n) { 59 | var x = binary[i]; 60 | if ( x == "0" ) { return hash2integer4(binary, i+1, n+256) } 61 | else { 62 | var b2 = binary.slice(i+1, i+9);//this is the only line that is different between hash2integer and newhash2integer 63 | var y = hash2integer5(b2) + n; 64 | return y; 65 | } 66 | } 67 | function hash2integer5(bin) { 68 | var x = 0; 69 | for (var i=0; i < bin.length; i++) { 70 | var y = bin[i]; 71 | if ( y == "0" ) { x = x * 2; } 72 | else { x = 1 + (x * 2) } 73 | } 74 | return x; 75 | } 76 | 77 | return hash2integer2(h.concat([255]), 0, 0); 78 | } 79 | -------------------------------------------------------------------------------- /src/js/oracle_bet.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Light Wallet - Oracle Bet - Amoveo

7 | mainnet mode
8 | testnet mode
9 | test mode
10 | main menu for this light node.
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 | -------------------------------------------------------------------------------- /src/js/oracle_close.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Light Wallet - Oracle Close - Amoveo

7 | mainnet mode
8 | testnet mode
9 | test mode
10 | main menu for this light node.
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 | -------------------------------------------------------------------------------- /src/js/subcurrency_combiner.js: -------------------------------------------------------------------------------- 1 | var subcurrency_combiner = (function(){ 2 | 3 | var div = document.getElementById("subcurrency_combiner"); 4 | var display = document.createElement("p"); 5 | div.appendChild(display); 6 | 7 | var contract_id = text_input("contract_id: ", div); 8 | div.appendChild(contract_id); 9 | div.appendChild(br()); 10 | var button = button_maker2("combine subcurrencies into veo", doit); 11 | div.appendChild(button); 12 | div.appendChild(br()); 13 | 14 | async function doit(){ 15 | var account = await rpc.apost(["account", keys.pub()]); 16 | var contract = await merkle.arequest_proof("contracts", contract_id.value); 17 | var nonce = account[2] + 1; 18 | var fee = 152050; 19 | var many_types = contract[2]; 20 | var amount = await amount_calc(many_types, 10000000000000000, contract_id.value); 21 | if(amount > -1) { 22 | display.innerHTML = "You don't have a complete set of shares for this market. you cannot withdraw to source currency." 23 | return(0); 24 | } 25 | var source = contract[8]; 26 | var source_type = contract[9]; 27 | var txs = []; 28 | var use_tx = ["contract_use_tx", 29 | keys.pub(), 30 | nonce, 31 | fee, 32 | contract_id.value, 33 | amount, 34 | many_types, 35 | source, 36 | source_type 37 | ]; 38 | var is_closed = contract[6]; 39 | var sink = contract[10]; 40 | if(is_closed === 1){ 41 | [win1, win2] = await buy_veo_contract.both_winners(contract_id.value); 42 | use_tx[4] = sink; 43 | txs = txs.concat([win1, win2]); 44 | }; 45 | txs = txs.concat([use_tx]); 46 | var tx = await multi_tx.amake(txs); 47 | console.log(JSON.stringify(tx)); 48 | var stx = keys.sign(tx); 49 | var x = await apost_txs([stx]); 50 | display.innerHTML = x; 51 | }; 52 | async function amount_calc(N, amount, cid) { 53 | if(N == 0){ 54 | return(-amount); 55 | }; 56 | var key = sub_accounts.key(keys.pub(), cid, N); 57 | key = btoa(array_to_string(key)); 58 | var sa = await rpc.apost(["sub_accounts", key]); 59 | var sub_amount = sa[1]; 60 | return(amount_calc(N-1, Math.min(sub_amount, amount), cid)); 61 | }; 62 | return({ 63 | contract_id: function(x){ contract_id.value = x} 64 | }); 65 | })(); 66 | -------------------------------------------------------------------------------- /src/js/verkle/main.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | //order of the finite field used to define ed25519. 3 | //2^255 - 19. 4 | var Order = fq.order(); 5 | var EllipticGroupOrder = 7237005577332262213973186563042994240857116359379907606001950938285454250989n;//order of the elliptic curve group ed25519, div 8. 6 | var Extended = nobleEd25519.ExtendedPoint; 7 | var Point = nobleEd25519.Point; 8 | 9 | 10 | function first_three_test() { 11 | //testing that point addition and doubling are the same as in the erlang version. 12 | var Base = Extended.fromAffine(Point.BASE); 13 | var Base2 = Base.add(Base); 14 | var Base3 = Base2.add(Base); 15 | var P = ([Base, Base2, Base3]).map( 16 | function(x) { return(x.toAffine())}); 17 | //console.log([P[2].x, P[2].y]); 18 | return((46896733464454938657123544595386787789046198280132665686241321779790909858396n == P[2].x) && 19 | (8324843778533443976490377120369201138301417226297555316741202210403726505172n == P[2].y)); 20 | 21 | } 22 | console.log(first_three_test()); 23 | 24 | var compressed_base_64 = 25 | "dZ4jcH5gd9CYeZNrreS1t5ylmFYjluSJ4sq8VT+dooc="; 26 | function decompress_base_test(){ 27 | var r = points.compressed2affine(compressed_base_64); 28 | console.log(r); 29 | return(r); 30 | }; 31 | function test_eq(){ 32 | //testing that addition and doubling calculate the same things, and that the equals function works. 33 | var base = Extended.fromAffine(Point.BASE); 34 | var base4 = base.double().double(); 35 | var base4b = base.add(base).add(base).add(base); 36 | if(!(points.eq(base4, base4b))){ 37 | return(["error", "unequal"]); 38 | }; 39 | return("success"); 40 | }; 41 | function test_hash(){ 42 | var base = Extended.fromAffine(Point.BASE); 43 | var h = points.hash(base); 44 | return(h == 1776483211286933621438884453533311676776004902530881175740560331936951997513n); 45 | }; 46 | function test_multi_exponent(){ 47 | var base = Extended.fromAffine(Point.BASE); 48 | var base4 = base.double().double(); 49 | var base4b = multi_exponent.doit( 50 | [2n, 1n, 1n], [base, base, base]); 51 | console.log([base4, base4b]); 52 | if(!(points.eq(base4, base4b))){ 53 | return(["error", "unequal"]); 54 | }; 55 | return("success"); 56 | }; 57 | console.log(test_eq()); 58 | console.log(test_hash()); 59 | console.log(test_multi_exponent()); 60 | 61 | })(); 62 | -------------------------------------------------------------------------------- /src/js/verkle_original/main.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | //order of the finite field used to define ed25519. 3 | //2^255 - 19. 4 | var Order = fq.order(); 5 | var EllipticGroupOrder = 7237005577332262213973186563042994240857116359379907606001950938285454250989n;//order of the elliptic curve group ed25519, div 8. 6 | var Extended = nobleEd25519.ExtendedPoint; 7 | var Point = nobleEd25519.Point; 8 | 9 | 10 | function first_three_test() { 11 | //testing that point addition and doubling are the same as in the erlang version. 12 | var Base = Extended.fromAffine(Point.BASE); 13 | var Base2 = Base.add(Base); 14 | var Base3 = Base2.add(Base); 15 | var P = ([Base, Base2, Base3]).map( 16 | function(x) { return(x.toAffine())}); 17 | //console.log([P[2].x, P[2].y]); 18 | return((46896733464454938657123544595386787789046198280132665686241321779790909858396n == P[2].x) && 19 | (8324843778533443976490377120369201138301417226297555316741202210403726505172n == P[2].y)); 20 | 21 | } 22 | console.log(first_three_test()); 23 | 24 | var compressed_base_64 = 25 | "dZ4jcH5gd9CYeZNrreS1t5ylmFYjluSJ4sq8VT+dooc="; 26 | function decompress_base_test(){ 27 | var r = points.compressed2affine(compressed_base_64); 28 | console.log(r); 29 | return(r); 30 | }; 31 | function test_eq(){ 32 | //testing that addition and doubling calculate the same things, and that the equals function works. 33 | var base = Extended.fromAffine(Point.BASE); 34 | var base4 = base.double().double(); 35 | var base4b = base.add(base).add(base).add(base); 36 | if(!(points.eq(base4, base4b))){ 37 | return(["error", "unequal"]); 38 | }; 39 | return("success"); 40 | }; 41 | function test_hash(){ 42 | var base = Extended.fromAffine(Point.BASE); 43 | var h = points.hash(base); 44 | return(h == 1776483211286933621438884453533311676776004902530881175740560331936951997513n); 45 | }; 46 | function test_multi_exponent(){ 47 | var base = Extended.fromAffine(Point.BASE); 48 | var base4 = base.double().double(); 49 | var base4b = multi_exponent.doit( 50 | [2n, 1n, 1n], [base, base, base]); 51 | console.log([base4, base4b]); 52 | if(!(points.eq(base4, base4b))){ 53 | return(["error", "unequal"]); 54 | }; 55 | return("success"); 56 | }; 57 | console.log(test_eq()); 58 | console.log(test_hash()); 59 | console.log(test_multi_exponent()); 60 | 61 | })(); 62 | -------------------------------------------------------------------------------- /src/js/wallet/create_scalar_tab_builder.js: -------------------------------------------------------------------------------- 1 | 2 | function create_scalar_tab_builder(div, selector){ 3 | var ZERO = btoa(array_to_string(integer_to_array(0, 32))); 4 | var display = document.createElement("div"); 5 | var title = document.createElement("h3"); 6 | title.innerHTML = "Create a new scalar derivative and a market for it "; 7 | div.appendChild(title); 8 | div.appendChild(br()); 9 | div.appendChild(display); 10 | div.appendChild(br()); 11 | var selector_label = document.createElement("span"); 12 | selector_label.innerHTML = "source currency (i.e. the collateral backing the contract): "; 13 | div.appendChild(selector_label); 14 | div.appendChild(selector); 15 | div.appendChild(br()); 16 | 17 | 18 | var oracle_text = text_input("A value that will be publicly known in the future (i.e. the temperature in a location as recorded on a particular website)", div); 19 | div.appendChild(br()); 20 | var guess_text = text_input("initial guess of what the outcome will be.", div); 21 | div.appendChild(br()); 22 | var min_text = text_input("lower limit of the range of values that this contract can measure.", div); 23 | div.appendChild(br()); 24 | var max_text = text_input("upper limit of the range of values that this contract can measure.", div); 25 | div.appendChild(br()); 26 | var amount_text = text_input("amount of source currency to put into the market as liquidity", div); 27 | div.appendChild(br()); 28 | 29 | var button = button_maker2("make contract", make_contract); 30 | div.appendChild(button); 31 | 32 | function make_contract(){ 33 | //MP is max price. we should rescale min to zero. 34 | var min = parseInt(min_text.value, 10); 35 | var guess = parseInt(guess_text.value, 10) - min; 36 | var MP = parseInt(max_text.value, 10) - 37 | min; 38 | var Text = oracle_text.value 39 | .concat(" minus ") 40 | .concat(min); 41 | //.concat("; in the range from 0 to ") 42 | //.concat(MP); 43 | var price = guess / MP; 44 | var amount = Math.round(parseFloat(amount_text.value)*token_units()); 45 | if(price<0){ 46 | console.log("initial guess must be greater than the minimum value that can be measured"); 47 | return(0); 48 | }; 49 | if(price>1){ 50 | console.log("initial guess must be less than the maximum value that can be measured"); 51 | return(0); 52 | }; 53 | 54 | return(tabs.tabs.create.tab.make_contract2(Text, MP, price, amount, display, selector)); 55 | }; 56 | return({ 57 | 58 | }); 59 | }; 60 | -------------------------------------------------------------------------------- /src/js/explorers/offer_explorer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Amoveo - Offer Explorer

6 | main menu for this light node.
7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 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 | -------------------------------------------------------------------------------- /src/js/new_oracle.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Light Wallet - New Oracle - Amoveo

7 | mainnet mode
8 | testnet mode
9 | test mode
10 | main menu for this light node.
11 |
12 | Instructions about how to format oracles
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 | -------------------------------------------------------------------------------- /src/js/simplified_scalar_oracle_creation.js: -------------------------------------------------------------------------------- 1 | var simplified_scalar_oracle_creation = (function(){ 2 | var div = document.getElementById("simplified_scalar_oracle_creation"); 3 | var display = document.createElement("p"); 4 | div.appendChild(display); 5 | var cid_text = text_input("contract id: ", div); 6 | div.appendChild(br()); 7 | 8 | var next_button = button_maker2("next", next); 9 | div.appendChild(next_button); 10 | 11 | var more_options = document.createElement("div"); 12 | div.appendChild(more_options); 13 | 14 | async function next(){ 15 | more_options.innerHTML = ""; 16 | var Start = headers_object.top()[1] - 2; 17 | var cid = cid_text.value; 18 | var contract = await rpc.apost(["read", 3, cid], get_ip(), 8090); 19 | console.log(cid); 20 | console.log(contract); 21 | var oracle_text = atob(contract[1]); 22 | var max_price = contract[3]; 23 | var source = contract[5]; 24 | var source_type = contract[6]; 25 | [price, liquidity] = await price_estimate_read( 26 | cid, source, source_type); 27 | var price_guess = Math.round(price * max_price); 28 | var price_text = text_input("final price (for binary, 1=true, 0=false): ", more_options); 29 | price_text.value = price_guess; 30 | more_options.appendChild(price_text); 31 | var info = document.createElement("div"); 32 | info.innerHTML = "oracle with text: " 33 | .concat(oracle_text) 34 | .concat("
with max price: ") 35 | .concat(max_price); 36 | more_options.appendChild(info); 37 | var make_oracle_button = button_maker2("make_oracle", async function(){ 38 | var price = parseInt(price_text.value, 10); 39 | console.log(max_price); 40 | console.log(price); 41 | var FullText = scalar_oracle_creation.fulltext( 42 | price, max_price, 43 | oracle_text); 44 | var oid = id_maker(Start, 0,0, FullText); 45 | var tx1 = ["oracle_new", 0,0,0, 46 | btoa(FullText), Start, 47 | oid, 0, 0, 0]; 48 | var bet_amount = 2220000; 49 | var tx2 = ["oracle_bet", 0, 0, 0, 50 | oid, 1, bet_amount]; 51 | var tx = await multi_tx.amake([tx1, tx2]); 52 | var stx = keys.sign(tx); 53 | var msg = await apost_txs([stx]); 54 | display.innerHTML = msg 55 | .concat("
") 56 | .concat("with oracle id ") 57 | .concat(oid); 58 | }); 59 | more_options.appendChild(make_oracle_button); 60 | }; 61 | })(); 62 | -------------------------------------------------------------------------------- /src/unused/unused.js: -------------------------------------------------------------------------------- 1 | 2 | function channel_feeder_simplify_helper(from, ss) { 3 | var cd = channel_manager[from]; 4 | var spk = cd.me; 5 | var unlocked = spk_bet_unlock(spk, ss); 6 | var ret = sign_tx(unlocked.spk); 7 | return {ss: unlocked.ssremaining, spk: ret}; 8 | } 9 | function api_bet_unlock(ip, port) { 10 | //get server id int server_id; 11 | var unlocked_object = channel_feeder_bets_unlock(server_id); 12 | teach_secrets(unlocked_object.secrets, ip, port); 13 | var msg = ["spk", my_pubkey]; 14 | //use msg to get themspk 15 | channel_feeder_update_to_me(them_spk, server_id); 16 | return "ok"; 17 | } 18 | function channel_feeder_bets_unlock(server_id) { 19 | var cd = channel_manager[server_id]; 20 | if (!(true == cd.live)) { 21 | console.log("this channel has been closed"); 22 | throw("this channel was closed"); 23 | } 24 | var spk_me = cd.me; 25 | var ss_old = cd.ssme; 26 | var unlock_object = spk_bet_unlock(spk_me, ss_old); 27 | cd.me = unlock_object.spk; 28 | cd.ssme = unlock_object.newss; 29 | cd.ssthem = unlock_object.ssthem; 30 | channel_manager[server_id] = cd; 31 | return {"secrets":unlock_object.secrets, 32 | "spk":unlock_object.spk}; 33 | } 34 | function spk_bet_unlock(spk, ss) { 35 | var remaining = JSON.parse(JSON.stringify(bets)); 36 | var amount_change = 0; 37 | var ssremaining = JSON.parse(JSON.stringify(ss)); 38 | var secrets = []; 39 | var dnonce = 0; 40 | var bets = spk[4]; 41 | var key; 42 | var ssthem; 43 | var f; 44 | for (var i = ss.length - 1, i > -1, i--) { 45 | key = bet[i].key; 46 | ssthem = ss[i]; 47 | console.log("ssthem is "); 48 | console.log(JSON.stringify(ssthem)); 49 | throw("working here"); 50 | //look up fun limit and var limit and gas limit from config file. 51 | //verify none of in ssthem 52 | f = spk_prove_facts( 53 | } 54 | spk.bets = remaining; 55 | spk.amount += amount_change; 56 | spk.nonce += dnonce; 57 | return {"ssremaining": ssremaining, 58 | "spk": spk, //make sure to change spk in a few ways; 59 | "secrets": secrets, 60 | "ssthem": ssthem}; 61 | } 62 | function teach_secrets(secrets, ip, port) { 63 | for (var i = 0; i < secrets.length; i++) { 64 | var msg = ["learn_secret", my_pubkey, secrets[i].secret, secrets[i].code]; 65 | } 66 | return "ok"; 67 | } 68 | -------------------------------------------------------------------------------- /src/js/subcurrency_set_buy.js: -------------------------------------------------------------------------------- 1 | var subcurrency_set_buy = (function(){ 2 | 3 | var div = document.getElementById("subcurrency_set_buy"); 4 | var display = document.createElement("p"); 5 | div.appendChild(display); 6 | 7 | var contract_id = text_input("contract_id: ", div); 8 | div.appendChild(contract_id); 9 | div.appendChild(br()); 10 | var amount_input = text_input("amount: ", div); 11 | div.appendChild(amount_input); 12 | div.appendChild(br()); 13 | var button = button_maker2("buy/sell the complete set of subcurrencies for one market", doit); 14 | div.appendChild(button); 15 | div.appendChild(br()); 16 | 17 | async function doit(){ 18 | console.log("get account"); 19 | var account = await rpc.apost(["account", keys.pub()]); 20 | if(account == "empty"){ 21 | display.innerHTML = "load an account first"; 22 | return(0); 23 | }; 24 | //var contract = await merkle.arequest_proof("contracts", contract_id.value); 25 | console.log("get contract"); 26 | var contract = await rpc.apost(["contracts", contract_id.value]); 27 | console.log("got contract"); 28 | if(contract == "empty"){ 29 | console.log("that contract does not exist"); 30 | display.innerHTML = "that contract does not exist"; 31 | return(0); 32 | }; 33 | var nonce = account[2] + 1; 34 | var fee = 152050; 35 | var many_types = contract[2]; 36 | var amount = parseInt(amount_input.value); 37 | var source = contract[8]; 38 | var source_type = contract[9]; 39 | var tx = ["contract_use_tx", 40 | keys.pub(), 41 | nonce, 42 | fee, 43 | contract_id.value, 44 | amount, 45 | many_types, 46 | source, 47 | source_type 48 | ]; 49 | console.log(tx); 50 | var stx = keys.sign(tx); 51 | var msg = await apost_txs([stx]); 52 | display.innerHTML = msg; 53 | }; 54 | async function amount_calc(N, amount, cid, callback) { 55 | if(N == 0){ 56 | return(callback(amount)); 57 | }; 58 | var key = sub_accounts.key(keys.pub(), cid, N); 59 | key = btoa(array_to_string(key)); 60 | var sa = await merkle.arequest_proof("sub_accounts", key); 61 | var sub_amount = sa[1]; 62 | amount_calc(N-1, Math.min(sub_amount, amount), cid, callback); 63 | }; 64 | return({ 65 | contract_id: function(x){ contract_id.value = x}, 66 | amount: function(x){ amount_input.value = x}, 67 | doit: doit 68 | }); 69 | })(); 70 | -------------------------------------------------------------------------------- /src/unused/trading.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |

Amoveo Trade Explorer

6 | main menu for this light node.
7 | Download 8 | Create 9 | Explore
10 | Buy VEO on Telegram 11 | 12 | 13 | 14 | 15 | 16 | 17 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
62 | 63 | 64 | -------------------------------------------------------------------------------- /src/unused/resolve_binary_contract.js: -------------------------------------------------------------------------------- 1 | var resolve_binary_contract = (function(){ 2 | var div = document.getElementById("resolve_binary_contract"); 3 | var display = document.createElement("p"); 4 | div.appendChild(display); 5 | var oracle_text = text_input("oracle text: ", div); 6 | // div.appendChild(oracle_text); 7 | div.appendChild(br()); 8 | var oracle_height = text_input("oracle start height: ", div); 9 | // div.appendChild(oracle_height); 10 | div.appendChild(br()); 11 | var button = button_maker2("resolve", resolve); 12 | div.appendChild(button); 13 | div.appendChild(br()); 14 | 15 | function resolve(){ 16 | var oid = id_maker(parseInt(oracle_height.value), 17 | 0,0, oracle_text.value); 18 | var cid = binary_derivative.id_maker2(oid, 3); 19 | merkle.request_proof("accounts", keys.pub(), function(my_acc){ 20 | merkle.request_proof("oracles", oid, function(oracle){ 21 | merkle.request_proof("contracts", cid, function(contract){ 22 | if(contract == "empty"){ 23 | display.innerHTML = "contract does not yet exist"; 24 | console.log(cid); 25 | return(0); 26 | }; 27 | if(oracle == "empty"){ 28 | display.innerHTML = "oracle does not yet exist"; 29 | return(0); 30 | }; 31 | if(oracle[2] == 0){ 32 | display.innerHTML = "oracle is not yet resolved"; 33 | console.log(oracle); 34 | return(0); 35 | }; 36 | var nonce = my_acc[2] + 1; 37 | var fee = 152050; 38 | var contract = binary_derivative.contract2(oid); 39 | var tx = ["contract_evidence_tx", 40 | keys.pub(), 41 | nonce, fee, contract, 42 | cid, "", 43 | [-6, ["oracles", oid]]]; 44 | console.log(tx); 45 | var stx = keys.sign(tx); 46 | post_txs([stx], function(msg){ 47 | //display.innerHTML = msg; 48 | 49 | var tx = ["contract_timeout_tx2", 50 | keys.pub(), 51 | nonce + 1, fee, cid, 0, 52 | 0, 0, 0] 53 | var stx = keys.sign(tx); 54 | post_txs([stx], function(msg2){ 55 | display.innerHTML = msg.concat("
").concat(msg2); 56 | }); 57 | }); 58 | }); 59 | }); 60 | }); 61 | }; 62 | //make timeout tx 63 | //make resolve tx 64 | return({ 65 | oracle_height: function(x){oracle_height.value = x}, 66 | oracle_text: function(x){oracle_text.value = x}, 67 | resolve: resolve 68 | }); 69 | })(); 70 | -------------------------------------------------------------------------------- /src/js/new_scalar_contract.js: -------------------------------------------------------------------------------- 1 | var new_scalar_contract = (function(){ 2 | var div = document.getElementById("new_scalar_contract"); 3 | if(!(div)){ 4 | var div = document.createElement("div"); 5 | }; 6 | var display = document.createElement("p"); 7 | div.appendChild(display); 8 | var full = btoa(array_to_string([255,255,255,255])); 9 | var empty = btoa(array_to_string([0,0,0,0])); 10 | 11 | var oracle_text = text_input("the question we ask the oracle", div); 12 | div.appendChild(br()); 13 | var max_price_text = text_input("maximum value we can measure with this oracle", div); 14 | div.appendChild(br()); 15 | var source = text_input("source contract (leave blank for veo): ", div); 16 | div.appendChild(br()); 17 | var source_type = text_input("source subcurrency type (leave blank for veo): ", div); 18 | div.appendChild(br()); 19 | var button = button_maker2("make contract", make_contract); 20 | div.appendChild(button); 21 | 22 | async function make_contract(){ 23 | var Text = oracle_text.value; 24 | var MP = parseInt(max_price_text.value); 25 | if(MP<1){ 26 | display.innerHTML = "max price must be an integer"; 27 | return(0); 28 | } 29 | var Source, SourceType; 30 | if(source.value == ""){ 31 | Source = btoa(array_to_string(integer_to_array(0, 32))); 32 | SourceType = 0; 33 | } else { 34 | Source = source.value; 35 | SourceType = parseInt(source_type.value); 36 | }; 37 | var tx = make_tx(Text, MP, Source, SourceType); 38 | var CH = tx[2]; 39 | var cid = merkle.contract_id_maker(CH, 2); 40 | 41 | setTimeout(async function(){ 42 | var msg = 43 | ["add", 3, btoa(Text), 44 | 0, MP, Source, 45 | SourceType]; 46 | var x = await rpc.apost(msg, get_ip(), 8090); 47 | console.log(x); 48 | console.log("taught a scalar contract."); 49 | return(0); 50 | }, 0); 51 | 52 | var stx = keys.sign(tx); 53 | var msg = await apost_txs([stx]); 54 | display.innerHTML = msg 55 | .concat("
the contract id is
") 56 | .concat(cid); 57 | }; 58 | function make_tx(text, max_price, Source, SourceType){ 59 | var contract = scalar_derivative.maker(text, max_price); 60 | var CH = scalar_derivative.hash(contract); 61 | var Fee = 152050; 62 | var MT = 2; 63 | if(!(Source)){ 64 | Source = btoa(array_to_string(integer_to_array(0, 32))); 65 | SourceType = 0; 66 | }; 67 | var tx = ["contract_new_tx", keys.pub(), CH, Fee, MT, Source, SourceType]; 68 | return(tx); 69 | }; 70 | return({ 71 | text: function(x){oracle_text.value = x}, 72 | max: function(x){max_price_text.value = x}, 73 | make_tx: make_tx 74 | }); 75 | })(); 76 | -------------------------------------------------------------------------------- /src/js/oracle_winnings.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Light Wallet - Oracle Winnings - Amoveo

7 | mainnet mode
8 | testnet mode
9 | test mode
10 | main menu for this light node.
11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/js/explorers/account_explorer.js: -------------------------------------------------------------------------------- 1 | (async function(){ 2 | var div = document.createElement("div"); 3 | document.body.appendChild(div); 4 | server_port.value = "8080"; 5 | if (server_ip.value == "") { 6 | server_ip.value = default_ip(); 7 | }; 8 | const urlParams = new URLSearchParams(window.location.search); 9 | var pubkey = urlParams.get('pubkey'); 10 | pubkey = pubkey.replace(/\ /g, "+"); 11 | 12 | div.appendChild(br()); 13 | 14 | var pubkey_text = document.createElement("div"); 15 | pubkey_text.innerHTML = "pubkey: " 16 | .concat(pubkey); 17 | div.appendChild(pubkey_text); 18 | 19 | var balance_text = document.createElement("div"); 20 | balance_text.innerHTML = "balance: ?"; 21 | div.appendChild(balance_text); 22 | 23 | var account = await rpc.apost( 24 | ["account", pubkey]); 25 | var balance = account[1]; 26 | 27 | balance_text.innerHTML = "balance: " 28 | .concat((balance/100000000).toFixed(8)); 29 | 30 | var account = await rpc.apost( 31 | ["account", pubkey], get_ip(), 8091); 32 | var acc = account[1]; 33 | console.log(acc); 34 | var txs = acc[2]; 35 | var sub_accs = acc[3]; 36 | var liquidity_shares = acc[4]; 37 | var worker_for = acc[5].slice(1); 38 | var boss_of = acc[6].slice(1); 39 | 40 | function link(ref, text){ 41 | var link = document.createElement("a"); 42 | link.href = ref; 43 | link.innerHTML = text; 44 | link.target = "_blank"; 45 | return(link); 46 | }; 47 | 48 | if (worker_for.length > 0){ 49 | //make links for all the workers. 50 | div.appendChild(title("has jobs")); 51 | worker_for.map(function(id){ 52 | var s = ""; 53 | s = s.concat(id); 54 | s = s.concat("
"); 55 | var l = link("./jobs_explorer.html?jid=".concat(id), s); 56 | div.appendChild(l); 57 | }); 58 | div.appendChild(br()); 59 | }; 60 | if (boss_of.length > 0) { 61 | //make links for all the bosses. 62 | div.appendChild(title("has employees")); 63 | boss_of.map(function(id){ 64 | var s = ""; 65 | s = s.concat(id); 66 | s = s.concat("
"); 67 | var l = link("./jobs_explorer.html?jid=".concat(id), s); 68 | div.appendChild(l); 69 | }); 70 | div.appendChild(br()); 71 | }; 72 | div.appendChild(title("transactions starting with the most recent")); 73 | make_tx_links(txs.slice(1)); 74 | 75 | function make_tx_links(txs){ 76 | if(txs.length === 0){ 77 | return(0); 78 | }; 79 | var txid = txs[0]; 80 | var link = document.createElement("a"); 81 | link.href = "tx_explorer.html?txid=" 82 | .concat(txid); 83 | link.innerHTML = txid; 84 | link.target = "_blank"; 85 | div.appendChild(link); 86 | div.appendChild(br()); 87 | return(make_tx_links(txs.slice(1))); 88 | }; 89 | 90 | })(); 91 | -------------------------------------------------------------------------------- /src/unused/wallet.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |

Light Wallet - Amoveo

7 | mainnet mode
8 | testnet mode
9 | test mode
10 | amoveo home website
11 | light-node main page
12 | Tool for asking the oracle questions.
13 | Tool for proposing custom P2P derivative contracts.
14 | Tool for accepting proposals of custom P2P derivative contracts.
15 | Tool for settling contracts to get your money out. For closing channels.
16 | Explorer on same server
17 | Explorer on Zack's server
18 |

blockchain

19 | 20 | 21 |

Units have been switched back to VEO from mVEO. 1 VEO = 1000 mVEO

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 | -------------------------------------------------------------------------------- /src/js/publish_swap_offer.js: -------------------------------------------------------------------------------- 1 | var publish_swap_offer = (function() { 2 | var div = document.getElementById("publish_swap_offer"); 3 | var display = document.createElement("p"); 4 | div.appendChild(display); 5 | 6 | var s_ip = text_input("server ip: ", div); 7 | div.appendChild(br()); 8 | s_ip.value = get_ip(); 9 | 10 | var s_port = text_input("server port: ", div); 11 | div.appendChild(br()); 12 | 13 | s_port.value = "8090"; 14 | 15 | var offer = text_input("offer: ", div); 16 | div.appendChild(br()); 17 | 18 | var button = button_maker2("publish the offer", publish); 19 | 20 | div.appendChild(button); 21 | div.appendChild(br()); 22 | 23 | async function publish(){ 24 | var x = JSON.parse(offer.value); 25 | var cid1 = x[1][4]; 26 | var zero = btoa(array_to_string(integer_to_array(0,32))); 27 | if(!(cid1 == zero)){ 28 | var first = await rpc.apost(["read", 3, cid1], s_ip.value, parseInt(s_port.value)); 29 | if(first == 0){ 30 | display.innerHTML = "contract " 31 | .concat(cid1) 32 | .concat(" is unknown to the server"); 33 | return(0); 34 | } else { 35 | return(publish2(zero, x)); 36 | } 37 | } else { 38 | return(publish2(zero, x)); 39 | }; 40 | }; 41 | async function publish2(zero, x) { 42 | var cid2 = x[1][7]; 43 | var second_offer = 0; 44 | if(!(cid2 == zero)){ 45 | var second = await rpc.apost(["read", 3, cid2], s_ip.value, parseInt(s_port.value)); 46 | if(second == 0) { 47 | display.innerHTML = "contract " 48 | .concat(cid2) 49 | .concat(" is unknown to the server"); 50 | return(0); 51 | } else { 52 | if(second[0] == "binary"){ 53 | var f = swaps.unpack(x); 54 | var C = { 55 | acc1: keys.pub(), 56 | end_limit: 9999999999, 57 | amount1: f.amount2, 58 | cid1: f.cid2, 59 | type1: f.type2, 60 | amount2: Math.floor(f.amount2 * 0.99), 61 | fee1: 200000, 62 | nonce: f.nonce 63 | }; 64 | second_offer = swaps.pack(C); 65 | }; 66 | return(publish3(x, second_offer)); 67 | } 68 | } else { 69 | return(publish3(x, 0)); 70 | } 71 | }; 72 | async function publish3(x, second_offer){ 73 | var z = await rpc.apost(["add", x, second_offer], s_ip.value, parseInt(s_port.value)); 74 | display.innerHTML = "successfully sent the swap offer to the server."; 75 | }; 76 | return({ip: function(x){ s_ip.value = x}, 77 | port: function(x){ s_port.value = x}, 78 | offer: function(x){ offer.value = x}, 79 | publish: publish 80 | }); 81 | })(); 82 | -------------------------------------------------------------------------------- /src/js/scalar_oracle_creation.js: -------------------------------------------------------------------------------- 1 | var scalar_oracle_creation = (function(){ 2 | var div = document.getElementById("scalar_oracle_creation"); 3 | if(!(div)){ 4 | div = document.createElement("div"); 5 | }; 6 | var display = document.createElement("p"); 7 | div.appendChild(display); 8 | 9 | var oracle_start_height = text_input("when it becomes possible to report on the outcome of the oracle question. a block height: ", div); 10 | div.appendChild(br()); 11 | var oracle_text = text_input("the question we ask the oracle", div); 12 | div.appendChild(br()); 13 | var max_price_text = text_input("maximum value we can measure with this oracle", div); 14 | div.appendChild(br()); 15 | var final_price_text = text_input("resulting price measured with this oracle", div); 16 | div.appendChild(br()); 17 | var button = button_maker2("make oracle", make_oracle); 18 | div.appendChild(button); 19 | function fulltext(fpt, mpt, ot){ 20 | var final_price_b = parseInt(fpt); 21 | var MaxVal = 4294967295; 22 | var max_price = parseInt(mpt); 23 | var final_price = Math.floor(MaxVal * final_price_b / max_price); 24 | var FullText = 25 | scalar_derivative.oracle_text(mpt, ot) 26 | .concat(final_price); 27 | return(FullText); 28 | }; 29 | async function make_oracle(){ 30 | var Start = parseInt(oracle_start_height.value); 31 | var FullText = fulltext(final_price_text.value, 32 | max_price_text.value, 33 | oracle_text.value) 34 | var oid = id_maker(Start, 0,0, FullText); 35 | console.log(Start); 36 | console.log(FullText); 37 | //MaxPrice = 5000; MaxVal = 4294967295; B = btc price in USD - 10000 from $0 to $MaxPrice; max(0, min(MaxVal, (B * MaxVal / MaxPrice)) is 3000 38 | //MaxPrice = 5000; MaxVal = 4294967295; B = btc price in USD - 10000 from $0 to $MaxPrice; max(0, min(MaxVal, (B * MaxVal / MaxPrice)) is 2576980377 39 | 40 | var fee = 152050; 41 | var tx1 = ["oracle_new", 0,0,0, 42 | btoa(FullText), Start, 43 | oid, 0, 0, 0]; 44 | var bet_amount = 2220000; 45 | var tx2 = ["oracle_bet", 0, 0, 0, 46 | oid, 1, bet_amount]; 47 | //multi_tx.make([tx1, tx2], async function(tx){ 48 | var tx = await multi_tx.amake([tx1, tx2]); 49 | console.log(tx); 50 | var stx = keys.sign(tx); 51 | //post_txs([stx], function(msg){ 52 | var msg = await apost_txs([stx]); 53 | display.innerHTML = msg 54 | .concat("
") 55 | .concat("with oracle id ") 56 | .concat(oid); 57 | //}); 58 | //}); 59 | }; 60 | return({ 61 | height: function(x){oracle_start_height.value = x}, 62 | text: function(x){oracle_text.value = x}, 63 | max: function(x){max_price_text.value = x}, 64 | price: function(x){final_price_text.value = x}, 65 | make_oracle: make_oracle, 66 | fulltext: fulltext 67 | }); 68 | 69 | })(); 70 | -------------------------------------------------------------------------------- /src/unused/binary_contract_winnings.js: -------------------------------------------------------------------------------- 1 | var binary_contract_winnings = (function(){ 2 | var div = document.getElementById("binary_contract_winnings"); 3 | var display = document.createElement("p"); 4 | div.appendChild(display); 5 | 6 | var contract_id = text_input("contract_id: ", div); 7 | div.appendChild(br()); 8 | var button = button_maker2("claim your prize", claim); 9 | div.appendChild(button); 10 | div.appendChild(br()); 11 | 12 | function claim(){ 13 | 14 | //-record(contract_winnings_tx, {from, nonce, fee, contract_id, amount, sub_account, winner, proof, row}). 15 | var cid = contract_id.value; 16 | merkle.request_proof("contracts", cid, function(contract){ 17 | merkle.request_proof("accounts", keys.pub(), function(acc){ 18 | var nonce = acc[2] + 1; 19 | var many = contract[2]; 20 | var payout_vector; 21 | var full = btoa(array_to_string([255,255,255,255])); 22 | var empty = btoa(array_to_string([0,0,0,0])); 23 | console.log(contract[7]); 24 | if(contract[7] == "NBRCGxgxiDQiCVZvrU4MByMHC0AwYw3eaFunAoHpJyU="){ 25 | payout_vector = [-6, full, empty, empty]; 26 | } else if(contract[7] == "ivW7MuSPsbRsYacyjBG6Z/QUn7MY+/VatVeUDZ0X0tk=") { 27 | payout_vector = [-6, empty, full, empty]; 28 | } else { 29 | payout_vector = [-6, empty, empty, full]; 30 | }; 31 | claim2(many, cid, nonce, payout_vector); 32 | }); 33 | }); 34 | }; 35 | function claim2(N, cid, nonce, payout_vector){ 36 | if(N<1){ 37 | return(0); 38 | } 39 | var key = sub_accounts.normal_key(keys.pub(), cid, N); 40 | merkle.request_proof("sub_accounts", key, function(sa){ 41 | if(!(sa == "empty")){ 42 | var bal = sa[1]; 43 | var scale = payout_vector[N]; 44 | if((bal > 0) && (!(scale == "AAAAAA=="))){ 45 | var fee = 152050; 46 | var tx = [ 47 | "contract_winnings_tx", 48 | keys.pub(), nonce, fee, 49 | cid, bal, 50 | key, keys.pub(), 51 | payout_vector, 0]; 52 | var stx = keys.sign(tx); 53 | return(rpc.post(["txs", [-6, stx]], 54 | function(x) { 55 | if(x == "ZXJyb3I="){ 56 | display.innerHTML = "server rejected the tx"; 57 | }else{ 58 | claim2(N-1, cid, nonce+1, payout_vector); 59 | display.innerHTML = "accepted trade offer and published tx. the tx id is ".concat(x); 60 | }})); 61 | } 62 | }; 63 | return(claim2(N-1, cid, nonce, payout_vector)); 64 | }); 65 | }; 66 | 67 | return({ 68 | contract_id: function(x){contract_id.value = x} 69 | }); 70 | })(); 71 | -------------------------------------------------------------------------------- /src/js/home.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 | 14 |

Light Wallet - Main Menu - Amoveo

15 | Learn about Amoveo
16 | Send VEO, receive VEO, sign txs, and publish txs. Used for cold storage.
17 | Encrypt and decrypt messages
18 |

Smart Contracts

19 | Easy Trading tool
20 | Advanced Smart Contract Tools
21 | a list of Amoveo contracts
22 | test out the smart contract language
23 | 24 | 34 |

Explorers

35 | Explorer on same server for blocks, accounts, hashrate, difficulty, blockrate.
36 | Explorer on Zack's server
37 | view a list of amoveo full nodes
38 | Lookup oracles, governance values, and more data from the blockchain
39 | The current market cap
40 |
41 |

Employment

42 | tools
43 |
44 |

Oracles

45 | List of oracles recently referenced on-chain
46 | Ask the oracle a new questions to bet on.
47 | Make a report to help the oracle resolve.
48 | Close an oracle.
49 | get your money out of a closed oracle.
50 |
51 | 52 | 53 | -------------------------------------------------------------------------------- /src/js/verkle_original/fq.js: -------------------------------------------------------------------------------- 1 | var fq = (function(){ 2 | 3 | //we only need montgomery encoding stuff to be able to decode the points in the proof. 4 | //all the math tools we export are over integers mod the group size. It is not using montgomery encoding. 5 | 6 | const IN = 21330121701610878104342023554231983025602365596302209165163239159352418617883n; 7 | const N = 57896044618658097711785492504343953926634992332820282019728792003956564819949n;//order of group used to define ed25519. (2^255) - 19 8 | const R = 115792089237316195423570985008687907853269984665640564039457584007913129639936n; 9 | const R2 = 1444n; 10 | 11 | function redc(x){ 12 | var tb = x % R; 13 | var m = (tb * IN) % R; 14 | var t2 = (x + (m * N)) / R; 15 | if (t2 > N){return (t2 - N);} 16 | else{return(t2)}; 17 | }; 18 | function decode(x){ 19 | return(redc(x)); 20 | }; 21 | //function mul(x, y){ 22 | // return(redc(x*y)); 23 | //}; 24 | function encode(x){ 25 | if((x > N)||(x < 0)){ 26 | return(["error", "can't montgomery encode outside of bounds"]); 27 | } else { 28 | return(redc(R2 * x)); 29 | }; 30 | }; 31 | function order(){ 32 | var x = N; 33 | return(x); 34 | }; 35 | function mul(a, b){ 36 | var c = a * b % N; 37 | return(c); 38 | }; 39 | function sub(a, b) { 40 | var c = a - b; 41 | if(c > 0){ 42 | return(c); 43 | } else { 44 | return(N + c); 45 | }; 46 | }; 47 | function neg(a) { 48 | return(N - a); 49 | }; 50 | function add(a, b){ 51 | var c = a + b; 52 | if(c < N) { 53 | return(c); 54 | } else { 55 | return(c - N); 56 | }; 57 | }; 58 | function inv(a){ 59 | return(finite_inverse.doit(a, N)); 60 | }; 61 | function batch_inverse(l){ 62 | return(finite_inverse.batch(l, N)); 63 | }; 64 | function pow(X, P) { 65 | if(P == 0){ return(1n);} 66 | else if(P == 1){ return(X);} 67 | else if((P % 2n) == 0){ 68 | return(pow(mul(X, X), P / 2n)); 69 | } else { 70 | return(mul(X, pow(mul(X, X), P / 2n))); 71 | }; 72 | }; 73 | function sqrt(A){ 74 | //var V = (A * 2n) ** ((N - 5n) / 8n); 75 | var V = pow(A*2n, ((N - 5n) / 8n)); 76 | var AV = mul(A, V); 77 | var I = mul(mul(2n, AV), V); 78 | var R = mul(AV, sub(I, 1n)); 79 | return([R, neg(R)]); 80 | }; 81 | function is_positive(N){ 82 | var M = encode(N); 83 | return((M % 2n) == 0); 84 | }; 85 | 86 | 87 | return({ 88 | decode: decode, 89 | encode:encode, 90 | order: order, 91 | mul: mul, 92 | sub: sub, 93 | neg: neg, 94 | add: add, 95 | inv: inv, 96 | batch_inverse: batch_inverse, 97 | pow: pow, 98 | sqrt: sqrt, 99 | is_positive: is_positive 100 | }); 101 | })(); 102 | -------------------------------------------------------------------------------- /src/js/new_market.js: -------------------------------------------------------------------------------- 1 | var new_market = (function(){ 2 | var div = document.getElementById("new_market"); 3 | if(!(div)){ 4 | div = document.createElement("div"); 5 | }; 6 | var display = document.createElement("p"); 7 | div.appendChild(display); 8 | var cid1 = text_input("subcurrency contract 1 (leave blank for veo): ", div); 9 | div.appendChild(br()); 10 | var type1 = text_input("subcurrency contract 1 type (leave blank for veo): ", div); 11 | div.appendChild(br()); 12 | var amount1 = text_input("how much of the first kind of subcurrency you pay: ", div); 13 | div.appendChild(br()); 14 | var cid2 = text_input("subcurrency contract 2 (leave blank for veo): ", div); 15 | div.appendChild(br()); 16 | var type2 = text_input("subcurrency contract 2 type (leave blank for veo): ", div); 17 | div.appendChild(br()); 18 | var amount2 = text_input("how much of the second kind of subcurrency you pay: ", div); 19 | div.appendChild(br()); 20 | var button = button_maker2("make market", doit); 21 | div.appendChild(button); 22 | 23 | 24 | async function doit(){ 25 | var Fee = 152050; 26 | var CID1 = cid1.value; 27 | var CID2 = cid2.value; 28 | var Type1 = parseInt(type1.value); 29 | var Type2 = parseInt(type2.value); 30 | if(!CID1){ 31 | CID1 = btoa(array_to_string(integer_to_array(0, 32))); 32 | Type1 = 0; 33 | }; 34 | if(!CID2){ 35 | CID2 = btoa(array_to_string(integer_to_array(0, 32))); 36 | Type2 = 0; 37 | }; 38 | var tx = ["market_new_tx", keys.pub(), 0, Fee, 39 | CID1, CID2, 40 | Type1, 41 | Type2, 42 | parseInt(amount1.value), 43 | parseInt(amount2.value)]; 44 | var MID = mid(CID1, CID2, Type1, Type2); 45 | console.log(JSON.stringify(tx)); 46 | var stx = keys.sign(tx); 47 | //post_txs([stx], function(msg){ 48 | var msg = await apost_txs([stx]); 49 | display.innerHTML = msg 50 | .concat(" and the market id is ") 51 | .concat(MID); 52 | //}); 53 | }; 54 | function mid(CID1, CID2, Type1, Type2){ 55 | var V1 = array_to_int(string_to_array(atob(CID1))); 56 | var V2 = array_to_int(string_to_array(atob(CID2))); 57 | if((V1 < V2) || ((V1 === V2) && (Type1 < Type2))){ 58 | } else { 59 | return(mid(CID2, CID1, Type2, Type1)); 60 | } 61 | var MID = btoa(array_to_string( 62 | hash(string_to_array(atob(CID1)) 63 | .concat(string_to_array(atob(CID2))) 64 | .concat(integer_to_array(Type1, 2)) 65 | .concat(integer_to_array(Type2, 2))))); 66 | return(MID); 67 | }; 68 | 69 | return({ 70 | cid1: function(x){cid1.value = x}, 71 | type1: function(x){type1.value = x}, 72 | amount1: function(x){amount1.value = x}, 73 | cid2: function(x){cid2.value = x}, 74 | type2: function(x){type2.value = x}, 75 | amount2: function(x){amount2.value = x}, 76 | mid: mid, 77 | doit: doit 78 | }); 79 | })(); 80 | -------------------------------------------------------------------------------- /src/js/verkle/fq.js: -------------------------------------------------------------------------------- 1 | var fq = (function(){ 2 | 3 | //we only need montgomery encoding stuff to be able to decode the points in the proof. 4 | //all the math tools we export are over integers mod the group size. It is not using montgomery encoding. 5 | 6 | const IN = 21330121701610878104342023554231983025602365596302209165163239159352418617883n; 7 | const N = 57896044618658097711785492504343953926634992332820282019728792003956564819949n;//order of group used to define ed25519. (2^255) - 19 8 | const R = 115792089237316195423570985008687907853269984665640564039457584007913129639936n; 9 | const R2 = 1444n; 10 | 11 | function redc(x){ 12 | var tb = x % R; 13 | var m = (tb * IN) % R; 14 | var t2 = (x + (m * N)) / R; 15 | if (t2 > N){return (t2 - N);} 16 | else{return(t2)}; 17 | }; 18 | function decode(x){ 19 | return(redc(x)); 20 | }; 21 | //function mul(x, y){ 22 | // return(redc(x*y)); 23 | //}; 24 | function encode(x){ 25 | if((x > N)||(x < 0)){ 26 | return(["error", "can't montgomery encode outside of bounds"]); 27 | } else { 28 | return(redc(R2 * x)); 29 | }; 30 | }; 31 | function order(){ 32 | var x = N; 33 | return(x); 34 | }; 35 | function mul(a, b){ 36 | var c = a * b % N; 37 | return(c); 38 | }; 39 | function sub(a, b) { 40 | var c = a - b; 41 | if(c > 0){ 42 | return(c); 43 | } else { 44 | return(N + c); 45 | }; 46 | }; 47 | function neg(a) { 48 | return(N - a); 49 | }; 50 | function add(a, b){ 51 | var c = a + b; 52 | if(c < N) { 53 | return(c); 54 | } else { 55 | return(c - N); 56 | }; 57 | }; 58 | function inv(a){ 59 | return(finite_inverse.doit(a, N)); 60 | }; 61 | function batch_inverse(l){ 62 | return(finite_inverse.batch(l, N)); 63 | }; 64 | function pow(X, P) { 65 | if(P == 0){ return(1n);} 66 | else if(P == 1){ return(X);} 67 | else if((P % 2n) == 0){ 68 | return(pow(mul(X, X), P / 2n)); 69 | } else { 70 | return(mul(X, pow(mul(X, X), P / 2n))); 71 | }; 72 | }; 73 | function sqrt(A){ 74 | //var V = (A * 2n) ** ((N - 5n) / 8n); 75 | var V = pow(A*2n, ((N - 5n) / 8n)); 76 | var AV = mul(A, V); 77 | var I = mul(mul(2n, AV), V); 78 | var J = mul(AV, sub(I, 1n)); 79 | //console.log([A, V, AV, I, J, neg(J)]); 80 | return([J, neg(J)]); 81 | }; 82 | function is_positive(X){ 83 | var M = encode(X); 84 | return((M % 2n) == 0); 85 | }; 86 | 87 | 88 | return({ 89 | decode: decode, 90 | encode:encode, 91 | order: order, 92 | mul: mul, 93 | sub: sub, 94 | neg: neg, 95 | add: add, 96 | inv: inv, 97 | batch_inverse: batch_inverse, 98 | pow: pow, 99 | sqrt: sqrt, 100 | is_positive: is_positive 101 | }); 102 | })(); 103 | -------------------------------------------------------------------------------- /src/js/explorers/lookup_block.js: -------------------------------------------------------------------------------- 1 | (function(){ 2 | var lookup_block_height = document.createElement("INPUT"); 3 | lookup_block_height.setAttribute("type", "text"); 4 | var input_info = document.createElement("h8"); 5 | input_info.innerHTML = "block number: "; 6 | document.body.appendChild(document.createElement("br")); 7 | document.body.appendChild(input_info); 8 | document.body.appendChild(lookup_block_height); 9 | 10 | var lookup_block_button = document.createElement("BUTTON"); 11 | lookup_block_button.id = "lookup block number"; 12 | var lookup_block_button_text = document.createTextNode("lookup block"); 13 | lookup_block_button.appendChild(lookup_block_button_text); 14 | lookup_block_button.onclick = async function() { 15 | var num = parseInt(lookup_block_height.value, 10); 16 | var x = await rpc.apost(["block", num]); 17 | lookup_block2(x); 18 | }; 19 | document.body.appendChild(lookup_block_button); 20 | var current_block = document.createElement("div"); 21 | current_block.id = "block div"; 22 | document.body.appendChild(current_block); 23 | 24 | function to_now(t) { 25 | var start_time = 15192951759; 26 | var n = (t + start_time);//10 * seconds since jan 1 1970 27 | var curdate = new Date(null); 28 | curdate.setTime(n*100); 29 | var final_now = curdate.toLocaleString(); 30 | console.log(final_now); 31 | return final_now; 32 | } 33 | function exponent(a, b) {//a is type bigint. b is an int. 34 | if (b == 0) { return BigInt(1); } 35 | else if (b == 1) { return a; } 36 | //else if ((b % 2) == 0) {return exponent(a.times(a), Math.floor(b / 2)); } 37 | else if ((b % 2) == 0) {return exponent(a * a, b / 2); } 38 | //else {return a.times(exponent(a, b-1)); } 39 | else {return a * (exponent(a, b-1)); } 40 | } 41 | function sci2int(x) { 42 | function pair2int(l) { 43 | var b = l.pop(); 44 | var a = l.pop(); 45 | var c = exponent(BigInt(2), a);//c is a bigint 46 | //return c.times((256 + b)).divide(256); 47 | return c * ((256n + BigInt(b))) / 256n; 48 | } 49 | function sci2pair(i) { 50 | var a = Math.floor(i / 256); 51 | var b = i % 256; 52 | return [a, b]; 53 | } 54 | return pair2int(sci2pair(x)); 55 | } 56 | function lookup_block2(block) { 57 | block2 = block[1]; 58 | var diff = sci2int(block[5]); 59 | console.log("lookup block 2"); 60 | console.log(diff); 61 | var current_block = document.getElementById("block div"); 62 | if (block == "empty") { 63 | current_block.innerHTML = "this block doesn't exist."; 64 | } else { 65 | var miner = block[10][1][1]; 66 | var time0 = block[4]; 67 | var prev_hash = toHex(atob(block[2])); 68 | var time = to_now(time0); 69 | //acc, number, hash, txs, power, nonce, total_coins, db_root 70 | current_block.innerHTML = "block: ".concat(block[1]).concat("
was mined by: ").concat(miner).concat("
has timestamp: ").concat(time).concat("
prev hash: ").concat(prev_hash).concat("
difficulty: ").concat(diff / 1000000000000n); 71 | } 72 | } 73 | } 74 | )(); 75 | -------------------------------------------------------------------------------- /src/js/wallet/spend_tab_builder.js: -------------------------------------------------------------------------------- 1 | function spend_tab_builder(div, selector){ 2 | var ZERO = btoa(array_to_string(integer_to_array(0, 32))); 3 | var display = document.createElement("div"); 4 | var title = document.createElement("h3"); 5 | title.innerHTML = "Send currency"; 6 | div.appendChild(title); 7 | div.appendChild(br()); 8 | div.appendChild(display); 9 | div.appendChild(br()); 10 | var selector_label = document.createElement("span"); 11 | selector_label.innerHTML = "kind to send: "; 12 | div.appendChild(selector_label); 13 | div.appendChild(selector); 14 | div.appendChild(br()); 15 | var amount_text = text_input("how much to send: ", div); 16 | var max_button = button_maker2("max", calculate_max); 17 | div.appendChild(amount_text); 18 | div.appendChild(max_button); 19 | div.appendChild(br()); 20 | var recipient_text = text_input("who to send to: ", div); 21 | var button = button_maker2("send", send); 22 | div.appendChild(br()); 23 | div.appendChild(button); 24 | div.appendChild(br()); 25 | 26 | async function calculate_max(){ 27 | if(selector.value == "veo"){ 28 | var to = parse_address(recipient_text.value); 29 | spend_tx.max_send_amount(keys.pub(), to, function(m, tx_type){ 30 | amount_text.value = (m / token_units()).toString(); 31 | }); 32 | } else { 33 | var V = JSON.parse(selector.value); 34 | var cid = V[0]; 35 | var type = parseInt(V[1]); 36 | var trie_key = sub_accounts.key(keys.pub(), cid, type); 37 | var trie_key = btoa(array_to_string(trie_key)); 38 | var x = await merkle.arequest_proof("sub_accounts", trie_key); 39 | amount_text.value = write_veo(x[1]); 40 | }; 41 | }; 42 | async function send(){ 43 | var to = parse_address(recipient_text.value); 44 | var from = keys.pub(); 45 | var amount = Math.round(parseFloat(amount_text.value, 10)* token_units()); 46 | if(selector.value == "veo"){ 47 | var tx = await spend_tx.amake_tx(to, from, amount); 48 | var stx = keys.sign(tx); 49 | var msg = await apost_txs([stx]); 50 | display.innerHTML = msg; 51 | } else { 52 | var ma = await rpc.apost(["account", keys.pub()]); 53 | var V = JSON.parse(selector.value); 54 | var cid = V[0]; 55 | var type = parseInt(V[1]); 56 | var sk = sub_accounts.key(keys.pub(), cid, type); 57 | var sk = btoa(array_to_string(sk)); 58 | var balances_db = tabs.balances_db; 59 | console.log(sk); 60 | console.log(balances_db); 61 | if(balances_db[sk] && 62 | balances_db[sk].limit){ 63 | amount = Math.floor( 64 | amount / 65 | balances_db[sk].limit); 66 | }; 67 | var Nonce = ma[2] + 1; 68 | var fee = 152050; 69 | var tx = ["sub_spend_tx", 70 | keys.pub(), 71 | Nonce, 72 | fee, to, amount, 73 | cid, type]; 74 | var stx = keys.sign(tx); 75 | var msg = await apost_txs([stx]); 76 | display.innerHTML = msg; 77 | }; 78 | }; 79 | }; 80 | --------------------------------------------------------------------------------