35 lines
678 B
Go
35 lines
678 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
)
|
||
|
|
||
|
type transaction struct {
|
||
|
inputs [1]txIn
|
||
|
outputs [1]txOut
|
||
|
}
|
||
|
|
||
|
type txIn struct {
|
||
|
prev_hash string
|
||
|
prev_index int
|
||
|
script_sig string // for now, just assume "script_sig" will be "public-key" (i.e., integer value) of recipient
|
||
|
sequence_no int
|
||
|
}
|
||
|
|
||
|
type txOut struct {
|
||
|
value int
|
||
|
script_pub_key string // for now, just assume "script_pub_key" needs to just equal script_sig
|
||
|
}
|
||
|
|
||
|
func makeTxn(pubkey string, privkey string, value int) transaction {
|
||
|
var ins [1]txIn
|
||
|
var outs [1]txOut
|
||
|
|
||
|
ins[0] = txIn{script_sig: pubkey}
|
||
|
outs[0] = txOut{value: value, script_pub_key: privkey}
|
||
|
|
||
|
return transaction {
|
||
|
inputs: ins,
|
||
|
outputs: outs,
|
||
|
}
|
||
|
}
|