// GetTx takes a txid and returns the transaction. If we have it. func (ts *TxStore) GetTx(txid *wire.ShaHash) (*wire.MsgTx, error) { rtx := wire.NewMsgTx() err := ts.StateDB.View(func(btx *bolt.Tx) error { txns := btx.Bucket(BKTTxns) if txns == nil { return fmt.Errorf("no transactions in db") } txbytes := txns.Get(txid.Bytes()) if txbytes == nil { return fmt.Errorf("tx %x not in db", txid.String()) } buf := bytes.NewBuffer(txbytes) return rtx.Deserialize(buf) }) if err != nil { return nil, err } return rtx, nil }
func RightSha(in wire.ShaHash) wire.ShaHash { return wire.DoubleSha256SH(append(in.Bytes(), 0x01)) // sha(sha(in, 1)) }
func LeftSha(in wire.ShaHash) wire.ShaHash { return wire.DoubleSha256SH(in.Bytes()) // left is sha(sha(in)) }