コード例 #1
0
    'node1.root-shard.mainnet.rchain.coop',
    'node2.root-shard.mainnet.rchain.coop',
    'node3.root-shard.mainnet.rchain.coop',
    'node4.root-shard.mainnet.rchain.coop',
    'node5.root-shard.mainnet.rchain.coop',
    'node6.root-shard.mainnet.rchain.coop',
    'node7.root-shard.mainnet.rchain.coop',
    'node8.root-shard.mainnet.rchain.coop'
]
READONLY_SERVER = [
    'observer-asia.services.mainnet.rchain.coop',
    'observer-us.services.mainnet.rchain.coop',
    'observer-eu.services.mainnet.rchain.coop'
]

admin_key = PrivateKey.generate()
contract = "@1!(2)"

exploratory_term = 'new return in{return!("a")}'

block_hash = '4d135ce5773a05a782d1c52a7dfb42c4142b1a471bc3c57d77eee4d5affdef9a'
find_deploy = '3045022100c4cdd5e8bb05b1627c2302ffd90393cf30ed0ad693ef63d46e5d8b99856a44c40220055b2dff342934b59b3fac5ac1f81c7b7763db9ee945809d86b04dbd48867bd4'

# read-only node can not deploy with deploy request
with RClient(READONLY_SERVER[0], 40401) as client:
    # get the latest 10 block in the rnode
    block_infos = client.show_blocks(depth=10)

    # get the detailed info in the rnode
    block = client.show_block(block_hash)
コード例 #2
0
#!/usr/bin/python

from rchain.crypto import PrivateKey
from pyrgov.rgov import rgovAPI

rgov = rgovAPI('localhost')
new1 = PrivateKey.generate()
new2 = PrivateKey.generate()
admin = rgov.get_private_key('bootstrap')

balance = rgov.checkBalance(admin.get_public_key().get_rev_address())
assert balance != 0

balance = rgov.checkBalance(new1.get_public_key().get_rev_address())
assert balance == 0

balance = rgov.checkBalance(new1.get_public_key().get_rev_address())
assert balance == 0

funds = 100000000
result = rgov.transfer(admin.get_public_key().get_rev_address(),
                       new1.get_public_key().get_rev_address(), funds, admin)
assert result[0]
result = rgov.transfer(admin.get_public_key().get_rev_address(),
                       new2.get_public_key().get_rev_address(), funds, admin)
assert result[0]

balance = rgov.checkBalance(new1.get_public_key().get_rev_address())
assert balance == funds
balance = rgov.checkBalance(new2.get_public_key().get_rev_address())
assert balance == funds
コード例 #3
0
from rchain.client import RClient
from rchain.crypto import PrivateKey
#from rchain.vault import VaultAPI
from pyrgov.rgov import rgovAPI

RCHAIN_SERVER = ['localhost', 'rhobot']

admin = PrivateKey.from_hex(
    '28a5c9ac133b4449ca38e9bdf7cacdce31079ef6b3ac2f0a080af83ecff98b36')
alpha = PrivateKey.from_hex(
    '7139b72b9939334ff76e1479072c0558dca2c3620971c2bb233a7b25a690d610')
bravo = PrivateKey.from_hex(
    'dd0dd23cd51460e6c42a154623df19372be332f0a61a51755603ab897f6ede39')
#alpha = PrivateKey.generate()
#bravo = PrivateKey.generate()
charlie = PrivateKey.generate()


def print_balances(rgov: rgovAPI):
    # get balance of vault
    admin_balance = rgov.checkBalance(admin.get_public_key().get_rev_address())
    print("admin Balance ", admin_balance, " REV ",
          admin.get_public_key().get_rev_address())
    alpha_balance = rgov.checkBalance(alpha.get_public_key().get_rev_address())
    print("alpha Balance ", alpha_balance, " REV ",
          alpha.get_public_key().get_rev_address())
    bravo_balance = rgov.checkBalance(bravo.get_public_key().get_rev_address())
    print("bravo Balance ", bravo_balance, " REV ",
          bravo.get_public_key().get_rev_address())
    charlie_balance = rgov.checkBalance(
        charlie.get_public_key().get_rev_address())
コード例 #4
0
ファイル: genkey.py プロジェクト: nzpr/letspay
from rchain.crypto import PrivateKey
import sys

if __name__ == "__main__":
    i = int(sys.argv[1])
    while i > 0:
        sk = PrivateKey.generate()
        pk = sk.get_public_key()
        w = pk.get_rev_address()
        print(sk.to_hex(), pk.to_hex(), w)
        i -= 1
コード例 #5
0
def generate_deployer_data():
    sk = PrivateKey.generate()
    pk = sk.get_public_key()
    rev = pk.get_rev_address()
    eth = pk.get_eth_address()
    return sk.to_hex(), pk.to_hex(), rev, eth
コード例 #6
0
ファイル: keys_example.py プロジェクト: vx-qa/pyrchain
from rchain.crypto import PrivateKey, PublicKey

# randomly generate private key
PrivateKey.generate()

# generate private key from hex
PrivateKey.from_hex(
    "ff2ba092524bafdbc85fa0c7eddb2b41c69bc9bf066a4711a8a16f749199e5be")

# generate private key from bytes
PrivateKey.from_bytes(
    b'\xff+\xa0\x92RK\xaf\xdb\xc8_\xa0\xc7\xed\xdb+A\xc6\x9b\xc9\xbf\x06jG\x11\xa8\xa1ot\x91\x99\xe5\xbe'
)

# generate private key from seed
PrivateKey.from_seed(1)

# generate private key from eth key path
PrivateKey.from_eth_keyfile('/path/to/the/key', 'password')

# generate public key from private key
PrivateKey.generate().get_public_key()

# generate public key from hex
PublicKey.from_hex(
    "04ad4793d81c5ee6c91c4baf2689c5299276c4774a8625fa87257f62ba8f3fe31f79d1351bd83af800afdaa94d40fe46c969f0ce2ac2e03e45d5a2d8a7687c39c0"
)

# generate public key from bytes
pub = PublicKey.from_bytes(
    b'\x04\xadG\x93\xd8\x1c^\xe6\xc9\x1cK\xaf&\x89\xc5)\x92v\xc4wJ\x86%\xfa\x87%\x7fb\xba\x8f?\xe3\x1fy\xd15\x1b\xd8:\xf8\x00\xaf\xda\xa9M@\xfeF\xc9i\xf0\xce*\xc2\xe0>E\xd5\xa2\xd8\xa7h|9\xc0'
コード例 #7
0
import time

from rchain.crypto import PrivateKey, PublicKey
from rchain.util import create_deploy_data, verify_deploy_data

private_key = PrivateKey.generate()
public_key = private_key.get_public_key()

contract = "@0!(2)"

deploy_data = create_deploy_data(key=private_key,
                                 term=contract, phlo_price=1,
                                 phlo_limit=100000,
                                 valid_after_block_no=10,
                                 timestamp_millis=int(time.time() * 1000))

assert verify_deploy_data(public_key, deploy_data.sig, deploy_data)