2019-08-09 21:41:50 +00:00
|
|
|
package types
|
|
|
|
|
2020-02-28 18:06:59 +00:00
|
|
|
import (
|
2019-08-13 04:27:54 +00:00
|
|
|
"encoding/base64"
|
|
|
|
|
2020-02-12 23:52:36 +00:00
|
|
|
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
|
2019-08-09 21:41:50 +00:00
|
|
|
cbor "github.com/ipfs/go-ipld-cbor"
|
|
|
|
)
|
|
|
|
|
2020-02-25 21:09:22 +00:00
|
|
|
func DecodeSignedVoucher(s string) (*paych.SignedVoucher, error) {
|
2019-08-13 04:27:54 +00:00
|
|
|
data, err := base64.RawURLEncoding.DecodeString(s)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2020-02-25 21:09:22 +00:00
|
|
|
var sv paych.SignedVoucher
|
2019-08-13 04:27:54 +00:00
|
|
|
if err := cbor.DecodeInto(data, &sv); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &sv, nil
|
|
|
|
}
|