From 4fb4d0a454203639600e728dbdd88757b050d512 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Sun, 8 Dec 2019 10:20:17 -0500 Subject: [PATCH 01/11] [guides] refs #130 - Describe wallet contracts --- content/dev-docs/guides/v2.wallet.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 content/dev-docs/guides/v2.wallet.md diff --git a/content/dev-docs/guides/v2.wallet.md b/content/dev-docs/guides/v2.wallet.md new file mode 100644 index 0000000..23baf3c --- /dev/null +++ b/content/dev-docs/guides/v2.wallet.md @@ -0,0 +1,21 @@ ++++ +title = "FiberCrypto Wallets Guide v2" +weight = 4 ++++ + +### Introduction + +Wallets create public keys to receive coins and use the corresponding private keys to spend them. Wallet files are specific to altcoin plugin implementations. They store private keys and (optionally) other information related to transactions for a given wallet in particular. + +Wallet contracts are addressed below in separate subsections whereas supported wallet files are documented in individual altcoin plugin implementations. This document attempts to always make it clear whether we are talking about wallet contracts or wallet files. + +### Wallet Contracts + +Permitting receiving and spending of coins is the only essential feature of all wallet contracts. Nonetheless a particular wallet imstance does not need to do both things. Two wallet objects can work together, one distributing public keys in order to receive coins and another one signing transactions spending those coins. + +Wallet also need to interact with the peer-to-peer network to get information from the block chain and to broadcast new transactions. However, the objects which distribute public keys or sign transactions don’t need to interact with the peer-to-peer network themselves. Moreover it is possible for a wallet to have access to a local copy of the block chain, thus enabling offline operations. + +This leaves us with four necessary, but separable, parts of a wallet system: a public key distribution subsystem, a set of signing strategies, a blockchain aware visor, and a networked component. In the subsections below, we will describe specific contracts and possible relations between them. + +Note: We speak about distributing public keys generically. In many cases, hashes will be distributed instead of public keys, with the actual public keys only being distributed when the outputs they control are spent. + From 02bdfe1c4a6da148016a3a8299d6da5b8345557b Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Sun, 8 Dec 2019 11:31:47 -0500 Subject: [PATCH 02/11] [guides] refs #130 - Document generic wallet ops. Full wallet contract. --- content/dev-docs/guides/v2.wallet.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/content/dev-docs/guides/v2.wallet.md b/content/dev-docs/guides/v2.wallet.md index 23baf3c..853a513 100644 --- a/content/dev-docs/guides/v2.wallet.md +++ b/content/dev-docs/guides/v2.wallet.md @@ -17,5 +17,23 @@ Wallet also need to interact with the peer-to-peer network to get information fr This leaves us with four necessary, but separable, parts of a wallet system: a public key distribution subsystem, a set of signing strategies, a blockchain aware visor, and a networked component. In the subsections below, we will describe specific contracts and possible relations between them. +In most cases, wallet contracts are obliged to implement generic operations like setting and reading a human readable label. All wallets shall have an identifier. The wallet instance should facilitate a way to calculate balances of the addresses it owns or manages. + +To help protect against theft, the system offers users the option of encrypting the wallet files which contain the private keys. In order to provide support for multiple encryption strategies, this feature is betond wallet contract. + Note: We speak about distributing public keys generically. In many cases, hashes will be distributed instead of public keys, with the actual public keys only being distributed when the outputs they control are spent. +#### Peer-to-peer exchange + +Every altcoin plugin must provide a way to broadcast transactions for further confirmation by peers across the network. Abstract types are used to identify peers either by name or by network routing address identifier. This is a top-level plugin entry point that could usually be implemented by a singleton instance. Since this is a global service not bound to any particular address, generic wallet operartions are not part of this contract. + +#### Full-Service Wallets + +This kind of wallets perform three of the four main functions: it generates private keys, derives the corresponding public keys, helps distribute those public keys as necessary, monitors for outputs spent to those public keys, creates and signs transactions spending those outputs. It does not broadcast the signed transactions though. + +The main advantage of full-service wallets is that they are easy to implement. A single instance does everything the user needs to receive and spend coins. + +The main disadvantage of full-service wallets is that they store the private keys on a device connected to the Internet. The compromise of such devices is a common occurrence, and an Internet connection makes it easy to transmit private keys from a compromised device to an attacker. Encryption is not enough since that approach protects the private keys when they aren’t being used, but it cannot protect against an attack designed to capture the encryption key or to read the decrypted keys from memory. + + + From 5cf0bae13b12ca42492f82631374de083265b931 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Sun, 8 Dec 2019 11:48:20 -0500 Subject: [PATCH 03/11] [guides] refs #130 - Wallet encryption explained. Signing-only wallets documented --- content/dev-docs/guides/v2.wallet.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/content/dev-docs/guides/v2.wallet.md b/content/dev-docs/guides/v2.wallet.md index 853a513..ae6facf 100644 --- a/content/dev-docs/guides/v2.wallet.md +++ b/content/dev-docs/guides/v2.wallet.md @@ -17,7 +17,7 @@ Wallet also need to interact with the peer-to-peer network to get information fr This leaves us with four necessary, but separable, parts of a wallet system: a public key distribution subsystem, a set of signing strategies, a blockchain aware visor, and a networked component. In the subsections below, we will describe specific contracts and possible relations between them. -In most cases, wallet contracts are obliged to implement generic operations like setting and reading a human readable label. All wallets shall have an identifier. The wallet instance should facilitate a way to calculate balances of the addresses it owns or manages. +In most cases, wallet contracts are obliged to implement generic operations like setting and reading a human readable label. All wallets shall have an identifier. The wallet instance should facilitate a way to calculate balances of the addresses it owns or manages. `Wallet` interface defines this generic contract. To help protect against theft, the system offers users the option of encrypting the wallet files which contain the private keys. In order to provide support for multiple encryption strategies, this feature is betond wallet contract. @@ -29,11 +29,17 @@ Every altcoin plugin must provide a way to broadcast transactions for further co #### Full-Service Wallets -This kind of wallets perform three of the four main functions: it generates private keys, derives the corresponding public keys, helps distribute those public keys as necessary, monitors for outputs spent to those public keys, creates and signs transactions spending those outputs. It does not broadcast the signed transactions though. +This kind of wallets perform three of the four main functions: it generates private keys, derives the corresponding public keys, helps distribute those public keys as necessary, monitors for outputs spent to those public keys, creates and signs transactions spending those outputs. It does not broadcast the signed transactions though. Full-service wallets shall implement `FullWallet` interface contract. The main advantage of full-service wallets is that they are easy to implement. A single instance does everything the user needs to receive and spend coins. The main disadvantage of full-service wallets is that they store the private keys on a device connected to the Internet. The compromise of such devices is a common occurrence, and an Internet connection makes it easy to transmit private keys from a compromised device to an attacker. Encryption is not enough since that approach protects the private keys when they aren’t being used, but it cannot protect against an attack designed to capture the encryption key or to read the decrypted keys from memory. +#### Signing-Only Wallets + +To increase security, private keys can be generated and stored by a separate wallet strategy operating in a more secure environment. These signing-only wallets work in conjunction with the PEX subsystem which interacts with the peer-to-peer network. `TxnSigner` establishes the contract these wallets shall satisfy. + +Signing-only wallets programs typically use deterministic key creation (described in a later subsection) to create parent private and public keys which can create child private and public keys. At first, the signing-only wallet creates a parent private key and transfers the corresponding parent public key to the networked wallet. The later does the rest. Often, users are given a chance to review the unsigned transactions’ details (particularly the output details) using the signing-only wallet. After the optional review step, the signing-only wallet uses the parent private key to derive the appropriate child private keys and signs the transactions, giving the signed transactions back to the PEX for subsequent broadcast. + From c1ac237d3071c34ac337e092360d2c05625ab713 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Sun, 8 Dec 2019 12:01:02 -0500 Subject: [PATCH 04/11] [guides] refs #130 - Document hardware wallet contract --- content/dev-docs/guides/v2.wallet.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/content/dev-docs/guides/v2.wallet.md b/content/dev-docs/guides/v2.wallet.md index ae6facf..e9e0ba6 100644 --- a/content/dev-docs/guides/v2.wallet.md +++ b/content/dev-docs/guides/v2.wallet.md @@ -41,5 +41,18 @@ To increase security, private keys can be generated and stored by a separate wal Signing-only wallets programs typically use deterministic key creation (described in a later subsection) to create parent private and public keys which can create child private and public keys. At first, the signing-only wallet creates a parent private key and transfers the corresponding parent public key to the networked wallet. The later does the rest. Often, users are given a chance to review the unsigned transactions’ details (particularly the output details) using the signing-only wallet. After the optional review step, the signing-only wallet uses the parent private key to derive the appropriate child private keys and signs the transactions, giving the signed transactions back to the PEX for subsequent broadcast. +##### Hardware Wallets +Hardware wallets are devices dedicated to running a signing-only wallet. Their dedication lets them eliminate many of the vulnerabilities present in operating systems designed for general use, allowing them to safely communicate directly with other devices so users don’t need to transfer data manually. + +The user’s workflow is defined by `HardwareWallet` contract and looks something like: + +1. (Hardware) Create parent private and public keys. Connect hardware wallet to a networked device so it can get the parent public key. +2. (Networked) As you would with a full-service wallet, distribute public keys to receive payment. When ready to spend coins, fill in the transaction details, connect the hardware wallet, and start spending workflow. The networked wallet will automatically send the transaction details to the hardware wallet. +3. (Hardware) Review the transaction details on the hardware wallet’s screen. Some hardware wallets may prompt for a passphrase or PIN number. The hardware wallet signs the transaction and uploads it to the networked wallet. +4. (Networked) The networked wallet receives the signed transaction from the hardware wallet and broadcasts it to the network. + +The primary advantage of hardware wallets is their possibility for greatly improved security over full-service wallets with much less hassle than offline wallets. + +The primary disadvantage of hardware wallets is their hassle. Even though the hassle is less than that of offline wallets, the user must still purchase a hardware wallet device and carry it with them whenever they need to make a transaction using the signing-only wallet. From 9a3994c4a27a7a3ac112dd9c7f6f381a95730d48 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Sun, 8 Dec 2019 12:22:41 -0500 Subject: [PATCH 05/11] [guides] refs #130 - Document wallet contract to distribute wallets --- content/dev-docs/guides/v2.wallet.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/content/dev-docs/guides/v2.wallet.md b/content/dev-docs/guides/v2.wallet.md index e9e0ba6..1315c10 100644 --- a/content/dev-docs/guides/v2.wallet.md +++ b/content/dev-docs/guides/v2.wallet.md @@ -56,3 +56,16 @@ The primary advantage of hardware wallets is their possibility for greatly impro The primary disadvantage of hardware wallets is their hassle. Even though the hassle is less than that of offline wallets, the user must still purchase a hardware wallet device and carry it with them whenever they need to make a transaction using the signing-only wallet. +#### Distributing-Only Wallets + +Wallet programs which run in difficult-to-secure environments, such as webservers, can be designed to distribute public keys and nothing more. `DistWallet` contract standardizes operations needed in this case. + +There are two common ways to design these minimalist wallets: + +Distributing-Only Wallets + +- `CollectionWallet` contract encloses the instances that pre-populate a database with a number of public keys or addresses, and then distribute on request a pubkey script or address using one of the database entries. To avoid key reuse, webservers should keep track of used keys and never run out of public keys. This can be made easier by using parent public keys as suggested in the next method. + +- `HDistWallet` contract standardizes wallets which use a parent public key to create child public keys. To avoid key reuse, a method must be used to ensure the same public key isn’t distributed twice. This can be a database entry for each key distributed or an incrementing pointer to the key index number. + +Neither method adds a significant amount of overhead, especially if a database is used anyway to associate each incoming payment with a separate public key for payment tracking. From 1b285248e794c5f9a75e61b2eae16f3880a0b42b Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Sun, 8 Dec 2019 12:50:42 -0500 Subject: [PATCH 06/11] [uml] refs #130 - PlantUML diagrams for API v1 --- .../diagrams/plantuml/bitcoin.spv.bloom.uml | 10 + content/diagrams/plantuml/core.v1.simple.uml | 179 +++++++++++ content/diagrams/plantuml/core.v1.uml | 278 ++++++++++++++++++ content/diagrams/plantuml/lib.genswig.uml | 80 +++++ 4 files changed, 547 insertions(+) create mode 100644 content/diagrams/plantuml/bitcoin.spv.bloom.uml create mode 100644 content/diagrams/plantuml/core.v1.simple.uml create mode 100644 content/diagrams/plantuml/core.v1.uml create mode 100644 content/diagrams/plantuml/lib.genswig.uml diff --git a/content/diagrams/plantuml/bitcoin.spv.bloom.uml b/content/diagrams/plantuml/bitcoin.spv.bloom.uml new file mode 100644 index 0000000..0f185e4 --- /dev/null +++ b/content/diagrams/plantuml/bitcoin.spv.bloom.uml @@ -0,0 +1,10 @@ +@startuml + +participant "FiberCrypto Bitcoin SPV" as wallet +participant "Bitcoin node" as btcnode +wallet -> btcnode : filterload(nFlags=BLOOM_UPDATE_ALL, ...) +wallet -> btcnode : get(inventory_type=MSG_MERKLEBLOCK, ...) +wallet <-- btcnode : merkleblock(TXID1, TXID2, ...) +wallet -> wallet : validate_merkleblock + +@enduml diff --git a/content/diagrams/plantuml/core.v1.simple.uml b/content/diagrams/plantuml/core.v1.simple.uml new file mode 100644 index 0000000..54adb8a --- /dev/null +++ b/content/diagrams/plantuml/core.v1.simple.uml @@ -0,0 +1,179 @@ + +@startuml +skinparam ClassBorderColor<< CryptoCurrencyToken >> Black +skinparam ClassBackgroundColor<< CryptoCurrencyToken >> White + + +interface CryptoAccount +interface Address +interface Iterator +interface AddressIterator +interface TxnSigner +interface TxnSignerIterator +class Timestamp <> +enum TransactionStatus +interface Transaction +interface TransactionIterator +interface TransactionInput +interface TransactionInputIterator +interface TransactionOutput +interface TransactionOutputIterator +interface Block +interface AltcoinPlugin +interface AltcoinManager +enum CoinValueMetric +interface BlockchainStatus +interface PEX +interface PexNodeIterator +interface PexNodeSet +interface PexNode +interface KeyValueStorage +interface WalletSet +interface WalletStorage +interface WalletIterator +enum AddressType +interface Wallet +interface SeedGenerator +interface WalletEnv + +TxnSignerIterator --|> Iterator : bind +AddressIterator --|> Iterator : bind +TransactionInputIterator --|> Iterator : bind +TransactionOutputIterator --|> Iterator : bind +TransactionIterator --|> Iterator : bind +PexNodeIterator --|> Iterator : bind +WalletIterator --|> Iterator : bind + +class AltcoinMetadata { + Name string + Ticker string + Family string + HasBip44 bool + Bip44CoinType int32 + Accuracy int32 +} + +CryptoAccount : GetBalance(ticker string) (uint64, error) +CryptoAccount : ListAssets() []string +CryptoAccount : ScanUnspentOutputs() TransactionOutputIterator +CryptoAccount : ListTransactions() TransactionIterator +CryptoAccount : ListPendingTransactions() (TransactionIterator, error) + +CryptoAccount --> TransactionOutputIterator +CryptoAccount --> TransactionIterator + +Address --> CryptoAccount + +TxnSigner --> Transaction : sign +TxnSigner ..> PasswordReader + +Iterator : Value() ItemType +Iterator : Next() bool +Iterator : HasNext() bool +Iterator : Count() int + +Transaction : SupportedAssets() []string +Transaction : GetTimestamp() Timestamp +Transaction : GetStatus() TransactionStatus +Transaction : GetInputs() []TransactionInput +Transaction : GetOutputs() []TransactionOutput +Transaction : GetId() string +Transaction : ComputeFee(ticker string) (uint64, error) +Transaction : VerifyUnsigned() error +Transaction : VerifySigned() error +Transaction : IsFullySigned() (bool, error) + +Transaction --> Timestamp +Transaction --> TransactionStatus +Transaction "1" *--> "*" TransactionInput +Transaction "1" *--> "*" TransactionOutput + +TransactionInput --> TransactionOutput : spend + +TransactionOutput "*" --> "1" Address : fund + +Block "*" *--> Transaction +Block --> Timestamp +Block --> TransactionIterator + +AltcoinPlugin : ListSupportedAltcoins() []AltcoinMetadata +AltcoinPlugin : ListSupportedFamilies() []string +AltcoinPlugin : RegisterTo(manager AltcoinManager) +AltcoinPlugin : GetName() string +AltcoinPlugin : GetDescription() string +AltcoinPlugin : LoadWalletEnvs() []WalletEnv +AltcoinPlugin : LoadPEX(netType string) (PEX, error) + +class CryptoCurrencyToken + +AltcoinPlugin "1" -- "*" CryptoCurrencyToken : implements +AltcoinManager "registry" <-- "plugin" AltcoinPlugin : registration +AltcoinPlugin "1" --> "*" WalletEnv +AltcoinPlugin --> PEX + +(AltcoinPlugin, CryptoCurrencyToken) .. AltcoinMetadata + +AltcoinManager : RegisterPlugin(p AltcoinPlugin) +AltcoinManager : RegisterAltcoin(info AltcoinMetadata, plugin AltcoinPlugin) +AltcoinManager : ListRegisteredPlugins() []AltcoinPlugin +AltcoinManager : LookupAltcoinPlugin(ticker string) (AltcoinPlugin, bool) +AltcoinManager : DescribeAltcoin(ticker string) (AltcoinMetadata, bool) + +AltcoinManager "1" o--> "*" AltcoinPlugin +AltcoinManager "cache" --> "record" AltcoinMetadata + +BlockchainStatus --> Block +BlockchainStatus ..> CoinValueMetric + +PEX --> TransactionIterator +PEX --> PexNodeSet +PEX ..> Transaction : P2P broadcast + +PexNodeSet --> PexNodeIterator +PexNodeSet "*" o--> "*" PexNode + +WalletSet --> WalletIterator +WalletSet o--> Wallet +WalletSet ..> PasswordReader + +WalletStorage : Encrypt(walletName string, password PasswordReader) +WalletStorage : Decrypt(walletName string, password PasswordReader) +WalletStorage : IsEncrypted(walletName string) (bool, error) + +WalletStorage ..> PasswordReader + +Wallet : GetId() string +Wallet : GetLabel() string +Wallet : SetLabel(wltName string) +Wallet : Transfer(to TransactionOutput, options KeyValueStorage) (Transaction, error) +Wallet : SendFromAddress(from []Address, to []TransactionOutput, change Address, options KeyValueStorage) (Transaction, error) +Wallet : Spend(unspent, new []TransactionOutput, change Address, options KeyValueStorage) (Transaction, error) +Wallet : GenAddresses(addrType AddressType, startIndex, count uint32, pwd PasswordReader) AddressIterator +Wallet : GetCryptoAccount() CryptoAccount +Wallet : GetLoadedAddresses() (AddressIterator, error) +Wallet : Sign(txn Transaction, source UID, pwd PasswordReader, index []string) (Transaction, error) +Wallet : AttachSignService(TxnSigner) error +Wallet : RemoveSignService(TxnSigner) error +Wallet : EnumerateSignServices() TxnSignerIterator + +Wallet ..> PasswordReader +Wallet ..> KeyValueStorage +Wallet ..> TransactionOutput +Wallet --> Transaction : create +Wallet --> Transaction : sign +Wallet "1" ..> "*" TxnSigner +Wallet ..> Address +Wallet ..> AddressType +Wallet --> AddressIterator +Wallet --> TxnSignerIterator + +Wallet ..> SeedGenerator + +WalletEnv : GetStorage() WalletStorage +WalletEnv : GetWalletSet() WalletSet + +WalletEnv "1" o--> "1" WalletStorage +WalletEnv "1" o--> "1" WalletSet + +@enduml + diff --git a/content/diagrams/plantuml/core.v1.uml b/content/diagrams/plantuml/core.v1.uml new file mode 100644 index 0000000..dbf015b --- /dev/null +++ b/content/diagrams/plantuml/core.v1.uml @@ -0,0 +1,278 @@ + +@startuml +skinparam ClassBorderColor<< CryptoCurrencyToken >> Black +skinparam ClassBackgroundColor<< CryptoCurrencyToken >> White + + +interface CryptoAccount +interface Address +interface Iterator +interface AddressIterator +interface TxnSigner +interface TxnSignerIterator +class Timestamp <> +enum TransactionStatus +interface Transaction +interface TransactionIterator +interface TransactionInput +interface TransactionInputIterator +interface TransactionOutput +interface TransactionOutputIterator +interface Block +interface AltcoinPlugin +interface AltcoinManager +enum CoinValueMetric +interface BlockchainStatus +interface PEX +interface PexNodeIterator +interface PexNodeSet +interface PexNode +interface KeyValueStorage +interface WalletSet +interface WalletStorage +interface WalletIterator +enum AddressType +interface Wallet +interface SeedGenerator +interface WalletEnv +interface BlockchainTransactionAPI +interface BlockchainSignService +interface WalletOutput +interface WalletAddress + +TxnSignerIterator --|> Iterator : bind +AddressIterator --|> Iterator : bind +TransactionInputIterator --|> Iterator : bind +TransactionOutputIterator --|> Iterator : bind +TransactionIterator --|> Iterator : bind +PexNodeIterator --|> Iterator : bind +WalletIterator --|> Iterator : bind + +class AltcoinMetadata { + Name string + Ticker string + Family string + HasBip44 bool + Bip44CoinType int32 + Accuracy int32 +} + +class InputSignDescriptor { + InputIndex string + SignerID UID + Wallet Wallet +} + +CryptoAccount : GetBalance(ticker string) (uint64, error) +CryptoAccount : ListAssets() []string +CryptoAccount : ScanUnspentOutputs() TransactionOutputIterator +CryptoAccount : ListTransactions() TransactionIterator +CryptoAccount : ListPendingTransactions() (TransactionIterator, error) + +CryptoAccount --> TransactionOutputIterator +CryptoAccount --> TransactionIterator + +Address : IsBip32() bool +Address : String() string +Address : GetCryptoAccount() CryptoAccount + +Address --> CryptoAccount + +TxnSigner : SignTransaction(Transaction, PasswordReader, []string) (Transaction, error) +TxnSigner : GetSignerUID() UID +TxnSigner : GetSignerDescription() string + +TxnSigner --> Transaction : sign +TxnSigner ..> PasswordReader + +Iterator : Value() ItemType +Iterator : Next() bool +Iterator : HasNext() bool +Iterator : Count() int + +Transaction : SupportedAssets() []string +Transaction : GetTimestamp() Timestamp +Transaction : GetStatus() TransactionStatus +Transaction : GetInputs() []TransactionInput +Transaction : GetOutputs() []TransactionOutput +Transaction : GetId() string +Transaction : ComputeFee(ticker string) (uint64, error) +Transaction : VerifyUnsigned() error +Transaction : VerifySigned() error +Transaction : IsFullySigned() (bool, error) + +Transaction --> Timestamp +Transaction --> TransactionStatus +Transaction "1" *--> "*" TransactionInput +Transaction "1" *--> "*" TransactionOutput + +TransactionInput : GetId() string +TransactionInput : GetSpentOutput() TransactionOutput +TransactionInput : GetCoins(ticker string) (uint64, error) +TransactionInput : SupportedAssets() []string + +TransactionInput --> TransactionOutput : spend + +TransactionOutput : GetId() string +TransactionOutput : IsSpent() bool +TransactionOutput : GetAddress() Address +TransactionOutput : GetCoins(ticker string) (uint64, error) +TransactionOutput : SupportedAssets() []string + +TransactionOutput "*" --> "1" Address : fund + +Block : GetHash() ([]byte, error) +Block : GetPrevHash() ([]byte, error) +Block : GetVersion() (uint32, error) +Block : GetTime() (Timestamp, error) +Block : GetHeight() (uint64, error) +Block : GetFee(ticker string) (uint64, error) +Block : IsGenesisBlock() (bool, error) +Block : GetTransactions() (TransactionIterator, error) + +Block "*" *--> Transaction +Block --> Timestamp +Block --> TransactionIterator + +AltcoinPlugin : ListSupportedAltcoins() []AltcoinMetadata +AltcoinPlugin : ListSupportedFamilies() []string +AltcoinPlugin : RegisterTo(manager AltcoinManager) +AltcoinPlugin : GetName() string +AltcoinPlugin : GetDescription() string +AltcoinPlugin : LoadWalletEnvs() []WalletEnv +AltcoinPlugin : LoadPEX(netType string) (PEX, error) +AltcoinPlugin : LoadTransactionAPI(netType string) (BlockchainTransactionAPI, error) +AltcoinPlugin : LoadSignService() (BlockchainSignService, error) + +class CryptoCurrencyToken + +AltcoinPlugin "1" -- "*" CryptoCurrencyToken : implements +AltcoinManager "registry" <-- "plugin" AltcoinPlugin : registration +AltcoinPlugin "1" --> "*" WalletEnv +AltcoinPlugin --> PEX +AltcoinPlugin --> BlockchainTransactionAPI +AltcoinPlugin --> BlockchainSignService + +(AltcoinPlugin, CryptoCurrencyToken) .. AltcoinMetadata + +AltcoinManager : RegisterPlugin(p AltcoinPlugin) +AltcoinManager : RegisterAltcoin(info AltcoinMetadata, plugin AltcoinPlugin) +AltcoinManager : ListRegisteredPlugins() []AltcoinPlugin +AltcoinManager : LookupAltcoinPlugin(ticker string) (AltcoinPlugin, bool) +AltcoinManager : DescribeAltcoin(ticker string) (AltcoinMetadata, bool) + +AltcoinManager "1" o--> "*" AltcoinPlugin +AltcoinManager "cache" --> "record" AltcoinMetadata + +BlockchainStatus : GetCoinValue(coinvalue CoinValueMetric, ticker string) (uint64, error) +BlockchainStatus : GetLastBlock() (Block, error) +BlockchainStatus : GetNumberOfBlocks() (uint64, error) + +BlockchainStatus --> Block +BlockchainStatus ..> CoinValueMetric + +PEX : GetTxnPool() (TransactionIterator, error) +PEX : GetConnections() (PexNodeSet, error) +PEX : BroadcastTxn(txn Transaction) error + +PEX --> TransactionIterator +PEX --> PexNodeSet +PEX ..> Transaction : P2P broadcast + +PexNodeSet : ListPeers() PexNodeIterator + +PexNodeSet --> PexNodeIterator +PexNodeSet "*" o--> "*" PexNode + +PexNode : GetIp() string +PexNode : GetPort() uint16 +PexNode : GetBlockHeight() uint64 +PexNode : IsTrusted() bool +PexNode : GetLastSeenIn() int64 +PexNode : GetLastSeenOut() int64 + +KeyValueStorage : GetValue(key string) interface{} +KeyValueStorage : SetValue(key string, value interface{}) + +WalletSet : ListWallets() WalletIterator +WalletSet : GetWallet(id string) Wallet +WalletSet : CreateWallet(name string, seed string, isEncryptrd bool, pwd PasswordReader, scanAddressesN int) (Wallet, error) + +WalletSet --> WalletIterator +WalletSet o--> Wallet +WalletSet ..> PasswordReader + +WalletStorage : Encrypt(walletName string, password PasswordReader) +WalletStorage : Decrypt(walletName string, password PasswordReader) +WalletStorage : IsEncrypted(walletName string) (bool, error) + +WalletStorage ..> PasswordReader + +Wallet : GetId() string +Wallet : GetLabel() string +Wallet : SetLabel(wltName string) +Wallet : Transfer(to TransactionOutput, options KeyValueStorage) (Transaction, error) +Wallet : SendFromAddress(from []Address, to []TransactionOutput, change Address, options KeyValueStorage) (Transaction, error) +Wallet : Spend(unspent, new []TransactionOutput, change Address, options KeyValueStorage) (Transaction, error) +Wallet : GenAddresses(addrType AddressType, startIndex, count uint32, pwd PasswordReader) AddressIterator +Wallet : GetCryptoAccount() CryptoAccount +Wallet : GetLoadedAddresses() (AddressIterator, error) +Wallet : Sign(txn Transaction, source UID, pwd PasswordReader, index []string) (Transaction, error) +Wallet : AttachSignService(TxnSigner) error +Wallet : RemoveSignService(TxnSigner) error +Wallet : EnumerateSignServices() TxnSignerIterator + +Wallet ..> PasswordReader +Wallet ..> KeyValueStorage +Wallet ..> TransactionOutput +Wallet --> Transaction : create +Wallet --> Transaction : sign +Wallet "1" ..> "*" TxnSigner +Wallet ..> Address +Wallet ..> AddressType +Wallet --> AddressIterator +Wallet --> TxnSignerIterator +Wallet --> CryptoAccount + +SeedGenerator : GenerateMnemonic(wordCount int) (string, error) +SeedGenerator : VerifyMnemonic(seed string) (bool, error) + +Wallet ..> SeedGenerator + +WalletEnv : GetStorage() WalletStorage +WalletEnv : GetWalletSet() WalletSet + +WalletEnv "1" o--> "1" WalletStorage +WalletEnv "1" o--> "1" WalletSet + +BlockchainTransactionAPI : SendFromAddress(from []WalletAddress, to []TransactionOutput, change Address, options KeyValueStorage) (Transaction, error) +BlockchainTransactionAPI : Spend(unspent []WalletOutput, new []TransactionOutput, change Address, options KeyValueStorage) (Transaction, error) + +BlockchainTransactionAPI ..> WalletAddress +BlockchainTransactionAPI ..> TransactionOutput +BlockchainTransactionAPI ..> WalletOutput +BlockchainTransactionAPI ..> Address +BlockchainTransactionAPI ..> KeyValueStorage +BlockchainTransactionAPI --> Transaction + +BlockchainSignService : Sign(txn Transaction, signSpec []InputSignDescriptor, pwd PasswordReader) (Transaction, error) + +BlockchainSignService ..> Transaction +BlockchainSignService ..> InputSignDescriptor +BlockchainSignService ..> PasswordReader +BlockchainSignService --> Transaction + +WalletOutput : GetWallet() Wallet +WalletOutput : GetOutput() TransactionOutput + +WalletOutput o--> Wallet +WalletOutput o--> TransactionOutput + +WalletAddress : GetWallet() Wallet +WalletAddress : GetAddress() Address + +WalletAddress o--> Wallet +WalletAddress o--> Address + +@enduml + diff --git a/content/diagrams/plantuml/lib.genswig.uml b/content/diagrams/plantuml/lib.genswig.uml new file mode 100644 index 0000000..7171af1 --- /dev/null +++ b/content/diagrams/plantuml/lib.genswig.uml @@ -0,0 +1,80 @@ + +@startuml +package fibercrypto { + +package fibercrypto.util <> { +} + +package fibercrypto.main <> { +} + +package fibercrypto.core <> { +interface AltcoinPlugin +interface AltcoinManager + +} + +package fibercrypto.coin <> { +class SkycoinPlugin +class BitcoinPlugin +class EthereumPlugin +} + +} + +note bottom : All other interfaces omitted + +package FiberCryptoPy <> { +} + +package FiberCryptoForLanguageX <> { +} + +package cgo <> { +} + +package cgogen <> { +} + +package swig <> { +} + +package fibercyptoc { + +package libfibercrypto.wrappers <> { +} + +package fibercryptoh <> { +} + +package libfibercrypto <> { +} + +} + +fibercyptoc -[hidden]-- fibercrypto +cgo -[hidden]-- swig +cgo -[hidden]-- cgogen +FiberCryptoForLanguageX -[hidden]-- FiberCryptoPy + +fibercrypto.coin +-- fibercrypto.core +fibercrypto.util +-- fibercrypto.core +fibercrypto.coin +-- fibercrypto.util + +SkycoinPlugin --|> AltcoinPlugin +BitcoinPlugin --|> AltcoinPlugin +EthereumPlugin --|> AltcoinPlugin + +cgogen -> libfibercrypto.wrappers +cgogen <- fibercrypto.util +cgogen <- fibercrypto.main +cgogen <- fibercrypto.core +libfibercrypto.wrappers -> cgo +cgo -> libfibercrypto +cgo -> fibercryptoh +libfibercrypto +-- fibercryptoh +fibercryptoh --> swig +swig -> FiberCryptoPy +swig -> FiberCryptoForLanguageX +@enduml + From b2d3391224e0df407af4b6b7e27ac22f350bb4a0 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Sun, 8 Dec 2019 15:17:12 -0500 Subject: [PATCH 07/11] [guides] refs #130 - Documentation for blockchain wallets --- content/dev-docs/guides/v2.wallet.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/content/dev-docs/guides/v2.wallet.md b/content/dev-docs/guides/v2.wallet.md index 1315c10..3635932 100644 --- a/content/dev-docs/guides/v2.wallet.md +++ b/content/dev-docs/guides/v2.wallet.md @@ -66,6 +66,11 @@ Distributing-Only Wallets - `CollectionWallet` contract encloses the instances that pre-populate a database with a number of public keys or addresses, and then distribute on request a pubkey script or address using one of the database entries. To avoid key reuse, webservers should keep track of used keys and never run out of public keys. This can be made easier by using parent public keys as suggested in the next method. -- `HDistWallet` contract standardizes wallets which use a parent public key to create child public keys. To avoid key reuse, a method must be used to ensure the same public key isn’t distributed twice. This can be a database entry for each key distributed or an incrementing pointer to the key index number. +- `HDAddressGenerator` contract standardizes wallets which use a parent public key to create child public keys. To avoid key reuse, a method must be used to ensure the same public key isn’t distributed twice. This can be a database entry for each key distributed or an incrementing pointer to the key index number. Neither method adds a significant amount of overhead, especially if a database is used anyway to associate each incoming payment with a separate public key for payment tracking. + +#### Transactions and blockchain operations + +MAny operations essential to crypto systems rely on transactions. It is necessary to have wallets able to scan the block chain to identify unspent outputs, and use such information to assemble unsigned transactions, calculate account balance, and observe incoming and outcoming transactions, among other things. Such wallets may be bound to one , a set, or an infinite sequence of addresses. They can even be instantiated for the blockchain as a whole. All instances must comply to the `BlockchainTransactionAPI` contract. + From 98c5857408e2c7b025ab0b808471620d3751315d Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Sun, 8 Dec 2019 23:09:29 -0500 Subject: [PATCH 08/11] [uml] refs #130 - Wallet classes in API v2 --- content/diagrams/plantuml/core.v2.simple.uml | 189 +++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 content/diagrams/plantuml/core.v2.simple.uml diff --git a/content/diagrams/plantuml/core.v2.simple.uml b/content/diagrams/plantuml/core.v2.simple.uml new file mode 100644 index 0000000..b062744 --- /dev/null +++ b/content/diagrams/plantuml/core.v2.simple.uml @@ -0,0 +1,189 @@ + +@startuml +skinparam ClassBorderColor<< CryptoCurrencyToken >> Black +skinparam ClassBackgroundColor<< CryptoCurrencyToken >> White + + +interface CryptoAccount +interface Address +interface Iterator +interface FiniteIterator +interface AddressIterator +interface TxnSigner +interface TxnSignerIterator +class Timestamp <> +enum TransactionStatus +interface Transaction +interface TransactionIterator +interface TransactionInput +interface TransactionInputIterator +interface TransactionOutput +interface TransactionOutputIterator +interface Block +interface AltcoinPlugin +interface AltcoinManager +enum CoinValueMetric +interface BlockchainStatus +interface PEX +interface PexNodeIterator +interface PexNodeSet +interface PexNode +interface KeyValueStorage +interface WalletSet +interface WalletStorage +interface WalletIterator +enum AddressType +interface Wallet +interface DistWallet +interface HDAddressGenerator +interface HardwareWallet +interface CollectionWallet +interface BlockchainWallet +interface FullWallet +interface SeedGenerator +interface WalletEnv +interface BlockchainTransactionAPI +interface BlockchainSignService +interface WalletOutput +interface WalletAddress + +TxnSignerIterator --|> FiniteIterator : bind +AddressIterator --|> Iterator : bind +TransactionInputIterator --|> Iterator : bind +TransactionOutputIterator --|> Iterator : bind +TransactionIterator --|> Iterator : bind +PexNodeIterator --|> Iterator : bind +WalletIterator --|> Iterator : bind + +class AltcoinMetadata { + Name string + Ticker string + Family string + HasBip44 bool + Bip44CoinType int32 + Accuracy int32 +} + +class InputSignDescriptor { + InputIndex string + SignerID UID + Wallet Wallet +} + +CryptoAccount --> TransactionOutputIterator +CryptoAccount --> TransactionIterator + +Address --> CryptoAccount +Wallet --> CryptoAccount + +TxnSigner --> Transaction : sign +TxnSigner ..> PasswordReader + +Iterator : Value() ItemType +Iterator : Next() bool +Iterator : HasNext() bool + +FiniteIterator : Count() int + +Iterator <|- FiniteIterator + +Transaction --> Timestamp +Transaction --> TransactionStatus +Transaction "1" *--> "*" TransactionInput +Transaction "1" *--> "*" TransactionOutput + +TransactionInput "1" --> "1" TransactionOutput : spend + +TransactionOutput "*" --> "1" Address : fund + +Block "*" *--> Transaction +Block --> Timestamp +Block --> TransactionIterator + +class CryptoCurrencyToken + +AltcoinPlugin "1" - "*" CryptoCurrencyToken : implements +AltcoinManager "registry" <-- "plugin" AltcoinPlugin : registration +AltcoinPlugin "1" --> "*" WalletEnv +AltcoinPlugin --> PEX + +(AltcoinPlugin, CryptoCurrencyToken) .. AltcoinMetadata + +AltcoinManager "1" o--> "*" AltcoinPlugin +AltcoinManager "cache" --> "record" AltcoinMetadata + +BlockchainStatus --> Block +BlockchainStatus ..> CoinValueMetric + +PEX --> TransactionIterator +PEX --> PexNodeSet +PEX ..> Transaction : P2P broadcast + +PexNodeSet --> PexNodeIterator +PexNodeSet "*" o--> "*" PexNode + +WalletSet --> WalletIterator +WalletSet o--> Wallet +WalletSet ..> PasswordReader + +WalletStorage ..> PasswordReader + +AltcoinPlugin --> BlockchainTransactionAPI +AltcoinPlugin --> BlockchainSignService + +FullWallet -|> Wallet +FullWallet --|> HDAddressGenerator +FullWallet --|> TxnSigner +FullWallet --|> BlockchainWallet +HardwareWallet --|> TxnSigner +HardwareWallet --|> HDAddressGenerator +Wallet <|-- DistWallet +Wallet <|-- CollectionWallet +Wallet <|-- HDAddressGenerator +Wallet <|-- TxnSigner +Wallet <|-- BlockchainWallet +DistWallet <|-- CollectionWallet +DistWallet <|-- HDAddressGenerator + +CollectionWallet "1" o--> "*" Address +HDAddressGenerator "1" *--> "∞" Address + +TxnSigner ..> PasswordReader +BlockchainWallet ..> KeyValueStorage +BlockchainWallet ..> TransactionOutput +BlockchainWallet --> Transaction : create +AlcoinManager "1" ..> "*" TxnSigner +DistWallet ..> Address +DistWallet --> AddressIterator +CollectionWallet ..> Address +HDAddressGenerator ..> AddressType +HDAddressGenerator --> AddressIterator + +AltcoinManager --> TxnSignerIterator + +WalletEnv "1" o--> "1" WalletStorage +WalletEnv "1" o--> "1" WalletSet +WalletSet ..> SeedGenerator + +BlockchainTransactionAPI ..> WalletAddress +BlockchainTransactionAPI ..> TransactionOutput +BlockchainTransactionAPI ..> WalletOutput +BlockchainTransactionAPI ..> Address +BlockchainTransactionAPI ..> KeyValueStorage +BlockchainTransactionAPI --> Transaction + +BlockchainSignService ..> Transaction +BlockchainSignService ..> InputSignDescriptor +BlockchainSignService ..> PasswordReader +BlockchainSignService --> Transaction + +WalletOutput o--> Wallet +WalletOutput o--> TransactionOutput + +WalletEnv "1" o--> "1" WalletStorage +WalletEnv "1" o--> "1" WalletSet + +WalletAddress o--> Wallet +WalletAddress o--> Address +@enduml + From dee16242286e1ea5282adaa369b581bcf3a6bcc5 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Mon, 9 Dec 2019 01:05:18 -0500 Subject: [PATCH 09/11] [uml] refs #130 - Fix typos in v1 core class diagram --- content/diagrams/plantuml/core.v2.simple.uml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/diagrams/plantuml/core.v2.simple.uml b/content/diagrams/plantuml/core.v2.simple.uml index b062744..3934b13 100644 --- a/content/diagrams/plantuml/core.v2.simple.uml +++ b/content/diagrams/plantuml/core.v2.simple.uml @@ -152,7 +152,7 @@ TxnSigner ..> PasswordReader BlockchainWallet ..> KeyValueStorage BlockchainWallet ..> TransactionOutput BlockchainWallet --> Transaction : create -AlcoinManager "1" ..> "*" TxnSigner +AltcoinManager "1" ..> "*" TxnSigner DistWallet ..> Address DistWallet --> AddressIterator CollectionWallet ..> Address From d6c0d3bbb4252b776ba835ba2d79b338bd9ded10 Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Mon, 9 Dec 2019 01:07:06 -0500 Subject: [PATCH 10/11] [uml] refs #130 - UML class diagrams for API v2 with detailed methods --- content/diagrams/plantuml/core.v2.uml | 313 ++++++++++++++++++++++++++ 1 file changed, 313 insertions(+) create mode 100644 content/diagrams/plantuml/core.v2.uml diff --git a/content/diagrams/plantuml/core.v2.uml b/content/diagrams/plantuml/core.v2.uml new file mode 100644 index 0000000..55cd3cb --- /dev/null +++ b/content/diagrams/plantuml/core.v2.uml @@ -0,0 +1,313 @@ + +@startuml +skinparam ClassBorderColor<< CryptoCurrencyToken >> Black +skinparam ClassBackgroundColor<< CryptoCurrencyToken >> White + + + +interface CryptoAccount +interface Address +interface Iterator +interface FiniteIterator +interface AddressIterator +interface TxnSigner +interface TxnSignerIterator +class Timestamp <> +enum TransactionStatus +interface Transaction +interface TransactionIterator +interface TransactionInput +interface TransactionInputIterator +interface TransactionOutput +interface TransactionOutputIterator +interface Block +interface AltcoinPlugin +interface AltcoinManager +enum CoinValueMetric +interface BlockchainStatus +interface PEX +interface PexNodeIterator +interface PexNodeSet +interface PexNode +interface KeyValueStorage +interface WalletSet +interface WalletStorage +interface WalletIterator +enum AddressType +interface Wallet +interface DistWallet +interface HDAddressGenerator +interface HardwareWallet +interface CollectionWallet +interface BlockchainWallet +interface FullWallet +interface SeedGenerator +interface WalletEnv +interface BlockchainTransactionAPI +interface BlockchainSignService +interface WalletOutput +interface WalletAddress + +TxnSignerIterator --|> FiniteIterator : bind +AddressIterator --|> Iterator : bind +TransactionInputIterator --|> Iterator : bind +TransactionOutputIterator --|> Iterator : bind +TransactionIterator --|> Iterator : bind +PexNodeIterator --|> Iterator : bind +WalletIterator --|> Iterator : bind + +class AltcoinMetadata { + Name string + Ticker string + Family string + HasBip44 bool + Bip44CoinType int32 + Accuracy int32 +} + +class InputSignDescriptor { + InputIndex string + SignerID UID + Wallet Wallet +} + +CryptoAccount --> TransactionOutputIterator +CryptoAccount --> TransactionIterator + +Address --> CryptoAccount +Wallet --> CryptoAccount + +TxnSigner --> Transaction : sign +TxnSigner ..> PasswordReader + +Iterator : Value() ItemType +Iterator : Next() bool +Iterator : HasNext() bool + +FiniteIterator : Count() int + +Iterator <|- FiniteIterator + +Transaction --> Timestamp +Transaction --> TransactionStatus +Transaction "1" *--> "*" TransactionInput +Transaction "1" *--> "*" TransactionOutput + +TransactionInput "1" --> "1" TransactionOutput : spend + +TransactionOutput "*" --> "1" Address : fund + +Block "*" *--> Transaction +Block --> Timestamp +Block --> TransactionIterator + +class CryptoCurrencyToken + +AltcoinPlugin "1" - "*" CryptoCurrencyToken : implements +AltcoinManager "registry" <-- "plugin" AltcoinPlugin : registration +AltcoinPlugin "1" --> "*" WalletEnv +AltcoinPlugin --> PEX + +(AltcoinPlugin, CryptoCurrencyToken) .. AltcoinMetadata + +AltcoinManager "1" o--> "*" AltcoinPlugin +AltcoinManager "cache" --> "record" AltcoinMetadata + +BlockchainStatus --> Block +BlockchainStatus ..> CoinValueMetric + +PEX --> TransactionIterator +PEX --> PexNodeSet +PEX ..> Transaction : P2P broadcast + +PexNodeSet --> PexNodeIterator +PexNodeSet "*" o--> "*" PexNode + +WalletSet --> WalletIterator +WalletSet o--> Wallet +WalletSet ..> PasswordReader + +WalletStorage ..> PasswordReader + +AltcoinPlugin --> BlockchainTransactionAPI +AltcoinPlugin --> BlockchainSignService + +FullWallet -|> Wallet +FullWallet --|> HDAddressGenerator +FullWallet --|> TxnSigner +FullWallet --|> BlockchainWallet +HardwareWallet --|> TxnSigner +HardwareWallet --|> HDAddressGenerator +Wallet <|-- DistWallet +Wallet <|-- CollectionWallet +Wallet <|-- HDAddressGenerator +Wallet <|-- TxnSigner +Wallet <|-- BlockchainWallet +DistWallet <|-- CollectionWallet +DistWallet <|-- HDAddressGenerator + +CollectionWallet "1" o--> "*" Address +HDAddressGenerator "1" *--> "∞" Address + +TxnSigner ..> PasswordReader +BlockchainWallet ..> KeyValueStorage +BlockchainWallet ..> TransactionOutput +BlockchainWallet --> Transaction : create +AltcoinManager "1" ..> "*" TxnSigner +DistWallet ..> Address +DistWallet --> AddressIterator +CollectionWallet ..> Address +HDAddressGenerator ..> AddressType +HDAddressGenerator --> AddressIterator + +AltcoinManager --> TxnSignerIterator + +WalletEnv "1" o--> "1" WalletStorage +WalletEnv "1" o--> "1" WalletSet +WalletSet ..> SeedGenerator + +BlockchainTransactionAPI ..> WalletAddress +BlockchainTransactionAPI ..> TransactionOutput +BlockchainTransactionAPI ..> WalletOutput +BlockchainTransactionAPI ..> Address +BlockchainTransactionAPI ..> KeyValueStorage +BlockchainTransactionAPI --> Transaction + +BlockchainSignService ..> Transaction +BlockchainSignService ..> InputSignDescriptor +BlockchainSignService ..> PasswordReader +BlockchainSignService --> Transaction + +WalletOutput o--> Wallet +WalletOutput o--> TransactionOutput + +WalletAddress o--> Wallet +WalletAddress o--> Address + +CryptoAccount : GetBalance(ticker string) (uint64, error) +CryptoAccount : ListAssets() []string +CryptoAccount : ScanUnspentOutputs() TransactionOutputIterator +CryptoAccount : ListTransactions() TransactionIterator +CryptoAccount : ListPendingTransactions() (TransactionIterator, error) + +Address : IsBip32() bool +Address : String() string +Address : GetCryptoAccount() CryptoAccount + +TxnSigner : SignTransaction(Transaction, PasswordReader, []string) (Transaction, error) +TxnSigner : GetSignerDescription() string + +Transaction : SupportedAssets() []string +Transaction : GetTimestamp() Timestamp +Transaction : GetStatus() TransactionStatus +Transaction : GetInputs() []TransactionInput +Transaction : GetOutputs() []TransactionOutput +Transaction : GetID() string +Transaction : ComputeFee(ticker string) (uint64, error) +Transaction : VerifyUnsigned() error +Transaction : VerifySigned() error +Transaction : IsFullySigned() (bool, error) + +TransactionInput : GetID() string +TransactionInput : GetSpentOutput() TransactionOutput +TransactionInput : GetCoins(ticker string) (uint64, error) +TransactionInput : SupportedAssets() []string + +TransactionOutput : GetID() string +TransactionOutput : IsSpent() bool +TransactionOutput : GetAddress() Address +TransactionOutput : GetCoins(ticker string) (uint64, error) +TransactionOutput : SupportedAssets() []string + +Block : GetHash() ([]byte, error) +Block : GetPrevHash() ([]byte, error) +Block : GetVersion() (uint32, error) +Block : GetTime() (Timestamp, error) +Block : GetHeight() (uint64, error) +Block : GetFee(ticker string) (uint64, error) +Block : IsGenesisBlock() (bool, error) +Block : GetTransactions() (TransactionIterator, error) + +AltcoinPlugin : ListSupportedAltcoins() []AltcoinMetadata +AltcoinPlugin : ListSupportedFamilies() []string +AltcoinPlugin : RegisterTo(manager AltcoinManager) +AltcoinPlugin : GetName() string +AltcoinPlugin : GetDescription() string +AltcoinPlugin : LoadWalletEnvs() []WalletEnv +AltcoinPlugin : LoadPEX(netType string) (PEX, error) +AltcoinPlugin : LoadTransactionAPI(netType string) (BlockchainTransactionAPI, error) +AltcoinPlugin : LoadSignService() (BlockchainSignService, error) + +AltcoinManager : RegisterPlugin(p AltcoinPlugin) +AltcoinManager : RegisterAltcoin(info AltcoinMetadata, plugin AltcoinPlugin) +AltcoinManager : ListRegisteredPlugins() []AltcoinPlugin +AltcoinManager : LookupAltcoinPlugin(ticker string) (AltcoinPlugin, bool) +AltcoinManager : DescribeAltcoin(ticker string) (AltcoinMetadata, bool) + +BlockchainStatus : GetCoinValue(coinvalue CoinValueMetric, ticker string) (uint64, error) +BlockchainStatus : GetLastBlock() (Block, error) +BlockchainStatus : GetNumberOfBlocks() (uint64, error) + +PEX : GetTxnPool() (TransactionIterator, error) +PEX : GetConnections() (PexNodeSet, error) +PEX : BroadcastTxn(txn Transaction) error + +PexNodeSet : ListPeers() PexNodeIterator + +PexNode : GetIp() string +PexNode : GetPort() uint16 +PexNode : GetBlockHeight() uint64 +PexNode : IsTrusted() bool +PexNode : GetLastSeenIn() int64 +PexNode : GetLastSeenOut() int64 + +KeyValueStorage : GetValue(key string) interface{} +KeyValueStorage : SetValue(key string, value interface{}) + +WalletSet : ListWallets() WalletIterator +WalletSet : GetWallet(id string) Wallet +WalletSet : CreateWallet(name string, seed string, isEncryptrd bool, pwd PasswordReader, scanAddressesN int) (Wallet, error) + +WalletStorage : Encrypt(walletName string, password PasswordReader) +WalletStorage : Decrypt(walletName string, password PasswordReader) +WalletStorage : IsEncrypted(walletName string) (bool, error) + +Wallet : WalletId() string +Wallet : WalletLabel() string +Wallet : SetLabel(wltName string) +Wallet : GetCryptoAccount() CryptoAccount + +BlockchainWallet : Transfer(to TransactionOutput, options KeyValueStorage) (Transaction, error) +BlockchainWallet : SendFromAddress(from []Address, to []TransactionOutput, change Address, options KeyValueStorage) (Transaction, error) +BlockchainWallet : Spend(unspent, new []TransactionOutput, change Address, options KeyValueStorage) (Transaction, error) + +HDAddressGenerator : GenAddresses(addrType AddressType, startIndex, count uint32, pwd PasswordReader) AddressIterator + +DistWallet : GetLoadedAddresses() (AddressIterator, error) + +CollectionWallet : AddAddress(Address) +CollectionWallet : RemoveAddress(Address) + +AltcoinManager : AttachSignService(TxnSigner) error +AltcoinManager : RemoveSignService(TxnSigner) error +AltcoinManager : EnumerateSignServices() TxnSignerIterator + +SeedGenerator : GenerateMnemonic(wordCount int) (string, error) +SeedGenerator : VerifyMnemonic(seed string) (bool, error) + +WalletEnv : GetStorage() WalletStorage +WalletEnv : GetWalletSet() WalletSet + +BlockchainTransactionAPI : SendFromAddress(from []WalletAddress, to []TransactionOutput, change Address, options KeyValueStorage) (Transaction, error) +BlockchainTransactionAPI : Spend(unspent []WalletOutput, new []TransactionOutput, change Address, options KeyValueStorage) (Transaction, error) + +BlockchainSignService : Sign(txn Transaction, signSpec []InputSignDescriptor, pwd PasswordReader) (Transaction, error) + +WalletOutput : GetWallet() Wallet +WalletOutput : GetOutput() TransactionOutput + +WalletAddress : GetWallet() Wallet +WalletAddress : GetAddress() Address + +@enduml + From 2bd5984a4218aed5ccb58b3fb655a16ba549b86c Mon Sep 17 00:00:00 2001 From: Olemis Lang Date: Mon, 9 Dec 2019 01:24:18 -0500 Subject: [PATCH 11/11] [uml] refs #130 - Rename WalletId => GetID WalletLabel => GetLabel --- content/diagrams/plantuml/core.v2.uml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/diagrams/plantuml/core.v2.uml b/content/diagrams/plantuml/core.v2.uml index 55cd3cb..7f82a66 100644 --- a/content/diagrams/plantuml/core.v2.uml +++ b/content/diagrams/plantuml/core.v2.uml @@ -272,8 +272,8 @@ WalletStorage : Encrypt(walletName string, password PasswordReader) WalletStorage : Decrypt(walletName string, password PasswordReader) WalletStorage : IsEncrypted(walletName string) (bool, error) -Wallet : WalletId() string -Wallet : WalletLabel() string +Wallet : GetID() string +Wallet : GetLabel() string Wallet : SetLabel(wltName string) Wallet : GetCryptoAccount() CryptoAccount