def test_sign_tx_invalid_segwit_no_amount(self): key = PrivateKey(WALLET_FORMAT_TEST_1) txobj = deserialize(UNSIGNED_TX_SEGWIT) unspents = copy.deepcopy(UNSPENTS_SEGWIT) unspents[1].amount = None with pytest.raises(ValueError): sign_tx(key, txobj, unspents=unspents)
def test_sign_tx_invalid_multisig_already_fully_signed(self): key1 = PrivateKey(WALLET_FORMAT_TEST_1) key2 = PrivateKey(WALLET_FORMAT_TEST_2) multi = MultiSig(key1, [key1.public_key, key2.public_key], 2) txobj = deserialize(FINAL_TX_BATCH) with pytest.raises(ValueError): sign_tx(multi, txobj, unspents=[UNSPENTS_BATCH[0]])
def test_sign_tx_multisig(self): key1 = PrivateKey(WALLET_FORMAT_TEST_1) key2 = PrivateKey(WALLET_FORMAT_TEST_2) multi = MultiSig(key1, [key1.public_key, key2.public_key], 2) txobj = deserialize(UNSIGNED_TX_BATCH) tx = sign_tx(multi, txobj, unspents=[UNSPENTS_BATCH[0]]) assert tx[:238] == FINAL_TX_BATCH[:238]
def send_tx(coin, account, recipient, amount): if coin == ETH: raw_tx = create_tx(coin, account, recipient, amount) signed_tx = account.sign_transaction(raw_tx) result = w3.eth.send_raw_transaction(signed_tx.rawTransaction) print(result.hex()) return result.hex() elif coin == BTCTEST: raw_tx = create_tx(coin, account, recipient, amount) signed_tx = account.bit(sign_tx(raw_tx)) result = account.bit(send_tx(signed_tx)) print(result.hex()) return result.hex()
def test_sign_tx_invalid_unspents(self): key = PrivateKey(WALLET_FORMAT_TEST_1) txobj = deserialize(UNSIGNED_TX_SEGWIT) with pytest.raises(TypeError): # Unspents must be presented as list: sign_tx(key, txobj, unspents=UNSPENTS_SEGWIT[0])
def test_sign_tx_segwit(self): key = PrivateKey(WALLET_FORMAT_TEST_1) txobj = deserialize(UNSIGNED_TX_SEGWIT) assert sign_tx(key, txobj, unspents=UNSPENTS_SEGWIT) == FINAL_TX_SEGWIT
def test_sign_tx_legacy_input(self): key = PrivateKey(WALLET_FORMAT_TEST_1) txobj = deserialize(UNSIGNED_TX_SEGWIT) tx = sign_tx(key, txobj, unspents=[UNSPENTS_SEGWIT[0]]) assert tx[:380] == FINAL_TX_SEGWIT[:380]