Beispiel #1
0
    def test_auction(self):
        # get the default wallet
        wallets = self.kcl.list_wallets()
        wallet_id = None
        for w in wallets:
            if w["name"] == wallet_name:
                wallet_id = w["id"]

        # get a new handle for the wallet
        handle = self.kcl.init_wallet_handle(wallet_id, wallet_pswd)

        # generate account with kmd
        account_1 = self.kcl.generate_key(handle, False)

        # get suggested parameters and fee
        params = self.acl.suggested_params()
        gen = params["genesisID"]
        gh = params["genesishashb64"]
        last_round = params["lastRound"]
        fee = params["fee"]

        # get self.account_0 private key
        private_key_0 = self.kcl.export_key(handle, wallet_pswd,
                                            self.account_0)

        # create bid
        bid = auction.Bid(self.account_0, 10000, 260, "bid_id", account_1,
                          "auc_id")
        sb = bid.sign(private_key_0)
        nf = auction.NoteField(sb, constants.note_field_type_bid)

        # create transaction
        txn = transaction.PaymentTxn(self.account_0,
                                     fee,
                                     last_round,
                                     last_round + 100,
                                     gh,
                                     account_1,
                                     100000,
                                     note=base64.b64decode(
                                         encoding.msgpack_encode(nf)),
                                     gen=gen)

        # sign transaction with account
        signed_account = txn.sign(private_key_0)

        # send transaction
        send = self.acl.send_transaction(signed_account)
        self.assertEqual(send, txn.get_txid())
        del_1 = self.kcl.delete_key(handle, wallet_pswd, account_1)
        self.assertTrue(del_1)
Beispiel #2
0
def create_bid(context):
    context.sk, pk = account.generate_account()
    context.bid = auction.Bid(pk, 1, 2, 3, pk, 4)
Beispiel #3
0
# get suggested parameters
sp = acl.suggested_params_as_object()

# Set other parameters
amount = 100000
note = "Some Text".encode()
_, receiver = account.generate_account()

# create the NoteField object
bid_currency = 100
max_price = 15
bid_id = 18862
auction_key = "7ZUECA7HFLZTXENRV24SHLU4AVPUTMTTDUFUBNBD64C73F3UHRTHAIOF6Q"
auction_id = 93559

bid = auction.Bid(public_key, bid_currency, max_price, bid_id, auction_key,
                  auction_id)
signed_bid = bid.sign(private_key)

notefield = auction.NoteField(signed_bid, constants.note_field_type_bid)

# create the transaction
txn = transaction.PaymentTxn(public_key,
                             sp,
                             receiver,
                             amount,
                             note=base64.b64decode(
                                 encoding.msgpack_encode(notefield)))

# encode the transaction
encoded_txn = encoding.msgpack_encode(txn)
print("Encoded transaction:", encoded_txn, "\n")