From 84645a1208a4261f1d46d05740c010de011244d9 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Mon, 5 Jul 2021 11:19:21 +0200 Subject: [PATCH] Wallet signs acks --- abc/wallet.nim | 5 +++++ tests/abc/testWallet.nim | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/abc/wallet.nim b/abc/wallet.nim index 44ead69..2cb2d5e 100644 --- a/abc/wallet.nim +++ b/abc/wallet.nim @@ -1,8 +1,10 @@ import ./keys import ./transactions +import ./acks export keys export transactions +export acks type Wallet* = object @@ -16,3 +18,6 @@ func id*(wallet: Wallet): PublicKey = func sign*(wallet: Wallet, transaction: var Transaction) = wallet.key.sign(transaction) + +func sign*(wallet: Wallet, ack: var Ack) = + wallet.key.sign(ack) diff --git a/tests/abc/testWallet.nim b/tests/abc/testWallet.nim index f0198f9..56ed8ea 100644 --- a/tests/abc/testWallet.nim +++ b/tests/abc/testWallet.nim @@ -16,3 +16,9 @@ suite "Wallets": check transaction.signature == Signature.default wallet.sign(transaction) check transaction.signature == key.sign(transaction.hash.toBytes) + + test "wallet can sign acknowledgment": + var ack = Ack.example + check ack.signature.isNone + wallet.sign(ack) + check ack.signature == key.sign(ack.hash.toBytes).some