@bsv/sdk 1.6.1 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/package.json +1 -1
- package/dist/cjs/src/overlay-tools/LookupResolver.js +3 -8
- package/dist/cjs/src/overlay-tools/LookupResolver.js.map +1 -1
- package/dist/cjs/src/overlay-tools/SHIPBroadcaster.js +44 -6
- package/dist/cjs/src/overlay-tools/SHIPBroadcaster.js.map +1 -1
- package/dist/cjs/src/transaction/Transaction.js +1 -1
- package/dist/cjs/src/transaction/Transaction.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/overlay-tools/LookupResolver.js +3 -8
- package/dist/esm/src/overlay-tools/LookupResolver.js.map +1 -1
- package/dist/esm/src/overlay-tools/SHIPBroadcaster.js +21 -6
- package/dist/esm/src/overlay-tools/SHIPBroadcaster.js.map +1 -1
- package/dist/esm/src/transaction/Transaction.js +1 -1
- package/dist/esm/src/transaction/Transaction.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/overlay-tools/LookupResolver.d.ts.map +1 -1
- package/dist/types/src/overlay-tools/SHIPBroadcaster.d.ts.map +1 -1
- package/dist/types/src/transaction/Transaction.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +1 -1
- package/package.json +1 -1
- package/src/overlay-tools/LookupResolver.ts +4 -9
- package/src/overlay-tools/SHIPBroadcaster.ts +20 -6
- package/src/overlay-tools/__tests/SHIPBroadcaster.test.ts +2 -1
- package/src/transaction/Transaction.ts +1 -1
package/package.json
CHANGED
|
@@ -198,7 +198,7 @@ export default class LookupResolver {
|
|
|
198
198
|
|
|
199
199
|
// Process the successful responses
|
|
200
200
|
// Aggregate outputs from all successful responses
|
|
201
|
-
const outputs = new Map<string, { beef: number[], outputIndex: number }>()
|
|
201
|
+
const outputs = new Map<string, { beef: number[], context?: number[], outputIndex: number }>()
|
|
202
202
|
|
|
203
203
|
for (const response of successfulResponses) {
|
|
204
204
|
if (response.type !== 'output-list') {
|
|
@@ -207,14 +207,9 @@ export default class LookupResolver {
|
|
|
207
207
|
try {
|
|
208
208
|
for (const output of response.outputs) {
|
|
209
209
|
try {
|
|
210
|
-
const txId: string =
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
const key = `${String(txId)}.${String(output.outputIndex)}`
|
|
214
|
-
outputs.set(key, output)
|
|
215
|
-
} else {
|
|
216
|
-
console.warn('Invalid transaction ID:', txId)
|
|
217
|
-
}
|
|
210
|
+
const txId: string = Transaction.fromBEEF(output.beef).id('hex') // !! This is STUPIDLY inefficient.
|
|
211
|
+
const key = `${txId}.${output.outputIndex}`
|
|
212
|
+
outputs.set(key, output)
|
|
218
213
|
} catch {
|
|
219
214
|
continue
|
|
220
215
|
}
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
BroadcastFailure,
|
|
5
5
|
Broadcaster
|
|
6
6
|
} from '../transaction/index.js'
|
|
7
|
+
import * as Utils from '../primitives/utils.js'
|
|
7
8
|
import LookupResolver from './LookupResolver.js'
|
|
8
9
|
import OverlayAdminTokenTemplate from './OverlayAdminTokenTemplate.js'
|
|
9
10
|
|
|
@@ -92,13 +93,25 @@ export class HTTPSOverlayBroadcastFacilitator implements OverlayBroadcastFacilit
|
|
|
92
93
|
'HTTPS facilitator can only use URLs that start with "https:"'
|
|
93
94
|
)
|
|
94
95
|
}
|
|
96
|
+
const headers = {
|
|
97
|
+
'Content-Type': 'application/octet-stream',
|
|
98
|
+
'X-Topics': JSON.stringify(taggedBEEF.topics)
|
|
99
|
+
}
|
|
100
|
+
let body
|
|
101
|
+
if (Array.isArray(taggedBEEF.offChainValues)) {
|
|
102
|
+
headers['x-includes-off-chain-values'] = 'true'
|
|
103
|
+
const w = new Utils.Writer()
|
|
104
|
+
w.writeVarIntNum(taggedBEEF.beef.length)
|
|
105
|
+
w.write(taggedBEEF.beef)
|
|
106
|
+
w.write(taggedBEEF.offChainValues)
|
|
107
|
+
body = new Uint8Array(w.toArray())
|
|
108
|
+
} else {
|
|
109
|
+
body = new Uint8Array(taggedBEEF.beef)
|
|
110
|
+
}
|
|
95
111
|
const response = await fetch(`${url}/submit`, {
|
|
96
112
|
method: 'POST',
|
|
97
|
-
headers
|
|
98
|
-
|
|
99
|
-
'X-Topics': JSON.stringify(taggedBEEF.topics)
|
|
100
|
-
},
|
|
101
|
-
body: new Uint8Array(taggedBEEF.beef)
|
|
113
|
+
headers,
|
|
114
|
+
body
|
|
102
115
|
})
|
|
103
116
|
if (response.ok) {
|
|
104
117
|
return await response.json()
|
|
@@ -154,8 +167,8 @@ export default class TopicBroadcaster implements Broadcaster {
|
|
|
154
167
|
async broadcast (
|
|
155
168
|
tx: Transaction
|
|
156
169
|
): Promise<BroadcastResponse | BroadcastFailure> {
|
|
157
|
-
console.log(tx)
|
|
158
170
|
let beef: number[]
|
|
171
|
+
const offChainValues = tx.metadata.get('OffChainValues') as number[]
|
|
159
172
|
try {
|
|
160
173
|
beef = tx.toBEEF()
|
|
161
174
|
} catch (error) {
|
|
@@ -176,6 +189,7 @@ export default class TopicBroadcaster implements Broadcaster {
|
|
|
176
189
|
try {
|
|
177
190
|
const steak = await this.facilitator.send(host, {
|
|
178
191
|
beef,
|
|
192
|
+
offChainValues,
|
|
179
193
|
topics: [...topics]
|
|
180
194
|
})
|
|
181
195
|
if (steak == null || Object.keys(steak).length === 0) {
|
|
@@ -318,7 +318,7 @@ export default class Transaction {
|
|
|
318
318
|
inputs: TransactionInput[] = [],
|
|
319
319
|
outputs: TransactionOutput[] = [],
|
|
320
320
|
lockTime: number = 0,
|
|
321
|
-
metadata: Record<string, any> =
|
|
321
|
+
metadata: Record<string, any> = new Map(),
|
|
322
322
|
merklePath?: MerklePath
|
|
323
323
|
) {
|
|
324
324
|
this.version = version
|