I want to listen for incoming transactions using typescript. But the dest address, payment id and more are all buffers.
I tried to encode them to utf-8 but still no luck.
Code:
import { fileURLToPath } from "url";
import { dirname, resolve } from "path";
import * as grpc from "@grpc/grpc-js";
import * as protoLoader from "@grpc/proto-loader";
import { ProtoGrpcType } from "../proto/generated/wallet.js";
import { TransactionEventResponse__Output } from "../proto/generated/tari/rpc/TransactionEventResponse.js";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const PORT = 18143;
const PROTO_FILE = "../proto/wallet.proto";
const packageDef = protoLoader.loadSync(resolve(__dirname, PROTO_FILE));
const grpcObj = grpc.loadPackageDefinition(
packageDef
) as unknown as ProtoGrpcType;
const client = new grpcObj.tari.rpc.Wallet(
`127.0.0.1:${PORT}`,
grpc.credentials.createInsecure()
);
client.GetVersion({}, (err, result) => {
console.log(result);
});
console.log("Streaming transactions...");
const stream = client.StreamTransactionEvents({});
stream.on("data", (result: TransactionEventResponse__Output) => {
console.log(result.transaction?.destAddress?.toString("utf-8"));
console.log(result.transaction?.paymentId?.toString("utf-8"));
});
Logs:
Streaming transactions...
{ version: '2.0.0' }
☺&�¶d��!����CY
�G�{�oד◄��˼§,�▼�▲o�}F�IH��YRN§'�++m�VGx�0↨`���O�
1�}0R��'����C��4A���→wzwarte���|r(��→&V▲r�D
undefined
undefined
☺&�¶d��!����CY
�G�{�oד◄��˼§,�▼�▲o�}F�IH��YRN§'�++m�VGx�0↨`���O�
1�}0R��'����C��4A���→wzwarte���|r(��→&V▲r�D
However the payment ID I used is 'zwarte' and you can see it present in the logs along with some random gibberish.
Already taken a look at https://rfc.tari.com/RFC-0155_TariAddress#encoding
How do I decode/deserialize this data and log it as the actual address and paymentId?
I want to listen for incoming transactions using typescript. But the dest address, payment id and more are all buffers.
I tried to encode them to utf-8 but still no luck.
Code:
Logs:
However the payment ID I used is 'zwarte' and you can see it present in the logs along with some random gibberish.
Already taken a look at https://rfc.tari.com/RFC-0155_TariAddress#encoding
How do I decode/deserialize this data and log it as the actual address and paymentId?