xbr._buyer

Classes

SimpleBuyer

Simple XBR buyer component. This component can be used by a XBR buyer delegate to

Transaction

Module Contents

class SimpleBuyer(market_maker_adr, buyer_key, max_price)[source]

Bases: object

Simple XBR buyer component. This component can be used by a XBR buyer delegate to handle the automated buying of data encryption keys from the XBR market maker.

_acct = None[source]
_addr[source]
_auto_close_channel = True[source]
_balance = 0[source]
_caddr = None[source]
_channel = None[source]
_keys[source]
_market_maker_adr[source]
_max_price[source]
_pkey[source]
_pkey_raw[source]
_receive_key[source]
_running = False[source]
_save_transaction_phase1(channel_oid, delegate_adr, buyer_pubkey, key_id, channel_seq, amount, balance, signature)[source]
Parameters:
  • channel_oid

  • delegate_adr

  • buyer_pubkey

  • key_id

  • channel_seq

  • amount

  • balance

  • signature

Returns:

_save_transaction_phase2(channel_oid, delegate_adr, buyer_pubkey, key_id, channel_seq, amount, balance, signature)[source]
Parameters:
  • channel_oid

  • delegate_adr

  • buyer_pubkey

  • key_id

  • channel_seq

  • amount

  • balance

  • signature

Returns:

_seq = 0[source]
_session = None[source]
_transaction_idx[source]
_transactions = [][source]
_xbrmm_config = None[source]
async balance()[source]

Return current balance of payment channel:

  • amount: The initial amount with which the payment channel was opened.

  • remaining: The remaining amount of XBR in the payment channel that can be spent.

  • inflight: The amount of XBR allocated to buy transactions that are currently processed.

Returns:

Current payment balance.

Return type:

dict

async close_channel(details=None)[source]

Requests to close the currently active payment channel.

Returns:

count_transactions()[source]
Returns:

get_transaction(key_id)[source]
Parameters:

key_id

Returns:

is_complete(key_id)[source]
Parameters:

key_id

Returns:

log = None[source]
async open_channel(buyer_addr, amount, details=None)[source]
Parameters:
  • amount

  • details

Returns:

Return type:

past_transactions(filter_complete=True, limit=1)[source]
Parameters:
  • filter_complete

  • limit

Returns:

async start(session, consumer_id)[source]

Start buying keys to decrypt XBR data by calling unwrap().

Parameters:
Returns:

Current remaining balance in payment channel.

Return type:

int

async stop()[source]

Stop buying keys.

async unwrap(key_id, serializer, ciphertext)[source]

Decrypt XBR data. This functions will potentially make the buyer call the XBR market maker to buy data encryption keys from the XBR provider.

Parameters:
  • key_id (bytes) – ID of the data encryption used for decryption of application payload.

  • serializer (str) – Application payload serializer.

  • ciphertext (bytes) – Ciphertext of encrypted application payload to decrypt.

Returns:

Decrypted application payload.

Return type:

object

class Transaction(channel, delegate, pubkey, key_id, channel_seq, amount, balance, signature)[source]

Bases: object

__str__()[source]
amount[source]
balance[source]
channel[source]
channel_seq[source]
delegate[source]
key_id[source]
marshal()[source]
pubkey[source]
signature[source]