This commit is contained in:
SowinskiBraeden committed 2022-12-12 09:19:55 -08:00
1 parent 9e6d5d4def
commit a77d1d9c74
9 files changed
+396 -162

No files matched your search

-19
View File
@@ -15,17 +15,6 @@ type Transaction struct {
Outputs []TxOutput
}
type TxOutput struct {
Value int
PubKey string
}
type TxInput struct {
ID []byte
Out int
Sig string
}
func (tx *Transaction) SetID() {
var encoded bytes.Buffer
var hash [32]byte
@@ -87,11 +76,3 @@ func NewTransaction(from, to string, amount int, chain *BlockChain) *Transaction
func (tx *Transaction) IsCoinbase() bool {
return len(tx.Inputs) == 1 && len(tx.Inputs[0].ID) == 0 && tx.Inputs[0].Out == -1
}
func (in *TxInput) CanUnlock(data string) bool {
return in.Sig == data
}
func (out *TxOutput) CanBeUnlocked(data string) bool {
return out.PubKey == data
}
+20
View File
@@ -0,0 +1,20 @@
package blockchain
type TxOutput struct {
Value int
PubKey string
}
type TxInput struct {
ID []byte
Out int
Sig string
}
func (in *TxInput) CanUnlock(data string) bool {
return in.Sig == data
}
func (out *TxOutput) CanBeUnlocked(data string) bool {
return out.PubKey == data
}