cfxdb.xbrmm

Submodules

Classes

Channel

XBR off-chain payment or paying channel.

ChannelBalance

XBR payment channel current (off-chain) balance. The sum of Balance.remaining and Balance.inflight equals Channel.amount.

ChannelState

ChannelType

IPFSFile

Record of downloaded files from Infura

IPFSFiles

Persisted IPFS files download log

IndexOfferByKey

Index: key_id -> offer_id

IndexPayingChannelByDelegate

Index: (delegate_adr, created_timestamp) -> channel_oid

IndexPayingChannelByRecipient

Index: (recipient_adr, created_timestamp) -> channel_oid

IndexPaymentChannelByDelegate

Index: (delegate_adr, created_timestamp) -> channel_oid

IndexUserKeyByMember

Database (index) table for (member_oid, created) -> userkey mapping.

Offer

Data encryption key offerings by XBR providers.

Offers

Persisted data encryption key offers.

PayingChannel

XBR off-chain payment or paying channel.

PayingChannelBalance

XBR payment channel current (off-chain) balance. The sum of Balance.remaining and Balance.inflight equals Channel.amount.

PayingChannelBalances

XBR paying channels current balances by channel_oid.

PayingChannels

XBR paying channels by channel_oid.

PaymentChannel

XBR off-chain payment or paying channel.

PaymentChannelBalance

XBR payment channel current (off-chain) balance. The sum of Balance.remaining and Balance.inflight equals Channel.amount.

PaymentChannelBalances

XBR payment channels current balances by channel_oid.

PaymentChannels

XBR payment channels by channel_oid.

Schema

CFC edge database schema for ZLMDB.

Transaction

Data encryption key buy-sell transactions.

TransactionState

Transactions

Data encryption key (off-chain) market transactions.

UserKey

User client (public) keys.

UserKeys

Database table for user client keys.

Package Contents

class Channel(from_fbs=None)[source]

Bases: object

XBR off-chain payment or paying channel.

__str__()[source]
_actor = None
_amount = None
_channel_oid = None
_channel_type = None
_close_balance = None
_close_channel_seq = None
_close_del_sig = None
_close_is_final = None
_close_mm_sig = None
_closed_at = None
_closed_tx = None
_closing_at = None
_delegate = None
_from_fbs = None
_market_oid = None
_marketmaker = None
_member_oid = None
_open_at = None
_recipient = None
_seq = None
_state = None
_timeout = None
_timestamp = None
property actor: bytes

Ethereum address of the sender (either XBR Consumer or XBR Market).

property amount: int

Amount of XBR tokens initially deposited into the payment channel.

build(builder)[source]
static cast(buf)[source]
property channel_oid: uuid.UUID

The unique OID of the channel.

property channel_type: int

payment channel (from XBR consumer to XBR market maker) or paying channel (from XBR market maker to XBR provider).

Type:

Channel type

property close_balance: int

Remaining (closing) channel balance (XBR).

property close_channel_seq: int

channel transaction sequence number.

Type:

Last off-chain, closing transaction

property close_del_sig: bytes

Closing signature by (seller or buyer) delegate.

property close_is_final: bool

Flag indication if close is final (happens immediately without a channel timeout).

property close_mm_sig: int

Closing signature by market maker.

property closed_at: int

Block number (on the blockchain) when the payment channel was finally closed.

property closed_tx: bytes

When channel was finally closed on-chain, the Ethereum transaction ID.

property closing_at: int

Block number (on the blockchain) when the payment channel will close (at the latest).

property delegate: bytes

Ethereum address of the sender delegate (either XBR Consumer delegate or XBR Market delegate == market maker)

property market_oid: uuid.UUID

The unique OID of the market.

property marketmaker: bytes

ID of the payment channel.

marshal() dict[source]
property member_oid: uuid.UUID

The unique OID of the member.

property open_at: int

Block number (on the blockchain) when the actor (originally) joined the market.

property recipient: bytes

Ethereum address of the recipient (either XBR Market or XBR Provider)

property seq: int

Global channel sequence number.

property state: int

Current state of payment channel.

property timeout: int

Payment channel (non-cooperative) closed timeout in blocks (on the blockchain).

property timestamp: numpy.datetime64

Database transaction time (epoch time in ns) of insert or last update.

class ChannelBalance(from_fbs=None)[source]

Bases: object

XBR payment channel current (off-chain) balance. The sum of Balance.remaining and Balance.inflight equals Channel.amount.

__str__()[source]
_from_fbs = None
_inflight = None
_remaining = None
_seq = None
build(builder)[source]
static cast(buf)[source]
property inflight: int

Amount of XBR tokens reserved to in-flight purchase transactions.

marshal() dict[source]
static parse(data: dict)[source]
property remaining: int

Amount of XBR tokens currently remaining in the payment channel.

property seq: int

Sequence number of transactions on this balance starting from 0 when the payment channel is created.

class ChannelState[source]

Bases: object

CLOSED = 3
CLOSING = 2
FAILED = 4
NONE = 0
OPEN = 1
class ChannelType[source]

Bases: object

NONE = 0
PAYING = 2
PAYMENT = 1
class IPFSFile(from_fbs=None)[source]

Record of downloaded files from Infura

__str__()[source]
_downloaded = None
_errored_at = None
_file_hash = None
_from_fbs = None
_retries = None
build(builder)[source]
static cast(buf)[source]
property downloaded: bool

Whether the file for the given IPFS has was downloaded

property errored_at: numpy.datetime64

Time of last time when downloaded errorred.

property file_hash: str

IPFS Multihash pointing to a RDF/Turtle file

marshal()[source]
property retries: int

Number of retries to download the file from Infura

class IPFSFiles(slot=None, compress=None, build=None, cast=None)[source]

Bases: zlmdb.MapStringFlatBuffers

Persisted IPFS files download log

Map zlmdb.MapStringFlatBuffers from file_hash to cfxdb.xbrmm.IPFSFile

class IndexOfferByKey(slot=None, compress=None)[source]

Bases: zlmdb.MapUuidUuid

Index: key_id -> offer_id

class IndexPayingChannelByDelegate(slot=None, compress=None)[source]

Bases: zlmdb.MapBytes20TimestampUuid

Index: (delegate_adr, created_timestamp) -> channel_oid

class IndexPayingChannelByRecipient(slot=None, compress=None)[source]

Bases: zlmdb.MapBytes20TimestampUuid

Index: (recipient_adr, created_timestamp) -> channel_oid

class IndexPaymentChannelByDelegate(slot=None, compress=None)[source]

Bases: zlmdb.MapBytes20TimestampUuid

Index: (delegate_adr, created_timestamp) -> channel_oid

class IndexUserKeyByMember(slot=None, compress=None)[source]

Bases: zlmdb.MapUuidTimestampBytes32

Database (index) table for (member_oid, created) -> userkey mapping.

class Offer(from_fbs=None)[source]

Bases: object

Data encryption key offerings by XBR providers.

__str__()[source]
_api = None
_categories = None
_copies = None
_expires = None
_from_fbs = None
_key = None
_offer = None
_price = None
_remaining = None
_seller = None
_seller_authid = None
_seller_session_id = None
_signature = None
_timestamp = None
_uri = None
_valid_from = None
property api: uuid.UUID

ID of the API the encrypted data (this key is for) is provided under.

Returns:

build(builder)[source]
static cast(buf)[source]
property categories: dict

Dictionary of optional user defined categories the specific data that is provided falls under.

property copies: int

Optional maximum number of times this data encryption key is to be sold or 0 for unlimited.

property expires: numpy.datetime64

Optional data at which this offer expires (epoch time in ns).

property key: uuid.UUID

ID of the data encryption key offered.

marshal() dict[source]
property offer: uuid.UUID

ID of the data encryption key offer.

property price: int

Price of data encryption key in XBR tokens.

property remaining: int

Remaining number of copies to be sold (if “copies” is set >0, otherwise 0).

property seller: bytes

Address of the XBR provider offering the data encryption key.

property seller_authid: str

WAMP session authid of the caller that originally placed this offer.

property seller_session_id: int

WAMP session ID of the caller that originally placed this offer.

property signature: bytes

Seller delegate signature for the offer. The signature covers all information of the original offer placement request and requestor.

property timestamp: numpy.datetime64

Offer transaction time (epoch time in ns)

property uri: str

URI under which the data encrypted with the key offered is provided under.

property valid_from: numpy.datetime64

Timestamp from which the offer is valid (epoch time in ns).

class Offers(slot=None, compress=None, build=None, cast=None)[source]

Bases: zlmdb.MapUuidFlatBuffers

Persisted data encryption key offers.

Map zlmdb.MapBytes32FlatBuffers from offer_id to cfxdb.xbr.Offer

class PayingChannel(from_fbs=None)

Bases: object

XBR off-chain payment or paying channel.

__str__()
_actor = None
_amount = None
_channel_oid = None
_channel_type = None
_close_balance = None
_close_channel_seq = None
_close_del_sig = None
_close_is_final = None
_close_mm_sig = None
_closed_at = None
_closed_tx = None
_closing_at = None
_delegate = None
_from_fbs = None
_market_oid = None
_marketmaker = None
_member_oid = None
_open_at = None
_recipient = None
_seq = None
_state = None
_timeout = None
_timestamp = None
property actor: bytes

Ethereum address of the sender (either XBR Consumer or XBR Market).

property amount: int

Amount of XBR tokens initially deposited into the payment channel.

build(builder)
static cast(buf)
property channel_oid: uuid.UUID

The unique OID of the channel.

property channel_type: int

payment channel (from XBR consumer to XBR market maker) or paying channel (from XBR market maker to XBR provider).

Type:

Channel type

property close_balance: int

Remaining (closing) channel balance (XBR).

property close_channel_seq: int

channel transaction sequence number.

Type:

Last off-chain, closing transaction

property close_del_sig: bytes

Closing signature by (seller or buyer) delegate.

property close_is_final: bool

Flag indication if close is final (happens immediately without a channel timeout).

property close_mm_sig: int

Closing signature by market maker.

property closed_at: int

Block number (on the blockchain) when the payment channel was finally closed.

property closed_tx: bytes

When channel was finally closed on-chain, the Ethereum transaction ID.

property closing_at: int

Block number (on the blockchain) when the payment channel will close (at the latest).

property delegate: bytes

Ethereum address of the sender delegate (either XBR Consumer delegate or XBR Market delegate == market maker)

property market_oid: uuid.UUID

The unique OID of the market.

property marketmaker: bytes

ID of the payment channel.

marshal() dict
property member_oid: uuid.UUID

The unique OID of the member.

property open_at: int

Block number (on the blockchain) when the actor (originally) joined the market.

property recipient: bytes

Ethereum address of the recipient (either XBR Market or XBR Provider)

property seq: int

Global channel sequence number.

property state: int

Current state of payment channel.

property timeout: int

Payment channel (non-cooperative) closed timeout in blocks (on the blockchain).

property timestamp: numpy.datetime64

Database transaction time (epoch time in ns) of insert or last update.

class PayingChannelBalance(from_fbs=None)

Bases: object

XBR payment channel current (off-chain) balance. The sum of Balance.remaining and Balance.inflight equals Channel.amount.

__str__()
_from_fbs = None
_inflight = None
_remaining = None
_seq = None
build(builder)
static cast(buf)
property inflight: int

Amount of XBR tokens reserved to in-flight purchase transactions.

marshal() dict
static parse(data: dict)
property remaining: int

Amount of XBR tokens currently remaining in the payment channel.

property seq: int

Sequence number of transactions on this balance starting from 0 when the payment channel is created.

class PayingChannelBalances(slot=None, compress=None, build=None, cast=None)[source]

Bases: zlmdb.MapUuidFlatBuffers

XBR paying channels current balances by channel_oid.

Map zlmdb.MapBytes20FlatBuffers from channel_oid to cfxdb.xbr.Balance

class PayingChannels(slot=None, compress=None, build=None, cast=None)[source]

Bases: zlmdb.MapUuidFlatBuffers

XBR paying channels by channel_oid.

Map zlmdb.MapUuidFlatBuffers from channel_oid to cfxdb.xbr.Channel

class PaymentChannel(from_fbs=None)

Bases: object

XBR off-chain payment or paying channel.

__str__()
_actor = None
_amount = None
_channel_oid = None
_channel_type = None
_close_balance = None
_close_channel_seq = None
_close_del_sig = None
_close_is_final = None
_close_mm_sig = None
_closed_at = None
_closed_tx = None
_closing_at = None
_delegate = None
_from_fbs = None
_market_oid = None
_marketmaker = None
_member_oid = None
_open_at = None
_recipient = None
_seq = None
_state = None
_timeout = None
_timestamp = None
property actor: bytes

Ethereum address of the sender (either XBR Consumer or XBR Market).

property amount: int

Amount of XBR tokens initially deposited into the payment channel.

build(builder)
static cast(buf)
property channel_oid: uuid.UUID

The unique OID of the channel.

property channel_type: int

payment channel (from XBR consumer to XBR market maker) or paying channel (from XBR market maker to XBR provider).

Type:

Channel type

property close_balance: int

Remaining (closing) channel balance (XBR).

property close_channel_seq: int

channel transaction sequence number.

Type:

Last off-chain, closing transaction

property close_del_sig: bytes

Closing signature by (seller or buyer) delegate.

property close_is_final: bool

Flag indication if close is final (happens immediately without a channel timeout).

property close_mm_sig: int

Closing signature by market maker.

property closed_at: int

Block number (on the blockchain) when the payment channel was finally closed.

property closed_tx: bytes

When channel was finally closed on-chain, the Ethereum transaction ID.

property closing_at: int

Block number (on the blockchain) when the payment channel will close (at the latest).

property delegate: bytes

Ethereum address of the sender delegate (either XBR Consumer delegate or XBR Market delegate == market maker)

property market_oid: uuid.UUID

The unique OID of the market.

property marketmaker: bytes

ID of the payment channel.

marshal() dict
property member_oid: uuid.UUID

The unique OID of the member.

property open_at: int

Block number (on the blockchain) when the actor (originally) joined the market.

property recipient: bytes

Ethereum address of the recipient (either XBR Market or XBR Provider)

property seq: int

Global channel sequence number.

property state: int

Current state of payment channel.

property timeout: int

Payment channel (non-cooperative) closed timeout in blocks (on the blockchain).

property timestamp: numpy.datetime64

Database transaction time (epoch time in ns) of insert or last update.

class PaymentChannelBalance(from_fbs=None)

Bases: object

XBR payment channel current (off-chain) balance. The sum of Balance.remaining and Balance.inflight equals Channel.amount.

__str__()
_from_fbs = None
_inflight = None
_remaining = None
_seq = None
build(builder)
static cast(buf)
property inflight: int

Amount of XBR tokens reserved to in-flight purchase transactions.

marshal() dict
static parse(data: dict)
property remaining: int

Amount of XBR tokens currently remaining in the payment channel.

property seq: int

Sequence number of transactions on this balance starting from 0 when the payment channel is created.

class PaymentChannelBalances(slot=None, compress=None, build=None, cast=None)[source]

Bases: zlmdb.MapUuidFlatBuffers

XBR payment channels current balances by channel_oid.

Map zlmdb.MapBytes20FlatBuffers from channel_oid to cfxdb.xbr.Balance

class PaymentChannels(slot=None, compress=None, build=None, cast=None)[source]

Bases: zlmdb.MapUuidFlatBuffers

XBR payment channels by channel_oid.

Map zlmdb.MapUuidFlatBuffers from channel_oid to cfxdb.xbr.Channel

class Schema(db)[source]

Bases: object

CFC edge database schema for ZLMDB.

static attach(db)[source]

Factory to create a schema from attaching to a database. The schema tables will be automatically mapped as persistant maps and attached to the database slots.

Parameters:

db – zlmdb.Database

Returns:

object of Schema

consents: cfxdb.xbr.consent.Consents

XBR data consents.

db

Consents-by-members-address index with (member_adr|bytes[20], joined|int) -> member_adr|UUID mapping.

idx_offer_by_key: cfxdb.xbrmm.offer.IndexOfferByKey

Index of key offers by key ID (rather than offer ID, as the object table is indexed by).

idx_paying_channel_by_delegate: cfxdb.xbrmm.channel.IndexPayingChannelByDelegate

Maps from XBR provider delegate address to the currently active paying channel address for the given provider delegate.

idx_paying_channel_by_recipient: cfxdb.xbrmm.channel.IndexPayingChannelByRecipient

Maps from XBR recipient address to the currently active paying channel address for the given recipient.

idx_payment_channel_by_actor: cfxdb.xbrmm.channel.IndexPaymentChannelByActor

Maps from XBR consumer actor address to the currently active payment channel address for the given consumer actor.

idx_payment_channel_by_delegate: cfxdb.xbrmm.channel.IndexPaymentChannelByDelegate

Maps from XBR consumer delegate address to the currently active payment channel address for the given consumer delegate.

idx_user_key_by_member: cfxdb.xbrmm.userkey.IndexUserKeyByMember

Index “by pubkey” of user keys xbrmm.IndexUserKeyByMember.

ipfs_files: cfxdb.xbrmm.ipfs_file.IPFSFiles

IPFS files download log table xbrmm.IPFSFiles.

offers: cfxdb.xbrmm.offer.Offers

Data encryption key offers.

paying_balances: cfxdb.xbrmm.channel.PayingChannelBalances

Current off-chain balances within paying channels.

paying_channels: cfxdb.xbrmm.channel.PayingChannels

Paying channels for XBR provider delegates.

payment_balances: cfxdb.xbrmm.channel.PaymentChannelBalances

Current off-chain balances within payment channels.

payment_channels: cfxdb.xbrmm.channel.PaymentChannels

Payment channels for XBR consumer delegates.

transactions: cfxdb.xbrmm.transaction.Transactions
user_keys: cfxdb.xbrmm.userkey.UserKeys

User client keys database table xbrmm.UserKeys.

class Transaction(from_fbs=None)[source]

Bases: object

Data encryption key buy-sell transactions.

STATUS_FAILED = 2

The transaction has completed with error (it failed)

STATUS_INFLIGHT = 1

The transaction is currently in-flight

STATUS_NONE = 0

Unset

STATUS_SUCCESS = 3

The transaction has completed with success

__str__()[source]
_amount = None
_buyer_pubkey = None
_completed = None
_completed_paying_channel_seq = None
_completed_payment_channel_seq = None
_created = None
_created_paying_channel_seq = None
_created_payment_channel_seq = None
_from_fbs = None
_key = None
_offer = None
_paying_channel = None
_paying_channel_after = None
_paying_del_sig = None
_paying_mm_sig = None
_payment_channel = None
_payment_channel_after = None
_payment_del_sig = None
_payment_mm_sig = None
_state = None
_tid = None
property amount: int

Transaction amount in XBR.

build(builder)[source]
property buyer_pubkey: bytes

Buyer public key (Ed25519).

static cast(buf)[source]
property completed: numpy.datetime64

Completion time of the transaction (epoch time in ns)

property completed_paying_channel_seq: int

Sequence number of the completed-state transaction within the paying channel.

property completed_payment_channel_seq: int

Sequence number of the completed-state transaction within the payment channel.

property created: numpy.datetime64

Creation time of the transaction (epoch time in ns).

property created_paying_channel_seq: int

Sequence number of the created-state transaction within the paying channel.

property created_payment_channel_seq: int

Sequence number of the created-state transaction within the payment channel.

property key: uuid.UUID

ID of the data encryption key sold under the transaction.

marshal()[source]
property offer: uuid.UUID

ID of the data encryption key offer this transaction is for.

property paying_channel: uuid.UUID

Address of the paying channel (of the seller) this transaction is transacting on.

property paying_channel_after: int

Payment channel balance after transaction.

property paying_del_sig: bytes

Paying channel (seller) delegate transaction signature.

property paying_mm_sig: bytes

Paying channel market maker transaction signature.

property payment_channel: uuid.UUID

Address of the payment channel (of the buyer) this transaction is transacting on.

property payment_channel_after: int

Payment channel balance after transaction.

property payment_del_sig: bytes

Payment channel (buyer) delegate transaction signature.

property payment_mm_sig: bytes

Payment channel market maker transaction signature.

property state: int

TransactionState.INFLIGHT when created, and then either TransactionState.SUCCESS or TransactionState.FAILED.

Type:

State of the transaction

property tid: uuid.UUID

ID of the transaction.

class TransactionState[source]

Bases: object

FAILED = 2
INFLIGHT = 1
NONE = 0
SUCCESS = 3
class Transactions(slot=None, compress=None, build=None, cast=None)[source]

Bases: zlmdb.MapUuidFlatBuffers

Data encryption key (off-chain) market transactions.

class UserKey(from_fbs=None)[source]

User client (public) keys.

__str__()[source]
_created = None
_from_fbs = None
_owner = None
_pubkey = None
_signature = None
_wallet_address = None
build(builder)[source]
static cast(buf)[source]
property created: numpy.datetime64

Timestamp (epoch time in ns) of initial creation of this record.

marshal()[source]
property owner: uuid.UUID

ID of user account this user key is owned by.

property pubkey: bytes

User key - a Ed25519 public key - for authenticating using WAMP-cryptosign.

property signature: bytes

market maker transaction signature.

property wallet_address: bytes

Wallet address of the member this key belong to.

class UserKeys(slot=None, compress=None, build=None, cast=None)[source]

Bases: zlmdb.MapBytes32FlatBuffers

Database table for user client keys.