use of io.bisq.core.btc.AddressEntry in project bisq-api by mrosseel.
the class BisqProxy method registerArbitrator.
public void registerArbitrator(List<String> languageCodes) {
// TODO most of this code is dupplication of ArbitratorRegistrationViewModel.onRegister
final String privKeyString = useDevPrivilegeKeys ? DevEnv.DEV_PRIVILEGE_PRIV_KEY : null;
// TODO hm, are we going to send private key over http?
if (null == privKeyString) {
throw new RuntimeException("Missing private key");
}
ECKey registrationKey = arbitratorManager.getRegistrationKey(privKeyString);
if (null == registrationKey) {
throw new RuntimeException("Missing registration key");
}
AddressEntry arbitratorDepositAddressEntry = btcWalletService.getOrCreateAddressEntry(AddressEntry.Context.ARBITRATOR);
String registrationSignature = arbitratorManager.signStorageSignaturePubKey(registrationKey);
Arbitrator arbitrator = new Arbitrator(p2PService.getAddress(), arbitratorDepositAddressEntry.getPubKey(), arbitratorDepositAddressEntry.getAddressString(), keyRing.getPubKeyRing(), new ArrayList<>(languageCodes), new Date().getTime(), registrationKey.getPubKey(), registrationSignature, null, null, null);
// TODO I don't know how to deal with those callbacks in order to send response back
arbitratorManager.addArbitrator(arbitrator, () -> System.out.println("Arbi registered"), message -> System.out.println("Error when registering arbi: " + message));
}
use of io.bisq.core.btc.AddressEntry in project bisq-api by mrosseel.
the class BisqProxy method updateLockedBalance.
// TODO copied from MainViewModel - refactor !
private Coin updateLockedBalance() {
Stream<Trade> lockedTrades = Stream.concat(closedTradableManager.getLockedTradesStream(), failedTradesManager.getLockedTradesStream());
lockedTrades = Stream.concat(lockedTrades, tradeManager.getLockedTradesStream());
Coin sum = Coin.valueOf(lockedTrades.mapToLong(trade -> {
final Optional<AddressEntry> addressEntryOptional = btcWalletService.getAddressEntry(trade.getId(), AddressEntry.Context.MULTI_SIG);
if (addressEntryOptional.isPresent())
return addressEntryOptional.get().getCoinLockedInMultiSig().getValue();
else
return 0;
}).sum());
return sum;
}
use of io.bisq.core.btc.AddressEntry in project bisq-api by mrosseel.
the class MainViewModelHeadless method updateLockedBalance.
private void updateLockedBalance() {
Stream<Trade> lockedTrades = Stream.concat(closedTradableManager.getLockedTradesStream(), failedTradesManager.getLockedTradesStream());
lockedTrades = Stream.concat(lockedTrades, tradeManager.getLockedTradesStream());
Coin sum = Coin.valueOf(lockedTrades.mapToLong(trade -> {
final Optional<AddressEntry> addressEntryOptional = btcWalletService.getAddressEntry(trade.getId(), AddressEntry.Context.MULTI_SIG);
if (addressEntryOptional.isPresent())
return addressEntryOptional.get().getCoinLockedInMultiSig().getValue();
else
return 0;
}).sum());
lockedBalance.set(formatter.formatCoinWithCode(sum));
}
use of io.bisq.core.btc.AddressEntry in project bisq-api by mrosseel.
the class MainViewModelHeadless method updateReservedBalance.
private void updateReservedBalance() {
Coin sum = Coin.valueOf(openOfferManager.getObservableList().stream().map(openOffer -> {
final Optional<AddressEntry> addressEntryOptional = btcWalletService.getAddressEntry(openOffer.getId(), AddressEntry.Context.RESERVED_FOR_TRADE);
if (addressEntryOptional.isPresent()) {
Address address = addressEntryOptional.get().getAddress();
return btcWalletService.getBalanceForAddress(address);
} else {
return null;
}
}).filter(e -> e != null).mapToLong(Coin::getValue).sum());
reservedBalance.set(formatter.formatCoinWithCode(sum));
}
use of io.bisq.core.btc.AddressEntry in project bisq-api by mrosseel.
the class BtcWalletResource method getOrCreateBtcWalletAddresses.
@ApiOperation("Get or create wallet addresses")
@POST
@Path("/addresses")
public BtcWalletAddress getOrCreateBtcWalletAddresses(@Valid CreateBtcWalletAddress payload) {
final AddressEntry addressEntry = bisqProxy.getOrCreateBtcWalletAddresses(payload.context, payload.unused);
final BtcWalletAddress btcWalletAddress = new BtcWalletAddress();
btcWalletAddress.address = addressEntry.getAddressString();
return btcWalletAddress;
}
Aggregations