소스 검색

Fix UTXOs update.

Shomari 1 개월 전
부모
커밋
808ce42fa5
1개의 변경된 파일18개의 추가작업 그리고 1개의 파일을 삭제
  1. 18 1
      web/stores/wallet.ts

+ 18 - 1
web/stores/wallet.ts

@@ -352,7 +352,24 @@ _setupHushKeychain.bind(this)()
             console.log('HUSH UTXOS', data)
 
             // FIXME Update the deltas ONLY!
-            // this._utxos[HUSH_PROTOCOL_ID] = data?.utxos
+            this._utxos[HUSH_PROTOCOL_ID] = {}
+
+            /* Handle unspent outputs. */
+            data.forEach(_unspent => {
+                _unspent.utxos.forEach(_utxo => {
+                    console.log('ADDING HUSH UTXO...', _utxo)
+
+                    /* Generate outpoint (hash). */
+                    const outpoint = sha256(_utxo.tx_hash + ':' + _utxo.tx_pos)
+
+                    /* Add to UTXOs. */
+                    this._utxos[HUSH_PROTOCOL_ID][outpoint] = {
+                        address: _unspent.address,
+                        ..._utxo,
+                    }
+                })
+            })
+
 
             /* Request history data. */
             data = await $fetch('/api/electrum', {