-
Notifications
You must be signed in to change notification settings - Fork 679
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #375 from RavenProject/release_2.1.0
Release 2.1.0 - Merge to Master
- Loading branch information
Showing
233 changed files
with
12,834 additions
and
3,378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#!/usr/bin/env python3 | ||
# Script to audit the assets | ||
# Reads the asset (amount has all issuances) | ||
# Reads the balances in every address for the asset. | ||
# Compares the two numbers to checks that qty of all assets are accounted for | ||
|
||
import subprocess | ||
import json | ||
|
||
|
||
#Set this to your raven-cli program | ||
cli = "raven-cli" | ||
|
||
mode = "-testnet" | ||
rpc_port = 18766 | ||
#mode = "-regtest" | ||
#rpc_port = 18443 | ||
|
||
#Set this information in your raven.conf file (in datadir, not testnet3) | ||
rpc_user = 'rpcuser' | ||
rpc_pass = 'rpcpass555' | ||
|
||
def listassets(filter): | ||
rpc_connection = get_rpc_connection() | ||
result = rpc_connection.listassets(filter, True) | ||
return(result) | ||
|
||
def listaddressesbyasset(asset): | ||
rpc_connection = get_rpc_connection() | ||
result = rpc_connection.listaddressesbyasset(asset) | ||
return(result) | ||
|
||
def rpc_call(params): | ||
process = subprocess.Popen([cli, mode, params], stdout=subprocess.PIPE) | ||
out, err = process.communicate() | ||
return(out) | ||
|
||
def generate_blocks(n): | ||
rpc_connection = get_rpc_connection() | ||
hashes = rpc_connection.generate(n) | ||
return(hashes) | ||
|
||
def get_rpc_connection(): | ||
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException | ||
connection = "http://%s:%[email protected]:%s"%(rpc_user, rpc_pass, rpc_port) | ||
#print("Connection: " + connection) | ||
rpc_connection = AuthServiceProxy(connection) | ||
return(rpc_connection) | ||
|
||
def audit(filter): | ||
assets = listassets(filter) | ||
print("Auditing: " + filter) | ||
#print(assets) | ||
print("Asset count: " + str(len(assets))) | ||
count = 0 | ||
max_dist_asset_name = "" | ||
max_dist_address_count = 0 | ||
for asset, properties in assets.items(): | ||
count=count+1 | ||
total_issued = 0 | ||
total_for_asset = 0 | ||
|
||
print("Auditing asset (" + str(count) + "): " + asset) | ||
for key, value in properties.items(): | ||
if (key == 'amount'): | ||
total_issued += value | ||
print("Total issued for " + asset + " is: " + str(value)) | ||
address_qtys = listaddressesbyasset(asset) | ||
|
||
address_count = 0 | ||
for address, qty in address_qtys.items(): | ||
address_count = address_count + 1 | ||
print(address + " -> " + str(qty)) | ||
total_for_asset += qty | ||
|
||
print("Total in addresses for asset " + asset + " is " + str(total_for_asset)) | ||
|
||
#Calculate stats | ||
if address_count > max_dist_address_count: | ||
max_dist_asset_name = asset | ||
max_dist_address_count = address_count | ||
|
||
if (total_issued == total_for_asset): | ||
print("Audit PASSED for " + asset) | ||
print("") | ||
else: | ||
print("Audit FAILED for " + asset) | ||
exit() | ||
|
||
if len(assets) == count: | ||
print("All " + str(len(assets)) + " assets audited.") | ||
print("Stats:") | ||
print(" Max Distribed Asset: " + max_dist_asset_name + " with " + str(max_dist_address_count) + " addresses.") | ||
|
||
|
||
|
||
if mode == "-regtest": #If regtest then mine our own blocks | ||
import os | ||
os.system(cli + " " + mode + " generate 400") | ||
|
||
audit("*") #Set to "*" for all. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#Shows data from the first 1000 blocks | ||
|
||
import random | ||
import os | ||
import subprocess | ||
import json | ||
|
||
|
||
#Set this to your raven-cli program | ||
cli = "raven-cli" | ||
|
||
#mode = "-testnet" | ||
mode = "" | ||
rpc_port = 8766 | ||
#Set this information in your raven.conf file (in datadir, not testnet3) | ||
rpc_user = 'rpcuser' | ||
rpc_pass = 'rpcpass555' | ||
|
||
|
||
def rpc_call(params): | ||
process = subprocess.Popen([cli, mode, params], stdout=subprocess.PIPE) | ||
out, err = process.communicate() | ||
return(out) | ||
|
||
def get_blockinfo(num): | ||
rpc_connection = get_rpc_connection() | ||
hash = rpc_connection.getblockhash(num) | ||
blockinfo = rpc_connection.getblock(hash) | ||
return(blockinfo) | ||
|
||
def get_rpc_connection(): | ||
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException | ||
connection = "http://%s:%[email protected]:%s"%(rpc_user, rpc_pass, rpc_port) | ||
#print("Connection: " + connection) | ||
rpc_connection = AuthServiceProxy(connection) | ||
return(rpc_connection) | ||
|
||
for i in range(1,1000): | ||
dta = get_blockinfo(i) | ||
print("Block #" + str(i)) | ||
print(dta.get('hash')) | ||
print(dta.get('difficulty')) | ||
print(dta.get('time')) | ||
print("") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
#Shows data from the transactions | ||
|
||
import random | ||
import os | ||
import subprocess | ||
import json | ||
|
||
|
||
#Set this to your raven-cli program | ||
cli = "raven-cli" | ||
|
||
mode = "-testnet" | ||
mode = "" | ||
rpc_port = 18766 | ||
#Set this information in your raven.conf file (in datadir, not testnet3) | ||
rpc_user = 'rpcuser' | ||
rpc_pass = 'rpcpass555' | ||
|
||
def get_rpc_connection(): | ||
from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException | ||
connection = "http://%s:%[email protected]:%s"%(rpc_user, rpc_pass, rpc_port) | ||
rpc_conn = AuthServiceProxy(connection) | ||
return(rpc_conn) | ||
|
||
rpc_connection = get_rpc_connection() | ||
|
||
def rpc_call(params): | ||
process = subprocess.Popen([cli, mode, params], stdout=subprocess.PIPE) | ||
out, err = process.communicate() | ||
process.stdout.close() | ||
process.stderr.close() | ||
return(out) | ||
|
||
def get_blockinfo(num): | ||
hash = rpc_connection.getblockhash(num) | ||
blockinfo = rpc_connection.getblock(hash) | ||
return(blockinfo) | ||
|
||
def get_block(hash): | ||
blockinfo = rpc_connection.getblock(hash) | ||
return(blockinfo) | ||
|
||
def get_rawtx(tx): | ||
txinfo = rpc_connection.getrawtransaction(tx) | ||
return(txinfo) | ||
|
||
def get_bci(): | ||
bci = rpc_connection.getblockchaininfo() | ||
return(bci) | ||
|
||
def decode_rawtx(txdata): | ||
#print("decoding: " + txdata) | ||
txjson = rpc_connection.decoderawtransaction(txdata) | ||
return(txjson) | ||
|
||
def decode_script(script): | ||
scriptinfo = rpc_connection.decodescript(script) | ||
return(scriptinfo) | ||
|
||
def ipfs_add(file): | ||
print("Adding to IPFS") | ||
import ipfsapi | ||
api = ipfsapi.connect('127.0.0.1', 5001) | ||
res = api.add(file) | ||
print(res) | ||
return(res['Hash']) | ||
|
||
def ipfs_get(hash): | ||
import ipfsapi | ||
api = ipfsapi.connect('127.0.0.1', 5001) | ||
res = api.get(hash) | ||
return() | ||
|
||
def ipfs_pin_add(hash): | ||
import ipfsapi | ||
api = ipfsapi.connect('127.0.0.1', 5001) | ||
res = api.pin_add(hash) | ||
return(res) | ||
|
||
def asset_handler(asset_script): | ||
# print("Type: " + asset_script.get('type')) | ||
# print("Asset: " + asset_script.get('asset_name')) | ||
# print(asset_script.get('amount')) | ||
# print(asset_script.get('units')) | ||
# print("Reissuable: " + str(asset_script.get('reissuable'))) | ||
# print("Has IPFS: " + str(asset_script.get('hasIPFS'))) | ||
if asset_script.get('hasIPFS') == True: | ||
print(asset_script.get('ipfs_hash')) | ||
ipfs_pin_add(asset_script.get('ipfs_hash')) | ||
|
||
#Get the blockheight of the chain | ||
blockheight = get_bci().get('blocks') | ||
|
||
for i in range(23500,blockheight): | ||
dta = get_blockinfo(i) | ||
print("Block #" + str(i) + " - " + dta.get('hash')) | ||
#print(dta.get('difficulty')) | ||
#print(dta.get('time')) | ||
|
||
tx_in_block = get_block(dta.get('hash')) | ||
txs = tx_in_block.get('tx') | ||
#print(txs) | ||
for tx in txs: | ||
tx_info = get_rawtx(tx) | ||
#print("txinfo: " + tx_info) | ||
tx_detail = decode_rawtx(tx_info) | ||
for vout in tx_detail.get('vout'): | ||
#print("vout: " + str(vout.get('value'))) | ||
#print(vout.get('scriptPubKey').get('asm')) | ||
if (vout.get('scriptPubKey').get('asm')[86:98] == "OP_RVN_ASSET"): | ||
#print("Found OP_RVN_ASSET") | ||
#print(vout.get('scriptPubKey').get('hex')) | ||
asset_script = decode_script(vout.get('scriptPubKey').get('hex')) | ||
asset_handler(asset_script) | ||
#print(asset_script) | ||
#print("txdecoded: " + tx_detail.get('vout')) | ||
|
||
|
||
#print("") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.