func NewPsetFromHex(psetHex string) (*Pset, error) {
	psetBytes, err := hex.DecodeString(psetHex)
	if err != nil {
		return nil, err
	}
	r := bytes.NewReader(psetBytes)
	return deserialize(r)
}
NewPsetFromHex returns a new Pset from serialized pset in hex encoiding.
package pset
import (
	"bytes"
	"encoding/base64"
	"encoding/hex"
	"errors"
	"io"
	"strings"
	"github.com/btcsuite/btcd/btcec"
	"github.com/btcsuite/btcd/txscript"
	"github.com/btcsuite/btcd/wire"
	"github.com/btcsuite/btcutil/psbt"
	"github.com/vulpemventures/go-elements/address"
	"github.com/vulpemventures/go-elements/payment"
	"github.com/vulpemventures/go-elements/transaction"
)
const psbtMagicLength = 5
var (
	psbtMagic = [psbtMagicLength]byte{0x70,
		0x73, 0x65, 0x74, 0xff,  
	}
)
type Unknown struct {
	Key   []byte
	Value []byte
}
type Pset struct {
	UnsignedTx *transaction.Transaction
	Inputs []PInput
	Outputs []POutput
	Unknowns []Unknown  
}
func validateUnsignedTX(tx *transaction.Transaction) bool {
	for _, tin := range tx.Inputs {
		if len(tin.Script) != 0 || len(tin.Witness) != 0 {
			return false
		}
	}
	return true
}
func deserialize(r io.Reader) (*Pset, error) {
	var magic [5]byte
	if _, err := io.ReadFull(r, magic[:]); err != nil {
		return nil, err
	}
	if magic != psbtMagic {
		return nil, psbt.ErrInvalidMagicBytes
	}
	keyint, keydata, err := getKey(r)
	if err != nil {
		return nil, err
	}
	if psbt.GlobalType(keyint) != psbt.UnsignedTxType || keydata != nil {
		return nil, psbt.ErrInvalidPsbtFormat
	}
	value, err := wire.ReadVarBytes(
		r, 0, psbt.MaxPsbtValueLength, "PSET value",
	)
	if err != nil {
		return nil, err
	}
	msgTx, err := transaction.NewTxFromBuffer(bytes.NewBuffer(value))
	if err != nil {
		return nil, err
	}
	if !validateUnsignedTX(msgTx) {
		return nil, psbt.ErrInvalidRawTxSigned
	}
	var unknownSlice []Unknown
	for {
		keyint, keydata, err := getKey(r)
		if err != nil {
			return nil, psbt.ErrInvalidPsbtFormat
		}
		if keyint == -1 {
			break
		}
		value, err := wire.ReadVarBytes(
			r, 0, psbt.MaxPsbtValueLength, "PSET value",
		)
		if err != nil {
			return nil, err
		}
		keyintanddata := []byte{byte(keyint)}
		keyintanddata = append(keyintanddata, keydata...)
		newUnknown := Unknown{
			Key:   keyintanddata,
			Value: value,
		}
		unknownSlice = append(unknownSlice, newUnknown)
	}
	inSlice := make([]PInput, len(msgTx.Inputs))
	for i := range msgTx.Inputs {
		input := PInput{}
		err = input.deserialize(r)
		if err != nil {
			return nil, err
		}
		inSlice[i] = input
	}
	outSlice := make([]POutput, len(msgTx.Outputs))
	for i := range msgTx.Outputs {
		output := POutput{}
		err = output.deserialize(r)
		if err != nil {
			return nil, err
		}
		outSlice[i] = output
	}
	newPset := Pset{
		UnsignedTx: msgTx,
		Inputs:     inSlice,
		Outputs:    outSlice,
		Unknowns:   unknownSlice,
	}
	if err = newPset.SanityCheck(); err != nil {
		return nil, err
	}
	return &newPset, nil
}
func NewPsetFromUnsignedTx(tx *transaction.Transaction) (*Pset, error) {
	if !validateUnsignedTX(tx) {
		return nil, psbt.ErrInvalidRawTxSigned
	}
	inSlice := make([]PInput, len(tx.Inputs))
	outSlice := make([]POutput, len(tx.Outputs))
	unknownSlice := make([]Unknown, 0)
	retPset := Pset{
		UnsignedTx: tx,
		Inputs:     inSlice,
		Outputs:    outSlice,
		Unknowns:   unknownSlice,
	}
	return &retPset, nil
}