diff --git a/modules/host/negotiateformcontract.go b/modules/host/negotiateformcontract.go index 3be8ac980a..4e6a01e843 100644 --- a/modules/host/negotiateformcontract.go +++ b/modules/host/negotiateformcontract.go @@ -29,11 +29,11 @@ func contractCollateral(settings modules.HostExternalSettings, fc types.FileCont } // managedAddCollateral adds the host's collateral to the file contract -// transaction set, returning the new inputs and outputs that get added to the +// transaction set, returning the new inputs that get added to the // transaction, as well as any new parents that get added to the transaction // set. The builder that is used to add the collateral is also returned, // because the new transaction has not yet been signed. -func (h *Host) managedAddCollateral(settings modules.HostExternalSettings, txnSet []types.Transaction) (builder modules.TransactionBuilder, newParents []types.Transaction, newInputs []types.SiacoinInput, newOutputs []types.SiacoinOutput, err error) { +func (h *Host) managedAddCollateral(settings modules.HostExternalSettings, txnSet []types.Transaction) (builder modules.TransactionBuilder, newParents []types.Transaction, newInputs []types.SiacoinInput, err error) { txn := txnSet[len(txnSet)-1] parents := txnSet[:len(txnSet)-1] fc := txn.FileContracts[0] @@ -45,11 +45,11 @@ func (h *Host) managedAddCollateral(settings modules.HostExternalSettings, txnSe err = builder.FundSiacoins(hostPortion) if err != nil { builder.Drop() - return nil, nil, nil, nil, extendErr("could not add collateral: ", ErrorInternal(err.Error())) + return nil, nil, nil, extendErr("could not add collateral: ", ErrorInternal(err.Error())) } // Return which inputs and outputs have been added by the collateral call. - newParentIndices, newInputIndices, newOutputIndices, _ := builder.ViewAdded() + newParentIndices, newInputIndices, _, _ := builder.ViewAdded() updatedTxn, updatedParents := builder.View() for _, parentIndex := range newParentIndices { newParents = append(newParents, updatedParents[parentIndex]) @@ -57,10 +57,7 @@ func (h *Host) managedAddCollateral(settings modules.HostExternalSettings, txnSe for _, inputIndex := range newInputIndices { newInputs = append(newInputs, updatedTxn.SiacoinInputs[inputIndex]) } - for _, outputIndex := range newOutputIndices { - newOutputs = append(newOutputs, updatedTxn.SiacoinOutputs[outputIndex]) - } - return builder, newParents, newInputs, newOutputs, nil + return builder, newParents, newInputs, nil } // managedRPCFormContract accepts a file contract from a renter, checks the @@ -119,13 +116,13 @@ func (h *Host) managedRPCFormContract(conn net.Conn) error { return extendErr("contract verification failed: ", err) } // The host adds collateral to the transaction. - txnBuilder, newParents, newInputs, newOutputs, err := h.managedAddCollateral(settings, txnSet) + txnBuilder, newParents, newInputs, err := h.managedAddCollateral(settings, txnSet) if err != nil { modules.WriteNegotiationRejection(conn, err) // Error ignored to preserve type in extendErr return extendErr("failed to add collateral: ", err) } // The host indicates acceptance, and then sends any new parent - // transactions, inputs and outputs that were added to the transaction. + // transactions and inputs that were added to the transaction. err = modules.WriteNegotiationAcceptance(conn) if err != nil { return extendErr("accepting verified contract failed: ", ErrorConnection(err.Error())) @@ -138,10 +135,6 @@ func (h *Host) managedRPCFormContract(conn net.Conn) error { if err != nil { return extendErr("failed to write new inputs: ", ErrorConnection(err.Error())) } - err = encoding.WriteObject(conn, newOutputs) - if err != nil { - return extendErr("failed to write new outputs: ", ErrorConnection(err.Error())) - } // The renter will now send a negotiation response, followed by transaction // signatures for the file contract transaction in the case of acceptance. diff --git a/modules/host/negotiaterenewcontract.go b/modules/host/negotiaterenewcontract.go index e2eb51344c..b04ff2f511 100644 --- a/modules/host/negotiaterenewcontract.go +++ b/modules/host/negotiaterenewcontract.go @@ -46,7 +46,7 @@ func renewContractCollateral(so storageObligation, settings modules.HostExternal // managedAddRenewCollateral adds the host's collateral to the renewed file // contract. -func (h *Host) managedAddRenewCollateral(so storageObligation, settings modules.HostExternalSettings, txnSet []types.Transaction) (builder modules.TransactionBuilder, newParents []types.Transaction, newInputs []types.SiacoinInput, newOutputs []types.SiacoinOutput, err error) { +func (h *Host) managedAddRenewCollateral(so storageObligation, settings modules.HostExternalSettings, txnSet []types.Transaction) (builder modules.TransactionBuilder, newParents []types.Transaction, newInputs []types.SiacoinInput, err error) { txn := txnSet[len(txnSet)-1] parents := txnSet[:len(txnSet)-1] fc := txn.FileContracts[0] @@ -58,11 +58,11 @@ func (h *Host) managedAddRenewCollateral(so storageObligation, settings modules. err = builder.FundSiacoins(hostPortion) if err != nil { builder.Drop() - return nil, nil, nil, nil, extendErr("could not add collateral: ", ErrorInternal(err.Error())) + return nil, nil, nil, extendErr("could not add collateral: ", ErrorInternal(err.Error())) } - // Return which inputs and outputs have been added by the collateral call. - newParentIndices, newInputIndices, newOutputIndices, _ := builder.ViewAdded() + // Return which inputs have been added by the collateral call. + newParentIndices, newInputIndices, _, _ := builder.ViewAdded() updatedTxn, updatedParents := builder.View() for _, parentIndex := range newParentIndices { newParents = append(newParents, updatedParents[parentIndex]) @@ -70,10 +70,7 @@ func (h *Host) managedAddRenewCollateral(so storageObligation, settings modules. for _, inputIndex := range newInputIndices { newInputs = append(newInputs, updatedTxn.SiacoinInputs[inputIndex]) } - for _, outputIndex := range newOutputIndices { - newOutputs = append(newOutputs, updatedTxn.SiacoinOutputs[outputIndex]) - } - return builder, newParents, newInputs, newOutputs, nil + return builder, newParents, newInputs, nil } // managedRenewContract accepts a request to renew a file contract. @@ -131,13 +128,13 @@ func (h *Host) managedRPCRenewContract(conn net.Conn) error { modules.WriteNegotiationRejection(conn, err) // Error is ignored to preserve type for extendErr return extendErr("verification of renewal failed: ", err) } - txnBuilder, newParents, newInputs, newOutputs, err := h.managedAddRenewCollateral(so, settings, txnSet) + txnBuilder, newParents, newInputs, err := h.managedAddRenewCollateral(so, settings, txnSet) if err != nil { modules.WriteNegotiationRejection(conn, err) // Error is ignored to preserve type for extendErr return extendErr("failed to add collateral: ", err) } - // The host indicates acceptance, then sends the new parents, inputs, and - // outputs to the transaction. + // The host indicates acceptance, then sends the new parents and inputs to + // the transaction. err = modules.WriteNegotiationAcceptance(conn) if err != nil { return extendErr("failed to write acceptance: ", ErrorConnection(err.Error())) @@ -150,10 +147,6 @@ func (h *Host) managedRPCRenewContract(conn net.Conn) error { if err != nil { return extendErr("failed to write new inputs: ", ErrorConnection(err.Error())) } - err = encoding.WriteObject(conn, newOutputs) - if err != nil { - return extendErr("failed to write new outputs: ", ErrorConnection(err.Error())) - } // The renter will send a negotiation response, followed by transaction // signatures for the file contract transaction in the case of acceptance. diff --git a/modules/renter/proto/formcontract.go b/modules/renter/proto/formcontract.go index 7d93548139..8d1fdc0cde 100644 --- a/modules/renter/proto/formcontract.go +++ b/modules/renter/proto/formcontract.go @@ -163,25 +163,18 @@ func (cs *ContractSet) FormContract(params ContractParams, txnBuilder transactio // were added to the transaction. var newParents []types.Transaction var newInputs []types.SiacoinInput - var newOutputs []types.SiacoinOutput if err = encoding.ReadObject(conn, &newParents, types.BlockSizeLimit); err != nil { return modules.RenterContract{}, errors.New("couldn't read the host's added parents: " + err.Error()) } if err = encoding.ReadObject(conn, &newInputs, types.BlockSizeLimit); err != nil { return modules.RenterContract{}, errors.New("couldn't read the host's added inputs: " + err.Error()) } - if err = encoding.ReadObject(conn, &newOutputs, types.BlockSizeLimit); err != nil { - return modules.RenterContract{}, errors.New("couldn't read the host's added outputs: " + err.Error()) - } // Merge txnAdditions with txnSet. txnBuilder.AddParents(newParents) for _, input := range newInputs { txnBuilder.AddSiacoinInput(input) } - for _, output := range newOutputs { - txnBuilder.AddSiacoinOutput(output) - } // Sign the txn. signedTxnSet, err := txnBuilder.Sign(true) diff --git a/modules/renter/proto/renew.go b/modules/renter/proto/renew.go index d7507fbc19..c8ed429d2e 100644 --- a/modules/renter/proto/renew.go +++ b/modules/renter/proto/renew.go @@ -166,29 +166,22 @@ func (cs *ContractSet) Renew(oldContract *SafeContract, params ContractParams, t if err = modules.ReadNegotiationAcceptance(conn); err != nil { return modules.RenterContract{}, errors.New("host did not accept our proposed contract: " + err.Error()) } - // host now sends any new parent transactions, inputs and outputs that + // host now sends any new parent transactions and inputs that // were added to the transaction var newParents []types.Transaction var newInputs []types.SiacoinInput - var newOutputs []types.SiacoinOutput if err = encoding.ReadObject(conn, &newParents, types.BlockSizeLimit); err != nil { return modules.RenterContract{}, errors.New("couldn't read the host's added parents: " + err.Error()) } if err = encoding.ReadObject(conn, &newInputs, types.BlockSizeLimit); err != nil { return modules.RenterContract{}, errors.New("couldn't read the host's added inputs: " + err.Error()) } - if err = encoding.ReadObject(conn, &newOutputs, types.BlockSizeLimit); err != nil { - return modules.RenterContract{}, errors.New("couldn't read the host's added outputs: " + err.Error()) - } // merge txnAdditions with txnSet txnBuilder.AddParents(newParents) for _, input := range newInputs { txnBuilder.AddSiacoinInput(input) } - for _, output := range newOutputs { - txnBuilder.AddSiacoinOutput(output) - } // sign the txn signedTxnSet, err := txnBuilder.Sign(true)