Commit 978b514e authored by David Vorick's avatar David Vorick

change Input and Output to SiacoinInput and SiacoinOutput

parent 47a58613
......@@ -7,7 +7,7 @@ import (
// mineTestingBlock accepts a bunch of parameters for a block and then grinds
// blocks until a block with the appropriate target is found.
func mineTestingBlock(parent BlockID, timestamp Timestamp, minerPayouts []Output, txns []Transaction, target Target) (b Block, err error) {
func mineTestingBlock(parent BlockID, timestamp Timestamp, minerPayouts []SiacoinOutput, txns []Transaction, target Target) (b Block, err error) {
b = Block{
ParentID: parent,
Timestamp: timestamp,
......@@ -27,9 +27,9 @@ func mineTestingBlock(parent BlockID, timestamp Timestamp, minerPayouts []Output
// nullMinerPayouts returns an []Output for the miner payouts field of a block
// so that the block can be valid. It assumes the block will be at whatever
// height you use as input.
func nullMinerPayouts(height BlockHeight) []Output {
return []Output{
Output{
func nullMinerPayouts(height BlockHeight) []SiacoinOutput {
return []SiacoinOutput{
SiacoinOutput{
Value: CalculateCoinbase(height),
},
}
......@@ -164,7 +164,7 @@ func testMinerPayouts(t *testing.T, s *State) {
// Create a block with a single legal payout, no miner fees. The payout
// goes to the hash of the empty spend conditions.
var sc SpendConditions
payout := []Output{Output{Value: CalculateCoinbase(s.Height() + 1), SpendHash: sc.CoinAddress()}}
payout := []SiacoinOutput{SiacoinOutput{Value: CalculateCoinbase(s.Height() + 1), SpendHash: sc.CoinAddress()}}
b, err := mineTestingBlock(s.CurrentBlock().ID(), Timestamp(time.Now().Unix()), payout, nil, s.CurrentTarget())
if err != nil {
t.Fatal(err)
......@@ -180,10 +180,10 @@ func testMinerPayouts(t *testing.T, s *State) {
}
// Create a block with multiple miner payouts.
payout = []Output{
Output{Value: CalculateCoinbase(s.Height()+1) - 750, SpendHash: sc.CoinAddress()},
Output{Value: 250, SpendHash: sc.CoinAddress()},
Output{Value: 500, SpendHash: sc.CoinAddress()},
payout = []SiacoinOutput{
SiacoinOutput{Value: CalculateCoinbase(s.Height()+1) - 750, SpendHash: sc.CoinAddress()},
SiacoinOutput{Value: 250, SpendHash: sc.CoinAddress()},
SiacoinOutput{Value: 500, SpendHash: sc.CoinAddress()},
}
b, err = mineTestingBlock(s.CurrentBlock().ID(), Timestamp(time.Now().Unix()), payout, nil, s.CurrentTarget())
if err != nil {
......@@ -210,7 +210,7 @@ func testMinerPayouts(t *testing.T, s *State) {
}
// Create a block with a too large payout.
payout = []Output{Output{Value: CalculateCoinbase(s.Height()), SpendHash: sc.CoinAddress()}}
payout = []SiacoinOutput{SiacoinOutput{Value: CalculateCoinbase(s.Height()), SpendHash: sc.CoinAddress()}}
b, err = mineTestingBlock(s.CurrentBlock().ID(), Timestamp(time.Now().Unix()), payout, nil, s.CurrentTarget())
if err != nil {
t.Fatal(err)
......@@ -226,7 +226,7 @@ func testMinerPayouts(t *testing.T, s *State) {
}
// Create a block with a too small payout.
payout = []Output{Output{Value: CalculateCoinbase(s.Height() + 2), SpendHash: sc.CoinAddress()}}
payout = []SiacoinOutput{SiacoinOutput{Value: CalculateCoinbase(s.Height() + 2), SpendHash: sc.CoinAddress()}}
b, err = mineTestingBlock(s.CurrentBlock().ID(), Timestamp(time.Now().Unix()), payout, nil, s.CurrentTarget())
if err != nil {
t.Fatal(err)
......@@ -243,8 +243,8 @@ func testMinerPayouts(t *testing.T, s *State) {
// Test legal multiple payouts when there are multiple miner fees.
txn1 := Transaction{
Inputs: []Input{
Input{OutputID: output250},
SiacoinInputs: []SiacoinInput{
SiacoinInput{OutputID: output250},
},
MinerFees: []Currency{
Currency(50),
......@@ -253,8 +253,8 @@ func testMinerPayouts(t *testing.T, s *State) {
},
}
txn2 := Transaction{
Inputs: []Input{
Input{OutputID: output500},
SiacoinInputs: []SiacoinInput{
SiacoinInput{OutputID: output500},
},
MinerFees: []Currency{
Currency(100),
......@@ -262,7 +262,7 @@ func testMinerPayouts(t *testing.T, s *State) {
Currency(250),
},
}
payout = []Output{Output{Value: CalculateCoinbase(s.Height()+1) + 25}, Output{Value: 650, SpendHash: sc.CoinAddress()}, Output{Value: 75, SpendHash: sc.CoinAddress()}}
payout = []SiacoinOutput{SiacoinOutput{Value: CalculateCoinbase(s.Height()+1) + 25}, SiacoinOutput{Value: 650, SpendHash: sc.CoinAddress()}, SiacoinOutput{Value: 75, SpendHash: sc.CoinAddress()}}
b, err = mineTestingBlock(s.CurrentBlock().ID(), Timestamp(time.Now().Unix()), payout, []Transaction{txn1, txn2}, s.CurrentTarget())
if err != nil {
t.Fatal(err)
......@@ -289,8 +289,8 @@ func testMinerPayouts(t *testing.T, s *State) {
// Test too large multiple payouts when there are multiple miner fees.
txn1 = Transaction{
Inputs: []Input{
Input{OutputID: output650},
SiacoinInputs: []SiacoinInput{
SiacoinInput{OutputID: output650},
},
MinerFees: []Currency{
Currency(100),
......@@ -299,8 +299,8 @@ func testMinerPayouts(t *testing.T, s *State) {
},
}
txn2 = Transaction{
Inputs: []Input{
Input{OutputID: output75},
SiacoinInputs: []SiacoinInput{
SiacoinInput{OutputID: output75},
},
MinerFees: []Currency{
Currency(10),
......@@ -308,7 +308,7 @@ func testMinerPayouts(t *testing.T, s *State) {
Currency(50),
},
}
payout = []Output{Output{Value: CalculateCoinbase(s.Height()+1) + 25}, Output{Value: 650, SpendHash: sc.CoinAddress()}, Output{Value: 75, SpendHash: sc.CoinAddress()}}
payout = []SiacoinOutput{SiacoinOutput{Value: CalculateCoinbase(s.Height()+1) + 25}, SiacoinOutput{Value: 650, SpendHash: sc.CoinAddress()}, SiacoinOutput{Value: 75, SpendHash: sc.CoinAddress()}}
b, err = mineTestingBlock(s.CurrentBlock().ID(), Timestamp(time.Now().Unix()), payout, []Transaction{txn1, txn2}, s.CurrentTarget())
if err != nil {
t.Fatal(err)
......
......@@ -91,7 +91,7 @@ func (s *State) applyContract(contract FileContract, id ContractID) (cd Contract
func (s *State) applyStorageProof(sp StorageProof) (od OutputDiff, cd ContractDiff) {
// Calculate the new output and its id.
contract := s.openContracts[sp.ContractID]
output := Output{
output := SiacoinOutput{
Value: contract.Payout,
SpendHash: contract.ValidProofAddress,
}
......@@ -118,7 +118,7 @@ func (s *State) applyStorageProof(sp StorageProof) (od OutputDiff, cd ContractDi
// on a file contract.
func (s *State) applyMissedProof(contract FileContract, id ContractID) (od OutputDiff, cd ContractDiff) {
// Create the output for the missed proof.
output := Output{
output := SiacoinOutput{
Value: contract.Payout,
SpendHash: contract.MissedProofAddress,
}
......
......@@ -20,7 +20,7 @@ import (
type OutputDiff struct {
New bool
ID OutputID
Output Output
Output SiacoinOutput
}
type ContractDiff struct {
......
......@@ -41,14 +41,14 @@ func (s *State) height() BlockHeight {
// State.Output returns the Output associated with the id provided for input,
// but only if the output is a part of the utxo set.
func (s *State) output(id OutputID) (output Output, exists bool) {
func (s *State) output(id OutputID) (output SiacoinOutput, exists bool) {
output, exists = s.unspentOutputs[id]
return
}
// Sorted UtxoSet returns all of the unspent transaction outputs sorted
// according to the numerical value of their id.
func (s *State) sortedUtxoSet() (sortedOutputs []Output) {
func (s *State) sortedUtxoSet() (sortedOutputs []SiacoinOutput) {
// Get all of the outputs in string form and sort the strings.
var unspentOutputStrings []string
for outputID := range s.unspentOutputs {
......@@ -203,7 +203,7 @@ func (s *State) HeightOfBlock(bid BlockID) (height BlockHeight, exists bool) {
// Output returns the output associated with an OutputID, returning an error if
// the output is not found.
func (s *State) Output(id OutputID) (output Output, exists bool) {
func (s *State) Output(id OutputID) (output SiacoinOutput, exists bool) {
s.mu.RLock()
defer s.mu.RUnlock()
return s.output(id)
......@@ -211,7 +211,7 @@ func (s *State) Output(id OutputID) (output Output, exists bool) {
// Sorted UtxoSet returns all of the unspent transaction outputs sorted
// according to the numerical value of their id.
func (s *State) SortedUtxoSet() []Output {
func (s *State) SortedUtxoSet() []SiacoinOutput {
s.mu.RLock()
defer s.mu.RUnlock()
return s.sortedUtxoSet()
......
......@@ -47,9 +47,9 @@ func (t Transaction) validCoveredFields() (err error) {
// Check that all fields are empty if `WholeTransaction` is set.
cf := sig.CoveredFields
if cf.WholeTransaction {
if len(cf.Inputs) != 0 ||
if len(cf.SiacoinInputs) != 0 ||
len(cf.MinerFees) != 0 ||
len(cf.Outputs) != 0 ||
len(cf.SiacoinOutputs) != 0 ||
len(cf.FileContracts) != 0 ||
len(cf.StorageProofs) != 0 ||
len(cf.SiafundInputs) != 0 ||
......@@ -63,7 +63,7 @@ func (t Transaction) validCoveredFields() (err error) {
// Check that all fields are sorted, and without repeat values, and
// that all elements point to objects that exists within the
// transaction.
err = sortedUnique(cf.Inputs, len(cf.Inputs)-1)
err = sortedUnique(cf.SiacoinInputs, len(cf.SiacoinInputs)-1)
if err != nil {
return
}
......@@ -71,7 +71,7 @@ func (t Transaction) validCoveredFields() (err error) {
if err != nil {
return
}
err = sortedUnique(cf.Outputs, len(cf.Outputs)-1)
err = sortedUnique(cf.SiacoinOutputs, len(cf.SiacoinOutputs)-1)
if err != nil {
return
}
......@@ -115,7 +115,7 @@ func (s *State) validSignatures(t Transaction) (err error) {
// Create the InputSignatures object for each input.
sigMap := make(map[OutputID]*InputSignatures)
for i, input := range t.Inputs {
for i, input := range t.SiacoinInputs {
_, exists := sigMap[input.OutputID]
if exists {
return errors.New("output spent twice in the same transaction.")
......
......@@ -37,7 +37,7 @@ type State struct {
currentPath map[BlockHeight]BlockID
siafundPool Currency
unspentSiafundOutputs map[OutputID]SiafundOutput
unspentOutputs map[OutputID]Output
unspentOutputs map[OutputID]SiacoinOutput
openContracts map[ContractID]FileContract
mu sync.RWMutex
......@@ -53,7 +53,7 @@ func CreateGenesisState(genesisTime Timestamp) (s *State) {
blockMap: make(map[BlockID]*blockNode),
currentPath: make(map[BlockHeight]BlockID),
openContracts: make(map[ContractID]FileContract),
unspentOutputs: make(map[OutputID]Output),
unspentOutputs: make(map[OutputID]SiacoinOutput),
unspentSiafundOutputs: make(map[OutputID]SiafundOutput),
}
......@@ -71,7 +71,7 @@ func CreateGenesisState(genesisTime Timestamp) (s *State) {
// Fill out the consensus informaiton for the genesis block.
s.currentBlockID = genesisBlock.ID()
s.currentPath[BlockHeight(0)] = genesisBlock.ID()
s.unspentOutputs[genesisBlock.MinerPayoutID(0)] = Output{
s.unspentOutputs[genesisBlock.MinerPayoutID(0)] = SiacoinOutput{
Value: CalculateCoinbase(0),
SpendHash: ZeroAddress,
}
......
......@@ -11,7 +11,7 @@ func (t Transaction) validStorageProofs() bool {
return true
}
if len(t.Outputs) != 0 {
if len(t.SiacoinOutputs) != 0 {
return false
}
if len(t.FileContracts) != 0 {
......@@ -26,7 +26,7 @@ func (t Transaction) validStorageProofs() bool {
// validInput returns err = nil if the input is valid within the current state,
// otherwise returns an error explaining what wasn't valid.
func (s *State) validInput(input Input) (err error) {
func (s *State) validInput(input SiacoinInput) (err error) {
// Check the input spends an existing and valid output.
_, exists := s.unspentOutputs[input.OutputID]
if !exists {
......@@ -60,7 +60,7 @@ func (s *State) validTransaction(t Transaction) (err error) {
// Validate each input and get the total amount of Currency.
inputSum := Currency(0)
for _, input := range t.Inputs {
for _, input := range t.SiacoinInputs {
// Check that the input is valid.
err = s.validInput(input)
if err != nil {
......@@ -106,7 +106,7 @@ func (s *State) validTransaction(t Transaction) (err error) {
// ConsensusState, updating the list of contracts, outputs, etc.
func (s *State) applyTransaction(t Transaction) (outputDiffs []OutputDiff, contractDiffs []ContractDiff) {
// Remove all inputs from the unspent outputs list.
for _, input := range t.Inputs {
for _, input := range t.SiacoinInputs {
// Sanity check - the input must exist within the blockchain, should
// have already been verified.
if DEBUG {
......@@ -126,7 +126,7 @@ func (s *State) applyTransaction(t Transaction) (outputDiffs []OutputDiff, contr
}
// Add all finanacial outputs to the unspent outputs list.
for i, output := range t.Outputs {
for i, output := range t.SiacoinOutputs {
// Sanity check - the output must not exist within the state, should
// have already been verified.
if DEBUG {
......@@ -175,7 +175,7 @@ func (t Transaction) OutputSum() (sum Currency) {
}
// Add the outputs
for _, output := range t.Outputs {
for _, output := range t.SiacoinOutputs {
sum += output.Value
}
......
......@@ -49,16 +49,16 @@ type Block struct {
ParentID BlockID
Nonce uint64
Timestamp Timestamp
MinerPayouts []Output
MinerPayouts []SiacoinOutput
Transactions []Transaction
}
// A Transaction is an update to the state of the network, can move money
// around, make contracts, etc.
type Transaction struct {
Inputs []Input
SiacoinInputs []SiacoinInput
MinerFees []Currency
Outputs []Output
SiacoinOutputs []SiacoinOutput
FileContracts []FileContract
StorageProofs []StorageProof
SiafundInputs []SiafundInput
......@@ -69,7 +69,7 @@ type Transaction struct {
// An Input contains the ID of the output it's trying to spend, and the spend
// conditions that unlock the output.
type Input struct {
type SiacoinInput struct {
OutputID OutputID
SpendConditions SpendConditions
}
......@@ -93,7 +93,7 @@ type SpendConditions struct {
// An Output contains a volume of currency and a 'CoinAddress', which is just a
// hash of the spend conditions which unlock the output.
type Output struct {
type SiacoinOutput struct {
Value Currency
SpendHash CoinAddress
}
......@@ -167,9 +167,9 @@ type TransactionSignature struct {
// empty except for the Signatures field.
type CoveredFields struct {
WholeTransaction bool
Inputs []uint64
SiacoinInputs []uint64
MinerFees []uint64
Outputs []uint64
SiacoinOutputs []uint64
FileContracts []uint64
StorageProofs []uint64
SiafundInputs []uint64
......@@ -229,9 +229,9 @@ func (b Block) MinerPayoutID(i int) OutputID {
func (t Transaction) FileContractID(i int) ContractID {
return ContractID(hash.HashAll(
FileContractIdentifier,
t.Inputs,
t.SiacoinInputs,
t.MinerFees,
t.Outputs,
t.SiacoinOutputs,
t.FileContracts,
t.StorageProofs,
t.SiafundInputs,
......@@ -247,9 +247,9 @@ func (t Transaction) FileContractID(i int) ContractID {
func (t Transaction) OutputID(i int) OutputID {
return OutputID(hash.HashAll(
SiacoinOutputIdentifier,
t.Inputs,
t.SiacoinInputs,
t.MinerFees,
t.Outputs,
t.SiacoinOutputs,
t.FileContracts,
t.StorageProofs,
t.SiafundInputs,
......@@ -274,9 +274,9 @@ func (fcID ContractID) StorageProofOutputID(proofValid bool) (outputID OutputID)
func (t Transaction) SiafundOutputID(i int) OutputID {
return OutputID(hash.HashAll(
SiafundOutputIdentifier,
t.Inputs,
t.SiacoinInputs,
t.MinerFees,
t.Outputs,
t.SiacoinOutputs,
t.FileContracts,
t.StorageProofs,
t.SiafundInputs,
......@@ -306,9 +306,9 @@ func (t Transaction) SigHash(i int) hash.Hash {
var signedData []byte
if cf.WholeTransaction {
signedData = encoding.MarshalAll(
t.Inputs,
t.SiacoinInputs,
t.MinerFees,
t.Outputs,
t.SiacoinOutputs,
t.FileContracts,
t.StorageProofs,
t.SiafundInputs,
......@@ -322,11 +322,11 @@ func (t Transaction) SigHash(i int) hash.Hash {
for _, minerFee := range cf.MinerFees {
signedData = append(signedData, encoding.Marshal(t.MinerFees[minerFee])...)
}
for _, input := range cf.Inputs {
signedData = append(signedData, encoding.Marshal(t.Inputs[input])...)
for _, input := range cf.SiacoinInputs {
signedData = append(signedData, encoding.Marshal(t.SiacoinInputs[input])...)
}
for _, output := range cf.Outputs {
signedData = append(signedData, encoding.Marshal(t.Outputs[output])...)
for _, output := range cf.SiacoinOutputs {
signedData = append(signedData, encoding.Marshal(t.SiacoinOutputs[output])...)
}
for _, contract := range cf.FileContracts {
signedData = append(signedData, encoding.Marshal(t.FileContracts[contract])...)
......
......@@ -33,7 +33,7 @@ func (h *Host) Announce(addr network.Address, freezeVolume consensus.Currency, f
if err != nil {
return
}
output := consensus.Output{
output := consensus.SiacoinOutput{
Value: freezeVolume,
SpendHash: spendHash,
}
......
......@@ -27,12 +27,12 @@ func findHostAnnouncements(height consensus.BlockHeight, b consensus.Block) (ann
}
// check that spend conditions are valid
if ha.SpendConditions.CoinAddress() != t.Outputs[ha.FreezeIndex].SpendHash {
if ha.SpendConditions.CoinAddress() != t.SiacoinOutputs[ha.FreezeIndex].SpendHash {
continue
}
// calculate freeze
freeze := uint64(ha.SpendConditions.TimeLock-height) * uint64(t.Outputs[ha.FreezeIndex].Value)
freeze := uint64(ha.SpendConditions.TimeLock-height) * uint64(t.SiacoinOutputs[ha.FreezeIndex].Value)
// check for sane freeze value
if freeze <= 0 {
......
......@@ -34,8 +34,8 @@ func (m *Miner) blockForWork() (b consensus.Block) {
subsidy += fee
}
}
output := consensus.Output{Value: subsidy, SpendHash: m.address}
b.MinerPayouts = []consensus.Output{output}
output := consensus.SiacoinOutput{Value: subsidy, SpendHash: m.address}
b.MinerPayouts = []consensus.SiacoinOutput{output}
// If we've got a time earlier than the earliest legal timestamp, set the
// timestamp equal to the earliest legal timestamp.
......
......@@ -10,7 +10,7 @@ import (
// the confirmed set of outputs or in the unconfirmed set of outputs.
// checkInputs also returns the sum of all the inputs in the transaction.
func (tp *TransactionPool) checkInputs(t consensus.Transaction) (inputSum consensus.Currency, err error) {
for _, input := range t.Inputs {
for _, input := range t.SiacoinInputs {
// Check that this output has not already been spent by an unconfirmed
// transaction.
_, exists := tp.outputs[input.OutputID]
......@@ -108,7 +108,7 @@ func (tp *TransactionPool) addTransaction(t consensus.Transaction) {
// Go through the inputs and them to the used outputs list, updating the
// requirements and dependents as necessary.
for _, input := range t.Inputs {
for _, input := range t.SiacoinInputs {
// Sanity check - this input should not already be in the usedOutputs
// list.
if consensus.DEBUG {
......@@ -127,7 +127,7 @@ func (tp *TransactionPool) addTransaction(t consensus.Transaction) {
}
// Add each new output to the list of outputs and newOutputs.
for i, output := range t.Outputs {
for i, output := range t.SiacoinOutputs {
// Sanity check - this output should not already exist in newOutputs or
// outputs.
if consensus.DEBUG {
......
......@@ -73,7 +73,7 @@ func (tp *TransactionPool) OutputDiffs() (diffs []consensus.OutputDiff) {
currentTxn := tp.head
for currentTxn != nil {
txn := currentTxn.transaction
for _, input := range txn.Inputs {
for _, input := range txn.SiacoinInputs {
diff := consensus.OutputDiff{
New: false,
ID: input.OutputID,
......@@ -95,7 +95,7 @@ func (tp *TransactionPool) OutputDiffs() (diffs []consensus.OutputDiff) {
diffs = append(diffs, diff)
}
for i, output := range txn.Outputs {
for i, output := range txn.SiacoinOutputs {
diff := consensus.OutputDiff{
New: true,
ID: txn.OutputID(i),
......
......@@ -8,7 +8,7 @@ import (
)
const (
TransactionSizeLimit = 64 * 1024
TransactionSizeLimit = 16 * 1024
)
// standard implements the rules outlined in Standard.md, and will return an
......@@ -21,19 +21,6 @@ func (tp *TransactionPool) IsStandardTransaction(t consensus.Transaction) (err e
return
}
// Check that transactions with storage proofs follow the storage proof
// rules.
if len(t.StorageProofs) != 0 {
if len(t.Inputs) > 1 ||
len(t.MinerFees) > 1 ||
len(t.Outputs) > 1 ||
len(t.FileContracts) != 0 ||
len(t.ArbitraryData) != 0 {
err = errors.New("transaction has storage proofs but does not follow the storage proof rules")
return
}
}
// TODO: Check that the arbitrary data is either prefixed with 'NonSia' or
// is prefixed with 'HostAnnouncement' plus follows rules for making a host
// announcement.
......
......@@ -40,7 +40,7 @@ type TransactionPool struct {
// Outputs contains a list of outputs that have been created by unconfirmed
// transactions. This list will not include outputs created by storage
// proofs.
outputs map[consensus.OutputID]consensus.Output
outputs map[consensus.OutputID]consensus.SiacoinOutput
// newOutputs is a mapping from an OutputID to the unconfirmed transaction
// that created the output. usedOutputs is a mapping to the unconfirmed
......@@ -70,7 +70,7 @@ func New(state *consensus.State) (tp *TransactionPool, err error) {
state: state,
recentBlock: state.CurrentBlock().ID(),
outputs: make(map[consensus.OutputID]consensus.Output),
outputs: make(map[consensus.OutputID]consensus.SiacoinOutput),
newOutputs: make(map[consensus.OutputID]*unconfirmedTransaction),
usedOutputs: make(map[consensus.OutputID]*unconfirmedTransaction),
......
......@@ -66,7 +66,7 @@ func (tp *TransactionPool) update() {
// Find any transactions in our set that are dependent on this
// transaction.
for i := range txn.Outputs {
for i := range txn.SiacoinOutputs {
dependent, exists := tp.usedOutputs[txn.OutputID(i)]
if exists {
ut.dependents[dependent] = struct{}{}
......@@ -92,7 +92,7 @@ func (tp *TransactionPool) update() {
// occur with transactions that got accepted.
for _, block := range addedBlocks {
for _, txn := range block.Transactions {
for _, input := range txn.Inputs {
for _, input := range txn.SiacoinInputs {
conflict, exists := tp.usedOutputs[input.OutputID]
if exists {
tp.removeTransactionFromPool(conflict)
......
......@@ -39,7 +39,7 @@ type Wallet interface {
// AddOutput adds an output to a transaction. It returns the index of the
// output in the transaction.
AddOutput(id string, output consensus.Output) (uint64, error)
AddOutput(id string, output consensus.SiacoinOutput) (uint64, error)
// AddFileContract adds a file contract to a transaction.
AddFileContract(id string, fc consensus.FileContract) error
......
......@@ -16,7 +16,7 @@ import (
// wallet's spent counter, then it has been spent since the previous reset.
type knownOutput struct {
id consensus.OutputID
output consensus.Output
output consensus.SiacoinOutput
spendable bool
age int
......
......@@ -54,12 +54,12 @@ func (w *Wallet) FundTransaction(id string, amount consensus.Currency) error {
// Create and add all of the inputs.
for _, knownOutput := range knownOutputs {
key := w.keys[knownOutput.output.SpendHash]
newInput := consensus.Input{
newInput := consensus.SiacoinInput{
OutputID: knownOutput.id,
SpendConditions: key.spendConditions,
}
openTxn.inputs = append(openTxn.inputs, len(txn.Inputs))
txn.Inputs = append(txn.Inputs, newInput)
openTxn.inputs = append(openTxn.inputs, len(txn.SiacoinInputs))
txn.SiacoinInputs = append(txn.SiacoinInputs, newInput)
// Set the age of the knownOutput to prevent accidental double spends.
knownOutput.age = w.age
......@@ -72,9 +72,9 @@ func (w *Wallet) FundTransaction(id string, amount consensus.Currency) error {
return err
}
txn.Outputs = append(
txn.Outputs,
consensus.Output{
txn.SiacoinOutputs = append(
txn.SiacoinOutputs,
consensus.SiacoinOutput{
Value: total - amount,
SpendHash: coinAddress,
},
......@@ -100,7 +100,7 @@ func (w *Wallet) AddMinerFee(id string, fee consensus.Currency) error {
// AddOutput adds an output to the transaction, but will not add any inputs.
// It returns the index of the output in the transaction.
func (w *Wallet) AddOutput(id string, output consensus.Output) (index uint64, err error) {
func (w *Wallet) AddOutput(id string, output consensus.SiacoinOutput) (index uint64, err error) {
w.mu.Lock()
defer w.mu.Unlock()
......@@ -110,8 +110,8 @@ func (w *Wallet) AddOutput(id string, output consensus.Output) (index uint64, er
return
}
openTxn.transaction.Outputs = append(openTxn.transaction.Outputs, output)
index = uint64(len(openTxn.transaction.Outputs) - 1)
openTxn.transaction.SiacoinOutputs = append(openTxn.transaction.SiacoinOutputs, output)
index = uint64(len(openTxn.transaction.SiacoinOutputs) - 1)
return
}
......@@ -178,11 +178,11 @@ func (w *Wallet) SignTransaction(id string, wholeTransaction bool) (txn consensu
for i := range txn.MinerFees {
coveredFields.MinerFees = append(coveredFields.MinerFees, uint64(i))
}
for i := range txn.Inputs {
coveredFields.Inputs = append(coveredFields.Inputs, uint64(i))
for i := range txn.SiacoinInputs {
coveredFields.SiacoinInputs = append(coveredFields.SiacoinInputs, uint64(i))
}
for i := range txn.Outputs {
coveredFields.Outputs = append(coveredFields.Outputs, uint64(i))
for i := range txn.SiacoinOutputs {
coveredFields.SiacoinOutputs = append(coveredFields.SiacoinOutputs, uint64(i))
}
for i := range txn.FileContracts {
coveredFields.FileContracts = append(coveredFields.FileContracts, uint64(i))
......@@ -201,7 +201,7 @@ func (w *Wallet) SignTransaction(id string, wholeTransaction bool) (txn consensu
// For each input in the transaction that we added, provide a signature.
for _, inputIndex := range openTxn.inputs {
input := txn.Inputs[inputIndex]
input := txn.SiacoinInputs[inputIndex]
sig := consensus.TransactionSignature{
InputID: input.OutputID,
CoveredFields: coveredFields,
......
......@@ -94,7 +94,7 @@ func New(state *consensus.State, tpool modules.TransactionPool, filename string)
// is submitted to the miner pool, but is also returned.
func (w *Wallet) SpendCoins(amount consensus.Currency, dest consensus.CoinAddress) (t consensus.Transaction, err error) {
// Create and send the transaction.
output := consensus.Output{
output := consensus.SiacoinOutput{
Value: amount,
SpendHash: dest,
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment