Skip to content

Latest commit

 

History

History

deprecated

LunesPy

LunesPy is an object-oriented Python interface to the Lunes blockchain platform.

Getting Started

You can install LunesPy using:

pip install lunespy

Documentation

The library utilizes classes to represent various Lunes data structures:

  • lunespy.Address
  • lunespy.Asset
  • lunespy.AssetPair
  • lunespy.Order

Code Example

import lunespy as pw

myAddress = pw.Address(privateKey='CtMQWJZqfc7PRzSWiMKaGmWFm4q2VN5fMcYyKDBPDx6S')
otherAddress = pw.Address('3PNTcNiUzppQXDL9RZrK3BcftbujiFqrAfM')
myAddress.sendLunes(otherAddress, 10000000)
myToken = myAddress.issueAsset('Token1', 'My Token', 1000, 0)
while not myToken.status():
	pass
myAddress.sendAsset(otherAddress, myToken, 50)

Address Class

lunespy.Address(address, publicKey, privateKey, seed) Creates a new Address object

attributes:

  • address
  • publicKey
  • privateKey
  • seed

methods:

balance(assetId='', confirmations=0) returns balance of Lunes or other assets

assets() returns a list of assets owned by the address

issueAsset(name, description, quantity, decimals=0, reissuable=False, txFee=DEFAULT_ASSET_FEE, timestamp=0) issue a new asset

reissueAsset(Asset, quantity, reissuable=False, txFee=DEFAULT_ASSET_FEE, timestamp=0) reissue an asset

burnAsset(Asset, quantity, txFee=DEFAULT_ASSET_FEE, timestamp=0) burn the specified quantity of an asset

sendLunes(recipient, amount, attachment='', txFee=DEFAULT_TX_FEE, timestamp=0) send specified amount of Lunes to recipient

massTransferLunes(transfers, attachment='', timestamp=0) sending Lunes tokens via a mass transfer

sendAsset(recipient, asset, amount, attachment='', txFee=DEFAULT_TX_FEE, timestamp=0) send specified amount of an asset to recipient

massTransferLunes(self, transfers, attachment='', timestamp=0) sending an asset via mass transfer

cancelOrder(assetPair, order) cancel an order

buy(assetPair, amount price, maxLifetime=30*86400, matcherFee=DEFAULT_MATCHER_FEE, timestamp=0) post a buy order

tradableBalance(assetPair) get tradable balance for the specified asset pair

sell(assetPair, amount, price, maxLifetime=30*86400, matcherFee=DEFAULT_MATCHER_FEE, timestamp=0) post a sell order

lease(recipient, amount, txFee=DEFAULT_LEASE_FEE, timestamp=0) post a lease transaction

leaseCancel(leaseId, txFee=DEFAULT_LEASE_FEE, timestamp=0) cancel a lease

getOrderHistory(assetPair) get order history for the specified asset pair

cancelOpenOrders(assetPair) cancel all open orders for the specified asset pair

deleteOrderHistory(assetPair) delete order history for the specified asset pair

createAlias(alias, txFee=DEFAULT_ALIAS_FEE, timestamp=0) create alias

sponsorAsset(assetId, minimalFeeInAssets, txFee=lunespy.DEFAULT_SPONSOR_FEE, timestamp=0) sponsoring assets

setScript(script, txFee=lunespy.DEFAULT_SCRIPT_FEE, timestamp=0) sets a script for this address

dataTransaction(data, timestamp=0) sets data for the account. data should be a json array with entries including type (bool, binary, int, string), key and value

deleteDataEntry(key) deletes a given data entry, identified by key, from the data storage of the account

setScript(scriptSource, txFee=lunespy.DEFAULT_SCRIPT_FEE, timestamp=0) issue a smart asset

setAssetScript(asset, scriptSource, txFee=lunespy.DEFAULT_ASSET_SCRIPT_FEE, timestamp=0) set a new script for a smart asset

invokeScript(dappAddress, functionName, params, payments, feeAsset = None, txFee=lunespy.DEFAULT_INVOKE_SCRIPT_FEE) invoke a script on a given dapp address

Asset Class

lunespy.Asset(assetId) Creates a new Asset object

attributes:

  • status
  • assetId
  • issuer
  • name
  • description
  • quantity
  • decimals = 0
  • reissuable = False

methods:

status() returns 'Issued' if the asset exists

AssetPair Class

lunespy.AssetPair(asset1, asset2) Creates a new AssetPair object with 2 Asset objects

attributes:

  • asset1
  • asset2

methods:

orderbook() get order book

ticker() get ticker with 24h ohlcv data

last() get traded price

open() get 24h open price

high() get 24h high price

low() get 24h low price

close() get 24h close price (same as last())

vwap() get 24h vwap price

volume() get 24h volume

priceVolume() get 24h price volume

trades(n) get the last n trades

trades(from, to) get the trades in from/to interval

candles(timeframe, n) get the last n candles in the specified timeframe

candles(timeframe, from, to) get the candles in from/to interval in the specified timeframe

Order Class

lunespy.Order(orderId, assetPair, address='') Creates a new Order object

attributes:

  • status
  • orderId
  • assetPair
  • address
  • matcher
  • matcherPublicKey

methods:

status() returns current order status cancel() cancel the order

Other functions

lunespy.setNode(node, chain, chain_id) set node URL ('http://ip-address:port') and chain (either 'mainnet' or 'testnet', or any other chain, if you also define the chain id)

lunespy.setChain(chain, chain_id) set chain (either 'mainnet' or 'testnet', or any other chain if you also supply the chain id)

lunespy.setOffline() switch to offline mode; sign tx locally without broadcasting to network

lunespy.setOnline() switch to online mode; sign tx locally a broadcast to network

lunespy.validateAddress(address) checks if the provided address is a valid Lunes address

lunespy.setMatcher(node) set matcher URL ('http://ip-address:port')

lunespy.setDatafeed(node) set datafeed URL ('http://ip-address:port')

lunespy.height() get blockchain height

lunespy.lastblock() get last block

lunespy.block(n) get block at specified height

lunespy.tx(id) get transaction details

lunespy.stateChangeForTx(id): get the state changes for the given tx by id

lunespy.stateChangesForAddress(address, limit = 1000): get the last (with a default of 1000) state changes for the given address

lunespy.symbols() get list of symbol-asset mapping

lunespy.markets() get all traded markets with tickers

lunespy.{SYMBOL_NAME} get predefined asset for the specified symbol (lunespy.LUNES, lunespy.BTC, lunespy.USD,...)

Default Fees

The fees for lunes/asset transfers, asset issue/reissue/burn and matcher transactions are set by default as follows:

  • DEFAULT_TX_FEE = 100000
  • DEFAULT_ASSET_FEE = 100000000
  • DEFAULT_MATCHER_FEE = 1000000
  • DEFAULT_LEASE_FEE = 100000
  • DEFAULT_ALIAS_FEE = 100000
  • DEFAULT_SPONSOR_FEE = 100000000
  • DEFAULT_SCRIPT_FEE = 100000

More Examples

Playing with addresses:

import lunespy as pw

# generate a new address
myAddress = pw.Address("<some address>")
myAddress._generate()

# set an address with an address
myAddress = pw.Address('3P6WfA4qYtkgwVAsWiiB6yaea2X8zyXncJh')

# get an existing address from seed
myAddress = pw.Address(seed='seven wrist bargain hope pattern banner plastic maple student chaos grit next space visa answer')

# get an existing address from privateKey
myAddress = pw.Address(privateKey='CtMQWJZqfc7PRzSWiMKaGmWFm4q2VN5fMcYyKDBPDx6S')

# get an existing address from a publicKey
address = pw.Address(publicKey=EYNuSmW4Adtcc6AMCZyxkiHMPmF2BZ2XxvjpBip3UFZL”)

# get an address from a seed with a different nonce (This is especially useful for accessing addresses generated by nodes)
myAddress = pw.Address(seed='seven wrist bargain hope pattern banner plastic maple student chaos grit next space visa answer', nonce=1)

Balances:

import lunespy as pw

myAddress = pw.Address('3P6WfA4qYtkgwVAsWiiB6yaea2X8zyXncJh')

# get Lunes balance
print("Your balance is %18d" % myAddress.balance())

# get Lunes balance after 20 confirmations 
print("Your balance is %18d" % myAddress.balance(confirmations = 20))

# get an asset balance
print("Your asset balance is %18d" % myAddress.balance('DHgwrRvVyqJsepd32YbBqUeDH4GJ1N984X8QoekjgH8J'))

Lunes and asset transfers:

import lunespy as pw

myAddress = pw.Address(privateKey='CtMQWJZqfc7PRzSWiMKaGmWFm4q2VN5fMcYyKDBPDx6S')

# send Lunes to another address
myAddress.sendLunes(recipient = pw.Address('3PNTcNiUzppQXDL9RZrK3BcftbujiFqrAfM'),
                    amount = 100000000)

# send asset to another address
myToken = pw.Asset('4ZzED8WJXsvuo2MEm2BmZ87Azw8Sx7TVC6ufSUA5LyTV')
myAddress.sendAsset(recipient = pw.Address('3PNTcNiUzppQXDL9RZrK3BcftbujiFqrAfM'),
                    asset = myToken,
                    amount = 1000)

Issuing an asset:

import lunespy as pw

myToken = myAddress.issueAsset( name = "MyToken",
                                description = "This is my first token",
                                quantity = 1000000,
                                decimals = 2 )

Create an alias:

import lunespy as pw

pw.setNode(node = 'http://127.0.0.1:6869', chain = 'testnet')

myAddress = pw.Address(privateKey='CtMQWJZqfc7PRzSWiMKaGmWFm4q2VN5fMcYyKDBPDx6S')
myAddress.createAlias("MYALIAS1")

Mass payment:

import lunespy as pw

recipients =   ['3PBbp6bg2YEnHfdJtYM7jzzXYQeb7sx5oFg',
                '3P4A27aCd3skNja46pcgrLYEnK36TkSzgUp',
                '3P81U3ujotNUwZMWALdcJQLzBVbrAuUQMfs',
                '3PGcKEMwQcEbmeL8Jhe9nZQRBNCNdcHCoZP',
                '3PKjtzZ4FhKrJUikbQ1hRk5xbwVKDyTyvkn']

myAddress = pw.Address(privateKey = "CtMQWJZqfc7PRzSWiMKaGmWFm4q2VN5fMcYyKDBPDx6S")

for address in recipients:
	myAddress.sendLunes(pw.Address(address), 1000000)

Mass transfer of Lunes (feature 11)

import lunespy as pw

transfers = [
	{ 'recipient': '3N1xca2DY8AEwqRDAJpzUgY99eq8J9h4rB3', 'amount': 1 },
	{ 'recipient': '3N3YWbQ27NnK7tek6ASFh38Bj93guLxxSi1', 'amount': 2 },
	{ 'recipient': '3MwiB5UkWxt4X1qJ8DQpP2LpM3m48V1z5rC', 'amount': 3 }
]

address = pw.Address(privateKey = "CtMQWJZqfc7PRzSWiMKaGmWFm4q2VN5fMcYyKDBPDx6S")
address.massTransferLunes(transfers)

Mass transfer of Assets (feature 11)

import lunespy as pw

transfers = [
	{ 'recipient': '3N1xca2DY8AEwqRDAJpzUgY99eq8J9h4rB3', 'amount': 1 },
	{ 'recipient': '3N3YWbQ27NnK7tek6ASFh38Bj93guLxxSi1', 'amount': 2 },
	{ 'recipient': '3MwiB5UkWxt4X1qJ8DQpP2LpM3m48V1z5rC', 'amount': 3 }
]

address = pw.Address(privateKey = "CtMQWJZqfc7PRzSWiMKaGmWFm4q2VN5fMcYyKDBPDx6S")
address.massTransferAssets(transfers, pw.Asset('9DtBNdyBCyViLZHptyF1HbQk73F6s7nQ5dXhNHubtBhd'))

Data Transaction:

import lunespy as py

myAddress = py.Address(privateKey='CtMQWJZqfc7PRzSWiMKaGmWFm4q2VN5fMcYyKDBPDx6S')

data = [{
        'type':'string', 
        'key': 'test', 
        'value':'testval'
        }]

myAddress.dataTransaction(data)

Token airdrop:

import lunespy as pw

myAddress = pw.Address(privateKey = '`')
myToken = pw.Asset('4ZzED8WJXsvuo2MEm2BmZ87Azw8Sx7TVC6ufSUA5LyTV')
amount = 1000

with open('recipients.txt') as f:
	lines = f.readlines()
for address in lines:
	myAddress.sendAsset(pw.Address(address.strip()), myToken, amount)

Add a script to an account:

import lunespy as pw
import base64

pw.setNode(node='<node>', chain='testnet')

script = 'match tx { \n' + \
'  case _ => true\n' + \
'}'
address = pw.Address(privateKey = "<private key>")
tx = address.setScript(script, txFee=1000000)

Issue a Smart Asset

imort lunespy as pw
import base64

pw.setNode(node='<node>', chain='testnet')

script = 'match tx { \n' + \
'  case _ => true\n' + \
'}'
address = pw.Address(privateKey = '<private key>')
tx = address.issueSmartAsset('smartTestAsset', 'an asset for testingsmart assets', 1000, script, 2)

Set a new script for a Smart Asset

import lunespy as pw
import base64

pw.setNode(node='<node>', chain='testnet')

script = 'match tx { \n' + \
'  case _ => true\n' + \
'}'
address = pw.Address(privateKey = '<private key>')
tx = address.setAssetScript(pw.Asset('<asset id>'), script)

Invoking a script on a dapp address

import lunespy as pw

pw.setNode(node='<node>', chain='testnet')

address = pw.Address(privateKey = '<private key>')
tx = address.invokeScript('3N5Wq22bLSf3gt5VwHTCRbRnETeSwpuT8kK', 'fundRecipient', [{"type": "integer", "value": 100, }, { "type": "string", "value": "test" }, { "type": "boolean", "value": True }], [ { "amount": 100, "assetId": "BGNVLgPKLwiBiZ7vWLcy3r92MzpPCU2DuUb4tv9W6gMi" } ])

Working with contracts

import lunespy as pw

pw.setNode(node = '<node>', 'T')

contract = pw.Contract('3N7XfieeJ8dHyMJfs7amukzxKB1PfMXzHzi', '<seed>')
contract.faucet()

Working with oracles

Querrying oracles:

import lunespy as pw

oracle = pw.Oracle(oracleAddress = '3P4PCxsJqMzQBALo8zANHtBDZRRquobHQp7')
# getting all data entries for an oracle
print(oracle.getData())
# getting data for a specific key of an oracle
print(oracle.getData('order_total_EeH5DRjdMnoYDhNbtkLsRNZq95etJUqWtvMDBCXojBoy'))
# getting all data entries of an oracle filtered by a regular expression
print(oracle.getData(regex = '^order_total_.*$'))

Storing data in an oracle:

import lunespy as pw

pw.setNode('https://testnode1.lunesnodes.com', 'T')

oracle = pw.Oracle(seed='<your seed here>')
print(oracle.storeData('oracle_test', 'string', 'test entry from oracle class'))

Working with more than one network

import lunespy as pw

config = pw.ParallelLunesPy()
config.setNode('https://testnode1.lunesnodes.com', 'testnet')

tAddress = pw.Address(seed = "test test test", lunespy = config)

address = pw.Address(seed = "test test test")
print(tAddress.address)
print(address.address)
print(tAddress.address)

Playing with Lunes Matcher node (DEX):

import lunespy as pw

# set Matcher node to use
pw.setMatcher(node = 'http://127.0.0.1:6886')

# post a buy order
BTC = pw.Asset('4ZzED8WJXsvuo2MEm2BmZ87Azw8Sx7TVC6ufSUA5LyTV')
USD = pw.Asset('6wuo2hTaDyPQVceETj1fc5p4WoMVCGMYNASN8ym4BGiL')
BTC_USD = pw.AssetPair(BTC, USD)
myOrder = myAddress.buy(assetPair = BTC_USD, amount = 15e8, price = 95075)

# post a sell order
WCT = pw.Asset('6wuo2hTaDyPQVceETj1fc5p4WoMVCGMYNASN8ym4BGiL')
Incent = pw.Asset('FLbGXzrpqkvucZqsHDcNxePTkh2ChmEi4GdBfDRRJVof')
WCT_Incent = pw.AssetPair(WCT, Incent)
myOrder = myAddress.sell(assetPair = WCT_Incent, amount = 100e8, price = 25e8)

# post a buy order using Lunes as price asset
BTC = pw.Asset('4ZzED8WJXsvuo2MEm2BmZ87Azw8Sx7TVC6ufSUA5LyTV')
BTC_LUNES = pw.AssetPair(BTC, pw.LUNES)
myOrder = myAddress.buy(assetPair = BTC_LUNES, amount = 1e8, price = 50e8)

# cancel an order
myOrder.cancel()
# or
myAddress.cancelOrder(assetPair, myOrder)

Getting Market Data from Lunes Data Feed (WDF):

import lunespy as pw

# set the asset pair
LUNES_BTC = pw.AssetPair(pw.LUNES, pw.BTC)

# get last price and volume
print("%s %s" % (LUNES_BTC.last(), LUNES_BTC.volume()))

# get ticker
ticker = LUNES_BTC.ticker()
print(ticker['24h_open'])
print(ticker['24h_vwap'])

# get last 10 trades
trades = LUNES_BTC.trades(10)
for t in trades:
	print("%s %s %s %s" % (t['buyer'], t['seller'], t['price'], t['amount']))
	
# get last 10 daily OHLCV candles
ohlcv = LUNES_BTC.candles(1440, 10)
for t in ohlcv:
	print("%s %s %s %s %s" % (t['open'], t['high'], t['low'], t['close'], t['volume']))

LPOS

import lunespy as pw

# connect to a local testnet node
pw.setNode(node = 'http://127.0.0.1:6869', chain = 'testnet')

myAddress = pw.Address(privateKey = 'CsBpQpNE3Z1THNMS9vJPaXqYwN9Hgmhd9AsAPrM3tiuJ')
minerAddress = pw.Address('3NBThmVJmcexzJ9itP9KiiC2K6qnGQwpqMq')

# lease 1000 Lunes to minerAddress
leaseId = myAddress.lease(minerAddress, 100000000000)

# revoke the lease
myAddress.leaseCancel(leaseId)

Using LunesPy in a Python shell

Check an address balance:

>>> import lunespy as pw
>>> pw.Address('3P31zvGdh6ai6JK6zZ18TjYzJsa1B83YPoj')
address = 3P31zvGdh6ai6JK6zZ18TjYzJsa1B83YPoj
publicKey = 
privateKey = 
seed = 
balances:
  Lunes = 1186077288304570
  BDMRyZsmDZpgKhdM7fUTknKcUbVVkDpMcqEj31PUzjMy (Tokes) = 43570656915
  RRBqh2XxcwAdLYEdSickM589Vb4RCemBCPH5mJaWhU9 (Ripto Bux) = 4938300000000
  4rmhfoscYcjz1imNDvtz45doouvrQqDpbX7xdfLB4guF (incentCoffee) = 7
  Ftim86CXM6hANxArJXZs2Fq7XLs3nJvgBzzEwQWwQn6N (Lunes) = 2117290600000000
  E4ip4jzTc4PCvebYn1818T4LNoYBVL3Y4Y4dMPatGwa9 (BitCoin) = 500000000000
  FLbGXzrpqkvucZqsHDcNxePTkh2ChmEi4GdBfDRRJVof (Incent) = 12302659925430
  GQr2fpkfmWjMaZCbqMxefbiwgvpcNgYdev7xpuX6xqcE (KISS) = 1000
  DxG3PLganyNzajHGzvWLjc4P3T2CpkBGxY4J9eJAAUPw (UltraCoin) = 200000000000000
  4eWBPyY4XNPsFLoQK3iuVUfamqKLDu5o6zQCYyp9d8Ae (LIKE) = 1000
>>> 

Generate a new address:

>>> import lunespy as pw
>>> newAddress = pw.Address('<some address>')
>>> newAddress._generate()
address = 3P6WfA4qYtkgwVAsWiiB6yaea2X8zyXncJh
publicKey = EYNuSmW4Adtcc6AMCZyxkiHMPmF2BZ2XxvjpBip3UFZL
privateKey = CtMQWJZqfc7PRzSWiMKaGmWFm4q2VN5fMcYyKDBPDx6S
seed = seven wrist bargain hope pattern banner plastic maple student chaos grit next space visa answer
balances:
  Lunes = 0
>>> 

Check an asset:

>>> import lunespy as pw
>>> pw.Asset('DHgwrRvVyqJsepd32YbBqUeDH4GJ1N984X8QoekjgH8J')
status = Issued
assetId = DHgwrRvVyqJsepd32YbBqUeDH4GJ1N984X8QoekjgH8J
issuer = 3PPKF2pH4KMYgsDixjrhnWrPycVHr1Ye37V
name = LunesCommunity
description = Lunes community token.
quantity = 1000000000
decimals = 2
reissuable = False

Post an order and check its status:

>>> myOrder = myAddress.buy(pw.AssetPair(token1, token2), 1, 25)
>>> myOrder
status = Accepted
id = ARZdYgfXz3ksRMvhnGeLLJnn3CQnz7RCa7U6dVw3zert
asset1 = AFzL992FQbhcgSZGKDKAiRWcjtthM55yVCE99hwbHf88
asset2 = 49Aha2RR2eunR3KZFwedfdi7K9v5MLQbLYcmVdp2QkZT
sender.address = 3P6WfA4qYtkgwVAsWiiB6yaea2X8zyXncJh
sender.publicKey = EYNuSmW4Adtcc6AMCZyxkiHMPmF2BZ2XxvjpBip3UFZL
matcher = http://127.0.0.1:6886

Cancel the order

>>> myOrder.cancel()
>>> myOrder
status = Cancelled
id = ARZdYgfXz3ksRMvhnGeLLJnn3CQnz7RCa7U6dVw3zert
asset1 = AFzL992FQbhcgSZGKDKAiRWcjtthM55yVCE99hwbHf88
asset2 = 49Aha2RR2eunR3KZFwedfdi7K9v5MLQbLYcmVdp2QkZT
sender.address = 3P6WfA4qYtkgwVAsWiiB6yaea2X8zyXncJh
sender.publicKey = EYNuSmW4Adtcc6AMCZyxkiHMPmF2BZ2XxvjpBip3UFZL
matcher = http://127.0.0.1:6886

Offline signing and custom timestamps

Offline signing a future transaction:

>>> import lunespy as pw
>>> pw.setOffline()
>>> myAddress=pw.Address(privateKey="F2jVbjrKzjUsZ1AQRdnd8MmxFc85NQz5jwvZX4BXswXv")
>>> recipient=pw.Address("3P8Ya6Ary5gzwnzbBXDp3xjeNG97JEiPcdA")
# sign a future tx to transfer 100 LUNES to recipient
# the tx is valid on Jan 1st, 2020 12:00pm
>>> myAddress.sendLunes(recipient, amount=100e8, timestamp=1577880000000)
{'api-endpoint': '/assets/broadcast/transfer',
 'api-type': 'POST',
 'api-data': '{"fee": 100000,
			   "timestamp": 1577880000000,
			   "senderPublicKey": "27zdzBa1q46RCMamZ8gw2xrTGypZnbzXs5J1Y2HbUmEv",
			   "amount": 10000000000,
			   "attachment": "",
			   "recipient": "3P8Ya6Ary5gzwnzbBXDp3xjeNG97JEiPcdA"
			   "signature": "YetPopTJWC4WBPXbneWv9g6YEp6J9g9rquZWjewjdQnFbmaxtXjrRsUu69NZzHebVzUGLrhQiFFoguXJwdUn8BH"}'}

Offline signing time lock/unlock transactions:

>>> import lunespy as pw
>>> pw.setOffline()
>>> myAddress=pw.Address(privateKey="F2jVbjrKzjUsZ1AQRdnd8MmxFc85NQz5jwvZX4BXswXv")
# generate a lockbox address
>>> lockAddress=pw.Address('<some address>')
>>> lockAddress._generate()
# sign the 'lock' tx to send 100e8 to the lockbox (valid on Nov 1st, 2017)
>>> myAddress.sendLunes(lockAddress, 100e8, timestamp=1509537600000)
{'api-endpoint': '/assets/broadcast/transfer',
 'api-type': 'POST',
 'api-data': '{"fee": 100000,
               "timestamp": 1509537600000,
               "senderPublicKey": "27zdzBa1q46RCMamZ8gw2xrTGypZnbzXs5J1Y2HbUmEv",
               "amount": 10000000000,
               "attachment": "",
               "recipient": "3P3UbyQM9W7WzTgjYkLuBrPZZeWsiUtCcpv",
               "signature": "5VgT6qWxJwxEyrxFNfsi67QqbyUiGq9Ka7HVzgovRTTDT8nLRyuQv2wBAJQhRiXDkTTV6zsQmHnBkh8keCaFPoNT"}'}
# sign the 'unlock' tx to send funds back to myAddress (valid on Jan 1st, 2020)
>>> lockAddress.sendLunes(myAddress, 100e8-200000, txFee=200000, timestamp=1577880000000)
{'api-endpoint': '/assets/broadcast/transfer',
 'api-type': 'POST',
 'api-data': '{"fee": 200000,
               "timestamp": 1577880000000,
			   "senderPublicKey": "52XnBGnAVZmw1CHo9aJPiMsVMiTWeNGSNN9aYJ7cDtx4",
			   "amount": 9999800000,
			   "attachment": "",
			   "recipient": "3P7tfdCaTyYCfg5ojxNahEJDSS4MZ7ybXBY",
			   "signature": "3beyz1sqKefP96LaXWT3CxdPRW86DAxcj6wgWPyyKq3SgdotVqnKyWXDyeHnBzCq1nC7JA9CChTmo1c1iVAv6C4T"}'}
# delete lockbox address and private key
>>> del lockAddress

Connecting to a different node or chain

LunesPy supports both mainnet and testnet chains. By default, LunesPy connects to the mainnet RPC server at https://nodes.lunesnodes.com. It's possible to specify a different server and chain with the setNode() function

import lunespy as pw

# connects to a local testnet node
pw.setNode(node = 'http://127.0.0.1:6869', chain = 'testnet')

# connects to a local mainnet node
pw.setNode(node = 'http://127.0.0.1:6869', chain = 'mainnet')

License

Code released under the MIT License.