In every contract of guarantee there is an implied promise by the principal debtor to indemnify the surety; and the surety is entitled to recover from the principal debtor whatever sum he has rightfully paid under the guarantee, but no sums which he has paid wrongfully.
Illustrations
(a) B is indebted to C, and A is surety for the debt. C sues B, and obtains a decree. C then sues A and A, not having been informed of the suit by C against B, defends the suit and loses it. A is entitled to recover from B the amount of the decree against him, with costs, together with all costs of the unsuccessful defence.
(b) C lends B a sum of money, and A, at the request of B, accepts a bill of exchange drawn by B upon A to secure the amount. C, the holder of the bill, does not present it for payment, but sues A upon it. A, not knowing that the bill has not been presented, does not plead the non-presentation, and pays the amount. A cannot recover from B the amount paid, since the payment was wrongful.