Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 23 additions & 6 deletions lib/provider/provider.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/provider/provider.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 22 additions & 7 deletions src/provider/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { SandshrewBitcoinClient } from '../rpclient/sandshrew'
import { EsploraRpc } from '../rpclient/esplora'
import { OrdRpc } from '../rpclient/ord'
import * as bitcoin from 'bitcoinjs-lib'
import { waitForTransaction } from '..'
import { delay, waitForTransaction } from '../shared/utils'
import { AlkanesRpc } from '../rpclient/alkanes'

export type ProviderConstructorArgs = {
Expand Down Expand Up @@ -96,12 +96,27 @@ export class Provider {
}
await this.sandshrew.bitcoindRpc.sendRawTransaction(rawTx)

await waitForTransaction({
txId,
sandshrewBtcClient: this.sandshrew,
})

const txInMemPool = await this.sandshrew.bitcoindRpc.getMemPoolEntry(txId)
let txInMemPool
for (let i = 0; i < 10; i++) {
try {
await waitForTransaction({
txId,
sandshrewBtcClient: this.sandshrew,
})
txInMemPool = await this.sandshrew.bitcoindRpc.getMemPoolEntry(txId)
if (txInMemPool) {
break
}
} catch (e) {
if (i === 9) {
throw e
}
await delay(1000)
}
}
if (!txInMemPool) {
throw new Error('Transaction not found in mempool after 10 retries')
}
const fee = txInMemPool.fees['base'] * 10 ** 8

return {
Expand Down