-
Notifications
You must be signed in to change notification settings - Fork 3
/
s2s.go
46 lines (39 loc) · 1.04 KB
/
s2s.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"math"
"github.com/astaxie/beego/logs"
"github.com/btcsuite/btcd/wire"
)
func s2sTx(recursion bool) {
logs.Info("EXEC s2sTx(%t)", recursion)
for reference, amount := range input {
give := int(amount*math.Pow10(8)) - fee
// Discard this transaction if out value less than zero, so that
// fee rate is nearly equal to each other for pack into a block
// easily!
// if creating a transaction out value less than zero, the client
// will throw an error "-26: 16: bad-txns-vout-negative"
if give < 0 { // Top Priority exec for optimizing
continue
}
pkScript := getRandScriptPubKey()
if pkScript == nil {
panic("no account in output...")
}
out := wire.TxOut{
Value: int64(give),
PkScript: pkScript,
}
s2s.TxOut[0] = &out
txin := wire.TxIn{
PreviousOutPoint: wire.OutPoint{
Hash: reference.hash,
Index: reference.index,
},
Sequence: 0xffffff,
}
s2s.TxIn[0] = &txin
// no assignment for tx.LockTime(default 0)
signAndSendTx(s2s, []ref{reference}, 1, recursion)
}
}