Fix app
This commit is contained in:
parent
01b2def693
commit
7dccf61484
13
app/app.go
13
app/app.go
|
@ -214,7 +214,7 @@ func sumAmounts(inputs []types.Input, outputs []types.Output, more int) (total u
|
|||
}
|
||||
|
||||
func allPubKeys(tx types.Tx) (pubKeys []crypto.PubKey) {
|
||||
pubKeys = make([]crypto.PubKey, len(tx.Inputs)+len(tx.Outputs))
|
||||
pubKeys = make([]crypto.PubKey, 0, len(tx.Inputs)+len(tx.Outputs))
|
||||
for _, input := range tx.Inputs {
|
||||
pubKeys = append(pubKeys, input.PubKey)
|
||||
}
|
||||
|
@ -278,13 +278,18 @@ func loadAccounts(eyesCli *eyes.MerkleEyesClient, pubKeys []crypto.PubKey) (accM
|
|||
if err != nil {
|
||||
panic("Error loading account: " + err.Error())
|
||||
}
|
||||
var acc types.PubAccount
|
||||
if len(accBytes) == 0 {
|
||||
continue
|
||||
}
|
||||
var acc types.Account
|
||||
err = wire.ReadBinaryBytes(accBytes, &acc)
|
||||
if err != nil {
|
||||
panic("Error reading account: " + err.Error())
|
||||
}
|
||||
acc.PubKey = pubKey // Set volatile field
|
||||
accMap[keyString] = acc
|
||||
accMap[keyString] = types.PubAccount{
|
||||
Account: acc,
|
||||
PubKey: pubKey,
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
7
main.go
7
main.go
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"github.com/tendermint/blackstar/app"
|
||||
"github.com/tendermint/blackstar/types"
|
||||
|
@ -39,13 +38,13 @@ func main() {
|
|||
Exit("parsing genesis JSON: " + err.Error())
|
||||
}
|
||||
for _, account := range genesisState.Accounts {
|
||||
pubKeyBytes := wire.BinaryBytes(account.PubKey)
|
||||
// pubKeyBytes := wire.BinaryBytes(account.PubKey)
|
||||
pubKeyString := account.PubKey.KeyString()
|
||||
accBytes := wire.BinaryBytes(account.Account)
|
||||
err = eyesCli.SetSync(pubKeyBytes, accBytes)
|
||||
err = eyesCli.SetSync([]byte(pubKeyString), accBytes)
|
||||
if err != nil {
|
||||
Exit("loading genesis accounts: " + err.Error())
|
||||
}
|
||||
fmt.Println("Loaded ", account)
|
||||
}
|
||||
|
||||
// Start the listener
|
||||
|
|
Binary file not shown.
|
@ -61,18 +61,14 @@ func main() {
|
|||
|
||||
// Sign request
|
||||
signBytes := wire.BinaryBytes(tx)
|
||||
fmt.Printf("SIGN: %X\n", signBytes)
|
||||
sig := root.PrivKey.Sign(signBytes)
|
||||
fmt.Println("VERIFY: ", root.PubKey.VerifyBytes(signBytes, sig))
|
||||
tx.Inputs[0].Signature = sig
|
||||
//fmt.Println("tx:", tx)
|
||||
|
||||
// Write request
|
||||
txBytes := wire.BinaryBytes(tx)
|
||||
fmt.Println("tx:", hex.EncodeToString(txBytes))
|
||||
request := rpctypes.NewRPCRequest("fakeid", "broadcast_tx_sync", Arr(txBytes))
|
||||
reqBytes := wire.JSONBytes(request)
|
||||
fmt.Println("req:", hex.EncodeToString(reqBytes))
|
||||
//fmt.Print(".")
|
||||
err := ws.WriteMessage(websocket.TextMessage, reqBytes)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue