@@ -1508,6 +1508,39 @@ func (a *covenantlessArkClient) getOffchainBalance(
1508
1508
return balance , amountByExpiration , nil
1509
1509
}
1510
1510
1511
+ func (a * covenantlessArkClient ) getAllBoardingUtxos (ctx context.Context ) ([]explorer.Utxo , error ) {
1512
+ _ , boardingAddrs , _ , err := a .wallet .GetAddresses (ctx )
1513
+ if err != nil {
1514
+ return nil , err
1515
+ }
1516
+
1517
+ utxos := []explorer.Utxo {}
1518
+ for _ , addr := range boardingAddrs {
1519
+ txs , err := a .explorer .GetTxs (addr )
1520
+ if err != nil {
1521
+ continue
1522
+ }
1523
+ for _ , tx := range txs {
1524
+ for i , vout := range tx .Vout {
1525
+ if vout .Address == addr {
1526
+ createdAt := time.Time {}
1527
+ if tx .Status .Confirmed {
1528
+ createdAt = time .Unix (tx .Status .Blocktime , 0 )
1529
+ }
1530
+ utxos = append (utxos , explorer.Utxo {
1531
+ Txid : tx .Txid ,
1532
+ Vout : uint32 (i ),
1533
+ Amount : vout .Amount ,
1534
+ CreatedAt : createdAt ,
1535
+ })
1536
+ }
1537
+ }
1538
+ }
1539
+ }
1540
+
1541
+ return utxos , nil
1542
+ }
1543
+
1511
1544
func (a * covenantlessArkClient ) getClaimableBoardingUtxos (ctx context.Context ) ([]explorer.Utxo , error ) {
1512
1545
offchainAddrs , boardingAddrs , _ , err := a .wallet .GetAddresses (ctx )
1513
1546
if err != nil {
@@ -1647,24 +1680,37 @@ func (a *covenantlessArkClient) selfTransferAllPendingPayments(
1647
1680
return roundTxid , nil
1648
1681
}
1649
1682
1650
- func (a * covenantlessArkClient ) getBoardingTxs (ctx context.Context ) []Transaction {
1683
+ func (a * covenantlessArkClient ) getBoardingTxs (ctx context.Context ) ( transactions []Transaction ) {
1651
1684
utxos , err := a .getClaimableBoardingUtxos (ctx )
1652
1685
if err != nil {
1653
1686
return nil
1654
1687
}
1655
1688
1656
- txs := make ([] Transaction , 0 , len ( utxos ) )
1689
+ isPending := make (map [ string ] bool )
1657
1690
for _ , u := range utxos {
1658
- txs = append (txs , Transaction {
1691
+ isPending [u .Txid ] = true
1692
+ }
1693
+
1694
+ allUtxos , err := a .getAllBoardingUtxos (ctx )
1695
+ if err != nil {
1696
+ return nil
1697
+ }
1698
+
1699
+ for _ , u := range allUtxos {
1700
+ pending := false
1701
+ if isPending [u .Txid ] {
1702
+ pending = true
1703
+ }
1704
+ transactions = append (transactions , Transaction {
1659
1705
BoardingTxid : u .Txid ,
1660
1706
Amount : u .Amount ,
1661
1707
Type : TxReceived ,
1662
- Pending : true ,
1663
- Claimed : false ,
1708
+ Pending : pending ,
1709
+ Claimed : ! pending ,
1664
1710
CreatedAt : u .CreatedAt ,
1665
1711
})
1666
1712
}
1667
- return txs
1713
+ return
1668
1714
}
1669
1715
1670
1716
func findVtxosBySpentBy (allVtxos []client.Vtxo , txid string ) (vtxos []client.Vtxo ) {
0 commit comments