Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14864319
D11711.id34293.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D11711.id34293.diff
View Options
diff --git a/web/cashtab/src/utils/cashMethods.js b/web/cashtab/src/utils/cashMethods.js
--- a/web/cashtab/src/utils/cashMethods.js
+++ b/web/cashtab/src/utils/cashMethods.js
@@ -8,6 +8,29 @@
import BigNumber from 'bignumber.js';
import cashaddr from 'ecashaddrjs';
+export const broadcastTx = async (chronik, rawTxHex) => {
+ if (!chronik || !rawTxHex) {
+ throw new Error('Invalid tx broadcast parameter');
+ }
+
+ // Broadcast transaction to the network via the chronik client
+ // sample chronik.broadcastTx() response:
+ // {"txid":"0075130c9ecb342b5162bb1a8a870e69c935ea0c9b2353a967cda404401acf19"}
+ const broadcastResponse = await chronik.broadcastTx(rawTxHex);
+ const txidStr = broadcastResponse.txid;
+ if (txidStr) {
+ console.log(`${currency.ticker} txid`, txidStr);
+ }
+ let link;
+ if (process.env.REACT_APP_NETWORK === `mainnet`) {
+ link = `${currency.blockExplorerUrl}/tx/${txidStr}`;
+ } else {
+ link = `${currency.blockExplorerUrlTestnet}/tx/${txidStr}`;
+ }
+
+ return link;
+};
+
export function parseOpReturn(hexStr) {
if (
!hexStr ||
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, May 20, 18:46 (2 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5861711
Default Alt Text
D11711.id34293.diff (1 KB)
Attached To
D11711: [Cashtab] [Chronik] [Tx Gen] Broadcast Tx
Event Timeline
Log In to Comment