Closed jcramer closed 4 years ago
This can be tested by running/connecting to the bchd fork located here: https://github.com/simpleledgerinc/bchd/tree/slp
Currently only SLP op_return is being included in any grpc response including pb.Transaction object. Here is some example code inspecting the response:
const grpc_bchrpc = require("grpc-bchrpc-node"); const sp = require("synchronized-promise"); const client = new grpc_bchrpc.GrpcClient(); const txStream = sp(async () => { return await client.subscribeTransactions({ includeBlockAcceptance: false, includeMempoolAcceptance: true, includeSerializedTxn: false, includeOnlySlp: true, // slpTokenIds: [ "d6876f0fce603be43f15d34348bb1de1a8d688e1152596543da033a060cff798" ], }); })(); txStream.on("data", async (data: TransactionNotification) => { const txn = data.getUnconfirmedTransaction().getTransaction(); const slpVersionTypeToString = (value: number) => { for (const k in SlpVersionType) { if (SlpVersionType[k] === value) { return k; } } return null; }; const slpOpreturnMetadataCaseToString = (value: number) => { for (const k in SlpTransactionInfo.SlpOpreturnMetadataCase) { if (SlpTransactionInfo.SlpOpreturnMetadataCase[k] === value) { return k; } } return null; }; const slpType = slpVersionTypeToString(txn.getSlpTransactionInfo()!.getVersionType()); console.log(`SLP Type: ${slpType}`); console.log(`Parse Error: ${txn.getSlpTransactionInfo()!.getParseError()}`); console.log(`Token ID: ${Buffer.from(txn.getSlpTransactionInfo()!.getTokenId_asU8()).toString("hex")}`); console.log(`CASE: ${slpOpreturnMetadataCaseToString(txn.getSlpTransactionInfo()!.getSlpOpreturnMetadataCase())}`); if (slpType === "SLP_V1_SEND") { console.log(`Send amounts: ${txn.getSlpTransactionInfo()!.getV1SendMessage()!.getAmountsList()}`); } else if (slpType === "SLP_V1_MINT") { console.log(`Mint amount: ${txn.getSlpTransactionInfo()!.getV1MintMessage()!.getMintAmount()}`); console.log(`Mint baton vout: ${txn.getSlpTransactionInfo()!.getV1MintMessage()!.getMintBatonVout()}`); } else if (slpType === "SLP_V1_GENESIS") { console.log(`Name: ${txn.getSlpTransactionInfo()!.getV1GenesisMessage()!.getName()}`); console.log(`Ticker: ${txn.getSlpTransactionInfo()!.getV1GenesisMessage()!.getTicker()}`); console.log(`Divisibility: ${txn.getSlpTransactionInfo()!.getV1GenesisMessage()!.getDecimals()}`); console.log(`Mint amount: ${txn.getSlpTransactionInfo()!.getV1GenesisMessage()!.getMintAmount()}`); console.log(`Mint baton: ${txn.getSlpTransactionInfo()!.getV1GenesisMessage()!.getMintBatonVout()}`); } });
added filters for subscribe transaction stream
This can be tested by running/connecting to the bchd fork located here: https://github.com/simpleledgerinc/bchd/tree/slp
Currently only SLP op_return is being included in any grpc response including pb.Transaction object. Here is some example code inspecting the response: