Create our keys and retrieve the oracle account already set up
In [2]:
from multisigcore import *
from multisigcore.providers.electrum import ElectrumService
from multisigcore.oracle import PersonalInformation, OracleUnknownKeychainException
from multisigcore.hierarchy import MasterKey, MultisigAccount
from pycoin.services import get_tx_db
from pycoin.services import insight
from pycoin.serialize import b2h, h2b
secrets = [u'aaa4', u'bbb4']
keys = [MasterKey.from_master_secret(x).bip44_account(0) for x in secrets]
account = MultisigAccount(keys, complete=False)
oracle = Oracle(account, tx_db=get_tx_db())
oracle.verbose = 0
parameters = {"levels": [ {
"asset": "BTC",
"period": 3600,
"value": 1.0
}]}
try: oracle.get()
except OracleUnknownKeychainException: oracle.create(parameters, PersonalInformation())
print("http://btc.blockr.io/address/info/" + account.address(0))
account.set_lookahead(0)
service = insight.InsightService('https://insight.bitpay.com/')
#service = ElectrumService("electrum.no-ip.org", 50002)
account._provider = service
print(account.balance())
print(oracle._url())
Create a transaction spending funds previously sent, then sign
In [5]:
tx = account.tx([('17HXqN4Prf4o6sjAm2X43gLhwwzCrhAauZ', 50000)])
account.sign(tx)
res = oracle.sign(tx, "spend003")
print(res)
print(res.transaction.as_hex())