136
General Discussion / nuBits: 9$ - nice peg
« on: February 06, 2015, 03:08:14 pm »not CMC's fault:
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
git clone https://github.com/xeroc/python-bitsharesrpc
cd python-bitsharesrpc
python setup install # (optionally with parameter --user fo non-root installations)
import bitsharesrpc
import config
rpc = bitsharesrpc.client(config.url, config.user, config.passwd)
any rpc command can be issued using the instance via the syntax rpc.command(parameters). Example:rpc.get_info()
rpc.open_wallet("default")
rpc.ask(account, amount, quote, price, base)
...
#!/usr/bin/python
import bitsharesrpc
import config
if __name__ == "__main__":
rpc = bitsharesrpc.client(config.url, config.user, config.passwd)
print(rpc.wallet_open(config.wallet))
print(rpc.unlock(999999, config.unlock))
#!/usr/bin/python
import bitsharesrpc
import config
if __name__ == "__main__":
rpc = bitsharesrpc.client(config.url, config.user, config.passwd)
print rpc.wallet_open("delegate")
print rpc.lock()
#!/usr/bin/python
import bitsharesrpc, json
rpc = bitsharesrpc.client("http://localhost:1998/rpc", "username", "password")
while 1:
cmd = raw_input(">>").split()
print(json.dumps(rpc.rpcexec({"method":cmd[0],"params":list(cmd[1:]),
"jsonrpc":"2.0","id":0}),indent=4))
url = "http://127.0.0.1:19988/rpc"
user = 'username'
passwd = 'pwd'
unlock = "unlockPwd"
wallet = "default"
accountname = "delegate.xeroc" # the delegate
exchangename = "exchange.xeroc" # a separate account to do the market operations
payoutname = "payouts.xeroc" # collect all funds to that account
partition = { # how to split the pay .. here 50% stay BTS 25% each for EUR and USD
"USD" : .25,
"EUR" : .25,
"BTS" : .5,
} ## BTS has to be last
spread = 0.02 # put ask 2% below feed
txfee = 0.1 # BTS
btsprecision = 1e5
#!/usr/bin/python
import requests
import json
class btsrpc(object) :
def __init__(self, url, user, pwd) :
self.auth = (user,pwd)
self.url = url
self.headers = {'content-type': 'application/json'}
def rpcexec(self,payload) :
try:
response = requests.post(self.url, data=json.dumps(payload), headers=self.headers, auth=self.auth)
return json.loads(response.text)
except:
raise Exception("Unkown error executing RPC call!")
def __getattr__(self, name) :
def method(*args):
r = self.rpcexec({
"method": name,
"params": args,
"jsonrpc": "2.0",
"id": 0
})
if "error" in r:
raise Exception(r["error"])
return r
return method
class btsrpcapi(btsrpc) :
def __init__(self, url, user, pwd) :
btsrpc.__init__(self, url, user, pwd)
### Room for Custom Functions: ###
def getassetbalance(self,name,asset) :
balance = self.wallet_account_balance(name)
for b in balance[ "result" ][ 0 ][ 1 ]:
if b[ 0 ] == asset : return float(b[ 1 ])
return -1
def setnetwork(self,d,m) :
return self.network_set_advanced_node_parameters({"desired_number_of_connections":d, "maximum_number_of_connections":m})
def orderhistory(self,a,b,l) :
return self.blockchain_market_order_history(a,b,1,l)
#!/usr/bin/python
from btsrpcapi import *
import config
if __name__ == "__main__":
rpc = btsrpcapi(config.url, config.user, config.passwd)
print rpc.info()
print rpc.wallet_open(config.wallet)
rpc.unlock(9999,config.unlock)
r = (rpc.wallet_list_my_accounts())
accounts = r["result"]
print "---------------------------------------------------------------------------------"
for account in accounts :
print "%20s - %s - %s" % (account["name"], account["owner_key"], rpc.wallet_dump_private_key(account["owner_key"]))
print "---------------------------------------------------------------------------------"
print rpc.lock()
#!/usr/bin/python
import csv
import os
from btsrpcapi import *
import config
rpc = btsrpcapi(config.backupurl, config.backupuser, config.backuppasswd)
rpc2 = btsrpcapi(config.mainurl, config.mainuser, config.mainpasswd)
def enable( ) :
print "checking connectivity"
rpc2.info()
rpc.info()
print "enabling backup block production"
rpc2.wallet_open("delegate")
rpc2.wallet_delegate_set_block_production("ALL","true")
rpc2.unlock(999999, config.mainunlock)
rpc2.setnetwork(25,30)
print "disabling main block production"
rpc.wallet_open("delegate")
rpc.lock()
rpc.wallet_delegate_set_block_production("ALL","false")
if __name__ == "__main__":
enable( )
## URL to RPC API of client
url = "http://10.0.0.16:19988/rpc"
## User as defined with --rpcuser=test or BitShares config file
user = 'username'
## User as defined with --rpcpassword=test or BitShares config file
passwd = 'password'
## Wallet name ( default: default :) )
wallet = "default"
## Unlock passphrase for the wallet
unlock = ""
## Delegate for which to publish a slate
delegate = "delegate.xeroc"
## Delegate which pays for the slate broadcast transaction
payee = "payouts.xeroc"
## NOTE: the private keys for both, "delegate" and "payee", must be in
## available in the wallet!
## List of trusted delegates
trusted = [
"a.delegate.charity",
"alecmenconi",
"angel.bitdelegate",
"b.delegate.charity",
"backbone.riverhead",
"bdnoble",
"bitcoiners",
"bitcube",
"bitsuperlab.gentso",
"clout-delegate1",
"crazybit"
"del.coinhoarder",
"dele-puppy",
"delegate.baozi",
"delegate.charity",
"delegate.jabbajabba",
"delegate.liondani",
"delegate.svk31",
"delegate.xeldal",
"delegate1.john-galt",
"forum.lottocharity",
"happyshares",
"luckybit",
"maqifrnswa",
"mr.agsexplorer",
"skyscraperfarms",
"spartako",
"testz",
"wackou.digitalgaia",
]
python main.py
Opening connection to client
Opening wallet delegate
Unlocking wallet
Unapproving all previously approve delegates
Approving trusted delegates
- a.delegate.charity
- alecmenconi
- angel.bitdelegate
- b.delegate.charity
- backbone.riverhead
- bdnoble
- bitcoiners
- bitcube
- bitsuperlab.gentso
- bts.fordream
- clout-delegate1
- crazybit
- del.coinhoarder
- dele-puppy
- delegate-clayop
- delegate.baozi
- delegate.charity
- delegate.jabbajabba
- delegate.liondani
- delegate.nathanhourt.com
- delegate.xeldal
- delegate1.john-galt
- dev.bitsharesblocks
- dev0.nikolai
- forum.lottocharity
- happyshares
- luckybit
- maqifrnswa
- marketing.methodx
- mr.agsexplorer
- skyscraperfarms
- spartako
- testz
- titan.crazybit
- wackou.digitalgaia
- dev-metaexchange.monsterer
- stan.delegate.xeldal
- bm.payroll.riverhead
- del0.cass
- argentina-marketing.matt608
- btstools.digitalgaia
- dev.sidhujag
- media-delegate
- jcalfee1-developer-team.helper.liondani
- media.bitscape
- provisional.bitscape
- valzav.payroll.testz
- elmato
- blackwavelabs
Broadcasting slate
Transactions ID: 88ed833a426d96ad93a95553e870da8eaaae7bd4
delegate (locked) >>> help wallet_market_submit_relative_ask
Usage:
wallet_market_submit_relative_ask <from_account_name> <sell_quantity> <sell_quantity_symbol> <relative_ask_price> <ask_price_symbol> [limit_ask_price] Used to place a request to sell a quantity of assets at a price specified in another asset
Used to place a request to sell a quantity of assets at a price specified in another asset
Parameters:
from_account_name (account_name, required): the account that will provide funds for the ask
sell_quantity (string, required): the quantity of items you would like to sell
sell_quantity_symbol (asset_symbol, required): the type of items you would like to sell
relative_ask_price (string, required): the relative price per unit sold.
ask_price_symbol (asset_symbol, required): the type of asset you would like to be paid
limit_ask_price (string, optional, defaults to ""): the minimum price per unit sold.
Returns:
transaction_record
aliases: relative_ask
delegate (locked) >>> help wallet_market_submit_relative_bid
Usage:
wallet_market_submit_relative_bid <from_account_name> <quantity> <quantity_symbol> <relative_price> <base_symbol> [limit_price] Used to place a request to buy a quantity of assets at a price specified in another asset
Used to place a request to buy a quantity of assets at a price specified in another asset
Parameters:
from_account_name (account_name, required): the account that will provide funds for the bid
quantity (string, required): the quantity of items you would like to buy
quantity_symbol (asset_symbol, required): the type of items you would like to buy
relative_price (string, required): the price relative to the feed you would like to pay
base_symbol (asset_symbol, required): the type of asset you would like to pay with
limit_price (string, optional, defaults to ""): the limit on what you are willing to pay
Returns:
transaction_record
aliases: relative_bid
you can do escrow/multisig as greenaddress.it and the other btc service i forgot the name to is doing. It would work that way:
1) all your funds require at least 2 out of 3 or 4 signatures
2) your have 1 installed on your computer and 2 in cold storage
3) the other key is installed at a service provider
4) you want to make a transaction and sign the tx ..
5) you mail your service provider with the built-in mailing app
6) your service provider sends a SMS or does some other kind of 2 faktor authentication
7) if the authentication is successfull the service provider also signs the tx and the tx gets valid
that way you can even include 2Fak via Google Authenticator or similar. Like a
extra for when you do your transaction that holds the 2fak code ..