def sign_request_stewards(self, request, number_signers=4): """ Sign a request with stewards. """ assert number_signers <= len(self._stewards) for i in range(0, number_signers): fut = multi_sign_request(self._wallet_handle, self._stewards[i], request) request = self._looper.loop.run_until_complete(fut) return request
def sign_transaction(wallet_handle: int, did: str, transaction: str) -> str: try: return run_coroutine(ledger.multi_sign_request(wallet_handle, did, transaction)) except IndyError as err: if err.error_code == ErrorCode.CommonInvalidStructure: raise Exception('Invalid Transaction') raise Exception(err.message)
def sdk_multi_sign_request_objects(looper, sdk_wallets, reqs: Sequence): reqs_str = [json.dumps(req.as_dict) for req in reqs] for sdk_wallet in sdk_wallets: wallet_h, did = sdk_wallet reqs_str = [ looper.loop.run_until_complete( multi_sign_request(wallet_h, did, req)) for req in reqs_str ] return reqs_str
def mint_request(libsovtoken, payment_address, wallet, trustees, looper): mint_future = build_mint_req(wallet, trustees[0], json.dumps([{"recipient": payment_address, "amount": 10}]), None) mint_request, _ = looper.loop.run_until_complete(mint_future) for trustee in trustees: mint_future = multi_sign_request(wallet, trustee, mint_request) mint_request = looper.loop.run_until_complete(mint_future) mint_request = json.loads(mint_request) sigs = mint_request["signatures"] mint_request = sdk_json_to_request_object(mint_request) setattr(mint_request, "signatures", sigs) return mint_request
def set_fees_request(libsovtoken, looper, trustees, wallet, fees): set_fees_future = build_set_txn_fees_req(wallet, trustees[0], "sov", fees) set_fees_request = looper.loop.run_until_complete(set_fees_future) for trustee in trustees: set_fees_future = multi_sign_request(wallet, trustee, set_fees_request) set_fees_request = looper.loop.run_until_complete(set_fees_future) set_fees_request = json.loads(set_fees_request) sigs = set_fees_request["signatures"] set_fees_request = sdk_json_to_request_object(set_fees_request) setattr(set_fees_request, "signatures", sigs) return set_fees_request
def test_sigining_without_identifier(looper, txnPoolNodeSet, sdk_pool_handle, sdk_steward_seed, sdk_wallet_handle): req = {TXN_PAYLOAD: {TXN_PAYLOAD_DATA: {"aaa": "BBB"}}} steward_did_future = create_and_store_my_did( sdk_wallet_handle, json.dumps({"seed": sdk_steward_seed})) steward_did, _ = looper.loop.run_until_complete(steward_did_future) did_future = create_and_store_my_did(sdk_wallet_handle, json.dumps({})) did, verkey = looper.loop.run_until_complete(did_future) nym_future = build_nym_request(steward_did, did, verkey, None, None) nym = looper.loop.run_until_complete(nym_future) resp_future = sign_and_submit_request(sdk_pool_handle, sdk_wallet_handle, steward_did, nym) resp = looper.loop.run_until_complete(resp_future) req_future = multi_sign_request(sdk_wallet_handle, did, json.dumps(req)) req = looper.loop.run_until_complete(req_future) req = json.loads(req) sigs = txnPoolNodeSet[0].init_core_authenticator().authenticate(req) assert sigs == [did]
def sdk_multisign_request_object(looper, sdk_wallet, req): wh, did = sdk_wallet return looper.loop.run_until_complete(multi_sign_request(wh, did, req))
def test_mint_by_uncommitted_trustee(capsys, looper, nodeSetWithIntegratedTokenPlugin, sdk_wallet_trustee, helpers, addresses): """ Check that a Trustee not committed yet can sign a MINT txn. """ uncommitted_size_before_domain = get_uncommitted_txns_count_for_pool( nodeSetWithIntegratedTokenPlugin, DOMAIN_LEDGER_ID) uncommitted_size_before_token = get_uncommitted_txns_count_for_pool( nodeSetWithIntegratedTokenPlugin, TOKEN_LEDGER_ID) committed_size_before_domain = get_committed_txns_count_for_pool( nodeSetWithIntegratedTokenPlugin, DOMAIN_LEDGER_ID) committed_size_before_token = get_committed_txns_count_for_pool( nodeSetWithIntegratedTokenPlugin, TOKEN_LEDGER_ID) node_stashers = [n.nodeIbStasher for n in nodeSetWithIntegratedTokenPlugin] with delay_rules(node_stashers, cDelay()): # Add a new TRUSTEE (uncommitted) new_did, verkey = helpers.wallet.create_did( sdk_wallet=sdk_wallet_trustee) req = helpers.request.nym(sdk_wallet=sdk_wallet_trustee, alias="new_steward", role=TRUSTEE, dest=new_did, verkey=verkey) helpers.sdk.send_request_objects([req], wallet=sdk_wallet_trustee) looper.run( eventually(lambda: assertExp( get_uncommitted_txns_count_for_pool( nodeSetWithIntegratedTokenPlugin, DOMAIN_LEDGER_ID) == uncommitted_size_before_domain + 1))) looper.run( eventually(lambda: assertExp( get_committed_txns_count_for_pool( nodeSetWithIntegratedTokenPlugin, DOMAIN_LEDGER_ID) == committed_size_before_domain))) # Do mint with a newly added Trustee [address1, *_] = addresses outputs = [{ADDRESS: address1, AMOUNT: 100}] request = helpers.request.mint(outputs, number_signers=2) request = looper.loop.run_until_complete( multi_sign_request(sdk_wallet_trustee[0], new_did, json.dumps(request.as_dict))) request = json.loads(request) sigs = request["signatures"] request = helpers.sdk.sdk_json_to_request_object(request) setattr(request, "signatures", sigs) helpers.sdk.send_request_objects([request]) # make sure we have both txns uncommitted looper.run( eventually(lambda: assertExp( get_uncommitted_txns_count_for_pool( nodeSetWithIntegratedTokenPlugin, DOMAIN_LEDGER_ID) == uncommitted_size_before_domain + 1))) looper.run( eventually(lambda: assertExp( get_committed_txns_count_for_pool( nodeSetWithIntegratedTokenPlugin, DOMAIN_LEDGER_ID) == committed_size_before_domain))) looper.run( eventually(lambda: assertExp( get_uncommitted_txns_count_for_pool( nodeSetWithIntegratedTokenPlugin, TOKEN_LEDGER_ID) == uncommitted_size_before_token + 1))) looper.run( eventually(lambda: assertExp( get_committed_txns_count_for_pool( nodeSetWithIntegratedTokenPlugin, TOKEN_LEDGER_ID) == committed_size_before_token))) # make sure we have both txns committed looper.run( eventually(lambda: assertExp( get_committed_txns_count_for_pool(nodeSetWithIntegratedTokenPlugin, DOMAIN_LEDGER_ID) == committed_size_before_domain + 1))) looper.run( eventually(lambda: assertExp( get_committed_txns_count_for_pool(nodeSetWithIntegratedTokenPlugin, TOKEN_LEDGER_ID) == committed_size_before_token + 1))) [address1_utxos, *_] = helpers.general.get_utxo_addresses(addresses) assert address1_utxos[0][PAYMENT_ADDRESS] == address1 assert address1_utxos[0][AMOUNT] == 100