wallets
This commit is contained in:
9 files changed
+396
-162
No files matched your search
@@ -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
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
Reference in new issue
Block a user