func (a *AuctionOrder) GenerateOrderFill(orderID *OrderID, execPrice float64) (orderExec OrderExecution, setExecs []*SettlementExecution, err error) {
	if a.AmountHave == 0 {
		err = fmt.Errorf("Error generating order fill: empty order, the AmountHave cannot be 0")
		return
	}
	if execPrice == float64(0) {
		err = fmt.Errorf("Error generating order fill: price cannot be zero")
		return
	}
	var amountToDebit uint64
	var debitAsset Asset
	var creditAsset Asset
	if a.IsBuySide() {
		debitAsset = a.TradingPair.AssetWant
		creditAsset = a.TradingPair.AssetHave
	} else if a.IsSellSide() {
		debitAsset = a.TradingPair.AssetHave
		creditAsset = a.TradingPair.AssetWant
	} else {
		err = fmt.Errorf("Error generating order fill from price, order is not buy or sell side, it's %s side", a.Side.String())
		return
	}
	amountToDebit = uint64(float64(a.AmountHave) * execPrice)
	orderExec = OrderExecution{
		OrderID:       *orderID,
		NewAmountWant: 0,
		NewAmountHave: 0,
		Filled:        true,
	}
	debitSetExec := SettlementExecution{
		Amount: amountToDebit,
		Asset:  debitAsset,
		Type:   Debit,
	}
	creditSetExec := SettlementExecution{
		Amount: a.AmountHave,
		Asset:  creditAsset,
		Type:   Credit,
	}
	copy(debitSetExec.Pubkey[:], a.Pubkey[:])
	copy(creditSetExec.Pubkey[:], a.Pubkey[:])
	setExecs = append(setExecs, &debitSetExec)
	setExecs = append(setExecs, &creditSetExec)
	return
}
GenerateOrderFill creates an execution that will fill an order (AmountHave at the end is 0) and provides an order and settlement execution.
This does not assume anything about the price of the order, as we can't infer what price the order was
placed at.
TODO: Figure out whether or not these should be pointers
package match
import (
	"encoding/binary"
	"encoding/json"
	"fmt"
	"github.com/mit-dci/opencx/crypto/timelockencoders"
)
type OrderPuzzleResult struct {
	Encrypted *EncryptedAuctionOrder
	Auction   *AuctionOrder
	Err       error
}
type AuctionOrder struct {
	Pubkey      [33]byte `json:"pubkey"`
	Side        Side     `json:"side"`
	TradingPair Pair     `json:"pair"`
	AmountHave uint64 `json:"amounthave"`
	AmountWant uint64 `json:"amountwant"`
	AuctionID AuctionID `json:"auctionid"`
	Nonce     [2]byte `json:"nonce"`
	Signature []byte  `json:"signature"`
}
func (a *AuctionOrder) TurnIntoEncryptedOrder(t uint64) (encrypted *EncryptedAuctionOrder, err error) {
	encrypted = new(EncryptedAuctionOrder)
	if encrypted.OrderCiphertext, encrypted.OrderPuzzle, err = timelockencoders.CreateRSW2048A2PuzzleRC5(t, a.Serialize()); err != nil {
		err = fmt.Errorf("Error creating puzzle from auction order: %s", err)
		return
	}
	encrypted.IntendedAuction = a.AuctionID
	encrypted.IntendedPair = a.TradingPair
	return
}
func (a *AuctionOrder) IsBuySide() bool {
	return a.Side == Buy
}
func (a *AuctionOrder) IsSellSide() bool {
	return a.Side == Sell
}
func (a *AuctionOrder) OppositeSide() (sideStr Side) {
	if a.IsBuySide() {
		sideStr = Sell
	} else if a.IsSellSide() {
		sideStr = Buy
	}
	return
}
func (a *AuctionOrder) Price() (price float64, err error) {
	if a.AmountWant == 0 || a.AmountHave == 0 {
		err = fmt.Errorf("The amount requested in the order is 0, so no price can be calculated")
		return
	}
	price = float64(a.AmountWant) / float64(a.AmountHave)
	return
}