t_2_2 = builder_t_2_2.gen_tx() hash_t_2_2 = builder_t_2_2.gen_te().hash_meta() builder_t_2_1 = Builder(secret=kp_a_2_seed, sequence=starting_sequence_a_2+1) builder_t_2_1.append_payment_op( kp_alice.address().decode(), COUNTERPRIZE, 'XLM') builder_t_2_1.add_time_bounds(counter_tx_timebound) t_2_1 = builder_t_2_1.gen_tx() hash_t_2_1 = builder_t_2_1.gen_te().hash_meta() builder_t_1_0 = Builder(secret=kp_a_1_seed) builder_t_1_0.append_set_options_op(master_weight=255) builder_t_1_0.append_set_options_op(med_threshold=2) builder_t_1_0.append_set_options_op(high_threshold=254) builder_t_1_0.append_pre_auth_tx_signer(hash_t_1_2, 1) builder_t_1_0.append_pre_auth_tx_signer(hash_t_1_1, 1) builder_t_1_0.append_hashx_signer(hash_x_a, 1) builder_t_1_0.append_set_options_op(master_weight=0) builder_t_1_0.sign() builder_t_2_0 = Builder(secret=kp_a_2_seed) builder_t_2_0.append_set_options_op(master_weight=255) builder_t_2_0.append_set_options_op(med_threshold=2) builder_t_2_0.append_set_options_op(high_threshold=254) builder_t_2_0.append_pre_auth_tx_signer(hash_t_2_1, 1) builder_t_2_0.append_pre_auth_tx_signer(hash_t_2_2, 1) builder_t_2_0.append_hashx_signer(hash_x_b, 1) builder_t_2_0.append_set_options_op(master_weight=0) builder_t_2_0.sign()
def genptxs( systemdb, timestamp): """generates contract ptxs 1-3 given systemdb, including a contract manifest in production, will add ptxs will be hosted along with manifest on e.g. IPFS """ q = Query() a_sk = systemdb.search(q.name == 'Contract')[0]['sk'] a_pk = systemdb.search(q.name == 'Contract')[0]['pk'] pr_pk = systemdb.search(q.name == 'Printer')[0]['pk'] pi_pk = systemdb.search(q.name == 'Pipe')[0]['pk'] UND = systemdb.search(q.type == 'manifest')[0]['UND'] UND_pk = systemdb.search(q.type == 'manifest')[0]['UND_source'] QUO = systemdb.search(q.type == 'manifest')[0]['QUO'] QUO_pk = systemdb.search(q.type == 'manifest')[0]['QUO_source'] strike = systemdb.search(q.type == 'manifest')[0]['strike'] size = systemdb.search(q.type == 'manifest')[0]['size'] address = Address(address=a_pk, network='TESTNET') address.get() ####2 PREAUTH TX ONE ##### b = Builder( secret = str(a_sk), horizon_uri = 'https://horizon.stellar.org', network = 'TESTNET', sequence = int(address.sequence)+3) """seq incremented by two bc acct will need to add hash signer, data entry, and lock """ strikeXsize = str(int(strike)*int(size)) b.append_payment_op(pr_pk, '0.5', 'OCA', pr_pk) if QUO_pk == None: b.append_payment_op(pi_pk, strikeXsize, QUO, asset_issuer=None) else: b.append_payment_op(pi_pk, strikeXsize, QUO, QUO_pk) b.append_manage_offer_op('SPA', pr_pk, 'OCA', pr_pk, '0.0000001', '5000000', offer_id=0) b.append_manage_offer_op('GTA', pr_pk, 'SPA', pr_pk, '1', '0.0000001', offer_id=0) price = str(float(1)/int(size)) b.append_manage_offer_op(UND, UND_pk, 'GTA', pr_pk, str(size), price, offer_id=0) envelope1 = b.gen_te() hashish1 = envelope1.hash_meta() xdr1 = b.gen_xdr() systemdb.insert({ 'type': 'ptx', 'name': 'ptx1', 'xdr': xdr1 }) ####2 PREAUTH TX TWO ##### b2 = Builder( secret = a_sk, horizon_uri ='https://horizon.stellar.org', network = 'TESTNET', sequence = int(address.sequence)+3) b2.append_payment_op(pi_pk, str(strike), UND, UND_pk) b2.append_set_options_op(master_weight=1, low_threshold=0, med_threshold=0, high_threshold=0) envelope2 = b2.gen_te() hashish2 = envelope2.hash_meta() xdr2 = b2.gen_xdr() systemdb.insert({ 'type': 'ptx', 'name': 'ptx2', 'xdr': xdr2 }) ####2 PREAUTH TX THREE ##### b3 = Builder( secret = a_sk, horizon_uri ='https://horizon.stellar.org', network = 'TESTNET', sequence = int(address.sequence)+4) b3.append_set_options_op(master_weight=1, low_threshold=0, med_threshold=0, high_threshold=0) envelope3 = b3.gen_te() hashish3 = envelope3.hash_meta() xdr3 = b3.gen_xdr() systemdb.insert({ 'type': 'ptx', 'name': 'ptx3', 'xdr': xdr3 }) bX = Builder(secret = a_sk, network='TESTNET') bX.append_pre_auth_tx_signer(hashish1, 1, source=None) bX.append_pre_auth_tx_signer(hashish2, 1, source=None) bX.append_pre_auth_tx_signer(hashish3, 1, source=None) bX.sign() print bX.submit()