@@ -138,7 +138,7 @@ @implementation AppModel {
138
138
ECC::NoLeak<ECC::uintBig> passwordHash;
139
139
140
140
NSString *pathLog;
141
- ByteBuffer lastVouchers;
141
+ ShieldedVoucherList lastVouchers;
142
142
NSString *lastWalledId;
143
143
std::string *lastWalledIdS;
144
144
}
@@ -1051,35 +1051,57 @@ -(void)generateWithdrawAddress:(NewAddressGeneratedBlock _Nonnull )block {
1051
1051
}
1052
1052
1053
1053
1054
- -(NSString *_Nonnull )generateOfflineAddress : (NSString *_Nonnull)walleetId assetId : (int )assetId amount : (double )amount {
1054
+ -(void )generateOfflineAddress : (NSString *_Nonnull)walleetId assetId : (int )assetId amount : (double )amount result : (PublicAddressBlock _Nonnull) block {
1055
1055
1056
1056
uint64_t bAmount = round (amount * Rules::Coin);
1057
-
1057
+
1058
1058
WalletID m_walletID (Zero);
1059
1059
m_walletID.FromHex (walleetId.string );
1060
1060
1061
1061
auto address = walletDb->getAddress (m_walletID);
1062
1062
1063
- if (![lastWalledId isEqualToString: walleetId]) {
1064
- lastWalledId = walleetId;
1065
- lastVouchers = wallet->generateVouchers (address->m_OwnID , 1 );
1066
- }
1067
-
1068
- TxParameters offlineParameters;
1069
- offlineParameters.SetParameter (TxParameterID::TransactionType, beam::wallet::TxType::PushTransaction);
1070
- offlineParameters.SetParameter (TxParameterID::ShieldedVoucherList, lastVouchers);
1071
- offlineParameters.SetParameter (TxParameterID::PeerID, address->m_walletID );
1072
- offlineParameters.SetParameter (TxParameterID::PeerWalletIdentity, address->m_Identity );
1073
- offlineParameters.SetParameter (TxParameterID::PeerOwnID, address->m_OwnID );
1074
- offlineParameters.SetParameter (TxParameterID::IsPermanentPeerID, true );
1075
- offlineParameters.SetParameter (TxParameterID::AssetID, uint32_t (assetId));
1076
-
1077
- if (bAmount > 0 ) {
1078
- offlineParameters.SetParameter (TxParameterID::Amount, bAmount);
1079
- }
1063
+ auto func = GenerateVaucherFunc ();
1064
+ func.newGenerateVaucherBlock = ^(ShieldedVoucherList list) {
1065
+ auto token = GenerateOfflineToken (*address, bAmount, uint32_t (assetId), list, std::string (BEAM_LIB_VERSION));
1066
+ block ([NSString stringWithUTF8String: token.c_str ()]);
1067
+ };
1080
1068
1081
- auto token = to_string (offlineParameters);
1082
- return [NSString stringWithUTF8String: token.c_str ()];
1069
+ wallet->getAsync ()->generateVouchers (address->m_OwnID , 1 , func);
1070
+
1071
+ // uint64_t bAmount = round(amount * Rules::Coin);
1072
+ //
1073
+ // WalletID m_walletID(Zero);
1074
+ // m_walletID.FromHex(walleetId.string);
1075
+ //
1076
+ // auto address = walletDb->getAddress(m_walletID);
1077
+ //
1078
+ // if(![lastWalledId isEqualToString:walleetId]) {
1079
+ //
1080
+ // lastWalledId = walleetId;
1081
+ //
1082
+ // auto func = GenerateVaucherFunc();
1083
+ // func.newGenerateVaucherBlock = ^(ShieldedVoucherList list) {
1084
+ // self->lastVouchers = list;
1085
+ // };
1086
+ //
1087
+ // wallet->getAsync()->generateVouchers(address->m_OwnID, 1, func);
1088
+ // }
1089
+ //
1090
+ // TxParameters offlineParameters;
1091
+ // offlineParameters.SetParameter(TxParameterID::TransactionType, beam::wallet::TxType::PushTransaction);
1092
+ // offlineParameters.SetParameter(TxParameterID::ShieldedVoucherList, lastVouchers);
1093
+ // offlineParameters.SetParameter(TxParameterID::PeerID, address->m_walletID);
1094
+ // offlineParameters.SetParameter(TxParameterID::PeerWalletIdentity, address->m_Identity);
1095
+ // offlineParameters.SetParameter(TxParameterID::PeerOwnID, address->m_OwnID);
1096
+ // offlineParameters.SetParameter(TxParameterID::IsPermanentPeerID, true);
1097
+ // offlineParameters.SetParameter(TxParameterID::AssetID, uint32_t(assetId));
1098
+ //
1099
+ // if (bAmount > 0) {
1100
+ // offlineParameters.SetParameter(TxParameterID::Amount, bAmount);
1101
+ // }
1102
+ //
1103
+ // auto token = to_string(offlineParameters);
1104
+ // return [NSString stringWithUTF8String:token.c_str()];
1083
1105
}
1084
1106
1085
1107
-(NSString *_Nonnull)generateRegularAddress : (NSString *_Nonnull)walleetId assetId : (int )assetId amount : (double )amount isPermanentAddress : (BOOL )isPermanentAddress {
@@ -1641,49 +1663,34 @@ -(void)editAddress:(BMAddress*_Nonnull)address {
1641
1663
{
1642
1664
[_presendedNotifications setValue: address.walletId forKey: address.walletId];
1643
1665
1644
- std::vector<WalletAddress> addresses = wallet-> ownAddresses ;
1666
+ auto status = beam:: wallet::WalletAddress::ExpirationStatus::AsIs ;
1645
1667
1646
- for ( int i= 0 ; i<addresses. size (); i++)
1647
- {
1648
- NSString *wAddress = [ NSString stringWithUTF8String: to_string (addresses[i].m_walletID). c_str ()];
1649
-
1650
- if ([wAddress isEqualToString: address.walletId])
1651
- {
1652
- addresses[i]. m_label = address. label . string ;
1653
-
1654
- if (address. isNowExpired ) {
1655
- addresses[i]. setExpirationStatus (beam::wallet::WalletAddress::ExpirationStatus::Expired);
1656
- }
1657
- else if (address. isNowActive ) {
1658
- if (address.isNowActiveDuration == 0 ) {
1659
- addresses[i]. setExpirationStatus ( beam::wallet::WalletAddress::ExpirationStatus::Never) ;
1660
- }
1661
- else {
1662
- addresses[i]. setExpirationStatus (beam::wallet::WalletAddress::ExpirationStatus::Auto);
1663
- }
1668
+ if (address. isNowExpired ) {
1669
+ status = beam::wallet::WalletAddress::ExpirationStatus::Expired;
1670
+ }
1671
+ else if (address. isNowActive ) {
1672
+ if (address.isNowActiveDuration == 0 ){
1673
+ status = beam::wallet::WalletAddress::ExpirationStatus::Never;
1674
+ }
1675
+ else {
1676
+ status = beam::wallet::WalletAddress::ExpirationStatus::Auto;
1677
+ }
1678
+ }
1679
+ else {
1680
+ if (address.isExpired ) {
1681
+ status = beam::wallet::WalletAddress::ExpirationStatus::Expired ;
1682
+ }
1683
+ else {
1684
+ if (address. duration == 0 ) {
1685
+ status = beam::wallet::WalletAddress::ExpirationStatus::Never;
1664
1686
}
1665
- else {
1666
- if (address.isExpired ) {
1667
- [_deletedNotifications setObject: wAddress forKey: wAddress];
1668
- addresses[i].setExpirationStatus (beam::wallet::WalletAddress::ExpirationStatus::Expired);
1669
- }
1670
- else {
1671
- if (address.duration == 0 ) {
1672
- addresses[i].setExpirationStatus (beam::wallet::WalletAddress::ExpirationStatus::Never);
1673
- }
1674
- else {
1675
- addresses[i].setExpirationStatus (beam::wallet::WalletAddress::ExpirationStatus::AsIs);
1676
- }
1677
- }
1687
+ else {
1688
+ status = beam::wallet::WalletAddress::ExpirationStatus::AsIs;
1678
1689
}
1679
-
1680
- // NSString *s = [NSString stringWithUTF8String:to_string(addresses[i].m_Identity).c_str()];
1681
-
1682
- wallet->getAsync ()->saveAddress (addresses[i]);
1683
-
1684
- break ;
1685
1690
}
1686
1691
}
1692
+
1693
+ wallet->getAsync ()->updateAddress (walletID, address.label .string , status);
1687
1694
}
1688
1695
}
1689
1696
}
@@ -1878,8 +1885,16 @@ -(double)remainingBeam:(double)amount fee:(double)fee {
1878
1885
return realAmount;
1879
1886
}
1880
1887
1881
- -(NSString *_Nullable)canSend : (double )amount assetId : (int )assetId fee : (double )fee to : (NSString *_Nullable)to {
1888
+ -(NSString *_Nullable)canSend : (double )amount assetId : (int )assetId fee : (double )fee to : (NSString *_Nullable)to maxAmount : ( double ) maxAmount {
1882
1889
NSString *errorString = [self sendError: amount assetId: assetId fee: fee to: to];
1890
+ if (errorString == nil ) {
1891
+ if (amount > maxAmount && maxAmount != 0 ) {
1892
+ NSString *amountString = [[StringManager sharedManager ] realAmountString: maxAmount];
1893
+ NSString *assetName = [[[AssetsManager sharedManager ] getAsset: assetId] unitName ];
1894
+ NSString *fullName = [NSString stringWithFormat: @" %@ %@ " , amountString, assetName];
1895
+ return [NSString stringWithFormat: [@" max_funds_error" localized ], fullName];
1896
+ }
1897
+ }
1883
1898
return errorString;
1884
1899
}
1885
1900
@@ -1917,11 +1932,15 @@ -(void)calculateFee:(double)amount assetId:(int)assetId fee:(double)fee isShield
1917
1932
1918
1933
Amount bAmount = round (amount * Rules::Coin);
1919
1934
Amount bFee = fee;
1920
-
1935
+
1921
1936
wallet->getAsync ()->selectCoins (bAmount, bFee, beam::Asset::ID (assetId), isShielded);
1922
1937
// wallet->getAsync()->calcShieldedCoinSelectionInfo(bAmount, 0, assetId, isShielded);
1923
1938
}
1924
1939
1940
+ -(double )grothToBeam : (uint64_t )groth {
1941
+ double real = double (groth / Rules::Coin);
1942
+ return real;
1943
+ }
1925
1944
1926
1945
-(NSString *)sendError : (double )amount assetId : (int )assetId fee : (double )fee checkMinAmount : (BOOL )check {
1927
1946
0 commit comments