INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
Create a :class:`Transaction` object from a Transaction XDR
object. | def from_xdr_object(cls, tx_xdr_object):
"""Create a :class:`Transaction` object from a Transaction XDR
object.
"""
source = encode_check('account', tx_xdr_object.sourceAccount.ed25519)
sequence = tx_xdr_object.seqNum - 1
time_bounds_in_xdr = tx_xdr_object.timeBounds # ... |
Generate a :class:`Keypair` object via a deterministic
phrase.
Using a mnemonic, such as one generated from :class:`StellarMnemonic`,
generate a new keypair deterministically. Uses :class:`StellarMnemonic`
internally to generate the seed from the mnemonic, using PBKDF2.
:param ... | def deterministic(cls, mnemonic, passphrase='', lang='english', index=0):
"""Generate a :class:`Keypair` object via a deterministic
phrase.
Using a mnemonic, such as one generated from :class:`StellarMnemonic`,
generate a new keypair deterministically. Uses :class:`StellarMnemonic`
... |
Generate a :class:`Keypair` object via a sequence of bytes.
Typically these bytes are random, such as the usage of
:func:`os.urandom` in :meth:`Keypair.random`. However this class method
allows you to use an arbitrary sequence of bytes, provided the sequence
is 32 bytes long.
:... | def from_raw_seed(cls, raw_seed):
"""Generate a :class:`Keypair` object via a sequence of bytes.
Typically these bytes are random, such as the usage of
:func:`os.urandom` in :meth:`Keypair.random`. However this class method
allows you to use an arbitrary sequence of bytes, provided the ... |
Generate a :class:`Keypair` object via Base58 encoded seed.
.. deprecated:: 0.1.7
Base58 address encoding is DEPRECATED! Use this method only for
transition to strkey encoding.
:param str base58_seed: A base58 encoded encoded secret seed.
:return: A new :class:`Keypair` d... | def from_base58_seed(cls, base58_seed):
"""Generate a :class:`Keypair` object via Base58 encoded seed.
.. deprecated:: 0.1.7
Base58 address encoding is DEPRECATED! Use this method only for
transition to strkey encoding.
:param str base58_seed: A base58 encoded encoded sec... |
Generate a :class:`Keypair` object via a strkey encoded public key.
:param str address: A base32 encoded public key encoded as described in
:func:`encode_check`
:return: A new :class:`Keypair` with only a verifying (public) key. | def from_address(cls, address):
"""Generate a :class:`Keypair` object via a strkey encoded public key.
:param str address: A base32 encoded public key encoded as described in
:func:`encode_check`
:return: A new :class:`Keypair` with only a verifying (public) key.
"""
... |
Create PublicKey XDR object via public key bytes.
:return: Serialized XDR of PublicKey type. | def account_xdr_object(self):
"""Create PublicKey XDR object via public key bytes.
:return: Serialized XDR of PublicKey type.
"""
return Xdr.types.PublicKey(Xdr.const.KEY_TYPE_ED25519,
self.verifying_key.to_bytes()) |
Generate base64 encoded XDR PublicKey object.
Return a base64 encoded PublicKey XDR object, for sending over the wire
when interacting with stellar.
:return: The base64 encoded PublicKey XDR structure. | def xdr(self):
"""Generate base64 encoded XDR PublicKey object.
Return a base64 encoded PublicKey XDR object, for sending over the wire
when interacting with stellar.
:return: The base64 encoded PublicKey XDR structure.
"""
kp = Xdr.StellarXDRPacker()
kp.pack_Pu... |
Sign a bytes-like object using the signing (private) key.
:param bytes data: The data to sign
:return: The signed data
:rtype: bytes | def sign(self, data):
"""Sign a bytes-like object using the signing (private) key.
:param bytes data: The data to sign
:return: The signed data
:rtype: bytes
"""
if self.signing_key is None:
raise MissingSigningKeyError("KeyPair does not contain secret key. "... |
Verify the signature of a sequence of bytes.
Verify the signature of a sequence of bytes using the verifying
(public) key and the data that was originally signed, otherwise throws
an exception.
:param bytes data: A sequence of bytes that were previously signed by
the privat... | def verify(self, data, signature):
"""Verify the signature of a sequence of bytes.
Verify the signature of a sequence of bytes using the verifying
(public) key and the data that was originally signed, otherwise throws
an exception.
:param bytes data: A sequence of bytes that we... |
Sign a bytes-like object and return the decorated signature.
Sign a bytes-like object by signing the data using the signing
(private) key, and return a decorated signature, which includes the
last four bytes of the public key as a signature hint to go along with
the signature as an XDR ... | def sign_decorated(self, data):
"""Sign a bytes-like object and return the decorated signature.
Sign a bytes-like object by signing the data using the signing
(private) key, and return a decorated signature, which includes the
last four bytes of the public key as a signature hint to go ... |
Creates an XDR Operation object that represents this
:class:`Operation`. | def to_xdr_object(self):
"""Creates an XDR Operation object that represents this
:class:`Operation`.
"""
try:
source_account = [account_xdr_object(self.source)]
except StellarAddressInvalidError:
source_account = []
return Xdr.types.Operation(sour... |
copy from base64._bytes_from_decode_data | def bytes_from_decode_data(s):
"""copy from base64._bytes_from_decode_data
"""
if isinstance(s, (str, unicode)):
try:
return s.encode('ascii')
except UnicodeEncodeError:
raise NotValidParamError(
'String argument should contain only ASCII characters')
... |
Packs and base64 encodes this :class:`Operation` as an XDR string. | def xdr(self):
"""Packs and base64 encodes this :class:`Operation` as an XDR string.
"""
op = Xdr.StellarXDRPacker()
op.pack_Operation(self.to_xdr_object())
return base64.b64encode(op.get_buffer()) |
Converts an amount to the appropriate value to send over the network
as a part of an XDR object.
Each asset amount is encoded as a signed 64-bit integer in the XDR
structures. An asset amount unit (that which is seen by end users) is
scaled down by a factor of ten million (10,000,000) t... | def to_xdr_amount(value):
"""Converts an amount to the appropriate value to send over the network
as a part of an XDR object.
Each asset amount is encoded as a signed 64-bit integer in the XDR
structures. An asset amount unit (that which is seen by end users) is
scaled down by a... |
Create the appropriate :class:`Operation` subclass from the XDR
structure.
Decode an XDR base64 encoded string and create the appropriate
:class:`Operation` object.
:param str xdr: The XDR object to create an :class:`Operation` (or
subclass) instance from. | def from_xdr(cls, xdr):
"""Create the appropriate :class:`Operation` subclass from the XDR
structure.
Decode an XDR base64 encoded string and create the appropriate
:class:`Operation` object.
:param str xdr: The XDR object to create an :class:`Operation` (or
subclas... |
Creates an XDR Operation object that represents this
:class:`CreateAccount`. | def to_xdr_object(self):
"""Creates an XDR Operation object that represents this
:class:`CreateAccount`.
"""
destination = account_xdr_object(self.destination)
create_account_op = Xdr.types.CreateAccountOp(
destination, Operation.to_xdr_amount(self.starting_balance)... |
Creates a :class:`CreateAccount` object from an XDR Operation
object. | def from_xdr_object(cls, op_xdr_object):
"""Creates a :class:`CreateAccount` object from an XDR Operation
object.
"""
if not op_xdr_object.sourceAccount:
source = None
else:
source = encode_check(
'account', op_xdr_object.sourceAccount[0].... |
Creates an XDR Operation object that represents this
:class:`Payment`. | def to_xdr_object(self):
"""Creates an XDR Operation object that represents this
:class:`Payment`.
"""
asset = self.asset.to_xdr_object()
destination = account_xdr_object(self.destination)
amount = Operation.to_xdr_amount(self.amount)
payment_op = Xdr.types.Pay... |
Creates a :class:`Payment` object from an XDR Operation
object. | def from_xdr_object(cls, op_xdr_object):
"""Creates a :class:`Payment` object from an XDR Operation
object.
"""
if not op_xdr_object.sourceAccount:
source = None
else:
source = encode_check(
'account', op_xdr_object.sourceAccount[0].ed2551... |
Creates an XDR Operation object that represents this
:class:`PathPayment`. | def to_xdr_object(self):
"""Creates an XDR Operation object that represents this
:class:`PathPayment`.
"""
destination = account_xdr_object(self.destination)
send_asset = self.send_asset.to_xdr_object()
dest_asset = self.dest_asset.to_xdr_object()
path = [asset.t... |
Creates a :class:`PathPayment` object from an XDR Operation
object. | def from_xdr_object(cls, op_xdr_object):
"""Creates a :class:`PathPayment` object from an XDR Operation
object.
"""
if not op_xdr_object.sourceAccount:
source = None
else:
source = encode_check(
'account', op_xdr_object.sourceAccount[0].ed... |
Creates an XDR Operation object that represents this
:class:`ChangeTrust`. | def to_xdr_object(self):
"""Creates an XDR Operation object that represents this
:class:`ChangeTrust`.
"""
line = self.line.to_xdr_object()
limit = Operation.to_xdr_amount(self.limit)
change_trust_op = Xdr.types.ChangeTrustOp(line, limit)
self.body.type = Xdr.co... |
Creates a :class:`ChangeTrust` object from an XDR Operation
object. | def from_xdr_object(cls, op_xdr_object):
"""Creates a :class:`ChangeTrust` object from an XDR Operation
object.
"""
if not op_xdr_object.sourceAccount:
source = None
else:
source = encode_check(
'account', op_xdr_object.sourceAccount[0].ed... |
Creates an XDR Operation object that represents this
:class:`AllowTrust`. | def to_xdr_object(self):
"""Creates an XDR Operation object that represents this
:class:`AllowTrust`.
"""
trustor = account_xdr_object(self.trustor)
length = len(self.asset_code)
assert length <= 12
pad_length = 4 - length if length <= 4 else 12 - length
... |
Creates a :class:`AllowTrust` object from an XDR Operation
object. | def from_xdr_object(cls, op_xdr_object):
"""Creates a :class:`AllowTrust` object from an XDR Operation
object.
"""
if not op_xdr_object.sourceAccount:
source = None
else:
source = encode_check(
'account', op_xdr_object.sourceAccount[0].ed2... |
Creates an XDR Operation object that represents this
:class:`SetOptions`. | def to_xdr_object(self):
"""Creates an XDR Operation object that represents this
:class:`SetOptions`.
"""
def assert_option_array(x):
if x is None:
return []
if not isinstance(x, list):
return [x]
return x
if ... |
Creates a :class:`SetOptions` object from an XDR Operation
object. | def from_xdr_object(cls, op_xdr_object):
"""Creates a :class:`SetOptions` object from an XDR Operation
object.
"""
if not op_xdr_object.sourceAccount:
source = None
else:
source = encode_check(
'account', op_xdr_object.sourceAccount[0].ed2... |
Creates an XDR Operation object that represents this
:class:`ManageOffer`. | def to_xdr_object(self):
"""Creates an XDR Operation object that represents this
:class:`ManageOffer`.
"""
selling = self.selling.to_xdr_object()
buying = self.buying.to_xdr_object()
price = Operation.to_xdr_price(self.price)
price = Xdr.types.Price(price['n'], p... |
Creates an XDR Operation object that represents this
:class:`CreatePassiveOffer`. | def to_xdr_object(self):
"""Creates an XDR Operation object that represents this
:class:`CreatePassiveOffer`.
"""
selling = self.selling.to_xdr_object()
buying = self.buying.to_xdr_object()
price = Operation.to_xdr_price(self.price)
price = Xdr.types.Price(price... |
Creates a :class:`CreatePassiveOffer` object from an XDR Operation
object. | def from_xdr_object(cls, op_xdr_object):
"""Creates a :class:`CreatePassiveOffer` object from an XDR Operation
object.
"""
if not op_xdr_object.sourceAccount:
source = None
else:
source = encode_check(
'account', op_xdr_object.sourceAccoun... |
Creates an XDR Operation object that represents this
:class:`AccountMerge`. | def to_xdr_object(self):
"""Creates an XDR Operation object that represents this
:class:`AccountMerge`.
"""
destination = account_xdr_object(self.destination)
self.body.type = Xdr.const.ACCOUNT_MERGE
self.body.destination = destination
return super(AccountMerge,... |
Creates a :class:`AccountMerge` object from an XDR Operation
object. | def from_xdr_object(cls, op_xdr_object):
"""Creates a :class:`AccountMerge` object from an XDR Operation
object.
"""
if not op_xdr_object.sourceAccount:
source = None
else:
source = encode_check(
'account', op_xdr_object.sourceAccount[0].e... |
Creates an XDR Operation object that represents this
:class:`Inflation`. | def to_xdr_object(self):
"""Creates an XDR Operation object that represents this
:class:`Inflation`.
"""
self.body.type = Xdr.const.INFLATION
return super(Inflation, self).to_xdr_object() |
Creates a :class:`Inflation` object from an XDR Operation
object. | def from_xdr_object(cls, op_xdr_object):
"""Creates a :class:`Inflation` object from an XDR Operation
object.
"""
if not op_xdr_object.sourceAccount:
source = None
else:
source = encode_check(
'account', op_xdr_object.sourceAccount[0].ed25... |
Creates an XDR Operation object that represents this
:class:`ManageData`. | def to_xdr_object(self):
"""Creates an XDR Operation object that represents this
:class:`ManageData`.
"""
data_name = bytearray(self.data_name, encoding='utf-8')
if self.data_value is not None:
if isinstance(self.data_value, bytes):
data_value = [byt... |
Creates a :class:`ManageData` object from an XDR Operation
object. | def from_xdr_object(cls, op_xdr_object):
"""Creates a :class:`ManageData` object from an XDR Operation
object.
"""
if not op_xdr_object.sourceAccount:
source = None
else:
source = encode_check(
'account', op_xdr_object.sourceAccount[0].ed2... |
Creates an XDR Operation object that represents this
:class:`BumpSequence`. | def to_xdr_object(self):
"""Creates an XDR Operation object that represents this
:class:`BumpSequence`.
"""
bump_sequence_op = Xdr.types.BumpSequenceOp(self.bump_to)
self.body.type = Xdr.const.BUMP_SEQUENCE
self.body.bumpSequenceOp = bump_sequence_op
return super... |
Creates a :class:`BumpSequence` object from an XDR Operation
object. | def from_xdr_object(cls, op_xdr_object):
"""Creates a :class:`BumpSequence` object from an XDR Operation
object.
"""
if not op_xdr_object.sourceAccount:
source = None
else:
source = encode_check(
'account', op_xdr_object.sourceAccount[0].e... |
Creates an XDR Memo object for a transaction with MEMO_TEXT. | def to_xdr_object(self):
"""Creates an XDR Memo object for a transaction with MEMO_TEXT."""
return Xdr.types.Memo(type=Xdr.const.MEMO_TEXT, text=self.text) |
Creates an XDR Memo object for a transaction with MEMO_HASH. | def to_xdr_object(self):
"""Creates an XDR Memo object for a transaction with MEMO_HASH."""
return Xdr.types.Memo(type=Xdr.const.MEMO_HASH, hash=self.memo_hash) |
Creates an XDR Memo object for a transaction with MEMO_RETURN. | def to_xdr_object(self):
"""Creates an XDR Memo object for a transaction with MEMO_RETURN."""
return Xdr.types.Memo(
type=Xdr.const.MEMO_RETURN, retHash=self.memo_return) |
Append an :class:`Operation <stellar_base.operation.Operation>` to
the list of operations.
Add the operation specified if it doesn't already exist in the list of
operations of this :class:`Builder` instance.
:param operation: The operation to append to the list of operations.
:... | def append_op(self, operation):
"""Append an :class:`Operation <stellar_base.operation.Operation>` to
the list of operations.
Add the operation specified if it doesn't already exist in the list of
operations of this :class:`Builder` instance.
:param operation: The operation to ... |
Append a :class:`CreateAccount
<stellar_base.operation.CreateAccount>` operation to the list of
operations.
:param str destination: Account address that is created and funded.
:param str starting_balance: Amount of XLM to send to the newly created
account. This XLM comes fro... | def append_create_account_op(self,
destination,
starting_balance,
source=None):
"""Append a :class:`CreateAccount
<stellar_base.operation.CreateAccount>` operation to the list of
operations.
... |
append_trust_op will be deprecated in the future, use append_change_trust_op instead.
Append a :class:`ChangeTrust <stellar_base.operation.ChangeTrust>`
operation to the list of operations.
:param str destination: The issuer address for the asset.
:param str code: The asset code for the... | def append_trust_op(self, destination, code, limit=None, source=None): # pragma: no cover
"""append_trust_op will be deprecated in the future, use append_change_trust_op instead.
Append a :class:`ChangeTrust <stellar_base.operation.ChangeTrust>`
operation to the list of operations.
:pa... |
Append a :class:`ChangeTrust <stellar_base.operation.ChangeTrust>`
operation to the list of operations.
:param str asset_issuer: The issuer address for the asset.
:param str asset_code: The asset code for the asset.
:param str limit: The limit of the new trustline.
:param str so... | def append_change_trust_op(self, asset_code, asset_issuer, limit=None, source=None):
"""Append a :class:`ChangeTrust <stellar_base.operation.ChangeTrust>`
operation to the list of operations.
:param str asset_issuer: The issuer address for the asset.
:param str asset_code: The asset cod... |
Append a :class:`Payment <stellar_base.operation.Payment>` operation
to the list of operations.
:param str destination: Account address that receives the payment.
:param str amount: The amount of the currency to send in the payment.
:param str asset_code: The asset code for the asset to... | def append_payment_op(self,
destination,
amount,
asset_code='XLM',
asset_issuer=None,
source=None):
"""Append a :class:`Payment <stellar_base.operation.Payment>` operation
to... |
Append a :class:`PathPayment <stellar_base.operation.PathPayment>`
operation to the list of operations.
:param str destination: The destination address (Account ID) for the
payment.
:param str send_code: The asset code for the source asset deducted from
the source accoun... | def append_path_payment_op(self,
destination,
send_code,
send_issuer,
send_max,
dest_code,
dest_issuer,
... |
Append an :class:`AllowTrust <stellar_base.operation.AllowTrust>`
operation to the list of operations.
:param str trustor: The account of the recipient of the trustline.
:param str asset_code: The asset of the trustline the source account
is authorizing. For example, if an anchor w... | def append_allow_trust_op(self,
trustor,
asset_code,
authorize,
source=None):
"""Append an :class:`AllowTrust <stellar_base.operation.AllowTrust>`
operation to the list of operations.
... |
Append a :class:`SetOptions <stellar_base.operation.SetOptions>`
operation to the list of operations.
.. _Accounts:
https://www.stellar.org/developers/guides/concepts/accounts.html
:param str inflation_dest: The address in which to send inflation to on
an :class:`Inflat... | def append_set_options_op(self,
inflation_dest=None,
clear_flags=None,
set_flags=None,
master_weight=None,
low_threshold=None,
med_threshold... |
Add a HashX signer to an account.
Add a HashX signer to an account via a :class:`SetOptions
<stellar_base.operation.SetOptions` operation. This is a helper
function for :meth:`append_set_options_op`.
:param hashx: The address of the new hashX signer.
:type hashx: str, bytes
... | def append_hashx_signer(self, hashx, signer_weight, source=None):
"""Add a HashX signer to an account.
Add a HashX signer to an account via a :class:`SetOptions
<stellar_base.operation.SetOptions` operation. This is a helper
function for :meth:`append_set_options_op`.
:param ha... |
Add a PreAuthTx signer to an account.
Add a PreAuthTx signer to an account via a :class:`SetOptions
<stellar_base.operation.SetOptions` operation. This is a helper
function for :meth:`append_set_options_op`.
:param pre_auth_tx: The address of the new preAuthTx signer - obtained by call... | def append_pre_auth_tx_signer(self,
pre_auth_tx,
signer_weight,
source=None):
"""Add a PreAuthTx signer to an account.
Add a PreAuthTx signer to an account via a :class:`SetOptions
<stellar_bas... |
Append a :class:`ManageOffer <stellar_base.operation.ManageOffer>`
operation to the list of operations.
:param str selling_code: The asset code for the asset the offer creator
is selling.
:param selling_issuer: The issuing address for the asset the offer
creator is selli... | def append_manage_offer_op(self,
selling_code,
selling_issuer,
buying_code,
buying_issuer,
amount,
price,
... |
Append a :class:`CreatePassiveOffer
<stellar_base.operation.CreatePassiveOffer>` operation to the list of
operations.
:param str selling_code: The asset code for the asset the offer creator
is selling.
:param selling_issuer: The issuing address for the asset the offer
... | def append_create_passive_offer_op(self,
selling_code,
selling_issuer,
buying_code,
buying_issuer,
amount,
... |
Append a :class:`AccountMerge
<stellar_base.operation.AccountMerge>` operation to the list of
operations.
:param str destination: The ID of the offer. 0 for new offer. Set to
existing offer ID to update or delete.
:param str source: The source address that is being merged in... | def append_account_merge_op(self, destination, source=None):
"""Append a :class:`AccountMerge
<stellar_base.operation.AccountMerge>` operation to the list of
operations.
:param str destination: The ID of the offer. 0 for new offer. Set to
existing offer ID to update or delet... |
Append a :class:`Inflation
<stellar_base.operation.Inflation>` operation to the list of
operations.
:param str source: The source address that is running the inflation
operation.
:return: This builder instance. | def append_inflation_op(self, source=None):
"""Append a :class:`Inflation
<stellar_base.operation.Inflation>` operation to the list of
operations.
:param str source: The source address that is running the inflation
operation.
:return: This builder instance.
... |
Append a :class:`ManageData <stellar_base.operation.ManageData>`
operation to the list of operations.
:param str data_name: String up to 64 bytes long. If this is a new Name
it will add the given name/value pair to the account. If this Name
is already present then the associated... | def append_manage_data_op(self, data_name, data_value, source=None):
"""Append a :class:`ManageData <stellar_base.operation.ManageData>`
operation to the list of operations.
:param str data_name: String up to 64 bytes long. If this is a new Name
it will add the given name/value pair... |
Append a :class:`BumpSequence <stellar_base.operation.BumpSequence>`
operation to the list of operations.
Only available in protocol version 10 and above
:param int bump_to: Sequence number to bump to.
:param str source: The source address that is running the inflation
oper... | def append_bump_sequence_op(self, bump_to, source=None):
"""Append a :class:`BumpSequence <stellar_base.operation.BumpSequence>`
operation to the list of operations.
Only available in protocol version 10 and above
:param int bump_to: Sequence number to bump to.
:param str sourc... |
Set the memo for the transaction to a new :class:`TextMemo
<stellar_base.memo.TextMemo>`.
:param memo_text: The text for the memo to add.
:type memo_text: str, bytes
:return: This builder instance. | def add_text_memo(self, memo_text):
"""Set the memo for the transaction to a new :class:`TextMemo
<stellar_base.memo.TextMemo>`.
:param memo_text: The text for the memo to add.
:type memo_text: str, bytes
:return: This builder instance.
"""
memo_text = memo.Text... |
Set the memo for the transaction to a new :class:`IdMemo
<stellar_base.memo.IdMemo>`.
:param int memo_id: A 64 bit unsigned integer to set as the memo.
:return: This builder instance. | def add_id_memo(self, memo_id):
"""Set the memo for the transaction to a new :class:`IdMemo
<stellar_base.memo.IdMemo>`.
:param int memo_id: A 64 bit unsigned integer to set as the memo.
:return: This builder instance.
"""
memo_id = memo.IdMemo(memo_id)
return s... |
Set the memo for the transaction to a new :class:`HashMemo
<stellar_base.memo.HashMemo>`.
:param memo_hash: A 32 byte hash or hex encoded string to use as the memo.
:type memo_hash: bytes, str
:return: This builder instance. | def add_hash_memo(self, memo_hash):
"""Set the memo for the transaction to a new :class:`HashMemo
<stellar_base.memo.HashMemo>`.
:param memo_hash: A 32 byte hash or hex encoded string to use as the memo.
:type memo_hash: bytes, str
:return: This builder instance.
"""
... |
Set the memo for the transaction to a new :class:`RetHashMemo
<stellar_base.memo.RetHashMemo>`.
:param bytes memo_return: A 32 byte hash or hex encoded string intended to be interpreted as
the hash of the transaction the sender is refunding.
:type memo_return: bytes, str
:re... | def add_ret_hash_memo(self, memo_return):
"""Set the memo for the transaction to a new :class:`RetHashMemo
<stellar_base.memo.RetHashMemo>`.
:param bytes memo_return: A 32 byte hash or hex encoded string intended to be interpreted as
the hash of the transaction the sender is refundi... |
Append a :class:`Payment <stellar_base.operation.Payment>` operation
to the list of operations using federation on the destination address.
Translates the destination stellar address to an account ID via
:func:`federation <stellar_base.federation.federation>`, before
creating a new paym... | def federation_payment(self,
fed_address,
amount,
asset_code='XLM',
asset_issuer=None,
source=None,
allow_http=False):
"""Append a :class:`Payment <st... |
Generate a :class:`Transaction
<stellar_base.transaction.Transaction>` object from the list of
operations contained within this object.
:return: A transaction representing all of the operations that have
been appended to this builder.
:rtype: :class:`Transaction <stellar_bas... | def gen_tx(self):
"""Generate a :class:`Transaction
<stellar_base.transaction.Transaction>` object from the list of
operations contained within this object.
:return: A transaction representing all of the operations that have
been appended to this builder.
:rtype: :cl... |
Create an XDR object representing this builder's transaction to be
sent over via the Compliance protocol (notably, with a sequence number
of 0).
Intentionally, the XDR object is returned without any signatures on the
transaction.
See `Stellar's documentation on its Compliance P... | def gen_compliance_xdr(self):
"""Create an XDR object representing this builder's transaction to be
sent over via the Compliance protocol (notably, with a sequence number
of 0).
Intentionally, the XDR object is returned without any signatures on the
transaction.
See `St... |
Create a :class:`TransactionEnvelope
<stellar_base.transaction_envelope.TransactionEnvelope>` via an XDR
object.
In addition, sets the fields of this builder (the transaction envelope,
transaction, operations, source, etc.) to all of the fields in the
provided XDR transaction en... | def import_from_xdr(self, xdr):
"""Create a :class:`TransactionEnvelope
<stellar_base.transaction_envelope.TransactionEnvelope>` via an XDR
object.
In addition, sets the fields of this builder (the transaction envelope,
transaction, operations, source, etc.) to all of the fields... |
Sign the generated :class:`TransactionEnvelope
<stellar_base.transaction_envelope.TransactionEnvelope>` from the list
of this builder's operations.
:param str secret: The secret seed to use if a key pair or secret was
not provided when this class was originaly instantiated, or if
... | def sign(self, secret=None):
"""Sign the generated :class:`TransactionEnvelope
<stellar_base.transaction_envelope.TransactionEnvelope>` from the list
of this builder's operations.
:param str secret: The secret seed to use if a key pair or secret was
not provided when this cl... |
Sign the generated transaction envelope using a Hash(x) signature.
:param preimage: The value to be hashed and used as a signer on the
transaction envelope.
:type preimage: str, bytes | def sign_preimage(self, preimage):
"""Sign the generated transaction envelope using a Hash(x) signature.
:param preimage: The value to be hashed and used as a signer on the
transaction envelope.
:type preimage: str, bytes
"""
if self.te is None:
self.gen... |
Create a new builder based off of this one with its sequence number
incremented.
:return: A new Builder instance
:rtype: :class:`Builder` | def next_builder(self):
"""Create a new builder based off of this one with its sequence number
incremented.
:return: A new Builder instance
:rtype: :class:`Builder`
"""
sequence = self.sequence + 1
next_builder = Builder(
horizon_uri=self.horizon.hor... |
Get the sequence number for a given account via Horizon.
:return: The current sequence number for a given account
:rtype: int | def get_sequence(self):
"""Get the sequence number for a given account via Horizon.
:return: The current sequence number for a given account
:rtype: int
"""
if not self.address:
raise StellarAddressInvalidError('No address provided.')
address = self.horizon.... |
Generate a dict for this object's attributes.
:return: A dict representing an :class:`Asset` | def to_dict(self):
"""Generate a dict for this object's attributes.
:return: A dict representing an :class:`Asset`
"""
rv = {'code': self.code}
if not self.is_native():
rv['issuer'] = self.issuer
rv['type'] = self.type
else:
rv['type']... |
Create an XDR object for this :class:`Asset`.
:return: An XDR Asset object | def to_xdr_object(self):
"""Create an XDR object for this :class:`Asset`.
:return: An XDR Asset object
"""
if self.is_native():
xdr_type = Xdr.const.ASSET_TYPE_NATIVE
return Xdr.types.Asset(type=xdr_type)
else:
x = Xdr.nullclass()
... |
Create an base64 encoded XDR string for this :class:`Asset`.
:return str: A base64 encoded XDR object representing this
:class:`Asset`. | def xdr(self):
"""Create an base64 encoded XDR string for this :class:`Asset`.
:return str: A base64 encoded XDR object representing this
:class:`Asset`.
"""
asset = Xdr.StellarXDRPacker()
asset.pack_Asset(self.to_xdr_object())
return base64.b64encode(asset.... |
Create a :class:`Asset` from an XDR Asset object.
:param asset_xdr_object: The XDR Asset object.
:return: A new :class:`Asset` object from the given XDR Asset object. | def from_xdr_object(cls, asset_xdr_object):
"""Create a :class:`Asset` from an XDR Asset object.
:param asset_xdr_object: The XDR Asset object.
:return: A new :class:`Asset` object from the given XDR Asset object.
"""
if asset_xdr_object.type == Xdr.const.ASSET_TYPE_NATIVE:
... |
Create an :class:`Asset` object from its base64 encoded XDR
representation.
:param bytes xdr: The base64 encoded XDR Asset object.
:return: A new :class:`Asset` object from its encoded XDR
representation. | def from_xdr(cls, xdr):
"""Create an :class:`Asset` object from its base64 encoded XDR
representation.
:param bytes xdr: The base64 encoded XDR Asset object.
:return: A new :class:`Asset` object from its encoded XDR
representation.
"""
xdr_decoded = base64.... |
r'[A-Za-z][A-Za-z0-9_]* | def t_ID(t):
r'[A-Za-z][A-Za-z0-9_]*'
if t.value in keywords:
t.type = t.value.upper()
return t |
constant_def : CONST ID EQUALS constant SEMI | def p_constant_def(t):
"""constant_def : CONST ID EQUALS constant SEMI"""
global name_dict
id = t[2]
value = t[4]
lineno = t.lineno(1)
if id_unique(id, 'constant', lineno):
name_dict[id] = const_info(id, value, lineno) |
optional_value : value
| empty | def p_optional_value(t):
"""optional_value : value
| empty"""
# return value or None.
t[0] = t[1]
# Note this must be unsigned
value = t[0]
if value is None or value[0].isdigit():
return
msg = ''
if value[0] == '-':
msg = "Can't use negative index %s... |
type_def : TYPEDEF declaration SEMI | def p_type_def_1(t):
"""type_def : TYPEDEF declaration SEMI"""
# declarations is a type_info
d = t[2]
lineno = t.lineno(1)
sortno = t.lineno(3) + 0.5
if d.type == 'void':
global error_occurred
error_occurred = True
print(
u"ERROR - can't use void in typedef at... |
type_def : ENUM ID enum_body SEMI | def p_type_def_2(t):
"""type_def : ENUM ID enum_body SEMI"""
id = t[2]
body = t[3]
lineno = t.lineno(1)
sortno = t.lineno(4) + 0.5
if id_unique(id, 'enum', lineno):
name_dict[id] = enum_info(id, body, lineno, sortno) |
type_def : STRUCT ID struct_body SEMI | def p_type_def_3(t):
"""type_def : STRUCT ID struct_body SEMI"""
id = t[2]
body = t[3]
lineno = t.lineno(1)
if id_unique(id, 'struct', lineno):
name_dict[id] = struct_info(id, body, lineno) |
type_def : UNION ID union_body SEMI | def p_type_def_4(t):
"""type_def : UNION ID union_body SEMI"""
id = t[2]
body = t[3]
lineno = t.lineno(1)
if id_unique(id, 'union', lineno):
name_dict[id] = union_info(id, body, lineno) |
declaration : type_specifier STAR ID | def p_declaration_3(t):
"""declaration : type_specifier STAR ID"""
# encode this as the equivalent 'type_specifier ID LT 1 GT'
if not isinstance(t[1], type_info):
t[1] = type_info(t[1], t.lineno(1))
t[1].id = t[3]
t[1].array = True
t[1].fixed = False
t[1].len = '1'
t[0] = t[1] |
type_specifier : INT
| HYPER
| FLOAT
| DOUBLE
| QUADRUPLE
| BOOL
| ID
| UNSIGNED
| enum_type_spec
| struct_type_spec
... | def p_type_specifier_2(t):
"""type_specifier : INT
| HYPER
| FLOAT
| DOUBLE
| QUADRUPLE
| BOOL
| ID
| UNSIGNED
| enum_type_spec
... |
enum_constant : ID EQUALS value | def p_enum_constant(t):
"""enum_constant : ID EQUALS value"""
global name_dict, error_occurred
id = t[1]
value = t[3]
lineno = t.lineno(1)
if id_unique(id, 'enum', lineno):
info = name_dict[id] = const_info(id, value, lineno, enum=True)
if not (value[0].isdigit() or value[0] == '... |
program_def : PROGRAM ID LBRACE version_def version_def_list RBRACE EQUALS constant SEMI | def p_program_def(t):
"""program_def : PROGRAM ID LBRACE version_def version_def_list RBRACE EQUALS constant SEMI"""
print("Ignoring program {0:s} = {1:s}".format(t[2], t[8]))
global name_dict
id = t[2]
value = t[8]
lineno = t.lineno(1)
if id_unique(id, 'program', lineno):
name_dict[... |
version_def : VERSION ID LBRACE procedure_def procedure_def_list RBRACE EQUALS constant SEMI | def p_version_def(t):
"""version_def : VERSION ID LBRACE procedure_def procedure_def_list RBRACE EQUALS constant SEMI"""
global name_dict
id = t[2]
value = t[8]
lineno = t.lineno(1)
if id_unique(id, 'version', lineno):
name_dict[id] = const_info(id, value, lineno) |
procedure_def : proc_return ID LPAREN proc_firstarg type_specifier_list RPAREN EQUALS constant SEMI | def p_procedure_def(t):
"""procedure_def : proc_return ID LPAREN proc_firstarg type_specifier_list RPAREN EQUALS constant SEMI"""
global name_dict
tid = t[2]
value = t[8]
lineno = t.lineno(1)
if id_unique(tid, 'procedure', lineno):
name_dict[tid] = const_info(tid, value, lineno) |
Returns True if dict_id not already used. Otherwise, invokes error | def id_unique(dict_id, name, lineno):
"""Returns True if dict_id not already used. Otherwise, invokes error"""
if dict_id in name_dict:
global error_occurred
error_occurred = True
print(
"ERROR - {0:s} definition {1:s} at line {2:d} conflicts with {3:s}"
.format(... |
Return xdr code for the body (part between braces) of big 3 types | def xdrbody(self, prefix=''):
"""Return xdr code for the body (part between braces) of big 3 types"""
body = ''
prefix += indent
if self.type == 'enum':
body = ''.join(
["%s,\n" % l.xdrout(prefix) for l in self.body[:-1]])
body += "%s\n" % self.bod... |
Encode a string using Base58 with a 4 character checksum | def b58encode_check(v):
"""Encode a string using Base58 with a 4 character checksum"""
digest = sha256(sha256(v).digest()).digest()
return b58encode(v + digest[:4]) |
Base58 encode or decode FILE, or standard input, to standard output. | def main():
'''Base58 encode or decode FILE, or standard input, to standard output.'''
import sys
import argparse
stdout = buffer(sys.stdout)
parser = argparse.ArgumentParser(description=main.__doc__)
parser.add_argument(
'file',
metavar='FILE',
nargs='?',
type... |
Use dhcpcd to activate the interfaces.
Args:
interfaces: list of string, the output device names to enable.
logger: logger object, used to write to SysLog and serial port. | def _Dhcpcd(self, interfaces, logger):
"""Use dhcpcd to activate the interfaces.
Args:
interfaces: list of string, the output device names to enable.
logger: logger object, used to write to SysLog and serial port.
"""
for interface in interfaces:
dhcpcd = ['/sbin/dhcpcd']
try:
... |
Generate a dictionary mapping MAC address to Ethernet interfaces.
Returns:
dict, string MAC addresses mapped to the string network interface name. | def _CreateInterfaceMapSysfs(self):
"""Generate a dictionary mapping MAC address to Ethernet interfaces.
Returns:
dict, string MAC addresses mapped to the string network interface name.
"""
interfaces = {}
for interface in os.listdir('/sys/class/net'):
try:
mac_address = open(
... |
Generate a dictionary mapping MAC address to Ethernet interfaces.
Returns:
dict, string MAC addresses mapped to the string network interface name. | def _CreateInterfaceMapNetifaces(self):
"""Generate a dictionary mapping MAC address to Ethernet interfaces.
Returns:
dict, string MAC addresses mapped to the string network interface name.
"""
interfaces = {}
for interface in netifaces.interfaces():
af_link = netifaces.ifaddresses(int... |
Context manager for creating a temporary directory.
Args:
prefix: string, the prefix for the temporary directory.
run_dir: string, the base directory location of the temporary directory.
Yields:
string, the temporary directory created. | def _CreateTempDir(prefix, run_dir=None):
"""Context manager for creating a temporary directory.
Args:
prefix: string, the prefix for the temporary directory.
run_dir: string, the base directory location of the temporary directory.
Yields:
string, the temporary directory created.
"""
temp_dir = ... |
Retrieve metadata scripts and execute them.
Args:
run_dir: string, the base directory location of the temporary directory. | def _RunScripts(self, run_dir=None):
"""Retrieve metadata scripts and execute them.
Args:
run_dir: string, the base directory location of the temporary directory.
"""
with _CreateTempDir(self.script_type, run_dir=run_dir) as dest_dir:
try:
self.logger.info('Starting %s scripts.', se... |
Get the instance configuration specified in metadata.
Returns:
string, the instance configuration data. | def _GetInstanceConfig(self):
"""Get the instance configuration specified in metadata.
Returns:
string, the instance configuration data.
"""
try:
instance_data = self.metadata_dict['instance']['attributes']
except KeyError:
instance_data = {}
self.logger.warning('Instance at... |
Run a script and log the streamed script output.
Args:
script: string, the file location of an executable script. | def _RunScript(self, script):
"""Run a script and log the streamed script output.
Args:
script: string, the file location of an executable script.
"""
process = subprocess.Popen(
script, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE)
while True:
for line in iter(p... |
Generate a new SSH key.
Args:
key_type: string, the type of the SSH key.
key_dest: string, a file location to store the SSH key. | def _GenerateSshKey(self, key_type, key_dest):
"""Generate a new SSH key.
Args:
key_type: string, the type of the SSH key.
key_dest: string, a file location to store the SSH key.
"""
# Create a temporary file to save the created RSA keys.
with tempfile.NamedTemporaryFile(prefix=key_type... |
Initialize the SSH daemon. | def _StartSshd(self):
"""Initialize the SSH daemon."""
# Exit as early as possible.
# Instance setup systemd scripts block sshd from starting.
if os.path.exists(constants.LOCALBASE + '/bin/systemctl'):
return
elif (os.path.exists('/etc/init.d/ssh')
or os.path.exists('/etc/init/ssh.co... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.