Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Commit

Permalink
Merge pull request #159 from lukechampine:hardfork
Browse files Browse the repository at this point in the history
wallet: Update txn signatures for Foundation hardfork
  • Loading branch information
Goober the Friendly Robutt committed Feb 3, 2021
2 parents 3e9f269 + eb857cf commit eb7b110
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 28 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ require (
filippo.io/edwards25519 v1.0.0-beta.2
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da
github.com/pkg/errors v0.9.1
gitlab.com/NebulousLabs/Sia v1.5.0
gitlab.com/NebulousLabs/Sia v1.5.4
gitlab.com/NebulousLabs/encoding v0.0.0-20200604091946-456c3dc907fe
gitlab.com/NebulousLabs/log v0.0.0-20200604091839-0ba4a941cdc2
gitlab.com/NebulousLabs/siamux v0.0.0-20200723083235-f2c35a421446 // for testing mux compatibility
gitlab.com/NebulousLabs/siamux v0.0.0-20201105164950-869a9dc7edcf // for testing mux compatibility
go.etcd.io/bbolt v1.3.5
golang.org/x/crypto v0.0.0-20200709230013-948cd5f35899
golang.org/x/sys v0.0.0-20200831180312-196b9ba8737a
Expand Down
8 changes: 8 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ gitlab.com/NebulousLabs/Sia v1.4.8 h1:NBBawRM0JvyD1Z1jB5er+4byrQ9B8jpqE7kfNbOHw2
gitlab.com/NebulousLabs/Sia v1.4.8/go.mod h1:AlAQ634YMvZ040N8ffji8u0oZdFLzlzs0ogUzIZ7Thg=
gitlab.com/NebulousLabs/Sia v1.5.0 h1:rmxUeEu07ODFdmwdcZJFA83Fv4EQs/CYjmn6RVw7OWk=
gitlab.com/NebulousLabs/Sia v1.5.0/go.mod h1:dcWW1yClYDu/v10Q/ujNX290kg9WrnU2/sZere4IRP4=
gitlab.com/NebulousLabs/Sia v1.5.4 h1:7+j8Z5BZLPn/LGF0dCODwr1Nq+AYD5cOjopK2PhYTew=
gitlab.com/NebulousLabs/Sia v1.5.4/go.mod h1:NN77/QIB1opjhFQ9ZxPKg4HqRPUQLiu6YXBHRIyRR1g=
gitlab.com/NebulousLabs/bolt v1.4.0 h1:6sfFp1YQtGWbSLLYoH8+0h3EtFRGbsp07L3uZNChdE0=
gitlab.com/NebulousLabs/bolt v1.4.0/go.mod h1:72gB2R0hTcUU2Ih7mBpHF0jJlIldSyPzG1cuwz1uYJY=
gitlab.com/NebulousLabs/bolt v1.4.4 h1:3UhpR2qtHs87dJBE3CIzhw48GYSoUUNByJmic0cbu1w=
Expand All @@ -152,6 +154,8 @@ gitlab.com/NebulousLabs/entropy-mnemonics v0.0.0-20181018051301-7532f67e3500 h1:
gitlab.com/NebulousLabs/entropy-mnemonics v0.0.0-20181018051301-7532f67e3500/go.mod h1:4koft3fRXTETovKPTeX/Aggj+ajCGWCcuuBBc598Pcs=
gitlab.com/NebulousLabs/errors v0.0.0-20171229012116-7ead97ef90b8 h1:gZfMjx7Jr6N8b7iJO4eUjDsn6xJqoyXg8D+ogdoAfKY=
gitlab.com/NebulousLabs/errors v0.0.0-20171229012116-7ead97ef90b8/go.mod h1:ZkMZ0dpQyWwlENaeZVBiQRjhMEZvk6VTXquzl3FOFP8=
gitlab.com/NebulousLabs/errors v0.0.0-20200929122200-06c536cf6975 h1:L/ENs/Ar1bFzUeKx6m3XjlmBgIUlykX9dzvp5k9NGxc=
gitlab.com/NebulousLabs/errors v0.0.0-20200929122200-06c536cf6975/go.mod h1:ZkMZ0dpQyWwlENaeZVBiQRjhMEZvk6VTXquzl3FOFP8=
gitlab.com/NebulousLabs/fastrand v0.0.0-20181126182046-603482d69e40 h1:dizWJqTWjwyD8KGcMOwgrkqu1JIkofYgKkmDeNE7oAs=
gitlab.com/NebulousLabs/fastrand v0.0.0-20181126182046-603482d69e40/go.mod h1:rOnSnoRyxMI3fe/7KIbVcsHRGxe30OONv8dEgo+vCfA=
gitlab.com/NebulousLabs/go-upnp v0.0.0-20181011194642-3a71999ed0d3 h1:qXqiXDgeQxspR3reot1pWme00CX1pXbxesdzND+EjbU=
Expand All @@ -173,10 +177,14 @@ gitlab.com/NebulousLabs/ratelimit v0.0.0-20191111145210-66b93e150b27 h1:G8v2awvH
gitlab.com/NebulousLabs/ratelimit v0.0.0-20191111145210-66b93e150b27/go.mod h1:hvNy5sMP9gGrNQ7kNgb+vWuiPptqTk4W45bQbbT/vmg=
gitlab.com/NebulousLabs/ratelimit v0.0.0-20200703092634-24a64284c0ec h1:+FlF7OO7h81SPLkx9wpDAnnTbLiTL5izb9gldkbW/MQ=
gitlab.com/NebulousLabs/ratelimit v0.0.0-20200703092634-24a64284c0ec/go.mod h1:hvNy5sMP9gGrNQ7kNgb+vWuiPptqTk4W45bQbbT/vmg=
gitlab.com/NebulousLabs/ratelimit v0.0.0-20200811080431-99b8f0768b2e h1:sMZdmPFduUilFk8Ed1Ya/DP0gVfUbGhLlNtLG2tONYk=
gitlab.com/NebulousLabs/ratelimit v0.0.0-20200811080431-99b8f0768b2e/go.mod h1:HVrehlTxX2hYjsrL1k0WK43OZ0NGZfGvqzPL+n0/zrM=
gitlab.com/NebulousLabs/siamux v0.0.0-20200511155832-64a7ac68c8ab h1:NUCtCUgbRosZfCOJ3v27O5GmEnK8+fXAyx3J1SEfHrE=
gitlab.com/NebulousLabs/siamux v0.0.0-20200511155832-64a7ac68c8ab/go.mod h1:oaTSN0KXMgdNRKLg0CVH1vuZB2NcsmkngWf2pYK0N1Y=
gitlab.com/NebulousLabs/siamux v0.0.0-20200723083235-f2c35a421446 h1:Vs6RMOAK6EKL/i4CZysNKkev36/ziM18E8GKyKrIeIY=
gitlab.com/NebulousLabs/siamux v0.0.0-20200723083235-f2c35a421446/go.mod h1:B0RyynPElUG2Y2CAVIIRriIqR9qht2I+nDisi3gfKn0=
gitlab.com/NebulousLabs/siamux v0.0.0-20201105164950-869a9dc7edcf h1:LdIti1+B0guIKJXdOVu0nkK4vRsRiwdt+xyjUI+9c50=
gitlab.com/NebulousLabs/siamux v0.0.0-20201105164950-869a9dc7edcf/go.mod h1:B0RyynPElUG2Y2CAVIIRriIqR9qht2I+nDisi3gfKn0=
gitlab.com/NebulousLabs/threadgroup v0.0.0-20180716154133-88a11db9e46c h1:psW9YBmnyKKCddPncr7mwJCx6n7FzlIs1EWIiSo7fyQ=
gitlab.com/NebulousLabs/threadgroup v0.0.0-20180716154133-88a11db9e46c/go.mod h1:w05nvlkvHlk3Vfc7mcU29Toic1X0BcYUnKoTHS0ea2Y=
gitlab.com/NebulousLabs/threadgroup v0.0.0-20200527092543-afa01960408c/go.mod h1:av52iTyGuPtGU+GMcqfGtZu2vxhIjPgrxvIwVYelEvs=
Expand Down
2 changes: 1 addition & 1 deletion wallet/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func FundTransaction(amount, feePerByte types.Currency, inputs []ValuedInput) (u
func AppendTransactionSignature(txn *types.Transaction, txnSig types.TransactionSignature, key ed25519.PrivateKey) {
txn.TransactionSignatures = append(txn.TransactionSignatures, txnSig)
sigIndex := len(txn.TransactionSignatures) - 1
txn.TransactionSignatures[sigIndex].Signature = ed25519hash.Sign(key, txn.SigHash(sigIndex, types.ASICHardforkHeight+1))
txn.TransactionSignatures[sigIndex].Signature = ed25519hash.Sign(key, txn.SigHash(sigIndex, types.FoundationHardforkHeight+1))
}

// UnconfirmedParents returns the parents of txn that are in limbo.
Expand Down
2 changes: 1 addition & 1 deletion wallet/seedwallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ func (w *HotWallet) SignTransaction(txn *types.Transaction, toSign []crypto.Hash
return errors.New("can't sign")
}
sk := w.seed.SecretKey(info.KeyIndex)
txn.TransactionSignatures[i].Signature = ed25519hash.Sign(sk, txn.SigHash(i, types.ASICHardforkHeight+1))
txn.TransactionSignatures[i].Signature = ed25519hash.Sign(sk, txn.SigHash(i, types.FoundationHardforkHeight+1))
return nil
}

Expand Down
56 changes: 32 additions & 24 deletions wallet/seedwallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ func (m *mockCS) sendTxn(txn types.Transaction) {
AppliedBlocks: []types.Block{{
Transactions: []types.Transaction{txn},
}},
SiacoinOutputDiffs: outputs,
ID: frand.Entropy256(),
ConsensusChangeDiffs: modules.ConsensusChangeDiffs{
SiacoinOutputDiffs: outputs,
},
ID: frand.Entropy256(),
}
m.subscriber.ProcessConsensusChange(cc)
m.height++
Expand All @@ -58,11 +60,13 @@ func (m *mockCS) mineBlock(fees types.Currency, addr types.UnlockHash) {
b.MinerPayouts[0].Value = b.CalculateSubsidy(0)
cc := modules.ConsensusChange{
AppliedBlocks: []types.Block{b},
DelayedSiacoinOutputDiffs: []modules.DelayedSiacoinOutputDiff{{
SiacoinOutput: b.MinerPayouts[0],
ID: b.MinerPayoutID(0),
MaturityHeight: types.MaturityDelay,
}},
ConsensusChangeDiffs: modules.ConsensusChangeDiffs{
DelayedSiacoinOutputDiffs: []modules.DelayedSiacoinOutputDiff{{
SiacoinOutput: b.MinerPayouts[0],
ID: b.MinerPayoutID(0),
MaturityHeight: types.MaturityDelay,
}},
},
ID: frand.Entropy256(),
}
for _, dsco := range m.dscos[m.height] {
Expand Down Expand Up @@ -99,11 +103,13 @@ func (m *mockCS) formContract(payout types.Currency, addr types.UnlockHash) {
}
cc := modules.ConsensusChange{
AppliedBlocks: []types.Block{b},
FileContractDiffs: []modules.FileContractDiff{{
FileContract: b.Transactions[0].FileContracts[0],
ID: b.Transactions[0].FileContractID(0),
Direction: modules.DiffApply,
}},
ConsensusChangeDiffs: modules.ConsensusChangeDiffs{
FileContractDiffs: []modules.FileContractDiff{{
FileContract: b.Transactions[0].FileContracts[0],
ID: b.Transactions[0].FileContractID(0),
Direction: modules.DiffApply,
}},
},
ID: frand.Entropy256(),
}
m.subscriber.ProcessConsensusChange(cc)
Expand Down Expand Up @@ -139,16 +145,18 @@ func (m *mockCS) reviseContract(id types.FileContractID) {
}
cc := modules.ConsensusChange{
AppliedBlocks: []types.Block{b},
FileContractDiffs: []modules.FileContractDiff{
{
FileContract: m.filecontracts[id],
ID: id,
Direction: modules.DiffRevert,
},
{
FileContract: fc,
ID: id,
Direction: modules.DiffApply,
ConsensusChangeDiffs: modules.ConsensusChangeDiffs{
FileContractDiffs: []modules.FileContractDiff{
{
FileContract: m.filecontracts[id],
ID: id,
Direction: modules.DiffRevert,
},
{
FileContract: fc,
ID: id,
Direction: modules.DiffApply,
},
},
},
ID: frand.Entropy256(),
Expand Down Expand Up @@ -299,7 +307,7 @@ func TestWallet(t *testing.T) {
txnSig := StandardTransactionSignature(crypto.Hash(sci.ParentID))
AppendTransactionSignature(&txn, txnSig, seed.SecretKey(0))
}
if err := txn.StandaloneValid(types.ASICHardforkHeight + 1); err != nil {
if err := txn.StandaloneValid(types.FoundationHardforkHeight + 1); err != nil {
t.Fatal(err)
}

Expand Down Expand Up @@ -503,7 +511,7 @@ func TestHotWallet(t *testing.T) {
// sign the transaction
if err := w.SignTransaction(&txn, nil); err != nil {
t.Fatal(err)
} else if err := txn.StandaloneValid(types.ASICHardforkHeight + 1); err != nil {
} else if err := txn.StandaloneValid(types.FoundationHardforkHeight + 1); err != nil {
t.Fatal(err)
}
// simulate broadcasting by putting the transaction in limbo
Expand Down

0 comments on commit eb7b110

Please sign in to comment.