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