autobahn.xbr._buyer


Module Contents

Classes

Transaction

SimpleBuyer

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

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

Bases: object

marshal()[source]
__str__()[source]

Return str(self).

class autobahn.xbr._buyer.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.

log
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 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 open_channel(buyer_addr, amount, details=None)[source]
Parameters
  • amount

  • details

Returns

Return type

async close_channel(details=None)[source]

Requests to close the currently active payment channel.

Returns

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

_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

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

  • limit

Returns

count_transactions()[source]
Returns

get_transaction(key_id)[source]
Parameters

key_id

Returns

is_complete(key_id)[source]
Parameters

key_id

Returns