Coins and fees and gas...

This commit is contained in:
Jae Kwon
2016-04-01 15:19:07 -07:00
parent f81718eea4
commit a16b96062b
10 changed files with 278 additions and 72 deletions
+1 -2
View File
@@ -15,7 +15,6 @@ func PrivAccountFromSecret(secret string) types.PrivAccount {
Account: types.Account{
PubKey: privKey.PubKey(),
Sequence: 0,
Balance: 0,
},
}
return privAccount
@@ -38,7 +37,7 @@ func RandAccounts(num int, minAmount int64, maxAmount int64) []types.PrivAccount
Account: types.Account{
PubKey: pubKey,
Sequence: 0,
Balance: balance,
Balance: types.Coins{types.Coin{"", balance}},
},
}
}
+4 -4
View File
@@ -51,14 +51,14 @@ func main() {
types.TxInput{
Address: root.Account.PubKey.Address(),
PubKey: root.Account.PubKey, // TODO is this needed?
Amount: 1000002,
Coins: types.Coins{{"", 1000002}},
Sequence: sequence,
},
},
Outputs: []types.TxOutput{
types.TxOutput{
Address: privAccount.Account.PubKey.Address(),
Amount: 1000000,
Coins: types.Coins{{"", 1000000}},
},
},
}
@@ -102,14 +102,14 @@ func main() {
types.TxInput{
Address: privAccountA.Account.PubKey.Address(),
PubKey: privAccountA.Account.PubKey,
Amount: 3,
Coins: types.Coins{{"", 3}},
Sequence: privAccountASequence + 1,
},
},
Outputs: []types.TxOutput{
types.TxOutput{
Address: privAccountB.Account.PubKey.Address(),
Amount: 1,
Coins: types.Coins{{"", 1}},
},
},
}
+14 -8
View File
@@ -28,24 +28,26 @@ func testSendTx() {
// Seed Basecoin with account
tAcc := tPriv.Account
tAcc.Balance = 1000
tAcc.Balance = types.Coins{{"", 1000}}
fmt.Println(bcApp.SetOption("base/chainID", "test_chain_id"))
fmt.Println(bcApp.SetOption("base/account", string(wire.JSONBytes(tAcc))))
// Construct a SendTx signature
tx := &types.SendTx{
Fee: 0,
Gas: 0,
Inputs: []types.TxInput{
types.TxInput{
Address: tPriv.Account.PubKey.Address(),
PubKey: tPriv.Account.PubKey, // TODO is this needed?
Amount: 1,
Coins: types.Coins{{"", 1}},
Sequence: 1,
},
},
Outputs: []types.TxOutput{
types.TxOutput{
Address: tPriv2.Account.PubKey.Address(),
Amount: 1,
Coins: types.Coins{{"", 1}},
},
},
}
@@ -95,7 +97,7 @@ func testSequence() {
// Get the root account
root := tests.PrivAccountFromSecret("test")
rootAcc := root.Account
rootAcc.Balance = 1 << 53
rootAcc.Balance = types.Coins{{"", 1 << 53}}
fmt.Println(bcApp.SetOption("base/chainID", "test_chain_id"))
fmt.Println(bcApp.SetOption("base/account", string(wire.JSONBytes(rootAcc))))
@@ -108,18 +110,20 @@ func testSequence() {
for i := 0; i < len(privAccounts); i++ {
privAccount := privAccounts[i]
tx := &types.SendTx{
Fee: 2,
Gas: 2,
Inputs: []types.TxInput{
types.TxInput{
Address: root.Account.PubKey.Address(),
PubKey: root.Account.PubKey, // TODO is this needed?
Amount: 1000002,
Coins: types.Coins{{"", 1000002}},
Sequence: sequence,
},
},
Outputs: []types.TxOutput{
types.TxOutput{
Address: privAccount.Account.PubKey.Address(),
Amount: 1000000,
Coins: types.Coins{{"", 1000000}},
},
},
}
@@ -155,18 +159,20 @@ func testSequence() {
privAccountB := privAccounts[randB]
tx := &types.SendTx{
Fee: 2,
Gas: 2,
Inputs: []types.TxInput{
types.TxInput{
Address: privAccountA.Account.PubKey.Address(),
PubKey: privAccountA.Account.PubKey,
Amount: 3,
Coins: types.Coins{{"", 3}},
Sequence: privAccountASequence + 1,
},
},
Outputs: []types.TxOutput{
types.TxOutput{
Address: privAccountB.Account.PubKey.Address(),
Amount: 1,
Coins: types.Coins{{"", 1}},
},
},
}