Overview
Artifact ID: | 7d6ceface489e266db6ed48ae5098668a8d8dfabc5972784003c026e2e6d3c8c |
---|---|
Page Name: | Manual |
Date: | 2018-07-17 13:51:26 |
Original User: | rkeene |
Next | e144fbbe21e74454dd056b590a6ec4c6bd5168873051fd9c6a6a08ad72a942f4 |
Content
NANO(N) | NANO(N) |
NAME
nano - Tcl bindings for NanoSYNOPSIS
nano::address::
toPublicKey address ?-hex|-binary? ?-verify|-no-verify?
key::
newSeed ?-hex|-binary?
block::
json::toBlock blockJSON
work::
fromWorkData blockHashOrPublicKey ?-hex|-binary?
account::
setFrontier account frontierHash balance representative
INTRODUCTION
Nano is a low-latency payment platform that requires minimal resources, relying on a peer-to-peer network to distribute "blocks", which are cryptographically signed transactions. This package provides bindings for interacting with the Nano network from Tcl.Addresses
Nano addresses are composed of a prefix (either "nano_" or "xrb_") and 300 bits of base32 encoded data. The 300-bits of base32 encoded data produce a string that is 6 characters long using the base32 alphabet 13456789abcdefghijkmnopqrstuwxyz. The format of these 300 bits arestruct {
uint4_t padding = 0000b;
uint256_t publicKey;
uint40_t checksum;
}
The checksum is computed as a 5 byte (40 bit) Blake2b hash of the 256-bit public key (in binary format), followed by reversing the bytes.
Network
The Nano network consists of two different peer-to-peer networks. One for real-time block updates over UDP, and another for bulk ledger updates over TCP (bootstrapping). The real-time network is a broadcast style network where every message sent over it are relayed to all other nodes.struct {
uint8_t magicProtocol = 0x52;
uint8_t magicNetwork = 0x41/0x42/0x43;
uint8_t versionMax;
uint8_t version;
uint8_t versionMin;
uint8_t messageType;
uint16_t extensions;
};
Where the magicProtocol field must be the value 0x52 (which is ASCII 'R') and the magicNetwork field must be one of 0x41, 0x42, or 0x43 corresponding to one of the three Nano networks. A value of 0x41 (ASCII 'A') represents the Test network; A value of 0x42 (ASCII 'B') represents the Beta network; A value of 0x43 (ASCII 'C') represents the Main network.
messageType | Name | On Bootstrap | On Realtime |
0x00 | Invalid | Yes | Yes |
0x01 | Not_A_Type | ? | ? |
0x02 | Keepalive | No | Yes |
0x03 | Publish | No | Yes |
0x04 | Confirm_Req | No | Yes |
0x05 | Confirm_Ack | No | Yes |
0x06 | Bulk_Pull | Yes | No |
0x07 | Bulk_Push | Yes | No |
0x08 | Frontier_Req | Yes | No |
0x09 | Bulk_Pull_Blocks | Yes | No |
- Invalid
-
TODOC
- Not_A_Type
-
TODOC
- Keepalive
-
The Keepalive message requires exactly 8 IPv6 address and port number tuples to be sent as its payload. The IPv6 addresses are each 128-bits (16-bytes) long and the port numbers are 16-bit integers sent in network byte order. The payload for the Keepalive message type is 144 bytes in size.
- Publish
-
TODOC
- Confirm_Req
-
TODOC
- Confirm_Ack
-
TODOC
- Bulk_Pull
-
TODOC
- Bulk_Push
-
TODOC
- Frontier_Req
-
TODOC
- Bulk_Pull_Blocks
-
TODOC
PROCEDURES
Addresses
- ::nano::address::toPublicKey
-
address ?-hex|-binary? ?-verify|-no-verify? -> publicKey
- ::nano::address::fromPublicKey
-
pubKey ?-xrb|-nano? -> address
- ::nano::address::fromPrivateKey
-
privateKey ?-xrb|-nano? -> address
Key Management
- ::nano::key::newSeed
-
?-hex|-binary? -> seed
- ::nano::key::newKey
-
?-hex|-binary? -> privateKey
- ::nano::key::fromSeed
-
seed ?index? ?-hex|-binary? -> privateKey
- ::nano::key::publicKeyFromPrivateKey
-
privateKey ?-hex|-binary? -> publicKey
Low-level Block
- ::nano::block::representation::toBlock
-
blockRepresentation -> blockData
- ::nano::block::json::fromDict
-
blockDict -> blockJSON
- ::nano::block::json::filter
-
blockJSON -> blockJSON
- ::nano::block::dict::fromJSON
-
blockJSON -> blockDict
- ::nano::block::representation::fromBlock
-
blockData ?-xrb|-nano? ? -type=blockType ? ? -signKey=privateKey ? -> blockRepresentation
- ::nano::block::representation::sign
-
blockRepresentation privateKey ?-update|-signature ?-hex|binary?? -> signature|blockJSON
- ::nano::block::representation::verifySignature
-
blockRepresentation -> boolean
- ::nano::block::representation::work
-
blockRepresentation ?-update|-work ?-hex|binary?? -> work|blockRepresentation
- ::nano::block::representation::validateWork
-
blockRepresentation -> boolean
- ::nano::block::hash
-
blockData ?-hex|-binary? -> blockHash
- ::nano::block::signBlockHash
-
blockHash privateKey ?-hex|-binary? -> signature
- ::nano::block::sign
-
blockData privateKey ?-hex|-binary? -> signature
- ::nano::block::verifyBlockHash
-
blockHash signature publicKey -> boolean
- ::nano::block::verify
-
blockData signature publicKey -> boolean
- ::nano::block::create::send
-
from address to address previous blockHash representative address previousBalance integer amount integer ? -json boolean ? -> blockJSON|blockDict
- ::nano::block::create::receive
-
to address sourceBlock blockHash previous blockHash representative address previousBalance integer amount integer ? -json boolean ? -> blockJSON|blockDict
- ::nano::block::create::setRepresentative
-
account address previous blockHash representative address ? -json boolean ? -> blockJSON|blockDict
Work Generation
- ::nano::work::fromWorkData
-
blockHashOrPublicKey ?-hex|-binary? -> work
- ::nano::work::fromBlock
-
blockData -> work
- ::nano::work::validate
-
workData work -> boolean
High-level Account
- :nano::account::setFrontier
-
account frontierHash balance representative
- :nano::account::getFrontier
-
account -> frontierInfo
- :nano::account::getFrontier
-
account ?frontierHash|balance|representative? -> frontierHash|balance|representative
- :nano::account::addPending
-
account blockHash amount
- :nano::account::getPending
-
account ?blockHash? -> dict
- ::nano::account::clearPending
-
account ?blockHash?
- :nano::account::receive
-
account blockHash privateKey -> blockJSON|blockDict
- :nano::account::receiveAllPending
-
account privateKey -> listOfBlockJSON|listOfBlockDict
- :nano::account::send
-
fromAccount toAccount amount privateKey -> blockJSON|blockDict
- ::nano::account::setRepresentative
-
account representative privateKey -> blockJSON|blockDict
EXAMPLES
Example 1: Generate a new seed and derive 10 addresses from it
package require nano 1.1
set seed [::nano::key::newSeed -hex]
puts "Generated seed: $seed"
for {set index 0} {$index < 10} {incr index} {
set accountPrivateKey [::nano::key::fromSeed $seed $index -hex]
set accountAddress [::nano::address::fromPrivateKey $accountPrivateKey]
puts " - $index: $accountAddress"
}
AUTHOR
Roy Keene <rkeene@nano.org>17-Jul-2018 | nano 1.1 |