Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions blockcert.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ func shell(ctx context.Context, node *p2p.P2pNode) {
//privateKey := keygen.ParsePrivateRSA(cli_args[2])
node.NewCertPublisher(ctx, cli_args[1], cli_args[2])
fmt.Println("Certificate successfully added!")
node.BcToJson(cli_args[3])
case "showallcerts":
node.ShowBlocks()
case "peers":
Expand Down
5 changes: 5 additions & 0 deletions src/certificate/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"crypto/rsa"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"
"strings"
Expand All @@ -12,6 +13,10 @@ import (
"github.com/panzerox123/blockcert/src/keygen"
)

func (bc *BlockChain) SaveToJson(srcFile string) {
fileDat, _ := json.Marshal(bc)
_ = ioutil.WriteFile(srcFile, fileDat, 0644)
}
func FileByteOut(srcFile string) []byte {
data, err := ioutil.ReadFile(srcFile)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions src/p2p/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ func (node *P2pNode) VerifyChain() bool {
fmt.Println(val)
return val
}
func (node *P2pNode) BcToJson(srcFile string) {
node.blockchain.SaveToJson(srcFile)
}

func (node *P2pNode) CheckCertificate(data []byte, pubkey *rsa.PublicKey) bool {
return node.blockchain.CheckSignature(data, pubkey)
Expand Down