Skip to content

Commit fe22652

Browse files
committed
correct document
1 parent 0d1eefc commit fe22652

12 files changed

+110
-117
lines changed

docs/api.rst

+6
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ Manage Data
155155
.. autoclass:: stellar_base.operation.ManageData
156156
:members:
157157

158+
Bump Sequence
159+
^^^^^^^^^^^^^
160+
161+
.. autoclass:: stellar_base.operation.BumpSequence
162+
:members:
163+
158164
Federation
159165
==========
160166

docs/index.rst

+5-6
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,17 @@ methods.
2626

2727
api
2828

29-
Snippets
29+
Examples
3030
--------
31-
Find examples here.
31+
Find examples `here`_.
3232

33-
.. toctree::
34-
:maxdepth: 2
35-
36-
snippets
3733

3834

3935
Indices
4036
-------
4137

4238
* :ref:`genindex`
4339
* :ref:`modindex`
40+
41+
42+
.. _here: https://github.com/StellarCN/py-stellar-base/tree/master/examples

docs/install.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ You can install it from source code via pip:
2727

2828
.. code-block:: bash
2929
30-
pip install git+git://github.com/StellarCN/py-stellar-base
30+
pip install -U git+git://github.com/StellarCN/py-stellar-base
3131
3232
And you can always clone `the repository <https://github.com/StellarCN/py-stellar-base>`_ directly, and install it locally:
3333

docs/quickstart.rst

+16-17
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ your secret phrase:
5757

5858
.. code-block:: python
5959
60-
kp = Keypair.deterministic(m, lang='chinese')
60+
kp = Keypair.deterministic(secret_phrase, lang='chinese')
6161
6262
You can even create multiple key pairs from the same phrase, using a different
6363
index with each call. For example:
6464

6565
.. code-block:: python
6666
67-
kp1 = Keypair.deterministic(m, lang='chinese', index=1)
68-
kp2 = Keypair.deterministic(m, lang='chinese', index=2)
67+
kp1 = Keypair.deterministic(secret_phrase, lang='chinese', index=1)
68+
kp2 = Keypair.deterministic(secret_phrase, lang='chinese', index=2)
6969
7070
From the generated :class:`Keypair <stellar_base.keypair.Keypair>` object, you
7171
can easily access your public and private key.
@@ -146,7 +146,6 @@ account of your own, here's an example of how to do so:
146146
.. code-block:: python
147147
148148
from stellar_base.keypair import Keypair
149-
from stellar_base.asset import Asset
150149
from stellar_base.operation import CreateAccount, Payment
151150
from stellar_base.transaction import Transaction
152151
from stellar_base.transaction_envelope import TransactionEnvelope as Te
@@ -161,11 +160,11 @@ account of your own, here's an example of how to do so:
161160
# new account in the create account operation. You'll need the seed in order
162161
# to sign off on the transaction. This is the source account.
163162
old_account_seed = "SCVLSUGYEAUC4MVWJORB63JBMY2CEX6ATTJ5MXTENGD3IELUQF4F6HUB"
164-
old_account_keypair = Keypair.from_seed(oldAccountSeed)
163+
old_account_keypair = Keypair.from_seed(old_account_seed)
165164
166165
# This is the new account ID (the StrKey representation of your newly
167166
# created public key). This is the destination account.
168-
new_account_addr = "GXXX"
167+
new_account_addr = "GABRGTDZEDCQ5W663U2EI5KWRSU3EAWJCSI57H7XAMUO5BQRIGNNZGTY"
169168
170169
amount = '1' # Your new account minimum balance (in XLM) to transfer over
171170
# create the CreateAccount operation
@@ -174,7 +173,7 @@ account of your own, here's an example of how to do so:
174173
starting_balance=amount
175174
)
176175
# create a memo
177-
memo = TextMemo('Transferring to my new account!')
176+
memo = TextMemo('Hello, StellarCN!')
178177
179178
# Get the current sequence of the source account by contacting Horizon. You
180179
# should also check the response for errors!
@@ -186,7 +185,7 @@ account of your own, here's an example of how to do so:
186185
# Create a transaction with our single create account operation, with the
187186
# default fee of 100 stroops as of this writing (0.00001 XLM)
188187
tx = Transaction(
189-
source=kp.address().decode(),
188+
source=old_account_keypair.address().decode(),
190189
sequence=sequence,
191190
memo=memo,
192191
operations=[
@@ -235,11 +234,11 @@ Like so:
235234

236235
.. code-block:: python
237236
238-
print("Balances: {}'.format(address.balances))
239-
print("Sequence Number: {}'.format(address.sequence))
240-
print("Flags: {}'.format(address.flags))
241-
print("Signers: {}'.format(address.signers))
242-
print("Data: {}'.format(address.data))
237+
print('Balances: {}'.format(address.balances))
238+
print('Sequence Number: {}'.format(address.sequence))
239+
print('Flags: {}'.format(address.flags))
240+
print('Signers: {}'.format(address.signers))
241+
print('Data: {}'.format(address.data))
243242
244243
245244
Most Recent Payments
@@ -268,7 +267,7 @@ signature.
268267

269268
.. code-block:: python
270269
271-
address.payments(sse=True, limit=100)
270+
address.payments(sse=True)
272271
273272
Other Account Attributes
274273
------------------------
@@ -309,7 +308,7 @@ way:
309308
builder = Builder(secret=seed)
310309
# builder = Builder(secret=seed, network='public') for LIVENET
311310
312-
bob_address = 'GXXX'
311+
bob_address = 'GABRGTDZEDCQ5W663U2EI5KWRSU3EAWJCSI57H7XAMUO5BQRIGNNZGTY'
313312
builder.append_payment_op(bob_address, '100', 'XLM')
314313
builder.add_text_memo('For beers') # string length <= 28 bytes
315314
builder.sign()
@@ -341,7 +340,7 @@ this, you use :meth:`import_from_xdr
341340
.. code-block:: python
342341
343342
# This is the transaction that you need to add your signature to
344-
xdr_string = 'GXXX'
343+
xdr_string = 'AAAAAAMTTHkgxQ7b3t00RHVWjKmyAskUkd+f9wMo7oYRQZrcAAAAZAAAAIHlSBzvAAAAAAAAAAAAAAABAAAAAAAAAAoAAAAFaGVsbG8AAAAAAAABAAAAB3N0ZWxsYXIAAAAAAAAAAAA='
345344
builder = Builder(secret=seed)
346345
builder.import_from_xdr(xdr_string)
347346
builder.sign()
@@ -404,7 +403,7 @@ In this example, Alice is sending Bob 100 CNY.
404403
405404
# Construct a transaction
406405
tx = Transaction(
407-
source=Alice.address().decode(),
406+
source=alice_kp.address().decode(),
408407
sequence=sequence,
409408
# time_bounds = {'minTime': 1531000000, 'maxTime': 1531234600},
410409
memo=msg,

docs/snippets.rst

-76
This file was deleted.

examples/create_keypair.py

+26-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1-
from stellar_base import Keypair
1+
from stellar_base.keypair import Keypair
2+
from stellar_base.utils import StellarMnemonic
3+
4+
5+
def generate_random_keypair():
6+
print("Generate random keypair")
7+
key_pair = Keypair.random()
8+
print("Public key / Account address:\n", key_pair.address().decode())
9+
print("Seed / Your secret to keep it on local:\n",
10+
key_pair.seed().decode())
211

312

413
def create_keypair_determinist_english():
14+
print("Create keypair determinist english")
515
mnemonic = ('illness spike retreat truth genius clock brain pass '
616
'fit cave bargain toe')
717
key_pair = Keypair.deterministic(mnemonic)
@@ -10,5 +20,20 @@ def create_keypair_determinist_english():
1020
key_pair.seed().decode())
1121

1222

23+
def create_multiple_keypair():
24+
print("Create multiple keypair")
25+
sm = StellarMnemonic()
26+
secret_phrase = sm.generate()
27+
kp0 = Keypair.deterministic(secret_phrase, index=0)
28+
kp1 = Keypair.deterministic(secret_phrase, index=1)
29+
kp2 = Keypair.deterministic(secret_phrase, index=2)
30+
for key_pair in (kp0, kp1, kp2):
31+
print("Public key / Account address:\n", key_pair.address().decode())
32+
print("Seed / Your secret to keep it on local:\n",
33+
key_pair.seed().decode())
34+
35+
1336
if __name__ == "__main__":
37+
generate_random_keypair()
1438
create_keypair_determinist_english()
39+
create_multiple_keypair()

examples/create_offer.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from stellar_base.builder import Builder
2+
3+
alice_seed = 'SB4675LMYLBWMKENDBAO6ZTVPLI6AISE3VZZDZASUFWW2T4MEGKX7NEI'
4+
bob_address = 'GCRNOBFLTGLGSYOWCYINZA7JAAAZ5CXMSNM7QUYFYOHHIEZY4R6665MA'
5+
6+
selling_code = 'XLM'
7+
selling_issuer = None
8+
9+
buying_code = 'XCN'
10+
buying_issuer = 'GCNY5OXYSY4FKHOPT2SPOQZAOEIGXB5LBYW3HVU3OWSTQITS65M5RCNY'
11+
12+
price = '5.5' # or price = {'n': 55, 'd': 10}
13+
amount = '12.5'
14+
15+
builder = Builder(secret=alice_seed, horizon='https://horizon-testnet.stellar.org') \
16+
.append_manage_offer_op(selling_code, selling_issuer, buying_code, \
17+
buying_issuer, amount, price)
18+
19+
builder.sign()
20+
builder.submit()

examples/payment.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from stellar_base.builder import Builder
2+
3+
alice_secret = 'SCB6JIZUC3RDHLRGFRTISOUYATKEE63EP7MCHNZNXQMQGZSLZ5CNRTKK'
4+
bob_address = 'GA7YNBW5CBTJZ3ZZOWX3ZNBKD6OE7A7IHUQVWMY62W2ZBG2SGZVOOPVH'
5+
6+
builder = Builder(secret=alice_secret)
7+
builder.add_text_memo("Hello, Stellar!").append_payment_op(
8+
destination=bob_address, amount='12.25', asset_code='XLM')
9+
builder.sign()
10+
response = builder.submit()
11+
print(response)

stellar_base/asset.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ class Asset(object):
1616
1717
:param str code: The asset code, in the formats specified in `Stellar's
1818
guide on assets`_.
19-
:param str issuer: The strkey encoded issuer of the asset. Note if the
19+
:param issuer: The strkey encoded issuer of the asset. Note if the
2020
currency is the native currency (XLM (Lumens)), no issuer is necessary.
21+
:type issuer: str, None
2122
2223
.. _Stellar's guide on assets:
2324
https://www.stellar.org/developers/guides/concepts/assets.html

stellar_base/builder.py

+15-8
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ def append_payment_op(self,
148148
:param str destination: Account address that receives the payment.
149149
:param str amount: The amount of the currency to send in the payment.
150150
:param str asset_code: The asset code for the asset to send.
151-
:param str asset_issuer: The address of the issuer of the asset.
151+
:param asset_issuer: The address of the issuer of the asset.
152+
:type asset_issuer: str, None
152153
:param str source: The source address of the payment.
153154
:return: This builder instance.
154155
@@ -174,12 +175,14 @@ def append_path_payment_op(self,
174175
payment.
175176
:param str send_code: The asset code for the source asset deducted from
176177
the source account.
177-
:param str send_issuer: The address of the issuer of the source asset.
178+
:param send_issuer: The address of the issuer of the source asset.
179+
:type send_issuer: str, None
178180
:param str send_max: The maximum amount of send asset to deduct
179181
(excluding fees).
180182
:param str dest_code: The asset code for the final destination asset
181183
sent to the recipient.
182-
:param str dest_issuer: Account address that receives the payment.
184+
:param dest_issuer: Account address that receives the payment.
185+
:type dest_issuer: str, None
183186
:param str dest_amount: The amount of destination asset the destination
184187
account receives.
185188
:param list path: A list of asset tuples, each tuple containing a
@@ -350,12 +353,14 @@ def append_manage_offer_op(self,
350353
351354
:param str selling_code: The asset code for the asset the offer creator
352355
is selling.
353-
:param str selling_issuer: The issuing address for the asset the offer
356+
:param selling_issuer: The issuing address for the asset the offer
354357
creator is selling.
358+
:type selling_issuer: str, None
355359
:param str buying_code: The asset code for the asset the offer creator
356360
is buying.
357-
:param str buying_issuer: The issuing address for the asset the offer
361+
:param buying_issuer: The issuing address for the asset the offer
358362
creator is selling.
363+
:type buying_issuer: str, None
359364
:param str amount: Amount of the asset being sold. Set to 0 if you want
360365
to delete an existing offer.
361366
:param price: Price of 1 unit of selling in terms of buying. You can pass
@@ -388,12 +393,14 @@ def append_create_passive_offer_op(self,
388393
389394
:param str selling_code: The asset code for the asset the offer creator
390395
is selling.
391-
:param str selling_issuer: The issuing address for the asset the offer
396+
:param selling_issuer: The issuing address for the asset the offer
392397
creator is selling.
398+
:type selling_issuer: str, None
393399
:param str buying_code: The asset code for the asset the offer creator
394400
is buying.
395-
:param str buying_issuer: The issuing address for the asset the offer
401+
:param buying_issuer: The issuing address for the asset the offer
396402
creator is selling.
403+
:type buying_issuer: str, None
397404
:param str amount: Amount of the asset being sold. Set to 0 if you want
398405
to delete an existing offer.
399406
:param price: Price of 1 unit of selling in terms of buying. You can pass
@@ -445,7 +452,7 @@ def append_manage_data_op(self, data_name, data_value, source=None):
445452
:param str data_name: String up to 64 bytes long. If this is a new Name
446453
it will add the given name/value pair to the account. If this Name
447454
is already present then the associated value will be modified.
448-
:param bytes data_value: If not present then the existing
455+
:param str data_value: If not present then the existing
449456
Name will be deleted. If present then this value will be set in the
450457
DataEntry. Up to 64 bytes long.
451458
:param str source: The source account on which data is being managed.

0 commit comments

Comments
 (0)