Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //JS code
- const {Transaction} = require('stellar-base')
- const parsedTx = new Transaction('tx_envelope_encoded_as_XDR')
- console.log(parsedTx)
- //GO code
- import (
- "bytes"
- "encoding/json"
- "fmt"
- "net/http"
- "github.com/stellar/go/xdr"
- "github.com/gorilla/mux"
- )
- func DecodeXDR(w http.ResponseWriter, r *http.Request) {
- var OBJ model.TransactionCollectionBody
- err := json.NewDecoder(r.Body).Decode(&OBJ)
- if err != nil {
- w.WriteHeader(http.StatusBadRequest)
- json.NewEncoder(w).Encode("Error while Decoding the body")
- fmt.Println(err)
- return
- }
- // fmt.Println(OBJ)
- // lol:=xdr.Value(OBJ.XDR)
- var txe xdr.Transaction
- err = xdr.SafeUnmarshalBase64(XDRB64, &txe)
- if err != nil {
- fmt.Println(err)
- }
- fmt.Println(txe)
- //Output
- {{PublicKeyTypePublicKeyTypeEd25519 0xc042055d20} 200 2800572080062465 <nil> {MemoTypeMemoNone <nil> <nil> <nil> <nil>} [{<nil> {OperationTypeManageData <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> 0xc042174040 <nil>}} {<nil> {OperationTypeManageData <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> <nil> 0xc042174080 <nil>}}] {0}}
- //Expected Output
- { type: 'payment', destination: 'GCKUXI3JRJANYOF3AM35Z22FGUGYYUIEBPE5TTZ7P3G6XAEFGYZC2POM', asset: Asset { code: 'Blog', issuer: 'GDOPTRADBVWJR6BMB6H5ACQTAVUS6XMT53CDNAJZLOSTIUICIW57ISMF' }, amount: '10' }
- { type: 'payment', destination: 'GCKUXI3JRJANYOF3AM35Z22FGUGYYUIEBPE5TTZ7P3G6XAEFGYZC2POM', asset: Asset { code: 'Blog', issuer: 'GDOPTRADBVWJR6BMB6H5ACQTAVUS6XMT53CDNAJZLOSTIUICIW57ISMF' }, amount: '10' }
- { type: 'payment', destination: 'GCKUXI3JRJANYOF3AM35Z22FGUGYYUIEBPE5TTZ7P3G6XAEFGYZC2POM', asset: Asset { code: 'Blog', issuer: 'GDOPTRADBVWJR6BMB6H5ACQTAVUS6XMT53CDNAJZLOSTIUICIW57ISMF' }, amount: '10' }
Add Comment
Please, Sign In to add comment