From 147e2fa96179be5a5cef84e3680e1c1b87f0ccf3 Mon Sep 17 00:00:00 2001
From: Caner Candan <candan@info.univ-angers.fr>
Date: Sun, 9 Feb 2014 00:47:02 +0100
Subject: [PATCH] * added server and port parameters to all API as well as
 wrappers classes

---
 __init__.py                         |  6 +++--
 hdc/__init__.py                     |  4 ++--
 hdc/amendments/__init__.py          | 22 +++++++++----------
 hdc/amendments/view.py              |  6 ++---
 hdc/coins/__init__.py               | 12 +++++-----
 hdc/coins/view.py                   |  6 ++---
 hdc/transactions/__init__.py        | 26 +++++++++++-----------
 hdc/transactions/sender/__init__.py | 12 +++++-----
 hdc/transactions/sender/issuance.py | 10 ++++-----
 pks/__init__.py                     |  4 ++--
 ucg/__init__.py                     | 12 +++++-----
 ucg/peering/__init__.py             |  6 ++---
 ucg/peering/peers.py                | 20 ++++++++---------
 wrappers/__init__.py                |  4 ++++
 wrappers/coins.py                   | 18 +++++++++------
 wrappers/transactions.py            | 34 +++++++++++++++++------------
 16 files changed, 109 insertions(+), 93 deletions(-)

diff --git a/__init__.py b/__init__.py
index 38a92099..e68c8e79 100644
--- a/__init__.py
+++ b/__init__.py
@@ -92,7 +92,7 @@ class Response:
 class API:
     """APIRequest is a class used as an interface. The intermediate derivated classes are the modules and the leaf classes are the API requests."""
 
-    def __init__(self, module):
+    def __init__(self, module, server=None, port=None):
         """
         Asks a module in order to create the url used then by derivated classes.
 
@@ -100,7 +100,9 @@ class API:
         - `module`: module name
         """
 
-        self.url = 'http://%s:%d/%s' % (settings['server'], settings['port'], module)
+        self.url = 'http://%s:%d/%s' % (server if server else settings['server'],
+                                        port if port else settings['port'],
+                                        module)
         self.headers = {}
 
         if settings['auth']:
diff --git a/hdc/__init__.py b/hdc/__init__.py
index c54d8f65..9e242612 100644
--- a/hdc/__init__.py
+++ b/hdc/__init__.py
@@ -21,7 +21,7 @@ from .. import API, logging
 logger = logging.getLogger("ucoin/hdc")
 
 class HDC(API):
-    def __init__(self, module='hdc'):
-        super().__init__(module)
+    def __init__(self, module='hdc', server=None, port=None):
+        super().__init__(module, server, port)
 
 from . import amendments, coins, transactions
diff --git a/hdc/amendments/__init__.py b/hdc/amendments/__init__.py
index 00136dc1..812066a5 100644
--- a/hdc/amendments/__init__.py
+++ b/hdc/amendments/__init__.py
@@ -22,13 +22,13 @@ import logging
 logger = logging.getLogger("ucoin/hdc/amendments")
 
 class Base(HDC):
-    def __init__(self):
-        super().__init__('hdc/amendments')
+    def __init__(self, server=None, port=None):
+        super().__init__('hdc/amendments', server, port)
 
 class Promoted(Base):
     """GET the current promoted amendment (amendment which received enough votes to be accepted)."""
 
-    def __init__(self, number=None):
+    def __init__(self, number=None, server=None, port=None):
         """
         Uses number to fit the result.
 
@@ -36,15 +36,15 @@ class Promoted(Base):
         - `number`: amendment number
         """
 
-        super().__init__()
+        super().__init__(server, port)
 
         self.number = number
 
     def __get__(self, **kwargs):
         if not self.number:
-            return self.requests_get('/promoted').json()
+            return self.requests_get('/promoted', **kwargs).json()
 
-        return self.requests_get('/promoted/%d' % self.number).json()
+        return self.requests_get('/promoted/%d' % self.number, **kwargs).json()
 
 class Current(Promoted):
     """Alias of amendments/promoted."""
@@ -57,11 +57,11 @@ class List(Base):
     def __get__(self, **kwargs):
         """creates a generator with one amendment per iteration."""
 
-        current = self.requests_get('/promoted').json()
+        current = self.requests_get('/promoted', **kwargs).json()
         yield current
 
         while 'previousHash' in current and current['previousHash']:
-            current = self.requests_get('/promoted/%d' % (current['number']-1)).json()
+            current = self.requests_get('/promoted/%d' % (current['number']-1), **kwargs).json()
             yield current
 
 class CurrentVotes(Base):
@@ -73,7 +73,7 @@ class CurrentVotes(Base):
 class Votes(Base):
     """GET an index of votes received by this node."""
 
-    def __init__(self, amendment_id=None):
+    def __init__(self, amendment_id=None, server=None, port=None):
         """
         Uses amendment_id to fit the result.
 
@@ -81,13 +81,13 @@ class Votes(Base):
         - `amendment_id`: amendment id
         """
 
-        super().__init__()
+        super().__init__(server, port)
 
         self.amendment_id = amendment_id
 
     def __get__(self, **kwargs):
         if not self.amendment_id:
-            return self.requests_get('/votes').json()
+            return self.requests_get('/votes', **kwargs).json()
 
         return self.merkle_easy_parser('/votes/%s' % self.amendment_id)
 
diff --git a/hdc/amendments/view.py b/hdc/amendments/view.py
index e32dce03..418606dc 100644
--- a/hdc/amendments/view.py
+++ b/hdc/amendments/view.py
@@ -21,8 +21,8 @@ from . import HDC, logging
 logger = logging.getLogger("ucoin/hdc/amendments/view")
 
 class View(HDC):
-    def __init__(self, amendment_id):
-        super().__init__('hdc/amendments/view/%s' % amendment_id)
+    def __init__(self, amendment_id, server=None, port=None):
+        super().__init__('hdc/amendments/view/%s' % amendment_id, server, port)
 
 class Members(View):
     """GET the members present in the Community for this amendment."""
@@ -34,7 +34,7 @@ class Self(View):
     """Shows the raw data of the amendment [AMENDMENT_ID]."""
 
     def __get__(self, **kwargs):
-        return self.requests_get('/self').json()
+        return self.requests_get('/self', **kwargs).json()
 
 class Voters(View):
     """GET the voters listed in this amendment."""
diff --git a/hdc/coins/__init__.py b/hdc/coins/__init__.py
index 5c6933c7..83c17412 100644
--- a/hdc/coins/__init__.py
+++ b/hdc/coins/__init__.py
@@ -21,24 +21,24 @@ from .. import HDC, logging
 logger = logging.getLogger("ucoin/hdc/coins")
 
 class Coins(HDC):
-    def __init__(self, pgp_fingerprint):
-        super().__init__('hdc/coins/%s' % pgp_fingerprint)
+    def __init__(self, pgp_fingerprint, server=None, port=None):
+        super().__init__('hdc/coins/%s' % pgp_fingerprint, server, port)
 
 class List(Coins):
     """GET a list of coins owned by the given [PGP_FINGERPRINT]."""
 
     def __get__(self, **kwargs):
-        return self.requests_get('/list').json()
+        return self.requests_get('/list', **kwargs).json()
 
 class View(Coins):
     """GET the ownership state of the coin [COIN_NUMBER] issued by [PGP_FINGERPRINT]."""
 
-    def __init__(self, pgp_fingerprint, coin_number):
-        super().__init__(pgp_fingerprint)
+    def __init__(self, pgp_fingerprint, coin_number, server=None, port=None):
+        super().__init__(pgp_fingerprint, server, port)
 
         self.coin_number = coin_number
 
     def __get__(self, **kwargs):
-        return self.requests_get('/view/%d' % self.coin_number).json()
+        return self.requests_get('/view/%d' % self.coin_number, **kwargs).json()
 
 from . import view
diff --git a/hdc/coins/view.py b/hdc/coins/view.py
index cfda8cbf..846aefef 100644
--- a/hdc/coins/view.py
+++ b/hdc/coins/view.py
@@ -21,11 +21,11 @@ from . import HDC, logging
 logger = logging.getLogger("ucoin/hdc/coins/view")
 
 class Base(HDC):
-    def __init__(self, pgp_fingerprint, coin_number):
-        super().__init__('hdc/coins/%s/view/%d' % (pgp_fingerprint, coin_number))
+    def __init__(self, pgp_fingerprint, coin_number, server=None, port=None):
+        super().__init__('hdc/coins/%s/view/%d' % (pgp_fingerprint, coin_number), server, port)
 
 class History(Base):
     """GET a transaction history of the coin [COIN_NUMBER] issued by [PGP_FINGERPRINT]."""
 
     def __get__(self, **kwargs):
-        return self.requests_get('/history').json()
+        return self.requests_get('/history', **kwargs).json()
diff --git a/hdc/transactions/__init__.py b/hdc/transactions/__init__.py
index 61b6bb61..0aaa09d3 100644
--- a/hdc/transactions/__init__.py
+++ b/hdc/transactions/__init__.py
@@ -21,8 +21,8 @@ from .. import HDC, logging
 logger = logging.getLogger("ucoin/hdc/transactions")
 
 class Base(HDC):
-    def __init__(self):
-        super().__init__('hdc/transactions')
+    def __init__(self, server=None, port=None):
+        super().__init__('hdc/transactions', server, port)
 
 class Process(Base):
     """POST a transaction."""
@@ -52,26 +52,26 @@ class Keys(Base):
 class Last(Base):
     """GET the last received transaction."""
 
-    def __init__(self, count=None):
+    def __init__(self, count=None, server=None, port=None):
         """
         Arguments:
         - `count`: Integer indicating to retrieve the last [COUNT] transactions.
         """
 
-        super().__init__()
+        super().__init__(server, port)
 
         self.count = count
 
     def __get__(self, **kwargs):
         if not self.count:
-            return self.requests_get('/last').json()
+            return self.requests_get('/last', **kwargs).json()
 
-        return self.requests_get('/last/%d' % self.count).json()
+        return self.requests_get('/last/%d' % self.count, **kwargs).json()
 
 class Sender(Base):
     """GET all the transactions sent by this sender and stored by this node (should contain all transactions of the sender)."""
 
-    def __init__(self, pgp_fingerprint, begin=None, end=None):
+    def __init__(self, pgp_fingerprint, begin=None, end=None, server=None, port=None):
         """
         Arguments:
         - `pgp_fingerprint`: PGP fingerprint of the key we want to see sent transactions.
@@ -79,7 +79,7 @@ class Sender(Base):
         - `end`: integer value used by the merkle parser to know when to end requesting.
         """
 
-        super().__init__()
+        super().__init__(server, port)
 
         self.pgp_fingerprint = pgp_fingerprint
         self.begin = begin
@@ -91,7 +91,7 @@ class Sender(Base):
 class Recipient(Base):
     """GET all the transactions received for this recipient stored by this node."""
 
-    def __init__(self, pgp_fingerprint, begin=None, end=None):
+    def __init__(self, pgp_fingerprint, begin=None, end=None, server=None, port=None):
         """
         Arguments:
         - `pgp_fingerprint`: PGP fingerprint of the key we want to see sent transactions.
@@ -99,7 +99,7 @@ class Recipient(Base):
         - `end`: integer value used by the merkle parser to know when to end requesting.
         """
 
-        super().__init__()
+        super().__init__(server, port)
 
         self.pgp_fingerprint = pgp_fingerprint
         self.begin = begin
@@ -111,17 +111,17 @@ class Recipient(Base):
 class View(Base):
     """GET the transaction of given TRANSACTION_ID."""
 
-    def __init__(self, transaction_id):
+    def __init__(self, transaction_id, server=None, port=None):
         """
         Arguments:
         - `transaction_id`: The transaction unique identifier.
         """
 
-        super().__init__()
+        super().__init__(server, port)
 
         self.transaction_id = transaction_id
 
     def __get__(self, **kwargs):
-        return self.requests_get('/view/%s' % self.transaction_id).json()
+        return self.requests_get('/view/%s' % self.transaction_id, **kwargs).json()
 
 from . import sender
diff --git a/hdc/transactions/sender/__init__.py b/hdc/transactions/sender/__init__.py
index d95208b8..3dc85196 100644
--- a/hdc/transactions/sender/__init__.py
+++ b/hdc/transactions/sender/__init__.py
@@ -23,32 +23,32 @@ logger = logging.getLogger("ucoin/hdc/transactions/sender")
 class Base(HDC):
     """Get the last received transaction of a PGP key."""
 
-    def __init__(self, pgp_fingerprint):
+    def __init__(self, pgp_fingerprint, server=None, port=None):
         """
         Arguments:
         - `pgp_fingerprint`: PGP fingerprint of the key we want to see sent transactions.
         """
 
-        super().__init__('hdc/transactions/sender/%s' % pgp_fingerprint)
+        super().__init__('hdc/transactions/sender/%s' % pgp_fingerprint, server, port)
 
 class Last(Base):
     """Get the last received transaction of a PGP key."""
 
-    def __init__(self, pgp_fingerprint, count=None):
+    def __init__(self, pgp_fingerprint, count=None, server=None, port=None):
         """
         Arguments:
         - `count`: Integer indicating to retrieve the last [COUNT] transactions.
         """
 
-        super().__init__(pgp_fingerprint)
+        super().__init__(pgp_fingerprint, server, port)
 
         self.count = count
 
     def __get__(self, **kwargs):
         if not self.count:
-            return self.requests_get('/last').json()
+            return self.requests_get('/last', **kwargs).json()
 
-        return self.requests_get('/last/%d' % self.count).json()
+        return self.requests_get('/last/%d' % self.count, **kwargs).json()
 
 class Transfer(Base):
     """GET all transfer transactions sent by this sender and stored by this node (should contain all transfert transactions of the sender)."""
diff --git a/hdc/transactions/sender/issuance.py b/hdc/transactions/sender/issuance.py
index d4a5c1e4..d5cd20cf 100644
--- a/hdc/transactions/sender/issuance.py
+++ b/hdc/transactions/sender/issuance.py
@@ -23,19 +23,19 @@ logger = logging.getLogger("ucoin/hdc/transactions/sender/issuance")
 class Base(HDC):
     """Get the received issuance transaction of a PGP key."""
 
-    def __init__(self, pgp_fingerprint):
+    def __init__(self, pgp_fingerprint, server=None, port=None):
         """
         Arguments:
         - `pgp_fingerprint`: PGP fingerprint of the key we want to see sent transactions.
         """
 
-        super().__init__('hdc/transactions/sender/%s/issuance' % pgp_fingerprint)
+        super().__init__('hdc/transactions/sender/%s/issuance' % pgp_fingerprint, server, port)
 
 class Last(Base):
     """GET the last received issuance transaction of a PGP key."""
 
     def __get__(self, **kwargs):
-        return self.requests_get('/last').json()
+        return self.requests_get('/last', **kwargs).json()
 
 class Fusion(Base):
     """GET all fusion transactions sent by this sender and stored by this node (should contain all fusion transactions of the sender)."""
@@ -46,13 +46,13 @@ class Fusion(Base):
 class Dividend(Base):
     """GET all dividend transactions (issuance of new coins) sent by this sender and stored by this node (should contain all dividend transactions of the sender)."""
 
-    def __init__(self, pgp_fingerprint, am_number=None):
+    def __init__(self, pgp_fingerprint, am_number=None, server=None, port=None):
         """
         Arguments:
         - `am_number`: amendment number
         """
 
-        super().__init__(pgp_fingerprint)
+        super().__init__(pgp_fingerprint, server, port)
 
         self.am_number = am_number
 
diff --git a/pks/__init__.py b/pks/__init__.py
index 3c0bed2b..2c52bb40 100644
--- a/pks/__init__.py
+++ b/pks/__init__.py
@@ -21,8 +21,8 @@ from .. import API, logging
 logger = logging.getLogger("ucoin/pks")
 
 class PKS(API):
-    def __init__(self, module='pks'):
-        super().__init__(module)
+    def __init__(self, module='pks', server=None, port=None):
+        super().__init__(module, server, port)
 
 class Add(PKS):
     """POST ASCII-armored OpenPGP certificates."""
diff --git a/ucg/__init__.py b/ucg/__init__.py
index a858f95c..cf1d7ff0 100644
--- a/ucg/__init__.py
+++ b/ucg/__init__.py
@@ -21,25 +21,25 @@ from .. import API, logging
 logger = logging.getLogger("ucoin/ucg")
 
 class UCG(API):
-    def __init__(self, module='ucg'):
-        super().__init__(module)
+    def __init__(self, module='ucg', server=None, port=None):
+        super().__init__(module, server, port)
 
 class Pubkey(UCG):
     """GET the public key of the peer."""
 
     def __get__(self, **kwargs):
-        return self.requests_get('/pubkey').text
+        return self.requests_get('/pubkey', **kwargs).text
 
 class Peering(UCG):
     """GET peering information about a peer."""
 
     def __get__(self, **kwargs):
-        return self.requests_get('/peering').json()
+        return self.requests_get('/peering', **kwargs).json()
 
 class THT(UCG):
     """GET/POST THT entries."""
 
-    def __init__(self, pgp_fingerprint=None):
+    def __init__(self, pgp_fingerprint=None, server=None, port=None):
         """
         Use the pgp fingerprint parameter in order to fit the result.
 
@@ -47,7 +47,7 @@ class THT(UCG):
         - `pgp_fingerprint`: pgp fingerprint to use as a filter
         """
 
-        super().__init__()
+        super().__init__(server, port)
 
         self.pgp_fingerprint = pgp_fingerprint
 
diff --git a/ucg/peering/__init__.py b/ucg/peering/__init__.py
index 77534303..f08b9a57 100644
--- a/ucg/peering/__init__.py
+++ b/ucg/peering/__init__.py
@@ -21,8 +21,8 @@ from .. import UCG, logging
 logger = logging.getLogger("ucoin/ucg/peering")
 
 class Base(UCG):
-    def __init__(self):
-        super().__init__('ucg/peering')
+    def __init__(self, server=None, port=None):
+        super().__init__('ucg/peering', server, port)
 
 class Keys(Base):
     """GET PGP keys' fingerprint this node manages, i.e. this node will have transactions history and follow ohter nodes for this history."""
@@ -38,7 +38,7 @@ class Peer(Base):
     def __get__(self, **kwargs):
         """returns peering entry of the node."""
 
-        return self.requests_get('/peer').json()
+        return self.requests_get('/peer', **kwargs).json()
 
 class Peers(Base):
     """GET peering entries of every node inside the currency network."""
diff --git a/ucg/peering/peers.py b/ucg/peering/peers.py
index f03cbe88..29fd76c5 100644
--- a/ucg/peering/peers.py
+++ b/ucg/peering/peers.py
@@ -21,13 +21,13 @@ from . import UCG, logging
 logger = logging.getLogger("ucoin/ucg/peering/peers")
 
 class Base(UCG):
-    def __init__(self):
-        super().__init__('ucg/peering/peers')
+    def __init__(self, server=None, port=None):
+        super().__init__('ucg/peering/peers', server, port)
 
 class Stream(Base):
     """GET a list of peers this node is listening to/by for ANY incoming transaction."""
 
-    def __init__(self, request, pgp_fingerprint=None):
+    def __init__(self, request, pgp_fingerprint=None, server=None, port=None):
         """
         Use the pgp fingerprint parameter in order to fit the result.
 
@@ -36,7 +36,7 @@ class Stream(Base):
         - `pgp_fingerprint`: pgp fingerprint to use as a filter
         """
 
-        super().__init__()
+        super().__init__(server, port)
 
         self.request = request
         self.pgp_fingerprint = pgp_fingerprint
@@ -45,14 +45,14 @@ class Stream(Base):
         """returns the corresponding peer list."""
 
         if not self.pgp_fingerprint:
-            return self.requests_get('/%s' % self.request).json()
+            return self.requests_get('/%s' % self.request, **kwargs).json()
 
-        return self.requests_get('/%s/%s' % (self.request, self.pgp_fingerprint)).json()
+        return self.requests_get('/%s/%s' % (self.request, self.pgp_fingerprint), **kwargs).json()
 
 class UpStream(Stream):
     """GET a list of peers this node is listening to for ANY incoming transaction."""
 
-    def __init__(self, pgp_fingerprint=None):
+    def __init__(self, pgp_fingerprint=None, server=None, port=None):
         """
         Use the pgp fingerprint parameter in order to fit the result.
 
@@ -60,12 +60,12 @@ class UpStream(Stream):
         - `pgp_fingerprint`: pgp fingerprint to use as a filter
         """
 
-        super().__init__('upstream', pgp_fingerprint)
+        super().__init__('upstream', pgp_fingerprint, server, port)
 
 class DownStream(Stream):
     """GET a list of peers this node is listening by for ANY incoming transaction."""
 
-    def __init__(self, pgp_fingerprint=None):
+    def __init__(self, pgp_fingerprint=None, server=None, port=None):
         """
         Use the pgp fingerprint parameter in order to fit the result.
 
@@ -73,4 +73,4 @@ class DownStream(Stream):
         - `pgp_fingerprint`: pgp fingerprint to use as a filter
         """
 
-        super().__init__('downstream', pgp_fingerprint)
+        super().__init__('downstream', pgp_fingerprint, server, port)
diff --git a/wrappers/__init__.py b/wrappers/__init__.py
index 2e7f868a..ee7cd804 100644
--- a/wrappers/__init__.py
+++ b/wrappers/__init__.py
@@ -23,6 +23,10 @@ from .. import pks, ucg, hdc, settings
 logger = logging.getLogger("wrappers")
 
 class Wrapper:
+    def __init__(self, server=None, port=None):
+        self.server = server
+        self.port = port
+
     def __call__(self):
         pass
 
diff --git a/wrappers/coins.py b/wrappers/coins.py
index 10689856..1793a0f9 100644
--- a/wrappers/coins.py
+++ b/wrappers/coins.py
@@ -23,16 +23,19 @@ from . import Wrapper, pks, ucg, hdc, settings
 logger = logging.getLogger("coins")
 
 class Coins(Wrapper):
-    def __init__(self, pgp_fingerprint):
+    def __init__(self, pgp_fingerprint, server=None, port=None):
+        super().__init__(server, port)
+
         self.pgp_fingerprint = pgp_fingerprint
 
 class Get(Coins):
-    def __init__(self, pgp_fingerprint, values):
-        super().__init__(pgp_fingerprint)
+    def __init__(self, pgp_fingerprint, values, server=None, port=None):
+        super().__init__(pgp_fingerprint, server, port)
+
         self.values = values
 
     def __call__(self):
-        __list = hdc.coins.List(self.pgp_fingerprint).get()
+        __list = hdc.coins.List(self.pgp_fingerprint, self.server, self.port).get()
         coins = {}
         for c in __list['coins']:
             for id in c['ids']:
@@ -60,12 +63,13 @@ class Get(Coins):
         return res
 
 class List(Coins):
-    def __init__(self, pgp_fingerprint, limit=None):
-        super().__init__(pgp_fingerprint)
+    def __init__(self, pgp_fingerprint, limit=None, server=None, port=None):
+        super().__init__(pgp_fingerprint, server, port)
+
         self.limit = limit
 
     def __call__(self):
-        __list = hdc.coins.List(self.pgp_fingerprint).get()
+        __list = hdc.coins.List(self.pgp_fingerprint, self.server, self.port).get()
         coins = []
         __sum = 0
 
diff --git a/wrappers/transactions.py b/wrappers/transactions.py
index 670dbffa..e1ed0f66 100644
--- a/wrappers/transactions.py
+++ b/wrappers/transactions.py
@@ -23,7 +23,9 @@ from . import Wrapper, pks, ucg, hdc, settings
 logger = logging.getLogger("transactions")
 
 class Transaction(Wrapper):
-    def __init__(self, type, pgp_fingerprint, message='', peering=None):
+    def __init__(self, type, pgp_fingerprint, message='', peering=None, server=None, port=None):
+        super().__init__(server, port)
+
         self.pgp_fingerprint = pgp_fingerprint
         self.message = message
         self.type = type
@@ -32,7 +34,7 @@ class Transaction(Wrapper):
 
     def __call__(self):
         try:
-            last_tx = hdc.transactions.sender.Last(self.pgp_fingerprint).get()
+            last_tx = hdc.transactions.sender.Last(self.pgp_fingerprint, self.server, self.port).get()
         except ValueError:
             last_tx = None
 
@@ -83,7 +85,7 @@ Comment:
 
     def process(self, tx, txs):
         try:
-            hdc.transactions.Process().post(transaction=tx, signature=txs)
+            hdc.transactions.Process(self.server, self.port).post(transaction=tx, signature=txs)
         except ValueError as e:
             self.error = str(e)
         else:
@@ -97,7 +99,7 @@ Comment:
             data = coin.split(':')
             issuer, numbers = data[0], data[1:]
             for number in numbers:
-                view = hdc.coins.View(issuer, int(number)).get()
+                view = hdc.coins.View(issuer, int(number), self.server, self.port).get()
                 if view['owner'] != self.pgp_fingerprint:
                     raise ValueError('Trying to divide a coin you do not own (%s)' % view['id'])
                 coins.append(view)
@@ -115,8 +117,9 @@ Comment:
         if not m: raise ValueError('bad sum value %d' % __sum)
 
 class Transfer(Transaction):
-    def __init__(self, pgp_fingerprint, recipient, coins, message=''):
-        super().__init__('TRANSFER', pgp_fingerprint, message)
+    def __init__(self, pgp_fingerprint, recipient, coins, message='', server=None, port=None):
+        super().__init__('TRANSFER', pgp_fingerprint, message, server, port)
+
         self.recipient = recipient
         self.coins = coins
 
@@ -133,7 +136,7 @@ Coins:
             data = coin.split(':')
             issuer = data[0]
             for number in data[1:]:
-                context_data.update(hdc.coins.View(issuer, int(number)).get())
+                context_data.update(hdc.coins.View(issuer, int(number), self.server, self.port).get())
                 tx += '%(id)s, %(transaction)s\n' % context_data
 
         return tx
@@ -154,7 +157,7 @@ Coins:
 """ % context_data
 
         try:
-            last_issuance = hdc.transactions.sender.issuance.Last(self.pgp_fingerprint).get()
+            last_issuance = hdc.transactions.sender.issuance.Last(self.pgp_fingerprint, self.server, self.port).get()
         except ValueError:
             last_issuance = None
 
@@ -168,8 +171,9 @@ Coins:
         return tx
 
 class Issue(MonoTransaction):
-    def __init__(self, pgp_fingerprint, amendment, coins, message=''):
-        super().__init__('ISSUANCE', pgp_fingerprint, message)
+    def __init__(self, pgp_fingerprint, amendment, coins, message='', server=None, port=None):
+        super().__init__('ISSUANCE', pgp_fingerprint, message, server, port)
+
         self.amendment = amendment
         self.coins = coins
 
@@ -184,8 +188,9 @@ class Issue(MonoTransaction):
         return tx
 
 class Fusion(MonoTransaction):
-    def __init__(self, pgp_fingerprint, coins, message=''):
-        super().__init__('FUSION', pgp_fingerprint, message)
+    def __init__(self, pgp_fingerprint, coins, message='', server=None, port=None):
+        super().__init__('FUSION', pgp_fingerprint, message, server, port)
+
         self.coins = coins
 
     def get_mono_message(self, context_data, tx=''):
@@ -200,8 +205,9 @@ class Fusion(MonoTransaction):
         return tx
 
 class Divide(MonoTransaction):
-    def __init__(self, pgp_fingerprint, old_coins, new_coins, message=''):
-        super().__init__('DIVISION', pgp_fingerprint, message)
+    def __init__(self, pgp_fingerprint, old_coins, new_coins, message='', server=None, port=None):
+        super().__init__('DIVISION', pgp_fingerprint, message, server, port)
+
         self.old_coins = old_coins
         self.new_coins = new_coins
 
-- 
GitLab