func addBlock(bc historydb.Blockchainer, td testData, tm uint64) (*coin.Block, *coin.Transaction, error) { tx := coin.Transaction{} // get unspent output ux, err := getUx(bc, td.Vin.BlockSeq, td.Vin.TxID, td.Vin.Addr) if err != nil { return nil, nil, err } if ux == nil { return nil, nil, errors.New("no unspent output") } tx.PushInput(ux.Hash()) for _, o := range td.Vouts { addr, err := cipher.DecodeBase58Address(o.ToAddr) if err != nil { return nil, nil, err } tx.PushOutput(addr, o.Coins, o.Hours) } sigKey := cipher.MustSecKeyFromHex(td.Vin.SigKey) tx.SignInputs([]cipher.SecKey{sigKey}) tx.UpdateHeader() if err := bc.VerifyTransaction(tx); err != nil { return nil, nil, err } preBlock := bc.GetBlock(td.PreBlockHash) b := newBlock(*preBlock, tm, *bc.GetUnspent(), coin.Transactions{tx}, _feeCalc) // uxs, err := bc.ExecuteBlock(&b) _, err = bc.ExecuteBlock(&b) if err != nil { return nil, nil, err } return &b, &tx, nil }