2021-06-29 15:10:30 +00:00
|
|
|
import std/random
|
2021-06-29 09:00:40 +00:00
|
|
|
import pkg/questionable
|
2021-06-29 15:10:30 +00:00
|
|
|
import abc
|
2021-06-30 15:18:19 +00:00
|
|
|
import abc/acks
|
2021-06-29 15:10:30 +00:00
|
|
|
import ./alicebob
|
2021-06-28 12:03:48 +00:00
|
|
|
|
|
|
|
proc example*(_: type PrivateKey): PrivateKey =
|
|
|
|
PrivateKey.random
|
|
|
|
|
|
|
|
proc example*(_: type PublicKey): PublicKey =
|
|
|
|
PrivateKey.example.toPublicKey
|
2021-06-28 13:04:50 +00:00
|
|
|
|
2021-06-29 09:00:40 +00:00
|
|
|
proc example*(_: type Wallet): Wallet =
|
|
|
|
let key = PrivateKey.example
|
|
|
|
Wallet.init(key)
|
2021-06-29 15:10:30 +00:00
|
|
|
|
|
|
|
proc example*(_: type Transaction): Transaction =
|
|
|
|
let alice = PublicKey.alice
|
2021-06-30 11:55:45 +00:00
|
|
|
let carol = PublicKey.example
|
2021-06-30 11:49:19 +00:00
|
|
|
let victor = PublicKey.victor
|
2021-06-29 15:10:30 +00:00
|
|
|
let genesis = Transaction.genesis
|
|
|
|
let amount = rand(100).u256
|
|
|
|
var transaction = !Transaction.init(
|
|
|
|
{genesis.hash: alice},
|
2021-06-30 11:55:45 +00:00
|
|
|
{carol: amount, alice: 100.u256 - amount},
|
2021-06-30 11:49:19 +00:00
|
|
|
victor
|
2021-06-29 15:10:30 +00:00
|
|
|
)
|
|
|
|
transaction
|
2021-06-30 15:18:19 +00:00
|
|
|
|
|
|
|
proc example*(_: type Ack): Ack =
|
|
|
|
let tx1, tx2 = Transaction.example
|
|
|
|
!Ack.init([tx1.hash, tx2.hash])
|